`
we1818
  • 浏览: 60444 次
  • 性别: Icon_minigender_1
  • 来自: 湖州
社区版块
存档分类
最新评论

joomla 1.5——JDocument类用法

    博客分类:
  • php
阅读更多
文档类,提供一个容易的接口解析和显示文件 
       
Method        Description
__construct        构造函数
addScript        增加一个连接到页
addScriptDeclaration        增加脚本到页
addStyleDeclaration        增加一个stylesheet声明到页
addStyleSheet        增加一连接的stylesheet到页
getBase        返回本文的基本URI
getBuffer        得到本文缓冲的内容
getCharset        返回本文charset 内码
getDescription        返回页的标题
getDirection        返回文件语言
getGenerator        返回文档创建者
getHeadData        得到本文头数据
getInstance        返回在全局 JDocument对象
getLanguage        得到语言.
getLink        得到文档的URL
getMetaData        得到meta标签
getTitle        得到文档标题
getType        得到文档类型
loadRenderer        随机装载
render        输出文档
setBase        设置文档的e基本URI
setBuffer        设置本文缓冲的内容
setCharset        设置本文charset
setDescription        设置本文的描述
setDirection         设置全局文件声明。 缺省左到右(ltr)。 
setGenerator        设置文本创建者
setHeadData        设置文本头信息
setLanguage        设置语言.
setLineEnd         设置线结尾样式对Windows、Mac、Unix或者自定义串。 
setLink        设置文档链接
setMetaData        设置metai标签
setMimeEncoding        设置被送到浏览器的本文MIME内码
setModifiedData        定本文修改过的日期
setTab        设置串被用于内嵌HTML
setTitle        设置文档标题
setType        设置文档类型.

方法应用:

addScript()
        意义:增加一个连接到页
        语法:void addScript (string $url, [string $type = "text/javascript"])
                string $url: URL to the linked script
                string $type: Type of script. Defaults to 'text/javascript'
        实际应用:
        $temp =& Jfactory::getDocument();
        $temp->addscript(JURI::base().'includes/js/overlib_mini.js');
        结果:在head部分插入一段js


addScriptDeclaration()
        意义:增加脚本到页头
        语法:void addScriptDeclaration (string $content, [string $type = 'text/javascript'])
                string $content: Script
                string $type: Scripting mime (defaults to 'text/javascript')
        实际应用:
        $temp =& Jfactory::getDocument();
        $script = "alert( 'A script has been added to the page!' );";
        $temp->addScriptDeclaration($scirpt);


getBase()
        意义:返回本文的基本URI
        语法:string getBase ()
        实际应用:
        $temp =& Jfactory::getDocument();
        echo $temp->getBase();


getBuffer()
        意义:得到本文缓冲的内容
        语法: getBuffer ()
        实际应用:
        $temp =& Jfactory::getDocument();
        echo $temp->getBuffer();


getInstance()
        意义:返回在全局JDocument对象
        语法:object The &getInstance ([type $type = 'html'], [ $attributes = array()])
                type $type: The document type to instantiate
                $attributes
        实际应用:
        $temp =& Jfactory::getDocument();
        $temp->getInstance('html'); //生成jdocumenthtml对象.
        $temp->getInstance('error');//生成 jdocumenterror对象.
        $temp->getInstance('feed');//生成 jdocumentfeed对象.
       



setBuffer()
        意义:设置本文缓冲的内容
        语法:void setBuffer (string $content)
                string $content: The content to be set in the buffer
        实际应用:
        $temp =& Jfactory::getDocument();
        echo $temp->setBuffer();




setDirection()
        意义: 设置全局文件声明。 缺省左到右(ltr)。 
        语法:void setDirection ([ $dir = "ltr"], string $lang)
                string $lang
                $dir
        实际应用:
        $temp =& Jfactory::getDocument();
        echo $temp->setDirection();


setGenerator()
        意义: 设置文本创建者
        语法:void setGenerator (string $generator)
                string $generator
        实际应用:
        $temp =& Jfactory::getDocument();
        echo $temp->setGenerator();


setHeadData()
        意义: 设置文本头信息
        语法:void setHeadData (array $data)
                array $data: The document head data in array form
        实际应用:
        $temp =& Jfactory::getDocument();
        echo $temp->setHeadData();


setLanguage()
        意义: 设置语言
        语法:void setLanguage ([string $lang = "en-gb"])
                string $lang
        实际应用:
        $temp =& Jfactory::getDocument();
        echo $temp->setLanguage();






setLineEnd()
        意义: 设置线结尾样式对Windows、Mac、Unix或者自定义串。
        语法:void setLineEnd (string $style)
                string $style: "win", "mac", "unix" or custom string.
        实际应用:
        $temp =& Jfactory::getDocument();
        echo $temp->setLineEnd();


setLink()
        意义: 设置文档链接
        语法:void setLink (string $url)
                string $url: A url
        实际应用:
        $temp =& Jfactory::getDocument();
        $link=”www.joomla.org”;
        $temp->setLink($link);



setMetaData()
        意义: 设置meta标签
        语法:void setMetaData (string $name, string $content, [bool $http_equiv = false])
                string $name: Value of name or http-equiv tag
                string $content: Value of the content tag
                bool $http_equiv: META type "http-equiv" defaults to null
        实际应用:
        $temp =& Jfactory::getDocument();
        $temp->setMetaData('Publisher', 'joomla! Documentation Team!');
        result:
        <meta name="Publisher" content="Joomla! Documentation Team" />


setMimeEncoding()
        意义: 设置被送到浏览器的本文MIME内码
        语法:void setMimeEncoding ([string $type = 'text/html'])
                string $type.
        实际应用:
        $temp =& Jfactory::getDocument();
        $temp->setMimrEncoding('application/xml'));


setModifiedDate()
        意义: 定本文修改过的日期
        语法:void setModifiedDate (string $date)
                string $date
        实际应用:
        $temp =& Jfactory::getDocument();
        $temp->setModifiedDate($date));
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics