PageRenderTime 47ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/phploader/test/test-loader.php

https://github.com/bensochar/phploader
PHP | 241 lines | 162 code | 51 blank | 28 comment | 28 complexity | d902ebe6431c5a396d6d1015dd85701b MD5 | raw file
  1. <?PHP
  2. /**
  3. * Copyright (c) 2009, Yahoo! Inc. All rights reserved.
  4. * Code licensed under the BSD License:
  5. * http://developer.yahoo.net/yui/license.html
  6. * version: 1.0.0b2
  7. */
  8. error_reporting(E_ALL);
  9. include("../loader.php");
  10. define("YUI_VERSION_TO_TEST", "2.8.0r4");
  11. // create the loader instance, this sets up the platform config as well,
  12. // which we need right away because we are iterating the packages to
  13. // generate a list of available modules.
  14. $loader = new YAHOO_util_Loader(YUI_VERSION_TO_TEST);
  15. $output = "";
  16. $checked = "";
  17. $modules = array();
  18. $embed = false;
  19. $loadOptional = false;
  20. $combine = false;
  21. if (isset($_GET["module"])) {
  22. $modules = $_GET['module'];
  23. $moduletype = null;
  24. $contenttype = "TAGS";
  25. // Module type is "css" for just css, "script" for just script
  26. // otherwise everything is sent out.
  27. if (isset($_GET["moduletype"])) {
  28. $moduletype = $_GET["moduletype"];
  29. // backwards compatible
  30. if ($moduletype == "YAHOO_util_CSS") {
  31. $moduletype = "css";
  32. } else if ($moduletype == "javascript") {
  33. $moduletype = "js";
  34. } else if ($moduletype == "YAHOO_util_JS") {
  35. $moduletype = "js";
  36. }
  37. }
  38. if (isset($_GET["contenttype"])) {
  39. $contenttype = $_GET["contenttype"];
  40. }
  41. // content type is "EMBED" to inline the files, otherwise links to the files are generated.
  42. if (isset($_GET["embed"])) {
  43. $contenttype = "EMBED";
  44. $embed = true;
  45. }
  46. if (isset($_GET["base"])) {
  47. $base= $_GET["base"];
  48. $loader->base = $base;
  49. }
  50. if (isset($_GET["comboBase"]) && !empty($_GET["comboBase"])) {
  51. $comboBase= $_GET["comboBase"];
  52. $loader->comboBase = $comboBase;
  53. } else {
  54. $comboBase= 'http://yui.yahooapis.com/combo?2.7.0/build/';
  55. $loader->comboBase = $comboBase;
  56. }
  57. if (isset($_GET["filter"])) {
  58. $filter= $_GET["filter"];
  59. $loader->filter = $filter;
  60. }
  61. if (isset($_GET["combine"])) {
  62. $combine = true;
  63. }
  64. if (isset($_GET["loadOptional"])) {
  65. $loadOptional = true;
  66. }
  67. $loader->combine = $combine;
  68. $loader->loadOptional = $loadOptional;
  69. // tell the loader about each module requested
  70. foreach ($modules as $module) {
  71. $loader->load( $module );
  72. }
  73. $output = $loader->processDependencies($contenttype, $moduletype);
  74. }
  75. ?>
  76. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  77. <html>
  78. <head>
  79. <title>Yahoo UI Library Loader</title>
  80. <style type="text/css">
  81. pre {
  82. font-size:90%;
  83. }
  84. .content {
  85. float: left;
  86. margin: 2px;
  87. padding: 2px;
  88. border: 1px solid #333333;
  89. }
  90. .content ul {
  91. list-style: none;
  92. padding: 2px;
  93. font-size: 86%;
  94. }
  95. .content input {
  96. padding: 0;
  97. margin: 2px;
  98. }
  99. #modulelist {
  100. width:150px;
  101. }
  102. #codewindow {
  103. overflow: auto;
  104. height: 524px;
  105. width: 80%;
  106. }
  107. </style>
  108. </head>
  109. <body>
  110. <form name="mainform" action="<?PHP echo getenv("REQUEST_URI"); ?>">
  111. <!-- All of the modules, check the ones that are required -->
  112. <div class="content" id="modulelist">
  113. <ul>
  114. <?PHP
  115. $i = 1;
  116. //$keys = sort(array_keys($yui_load_manager->modules));
  117. //foreach($loader->modules as $name => $allmoddef) {
  118. //foreach($keys as $name => $allmoddef) {
  119. $keys = array_keys($loader->modules);
  120. sort($keys);
  121. foreach($keys as $name) {
  122. $checked = (array_search($name, $modules) !== false) ? "checked" : "";
  123. $id = "module$i" . $i++;
  124. echo ("<li><label for=\"$id\"><input id=\"$id\" type=\"checkbox\" name=\"module[]\" value=\"$name\" $checked />$name</label></li>");
  125. }
  126. ?>
  127. </ul>
  128. <hr />
  129. <?PHP
  130. $prodchecked = "";
  131. $debugchecked = "";
  132. $combinechecked = "";
  133. $embedchecked = "";
  134. $loadOptionalchecked = "";
  135. // if ($target == $prod) {
  136. // $prodchecked = "checked";
  137. // } else if ($target == $debug) {
  138. // $debugchecked = "checked";
  139. // } else if ($target == $local) {
  140. // $localchecked = "checked";
  141. // } else {
  142. // $devchecked = "checked";
  143. // }
  144. if ($combine) {
  145. $combinechecked = "checked";
  146. }
  147. if ($embed) {
  148. $embedchecked = "checked";
  149. }
  150. if ($loadOptional) {
  151. $loadOptionalchecked = "checked";
  152. }
  153. ?>
  154. <p>
  155. <label>Base:</label><br />
  156. <input id="base" type="text" name="base" value="<?PHP echo $loader->base; ?>" size="15"/>
  157. </p>
  158. <p>
  159. <label>Combo Base:</label><br />
  160. <input id="base" type="text" name="comboBase" value="<?PHP echo $loader->comboBase; ?>" size="15"/>
  161. </p>
  162. <p>
  163. <select id="filter" name="filter">
  164. <option value="" <?PHP if (!$loader->filter) echo "selected"; ?>>None</option>
  165. <option value="RAW" <?PHP if ($loader->filter == "RAW") echo "selected"; ?>>RAW</option>
  166. <option value="DEBUG" <?PHP if ($loader->filter == "DEBUG") echo "selected"; ?>>DEBUG</option>
  167. </select>
  168. </p>
  169. <p>
  170. <input type="checkbox" name="combine" value="1" <?PHP echo $combine; ?> />
  171. Use Combo Loader
  172. </p>
  173. <p>
  174. <input type="checkbox" name="embed" value="1" <?PHP echo $embedchecked; ?> />
  175. Embed enabled
  176. </p>
  177. <p>
  178. <input type="checkbox" name="loadOptional" value="1" <?PHP echo $loadOptionalchecked; ?> />
  179. Load Optional
  180. </p>
  181. <hr />
  182. <input type="submit" name="subbut" value="Get Dependencies" />
  183. </div>
  184. <!-- Encoded loader output for easy reading -->
  185. <div class="content" id="codewindow">
  186. <pre><?PHP echo htmlentities($output); ?></pre>
  187. </div>
  188. </form>
  189. </body>
  190. </html>