public function get($d = array()) { parent::get($d); if (empty($this->_allTemplates)) { $directories = utilsCsp::getDirList(CSP_TEMPLATES_DIR); if (!empty($directories)) { foreach ($directories as $code => $dir) { if ($xml = utilsCsp::getXml($dir['path'] . 'settings.xml')) { $this->_allTemplates[$code] = $xml; $this->_allTemplates[$code]->prevImg = CSP_TEMPLATES_PATH . $code . '/screenshot.png'; } } } if (is_dir(utilsCsp::getCurrentWPThemeDir() . 'csp' . DS)) { if ($xml = utilsCsp::getXml(utilsCsp::getCurrentWPThemeDir() . 'csp' . DS . 'settings.xml')) { $code = utilsCsp::getCurrentWPThemeCode(); if (strpos($code, '/') !== false) { // If theme is in sub-folder $code = explode('/', $code); $code = trim($code[count($code) - 1]); } $this->_allTemplates[$code] = $xml; if (is_file(utilsCsp::getCurrentWPThemeDir() . 'screenshot.jpg')) { $this->_allTemplates[$code]->prevImg = utilsCsp::getCurrentWPThemePath() . '/screenshot.jpg'; } else { $this->_allTemplates[$code]->prevImg = utilsCsp::getCurrentWPThemePath() . '/screenshot.png'; } } } } if (isset($d['code']) && isset($this->_allTemplates[$d['code']])) { return $this->_allTemplates[$d['code']]; } return $this->_allTemplates; }
private static function _getModulesFromXml($xmlPath) { if ($xml = utilsCsp::getXml($xmlPath)) { if (isset($xml->modules) && isset($xml->modules->mod)) { $modules = array(); $xmlMods = $xml->modules->children(); foreach ($xmlMods->mod as $mod) { $modules[] = $mod; } if (empty($modules)) { errorsCsp::push(langCsp::_('No modules were found in XML file'), errorsCsp::MOD_INSTALL); } else { return $modules; } } else { errorsCsp::push(langCsp::_('Invalid XML file'), errorsCsp::MOD_INSTALL); } } else { errorsCsp::push(langCsp::_('No XML file were found'), errorsCsp::MOD_INSTALL); } return false; }