function getTheme($property, $mode = "STD") { $jfile = file_get_contents(CopixUrl::getResourcePath("theme.conf.json")); if (!$jfile) { trigger_error('THEME : unable to find JSON configuration file', E_USER_ERROR); return false; } $jtheme = json_decode($jfile); if (!$jtheme) { trigger_error('THEME : unable to parse JSON configuration file', E_USER_ERROR); return false; } switch ($property) { case 'dimensions': return $jtheme->dimensions->{$mode}; break; case 'zones': return $jtheme->layout->{$mode}; break; default: return $jtheme; } }
/** * 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)); } } } } }
public function testModuleContext() { $modulePrefix = CopixModule::getPath('copixtest') . 'www/'; // Attention ici on teste getResourcePath $this->assertEquals($modulePrefix . 'img/fr_FR/module_fr_FR.jpg', CopixUrl::getResourcePath('|img/module_fr_FR.jpg')); $this->assertEquals($modulePrefix . 'img/fr/module_fr.jpg', CopixUrl::getResourcePath('|img/module_fr.jpg')); $this->assertEquals($modulePrefix . 'img/module.jpg', CopixUrl::getResourcePath('|img/module.jpg')); $this->assertEquals(CopixUrl::get() . 'img/notFound.jpg', CopixUrl::getResource('|img/notFound.jpg')); }
/** * Alias à CopixURL::getResourcePath (); * @see CopixURL::getResourcePath () * @param string $pResourcePath le chemin de la ressource que l'on souhaite aller chercher * @return string */ function _resourcePath($pResourcePath) { return CopixUrl::getResourcePath($pResourcePath); }