page.php

来自「视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.」· PHP 代码 · 共 1,112 行 · 第 1/3 页

PHP
1,112
字号
<?php/* vim: set expandtab tabstop=4 shiftwidth=4: */// +----------------------------------------------------------------------+// | PHP Version 4                                                        |// +----------------------------------------------------------------------+// | Copyright (c) 1997 - 2003 The PHP Group                              |// +----------------------------------------------------------------------+// | This source file is subject to version 3.0 of the PHP license,       |// | that is bundled with this package in the file LICENSE, and is        |// | available at through the world-wide-web at                           |// | http://www.php.net/license/3_0.txt.                                  |// | If you did not receive a copy of the PHP license and are unable to   |// | obtain it through the world-wide-web, please send a note to          |// | license@php.net so we can mail you a copy immediately.               |// +----------------------------------------------------------------------+// | Authors: Adam Daniel <adaniel1@eesus.jnj.com>                        |// |          Klaus Guenther <klaus@capitalfocus.org>                     |// +----------------------------------------------------------------------+//// $Id: Page.php,v 1.26 2003/10/16 15:04:49 thesaur Exp $require_once 'PEAR.php';require_once 'HTML/Common.php';// HTML/Page/Doctypes.php is required in _getDoctype()// HTML/Page/Namespaces.php is required in _getNamespace()/** * Base class for XHTML pages * * This class handles the details for creating a properly constructed XHTML page. * Page caching, stylesheets, client side script, and Meta tags can be * managed using this class. *  * The body may be a string, object, or array of objects or strings. Objects with * toHtml() and toString() methods are supported. *  * * XHTML Examples: * --------------- * * Simplest example: * ----------------- * <code> * // the default doctype is XHTML 1.0 Transitional * // All doctypes and defaults are set in HTML/Page/Doctypes.php * $p = new HTML_Page(); * * //add some content * $p->addBodyContent("<p>some text</p>"); * * // print to browser * $p->display(); * </code> *  * Complex XHTML example: * ---------------------- * <code> * // The initializing code can also be in in the form of an HTML * // attr="value" string. * // Possible attributes are: charset, mime, lineend, tab, doctype, namespace, language and cache *  * $p = new HTML_Page(array ( * *                          // Sets the charset encoding *                          // utf-8 is default *                          'charset'  => 'utf-8', * *                          // Sets the line end character *                          // unix (\n) is default *                          'lineend'  => 'unix', * *                          // Sets the tab string for autoindent *                          // tab (\t) is default *                          'tab'  => '  ', * *                          // This is where you define the doctype *                          'doctype'  => "XHTML 1.0 Strict", * *                          // Global page language setting *                          'language' => 'en', * *                          // If cache is set to true, the browser may *                          // cache the output. Else  *                          'cache'    => 'false' *                          )); * * // Here we go * * // Set the page title * $p->setTitle("My page"); *  * // Add optional meta data * $p->setMetaData("author", "My Name"); *  * // Put something into the body * $p->addBodyContent = "<p>some text</p>"; * * // If at some point you want to clear the page content * // and output an error message, you can easily do that * // See the source for {@link toHtml} and {@link _getDoctype} * // for more details * if ($error) { *     $p->setTitle("Error!"); *     $p->setBodyContent("<p>Houston, we have a problem: $error</p>"); *     $p->display(); *     die; * } // end error handling * * // print to browser * $p->display(); * // output to file * $p->toFile('example.html'); * </code> *  * Simple XHTML declaration example: * <code> * $p = new HTML_Page(); * // An XHTML compliant page (with title) is automatically generated * * // This overrides the XHTML 1.0 Transitional default * $p->setDoctype('XHTML 1.0 Strict'); *  * // Put some content in here * $p->addBodyContent("<p>some text</p>"); * * // print to browser * $p->display(); * </code> *  * * HTML examples: * -------------- * * HTML 4.01 example: * ------------------ * <code> * $p = new HTML_Page('doctype="HTML 4.01 Strict"'); * $p->addBodyContent = "<p>some text</p>"; * $p->display(); * </code> *  * nuke doctype declaration: * ------------------------- * <code> * $p = new HTML_Page('doctype="none"'); * $p->addBodyContent = "<p>some text</p>"; * $p->display(); * </code> *  * @author       Adam Daniel <adaniel1@eesus.jnj.com> * @author       Klaus Guenther <klaus@capitalfocus.org> * @package      HTML_Page * @version      2.0 * @since        PHP 4.0.3pl1 */class HTML_Page extends HTML_Common {        /**     * Contains the content of the &lt;body&gt; tag.     *      * @var     array     * @access  private     */    var $_body = array();        /**     * Controls caching of the page     *      * @var     bool     * @access  private     */    var $_cache = false;        /**     * Contains the character encoding string     *      * @var     string     * @access  private     */    var $_charset = 'utf-8';        /**     * Contains the !DOCTYPE definition     *      * @var array     * @access private     */    var $_doctype = array('type'=>'xhtml','version'=>'1.0','variant'=>'transitional');        /**     * Contains the page language setting     *      * @var     string     * @access  private     */    var $_language = 'en';        /**     * Array of meta tags     *      * @var     array     * @access  private     */    var $_metaTags = array( 'standard' => array ( 'Generator' => 'PEAR HTML_Page' ) );        /**     * Document mime type     *      * @var  string     * @access   private     */    var $_mime = 'text/html';        /**     * Document namespace     *      * @var  string     * @access   private     */    var $_namespace = '';        /**     * Array of linked scripts     *      * @var  array     * @access   private     */    var $_scripts = array();        /**     * Array of scripts placed in the header     *      * @var  array     * @access   private     */    var $_script = array();        /**     * Array of linked scripts     *      * @var     array     * @access  private     */    var $_simple = false;        /**     * Array of included style declarations     *      * @var     array     * @access  private     */    var $_style = array();        /**     * Array of linked style sheets     *      * @var     array     * @access  private     */    var $_styleSheets = array();        /**     * HTML page title     *      * @var     string     * @access  private     */    var $_title = '';        /**     * Defines whether XML prolog should be prepended to XHTML documents     *      * @var  bool     * @access   private     */    var $_xmlProlog = true;        /**     * Class constructor     * Possible attributes are:     * - general options:     *     - "lineend" => "unix|win|mac" (Sets line ending style; defaults to unix.)     *     - "tab"     => string (Sets line ending style; defaults to \t.)     *     - "cache"   => "false|true"     *     - "charset" => charset string (Sets charset encoding; defaults to utf-8)     *     - "mime"    => mime encoding string (Sets document mime type; defaults to text/html)     * - XHTML specific:     *     - "doctype"  => string (Sets XHTML doctype; defaults to XHTML 1.0 Transitional.)     *     - "language" => two letter language designation. (Defines global document language; defaults to "en".)     *     - "namespace"  => string (Sets document namespace; defaults to the W3C defined namespace.)     *      * @param   mixed   $attributes     Associative array of table tag attributes     *                                  or HTML attributes name="value" pairs     * @access  public     */    function HTML_Page($attributes = array())    {        $commonVersion = 1.7;        if (HTML_Common::apiVersion() < $commonVersion) {            return PEAR::raiseError("HTML_Page version " . $this->apiVersion() . " requires " .                "HTML_Common version 1.2 or greater.", 0, PEAR_ERROR_TRIGGER);        }                if ($attributes) {            $attributes = $this->_parseAttributes($attributes);        }                if (isset($attributes['lineend'])) {            $this->setLineEnd($attributes['lineend']);        }                if (isset($attributes['charset'])) {            $this->setCharset($attributes['charset']);        }                if (isset($attributes['doctype'])){            if ($attributes['doctype'] == 'none') {                $this->_simple = true;            } elseif ($attributes['doctype']) {                $this->setDoctype($attributes['doctype']);            }        }                if (isset($attributes['language'])) {            $this->setLang($attributes['language']);        }                if (isset($attributes['mime'])) {            $this->setMimeEncoding($attributes['mime']);        }                if (isset($attributes['namespace'])) {            $this->setNamespace($attributes['namespace']);        }                if (isset($attributes['tab'])) {            $this->setTab($attributes['tab']);        }                if (isset($attributes['cache'])) {            $this->setCache($attributes['cache']);        }            }        /**     * Generates the HTML string for the &lt;body&lt; tag     *      * @access  private     * @return  string     */    function _generateBody()    {                // get line endings        $lnEnd = $this->_getLineEnd();        $tab = $this->_getTab();                // If body attributes exist, add them to the body tag.        // Depreciated because of CSS        $strAttr = $this->_getAttrString($this->_attributes);                if ($strAttr) {            $strHtml = "<body $strAttr>" . $lnEnd;        } else {            $strHtml = '<body>' . $lnEnd;        }                // Allow for mixed content in the body array        // Iterate through the array and process each element        foreach ($this->_body as $element) {

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?