function init() { // forbit access if the user is not an administrator $oMemberModel =& getModel('member'); $logged_info = $oMemberModel->getLoggedInfo(); if ($logged_info->is_admin != 'Y') { return $this->stop("msg_is_not_administrator"); } // change into administration layout //$this->setTemplatePath('./modules/cympusadmin/tpl'); $this->setLayoutPath('./modules/cympusadmin/tpl'); $this->setLayoutFile(_CYMPUSADMIN_LAYOUT_); // parse admin menu $act = Context::get('act'); $oXmlParser = new XmlParser(); $xml_obj = $oXmlParser->loadXmlFile('./modules/cympusadmin/conf/' . _CYMPUSADMIN_MENU_); $admin_menu = array(); $admin_menu = cympusadmin::getMenu($xml_obj->menu->item); Context::set('cympusadmin_menu', $admin_menu); $oModuleModel =& getModel('module'); $module_info = $oModuleModel->getModuleInfoXml('cympusadmin'); Context::set('cympus_modinfo', $module_info); $news = getNewsFromAgency(); Context::set('news', $news); Context::set('admin_bar', 'false'); }
function init() { // forbit access if the user is not an administrator if (!$this->grant->manager && !$this->grant->is_admin) { return $this->stop("msg_is_not_administrator"); } // change into administration layout //$this->setTemplatePath('./modules/cympusadmin/tpl'); $this->setLayoutPath('./modules/cympusadmin/tpl'); $this->setLayoutFile(_CYMPUSADMIN_LAYOUT_); Context::loadLang(_XE_PATH_ . 'modules/cympusadmin/lang/'); if ($this->grant->is_admin) { // parse admin menu $oXmlParser = new XmlParser(); $xml_obj = $oXmlParser->loadXmlFile('./modules/cympusadmin/conf/' . _CYMPUSADMIN_MENU_); $admin_menu = cympusadmin::getMenu($xml_obj->menu->item); Context::set('cympusadmin_menu', $admin_menu); } else { $output = ModuleHandler::triggerCall('cympusadmin.getManagerMenu', 'before', $manager_menu); if (!$output->toBool()) { return $output; } Context::set('cympusadmin_menu', $manager_menu); } $news = getNewsFromAgency(); Context::set('news', $news); Context::set('admin_bar', 'false'); $oModuleModel =& getModel('module'); $module_info = $oModuleModel->getModuleInfoXml('cympusadmin'); Context::set('cympus_modinfo', $module_info); return new Object(); }
function init($module = null) { // change into administration layout $config = getModel('cympusadmin')->getConfig(); $args = new stdClass(); $args->module = 'cympusadmin'; $module_list = getModel('module')->getModuleSrlList($args); if (!empty($module_list)) { foreach ($module_list as $module_info) { $cympus_module_info = $module_info; } } $module_path = './modules/cympusadmin/'; $template_path = sprintf("%sskins/%s/", $module_path, $cympus_module_info->skin); if (!is_dir($template_path) || !$cympus_module_info->skin) { $config->admin_skins = 'default'; $template_path = sprintf("%sskins/%s/", $module_path, $cympus_module_info->skin); } if ($module) { $module->setLayoutPath($template_path); $module->setLayoutFile(_CYMPUSADMIN_LAYOUT_); } else { $this->setLayoutPath($template_path); $this->setLayoutFile(_CYMPUSADMIN_LAYOUT_); } Context::loadLang(_XE_PATH_ . 'modules/cympusadmin/lang/'); $logged_info = Context::get('logged_info'); if ($logged_info->is_admin == 'Y') { // parse admin menu $oXmlParser = new XmlParser(); $xml_obj = $oXmlParser->loadXmlFile('./modules/cympusadmin/conf/' . _CYMPUSADMIN_MENU_); $admin_menu = cympusadmin::getMenu($xml_obj->menu->item); Context::set('cympusadmin_menu', $admin_menu); } else { $output = ModuleHandler::triggerCall('cympusadmin.getManagerMenu', 'before', $manager_menu); if (!$output->toBool()) { return $output; } Context::set('cympusadmin_menu', $manager_menu); } $news = getNewsFromAgency(); Context::set('news', $news); Context::set('admin_bar', 'false'); $oModuleModel = getModel('module'); $module_info = $oModuleModel->getModuleInfoXml('cympusadmin'); Context::set('cympus_modinfo', $module_info); return new Object(); }
/** * Rearrage all item * * <pre> * $items: * Array * ( * [0] => stdClass Object * ( * [category_srl] => stdClass Object * ( * [body] => xxx * ) * [package_srl] => stdClass Object * ( * [body] => xxx * ) * ... * [depfrom] => stdClass Object * ( * [body] => xxx * ) * ) * [1] => stdClass Object * ( * ... * ) * ... * ) * * $packages: * Array * ( * [<i>package_srl</i>] => stdClass Object * ( * [current_version] => xxx * [need_update] => xxx * [path] => xxx * ... * ) * ... * ) * * return: * Array * ( * [<i>package_srl</i>] => stdClass Object * ( * [category_srl] => xxx * [package_srl] => xxx * ... * [category] => xxx * [current_version] => xxx * [type] => xxx * [need_update] => xxx * [avail_remove] => xxx * [deps] => Array * ( * [0] => xxx * ... * ) * ) * ... * ) * </pre> * * @param object $items Recived data from server * @param object $packages Local data * @return object */ function rearranges($items, $packages = null) { if (!is_array($items)) { $items = array($items); } $item_list = array(); $targets = array('category_srl', 'package_srl', 'item_screenshot_url', 'package_voted', 'package_voter', 'package_description', 'package_downloaded', 'item_regdate', 'title', 'item_version', 'package_star', 'depfrom'); $targetpackages = array(); foreach ($items as $item) { $targetpackages[$item->package_srl->body] = 0; } $oModel =& getModel('autoinstall'); if ($package == null) { $packages = $oModel->getInstalledPackages(array_keys($targetpackages)); } $depto = array(); foreach ($items as $item) { $v = $this->rearrange($item, $targets); $v->category = $this->categories[$v->category_srl]->title; if ($packages[$v->package_srl]) { $v->current_version = $packages[$v->package_srl]->current_version; $v->need_update = $packages[$v->package_srl]->need_update; $v->type = $oModel->getTypeFromPath($packages[$v->package_srl]->path); if ($this->ftp_set && $v->depfrom) { $depfrom = explode(",", $v->depfrom); foreach ($depfrom as $package_srl) { $depto[$package_srl][] = $v->package_srl; } } if ($v->type == "core") { $v->avail_remove = false; } else { if ($v->type == "module") { $v->avail_remove = $oModel->checkRemovable($packages[$v->package_srl]->path); } else { $v->avail_remove = true; } } } $item_list[$v->package_srl] = $v; } if (count($depto) > 0) { $installed = $oModel->getInstalledPackages(implode(",", array_keys($depto))); foreach ($installed as $key => $val) { $path = $val->path; $type = $oModel->getTypeFromPath($path); if (!$type || $type == "core") { continue; } $config_file = $oModel->getConfigFilePath($type); if (!$config_file) { continue; } $xml = new XmlParser(); $xmlDoc = $xml->loadXmlFile(FileHandler::getRealPath($path) . $config_file); if (!$xmlDoc) { continue; } if ($type == "drcomponent") { $type = "component"; } if ($type == "style" || $type == "m.skin") { $type = "skin"; } if ($type == "m.layout") { $type = "layout"; } $title = $xmlDoc->{$type}->title->body; $installed[$key]->title = $title; } Context::set('installed', $installed); foreach ($installed as $key => $val) { foreach ($depto[$key] as $package_srl) { $item_list[$package_srl]->avail_remove = false; $item_list[$package_srl]->deps[] = $key; } } } return $item_list; }
/** * Load a xml file * @param string $xml_path A file name to be loaded * @return boolean */ function load($xml_path) { $this->_xml_ruleset = null; $xml_path = realpath($xml_path); if (!is_readable($xml_path)) { return false; } $parser = new XmlParser(); $xml = $parser->loadXmlFile($xml_path); if (!isset($xml->ruleset) || !isset($xml->ruleset->fields) || !isset($xml->ruleset->fields->field)) { return false; } // custom rules if (isset($xml->ruleset->customrules) && isset($xml->ruleset->customrules->rule)) { $customrules = $xml->ruleset->customrules->rule; if (!is_array($customrules)) { $customrules = array($customrules); } $rules = array(); foreach ($customrules as $rule) { if (!isset($rule->attrs) || !isset($rule->attrs->name)) { continue; } $rule = (array) $rule->attrs; $name = $rule['name']; unset($rule['name']); $rules[$name] = $rule; } if (count($rules)) { $this->addRule($rules); } } // filters $fields = $xml->ruleset->fields->field; if (!is_array($fields)) { $fields = array($fields); } $filters = array(); foreach ($fields as $field) { $name = ''; $filter = array(); if (!isset($field->attrs) || !isset($field->attrs->name)) { continue; } $filter = (array) $field->attrs; $name = $filter['name']; unset($filter['name']); // conditional statement if (isset($field->if)) { $if = $field->if; if (!is_array($if)) { $if = array($if); } foreach ($if as $idx => $cond) { $if[$idx] = (array) $cond->attrs; } $filter['if'] = $if; } $filters[$name] = $filter; } $this->_xml_ruleset = $xml->ruleset; $this->_filters = $filters; $this->_xml_path = $xml_path; return true; }
/** * @brief parse xml, retrieve plugin info. * (this function will be removed in the future) **/ function getPluginInfoXml($plugin, $vars = array()) { $plugin_path = _XE_PATH_ . "modules/epay/plugins/" . $plugin; $xml_file = sprintf(_XE_PATH_ . "modules/epay/plugins/%s/info.xml", $plugin); if (!file_exists($xml_file)) { return; } $oXmlParser = new XmlParser(); $tmp_xml_obj = $oXmlParser->loadXmlFile($xml_file); $xml_obj = $tmp_xml_obj->plugin; $cache_file = sprintf(_XE_PATH_ . "files/cache/epay/%s.%s.%s.php", $plugin, Context::getLangType(), __XE_VERSION__); if (!$xml_obj) { return; } $plugin_info = new stdClass(); $plugin_info->title = $xml_obj->title->body; $plugin_info->description = $xml_obj->description->body; $plugin_info->version = $xml_obj->version->body; sscanf($xml_obj->date->body, '%d-%d-%d', $date_obj->y, $date_obj->m, $date_obj->d); $plugin_info->date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d); $plugin_info->license = $xml_obj->license->body; $plugin_info->license_link = $xml_obj->license->attrs->link; if (!is_array($xml_obj->author)) { $author_list[] = $xml_obj->author; } else { $author_list = $xml_obj->author; } foreach ($author_list as $author) { if (!$author_obj) { $author_obj = new stdClass(); } $author_obj->name = $author->name->body; $author_obj->email_address = $author->attrs->email_address; $author_obj->homepage = $author->attrs->link; $plugin_info->author[] = $author_obj; } $buff = array(); $buff[] = '<?php if(!defined("__XE__")) exit();'; $buff[] = sprintf('$plugin_info->site_srl = "%s";', $site_srl); // 추가 변수 (템플릿에서 사용할 제작자 정의 변수) $extra_var_groups = $xml_obj->extra_vars->group; if (!$extra_var_groups) { $extra_var_groups = $xml_obj->extra_vars; } if (!is_array($extra_var_groups)) { $extra_var_groups = array($extra_var_groups); } $buff[] = '$plugin_info->extra_var = new stdClass();'; foreach ($extra_var_groups as $group) { $extra_vars = $group->var; if ($extra_vars) { if (!is_array($extra_vars)) { $extra_vars = array($extra_vars); } $extra_var_count = count($extra_vars); $buff[] = sprintf('$plugin_info->extra_var_count = \'%s\';', $extra_var_count); for ($i = 0; $i < $extra_var_count; $i++) { unset($var); unset($options); $var = $extra_vars[$i]; $name = $var->attrs->name; $buff[] = sprintf('$plugin_info->extra_var->%s = new stdClass();', $name); $buff[] = sprintf('$plugin_info->extra_var->%s->group = \'%s\';', $name, $group->title->body); $buff[] = sprintf('$plugin_info->extra_var->%s->title = \'%s\';', $name, $var->title->body); $buff[] = sprintf('$plugin_info->extra_var->%s->type = \'%s\';', $name, $var->attrs->type); $buff[] = sprintf('$plugin_info->extra_var->%s->default = \'%s\';', $name, $var->attrs->default); if ($var->attrs->type == 'image' && $var->attrs->location) { $buff[] = sprintf('$plugin_info->extra_var->%s->location = \'%s\';', $name, $var->attrs->location); } $buff[] = sprintf('$plugin_info->extra_var->%s->value = $vars->%s;', $name, $name); $buff[] = sprintf('$plugin_info->extra_var->%s->description = \'%s\';', $name, str_replace('\'', '\'', $var->description->body)); $options = $var->options; if (!$options) { continue; } if (!is_array($options)) { $options = array($options); } $options_count = count($options); $thumbnail_exist = false; for ($j = 0; $j < $options_count; $j++) { $thumbnail = $options[$j]->attrs->src; if ($thumbnail) { $thumbnail = $plugin_path . $thumbnail; if (file_exists($thumbnail)) { $buff[] = sprintf('$plugin_info->extra_var->%s->options[\'%s\'] = new stdClass();', $var->attrs->name, $options[$j]->attrs->value); $buff[] = sprintf('$plugin_info->extra_var->%s->options[\'%s\']->thumbnail = \'%s\';', $var->attrs->name, $options[$j]->attrs->value, $thumbnail); if (!$thumbnail_exist) { $buff[] = sprintf('$plugin_info->extra_var->%s->thumbnail_exist = true;', $var->attrs->name); $thumbnail_exist = true; } } } $buff[] = sprintf('$plugin_info->extra_var->%s->options[\'%s\'] = new stdClass();', $var->attrs->name, $options[$j]->attrs->value); $buff[] = sprintf('$plugin_info->extra_var->%s->options[\'%s\']->val = \'%s\';', $var->attrs->name, $options[$j]->attrs->value, $options[$j]->title->body); } } } } if ($buff) { $buff = implode(PHP_EOL, $buff); FileHandler::writeFile($cache_file, $buff); } require_once $cache_file; return $plugin_info; }
/** * Get information by reading conf/info.xml in the module * It uses caching to reduce time for xml parsing .. * @param string $layout * @param object $info * @param string $layoutType (P : PC, M : Mobile) * @return object info of layout */ function getLayoutInfo($layout, $info = null, $layout_type = "P") { if ($info) { $layout_title = $info->title; $layout = $info->layout; $layout_srl = $info->layout_srl; $site_srl = $info->site_srl; $vars = unserialize($info->extra_vars); if ($info->module_srl) { $layout_path = preg_replace('/([a-zA-Z0-9\\_\\.]+)(\\.html)$/', '', $info->layout_path); $xml_file = sprintf('%sskin.xml', $layout_path); } } // Get a path of the requested module. Return if not exists. if (!$layout_path) { $layout_path = $this->getLayoutPath($layout, $layout_type); } if (!is_dir($layout_path)) { return; } // Read the xml file for module skin information if (!$xml_file) { $xml_file = sprintf("%sconf/info.xml", $layout_path); } if (!file_exists($xml_file)) { $layout_info = new stdClass(); $layout_info->title = $layout; $layout_info->layout = $layout; $layout_info->path = $layout_path; $layout_info->layout_title = $layout_title; if (!$layout_info->layout_type) { $layout_info->layout_type = $layout_type; } return $layout_info; } // Include the cache file if it is valid and then return $layout_info variable if (!$layout_srl) { $cache_file = $this->getLayoutCache($layout, Context::getLangType(), $layout_type); } else { $cache_file = $this->getUserLayoutCache($layout_srl, Context::getLangType()); } if (file_exists($cache_file) && filemtime($cache_file) > filemtime($xml_file)) { include $cache_file; if ($layout_info->extra_var && $vars) { foreach ($vars as $key => $value) { if (!$layout_info->extra_var->{$key} && !$layout_info->{$key}) { $layout_info->{$key} = $value; } } } if (!$layout_info->title) { $layout_info->title = $layout; } return $layout_info; } // If no cache file exists, parse the xml and then return the variable. $oXmlParser = new XmlParser(); $tmp_xml_obj = $oXmlParser->loadXmlFile($xml_file); if ($tmp_xml_obj->layout) { $xml_obj = $tmp_xml_obj->layout; } elseif ($tmp_xml_obj->skin) { $xml_obj = $tmp_xml_obj->skin; } if (!$xml_obj) { return; } $buff = array(); $buff[] = '$layout_info = new stdClass;'; $buff[] = sprintf('$layout_info->site_srl = "%s";', $site_srl); if ($xml_obj->version && $xml_obj->attrs->version == '0.2') { // Layout title, version and other information sscanf($xml_obj->date->body, '%d-%d-%d', $date_obj->y, $date_obj->m, $date_obj->d); $date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d); $buff[] = sprintf('$layout_info->layout = "%s";', $layout); $buff[] = sprintf('$layout_info->type = "%s";', $xml_obj->attrs->type); $buff[] = sprintf('$layout_info->path = "%s";', $layout_path); $buff[] = sprintf('$layout_info->title = "%s";', $xml_obj->title->body); $buff[] = sprintf('$layout_info->description = "%s";', $xml_obj->description->body); $buff[] = sprintf('$layout_info->version = "%s";', $xml_obj->version->body); $buff[] = sprintf('$layout_info->date = "%s";', $date); $buff[] = sprintf('$layout_info->homepage = "%s";', $xml_obj->link->body); $buff[] = sprintf('$layout_info->layout_srl = $layout_srl;'); $buff[] = sprintf('$layout_info->layout_title = $layout_title;'); $buff[] = sprintf('$layout_info->license = "%s";', $xml_obj->license->body); $buff[] = sprintf('$layout_info->license_link = "%s";', $xml_obj->license->attrs->link); $buff[] = sprintf('$layout_info->layout_type = "%s";', $layout_type); // Author information if (!is_array($xml_obj->author)) { $author_list[] = $xml_obj->author; } else { $author_list = $xml_obj->author; } $buff[] = '$layout_info->author = array();'; for ($i = 0, $c = count($author_list); $i < $c; $i++) { $buff[] = sprintf('$layout_info->author[%d] = new stdClass;', $i); $buff[] = sprintf('$layout_info->author[%d]->name = "%s";', $i, $author_list[$i]->name->body); $buff[] = sprintf('$layout_info->author[%d]->email_address = "%s";', $i, $author_list[$i]->attrs->email_address); $buff[] = sprintf('$layout_info->author[%d]->homepage = "%s";', $i, $author_list[$i]->attrs->link); } // Extra vars (user defined variables to use in a template) $extra_var_groups = $xml_obj->extra_vars->group; if (!$extra_var_groups) { $extra_var_groups = $xml_obj->extra_vars; } if (!is_array($extra_var_groups)) { $extra_var_groups = array($extra_var_groups); } $buff[] = '$layout_info->extra_var = new stdClass;'; $extra_var_count = 0; foreach ($extra_var_groups as $group) { $extra_vars = $group->var; if ($extra_vars) { if (!is_array($extra_vars)) { $extra_vars = array($extra_vars); } $count = count($extra_vars); $extra_var_count += $count; for ($i = 0; $i < $count; $i++) { unset($var, $options); $var = $extra_vars[$i]; $name = $var->attrs->name; $buff[] = sprintf('$layout_info->extra_var->%s = new stdClass;', $name); $buff[] = sprintf('$layout_info->extra_var->%s->group = "%s";', $name, $group->title->body); $buff[] = sprintf('$layout_info->extra_var->%s->title = "%s";', $name, $var->title->body); $buff[] = sprintf('$layout_info->extra_var->%s->type = "%s";', $name, $var->attrs->type); $buff[] = sprintf('$layout_info->extra_var->%s->value = $vars->%s;', $name, $name); $buff[] = sprintf('$layout_info->extra_var->%s->description = "%s";', $name, str_replace('"', '\\"', $var->description->body)); $options = $var->options; if (!$options) { continue; } if (!is_array($options)) { $options = array($options); } $buff[] = sprintf('$layout_info->extra_var->%s->options = array();', $var->attrs->name); $options_count = count($options); $thumbnail_exist = false; for ($j = 0; $j < $options_count; $j++) { $buff[] = sprintf('$layout_info->extra_var->%s->options["%s"] = new stdClass;', $var->attrs->name, $options[$j]->attrs->value); $thumbnail = $options[$j]->attrs->src; if ($thumbnail) { $thumbnail = $layout_path . $thumbnail; if (file_exists($thumbnail)) { $buff[] = sprintf('$layout_info->extra_var->%s->options["%s"]->thumbnail = "%s";', $var->attrs->name, $options[$j]->attrs->value, $thumbnail); if (!$thumbnail_exist) { $buff[] = sprintf('$layout_info->extra_var->%s->thumbnail_exist = true;', $var->attrs->name); $thumbnail_exist = true; } } } $buff[] = sprintf('$layout_info->extra_var->%s->options["%s"]->val = "%s";', $var->attrs->name, $options[$j]->attrs->value, $options[$j]->title->body); } } } } $buff[] = sprintf('$layout_info->extra_var_count = "%s";', $extra_var_count); // Menu if ($xml_obj->menus->menu) { $menus = $xml_obj->menus->menu; if (!is_array($menus)) { $menus = array($menus); } $menu_count = count($menus); $buff[] = sprintf('$layout_info->menu_count = "%s";', $menu_count); $buff[] = '$layout_info->menu = new stdClass;'; for ($i = 0; $i < $menu_count; $i++) { $name = $menus[$i]->attrs->name; if ($menus[$i]->attrs->default == "true") { $buff[] = sprintf('$layout_info->default_menu = "%s";', $name); } $buff[] = sprintf('$layout_info->menu->%s = new stdClass;', $name); $buff[] = sprintf('$layout_info->menu->%s->name = "%s";', $name, $menus[$i]->attrs->name); $buff[] = sprintf('$layout_info->menu->%s->title = "%s";', $name, $menus[$i]->title->body); $buff[] = sprintf('$layout_info->menu->%s->maxdepth = "%s";', $name, $menus[$i]->attrs->maxdepth); $buff[] = sprintf('$layout_info->menu->%s->menu_srl = $vars->%s;', $name, $name); $buff[] = sprintf('$layout_info->menu->%s->xml_file = "./files/cache/menu/".$vars->%s.".xml.php";', $name, $name); $buff[] = sprintf('$layout_info->menu->%s->php_file = "./files/cache/menu/".$vars->%s.".php";', $name, $name); } } } else { // Layout title, version and other information sscanf($xml_obj->author->attrs->date, '%d. %d. %d', $date_obj->y, $date_obj->m, $date_obj->d); $date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d); $buff[] = sprintf('$layout_info->layout = "%s";', $layout); $buff[] = sprintf('$layout_info->path = "%s";', $layout_path); $buff[] = sprintf('$layout_info->title = "%s";', $xml_obj->title->body); $buff[] = sprintf('$layout_info->description = "%s";', $xml_obj->author->description->body); $buff[] = sprintf('$layout_info->version = "%s";', $xml_obj->attrs->version); $buff[] = sprintf('$layout_info->date = "%s";', $date); $buff[] = sprintf('$layout_info->layout_srl = $layout_srl;'); $buff[] = sprintf('$layout_info->layout_title = $layout_title;'); // Author information $buff[] = sprintf('$layout_info->author[0]->name = "%s";', $xml_obj->author->name->body); $buff[] = sprintf('$layout_info->author[0]->email_address = "%s";', $xml_obj->author->attrs->email_address); $buff[] = sprintf('$layout_info->author[0]->homepage = "%s";', $xml_obj->author->attrs->link); // Extra vars (user defined variables to use in a template) $extra_var_groups = $xml_obj->extra_vars->group; if (!$extra_var_groups) { $extra_var_groups = $xml_obj->extra_vars; } if (!is_array($extra_var_groups)) { $extra_var_groups = array($extra_var_groups); } foreach ($extra_var_groups as $group) { $extra_vars = $group->var; if ($extra_vars) { if (!is_array($extra_vars)) { $extra_vars = array($extra_vars); } $extra_var_count = count($extra_vars); $buff[] = sprintf('$layout_info->extra_var_count = "%s";', $extra_var_count); for ($i = 0; $i < $extra_var_count; $i++) { unset($var, $options); $var = $extra_vars[$i]; $name = $var->attrs->name; $buff[] = sprintf('$layout_info->extra_var->%s->group = "%s";', $name, $group->title->body); $buff[] = sprintf('$layout_info->extra_var->%s->title = "%s";', $name, $var->title->body); $buff[] = sprintf('$layout_info->extra_var->%s->type = "%s";', $name, $var->attrs->type); $buff[] = sprintf('$layout_info->extra_var->%s->value = $vars->%s;', $name, $name); $buff[] = sprintf('$layout_info->extra_var->%s->description = "%s";', $name, str_replace('"', '\\"', $var->description->body)); $options = $var->options; if (!$options) { continue; } if (!is_array($options)) { $options = array($options); } $options_count = count($options); for ($j = 0; $j < $options_count; $j++) { $buff[] = sprintf('$layout_info->extra_var->%s->options["%s"]->val = "%s";', $var->attrs->name, $options[$j]->value->body, $options[$j]->title->body); } } } } // Menu if ($xml_obj->menus->menu) { $menus = $xml_obj->menus->menu; if (!is_array($menus)) { $menus = array($menus); } $menu_count = count($menus); $buff[] = sprintf('$layout_info->menu_count = "%s";', $menu_count); for ($i = 0; $i < $menu_count; $i++) { $name = $menus[$i]->attrs->name; if ($menus[$i]->attrs->default == "true") { $buff[] = sprintf('$layout_info->default_menu = "%s";', $name); } $buff[] = sprintf('$layout_info->menu->%s->name = "%s";', $name, $name); $buff[] = sprintf('$layout_info->menu->%s->title = "%s";', $name, $menus[$i]->title->body); $buff[] = sprintf('$layout_info->menu->%s->maxdepth = "%s";', $name, $menus[$i]->maxdepth->body); $buff[] = sprintf('$layout_info->menu->%s->menu_srl = $vars->%s;', $name, $name); $buff[] = sprintf('$layout_info->menu->%s->xml_file = "./files/cache/menu/".$vars->%s.".xml.php";', $name, $name); $buff[] = sprintf('$layout_info->menu->%s->php_file = "./files/cache/menu/".$vars->%s.".php";', $name, $name); } } } // header_script $oModuleModel = getModel('module'); $layout_config = $oModuleModel->getModulePartConfig('layout', $layout_srl); $header_script = trim($layout_config->header_script); if ($header_script) { $buff[] = sprintf(' $layout_info->header_script = "%s"; ', str_replace(array('$', '"'), array('\\$', '\\"'), $header_script)); } FileHandler::writeFile($cache_file, '<?php if(!defined("__XE__")) exit(); ' . join(PHP_EOL, $buff)); if (FileHandler::exists($cache_file)) { include $cache_file; } if (!$layout_info->title) { $layout_info->title = $layout; } return $layout_info; }
/** * @brief 모듈의 conf/info.xml 을 읽어서 정보를 구함 * 이것 역시 캐싱을 통해서 xml parsing 시간을 줄인다.. **/ function getWidgetStyleInfo($widgetStyle) { $widgetStyle_path = $this->getWidgetStylePath($widgetStyle); if (!$widgetStyle_path) { return; } $xml_file = sprintf("%sskin.xml", $widgetStyle_path); if (!file_exists($xml_file)) { return; } // cache 파일을 비교하여 문제 없으면 include하고 $widgetStyle_info 변수를 return $cache_file = sprintf('./files/cache/widgetstyles/%s.%s.cache.php', $widgetStyle, Context::getLangType()); if (file_exists($cache_file) && filemtime($cache_file) > filemtime($xml_file)) { @(include $cache_file); return $widgetStyle_info; } // cache 파일이 없으면 xml parsing하고 변수화 한 후에 캐시 파일에 쓰고 변수 바로 return $oXmlParser = new XmlParser(); $tmp_xml_obj = $oXmlParser->loadXmlFile($xml_file); $xml_obj = $tmp_xml_obj->widgetstyle; if (!$xml_obj) { return; } $buff = ''; // 위젯의 제목, 버전 $buff .= sprintf('$widgetStyle_info->widgetStyle = "%s";', $widgetStyle); $buff .= sprintf('$widgetStyle_info->path = "%s";', $widgetStyle_path); $buff .= sprintf('$widgetStyle_info->title = "%s";', $xml_obj->title->body); $buff .= sprintf('$widgetStyle_info->description = "%s";', $xml_obj->description->body); $buff .= sprintf('$widgetStyle_info->version = "%s";', $xml_obj->version->body); sscanf($xml_obj->date->body, '%d-%d-%d', $date_obj->y, $date_obj->m, $date_obj->d); $date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d); $buff .= sprintf('$widgetStyle_info->date = "%s";', $date); $buff .= sprintf('$widgetStyle_info->homepage = "%s";', $xml_obj->link->body); $buff .= sprintf('$widgetStyle_info->license = "%s";', $xml_obj->license->body); $buff .= sprintf('$widgetStyle_info->license_link = "%s";', $xml_obj->license->attrs->link); // preview if (!$xml_obj->preview->body) { $xml_obj->preview->body = 'preview.jpg'; } $preview_file = sprintf("%s%s", $widgetStyle_path, $xml_obj->preview->body); if (file_exists($preview_file)) { $buff .= sprintf('$widgetStyle_info->preview = "%s";', $preview_file); } // 작성자 정보 if (!is_array($xml_obj->author)) { $author_list[] = $xml_obj->author; } else { $author_list = $xml_obj->author; } for ($i = 0; $i < count($author_list); $i++) { $buff .= sprintf('$widgetStyle_info->author[' . $i . ']->name = "%s";', $author_list[$i]->name->body); $buff .= sprintf('$widgetStyle_info->author[' . $i . ']->email_address = "%s";', $author_list[$i]->attrs->email_address); $buff .= sprintf('$widgetStyle_info->author[' . $i . ']->homepage = "%s";', $author_list[$i]->attrs->link); } // history if ($xml_obj->history) { if (!is_array($xml_obj->history)) { $history_list[] = $xml_obj->history; } else { $history_list = $xml_obj->history; } for ($i = 0; $i < count($history_list); $i++) { sscanf($history_list[$i]->attrs->date, '%d-%d-%d', $date_obj->y, $date_obj->m, $date_obj->d); $date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d); $buff .= sprintf('$widgetStyle_info->history[' . $i . ']->description = "%s";', $history_list[$i]->description->body); $buff .= sprintf('$widgetStyle_info->history[' . $i . ']->version = "%s";', $history_list[$i]->attrs->version); $buff .= sprintf('$widgetStyle_info->history[' . $i . ']->date = "%s";', $date); if ($history_list[$i]->author) { !is_array($history_list[$i]->author) ? $obj->author_list[] = $history_list[$i]->author : ($obj->author_list = $history_list[$i]->author); for ($j = 0; $j < count($obj->author_list); $j++) { $buff .= sprintf('$widgetStyle_info->history[' . $i . ']->author[' . $j . ']->name = "%s";', $obj->author_list[$j]->name->body); $buff .= sprintf('$widgetStyle_info->history[' . $i . ']->author[' . $j . ']->email_address = "%s";', $obj->author_list[$j]->attrs->email_address); $buff .= sprintf('$widgetStyle_info->history[' . $i . ']->author[' . $j . ']->homepage = "%s";', $obj->author_list[$j]->attrs->link); } } if ($history_list[$i]->log) { !is_array($history_list[$i]->log) ? $obj->log_list[] = $history_list[$i]->log : ($obj->log_list = $history_list[$i]->log); for ($j = 0; $j < count($obj->log_list); $j++) { $buff .= sprintf('$widgetStyle_info->history[' . $i . ']->logs[' . $j . ']->text = "%s";', $obj->log_list[$j]->body); $buff .= sprintf('$widgetStyle_info->history[' . $i . ']->logs[' . $j . ']->link = "%s";', $obj->log_list[$j]->attrs->link); } } } } // 추가 변수 (템플릿에서 사용할 제작자 정의 변수) $extra_var_groups = $xml_obj->extra_vars->group; if (!$extra_var_groups) { $extra_var_groups = $xml_obj->extra_vars; } if (!is_array($extra_var_groups)) { $extra_var_groups = array($extra_var_groups); } foreach ($extra_var_groups as $group) { $extra_vars = $group->var; if (!is_array($group->var)) { $extra_vars = array($group->var); } if ($extra_vars[0]->attrs->id || $extra_vars[0]->attrs->name) { $extra_var_count = count($extra_vars); $buff .= sprintf('$widgetStyle_info->extra_var_count = "%s";', $extra_var_count); for ($i = 0; $i < $extra_var_count; $i++) { unset($var); unset($options); $var = $extra_vars[$i]; $id = $var->attrs->id ? $var->attrs->id : $var->attrs->name; $name = $var->name->body ? $var->name->body : $var->title->body; $type = $var->attrs->type ? $var->attrs->type : $var->type->body; $buff .= sprintf('$widgetStyle_info->extra_var->%s->group = "%s";', $id, $group->title->body); $buff .= sprintf('$widgetStyle_info->extra_var->%s->name = "%s";', $id, $name); $buff .= sprintf('$widgetStyle_info->extra_var->%s->type = "%s";', $id, $type); if ($type == 'filebox') { $buff .= sprintf('$widgetStyle_info->extra_var->%s->filter = "%s";', $id, $var->attrs->filter); } $buff .= sprintf('$widgetStyle_info->extra_var->%s->value = $vars->%s;', $id, $id); $buff .= sprintf('$widgetStyle_info->extra_var->%s->description = "%s";', $id, str_replace('"', '\\"', $var->description->body)); $options = $var->options; if (!$options) { continue; } if (!is_array($options)) { $options = array($options); } $options_count = count($options); for ($j = 0; $j < $options_count; $j++) { $buff .= sprintf('$widgetStyle_info->extra_var->%s->options["%s"] = "%s";', $id, $options[$j]->value->body, $options[$j]->name->body); } } } } $buff = '<?php if(!defined("__ZBXE__")) exit(); ' . $buff . ' ?>'; FileHandler::writeFile($cache_file, $buff); if (file_exists($cache_file)) { @(include $cache_file); } return $widgetStyle_info; }
/** * Import data in module.xml format * @param int $key * @param int $cur * @param string $index_file * @param int $module_srl * @return int */ function importModule($key, $cur, $index_file, $module_srl) { // Pre-create the objects needed $this->oXmlParser = new XmlParser(); // Get category information of the target module $oDocumentController = getController('document'); $oDocumentModel = getModel('document'); $category_list = $category_titles = array(); $category_list = $oDocumentModel->getCategoryList($module_srl); if (count($category_list)) { foreach ($category_list as $key => $val) { $category_titles[$val->title] = $val->category_srl; } } // Extract category information $category_file = preg_replace('/index$/i', 'category.xml', $index_file); if (file_exists($category_file)) { $buff = FileHandler::readFile($category_file); // Create the xmlParser object $xmlDoc = $this->oXmlParser->loadXmlFile($category_file); $categories = $xmlDoc->items->category; if ($categories) { if (!is_array($categories)) { $categories = array($categories); } $match_sequence = array(); foreach ($categories as $k => $v) { $category = trim(base64_decode($v->body)); if (!$category || $category_titles[$category]) { continue; } $sequence = $v->attrs->sequence; $parent = $v->attrs->parent; $obj = null; $obj->title = $category; $obj->module_srl = $module_srl; if ($parent) { $obj->parent_srl = $match_sequence[$parent]; } $output = $oDocumentController->insertCategory($obj); if ($output->toBool()) { $match_sequence[$sequence] = $output->get('category_srl'); } } $oDocumentController = getController('document'); $oDocumentController->makeCategoryFile($module_srl); } FileHandler::removeFile($category_file); } $category_list = $category_titles = array(); $category_list = $oDocumentModel->getCategoryList($module_srl); if (count($category_list)) { foreach ($category_list as $key => $val) { $category_titles[$val->title] = $val->category_srl; } } $ek_args->module_srl = $module_srl; $output = executeQueryArray('document.getDocumentExtraKeys', $ek_args); if ($output->data) { foreach ($output->data as $key => $val) { $extra_keys[$val->eid] = true; } } if (!$cur) { $cur = 0; } // Open an index file $f = fopen($index_file, "r"); // Pass if already read for ($i = 0; $i < $cur; $i++) { fgets($f, 1024); } // Read each line until the condition meets for ($idx = $cur; $idx < $cur + $this->unit_count; $idx++) { if (feof($f)) { break; } // Find a location $target_file = trim(fgets($f, 1024)); if (!file_exists($target_file)) { continue; } // Importing data from now on $fp = fopen($target_file, "r"); if (!$fp) { continue; } $obj = new stdClass(); $obj->module_srl = $module_srl; $obj->document_srl = getNextSequence(); $files = array(); $extra_vars = array(); $started = false; $buff = array(); // Start from the body data while (!feof($fp)) { $str = fgets($fp, 1024); // Prepare an item if (trim($str) == '<post>') { $started = true; // Trackback inserted } else { if (substr($str, 0, 11) == '<trackbacks') { $obj->trackback_count = $this->importTrackbacks($fp, $module_srl, $obj->document_srl); continue; // Comments inserted } else { if (substr($str, 0, 9) == '<comments') { $obj->comment_count = $this->importComments($fp, $module_srl, $obj->document_srl); continue; // Attachment inserted } else { if (substr($str, 0, 9) == '<attaches') { $obj->uploaded_count = $this->importAttaches($fp, $module_srl, $obj->document_srl, $files); continue; // When starting extra variabls } elseif (trim($str) == '<extra_vars>') { $extra_vars = $this->importExtraVars($fp); continue; } } } } if ($started) { $buff[] = $str; } } $xmlDoc = $this->oXmlParser->parse(implode('', $buff)); $category = base64_decode($xmlDoc->post->category->body); if ($category_titles[$category]) { $obj->category_srl = $category_titles[$category]; } $obj->member_srl = 0; $obj->is_notice = base64_decode($xmlDoc->post->is_notice->body) == 'Y' ? 'Y' : 'N'; $obj->status = base64_decode($xmlDoc->post->is_secret->body) == 'Y' ? $oDocumentModel->getConfigStatus('secret') : $oDocumentModel->getConfigStatus('public'); $obj->title = base64_decode($xmlDoc->post->title->body); $obj->content = base64_decode($xmlDoc->post->content->body); $obj->readed_count = base64_decode($xmlDoc->post->readed_count->body); $obj->voted_count = base64_decode($xmlDoc->post->voted_count->body); $obj->blamed_count = base64_decode($xmlDoc->post->blamed_count->body); $obj->password = base64_decode($xmlDoc->post->password->body); $obj->user_name = base64_decode($xmlDoc->post->user_name->body); $obj->nick_name = base64_decode($xmlDoc->post->nick_name->body); if (!$obj->user_name) { $obj->user_name = $obj->nick_name; } $obj->user_id = base64_decode($xmlDoc->post->user_id->body); $obj->email_address = base64_decode($xmlDoc->post->email->body); $obj->homepage = base64_decode($xmlDoc->post->homepage->body); if ($obj->homepage && strncasecmp('http://', $obj->homepage, 7) !== 0 && strncasecmp('https://', $obj->homepage, 8) !== 0) { $obj->homepage = 'http://' . $obj->homepage; } $obj->tags = base64_decode($xmlDoc->post->tags->body); $obj->regdate = base64_decode($xmlDoc->post->regdate->body); $obj->last_update = base64_decode($xmlDoc->post->update->body); $obj->last_updater = base64_decode($xmlDoc->post->last_updater->body); if (!$obj->last_update) { $obj->last_update = $obj->regdate; } $obj->ipaddress = base64_decode($xmlDoc->post->ipaddress->body); $obj->list_order = $obj->update_order = $obj->document_srl * -1; $obj->commentStatus = base64_decode($xmlDoc->post->allow_comment->body) != 'N' ? 'ALLOW' : 'DENY'; $obj->allow_trackback = base64_decode($xmlDoc->post->allow_trackback->body) != 'N' ? 'Y' : 'N'; $obj->notify_message = base64_decode($xmlDoc->post->is_notice->body); // Change content information (attachment) if (count($files)) { foreach ($files as $key => $val) { $obj->content = preg_replace('/(src|href)\\=(["\']?)' . preg_quote($key) . '(["\']?)/i', '$1="' . $val . '"', $obj->content); $obj->content = preg_replace('/(["\']?).\\/files\\/(.+)\\/' . preg_quote($key) . '([^"\']+)(["\']?)/i', '"' . $val . '"', $obj->content); $obj->content = preg_replace('/(["\']?)files\\/(.+)\\/' . preg_quote($key) . '([^"\']+)(["\']?)/i', '"' . $val . '"', $obj->content); } } $output = executeQuery('document.insertDocument', $obj); if ($output->toBool() && $obj->tags) { $tag_list = explode(',', $obj->tags); $tag_count = count($tag_list); for ($i = 0; $i < $tag_count; $i++) { $args = new stdClass(); $args->tag_srl = getNextSequence(); $args->module_srl = $module_srl; $args->document_srl = $obj->document_srl; $args->tag = trim($tag_list[$i]); $args->regdate = $obj->regdate; if (!$args->tag) { continue; } $output = executeQuery('tag.insertTag', $args); } } // Add extra variables if (count($extra_vars)) { foreach ($extra_vars as $key => $val) { if (!$val->value) { continue; } unset($e_args); $e_args->module_srl = $module_srl; $e_args->document_srl = $obj->document_srl; $e_args->var_idx = $val->var_idx; $e_args->value = $val->value; $e_args->lang_code = $val->lang_code; $e_args->eid = $val->eid; // Create a key for extra vars if not exists (except vars for title and content) if (!preg_match('/^(title|content)_(.+)$/i', $e_args->eid) && !$extra_keys[$e_args->eid]) { unset($ek_args); $ek_args->module_srl = $module_srl; $ek_args->var_idx = $val->var_idx; $ek_args->var_name = $val->eid; $ek_args->var_type = 'text'; $ek_args->var_is_required = 'N'; $ek_args->var_default = ''; $ek_args->eid = $val->eid; $output = executeQuery('document.insertDocumentExtraKey', $ek_args); $extra_keys[$ek_args->eid] = true; } $output = executeQuery('document.insertDocumentExtraVar', $e_args); } } fclose($fp); FileHandler::removeFile($target_file); } fclose($f); // Sync category counts if (count($category_list)) { foreach ($category_list as $key => $val) { $oDocumentController->updateCategoryCount($module_srl, $val->category_srl); } } return $idx - 1; }
/** * Import data in module.xml format * @param int $key * @param int $cur * @param string $index_file * @param int $unit_count * @param int $module_srl * @param int $guestbook_module_srl * @param string $user_id * @param string $module_name * @return int */ function importModule($key, $cur, $index_file, $unit_count, $module_srl, $guestbook_module_srl, $user_id, $module_name = null) { // Pre-create the objects needed $this->oXmlParser = new XmlParser(); // Get category information of the target module $oDocumentController = getController('document'); $oDocumentModel = getModel('document'); $category_list = $category_titles = array(); $category_list = $oDocumentModel->getCategoryList($module_srl); if (count($category_list)) { foreach ($category_list as $key => $val) { $category_titles[$val->title] = $val->category_srl; } } // First handle categorty information $category_file = preg_replace('/index$/i', 'category.xml', $index_file); if (file_exists($category_file)) { // Create the xmlParser object $xmlDoc = $this->oXmlParser->loadXmlFile($category_file); // List category information if ($xmlDoc->categories->category) { $categories = array(); $idx = 0; $this->arrangeCategory($xmlDoc->categories, $categories, $idx, 0); $match_sequence = array(); foreach ($categories as $k => $v) { $category = $v->name; if (!$category || $category_titles[$category]) { continue; } $obj = null; $obj->title = $category; $obj->module_srl = $module_srl; if ($v->parent) { $obj->parent_srl = $match_sequence[$v->parent]; } $output = $oDocumentController->insertCategory($obj); if ($output->toBool()) { $match_sequence[$v->sequence] = $category_titles[$category] = $output->get('category_srl'); } } $oDocumentController->makeCategoryFile($module_srl); } FileHandler::removeFile($category_file); } $category_list = $category_titles = array(); $category_list = $oDocumentModel->getCategoryList($module_srl); if (count($category_list)) { foreach ($category_list as $key => $val) { $category_titles[$val->title] = $val->category_srl; } } // Get administrator information $oMemberModel = getModel('member'); $member_info = $oMemberModel->getMemberInfoByUserID($user_id); $author_xml_id = 0; if (!$cur) { $cur = 0; } // Open an index file $f = fopen($index_file, "r"); // Pass if already read for ($i = 0; $i < $cur; $i++) { fgets($f, 1024); } // Read each line until the codition meets for ($idx = $cur; $idx < $cur + $unit_count; $idx++) { if (feof($f)) { break; } // Find a location $target_file = trim(fgets($f, 1024)); if (!file_exists($target_file)) { continue; } // Start importing data $fp = fopen($target_file, "r"); if (!$fp) { continue; } $obj = null; $obj->module_srl = $module_srl; $obj->document_srl = getNextSequence(); $obj->uploaded_count = 0; $files = array(); $started = false; $buff = null; // Start importing from the body data while (!feof($fp)) { $str = fgets($fp, 1024); // Prepare an item if (substr($str, 0, 5) == '<post') { $started = true; continue; // Import the attachment } else { if (substr($str, 0, 12) == '<attachment ') { if ($this->importAttaches($fp, $module_srl, $obj->document_srl, $files, $str)) { $obj->uploaded_count++; } continue; } } if ($started) { $buff .= $str; } } $xmlDoc = $this->oXmlParser->parse('<post>' . $buff); $author_xml_id = $xmlDoc->post->author->body; if ($xmlDoc->post->category->body) { $tmp_arr = explode('/', $xmlDoc->post->category->body); $category = trim($tmp_arr[count($tmp_arr) - 1]); if ($category_titles[$category]) { $obj->category_srl = $category_titles[$category]; } } $obj->is_notice = 'N'; $obj->status = in_array($xmlDoc->post->visibility->body, array('public', 'syndicated')) ? $oDocumentModel->getConfigStatus('public') : $oDocumentModel->getConfigStatus('secret'); $obj->title = $xmlDoc->post->title->body; $obj->content = $xmlDoc->post->content->body; $obj->password = md5($xmlDoc->post->password->body); $obj->commentStatus = $xmlDoc->post->acceptcomment->body == '1' ? 'ALLOW' : 'DENY'; $obj->allow_trackback = $xmlDoc->post->accepttrackback->body == '1' ? 'Y' : 'N'; //$obj->allow_comment = $xmlDoc->post->acceptComment->body=='1'?'Y':'N'; //$obj->allow_trackback = $xmlDoc->post->acceptTrackback->body=='1'?'Y':'N'; $obj->regdate = date("YmdHis", $xmlDoc->post->published->body); $obj->last_update = date("YmdHis", $xmlDoc->post->modified->body); if (!$obj->last_update) { $obj->last_update = $obj->regdate; } $tag = null; $tmp_tags = null; $tag = $xmlDoc->post->tag; if ($tag) { if (!is_array($tag)) { $tag = array($tag); } foreach ($tag as $key => $val) { $tmp_tags[] = $val->body; } $obj->tags = implode(',', $tmp_tags); } $obj->readed_count = 0; $obj->voted_count = 0; $obj->nick_name = $member_info->nick_name; $obj->user_name = $member_info->user_name; $obj->user_id = $member_info->user_id; $obj->member_srl = $member_info->member_srl; $obj->email_address = $member_info->email_address; $obj->homepage = $member_info->homepage; $obj->ipaddress = $_REMOTE['SERVER_ADDR']; $obj->list_order = $obj->update_order = $obj->document_srl * -1; $obj->notify_message = 'N'; // Change content information (attachment) $obj->content = str_replace('[##_ATTACH_PATH_##]/', '', $obj->content); if (count($files)) { foreach ($files as $key => $val) { $obj->content = preg_replace('/(src|href)\\=(["\']?)' . preg_quote($key) . '(["\']?)/i', '$1="' . $val->url . '"', $obj->content); } } $obj->content = preg_replace_callback('!\\[##_Movie\\|([^\\|]*)\\|(.*?)_##\\]!is', array($this, '_replaceTTMovie'), $obj->content); if (count($files)) { $this->files = $files; $obj->content = preg_replace_callback('!\\[##_([a-z0-9]+)\\|([^\\|]*)\\|([^\\|]*)\\|(.*?)_##\\]!is', array($this, '_replaceTTAttach'), $obj->content); } // Trackback inserted $obj->trackback_count = 0; if ($xmlDoc->post->trackback) { $trackbacks = $xmlDoc->post->trackback; if (!is_array($trackbacks)) { $trackbacks = array($trackbacks); } if (count($trackbacks)) { foreach ($trackbacks as $key => $val) { $tobj = null; $tobj->trackback_srl = getNextSequence(); $tobj->module_srl = $module_srl; $tobj->document_srl = $obj->document_srl; $tobj->url = $val->url->body; $tobj->title = $val->title->body; $tobj->blog_name = $val->site->body; $tobj->excerpt = $val->excerpt->body; $tobj->regdate = date("YmdHis", $val->received->body); $tobj->ipaddress = $val->ip->body; $tobj->list_order = -1 * $tobj->trackback_srl; $output = executeQuery('trackback.insertTrackback', $tobj); if ($output->toBool()) { $obj->trackback_count++; } } } } // Comment $obj->comment_count = 0; if ($xmlDoc->post->comment) { $comment = $xmlDoc->post->comment; if (!is_array($comment)) { $comment = array($comment); } foreach ($comment as $key => $val) { $parent_srl = $this->insertComment($val, $module_srl, $obj->document_srl, $member_info, 0, $author_xml_id); if ($parent_srl === false) { continue; } $obj->comment_count++; if ($val->comment) { $child_comment = $val->comment; if (!is_array($child_comment)) { $child_comment = array($child_comment); } foreach ($child_comment as $k => $v) { $result = $this->insertComment($v, $module_srl, $obj->document_srl, $member_info, $parent_srl, $author_xml_id); if ($result !== false) { $obj->comment_count++; } } } } } if ($module_name == 'textyle') { $args = new stdClass(); $args->document_srl = $obj->document_srl; $args->module_srl = $obj->module_srl; $args->logs = serialize(null); $output = executeQuery('textyle.insertPublishLog', $args); // Visibility value of published state $status_published = array('public', 'syndicated'); // Save state if not published if (!in_array($xmlDoc->post->visibility->body, $status_published)) { $obj->module_srl = $member_info->member_srl; } } // Document $output = executeQuery('document.insertDocument', $obj); if ($output->toBool()) { // Tags if ($obj->tags) { $tag_list = explode(',', $obj->tags); $tag_count = count($tag_list); for ($i = 0; $i < $tag_count; $i++) { $args = new stdClass(); $args->tag_srl = getNextSequence(); $args->module_srl = $module_srl; $args->document_srl = $obj->document_srl; $args->tag = trim($tag_list[$i]); $args->regdate = $obj->regdate; if (!$args->tag) { continue; } $output = executeQuery('tag.insertTag', $args); } } } fclose($fp); FileHandler::removeFile($target_file); } fclose($f); if (count($category_list)) { foreach ($category_list as $key => $val) { $oDocumentController->updateCategoryCount($module_srl, $val->category_srl); } } // Guestbook information $guestbook_file = preg_replace('/index$/i', 'guestbook.xml', $index_file); if (file_exists($guestbook_file)) { // Create the xmlParser object $xmlDoc = $this->oXmlParser->loadXmlFile($guestbook_file); // Handle guest book information if ($guestbook_module_srl && $xmlDoc->guestbook->comment) { $comment = $xmlDoc->guestbook->comment; if (!is_array($comment)) { $comment = array($comment); } if ($module_name == 'textyle') { foreach ($comment as $key => $val) { $textyle_guestbook_srl = getNextSequence(); if ($val->comment) { $child_comment = $val->comment; if (!is_array($child_comment)) { $child_comment = array($child_comment); } foreach ($child_comment as $k => $v) { $result = $this->insertTextyleGuestbookItem($v, $module_srl, $member_info, 0, $textyle_guestbook_srl, $author_xml_id); } } $result = $this->insertTextyleGuestbookItem($val, $module_srl, $member_info, $textyle_guestbook_srl, 0, $author_xml_id); } } else { foreach ($comment as $key => $val) { $obj = null; $obj->module_srl = $guestbook_module_srl; $obj->document_srl = getNextSequence(); $obj->uploaded_count = 0; $obj->is_notice = 'N'; $obj->status = $val->secret->body == '1' ? $oDocumentModel->getConfigStatus('secret') : $oDocumentModel->getConfigStatus('public'); $obj->content = nl2br($val->content->body); // Extract a title form the bocy $obj->title = cut_str(strip_tags($obj->content), 20, '...'); if ($obj->title == '') { $obj->title = 'Untitled'; } $obj->commentStatus = 'ALLOW'; $obj->allow_trackback = 'N'; $obj->regdate = date("YmdHis", $val->written->body); $obj->last_update = date("YmdHis", $val->written->body); if (!$obj->last_update) { $obj->last_update = $obj->regdate; } $obj->tags = ''; $obj->readed_count = 0; $obj->voted_count = 0; if ($author_xml_id && $val->commenter->attrs->id == $author_xml_id) { $obj->password = ''; $obj->nick_name = $member_info->nick_name; $obj->user_name = $member_info->user_name; $obj->user_id = $member_info->user_id; $obj->member_srl = $member_info->member_srl; $obj->email_address = $member_info->email_address; $obj->homepage = $member_info->homepage; } else { $obj->password = $val->password->body; $obj->nick_name = $val->commenter->name->body; $obj->member_srl = 0; $homepage = $val->commenter->homepage->body; } $obj->ipaddress = $val->commenter->ip->body; $obj->list_order = $obj->update_order = $obj->document_srl * -1; $obj->notify_message = 'N'; $obj->trackback_count = 0; $obj->comment_count = 0; if ($val->comment) { $child_comment = $val->comment; if (!is_array($child_comment)) { $child_comment = array($child_comment); } foreach ($child_comment as $k => $v) { $result = $this->insertComment($v, $module_srl, $obj->document_srl, $member_info, 0, $author_xml_id); if ($result !== false) { $obj->comment_count++; } } } // Document $output = executeQuery('document.insertDocument', $obj); } } } FileHandler::removeFile($guestbook_file); } return $idx - 1; }
/** * Update installed package information * * @return void */ function checkInstalled() { executeQuery("autoinstall.deleteInstalledPackage"); $oModel = getModel('autoinstall'); $packages = $oModel->getPackages(); foreach ($packages as $package) { $real_path = FileHandler::getRealPath($package->path); if (!file_exists($real_path)) { continue; } $type = $oModel->getTypeFromPath($package->path); if ($type == "core") { $version = __XE_VERSION__; } else { $config_file = NULL; switch ($type) { case "m.layout": $type = "layout"; case "module": case "addon": case "layout": case "widget": $config_file = "/conf/info.xml"; break; case "component": $config_file = "/info.xml"; break; case "style": case "m.skin": $type = "skin"; case "skin": case "widgetstyle": $config_file = "/skin.xml"; break; case "drcomponent": $config_file = "/info.xml"; $type = "component"; break; case "theme": $config_file = "/conf/info.xml"; $type = "theme"; break; } if (!$config_file) { continue; } $xml = new XmlParser(); $xmlDoc = $xml->loadXmlFile($real_path . $config_file); if (!$xmlDoc) { continue; } $version = $xmlDoc->{$type}->version->body; } $args = new stdClass(); $args->package_srl = $package->package_srl; $args->version = $package->version; $args->current_version = $version; if (version_compare($args->version, $args->current_version, ">")) { $args->need_update = "Y"; } else { $args->need_update = "N"; } $output = executeQuery("autoinstall.insertInstalledPackage", $args); } }
function getPluginInfoXml($plugin_name, $extra_vals) { $plugin_path = $this->module_path . 'plugins/' . $plugin_name; $xml_file = $plugin_path . '/plugin.xml'; if (!file_exists($xml_file)) { return new stdClass(); } $oXmlParser = new XmlParser(); $xml_obj = $oXmlParser->loadXmlFile($xml_file); if ($xml_obj->plugin) { $xml_obj = $xml_obj->plugin; } else { return new stdClass(); } if (!is_array($extra_vals)) { $extra_vals = array($extra_vals); } $plugin_info = new stdClass(); $plugin_info->title = $xml_obj->title->body; if ($xml_obj->version && $xml_obj->attrs->version == '1.0') { sscanf($xml_obj->date->body, '%d-%d-%d', $date_obj->y, $date_obj->m, $date_obj->d); $plugin_info->version = $xml_obj->version->body; $plugin_info->date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d); $plugin_info->homepage = $xml_obj->link->body; $plugin_info->license = $xml_obj->license->body; $plugin_info->license_link = $xml_obj->license->attrs->link; $plugin_info->description = $xml_obj->description->body; if (is_array($xml_obj->author)) { $author_list = $xml_obj->author; } else { $author_list[] = $xml_obj->author; } foreach ($author_list as $author) { $author_obj = new stdClass(); $author_obj->name = $author->name->body; $author_obj->email_address = $author->attrs->email_address; $author_obj->homepage = $author->attrs->link; $plugin_info->author[] = $author_obj; } if ($xml_obj->extra_vars) { $extra_var_groups = $xml_obj->extra_vars->group; if (!$extra_var_groups) { $extra_var_groups = $xml_obj->extra_vars; } if (!is_array($extra_var_groups)) { $extra_var_groups = array($extra_var_groups); } foreach ($extra_var_groups as $group) { $extra_vars = $group->var; if (!$extra_vars) { continue; } if (!is_array($extra_vars)) { $extra_vars = array($extra_vars); } foreach ($extra_vars as $key => $val) { $obj = new stdClass(); if (!$val->attrs->type) { $val->attrs->type = 'text'; } $obj->group = $group->title->body; $obj->name = $val->attrs->name; $obj->title = $val->title->body; $obj->type = $val->attrs->type; $obj->description = $val->description->body; $obj->default = $val->attrs->default; if ($obj->name) { $obj->value = $extra_vals[$obj->name]->value; } if (strpos($obj->value, '|@|') != FALSE) { $obj->value = explode('|@|', $obj->value); } if (is_array($val->options)) { $options_length = count($val->options); for ($i = 0; $i < $options_length; $i++) { $obj->options[$i] = new stdClass(); $obj->options[$i]->title = $val->options[$i]->title->body; $obj->options[$i]->value = $val->options[$i]->attrs->value; } } else { $obj->options[0] = new stdClass(); $obj->options[0]->title = $val->options->title->body; $obj->options[0]->value = $val->options->attrs->value; } $plugin_info->extra_vars[] = $obj; } } } } $colorset = $xml_obj->colorset->color; if ($colorset) { if (!is_array($colorset)) { $colorset = array($colorset); } foreach ($colorset as $color) { $name = $color->attrs->name; $title = $color->title->body; $screenshot = $color->attrs->src; if ($screenshot) { $screenshot = $plugin_path . '/' . $screenshot; if (!file_exists($screenshot)) { $screenshot = ''; } } else { $screenshot = ''; } $obj = new stdClass(); $obj->name = $name; $obj->title = $title; $obj->screenshot = $screenshot; $plugin_info->colorset[] = $obj; } } $thumbnail = $plugin_path . '/thumbnail.png'; if (!file_exists($thumbnail)) { $thumbnail = NULL; } $plugin_info->thumbnail = $thumbnail; return $plugin_info; }
/** * @brief Read xml information of the component **/ function getComponentXmlInfo($component) { $lang_type = Context::getLangType(); // Get xml file path of the requested components $component_path = sprintf('%s/components/%s/', $this->module_path, $component); $xml_file = sprintf('%sinfo.xml', $component_path); $cache_file = sprintf('./files/cache/editor/%s.%s.php', $component, $lang_type); // Include and return xml file information if cached file exists if (file_exists($cache_file) && file_exists($xml_file) && filemtime($cache_file) > filemtime($xml_file)) { include $cache_file; return $xml_info; } // Parse, cache and then return if the cached file doesn't exist $oParser = new XmlParser(); $xml_doc = $oParser->loadXmlFile($xml_file); // Component information listed if ($xml_doc->component->version && $xml_doc->component->attrs->version == '0.2') { $component_info->component_name = $component; $component_info->title = $xml_doc->component->title->body; $component_info->description = str_replace('\\n', "\n", $xml_doc->component->description->body); $component_info->version = $xml_doc->component->version->body; $component_info->date = $xml_doc->component->date->body; $component_info->homepage = $xml_doc->component->link->body; $component_info->license = $xml_doc->component->license->body; $component_info->license_link = $xml_doc->component->license->attrs->link; $buff = '<?php if(!defined("__ZBXE__")) exit(); '; $buff .= sprintf('$xml_info->component_name = "%s";', $component_info->component_name); $buff .= sprintf('$xml_info->title = "%s";', $component_info->title); $buff .= sprintf('$xml_info->description = "%s";', $component_info->description); $buff .= sprintf('$xml_info->version = "%s";', $component_info->version); $buff .= sprintf('$xml_info->date = "%s";', $component_info->date); $buff .= sprintf('$xml_info->homepage = "%s";', $component_info->homepage); $buff .= sprintf('$xml_info->license = "%s";', $component_info->license); $buff .= sprintf('$xml_info->license_link = "%s";', $component_info->license_link); // Author information if (!is_array($xml_doc->component->author)) { $author_list[] = $xml_doc->component->author; } else { $author_list = $xml_doc->component->author; } for ($i = 0; $i < count($author_list); $i++) { $buff .= sprintf('$xml_info->author[' . $i . ']->name = "%s";', $author_list[$i]->name->body); $buff .= sprintf('$xml_info->author[' . $i . ']->email_address = "%s";', $author_list[$i]->attrs->email_address); $buff .= sprintf('$xml_info->author[' . $i . ']->homepage = "%s";', $author_list[$i]->attrs->link); } // history if ($xml_doc->component->history) { if (!is_array($xml_doc->component->history)) { $history_list[] = $xml_doc->component->history; } else { $history_list = $xml_doc->component->history; } for ($i = 0; $i < count($history_list); $i++) { unset($obj); sscanf($history_list[$i]->attrs->date, '%d-%d-%d', $date_obj->y, $date_obj->m, $date_obj->d); $date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d); $buff .= sprintf('$xml_info->history[' . $i . ']->description = "%s";', $history_list[$i]->description->body); $buff .= sprintf('$xml_info->history[' . $i . ']->version = "%s";', $history_list[$i]->attrs->version); $buff .= sprintf('$xml_info->history[' . $i . ']->date = "%s";', $date); if ($history_list[$i]->author) { !is_array($history_list[$i]->author) ? $obj->author_list[] = $history_list[$i]->author : ($obj->author_list = $history_list[$i]->author); for ($j = 0; $j < count($obj->author_list); $j++) { $buff .= sprintf('$xml_info->history[' . $i . ']->author[' . $j . ']->name = "%s";', $obj->author_list[$j]->name->body); $buff .= sprintf('$xml_info->history[' . $i . ']->author[' . $j . ']->email_address = "%s";', $obj->author_list[$j]->attrs->email_address); $buff .= sprintf('$xml_info->history[' . $i . ']->author[' . $j . ']->homepage = "%s";', $obj->author_list[$j]->attrs->link); } } if ($history_list[$i]->log) { !is_array($history_list[$i]->log) ? $obj->log_list[] = $history_list[$i]->log : ($obj->log_list = $history_list[$i]->log); for ($j = 0; $j < count($obj->log_list); $j++) { $buff .= sprintf('$xml_info->history[' . $i . ']->logs[' . $j . ']->text = "%s";', $obj->log_list[$j]->body); $buff .= sprintf('$xml_info->history[' . $i . ']->logs[' . $j . ']->link = "%s";', $obj->log_list[$j]->attrs->link); } } } } } else { sscanf($xml_doc->component->author->attrs->date, '%d. %d. %d', $date_obj->y, $date_obj->m, $date_obj->d); $date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d); $xml_info->component_name = $component; $xml_info->title = $xml_doc->component->title->body; $xml_info->description = str_replace('\\n', "\n", $xml_doc->component->author->description->body); $xml_info->version = $xml_doc->component->attrs->version; $xml_info->date = $date; $xml_info->author->name = $xml_doc->component->author->name->body; $xml_info->author->email_address = $xml_doc->component->author->attrs->email_address; $xml_info->author->homepage = $xml_doc->component->author->attrs->link; $buff = '<?php if(!defined("__ZBXE__")) exit(); '; $buff .= sprintf('$xml_info->component_name = "%s";', $xml_info->component_name); $buff .= sprintf('$xml_info->title = "%s";', $xml_info->title); $buff .= sprintf('$xml_info->description = "%s";', $xml_info->description); $buff .= sprintf('$xml_info->version = "%s";', $xml_info->version); $buff .= sprintf('$xml_info->date = "%s";', $xml_info->date); $buff .= sprintf('$xml_info->author[0]->name = "%s";', $xml_info->author->name); $buff .= sprintf('$xml_info->author[0]->email_address = "%s";', $xml_info->author->email_address); $buff .= sprintf('$xml_info->author[0]->homepage = "%s";', $xml_info->author->homepage); } // List extra variables (text type only for editor component) $extra_vars = $xml_doc->component->extra_vars->var; if ($extra_vars) { if (!is_array($extra_vars)) { $extra_vars = array($extra_vars); } foreach ($extra_vars as $key => $val) { unset($obj); $key = $val->attrs->name; $title = $val->title->body; $description = $val->description->body; $xml_info->extra_vars->{$key}->title = $title; $xml_info->extra_vars->{$key}->description = $description; $buff .= sprintf('$xml_info->extra_vars->%s->%s = "%s";', $key, 'title', $title); $buff .= sprintf('$xml_info->extra_vars->%s->%s = "%s";', $key, 'description', $description); } } $buff .= ' ?>'; FileHandler::writeFile($cache_file, $buff, "w"); unset($xml_info); include $cache_file; return $xml_info; }
/** * @brief 모듈의 conf/info.xml 을 읽어서 정보를 구함 * 이것 역시 캐싱을 통해서 xml parsing 시간을 줄인다.. **/ function getLayoutInfo($layout, $info = null) { if ($info) { $layout_title = $info->title; $layout = $info->layout; $layout_srl = $info->layout_srl; $site_srl = $info->site_srl; $vars = unserialize($info->extra_vars); if ($info->module_srl) { $layout_path = preg_replace('/([a-zA-Z0-9\\_\\.]+)(\\.html)$/', '', $info->layout_path); $xml_file = sprintf('%sskin.xml', $layout_path); } } // 요청된 모듈의 경로를 구한다. 없으면 return if (!$layout_path) { $layout_path = $this->getLayoutPath($layout); } if (!is_dir($layout_path)) { return; } // 현재 선택된 모듈의 스킨의 정보 xml 파일을 읽음 if (!$xml_file) { $xml_file = sprintf("%sconf/info.xml", $layout_path); } if (!file_exists($xml_file)) { $layout_info->layout = $layout; $layout_info->path = $layout_path; $layout_info->layout_title = $layout_title; return $layout_info; } // cache 파일을 비교하여 문제 없으면 include하고 $layout_info 변수를 return if (!$layout_srl) { $cache_file = $this->getLayoutCache($layout, Context::getLangType()); } else { $cache_file = $this->getUserLayoutCache($layout_srl, Context::getLangType()); } if (file_exists($cache_file) && filemtime($cache_file) > filemtime($xml_file)) { @(include $cache_file); if ($layout_info->extra_var && $vars) { foreach ($vars as $key => $value) { if (!$layout_info->extra_var->{$key} && !$layout_info->{$key}) { $layout_info->{$key} = $value; } } } return $layout_info; } // cache 파일이 없으면 xml parsing하고 변수화 한 후에 캐시 파일에 쓰고 변수 바로 return $oXmlParser = new XmlParser(); $tmp_xml_obj = $oXmlParser->loadXmlFile($xml_file); if ($tmp_xml_obj->layout) { $xml_obj = $tmp_xml_obj->layout; } elseif ($tmp_xml_obj->skin) { $xml_obj = $tmp_xml_obj->skin; } if (!$xml_obj) { return; } $buff = ''; $buff .= sprintf('$layout_info->site_srl = "%s";', $site_srl); if ($xml_obj->version && $xml_obj->attrs->version == '0.2') { // 레이아웃의 제목, 버전 sscanf($xml_obj->date->body, '%d-%d-%d', $date_obj->y, $date_obj->m, $date_obj->d); $date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d); $buff .= sprintf('$layout_info->layout = "%s";', $layout); $buff .= sprintf('$layout_info->type = "%s";', $xml_obj->attrs->type); $buff .= sprintf('$layout_info->path = "%s";', $layout_path); $buff .= sprintf('$layout_info->title = "%s";', $xml_obj->title->body); $buff .= sprintf('$layout_info->description = "%s";', $xml_obj->description->body); $buff .= sprintf('$layout_info->version = "%s";', $xml_obj->version->body); $buff .= sprintf('$layout_info->date = "%s";', $date); $buff .= sprintf('$layout_info->homepage = "%s";', $xml_obj->link->body); $buff .= sprintf('$layout_info->layout_srl = $layout_srl;'); $buff .= sprintf('$layout_info->layout_title = $layout_title;'); $buff .= sprintf('$layout_info->license = "%s";', $xml_obj->license->body); $buff .= sprintf('$layout_info->license_link = "%s";', $xml_obj->license->attrs->link); // 작성자 정보 if (!is_array($xml_obj->author)) { $author_list[] = $xml_obj->author; } else { $author_list = $xml_obj->author; } for ($i = 0; $i < count($author_list); $i++) { $buff .= sprintf('$layout_info->author[' . $i . ']->name = "%s";', $author_list[$i]->name->body); $buff .= sprintf('$layout_info->author[' . $i . ']->email_address = "%s";', $author_list[$i]->attrs->email_address); $buff .= sprintf('$layout_info->author[' . $i . ']->homepage = "%s";', $author_list[$i]->attrs->link); } // 추가 변수 (템플릿에서 사용할 제작자 정의 변수) $extra_var_groups = $xml_obj->extra_vars->group; if (!$extra_var_groups) { $extra_var_groups = $xml_obj->extra_vars; } if (!is_array($extra_var_groups)) { $extra_var_groups = array($extra_var_groups); } foreach ($extra_var_groups as $group) { $extra_vars = $group->var; if ($extra_vars) { if (!is_array($extra_vars)) { $extra_vars = array($extra_vars); } $extra_var_count = count($extra_vars); $buff .= sprintf('$layout_info->extra_var_count = "%s";', $extra_var_count); for ($i = 0; $i < $extra_var_count; $i++) { unset($var); unset($options); $var = $extra_vars[$i]; $name = $var->attrs->name; $buff .= sprintf('$layout_info->extra_var->%s->group = "%s";', $name, $group->title->body); $buff .= sprintf('$layout_info->extra_var->%s->title = "%s";', $name, $var->title->body); $buff .= sprintf('$layout_info->extra_var->%s->type = "%s";', $name, $var->attrs->type); $buff .= sprintf('$layout_info->extra_var->%s->value = $vars->%s;', $name, $name); $buff .= sprintf('$layout_info->extra_var->%s->description = "%s";', $name, str_replace('"', '\\"', $var->description->body)); $options = $var->options; if (!$options) { continue; } if (!is_array($options)) { $options = array($options); } $options_count = count($options); for ($j = 0; $j < $options_count; $j++) { $buff .= sprintf('$layout_info->extra_var->%s->options["%s"] = "%s";', $var->attrs->name, $options[$j]->attrs->value, $options[$j]->title->body); } } } } // 메뉴 if ($xml_obj->menus->menu) { $menus = $xml_obj->menus->menu; if (!is_array($menus)) { $menus = array($menus); } $menu_count = count($menus); $buff .= sprintf('$layout_info->menu_count = "%s";', $menu_count); for ($i = 0; $i < $menu_count; $i++) { $name = $menus[$i]->attrs->name; if ($menus[$i]->attrs->default == "true") { $buff .= sprintf('$layout_info->default_menu = "%s";', $name); } $buff .= sprintf('$layout_info->menu->%s->name = "%s";', $name, $menus[$i]->attrs->name); $buff .= sprintf('$layout_info->menu->%s->title = "%s";', $name, $menus[$i]->title->body); $buff .= sprintf('$layout_info->menu->%s->maxdepth = "%s";', $name, $menus[$i]->attrs->maxdepth); $buff .= sprintf('$layout_info->menu->%s->menu_srl = $vars->%s;', $name, $name); $buff .= sprintf('$layout_info->menu->%s->xml_file = "./files/cache/menu/".$vars->%s.".xml.php";', $name, $name); $buff .= sprintf('$layout_info->menu->%s->php_file = "./files/cache/menu/".$vars->%s.".php";', $name, $name); } } // history if ($xml_obj->history) { if (!is_array($xml_obj->history)) { $history_list[] = $xml_obj->history; } else { $history_list = $xml_obj->history; } for ($i = 0; $i < count($history_list); $i++) { sscanf($history_list[$i]->attrs->date, '%d-%d-%d', $date_obj->y, $date_obj->m, $date_obj->d); $date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d); $buff .= sprintf('$layout_info->history[' . $i . ']->description = "%s";', $history_list[$i]->description->body); $buff .= sprintf('$layout_info->history[' . $i . ']->version = "%s";', $history_list[$i]->attrs->version); $buff .= sprintf('$layout_info->history[' . $i . ']->date = "%s";', $date); if ($history_list[$i]->author) { !is_array($history_list[$i]->author) ? $obj->author_list[] = $history_list[$i]->author : ($obj->author_list = $history_list[$i]->author); for ($j = 0; $j < count($obj->author_list); $j++) { $buff .= sprintf('$layout_info->history[' . $i . ']->author[' . $j . ']->name = "%s";', $obj->author_list[$j]->name->body); $buff .= sprintf('$layout_info->history[' . $i . ']->author[' . $j . ']->email_address = "%s";', $obj->author_list[$j]->attrs->email_address); $buff .= sprintf('$layout_info->history[' . $i . ']->author[' . $j . ']->homepage = "%s";', $obj->author_list[$j]->attrs->link); } } if ($history_list[$i]->log) { !is_array($history_list[$i]->log) ? $obj->log_list[] = $history_list[$i]->log : ($obj->log_list = $history_list[$i]->log); for ($j = 0; $j < count($obj->log_list); $j++) { $buff .= sprintf('$layout_info->history[' . $i . ']->logs[' . $j . ']->text = "%s";', $obj->log_list[$j]->body); $buff .= sprintf('$layout_info->history[' . $i . ']->logs[' . $j . ']->link = "%s";', $obj->log_list[$j]->attrs->link); } } } } } else { // 레이아웃의 제목, 버전 sscanf($xml_obj->author->attrs->date, '%d. %d. %d', $date_obj->y, $date_obj->m, $date_obj->d); $date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d); $buff .= sprintf('$layout_info->layout = "%s";', $layout); $buff .= sprintf('$layout_info->path = "%s";', $layout_path); $buff .= sprintf('$layout_info->title = "%s";', $xml_obj->title->body); $buff .= sprintf('$layout_info->description = "%s";', $xml_obj->author->description->body); $buff .= sprintf('$layout_info->version = "%s";', $xml_obj->attrs->version); $buff .= sprintf('$layout_info->date = "%s";', $date); $buff .= sprintf('$layout_info->layout_srl = $layout_srl;'); $buff .= sprintf('$layout_info->layout_title = $layout_title;'); // 작성자 정보 $buff .= sprintf('$layout_info->author[0]->name = "%s";', $xml_obj->author->name->body); $buff .= sprintf('$layout_info->author[0]->email_address = "%s";', $xml_obj->author->attrs->email_address); $buff .= sprintf('$layout_info->author[0]->homepage = "%s";', $xml_obj->author->attrs->link); // 추가 변수 (템플릿에서 사용할 제작자 정의 변수) $extra_var_groups = $xml_obj->extra_vars->group; if (!$extra_var_groups) { $extra_var_groups = $xml_obj->extra_vars; } if (!is_array($extra_var_groups)) { $extra_var_groups = array($extra_var_groups); } foreach ($extra_var_groups as $group) { $extra_vars = $group->var; if ($extra_vars) { if (!is_array($extra_vars)) { $extra_vars = array($extra_vars); } $extra_var_count = count($extra_vars); $buff .= sprintf('$layout_info->extra_var_count = "%s";', $extra_var_count); for ($i = 0; $i < $extra_var_count; $i++) { unset($var); unset($options); $var = $extra_vars[$i]; $name = $var->attrs->name; $buff .= sprintf('$layout_info->extra_var->%s->group = "%s";', $name, $group->title->body); $buff .= sprintf('$layout_info->extra_var->%s->title = "%s";', $name, $var->title->body); $buff .= sprintf('$layout_info->extra_var->%s->type = "%s";', $name, $var->attrs->type); $buff .= sprintf('$layout_info->extra_var->%s->value = $vars->%s;', $name, $name); $buff .= sprintf('$layout_info->extra_var->%s->description = "%s";', $name, str_replace('"', '\\"', $var->description->body)); $options = $var->options; if (!$options) { continue; } if (!is_array($options)) { $options = array($options); } $options_count = count($options); for ($j = 0; $j < $options_count; $j++) { $buff .= sprintf('$layout_info->extra_var->%s->options["%s"] = "%s";', $var->attrs->name, $options[$j]->value->body, $options[$j]->title->body); } } } } // 메뉴 if ($xml_obj->menus->menu) { $menus = $xml_obj->menus->menu; if (!is_array($menus)) { $menus = array($menus); } $menu_count = count($menus); $buff .= sprintf('$layout_info->menu_count = "%s";', $menu_count); for ($i = 0; $i < $menu_count; $i++) { $name = $menus[$i]->attrs->name; if ($menus[$i]->attrs->default == "true") { $buff .= sprintf('$layout_info->default_menu = "%s";', $name); } $buff .= sprintf('$layout_info->menu->%s->name = "%s";', $name, $menus[$i]->attrs->name); $buff .= sprintf('$layout_info->menu->%s->title = "%s";', $name, $menus[$i]->title->body); $buff .= sprintf('$layout_info->menu->%s->maxdepth = "%s";', $name, $menus[$i]->maxdepth->body); $buff .= sprintf('$layout_info->menu->%s->menu_srl = $vars->%s;', $name, $name); $buff .= sprintf('$layout_info->menu->%s->xml_file = "./files/cache/menu/".$vars->%s.".xml.php";', $name, $name); $buff .= sprintf('$layout_info->menu->%s->php_file = "./files/cache/menu/".$vars->%s.".php";', $name, $name); } } } // header_script $oModuleModel =& getModel('module'); $layout_config = $oModuleModel->getModulePartConfig('layout', $layout_srl); $header_script = trim($layout_config->header_script); if ($header_script) { $buff .= sprintf(' $layout_info->header_script = "%s"; ', str_replace('"', '\\"', $header_script)); } $buff = '<?php if(!defined("__ZBXE__")) exit(); ' . $buff . ' ?>'; FileHandler::writeFile($cache_file, $buff); if (file_exists($cache_file)) { @(include $cache_file); } return $layout_info; }
/** * @brief Get skin information on a specific location */ function loadSkinInfo($path, $skin, $dir = 'skins') { // Read xml file having skin information if (substr($path, -1) != '/') { $path .= '/'; } $skin_xml_file = sprintf("%s%s/%s/skin.xml", $path, $dir, $skin); if (!file_exists($skin_xml_file)) { return; } // Create XmlParser object $oXmlParser = new XmlParser(); $_xml_obj = $oXmlParser->loadXmlFile($skin_xml_file); // Return if no skin information is if (!$_xml_obj->skin) { return; } $xml_obj = $_xml_obj->skin; // Skin Name $skin_info = new stdClass(); $skin_info->title = $xml_obj->title->body; // Author information if ($xml_obj->version && $xml_obj->attrs->version == '0.2') { // skin format v0.2 sscanf($xml_obj->date->body, '%d-%d-%d', $date_obj->y, $date_obj->m, $date_obj->d); $skin_info->version = $xml_obj->version->body; $skin_info->date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d); $skin_info->homepage = $xml_obj->link->body; $skin_info->license = $xml_obj->license->body; $skin_info->license_link = $xml_obj->license->attrs->link; $skin_info->description = $xml_obj->description->body; if (!is_array($xml_obj->author)) { $author_list[] = $xml_obj->author; } else { $author_list = $xml_obj->author; } foreach ($author_list as $author) { $author_obj = new stdClass(); $author_obj->name = $author->name->body; $author_obj->email_address = $author->attrs->email_address; $author_obj->homepage = $author->attrs->link; $skin_info->author[] = $author_obj; } // List extra vars if ($xml_obj->extra_vars) { $extra_var_groups = $xml_obj->extra_vars->group; if (!$extra_var_groups) { $extra_var_groups = $xml_obj->extra_vars; } if (!is_array($extra_var_groups)) { $extra_var_groups = array($extra_var_groups); } foreach ($extra_var_groups as $group) { $extra_vars = $group->var; if (!$extra_vars) { continue; } if (!is_array($group->var)) { $extra_vars = array($group->var); } foreach ($extra_vars as $key => $val) { $obj = new stdClass(); if (!$val->attrs->type) { $val->attrs->type = 'text'; } $obj->group = $group->title->body; $obj->name = $val->attrs->name; $obj->title = $val->title->body; $obj->type = $val->attrs->type; $obj->description = $val->description->body; $obj->value = $extra_vals->{$obj->name}; $obj->default = $val->attrs->default; if (strpos($obj->value, '|@|') != false) { $obj->value = explode('|@|', $obj->value); } if ($obj->type == 'mid_list' && !is_array($obj->value)) { $obj->value = array($obj->value); } // Get an option list from 'select'type if (is_array($val->options)) { $option_count = count($val->options); for ($i = 0; $i < $option_count; $i++) { $obj->options[$i] = new stdClass(); $obj->options[$i]->title = $val->options[$i]->title->body; $obj->options[$i]->value = $val->options[$i]->attrs->value; } } else { $obj->options[0] = new stdClass(); $obj->options[0]->title = $val->options->title->body; $obj->options[0]->value = $val->options->attrs->value; } $skin_info->extra_vars[] = $obj; } } } } else { // skin format v0.1 sscanf($xml_obj->maker->attrs->date, '%d-%d-%d', $date_obj->y, $date_obj->m, $date_obj->d); $skin_info->version = $xml_obj->version->body; $skin_info->date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d); $skin_info->homepage = $xml_obj->link->body; $skin_info->license = $xml_obj->license->body; $skin_info->license_link = $xml_obj->license->attrs->link; $skin_info->description = $xml_obj->maker->description->body; $skin_info->author[0] = new stdClass(); $skin_info->author[0]->name = $xml_obj->maker->name->body; $skin_info->author[0]->email_address = $xml_obj->maker->attrs->email_address; $skin_info->author[0]->homepage = $xml_obj->maker->attrs->link; // Variables used in the skin $extra_var_groups = $xml_obj->extra_vars->group; if (!$extra_var_groups) { $extra_var_groups = $xml_obj->extra_vars; } if (!is_array($extra_var_groups)) { $extra_var_groups = array($extra_var_groups); } foreach ($extra_var_groups as $group) { $extra_vars = $group->var; if ($extra_vars) { if (!is_array($extra_vars)) { $extra_vars = array($extra_vars); } foreach ($extra_vars as $var) { unset($obj); unset($options); $group = $group->title->body; $name = $var->attrs->name; $type = $var->attrs->type; $title = $var->title->body; $description = $var->description->body; // Get an option list from 'select'type. if (is_array($var->default)) { $option_count = count($var->default); for ($i = 0; $i < $option_count; $i++) { $options[$i]->title = $var->default[$i]->body; $options[$i]->value = $var->default[$i]->body; } } else { $options[0]->title = $var->default->body; $options[0]->value = $var->default->body; } $width = $var->attrs->width; $height = $var->attrs->height; unset($obj); $obj->group = $group; $obj->title = $title; $obj->description = $description; $obj->name = $name; $obj->type = $type; $obj->options = $options; $obj->width = $width; $obj->height = $height; $obj->default = $options[0]->value; $skin_info->extra_vars[] = $obj; } } } } // colorset $colorset = $xml_obj->colorset->color; if ($colorset) { if (!is_array($colorset)) { $colorset = array($colorset); } foreach ($colorset as $color) { $name = $color->attrs->name; $title = $color->title->body; $screenshot = $color->attrs->src; if ($screenshot) { $screenshot = sprintf("%s%s/%s/%s", $path, $dir, $skin, $screenshot); if (!file_exists($screenshot)) { $screenshot = ""; } } else { $screenshot = ""; } $obj = new stdClass(); $obj->name = $name; $obj->title = $title; $obj->screenshot = $screenshot; $skin_info->colorset[] = $obj; } } // Menu type (settings for layout) if ($xml_obj->menus->menu) { $menus = $xml_obj->menus->menu; if (!is_array($menus)) { $menus = array($menus); } $menu_count = count($menus); $skin_info->menu_count = $menu_count; for ($i = 0; $i < $menu_count; $i++) { unset($obj); $obj->name = $menus[$i]->attrs->name; if ($menus[$i]->attrs->default == "true") { $obj->default = true; } $obj->title = $menus[$i]->title->body; $obj->maxdepth = $menus[$i]->maxdepth->body; $skin_info->menu->{$obj->name} = $obj; } } $thumbnail = sprintf("%s%s/%s/thumbnail.png", $path, $dir, $skin); $skin_info->thumbnail = file_exists($thumbnail) ? $thumbnail : null; return $skin_info; }
/** * @brief Read xml information of the component */ function getComponentXmlInfo($component) { $lang_type = Context::getLangType(); // Get xml file path of the requested components $component_path = sprintf('%s/components/%s/', $this->module_path, $component); $xml_file = sprintf('%sinfo.xml', $component_path); $cache_file = sprintf('./files/cache/editor/%s.%s.php', $component, $lang_type); // Include and return xml file information if cached file exists if (file_exists($cache_file) && file_exists($xml_file) && filemtime($cache_file) > filemtime($xml_file)) { include $cache_file; return $xml_info; } $oParser = new XmlParser(); $xml_doc = $oParser->loadXmlFile($xml_file); // Component information listed $component_info = new stdClass(); $component_info->author = array(); $component_info->extra_vars = new stdClass(); $component_info->component_name = $component; $component_info->title = $xml_doc->component->title->body; if ($xml_doc->component->version) { $component_info->description = str_replace('\\n', "\n", $xml_doc->component->description->body); $component_info->version = $xml_doc->component->version->body; $component_info->date = $xml_doc->component->date->body; $component_info->homepage = $xml_doc->component->link->body; $component_info->license = $xml_doc->component->license->body; $component_info->license_link = $xml_doc->component->license->attrs->link; } else { sscanf($xml_doc->component->author->attrs->date, '%d. %d. %d', $date_obj->y, $date_obj->m, $date_obj->d); $date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d); $component_info->description = str_replace('\\n', "\n", $xml_doc->component->author->description->body); $component_info->version = $xml_doc->component->attrs->version; $component_info->date = $date; $component_info->author = array(); $component_info->author[0]->name = $xml_doc->component->author->name->body; $component_info->author[0]->email_address = $xml_doc->component->author->attrs->email_address; $component_info->author[0]->homepage = $xml_doc->component->author->attrs->link; } // Author information $author_list = array(); if (!is_array($xml_doc->component->author)) { $author_list[] = $xml_doc->component->author; } else { $author_list = $xml_doc->component->author; } for ($i = 0; $i < count($author_list); $i++) { $author = new stdClass(); $author->name = $author_list[$i]->name->body; $author->email_address = $author_list[$i]->attrs->email_address; $author->homepage = $author_list[$i]->attrs->link; $component_info->author[] = $author; } // List extra variables (text type only for editor component) $extra_vars = $xml_doc->component->extra_vars; if ($extra_vars) { $extra_var_groups = $extra_vars->group; if (!$extra_var_groups) { $extra_var_groups = $extra_vars; } if (!is_array($extra_var_groups)) { $extra_var_groups = array($extra_var_groups); } foreach ($extra_var_groups as $group) { $extra_vars = $group->var; if (!is_array($group->var)) { $extra_vars = array($group->var); } foreach ($extra_vars as $key => $val) { if (!$val) { continue; } $obj = new stdClass(); if (!$val->attrs) { $val->attrs = new stdClass(); } if (!$val->attrs->type) { $val->attrs->type = 'text'; } $obj->group = $group->title->body; $obj->name = $val->attrs->name; $obj->title = $val->title->body; $obj->type = $val->attrs->type; $obj->description = $val->description->body; if ($obj->name) { $obj->value = $extra_vals->{$obj->name}; } if (strpos($obj->value, '|@|') != FALSE) { $obj->value = explode('|@|', $obj->value); } if ($obj->type == 'mid_list' && !is_array($obj->value)) { $obj->value = array($obj->value); } // 'Select'type obtained from the option list. if ($val->options && !is_array($val->options)) { $val->options = array($val->options); } for ($i = 0, $c = count($val->options); $i < $c; $i++) { $obj->options[$i] = new stdClass(); $obj->options[$i]->title = $val->options[$i]->title->body; $obj->options[$i]->value = $val->options[$i]->attrs->value; } $component_info->extra_vars->{$obj->name} = $obj; } } } $buff = array(); $buff[] = '<?php if(!defined(\'__XE__\')) exit();'; $buff[] = '$xml_info = ' . var_export($component_info, TRUE) . ';'; $buff = str_replace('stdClass::__set_state', '(object)', implode(PHP_EOL, $buff)); FileHandler::writeFile($cache_file, $buff, 'w'); return $component_info; }
/** * @brief 모듈의 conf/info.xml 을 읽어서 정보를 구함 **/ function getAddonInfoXml($addon, $site_srl = 0) { // 요청된 모듈의 경로를 구한다. 없으면 return $addon_path = $this->getAddonPath($addon); if (!$addon_path) { return; } // 현재 선택된 모듈의 스킨의 정보 xml 파일을 읽음 $xml_file = sprintf("%sconf/info.xml", $addon_path); if (!file_exists($xml_file)) { return; } $oXmlParser = new XmlParser(); $tmp_xml_obj = $oXmlParser->loadXmlFile($xml_file); $xml_obj = $tmp_xml_obj->addon; if (!$xml_obj) { return; } // DB에 설정된 내역을 가져온다 $db_args->addon = $addon; if (!$site_srl) { $output = executeQuery('addon.getAddonInfo', $db_args); } else { $db_args->site_srl = $site_srl; $output = executeQuery('addon.getSiteAddonInfo', $db_args); } $extra_vals = unserialize($output->data->extra_vars); if ($extra_vals->mid_list) { $addon_info->mid_list = $extra_vals->mid_list; } else { $addon_info->mid_list = array(); } // 애드온 정보 if ($xml_obj->version && $xml_obj->attrs->version == '0.2') { // addon format v0.2 sscanf($xml_obj->date->body, '%d-%d-%d', $date_obj->y, $date_obj->m, $date_obj->d); $addon_info->date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d); $addon_info->addon_name = $addon; $addon_info->title = $xml_obj->title->body; $addon_info->description = trim($xml_obj->description->body); $addon_info->version = $xml_obj->version->body; $addon_info->homepage = $xml_obj->link->body; $addon_info->license = $xml_obj->license->body; $addon_info->license_link = $xml_obj->license->attrs->link; if (!is_array($xml_obj->author)) { $author_list[] = $xml_obj->author; } else { $author_list = $xml_obj->author; } foreach ($author_list as $author) { unset($author_obj); $author_obj->name = $author->name->body; $author_obj->email_address = $author->attrs->email_address; $author_obj->homepage = $author->attrs->link; $addon_info->author[] = $author_obj; } // 확장변수를 정리 if ($xml_obj->extra_vars) { $extra_var_groups = $xml_obj->extra_vars->group; if (!$extra_var_groups) { $extra_var_groups = $xml_obj->extra_vars; } if (!is_array($extra_var_groups)) { $extra_var_groups = array($extra_var_groups); } foreach ($extra_var_groups as $group) { $extra_vars = $group->var; if (!is_array($group->var)) { $extra_vars = array($group->var); } foreach ($extra_vars as $key => $val) { unset($obj); if (!$val->attrs->type) { $val->attrs->type = 'text'; } $obj->group = $group->title->body; $obj->name = $val->attrs->name; $obj->title = $val->title->body; $obj->type = $val->attrs->type; $obj->description = $val->description->body; $obj->value = $extra_vals->{$obj->name}; if (strpos($obj->value, '|@|') != false) { $obj->value = explode('|@|', $obj->value); } if ($obj->type == 'mid_list' && !is_array($obj->value)) { $obj->value = array($obj->value); } // 'select'type에서 option목록을 구한다. if (is_array($val->options)) { $option_count = count($val->options); for ($i = 0; $i < $option_count; $i++) { $obj->options[$i]->title = $val->options[$i]->title->body; $obj->options[$i]->value = $val->options[$i]->attrs->value; } } else { $obj->options[0]->title = $val->options[0]->title->body; $obj->options[0]->value = $val->options[0]->attrs->value; } $addon_info->extra_vars[] = $obj; } } } // history if ($xml_obj->history) { if (!is_array($xml_obj->history)) { $history[] = $xml_obj->history; } else { $history = $xml_obj->history; } foreach ($history as $item) { unset($obj); if ($item->author) { !is_array($item->author) ? $obj->author_list[] = $item->author : ($obj->author_list = $item->author); foreach ($obj->author_list as $author) { unset($author_obj); $author_obj->name = $author->name->body; $author_obj->email_address = $author->attrs->email_address; $author_obj->homepage = $author->attrs->link; $obj->author[] = $author_obj; } } $obj->name = $item->name->body; $obj->email_address = $item->attrs->email_address; $obj->homepage = $item->attrs->link; $obj->version = $item->attrs->version; $obj->date = $item->attrs->date; $obj->description = $item->description->body; if ($item->log) { !is_array($item->log) ? $obj->log[] = $item->log : ($obj->log = $item->log); foreach ($obj->log as $log) { unset($log_obj); $log_obj->text = $log->body; $log_obj->link = $log->attrs->link; $obj->logs[] = $log_obj; } } $addon_info->history[] = $obj; } } } else { // addon format 0.1 $addon_info->addon_name = $addon; $addon_info->title = $xml_obj->title->body; $addon_info->description = trim($xml_obj->author->description->body); $addon_info->version = $xml_obj->attrs->version; sscanf($xml_obj->author->attrs->date, '%d. %d. %d', $date_obj->y, $date_obj->m, $date_obj->d); $addon_info->date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d); $author_obj->name = $xml_obj->author->name->body; $author_obj->email_address = $xml_obj->author->attrs->email_address; $author_obj->homepage = $xml_obj->author->attrs->link; $addon_info->author[] = $author_obj; if ($xml_obj->extra_vars) { // 확장변수를 정리 $extra_var_groups = $xml_obj->extra_vars->group; if (!$extra_var_groups) { $extra_var_groups = $xml_obj->extra_vars; } if (!is_array($extra_var_groups)) { $extra_var_groups = array($extra_var_groups); } foreach ($extra_var_groups as $group) { $extra_vars = $group->var; if (!is_array($group->var)) { $extra_vars = array($group->var); } foreach ($extra_vars as $key => $val) { unset($obj); if (!$val->type->body) { $val->type->body = 'text'; } $obj->group = $group->title->body; $obj->name = $val->attrs->name; $obj->title = $val->title->body; $obj->type = $val->type->body; $obj->description = $val->description->body; $obj->value = $extra_vals->{$obj->name}; if (strpos($obj->value, '|@|') != false) { $obj->value = explode('|@|', $obj->value); } if ($obj->type == 'mid_list' && !is_array($obj->value)) { $obj->value = array($obj->value); } // 'select'type에서 option목록을 구한다. if (is_array($val->options)) { $option_count = count($val->options); for ($i = 0; $i < $option_count; $i++) { $obj->options[$i]->title = $val->options[$i]->title->body; $obj->options[$i]->value = $val->options[$i]->value->body; } } $addon_info->extra_vars[] = $obj; } } } } return $addon_info; }
/** * Returns list of need update */ public function getNeedUpdateList() { $oModel = getModel('autoinstall'); $output = executeQueryArray('autoinstall.getNeedUpdate'); if (!is_array($output->data)) { return NULL; } $result = array(); $xml = new XmlParser(); foreach ($output->data as $package) { $packageSrl = $package->package_srl; $packageInfo = new stdClass(); $packageInfo->currentVersion = $package->current_version; $packageInfo->version = $package->version; $packageInfo->type = $oModel->getTypeFromPath($package->path); $packageInfo->url = $oModel->getUpdateUrlByPackageSrl($package->package_srl); if ($packageInfo->type == 'core') { $title = 'XpressEngine'; } else { $configFile = $oModel->getConfigFilePath($packageInfo->type); $xmlDoc = $xml->loadXmlFile(FileHandler::getRealPath($package->path) . $configFile); if ($xmlDoc) { $type = $packageInfo->type; if ($type == "drcomponent") { $type = "component"; } if ($type == "style" || $type == "m.skin") { $type = "skin"; } if ($type == "m.layout") { $type = "layout"; } $title = $xmlDoc->{$type}->title->body; } else { $pathInfo = explode('/', $package->path); $title = $pathInfo[count($pathInfo) - 1]; } } $packageInfo->title = $title; $result[] = $packageInfo; } return $result; }
/** * @brief parse xml, retrieve plugin info. * (this function will be removed in the future) **/ function getPluginInfoXml($plugin, $vars = array()) { $plugin_path = _XE_PATH_ . "modules/epay/plugins/" . $plugin; $xml_file = sprintf(_XE_PATH_ . "modules/epay/plugins/%s/info.xml", $plugin); if (!file_exists($xml_file)) { return; } $oXmlParser = new XmlParser(); $tmp_xml_obj = $oXmlParser->loadXmlFile($xml_file); $xml_obj = $tmp_xml_obj->plugin; if (!$xml_obj) { return; } $plugin_info->title = $xml_obj->title->body; $plugin_info->description = $xml_obj->description->body; $plugin_info->version = $xml_obj->version->body; sscanf($xml_obj->date->body, '%d-%d-%d', $date_obj->y, $date_obj->m, $date_obj->d); $plugin_info->date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d); $plugin_info->license = $xml_obj->license->body; $plugin_info->license_link = $xml_obj->license->attrs->link; if (!is_array($xml_obj->author)) { $author_list[] = $xml_obj->author; } else { $author_list = $xml_obj->author; } foreach ($author_list as $author) { unset($author_obj); $author_obj->name = $author->name->body; $author_obj->email_address = $author->attrs->email_address; $author_obj->homepage = $author->attrs->link; $plugin_info->author[] = $author_obj; } $buff = ''; $buff .= sprintf('$plugin_info->site_srl = "%s";', $site_srl); // 추가 변수 (템플릿에서 사용할 제작자 정의 변수) $extra_var_groups = $xml_obj->extra_vars->group; if (!$extra_var_groups) { $extra_var_groups = $xml_obj->extra_vars; } if (!is_array($extra_var_groups)) { $extra_var_groups = array($extra_var_groups); } foreach ($extra_var_groups as $group) { $extra_vars = $group->var; if ($extra_vars) { if (!is_array($extra_vars)) { $extra_vars = array($extra_vars); } $extra_var_count = count($extra_vars); $buff .= sprintf('$plugin_info->extra_var_count = "%s";', $extra_var_count); for ($i = 0; $i < $extra_var_count; $i++) { unset($var); unset($options); $var = $extra_vars[$i]; $name = $var->attrs->name; $buff .= sprintf('$plugin_info->extra_var->%s->group = "%s";', $name, $group->title->body); $buff .= sprintf('$plugin_info->extra_var->%s->title = "%s";', $name, $var->title->body); $buff .= sprintf('$plugin_info->extra_var->%s->type = "%s";', $name, $var->attrs->type); $buff .= sprintf('$plugin_info->extra_var->%s->default = "%s";', $name, $var->attrs->default); if ($var->attrs->type == 'image' && $var->attrs->location) { $buff .= sprintf('$plugin_info->extra_var->%s->location = "%s";', $name, $var->attrs->location); } $buff .= sprintf('$plugin_info->extra_var->%s->value = $vars->%s;', $name, $name); $buff .= sprintf('$plugin_info->extra_var->%s->description = "%s";', $name, str_replace('"', '\\"', $var->description->body)); $options = $var->options; if (!$options) { continue; } if (!is_array($options)) { $options = array($options); } $options_count = count($options); $thumbnail_exist = false; for ($j = 0; $j < $options_count; $j++) { $thumbnail = $options[$j]->attrs->src; if ($thumbnail) { $thumbnail = $plugin_path . $thumbnail; if (file_exists($thumbnail)) { $buff .= sprintf('$plugin_info->extra_var->%s->options["%s"]->thumbnail = "%s";', $var->attrs->name, $options[$j]->attrs->value, $thumbnail); if (!$thumbnail_exist) { $buff .= sprintf('$plugin_info->extra_var->%s->thumbnail_exist = true;', $var->attrs->name); $thumbnail_exist = true; } } } $buff .= sprintf('$plugin_info->extra_var->%s->options["%s"]->val = "%s";', $var->attrs->name, $options[$j]->attrs->value, $options[$j]->title->body); } } } } if ($buff) { eval($buff); } return $plugin_info; }
/** * @brief 주어진 xml 파일을 파싱해서 쪽지 정보 입력 **/ function importMessage($key, $cur, $index_file) { if (!$cur) { $cur = 0; } // xmlParser객체 생성 $oXmlParser = new XmlParser(); // index파일을 염 $f = fopen($index_file, "r"); // 이미 읽혀진 것은 패스 for ($i = 0; $i < $cur; $i++) { fgets($f, 1024); } // 라인단위로 읽어들이면서 $cur보다 커지고 $cur+$this->unit_count개보다 작으면 중지 for ($idx = $cur; $idx < $cur + $this->unit_count; $idx++) { if (feof($f)) { break; } // 정해진 위치를 찾음 $target_file = trim(fgets($f, 1024)); // 대상 파일을 읽여서 파싱후 입력 $xmlObj = $oXmlParser->loadXmlFile($target_file); FileHandler::removeFile($target_file); if (!$xmlObj) { continue; } // 객체 정리 $obj = null; $obj->receiver = base64_decode($xmlObj->message->receiver->body); $obj->sender = base64_decode($xmlObj->message->sender->body); $obj->title = base64_decode($xmlObj->message->title->body); $obj->content = base64_decode($xmlObj->message->content->body); $obj->readed = base64_decode($xmlObj->message->readed->body) == 'Y' ? 'Y' : 'N'; $obj->regdate = base64_decode($xmlObj->message->regdate->body); $obj->readed_date = base64_decode($xmlObj->message->readed_date->body); $obj->receiver = base64_decode($xmlObj->message->receiver->body); // 보낸이/ 받는이의 member_srl을 구함 (존재하지 않으면 그냥 pass..) if (!$obj->sender) { continue; } $sender_args->user_id = $obj->sender; $sender_output = executeQuery('member.getMemberInfo', $sender_args); $sender_srl = $sender_output->data->member_srl; if (!$sender_srl) { continue; } $receiver_args->user_id = $obj->receiver; if (!$obj->receiver) { continue; } $receiver_output = executeQuery('member.getMemberInfo', $receiver_args); $receiver_srl = $receiver_output->data->member_srl; if (!$receiver_srl) { continue; } // 보내는 사용자의 쪽지함에 넣을 쪽지 $sender_args->sender_srl = $sender_srl; $sender_args->receiver_srl = $receiver_srl; $sender_args->message_type = 'S'; $sender_args->title = $obj->title; $sender_args->content = $obj->content; $sender_args->readed = $obj->readed; $sender_args->regdate = $obj->regdate; $sender_args->readed_date = $obj->readed_date; $sender_args->related_srl = getNextSequence(); $sender_args->message_srl = getNextSequence(); $sender_args->list_order = $sender_args->message_srl * -1; $output = executeQuery('communication.sendMessage', $sender_args); if ($output->toBool()) { // 받는 회원의 쪽지함에 넣을 쪽지 $receiver_args->message_srl = $sender_args->related_srl; $receiver_args->list_order = $sender_args->related_srl * -1; $receiver_args->sender_srl = $sender_srl; if (!$receiver_args->sender_srl) { $receiver_args->sender_srl = $receiver_srl; } $receiver_args->receiver_srl = $receiver_srl; $receiver_args->message_type = 'R'; $receiver_args->title = $obj->title; $receiver_args->content = $obj->content; $receiver_args->readed = $obj->readed; $receiver_args->regdate = $obj->regdate; $receiver_args->readed_date = $obj->readed_date; $output = executeQuery('communication.sendMessage', $receiver_args); } } fclose($f); return $idx - 1; }
/** * Load a xml file * @param string $xml_path A file name to be loaded * @return boolean */ function load($xml_path) { $this->_xml_ruleset = NULL; $xml_path = realpath($xml_path); if (!is_readable($xml_path)) { return FALSE; } $parser = new XmlParser(); $xml = $parser->loadXmlFile($xml_path); if (!isset($xml->ruleset) || !isset($xml->ruleset->fields) || !isset($xml->ruleset->fields->field)) { return FALSE; } // custom rules if (isset($xml->ruleset->customrules) && isset($xml->ruleset->customrules->rule)) { $customrules = $xml->ruleset->customrules->rule; if (!is_array($customrules)) { $customrules = array($customrules); } $rules = array(); $messages = array(); foreach ($customrules as $rule) { if (!isset($rule->attrs) || !isset($rule->attrs->name)) { continue; } $message = $rule->message ? $rule->message->body : NULL; $rule = (array) $rule->attrs; $rule['message'] = $message; $name = $rule['name']; unset($rule['name']); $rules[$name] = $rule; if (isset($message)) { $messages['invalid_' . $name] = $message; } } if (count($rules)) { $this->addRule($rules); } } // filters $fields = $xml->ruleset->fields->field; if (!is_array($fields)) { $fields = array($fields); } $filters = array(); $fieldsNames = array(); foreach ($fields as $field) { $name = ''; $filter = array(); if (!isset($field->attrs) || !isset($field->attrs->name)) { continue; } $title = $field->title ? $field->title->body : NULL; $filter = (array) $field->attrs; $filter['title'] = $title; $name = $filter['name']; if (isset($title)) { $fieldsNames[$name] = $title; } unset($filter['name']); // conditional statement if (isset($field->if)) { $if = $field->if; if (!is_array($if)) { $if = array($if); } foreach ($if as $idx => $cond) { $if[$idx] = (array) $cond->attrs; } $filter['if'] = $if; } $filters[$name] = $filter; } $this->_xml_ruleset = $xml->ruleset; $this->_filters = $filters; $this->_message = $messages; $this->_fieldNames = $fieldsNames; $this->_xml_path = $xml_path; return TRUE; }
/** * Returns a information of addon * * @param string $addon Name to get information * @param int $site_srl Site srl * @param string $gtype site or global * @return object Returns a information */ function getAddonInfoXml($addon, $site_srl = 0, $gtype = 'site') { // Get a path of the requested module. Return if not exists. $addon_path = $this->getAddonPath($addon); if (!$addon_path) { return; } // Read the xml file for module skin information $xml_file = sprintf("%sconf/info.xml", FileHandler::getRealpath($addon_path)); if (!file_exists($xml_file)) { return; } $oXmlParser = new XmlParser(); $tmp_xml_obj = $oXmlParser->loadXmlFile($xml_file); $xml_obj = $tmp_xml_obj->addon; if (!$xml_obj) { return; } // DB is set to bring history $db_args = new stdClass(); $db_args->addon = $addon; if ($gtype == 'global') { $output = executeQuery('addon.getAddonInfo', $db_args); } else { $db_args->site_srl = $site_srl; $output = executeQuery('addon.getSiteAddonInfo', $db_args); } $extra_vals = unserialize($output->data->extra_vars); $addon_info = new stdClass(); if ($extra_vals->mid_list) { $addon_info->mid_list = $extra_vals->mid_list; } else { $addon_info->mid_list = array(); } if ($extra_vals->xe_run_method) { $addon_info->xe_run_method = $extra_vals->xe_run_method; } // Add information if ($xml_obj->version && $xml_obj->attrs->version == '0.2') { // addon format v0.2 $date_obj = new stdClass(); sscanf($xml_obj->date->body, '%d-%d-%d', $date_obj->y, $date_obj->m, $date_obj->d); $addon_info->date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d); $addon_info->addon_name = $addon; $addon_info->title = $xml_obj->title->body; $addon_info->description = trim($xml_obj->description->body); $addon_info->version = $xml_obj->version->body; $addon_info->homepage = $xml_obj->link->body; $addon_info->license = $xml_obj->license->body; $addon_info->license_link = $xml_obj->license->attrs->link; if (!is_array($xml_obj->author)) { $author_list = array(); $author_list[] = $xml_obj->author; } else { $author_list = $xml_obj->author; } $addon_info->author = array(); foreach ($author_list as $author) { $author_obj = new stdClass(); $author_obj->name = $author->name->body; $author_obj->email_address = $author->attrs->email_address; $author_obj->homepage = $author->attrs->link; $addon_info->author[] = $author_obj; } // Expand the variable order if ($xml_obj->extra_vars) { $extra_var_groups = $xml_obj->extra_vars->group; if (!$extra_var_groups) { $extra_var_groups = $xml_obj->extra_vars; } if (!is_array($extra_var_groups)) { $extra_var_groups = array($extra_var_groups); } foreach ($extra_var_groups as $group) { $extra_vars = $group->var; if (!is_array($group->var)) { $extra_vars = array($group->var); } foreach ($extra_vars as $key => $val) { if (!$val) { continue; } $obj = new stdClass(); if (!$val->attrs) { $val->attrs = new stdClass(); } if (!$val->attrs->type) { $val->attrs->type = 'text'; } $obj->group = $group->title->body; $obj->name = $val->attrs->name; $obj->title = $val->title->body; $obj->type = $val->attrs->type; $obj->description = $val->description->body; if ($obj->name) { $obj->value = $extra_vals->{$obj->name}; } if (strpos($obj->value, '|@|') != FALSE) { $obj->value = explode('|@|', $obj->value); } if ($obj->type == 'mid_list' && !is_array($obj->value)) { $obj->value = array($obj->value); } // 'Select'type obtained from the option list. if ($val->options && !is_array($val->options)) { $val->options = array($val->options); } for ($i = 0, $c = count($val->options); $i < $c; $i++) { $obj->options[$i] = new stdClass(); $obj->options[$i]->title = $val->options[$i]->title->body; $obj->options[$i]->value = $val->options[$i]->attrs->value; } $addon_info->extra_vars[] = $obj; } } } } else { // addon format 0.1 $addon_info = new stdClass(); $addon_info->addon_name = $addon; $addon_info->title = $xml_obj->title->body; $addon_info->description = trim($xml_obj->author->description->body); $addon_info->version = $xml_obj->attrs->version; $date_obj = new stdClass(); sscanf($xml_obj->author->attrs->date, '%d. %d. %d', $date_obj->y, $date_obj->m, $date_obj->d); $addon_info->date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d); $author_obj = new stdClass(); $author_obj->name = $xml_obj->author->name->body; $author_obj->email_address = $xml_obj->author->attrs->email_address; $author_obj->homepage = $xml_obj->author->attrs->link; $addon_info->author = array(); $addon_info->author[] = $author_obj; if ($xml_obj->extra_vars) { // Expand the variable order $extra_var_groups = $xml_obj->extra_vars->group; if (!$extra_var_groups) { $extra_var_groups = $xml_obj->extra_vars; } if (!is_array($extra_var_groups)) { $extra_var_groups = array($extra_var_groups); } foreach ($extra_var_groups as $group) { $extra_vars = $group->var; if (!is_array($group->var)) { $extra_vars = array($group->var); } $addon_info->extra_vars = array(); foreach ($extra_vars as $key => $val) { if (!$val) { continue; } $obj = new stdClass(); $obj->group = $group->title->body; $obj->name = $val->attrs->name; $obj->title = $val->title->body; $obj->type = $val->type->body ? $val->type->body : 'text'; $obj->description = $val->description->body; if ($obj->name) { $obj->value = $extra_vals->{$obj->name}; } if (strpos($obj->value, '|@|') != false) { $obj->value = explode('|@|', $obj->value); } if ($obj->type == 'mid_list' && !is_array($obj->value)) { $obj->value = array($obj->value); } // 'Select'type obtained from the option list. if ($val->options && !is_array($val->options)) { $val->options = array($val->options); } $obj->options = array(); for ($i = 0, $c = count($val->options); $i < $c; $i++) { $obj->options[$i]->title = $val->options[$i]->title->body; $obj->options[$i]->value = $val->options[$i]->value->body; } $addon_info->extra_vars[] = $obj; } } } } return $addon_info; }
/** * Return theme info * @param string $theme_name * @param array $layout_list * @return object */ function getThemeInfo($theme_name, $layout_list = NULL) { if ($GLOBALS['__ThemeInfo__'][$theme_name]) { return $GLOBALS['__ThemeInfo__'][$theme_name]; } $info_file = _XE_PATH_ . 'themes/' . $theme_name . '/conf/info.xml'; if (!file_exists($info_file)) { return; } $oXmlParser = new XmlParser(); $_xml_obj = $oXmlParser->loadXmlFile($info_file); if (!$_xml_obj->theme) { return; } $xml_obj = $_xml_obj->theme; // 스킨이름 $theme_info = new stdClass(); $theme_info->name = $theme_name; $theme_info->title = $xml_obj->title->body; $thumbnail = './themes/' . $theme_name . '/thumbnail.png'; $theme_info->thumbnail = FileHandler::exists($thumbnail) ? $thumbnail : NULL; $theme_info->version = $xml_obj->version->body; $date_obj = new stdClass(); sscanf($xml_obj->date->body, '%d-%d-%d', $date_obj->y, $date_obj->m, $date_obj->d); $theme_info->date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d); $theme_info->description = $xml_obj->description->body; $theme_info->path = './themes/' . $theme_name . '/'; if (!is_array($xml_obj->publisher)) { $publisher_list = array(); $publisher_list[] = $xml_obj->publisher; } else { $publisher_list = $xml_obj->publisher; } $theme_info->publisher = array(); foreach ($publisher_list as $publisher) { $publisher_obj = new stdClass(); $publisher_obj->name = $publisher->name->body; $publisher_obj->email_address = $publisher->attrs->email_address; $publisher_obj->homepage = $publisher->attrs->link; $theme_info->publisher[] = $publisher_obj; } $layout = $xml_obj->layout; $layout_path = $layout->directory->attrs->path; $layout_parse = explode('/', $layout_path); $layout_info = new stdClass(); switch ($layout_parse[1]) { case 'themes': $layout_info->name = $theme_name . '|@|' . $layout_parse[count($layout_parse) - 1]; break; case 'layouts': $layout_info->name = $layout_parse[count($layout_parse) - 1]; break; } $layout_info->title = $layout_parse[count($layout_parse) - 1]; $layout_info->path = $layout_path; $site_info = Context::get('site_module_info'); // check layout instance $is_new_layout = TRUE; $oLayoutModel = getModel('layout'); $layout_info_list = array(); $layout_list = $oLayoutModel->getLayoutList($site_info->site_srl); if ($layout_list) { foreach ($layout_list as $val) { if ($val->layout == $layout_info->name) { $is_new_layout = FALSE; $layout_info->layout_srl = $val->layout_srl; break; } } } if ($is_new_layout) { $site_module_info = Context::get('site_module_info'); $args = new stdClass(); $args->site_srl = (int) $site_module_info->site_srl; $args->layout_srl = getNextSequence(); $args->layout = $layout_info->name; $args->title = $layout_info->title; $args->layout_type = "P"; // Insert into the DB $oLayoutAdminController = getAdminController('layout'); $output = $oLayoutAdminController->insertLayout($args); $layout_info->layout_srl = $args->layout_srl; } $theme_info->layout_info = $layout_info; $skin_infos = $xml_obj->skininfos; if (is_array($skin_infos->skininfo)) { $skin_list = $skin_infos->skininfo; } else { $skin_list = array($skin_infos->skininfo); } $oModuleModel = getModel('module'); $skins = array(); foreach ($skin_list as $val) { $skin_info = new stdClass(); unset($skin_parse); $skin_parse = explode('/', $val->directory->attrs->path); switch ($skin_parse[1]) { case 'themes': $is_theme = TRUE; $module_name = $skin_parse[count($skin_parse) - 1]; $skin_info->name = $theme_name . '|@|' . $module_name; break; case 'modules': $is_theme = FALSE; $module_name = $skin_parse[2]; $skin_info->name = $skin_parse[count($skin_parse) - 1]; break; } $skin_info->path = $val->directory->attrs->path; $skin_info->is_theme = $is_theme; $skins[$module_name] = $skin_info; if ($is_theme) { if (!$GLOBALS['__ThemeModuleSkin__'][$module_name]) { $GLOBALS['__ThemeModuleSkin__'][$module_name] = array(); $GLOBALS['__ThemeModuleSkin__'][$module_name]['skins'] = array(); $moduleInfo = $oModuleModel->getModuleInfoXml($module_name); $GLOBALS['__ThemeModuleSkin__'][$module_name]['title'] = $moduleInfo->title; } $GLOBALS['__ThemeModuleSkin__'][$module_name]['skins'][$skin_info->name] = $oModuleModel->loadSkinInfo($skin_info->path, '', ''); } } $theme_info->skin_infos = $skins; $GLOBALS['__ThemeInfo__'][$theme_name] = $theme_info; return $theme_info; }
/** * @brief Modules conf/info.xml wanted to read the information * It uses caching to reduce time for xml parsing .. */ function getWidgetStyleInfo($widgetStyle) { $widgetStyle_path = $this->getWidgetStylePath($widgetStyle); if (!$widgetStyle_path) { return; } $xml_file = sprintf("%sskin.xml", $widgetStyle_path); if (!file_exists($xml_file)) { return; } // If the problem by comparing the cache file and include the return variable $widgetStyle_info $cache_file = sprintf(_XE_PATH_ . 'files/cache/widgetstyles/%s.%s.cache.php', $widgetStyle, Context::getLangType()); if (file_exists($cache_file) && filemtime($cache_file) > filemtime($xml_file)) { @(include $cache_file); return $widgetStyle_info; } // If no cache file exists, parse the xml and then return the variable. $oXmlParser = new XmlParser(); $tmp_xml_obj = $oXmlParser->loadXmlFile($xml_file); $xml_obj = $tmp_xml_obj->widgetstyle; if (!$xml_obj) { return; } $buff = array(); $buff[] = '<?php if(!defined("__XE__")) exit();'; $buff[] = '$widgetStyle_info = new stdClass();'; // Title of the widget, version $buff[] = sprintf('$widgetStyle_info->widgetStyle = "%s";', $widgetStyle); $buff[] = sprintf('$widgetStyle_info->path = "%s";', $widgetStyle_path); $buff[] = sprintf('$widgetStyle_info->title = "%s";', $xml_obj->title->body); $buff[] = sprintf('$widgetStyle_info->description = "%s";', $xml_obj->description->body); $buff[] = sprintf('$widgetStyle_info->version = "%s";', $xml_obj->version->body); sscanf($xml_obj->date->body, '%d-%d-%d', $date_obj->y, $date_obj->m, $date_obj->d); $date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d); $buff[] = sprintf('$widgetStyle_info->date = "%s";', $date); $buff[] = sprintf('$widgetStyle_info->homepage = "%s";', $xml_obj->link->body); $buff[] = sprintf('$widgetStyle_info->license = "%s";', $xml_obj->license->body); $buff[] = sprintf('$widgetStyle_info->license_link = "%s";', $xml_obj->license->attrs->link); // preview if (!$xml_obj->preview->body) { $xml_obj->preview->body = 'preview.jpg'; } $preview_file = sprintf("%s%s", $widgetStyle_path, $xml_obj->preview->body); if (file_exists($preview_file)) { $buff[] = sprintf('$widgetStyle_info->preview = "%s";', $preview_file); } // Author information if (!is_array($xml_obj->author)) { $author_list[] = $xml_obj->author; } else { $author_list = $xml_obj->author; } foreach ($author_list as $idx => $author) { $buff[] = sprintf('$widgetStyle_info->author[%d] = new stdClass();', $idx); $buff[] = sprintf('$widgetStyle_info->author[%d]->name = "%s";', $idx, $author->name->body); $buff[] = sprintf('$widgetStyle_info->author[%d]->email_address = "%s";', $idx, $author->attrs->email_address); $buff[] = sprintf('$widgetStyle_info->author[%d]->homepage = "%s";', $idx, $author->attrs->link); } // Extra vars (user defined variables to use in a template) $extra_var_groups = $xml_obj->extra_vars->group; if (!$extra_var_groups) { $extra_var_groups = $xml_obj->extra_vars; } if (!is_array($extra_var_groups)) { $extra_var_groups = array($extra_var_groups); } $extra_var_count = 0; $buff[] = sprintf('$widgetStyle_info->extra_var = new stdClass();', $extra_var_count); foreach ($extra_var_groups as $group) { $extra_vars = !is_array($group->var) ? array($group->var) : $group->var; if ($extra_vars[0]->attrs->id || $extra_vars[0]->attrs->name) { foreach ($extra_vars as $var) { $extra_var_count++; $id = $var->attrs->id ? $var->attrs->id : $var->attrs->name; $name = $var->name->body ? $var->name->body : $var->title->body; $type = $var->attrs->type ? $var->attrs->type : $var->type->body; $buff[] = sprintf('$widgetStyle_info->extra_var->%s = new stdClass();', $id); $buff[] = sprintf('$widgetStyle_info->extra_var->%s->group = "%s";', $id, $group->title->body); $buff[] = sprintf('$widgetStyle_info->extra_var->%s->name = "%s";', $id, $name); $buff[] = sprintf('$widgetStyle_info->extra_var->%s->type = "%s";', $id, $type); if ($type == 'filebox') { $buff[] = sprintf('$widgetStyle_info->extra_var->%s->filter = "%s";', $id, $var->attrs->filter); $buff[] = sprintf('$widgetStyle_info->extra_var->%s->allow_multiple = "%s";', $id, $var->attrs->allow_multiple); } $buff[] = sprintf('$widgetStyle_info->extra_var->%s->value = $vars->%s;', $id, $id); $buff[] = sprintf('$widgetStyle_info->extra_var->%s->description = "%s";', $id, str_replace('"', '\\"', $var->description->body)); if ($var->options) { $var_options = !is_array($var->options) ? array($var->options) : $var->options; foreach ($var_options as $option_item) { $buff[] = sprintf('$widgetStyle_info->extra_var->%s->options["%s"] = "%s";', $id, $option_item->value->body, $option_item->name->body); } } } } } $buff[] = sprintf('$widgetStyle_info->extra_var_count = %d;', $extra_var_count); FileHandler::writeFile($cache_file, implode(PHP_EOL, $buff)); if (file_exists($cache_file)) { @(include $cache_file); } return $widgetStyle_info; }
/** * @brief 특정 위치의 특정 스킨의 정보를 구해옴 **/ function loadSkinInfo($path, $skin, $dir = 'skins') { // 모듈의 스킨의 정보 xml 파일을 읽음 if (substr($path, -1) != '/') { $path .= '/'; } $skin_xml_file = sprintf("%s%s/%s/skin.xml", $path, $dir, $skin); if (!file_exists($skin_xml_file)) { return; } // XmlParser 객체 생성 $oXmlParser = new XmlParser(); $_xml_obj = $oXmlParser->loadXmlFile($skin_xml_file); // 스킨 정보가 없으면 return if (!$_xml_obj->skin) { return; } $xml_obj = $_xml_obj->skin; // 스킨이름 $skin_info->title = $xml_obj->title->body; // 작성자 정보 if ($xml_obj->version && $xml_obj->attrs->version == '0.2') { // skin format v0.2 sscanf($xml_obj->date->body, '%d-%d-%d', $date_obj->y, $date_obj->m, $date_obj->d); $skin_info->version = $xml_obj->version->body; $skin_info->date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d); $skin_info->homepage = $xml_obj->link->body; $skin_info->license = $xml_obj->license->body; $skin_info->license_link = $xml_obj->license->attrs->link; $skin_info->description = $xml_obj->description->body; if (!is_array($xml_obj->author)) { $author_list[] = $xml_obj->author; } else { $author_list = $xml_obj->author; } foreach ($author_list as $author) { unset($author_obj); $author_obj->name = $author->name->body; $author_obj->email_address = $author->attrs->email_address; $author_obj->homepage = $author->attrs->link; $skin_info->author[] = $author_obj; } // 확장변수를 정리 if ($xml_obj->extra_vars) { $extra_var_groups = $xml_obj->extra_vars->group; if (!$extra_var_groups) { $extra_var_groups = $xml_obj->extra_vars; } if (!is_array($extra_var_groups)) { $extra_var_groups = array($extra_var_groups); } foreach ($extra_var_groups as $group) { $extra_vars = $group->var; if (!is_array($group->var)) { $extra_vars = array($group->var); } foreach ($extra_vars as $key => $val) { unset($obj); if (!$val->attrs->type) { $val->attrs->type = 'text'; } $obj->group = $group->title->body; $obj->name = $val->attrs->name; $obj->title = $val->title->body; $obj->type = $val->attrs->type; $obj->description = $val->description->body; $obj->value = $extra_vals->{$obj->name}; $obj->default = $val->attrs->default; if (strpos($obj->value, '|@|') != false) { $obj->value = explode('|@|', $obj->value); } if ($obj->type == 'mid_list' && !is_array($obj->value)) { $obj->value = array($obj->value); } // 'select'type에서 option목록을 구한다. if (is_array($val->options)) { $option_count = count($val->options); for ($i = 0; $i < $option_count; $i++) { $obj->options[$i]->title = $val->options[$i]->title->body; $obj->options[$i]->value = $val->options[$i]->attrs->value; } } else { $obj->options[0]->title = $val->options->title->body; $obj->options[0]->value = $val->options->attrs->value; } $skin_info->extra_vars[] = $obj; } } } // history if ($xml_obj->history) { if (!is_array($xml_obj->history)) { $history[] = $xml_obj->history; } else { $history = $xml_obj->history; } foreach ($history as $item) { unset($obj); if ($item->author) { !is_array($item->author) ? $obj->author_list[] = $item->author : ($obj->author_list = $item->author); foreach ($obj->author_list as $author) { unset($author_obj); $author_obj->name = $author->name->body; $author_obj->email_address = $author->attrs->email_address; $author_obj->homepage = $author->attrs->link; $obj->author[] = $author_obj; } } $obj->name = $item->name->body; $obj->email_address = $item->attrs->email_address; $obj->homepage = $item->attrs->link; $obj->version = $item->attrs->version; $obj->date = $item->attrs->date; $obj->description = $item->description->body; if ($item->log) { !is_array($item->log) ? $obj->log[] = $item->log : ($obj->log = $item->log); foreach ($obj->log as $log) { unset($log_obj); $log_obj->text = $log->body; $log_obj->link = $log->attrs->link; $obj->logs[] = $log_obj; } } $skin_info->history[] = $obj; } } } else { // skin format v0.1 sscanf($xml_obj->maker->attrs->date, '%d-%d-%d', $date_obj->y, $date_obj->m, $date_obj->d); $skin_info->version = $xml_obj->version->body; $skin_info->date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d); $skin_info->homepage = $xml_obj->link->body; $skin_info->license = $xml_obj->license->body; $skin_info->license_link = $xml_obj->license->attrs->link; $skin_info->description = $xml_obj->maker->description->body; $skin_info->author[0]->name = $xml_obj->maker->name->body; $skin_info->author[0]->email_address = $xml_obj->maker->attrs->email_address; $skin_info->author[0]->homepage = $xml_obj->maker->attrs->link; // 스킨에서 사용되는 변수들 $extra_var_groups = $xml_obj->extra_vars->group; if (!$extra_var_groups) { $extra_var_groups = $xml_obj->extra_vars; } if (!is_array($extra_var_groups)) { $extra_var_groups = array($extra_var_groups); } foreach ($extra_var_groups as $group) { $extra_vars = $group->var; if ($extra_vars) { if (!is_array($extra_vars)) { $extra_vars = array($extra_vars); } foreach ($extra_vars as $var) { unset($obj); unset($options); $group = $group->title->body; $name = $var->attrs->name; $type = $var->attrs->type; $title = $var->title->body; $description = $var->description->body; // 'select'type에서 option목록을 구한다. if (is_array($var->default)) { $option_count = count($var->default); for ($i = 0; $i < $option_count; $i++) { $options[$i]->title = $var->default[$i]->body; $options[$i]->value = $var->default[$i]->body; } } else { $options[0]->title = $var->default->body; $options[0]->value = $var->default->body; } $width = $var->attrs->width; $height = $var->attrs->height; unset($obj); $obj->group = $group; $obj->title = $title; $obj->description = $description; $obj->name = $name; $obj->type = $type; $obj->options = $options; $obj->width = $width; $obj->height = $height; $obj->default = $options[0]->value; $skin_info->extra_vars[] = $obj; } } } } // colorset $colorset = $xml_obj->colorset->color; if ($colorset) { if (!is_array($colorset)) { $colorset = array($colorset); } foreach ($colorset as $color) { $name = $color->attrs->name; $title = $color->title->body; $screenshot = $color->attrs->src; if ($screenshot) { $screenshot = sprintf("%sskins/%s/%s", $path, $skin, $screenshot); if (!file_exists($screenshot)) { $screenshot = ""; } } else { $screenshot = ""; } unset($obj); $obj->name = $name; $obj->title = $title; $obj->screenshot = $screenshot; $skin_info->colorset[] = $obj; } } // 메뉴 종류 (레이아웃을 위한 설정) if ($xml_obj->menus->menu) { $menus = $xml_obj->menus->menu; if (!is_array($menus)) { $menus = array($menus); } $menu_count = count($menus); $skin_info->menu_count = $menu_count; for ($i = 0; $i < $menu_count; $i++) { unset($obj); $obj->name = $menus[$i]->attrs->name; if ($menus[$i]->attrs->default == "true") { $obj->default = true; } $obj->title = $menus[$i]->title->body; $obj->maxdepth = $menus[$i]->maxdepth->body; $skin_info->menu->{$obj->name} = $obj; } } return $skin_info; }