cvs: pear /HTML_Page Page.php

From: Date: Sat, 12 Jul 2003 06:33:46 +0000
Subject: cvs: pear /HTML_Page Page.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-11449@lists.php.net to get a copy of this message
thesaur Sat Jul 12 02:33:46 2003 EDT Modified files: /pear/HTML_Page Page.php Log: allow MIME encoding declaration (still needs a little work) Index: pear/HTML_Page/Page.php diff -u pear/HTML_Page/Page.php:1.9 pear/HTML_Page/Page.php:1.10 --- pear/HTML_Page/Page.php:1.9 Wed Jul 9 04:50:41 2003 +++ pear/HTML_Page/Page.php Sat Jul 12 02:33:46 2003 @@ -17,7 +17,7 @@ // | Klaus Guenther <klaus@capitalfocus.org> | // +----------------------------------------------------------------------+ // -// $Id: Page.php,v 1.9 2003/07/09 08:50:41 thesaur Exp $ +// $Id: Page.php,v 1.10 2003/07/12 06:33:46 thesaur Exp $ require_once 'PEAR.php'; require_once 'HTML/Common.php'; @@ -200,6 +200,14 @@ var $_metaTags = array( 'standard' => array ( 'Generator' => 'PEAR HTML_Page' ) ); /** + * Document mime type + * + * @var string + * @access private + */ + var $_mime = 'text/html'; + + /** * Array of linked scripts * * @var array @@ -244,9 +252,10 @@ * 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.) + * - "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" => mixed (Sets XHTML doctype; defaults to XHTML 1.0 Transitional.) * - "language" => two letter language designation. (Defines global document language; defaults to "en".) @@ -287,6 +296,10 @@ $this->setLang($attributes['language']); } + if (isset($attributes['mime'])) { + $this->setMimeEncoding($attributes['mime']); + } + if (isset($attributes['cache'])) { $this->setCache($attributes['cache']); } @@ -754,6 +767,20 @@ } // end func setMetaRefresh /** + * Sets the document MIME encoding that is sent to the browser. + * + * @param string $type + * @access public + * @returns void + */ + function setMimeEncoding($type = 'text/html') + { + $this->_mime = $type; + // adds an http-equiv meta tag declaration + $this->setMetaData('Content-type', $type . '; ' . $this->_charset , true ); + } // end func setMimeEncoding + + /** * Sets the title of the page * * @param string $title @@ -780,17 +807,24 @@ // get the doctype declaration $strDoctype = $this->_getDoctype(); - // + // This determines how the doctype is declared if ($this->_simple) { + $strHtml = '<html>' . $lnEnd; + } elseif ($this->_doctype['type'] == 'xhtml') { + $strHtml = '<?xml version="1.0" encoding="' . $this->_charset . '"?>' . $lnEnd; $strHtml .= $strDoctype . $lnEnd; $strHtml .= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="'.$this->_language.'">'; + } else { + $strHtml = $strDoctype . $lnEnd; $strHtml .= '<html>' . $lnEnd; + } + $strHtml .= $this->_generateHead(); $strHtml .= $this->_generateBody(); $strHtml .= '</html>'; @@ -812,7 +846,7 @@ } // set character encoding - header("Content-Type: text/html; charset=" . $this->_charset); + header('Content-Type: ' . $this->_mime . '; charset=' . $this->_charset); $strHtml = $this->toHTML(); print $strHtml;

« previous php.pear.cvs (#11449) next »