PageRenderTime 55ms CodeModel.GetById 29ms RepoModel.GetById 1ms app.codeStats 0ms

/www/_bshe/xajax/tests/suite/css.php

https://github.com/yuiti/Bshe
PHP | 256 lines | 213 code | 33 blank | 10 comment | 4 complexity | e34da624e3c07b702771a2f4ae7c675e MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. /*
  3. File: css.php
  4. Test script that uses <xajaxResponse->includeCSS> and <xajaxResponse->removeCSS>
  5. to effect the active style information on the page dynamically.
  6. */
  7. error_reporting(E_ALL^E_NOTICE);
  8. ini_set("display_errors", 1);
  9. require_once("./options.inc.php");
  10. require_once('./testScriptPlugin.inc.php');
  11. $objResponse = new xajaxResponse();
  12. class clsFunctions {
  13. function clsFunctions() {
  14. }
  15. function loadCSS1() {
  16. global $objResponse;
  17. $objResponse->includeCSS('css1.css');
  18. $objResponse->append('log', 'innerHTML', 'CSS1 loaded.<br />');
  19. return $objResponse;
  20. }
  21. function unloadCSS1() {
  22. global $objResponse;
  23. $objResponse->removeCSS('css1.css');
  24. $objResponse->append('log', 'innerHTML', 'CSS1 unloaded.<br />');
  25. return $objResponse;
  26. }
  27. function loadCSS2() {
  28. global $objResponse;
  29. $objResponse->includeCSS('css2.css');
  30. $objResponse->append('log', 'innerHTML', 'CSS2 loaded.<br />');
  31. return $objResponse;
  32. }
  33. function unloadCSS2() {
  34. global $objResponse;
  35. $objResponse->removeCSS('css2.css');
  36. $objResponse->append('log', 'innerHTML', 'CSS2 unloaded.<br />');
  37. return $objResponse;
  38. }
  39. function loadCSS1_Print() {
  40. global $objResponse;
  41. $objResponse->includeCSS('css3.css');
  42. $objResponse->includeCSS('css1.css', 'print');
  43. $objResponse->append('log', 'innerHTML', 'CSS1 loaded for Print media.<br />');
  44. return $objResponse;
  45. }
  46. function unloadCSS1_Print() {
  47. global $objResponse;
  48. $objResponse->removeCSS('css3.css');
  49. $objResponse->removeCSS('css1.css', 'print');
  50. $objResponse->append('log', 'innerHTML', 'CSS1 unloaded for Print media.<br />');
  51. return $objResponse;
  52. }
  53. function loadCSS2_Print() {
  54. global $objResponse;
  55. $objResponse->includeCSS('css4.css');
  56. $objResponse->includeCSS('css2.css', 'print');
  57. $objResponse->append('log', 'innerHTML', 'CSS2 loaded for Print media.<br />');
  58. return $objResponse;
  59. }
  60. function unloadCSS2_Print() {
  61. global $objResponse;
  62. $objResponse->removeCSS('css4.css');
  63. $objResponse->removeCSS('css2.css', 'print');
  64. $objResponse->append('log', 'innerHTML', 'CSS2 unloaded for Print media.<br />');
  65. return $objResponse;
  66. }
  67. }
  68. $functions = new clsFunctions();
  69. $aFunctions = $xajax->register(XAJAX_CALLABLE_OBJECT, $functions);
  70. $xajax->processRequest();
  71. $sRoot = dirname(dirname(dirname(__FILE__)));
  72. if (false == class_exists('xajaxControl')) {
  73. $sCore = '/xajax_core';
  74. include_once($sRoot . $sCore . '/xajaxControl.inc.php');
  75. }
  76. $sControls = '/xajax_controls';
  77. include_once($sRoot . $sControls . '/document.inc.php');
  78. include_once($sRoot . $sControls . '/content.inc.php');
  79. include_once($sRoot . $sControls . '/group.inc.php');
  80. include_once($sRoot . $sControls . '/form.inc.php');
  81. include_once($sRoot . $sControls . '/misc.inc.php');
  82. $buttonLoadCSS1 = new clsButton(array(
  83. 'attributes' => array(
  84. 'class' => 'loadCSS1',
  85. 'id' => 'loadCSS1'
  86. ),
  87. 'children' => array(new clsLiteral('Load CSS 1')),
  88. 'event' => array('onclick', $aFunctions['loadcss1'])
  89. ));
  90. $buttonUnloadCSS1 = new clsButton(array(
  91. 'attributes' => array(
  92. 'class' => 'initiallyHidden unloadCSS1',
  93. 'id' => 'unloadCSS1'
  94. ),
  95. 'children' => array(new clsLiteral('Unload CSS 1')),
  96. 'event' => array('onclick', $aFunctions['unloadcss1'])
  97. ));
  98. $buttonLoadCSS2 = new clsButton(array(
  99. 'attributes' => array(
  100. 'class' => 'loadCSS2',
  101. 'id' => 'loadCSS2'
  102. ),
  103. 'children' => array(new clsLiteral('Load CSS 2')),
  104. 'event' => array('onclick', $aFunctions['loadcss2'])
  105. ));
  106. $buttonUnloadCSS2 = new clsButton(array(
  107. 'attributes' => array(
  108. 'class' => 'initiallyHidden unloadCSS2',
  109. 'id' => 'unloadCSS2'
  110. ),
  111. 'children' => array(new clsLiteral('Unload CSS 2')),
  112. 'event' => array('onclick', $aFunctions['unloadcss2'])
  113. ));
  114. $buttonLoadCSS1_Print = new clsButton(array(
  115. 'attributes' => array(
  116. 'class' => 'loadCSS1_Print',
  117. 'id' => 'loadCSS1_Print'
  118. ),
  119. 'children' => array(new clsLiteral('Load CSS 1 (print)')),
  120. 'event' => array('onclick', $aFunctions['loadcss1_print'])
  121. ));
  122. $buttonUnloadCSS1_Print = new clsButton(array(
  123. 'attributes' => array(
  124. 'class' => 'initiallyHidden unloadCSS1_Print',
  125. 'id' => 'unloadCSS1_Print'
  126. ),
  127. 'children' => array(new clsLiteral('Unload CSS 1 (print)')),
  128. 'event' => array('onclick', $aFunctions['unloadcss1_print'])
  129. ));
  130. $buttonLoadCSS2_Print = new clsButton(array(
  131. 'attributes' => array(
  132. 'class' => 'loadCSS2_Print',
  133. 'id' => 'loadCSS2_Print'
  134. ),
  135. 'children' => array(new clsLiteral('Load CSS 2 (print)')),
  136. 'event' => array('onclick', $aFunctions['loadcss2_print'])
  137. ));
  138. $buttonUnloadCSS2_Print = new clsButton(array(
  139. 'attributes' => array(
  140. 'class' => 'initiallyHidden unloadCSS2_Print',
  141. 'id' => 'unloadCSS2_Print'
  142. ),
  143. 'children' => array(new clsLiteral('Unload CSS 2 (print)')),
  144. 'event' => array('onclick', $aFunctions['unloadcss2_print'])
  145. ));
  146. ob_start();
  147. ?>
  148. <script type='text/javascript'>
  149. /* <![CDATA[ */
  150. clearLog = function() {
  151. xajax.$('log').innerHTML = '';
  152. }
  153. /* ]]> */
  154. </script>
  155. <style type='text/css'>
  156. /* <![CDATA[ */
  157. .initiallyHidden {
  158. visibility: hidden;
  159. }
  160. .controls {
  161. width: 600px;
  162. border: 1px solid black;
  163. }
  164. .logger {
  165. margin-top: 3px;
  166. width: 600px;
  167. border: 1px solid black;
  168. }
  169. .log {
  170. padding: 2px;
  171. }
  172. .description {
  173. margin-top: 3px;
  174. padding: 2px;
  175. border: 1px solid #999999;
  176. font-size: smaller;
  177. width: 594px;
  178. }
  179. .clearLink {
  180. font-size: smaller;
  181. }
  182. /* ]]> */
  183. </style>
  184. <?
  185. $objTestScriptPlugin->printHeader($xajax, "Load / Unload CSS files",ob_get_clean());
  186. ob_start();
  187. ?>
  188. <table cellspacing='0' cellpadding='0'>
  189. <tbody>
  190. <tr>
  191. <td align='center' valign='top' width="50%">
  192. <div><?php $buttonLoadCSS1->printHTML(); ?><?php $buttonUnloadCSS1->printHTML(); ?></div>
  193. <div><?php $buttonLoadCSS2->printHTML(); ?><?php $buttonUnloadCSS2->printHTML(); ?></div>
  194. </td>
  195. <td valign='top' rowspan='2'>
  196. <div class='frame'>
  197. <div class='headerText'>Header Text</div>
  198. <div class='bodyText'>This is the body text.</div>
  199. <div class='initiallyHidden tagline'>This is the tagline.</div>
  200. </div>
  201. </td>
  202. </tr>
  203. <tr>
  204. <td align='center' valign='top' width="50%">
  205. <div><?php $buttonLoadCSS1_Print->printHTML(); ?><?php $buttonUnloadCSS1_Print->printHTML(); ?></div>
  206. <div><?php $buttonLoadCSS2_Print->printHTML(); ?><?php $buttonUnloadCSS2_Print->printHTML(); ?></div>
  207. </td>
  208. </tr>
  209. </tbody>
  210. </table>
  211. <?
  212. $objTestScriptPlugin->printControlPanel(ob_get_clean());
  213. $objTestScriptPlugin->printStatusPanel();
  214. $objTestScriptPlugin->printLogPanel();
  215. $objTestScriptPlugin->printDescriptionPanel("
  216. This test script demonstrates the ability to request the loading and unloading of CSS files from the server side.
  217. Click the load button for either CSS1 or CSS2 and watch the browser apply the style changes to the page nearly
  218. instantly. Once loaded, the style changes can be removed with the unload button. *NEW* This test script now
  219. shows the use of the new media (optional parameter). When you click the load or unload CSS1 and CSS2 for print,
  220. you can see the changes only in the print preview or on a printed page.
  221. ");
  222. $objTestScriptPlugin->printFooter();