/fmake/libs/xajax/xajax_controls/document.inc.php

https://github.com/fmake/adv · PHP · 324 lines · 237 code · 55 blank · 32 comment · 56 complexity · f8c744a50e52feb916647faffff09dfa MD5 · raw file

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