public function __construct($forceLang = '') { // Timezone date_default_timezone_set(date_default_timezone_get()); // Macgic quotes OFF util::setMagicQuotesOff(); // Configuration $this->config = util::readJsonFile(DATA . 'config.json', true); // Error reporting if ($this->config['debug']) { error_reporting(E_ALL); } else { error_reporting(E_ERROR | E_PARSE); } // Tableau des paramètres d'URL if ($this->getConfigVal('urlRewriting') == 1) { if (isset($_GET['param'])) { $this->urlParams = explode($this->getConfigVal('urlSeparator'), $_GET['param']); } } else { foreach ($_GET as $k => $v) { if ($k != 'p') { $this->urlParams[] = $v; } } } // Liste des thèmes $temp = util::scanDir(THEMES); foreach ($temp['dir'] as $k => $v) { $this->themes[$v] = util::readJsonFile(THEMES . $v . '/infos.json', true); } // Liste des langues $this->langs = array('en'); $temp = util::scanDir(LANG); foreach ($temp['file'] as $k => $v) { $this->langs[] = substr($v, 0, 2); } // Tableau langue courante if ($forceLang == '') { $this->lang = util::readJsonFile(LANG . $this->getConfigVal('siteLang') . '.json', true); } else { $this->lang = util::readJsonFile(LANG . $forceLang . '.json', true); } if (file_exists(THEMES . $this->getConfigVal('theme') . '/lang/' . $this->getConfigVal('siteLang') . '.json')) { $this->lang = array_merge($this->lang, util::readJsonFile(THEMES . $this->getConfigVal('theme') . '/lang/' . $this->getConfigVal('siteLang') . '.json', true)); } if (!is_array($this->lang)) { $this->lang = array(); } // Quel est le plugin solicité ? $this->pluginToCall = isset($_GET['p']) ? $_GET['p'] : $this->getConfigVal('defaultPlugin'); }
private function listPlugins() { $data = array(); $dataNotSorted = array(); $dataFromCache = $this->loadPluginsFromCache(); if (ROOT == './' && is_array($dataFromCache)) { $data = $dataFromCache; } // Si pas de cache plugins, on reconstruit le fichier cache if (!$dataFromCache) { $items = util::scanDir(PLUGINS); foreach ($items['dir'] as $dir) { // Si le plugin est installé on récupère sa configuration if (file_exists(DATA_PLUGIN . $dir . '/config.json')) { $dataNotSorted[$dir] = util::readJsonFile(DATA_PLUGIN . $dir . '/config.json', true); } else { $dataNotSorted[$dir]['priority'] = '10'; } } // On tri les plugins par priorité $dataSorted = @util::sort2DimArray($dataNotSorted, 'priority', 'num'); foreach ($dataSorted as $plugin => $config) { $data[] = $this->createPlugin($plugin); } // On génère le cache if (ROOT == './') { $this->intiPluginsCache($data); } } return $data; }
public function listTemplates() { $core = core::getInstance(); $data = array(); $items = util::scanDir(THEMES . $core->getConfigVal('theme') . '/', array('header.php', 'footer.php', 'style.css', '404.php')); foreach ($items['file'] as $file) { if (in_array(util::getFileExtension($file), array('htm', 'html', 'txt', 'php'))) { $data[] = $file; } } return $data; }