PageRenderTime 45ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/javascript.inc.php

https://bitbucket.org/chamilo/chamilo-dev/
PHP | 111 lines | 92 code | 13 blank | 6 comment | 7 complexity | 4c35fae2ae29f33a6b189f9835c320b7 MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause, LGPL-2.1, LGPL-3.0, GPL-3.0, MIT
  1. <?php
  2. use common\libraries\Request;
  3. use common\libraries\Path;
  4. use common\libraries\Theme;
  5. use common\libraries\PlatformSetting;
  6. use common\libraries\Cache;
  7. use common\libraries\Filesystem;
  8. use common\libraries\JavascriptUtilities;
  9. use common\libraries\ClientCache;
  10. use common\libraries\ResourceCache;
  11. use common\libraries\HttpHeader;
  12. use common\libraries\BasicApplication;
  13. use repository\RepositoryManager;
  14. require_once dirname(__FILE__) . '/common/init.inc.php';
  15. $theme = Request :: get('theme');
  16. $time = Request :: get('time');
  17. $server_type = Request :: get('server_type', 'production');
  18. $is_caching = $server_type == 'production'; //we turn on caching for production only
  19. $application = Request :: get('application', 'common');
  20. $key = 'javascript_' . $theme . '_' . $application . '_' . $time . '.js';
  21. $client_time = Request :: server('HTTP_IF_MODIFIED_SINCE');
  22. $client_time = $client_time ? strtotime($client_time) : 0;
  23. HttpHeader :: content_type(HttpHeader :: CONTENT_TYPE_JAVASCRIPT, JavascriptUtilities :: DEFAULT_CHARSET);
  24. ClientCache :: prolog($key, $time, $is_caching);
  25. ResourceCache :: prolog($key, $time, $is_caching);
  26. /**
  27. * complete configuration.
  28. */
  29. require_once dirname(__FILE__) . '/common/conf.inc.php';
  30. //CONTENT
  31. ob_flush();
  32. ob_start();
  33. if ($application == 'common')
  34. {
  35. $plugin_path = Path :: get(SYS_PLUGIN_PATH);
  36. $common_libraries = Path :: get_common_libraries_path();
  37. $files = array();
  38. $files[] = $plugin_path . 'jquery/jquery.min.js';
  39. $files[] = $plugin_path . 'jquery/jquery.dimensions.min.js';
  40. $files[] = $plugin_path . 'jquery/jquery.tabula.js';
  41. $files[] = $plugin_path . 'jquery/jquery.dynamic.visual_tabs.js';
  42. $files[] = $plugin_path . 'jquery/jquery.tablednd.js';
  43. $files[] = $plugin_path . 'jquery/jquery.ui.min.js';
  44. $files[] = $plugin_path . 'jquery/jquery.ui.tabs.paging.js';
  45. $files[] = $plugin_path . 'jquery/jquery.simplemodal.js';
  46. $files[] = $plugin_path . 'jquery/jquery.treeview.pack.js';
  47. $files[] = $plugin_path . 'jquery/jquery.treeview.async.js';
  48. $files[] = $plugin_path . 'jquery/jquery.timeout.interval.idle.js';
  49. $files[] = $plugin_path . 'jquery/jquery.mousewheel.min.js';
  50. $files[] = $plugin_path . 'jquery/jquery.scrollable.pack.js';
  51. $files[] = $plugin_path . 'jquery/jquery.xml2json.pack.js';
  52. $files[] = $plugin_path . 'jquery/jquery.json.js';
  53. $files[] = $plugin_path . 'jquery/jquery.iphone.checkboxes.js';
  54. $files[] = $plugin_path . 'jquery/jquery.textarearesizer.js';
  55. $files[] = $plugin_path . 'jquery/jquery.jsuggest.js';
  56. $files[] = $plugin_path . 'jquery/jquery.jeditable.mini.js';
  57. $files[] = $plugin_path . 'jquery/jquery.query.js';
  58. $files[] = $plugin_path . 'jquery/jquery.replacetext.js';
  59. $files[] = $plugin_path . 'jquery/jquery.tree_menu.js';
  60. $files[] = $common_libraries . 'resources/javascript/utilities.js';
  61. $files[] = $common_libraries . 'resources/javascript/notifications.js';
  62. $files[] = $common_libraries . 'resources/javascript/help.js';
  63. $files[] = $common_libraries . 'resources/javascript/visit.js';
  64. foreach ($files as $file)
  65. {
  66. if (is_readable($file))
  67. {
  68. echo "\n";
  69. readfile($file);
  70. }
  71. }
  72. }
  73. else
  74. {
  75. $path = BasicApplication :: get_application_class_path($application) . 'javascript.inc.php';
  76. if (is_readable($path))
  77. {
  78. include $path;
  79. }
  80. else
  81. {
  82. $path = BasicApplication :: get_application_resources_javascript_path($application) . $application . '.js';
  83. if (is_readable($path))
  84. {
  85. readfile($path);
  86. }
  87. }
  88. }
  89. $result = $is_caching ? ob_get_contents() . ' ' : ''; //does not empty the buffer
  90. ob_end_flush();
  91. echo ' ';
  92. if ($is_caching)
  93. {
  94. //leaving minify out for now as it does not improve much.
  95. //$result = JavascriptUtilities::Minify($result);
  96. ResourceCache :: set($key, $result);
  97. }
  98. ?>