public function beforeProcess(&$pExecParams) { if ($theme = $this->config->getThemeFor(CopixRequest::get('module'))) { CopixTpl::setTheme($theme); } //Ajout d'une gestion de tpl par thème $config = CopixConfig::instance(); $theme = CopixTpl::getThemeInformations(CopixTpl::getTheme()); if ($theme->tpl != null) { $config->mainTemplate = $theme->tpl; } }
public function afterDisplay() { if (CopixTpl::getTheme() != CopixConfig::get('admin|defaultThemeId')) { CopixAJAX::getSession()->set('currentTheme', CopixTpl::getTheme()); } }
/** * Récupère un chemin de ressource (situé dans www) * * Ira chercher dans l'ordre de priorité dans * ./nom_theme/lang_COUNTRY/$path * ./nom_theme/lang/$path * ./nom_theme/$path * ./default/lang_COUNTRY/$path * ./default/lang/$path * ./default/$path * ./$path * * <code> * //on souhaites récupérer la feuille de style * $path = CopixURL::getRessourcePath ('styles/copix.css'); * //$path == /var/www/themes/nom_du_theme/styles/copix.css si le fichier existe * </code> * * @param string $resourcePath le chemin du fichier que l'on souhaites récupérer * www/$ressourcePath (doit représenter un fichier) * @return string le $ressourcePath complet en fonction des thèmes */ public static function getResourcePath($pResourcePath) { static $calculated = array(); $theme = CopixTpl::getTheme(); $i18n = CopixConfig::instance()->i18n_path_enabled; $lang = CopixI18N::getLang(); $country = CopixI18N::getCountry(); $key = $theme . $i18n . $lang . $country . $pResourcePath; if (isset($calculated[$key])) { return $calculated[$key]; } list($resourcePath, $moduleName, $modulePath) = self::_parseResourcePath($pResourcePath); // Utilise CopixResource pour trouver la ressource return $calculated[$key] = CopixResource::findResourcePath($resourcePath, $moduleName, $modulePath, $theme, $i18n, $lang, $country); }
/** * Demande le chargement de Mootools. * * @param array $pPlugins Liste de plugins à charger. */ public static function addJSFramework($pPlugins = null) { // Charge le noyau if (!isset(self::$_JSFrameworkAdded['*core*'])) { self::$_JSFrameworkAdded['*core*'] = true; // Initialise Mootools et l'identifiant de session if (!CopixAJAX::isAJAXRequest()) { // Ajoute MooTools et FirebugLite if (CopixConfig::instance()->getMode() == CopixConfig::DEVEL) { // MooTools non compressé et FirebugLite normal self::addJSLink(_resource('js/firebuglite/firebug.js'), array('id' => 'firebug_js')); self::addJSLink(_resource('js/mootools/mootools-devel.js'), array('id' => 'mootools_core_js')); } else { // MooTools compressé et FirebugLite qui ne fait rien. self::addJSLink(_resource('js/firebuglite/firebugx.js'), array('id' => 'firebug_js')); self::addJSLink(_resource('js/mootools/mootools.js'), array('id' => 'mootools_core_js')); } // Ajoute le framework JS spécifique de Copix self::addJSLink(_resource('js/copix.js'), array('id' => 'copix_js', 'charset' => 'UTF-8')); // Ajoute le code d'initialisation $urlBase = CopixUrl::get(); self::addJSCode(sprintf('Copix = new CopixClass(%s);', CopixJSON::encode(array('ajaxSessionId' => CopixAJAX::getSessionId(), 'module' => CopixContext::get(), 'urlBase' => $urlBase, 'resourceUrlBase' => CopixResource::getResourceBaseUrl($urlBase, CopixTpl::getTheme(), CopixI18N::getLang(), CopixI18N::getCountry())))), 'copixajax_init', CopixHTMLHeader::DOMREADY_ALWAYS); } } // Charge les plugins if (is_array($pPlugins)) { foreach ($pPlugins as $pluginName) { if (!isset(self::$_JSFrameworkAdded[$pluginName])) { self::$_JSFrameworkAdded[$pluginName] = true; $pluginId = 'mootools_plugin_' . $pluginName; $scriptId = $pluginId . '_js'; $stylesheetId = $pluginId . '_css'; if (file_exists(CopixUrl::getResourcePath($path = 'js/mootools/plugins/' . $pluginName . '.js'))) { self::addJSLink(_resource($path), array("id" => $scriptId)); } elseif (file_exists(CopixUrl::getResourcePath($path = 'js/mootools/plugins/' . $pluginName . '.js.php'))) { self::addJSLink(_resource($path), array("id" => $scriptId)); } else { throw new CopixException('[Mootools] Plugin ' . $pluginName . ' not found in ' . $pluginPath); } if (file_exists(CopixUrl::getResourcePath($path = 'js/mootools/css/' . $pluginName . '.css'))) { self::addCssLink(_resource($path), array("id" => $stylesheetId)); } } } } }