public function get($d = array()) { parent::get($d); if (empty($this->_allTemplates)) { $directories = utilsGmp::getDirList(GMP_TEMPLATES_DIR); if (!empty($directories)) { foreach ($directories as $code => $dir) { if ($xml = utilsGmp::getXml($dir['path'] . 'settings.xml')) { $this->_allTemplates[$code] = $xml; $this->_allTemplates[$code]->prevImg = GMP_TEMPLATES_PATH . $code . '/screenshot.png'; } } } if (is_dir(utilsGmp::getCurrentWPThemeDir() . 'gmp' . DS)) { if ($xml = utilsGmp::getXml(utilsGmp::getCurrentWPThemeDir() . 'gmp' . DS . 'settings.xml')) { $code = utilsGmp::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(utilsGmp::getCurrentWPThemeDir() . 'screenshot.jpg')) { $this->_allTemplates[$code]->prevImg = utilsGmp::getCurrentWPThemePath() . '/screenshot.jpg'; } else { $this->_allTemplates[$code]->prevImg = utilsGmp::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 = utilsGmp::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)) { errorsGmp::push(__('No modules were found in XML file', GMP_LANG_CODE), errorsGmp::MOD_INSTALL); } else { return $modules; } } else { errorsGmp::push(__('Invalid XML file', GMP_LANG_CODE), errorsGmp::MOD_INSTALL); } } else { errorsGmp::push(__('No XML file were found', GMP_LANG_CODE), errorsGmp::MOD_INSTALL); } return false; }