Пример #1
0
 private function generateHeader()
 {
     global $jQuery;
     if (isset($jQuery['loaded'])) {
         return;
     }
     $html = jQueryBase::getJavascriptTag($this->config['root_url'] . '/modules/jQuery/libraries/jquery-1.4.2/jquery.js');
     $html .= jQueryBase::getJavascriptTag(null, 'jQuery.noConflict();');
     // foreach ($this->getPlugins() as $plugin => $parameters)
     // 		{
     // 			if (isset($parameters['active'] ))
     // 			$html .= ($parameters['active'] == 1)?jQueryBase::getJavascriptTag($this->config['root_url'] . '/modules/jQuery/libraries/plugins/' . $parameters['path']):'';
     // 		}
     // Scripts loading
     $default_scripts = jQueryScript::doSelect(array('where' => array('load_default' => true)));
     foreach ($default_scripts as $script) {
         $jQuery['headers']['scripts'][$script->getPosition()] = $script->getId();
         $required_plugins = explode(',', $script->getRequiredPlugins());
         foreach ($required_plugins as $plugin) {
             if ($plugin != '') {
                 $jQuery['headers']['plugins'][$plugin] = 1;
             }
             //TODO: FIX THE POSITION ISSUE
         }
     }
     // Plugins
     $plugins = $this->getActivePlugins();
     foreach ($plugins as $plugin => $status) {
         $jQuery['headers']['plugins'][$plugin] = 1;
     }
     // Output plugins
     if (is_array($jQuery['headers']['plugins'])) {
         foreach ($jQuery['headers']['plugins'] as $plugin => $status) {
             $html .= jQueryBase::getJavascriptTag($this->getPluginUrl($plugin));
         }
     }
     // Output scripts
     if (is_array($jQuery['headers']['scripts'])) {
         ksort($jQuery['headers']['scripts']);
         foreach ($jQuery['headers']['scripts'] as $script_id) {
             $html .= jQueryBase::getJavascriptTag($this->config['root_url'] . '/modules/jQuery/load.php?id=' . $script_id);
         }
     }
     $jQuery['loaded'] = true;
     return $html;
 }
Пример #2
0
<?php

if (!isset($gCms)) {
    exit;
}
if (isset($params['script'])) {
    $script = jQueryScript::retrieveByPk($params['script']);
    if (!is_null($script)) {
        if ($script->getInHeader() || $script->getLoadDefault()) {
            // We have to load it in header
            global $jQuery;
            $jQuery['headers']['scripts'][$script->getPosition()] = $script->getId();
            $required_plugins = explode(',', $script->getRequiredPlugins());
            foreach ($required_plugins as $plugin) {
                if ($plugin != '') {
                    $jQuery['headers']['plugins'][$plugin] = 1;
                }
                //TODO: FIX THE POSITION ISSUE
            }
        } else {
            echo jQueryBase::getJavascriptTag($this->config['root_url'] . '/modules/jQuery/load.php?id=' . $script->getId());
        }
    }
}