/** * Return the code for the placeholder * @access public * @static * @return string */ public static function getCode() { $cssfiles = array(); // TODO: Unused // $jsfiles = array(); // $specialcode = array(); $lazyLoadingFiles = array(); $retstring = ''; $jsScripts = array(); if (count(self::$active) > 0) { // check for lazy dependencies, if there are lazy dependencies, activate cx // cx provides the lazy loading mechanism // this should be here because the cx variable have to be set before cx is initialized foreach (self::$active as $name) { $data = self::$available[$name]; if (!empty($data['lazyDependencies'])) { foreach ($data['lazyDependencies'] as $dependency) { if (!in_array($dependency, self::$active)) { // if the lazy dependency is not activated so far $lazyLoadingFiles = array_merge($lazyLoadingFiles, self::$available[$dependency]['jsfiles']); } if (!empty(self::$available[$dependency]['cssfiles'])) { $cssfiles = array_merge($cssfiles, self::$available[$dependency]['cssfiles']); } } } } if (!empty($lazyLoadingFiles)) { JS::activate('cx'); } // set cx.variables with lazy loading file paths ContrexxJavascript::getInstance()->setVariable('lazyLoadingFiles', $lazyLoadingFiles, 'contrexx'); // Note the "reverse" here. Dependencies are at the end of the // array, and must be loaded first! foreach (array_reverse(self::$active) as $name) { $data = self::$available[$name]; if (!isset($data['jsfiles']) && !isset($data['versions'])) { self::$error = "A JS entry should at least contain one js file..."; return false; } // get js files which are specified or the js files from first version if (!isset($data['jsfiles'])) { // get data from default version and load the files from there $versionData = end($data['versions']); $data = array_merge($data, $versionData); } $jsScripts[] = self::makeJSFiles($data['jsfiles']); if (!empty($data['cssfiles'])) { $cssfiles = array_merge($cssfiles, $data['cssfiles']); } if (isset($data['specialcode']) && strlen($data['specialcode']) > 0) { $jsScripts[] = self::makeSpecialCode(array($data['specialcode'])); } if (isset($data['makecallback'])) { self::$data['makecallback'](); } // Special case cloudrexx-API: fetch specialcode if activated if ($name == 'cx') { $jsScripts[] = self::makeSpecialCode(array(ContrexxJavascript::getInstance()->initJs())); } } } $jsScripts[] = self::makeJSFiles(self::$customJS); // if jquery is activated, do a noConflict if (array_search('jquery', self::$active) !== false) { $jsScripts[] = self::makeSpecialCode('if (typeof jQuery != "undefined") { jQuery.noConflict(); }'); } $jsScripts[] = self::makeJSFiles(self::$templateJS); // no conflict for normal jquery version which has been included in template or by theme dependency $jsScripts[] = self::makeSpecialCode('if (typeof jQuery != "undefined") { jQuery.noConflict(); }'); $retstring .= self::makeCSSFiles($cssfiles); $retstring .= self::makeCSSFiles(self::$customCSS); // Add javscript files $retstring .= implode(' ', $jsScripts); $retstring .= self::makeJSFiles(self::$customJS); $retstring .= self::makeSpecialCode(self::$customCode); return $retstring; }
/** * Return the code for the placeholder * @access public * @static * @return string */ public static function getCode() { $cssfiles = array(); // TODO: Unused // $jsfiles = array(); // $specialcode = array(); $retstring = ''; if (count(self::$active) > 0) { foreach (self::$active as $name) { $data = self::$available[$name]; if (!isset($data['jsfiles'])) { self::$error = "A JS entry should at least contain one js file..."; return false; } $retstring .= self::makeJSFiles($data['jsfiles']); if (!empty($data['cssfiles'])) { $cssfiles = array_merge($cssfiles, $data['cssfiles']); } if (isset($data['specialcode']) && strlen($data['specialcode']) > 0) { $retstring .= self::makeSpecialCode(array($data['specialcode'])); } if (isset($data['makecallback'])) { self::$data['makecallback'](); } // Special case cloudrexx-API: fetch specialcode if activated if ($name == 'cx') { $retstring .= self::makeSpecialCode(array(ContrexxJavascript::getInstance()->initJs())); } } } $retstring .= self::makeJSFiles(self::$customJS); $retstring .= self::makeCSSFiles($cssfiles); $retstring .= self::makeCSSFiles(self::$customCSS); $retstring .= self::makeSpecialCode(self::$customCode); return $retstring; }