PageRenderTime 53ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/source/Plug-in/xajax/xajax_controls/document.inc.php

http://prosporous.googlecode.com/
PHP | 323 lines | 237 code | 55 blank | 31 comment | 56 complexity | 43a6457b18785af48c80f8451809f66e MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. /*
  3. File: document.inc.php
  4. HTML Control Library - Document Level Tags
  5. Title: xajax HTML control class library
  6. Please see <copyright.inc.php> for a detailed description, copyright
  7. and license information.
  8. */
  9. /*
  10. @package xajax
  11. @version $Id: document.inc.php 362 2007-05-29 15:32:24Z calltoconstruct $
  12. @copyright Copyright (c) 2005-2006 by Jared White & J. Max Wilson
  13. @license http://www.xajaxproject.org/bsd_license.txt BSD License
  14. */
  15. /*
  16. Section: Description
  17. This file contains the class declarations for the following HTML Controls:
  18. - document, doctype, html, head, body
  19. - meta, link, script, style
  20. - title, base
  21. - noscript
  22. - frameset, frame, iframe, noframes
  23. The following controls are deprecated as of HTML 4.01, so they will not be supported:
  24. - basefont
  25. */
  26. class clsDocument extends xajaxControlContainer
  27. {
  28. function clsDocument($aConfiguration=array())
  29. {
  30. if (isset($aConfiguration['attributes']))
  31. trigger_error(
  32. 'clsDocument objects cannot have attributes.'
  33. . $this->backtrace(),
  34. E_USER_ERROR);
  35. xajaxControlContainer::xajaxControlContainer('DOCUMENT', $aConfiguration);
  36. $this->sClass = '%block';
  37. }
  38. function printHTML()
  39. {
  40. $tStart = microtime();
  41. $this->_printChildren();
  42. $tStop = microtime();
  43. echo '<' . '!--';
  44. echo ' page generation took ';
  45. $nTime = $tStop - $tStart;
  46. $nTime *= 1000;
  47. echo $nTime;
  48. echo ' --' . '>';
  49. }
  50. }
  51. class clsDoctype extends xajaxControlContainer
  52. {
  53. var $sText;
  54. var $sFormat;
  55. var $sVersion;
  56. var $sValidation;
  57. var $sEncoding;
  58. function clsDocType($sFormat=null, $sVersion=null, $sValidation=null, $sEncoding='UTF-8')
  59. {
  60. if (null === $sFormat && false == defined('XAJAX_HTML_CONTROL_DOCTYPE_FORMAT'))
  61. trigger_error('You must specify a doctype format.', E_USER_ERROR);
  62. if (null === $sVersion && false == defined('XAJAX_HTML_CONTROL_DOCTYPE_VERSION'))
  63. trigger_error('You must specify a doctype version.', E_USER_ERROR);
  64. if (null === $sValidation && false == defined('XAJAX_HTML_CONTROL_DOCTYPE_VALIDATION'))
  65. trigger_error('You must specify a doctype validation.', E_USER_ERROR);
  66. if (null === $sFormat)
  67. $sFormat = XAJAX_HTML_CONTROL_DOCTYPE_FORMAT;
  68. if (null === $sVersion)
  69. $sVersion = XAJAX_HTML_CONTROL_DOCTYPE_VERSION;
  70. if (null === $sValidation)
  71. $sValidation = XAJAX_HTML_CONTROL_DOCTYPE_VALIDATION;
  72. xajaxControlContainer::xajaxControlContainer('DOCTYPE', array());
  73. $this->sText = '<'.'!DOCTYPE html PUBLIC "-//W3C//DTD ';
  74. $this->sText .= $sFormat;
  75. $this->sText .= ' ';
  76. $this->sText .= $sVersion;
  77. if ('TRANSITIONAL' == $sValidation)
  78. $this->sText .= ' Transitional';
  79. else if ('FRAMESET' == $sValidation)
  80. $this->sText .= ' Frameset';
  81. $this->sText .= '//EN" ';
  82. if ('HTML' == $sFormat) {
  83. if ('4.0' == $sVersion) {
  84. if ('STRICT' == $sValidation)
  85. $this->sText .= '"http://www.w3.org/TR/html40/strict.dtd"';
  86. else if ('TRANSITIONAL' == $sValidation)
  87. $this->sText .= '"http://www.w3.org/TR/html40/loose.dtd"';
  88. } else if ('4.01' == $sVersion) {
  89. if ('STRICT' == $sValidation)
  90. $this->sText .= '"http://www.w3.org/TR/html401/strict.dtd"';
  91. else if ('TRANSITIONAL' == $sValidation)
  92. $this->sText .= '"http://www.w3.org/TR/html401/loose.dtd"';
  93. else if ('FRAMESET' == $sValidation)
  94. $this->sText .= '"http://www.w3.org/TR/html4/frameset.dtd"';
  95. }
  96. } else if ('XHTML' == $sFormat) {
  97. if ('1.0' == $sVersion) {
  98. if ('STRICT' == $sValidation)
  99. $this->sText .= '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"';
  100. else if ('TRANSITIONAL' == $sValidation)
  101. $this->sText .= '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"';
  102. } else if ('1.1' == $sVersion) {
  103. $this->sText .= '"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"';
  104. }
  105. } else
  106. trigger_error('Unsupported DOCTYPE tag.'
  107. . $this->backtrace(),
  108. E_USER_ERROR
  109. );
  110. $this->sText .= '>';
  111. $this->sFormat = $sFormat;
  112. $this->sVersion = $sVersion;
  113. $this->sValidation = $sValidation;
  114. $this->sEncoding = $sEncoding;
  115. }
  116. function printHTML($sIndent='')
  117. {
  118. header('content-type: text/html; charset=' . $this->sEncoding);
  119. if ('XHTML' == $this->sFormat)
  120. print '<' . '?' . 'xml version="1.0" encoding="' . $this->sEncoding . '" ' . '?' . ">\n";
  121. print $this->sText;
  122. print "\n";
  123. xajaxControlContainer::_printChildren($sIndent);
  124. }
  125. }
  126. class clsHtml extends xajaxControlContainer
  127. {
  128. function clsHtml($aConfiguration=array())
  129. {
  130. xajaxControlContainer::xajaxControlContainer('html', $aConfiguration);
  131. $this->sClass = '%block';
  132. $this->sEndTag = 'optional';
  133. }
  134. }
  135. class clsHead extends xajaxControlContainer
  136. {
  137. var $objXajax;
  138. function clsHead($aConfiguration=array())
  139. {
  140. $this->objXajax = null;
  141. if (isset($aConfiguration['xajax']))
  142. $this->setXajax($aConfiguration['xajax']);
  143. xajaxControlContainer::xajaxControlContainer('head', $aConfiguration);
  144. $this->sClass = '%block';
  145. $this->sEndTag = 'optional';
  146. }
  147. function setXajax(&$objXajax)
  148. {
  149. $this->objXajax =& $objXajax;
  150. }
  151. function _printChildren($sIndent='')
  152. {
  153. if (null != $this->objXajax)
  154. $this->objXajax->printJavascript();
  155. xajaxControlContainer::_printChildren($sIndent);
  156. }
  157. }
  158. class clsBody extends xajaxControlContainer
  159. {
  160. function clsBody($aConfiguration=array())
  161. {
  162. xajaxControlContainer::xajaxControlContainer('body', $aConfiguration);
  163. $this->sClass = '%block';
  164. $this->sEndTag = 'optional';
  165. }
  166. }
  167. class clsScript extends xajaxControlContainer
  168. {
  169. function clsScript($aConfiguration=array())
  170. {
  171. xajaxControlContainer::xajaxControlContainer('script', $aConfiguration);
  172. $this->sClass = '%block';
  173. }
  174. }
  175. class clsStyle extends xajaxControlContainer
  176. {
  177. function clsStyle($aConfiguration=array())
  178. {
  179. xajaxControlContainer::xajaxControlContainer('style', $aConfiguration);
  180. $this->sClass = '%block';
  181. }
  182. }
  183. class clsLink extends xajaxControl
  184. {
  185. function clsLink($aConfiguration=array())
  186. {
  187. xajaxControl::xajaxControl('link', $aConfiguration);
  188. $this->sClass = '%block';
  189. }
  190. }
  191. class clsMeta extends xajaxControl
  192. {
  193. function clsMeta($aConfiguration=array())
  194. {
  195. xajaxControl::xajaxControl('meta', $aConfiguration);
  196. $this->sClass = '%block';
  197. }
  198. }
  199. class clsTitle extends xajaxControlContainer
  200. {
  201. function clsTitle($aConfiguration=array())
  202. {
  203. xajaxControlContainer::xajaxControlContainer('title', $aConfiguration);
  204. $this->sClass = '%block';
  205. }
  206. function setEvent($sEvent, &$objRequest)
  207. {
  208. trigger_error(
  209. 'clsTitle objects do not support events.'
  210. . $this->backtrace(),
  211. E_USER_ERROR);
  212. }
  213. }
  214. class clsBase extends xajaxControl
  215. {
  216. function clsBase($aConfiguration=array())
  217. {
  218. xajaxControl::xajaxControl('base', $aConfiguration);
  219. $this->sClass = '%block';
  220. }
  221. }
  222. class clsNoscript extends xajaxControlContainer
  223. {
  224. function clsNoscript($aConfiguration=array())
  225. {
  226. xajaxControlContainer::xajaxControlContainer('noscript', $aConfiguration);
  227. $this->sClass = '%flow';
  228. }
  229. }
  230. class clsIframe extends xajaxControlContainer
  231. {
  232. function clsIframe($aConfiguration=array())
  233. {
  234. xajaxControlContainer::xajaxControlContainer('iframe', $aConfiguration);
  235. $this->sClass = '%block';
  236. }
  237. }
  238. class clsFrameset extends xajaxControlContainer
  239. {
  240. function clsFrameset($aConfiguration=array())
  241. {
  242. xajaxControlContainer::xajaxControlContainer('frameset', $aConfiguration);
  243. $this->sClass = '%block';
  244. }
  245. }
  246. class clsFrame extends xajaxControl
  247. {
  248. function clsFrame($aConfiguration=array())
  249. {
  250. xajaxControl::xajaxControl('frame', $aConfiguration);
  251. $this->sClass = '%block';
  252. }
  253. }
  254. class clsNoframes extends xajaxControlContainer
  255. {
  256. function clsNoframes($aConfiguration=array())
  257. {
  258. xajaxControlContainer::xajaxControlContainer('noframes', $aConfiguration);
  259. $this->sClass = '%flow';
  260. }
  261. }