/javascript.inc.php
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
- <?php
-
- use common\libraries\Request;
- use common\libraries\Path;
- use common\libraries\Theme;
- use common\libraries\PlatformSetting;
- use common\libraries\Cache;
- use common\libraries\Filesystem;
- use common\libraries\JavascriptUtilities;
- use common\libraries\ClientCache;
- use common\libraries\ResourceCache;
- use common\libraries\HttpHeader;
- use common\libraries\BasicApplication;
- use repository\RepositoryManager;
-
- require_once dirname(__FILE__) . '/common/init.inc.php';
-
- $theme = Request :: get('theme');
- $time = Request :: get('time');
- $server_type = Request :: get('server_type', 'production');
- $is_caching = $server_type == 'production'; //we turn on caching for production only
- $application = Request :: get('application', 'common');
- $key = 'javascript_' . $theme . '_' . $application . '_' . $time . '.js';
- $client_time = Request :: server('HTTP_IF_MODIFIED_SINCE');
- $client_time = $client_time ? strtotime($client_time) : 0;
-
- HttpHeader :: content_type(HttpHeader :: CONTENT_TYPE_JAVASCRIPT, JavascriptUtilities :: DEFAULT_CHARSET);
- ClientCache :: prolog($key, $time, $is_caching);
- ResourceCache :: prolog($key, $time, $is_caching);
-
- /**
- * complete configuration.
- */
- require_once dirname(__FILE__) . '/common/conf.inc.php';
-
- //CONTENT
-
-
- ob_flush();
- ob_start();
-
- if ($application == 'common')
- {
- $plugin_path = Path :: get(SYS_PLUGIN_PATH);
- $common_libraries = Path :: get_common_libraries_path();
-
- $files = array();
- $files[] = $plugin_path . 'jquery/jquery.min.js';
- $files[] = $plugin_path . 'jquery/jquery.dimensions.min.js';
- $files[] = $plugin_path . 'jquery/jquery.tabula.js';
- $files[] = $plugin_path . 'jquery/jquery.dynamic.visual_tabs.js';
- $files[] = $plugin_path . 'jquery/jquery.tablednd.js';
- $files[] = $plugin_path . 'jquery/jquery.ui.min.js';
- $files[] = $plugin_path . 'jquery/jquery.ui.tabs.paging.js';
- $files[] = $plugin_path . 'jquery/jquery.simplemodal.js';
- $files[] = $plugin_path . 'jquery/jquery.treeview.pack.js';
- $files[] = $plugin_path . 'jquery/jquery.treeview.async.js';
- $files[] = $plugin_path . 'jquery/jquery.timeout.interval.idle.js';
- $files[] = $plugin_path . 'jquery/jquery.mousewheel.min.js';
- $files[] = $plugin_path . 'jquery/jquery.scrollable.pack.js';
- $files[] = $plugin_path . 'jquery/jquery.xml2json.pack.js';
- $files[] = $plugin_path . 'jquery/jquery.json.js';
- $files[] = $plugin_path . 'jquery/jquery.iphone.checkboxes.js';
- $files[] = $plugin_path . 'jquery/jquery.textarearesizer.js';
- $files[] = $plugin_path . 'jquery/jquery.jsuggest.js';
- $files[] = $plugin_path . 'jquery/jquery.jeditable.mini.js';
- $files[] = $plugin_path . 'jquery/jquery.query.js';
- $files[] = $plugin_path . 'jquery/jquery.replacetext.js';
- $files[] = $plugin_path . 'jquery/jquery.tree_menu.js';
- $files[] = $common_libraries . 'resources/javascript/utilities.js';
- $files[] = $common_libraries . 'resources/javascript/notifications.js';
- $files[] = $common_libraries . 'resources/javascript/help.js';
- $files[] = $common_libraries . 'resources/javascript/visit.js';
-
- foreach ($files as $file)
- {
- if (is_readable($file))
- {
- echo "\n";
- readfile($file);
- }
- }
- }
- else
- {
- $path = BasicApplication :: get_application_class_path($application) . 'javascript.inc.php';
- if (is_readable($path))
- {
- include $path;
- }
- else
- {
- $path = BasicApplication :: get_application_resources_javascript_path($application) . $application . '.js';
- if (is_readable($path))
- {
- readfile($path);
- }
- }
- }
-
- $result = $is_caching ? ob_get_contents() . ' ' : ''; //does not empty the buffer
- ob_end_flush();
- echo ' ';
-
- if ($is_caching)
- {
- //leaving minify out for now as it does not improve much.
- //$result = JavascriptUtilities::Minify($result);
- ResourceCache :: set($key, $result);
- }
- ?>