index.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. // Use installer
  3. if (file_exists("../install"))
  4. die("alert('You need to run the installer or rename/remove the \"install\" directory.');");
  5. error_reporting(E_ALL ^ E_NOTICE);
  6. require_once("../includes/general.php");
  7. require_once('../classes/Utils/JSCompressor.php');
  8. require_once("../classes/ManagerEngine.php");
  9. $theme = getRequestParam("theme", "", true);
  10. $package = getRequestParam("package", "", true);
  11. $type = getRequestParam("type", "", true);
  12. // Include Base and Core and Config.
  13. $man = new Moxiecode_ManagerEngine($type);
  14. require_once($basepath ."CorePlugin.php");
  15. require_once("../config.php");
  16. $man->dispatchEvent("onPreInit", array($type));
  17. $config = $man->getConfig();
  18. if ($package) {
  19. $compressor = new Moxiecode_JSCompressor(array(
  20. 'expires_offset' => 3600 * 24 * 10,
  21. 'disk_cache' => true,
  22. 'cache_dir' => '_cache',
  23. 'gzip_compress' => true,
  24. 'remove_whitespace' => true,
  25. 'charset' => 'UTF-8',
  26. 'name' => $theme . "_" . $package
  27. ));
  28. require_once('../classes/Utils/ClientResources.php');
  29. $resources = new Moxiecode_ClientResources();
  30. // Load theme resources
  31. $resources->load('../pages/' . $theme . '/resources.xml');
  32. // Load plugin resources
  33. $plugins = explode(',', $config["general.plugins"]);
  34. foreach ($plugins as $plugin)
  35. $resources->load('../plugins/' . $plugin . '/resources.xml');
  36. $files = $resources->getFiles($package);
  37. if ($resources->isDebugEnabled() || checkBool($config["general.debug"])) {
  38. header('Content-type: text/javascript');
  39. $pagePath = dirname($_SERVER['SCRIPT_NAME']);
  40. echo "// Debug enabled, scripts will be loaded without compression\n";
  41. echo "(function() {\n";
  42. echo "var h = '';\n";
  43. foreach ($files as $file)
  44. echo 'h += \'<script type="text/javascript" src="' . $pagePath . '/' . $file->getPath() . '"></script>\';' . "\n";
  45. echo "document.write(h);\n";
  46. echo "})();\n";
  47. } else {
  48. foreach ($files as $file)
  49. $compressor->addFile($file->getPath(), $file->isRemoveWhiteSpaceEnabled());
  50. $compressor->compress($package);
  51. }
  52. die;
  53. }
  54. ?>