function deleteMenu($menu_srl) { // 캐시 파일 삭제 $cache_list = FileHandler::readDir("./files/cache/menu", "", false, true); if (count($cache_list)) { foreach ($cache_list as $cache_file) { $pos = strpos($cache_file, $menu_srl . '_'); if ($pos > 0) { FileHandler::removeFile($cache_file); } } } // 이미지 버튼 모두 삭제 $image_path = sprintf('./files/attach/menu_button/%s', $menu_srl); FileHandler::removeDir($image_path); $args->menu_srl = $menu_srl; // 메뉴 메뉴 삭제 $output = executeQuery("menu.deleteMenuItems", $args); if (!$output->toBool()) { return $output; } // 메뉴 삭제 $output = executeQuery("menu.deleteMenu", $args); if (!$output->toBool()) { return $output; } return new Object(0, 'success_deleted'); }
/** * @brief 지원 가능한 DB 목록을 return **/ function _getSupportedList() { $db_classes_path = _XE_PATH_ . "classes/db/"; $filter = "/^DB([^\\.]+)\\.class\\.php/i"; $supported_list = FileHandler::readDir($db_classes_path, $filter, true); sort($supported_list); // 구해진 클래스의 객체 생성후 isSupported method를 통해 지원 여부를 판단 for ($i = 0; $i < count($supported_list); $i++) { $db_type = $supported_list[$i]; if (version_compare(phpversion(), '5.0') < 0 && preg_match('/pdo/i', $db_type)) { continue; } $class_name = sprintf("DB%s%s", strtoupper(substr($db_type, 0, 1)), strtolower(substr($db_type, 1))); $class_file = sprintf(_XE_PATH_ . "classes/db/%s.class.php", $class_name); if (!file_exists($class_file)) { continue; } unset($oDB); require_once $class_file; $eval_str = sprintf('$oDB = new %s();', $class_name); eval($eval_str); if (!$oDB) { continue; } $obj = null; $obj->db_type = $db_type; $obj->enable = $oDB->isSupported() ? true : false; $this->supported_list[] = $obj; } return $this->supported_list; }
/** * @brief 업데이트 실행 **/ function moduleUpdate() { $oDB =& DB::getInstance(); // 2009. 02. 11 menu 테이블에 site_srl 추가 if (!$oDB->isColumnExists('layouts', 'site_srl')) { $oDB->addColumn('layouts', 'site_srl', 'number', 11, 0, true); } // 2009. 02. 26 faceOff에 맞춰 기존 레이아웃 편집본을 이동 $oLayoutModel =& getModel('layout'); $files = FileHandler::readDir('./files/cache/layout'); for ($i = 0, $c = count($files); $i < $c; $i++) { $filename = $files[$i]; if (!preg_match('/([0-9]+)\\.html/i', $filename, $match)) { continue; } $layout_srl = $match[1]; if (!$layout_srl) { continue; } $path = $oLayoutModel->getUserLayoutPath($layout_srl); if (!is_dir($path)) { FileHandler::makeDir($path); } FileHandler::copyFile('./files/cache/layout/' . $filename, $path . 'layout.html'); @unlink('./files/cache/layout/' . $filename); } return new Object(0, 'success_updated'); }
/** * Regenerate all cache files * @return void */ function procAdminRecompileCacheFile() { // rename cache dir Rhymix\Framework\Storage::move(\RX_BASEDIR . 'files/cache', \RX_BASEDIR . 'files/cache_' . time()); Rhymix\Framework\Storage::createDirectory(\RX_BASEDIR . 'files/cache'); // remove module extend cache Rhymix\Framework\Storage::delete(RX_BASEDIR . 'files/config/module_extend.php'); // remove debug files Rhymix\Framework\Storage::delete(RX_BASEDIR . 'files/_debug_message.php'); Rhymix\Framework\Storage::delete(RX_BASEDIR . 'files/_debug_db_query.php'); Rhymix\Framework\Storage::delete(RX_BASEDIR . 'files/_db_slow_query.php'); $oModuleModel = getModel('module'); $module_list = $oModuleModel->getModuleList(); // call recompileCache for each module foreach ($module_list as $module) { $oModule = NULL; $oModule = getClass($module->module); if (method_exists($oModule, 'recompileCache')) { $oModule->recompileCache(); } } // remove object cache if (!in_array(Rhymix\Framework\Cache::getDriverName(), array('file', 'sqlite', 'dummy'))) { Rhymix\Framework\Cache::clearAll(); } // remove old cache dir $tmp_cache_list = FileHandler::readDir(\RX_BASEDIR . 'files', '/^(cache_[0-9]+)/'); if ($tmp_cache_list) { foreach ($tmp_cache_list as $tmp_dir) { if (strval($tmp_dir) !== '') { $tmp_dir = \RX_BASEDIR . 'files/' . strval($tmp_dir); if (!Rhymix\Framework\Storage::isDirectory($tmp_dir)) { continue; } // If possible, use system command to speed up recursive deletion if (function_exists('exec') && !preg_match('/(?<!_)exec/', ini_get('disable_functions'))) { if (strncasecmp(\PHP_OS, 'win', 3) == 0) { @exec('rmdir /S /Q ' . escapeshellarg($tmp_dir)); } else { @exec('rm -rf ' . escapeshellarg($tmp_dir)); } } // If the directory still exists, delete using PHP. Rhymix\Framework\Storage::deleteDirectory($tmp_dir); } } } // remove duplicate indexes (only for CUBRID) $db_type = Context::getDBType(); if ($db_type == 'cubrid') { $db = DB::getInstance(); $db->deleteDuplicateIndexes(); } // check autoinstall packages $oAutoinstallAdminController = getAdminController('autoinstall'); $oAutoinstallAdminController->checkInstalled(); $this->setMessage('success_updated'); }
/** * Regenerate all cache files * @return void */ function procAdminRecompileCacheFile() { // rename cache dir $temp_cache_dir = './files/cache_' . $_SERVER['REQUEST_TIME']; FileHandler::rename('./files/cache', $temp_cache_dir); FileHandler::makeDir('./files/cache'); // remove module extend cache FileHandler::removeFile(_XE_PATH_ . 'files/config/module_extend.php'); // remove debug files FileHandler::removeFile(_XE_PATH_ . 'files/_debug_message.php'); FileHandler::removeFile(_XE_PATH_ . 'files/_debug_db_query.php'); FileHandler::removeFile(_XE_PATH_ . 'files/_db_slow_query.php'); $oModuleModel = getModel('module'); $module_list = $oModuleModel->getModuleList(); // call recompileCache for each module foreach ($module_list as $module) { $oModule = NULL; $oModule = getClass($module->module); if (method_exists($oModule, 'recompileCache')) { $oModule->recompileCache(); } } // remove cache $truncated = array(); $oObjectCacheHandler = CacheHandler::getInstance('object'); $oTemplateCacheHandler = CacheHandler::getInstance('template'); if ($oObjectCacheHandler->isSupport()) { $truncated[] = $oObjectCacheHandler->truncate(); } if ($oTemplateCacheHandler->isSupport()) { $truncated[] = $oTemplateCacheHandler->truncate(); } if (count($truncated) && in_array(FALSE, $truncated)) { return new Object(-1, 'msg_self_restart_cache_engine'); } // remove cache dir $tmp_cache_list = FileHandler::readDir('./files', '/(^cache_[0-9]+)/'); if ($tmp_cache_list) { foreach ($tmp_cache_list as $tmp_dir) { if ($tmp_dir) { FileHandler::removeDir('./files/' . $tmp_dir); } } } // remove duplicate indexes (only for CUBRID) $db_type = Context::getDBType(); if ($db_type == 'cubrid') { $db = DB::getInstance(); $db->deleteDuplicateIndexes(); } // check autoinstall packages $oAutoinstallAdminController = getAdminController('autoinstall'); $oAutoinstallAdminController->checkInstalled(); $this->setMessage('success_updated'); }
/** * Returns addon list * * @param int $site_srl Site srl * @param string $gtype site or global * @return array Returns addon list */ function getAddonList($site_srl = 0, $gtype = 'site') { // Wanted to add a list of activated $inserted_addons = $this->getInsertedAddons($site_srl, $gtype); // Downloaded and installed add-on to the list of Wanted $searched_list = FileHandler::readDir('./addons', '/^([a-zA-Z0-9-_]+)$/'); $searched_count = count($searched_list); if (!$searched_count) { return; } sort($searched_list); $oAddonAdminController = getAdminController('addon'); for ($i = 0; $i < $searched_count; $i++) { // Add the name of $addon_name = $searched_list[$i]; if ($addon_name == "smartphone") { continue; } // Add the path (files/addons precedence) $path = $this->getAddonPath($addon_name); // Wanted information on the add-on $info = $this->getAddonInfoXml($addon_name, $site_srl, $gtype); if (!$info) { $info = new stdClass(); } $info->addon = $addon_name; $info->path = $path; $info->activated = FALSE; $info->mactivated = FALSE; $info->fixed = FALSE; // Check if a permossion is granted entered in DB if (!in_array($addon_name, array_keys($inserted_addons))) { // If not, type in the DB type (model, perhaps because of the hate doing this haneungeo .. ㅡ. ㅜ) $oAddonAdminController->doInsert($addon_name, $site_srl, $type, 'N', new stdClass()); // Is activated } else { if ($inserted_addons[$addon_name]->is_used == 'Y') { $info->activated = TRUE; } if ($inserted_addons[$addon_name]->is_used_m == 'Y') { $info->mactivated = TRUE; } if ($gtype == 'global' && $inserted_addons[$addon_name]->is_fixed == 'Y') { $info->fixed = TRUE; } } $list[] = $info; } return $list; }
/** * Regenerate all cache files * @return void */ function procAdminRecompileCacheFile() { // rename cache dir $temp_cache_dir = './files/cache_' . time(); FileHandler::rename('./files/cache', $temp_cache_dir); FileHandler::makeDir('./files/cache'); // remove debug files FileHandler::removeFile(_XE_PATH_ . 'files/_debug_message.php'); FileHandler::removeFile(_XE_PATH_ . 'files/_debug_db_query.php'); FileHandler::removeFile(_XE_PATH_ . 'files/_db_slow_query.php'); $oModuleModel =& getModel('module'); $module_list = $oModuleModel->getModuleList(); // call recompileCache for each module foreach ($module_list as $module) { $oModule = null; $oModule =& getClass($module->module); if (method_exists($oModule, 'recompileCache')) { $oModule->recompileCache(); } } // remove cache $truncated = array(); $oObjectCacheHandler =& CacheHandler::getInstance('object'); $oTemplateCacheHandler =& CacheHandler::getInstance('template'); if ($oObjectCacheHandler->isSupport()) { $truncated[] = $oObjectCacheHandler->truncate(); } if ($oTemplateCacheHandler->isSupport()) { $truncated[] = $oTemplateCacheHandler->truncate(); } if (count($truncated) && in_array(false, $truncated)) { return new Object(-1, 'msg_self_restart_cache_engine'); } // remove cache dir $tmp_cache_list = FileHandler::readDir('./files', '/(^cache_[0-9]+)/'); if ($tmp_cache_list) { foreach ($tmp_cache_list as $tmp_dir) { if ($tmp_dir) { FileHandler::removeDir('./files/' . $tmp_dir); } } } // remove duplicate indexes (only for CUBRID) $db_type =& Context::getDBType(); if ($db_type == 'cubrid') { $db =& DB::getInstance(); $db->deleteDuplicateIndexes(); } $this->setMessage('success_updated'); }
/** * Execute update * @return Object */ function moduleUpdate() { $oDB =& DB::getInstance(); // 2009. 02. 11 Add site_srl to menu table if (!$oDB->isColumnExists('layouts', 'site_srl')) { $oDB->addColumn('layouts', 'site_srl', 'number', 11, 0, true); } // 2009. 02. 26 Move the previous layout for faceoff $oLayoutModel = getModel('layout'); $files = FileHandler::readDir('./files/cache/layout'); for ($i = 0, $c = count($files); $i < $c; $i++) { $filename = $files[$i]; if (!preg_match('/([0-9]+)\\.html/i', $filename, $match)) { continue; } $layout_srl = $match[1]; if (!$layout_srl) { continue; } $path = $oLayoutModel->getUserLayoutPath($layout_srl); if (!is_dir($path)) { FileHandler::makeDir($path); } FileHandler::copyFile('./files/cache/layout/' . $filename, $path . 'layout.html'); @unlink('./files/cache/layout/' . $filename); } if (!$oDB->isColumnExists('layouts', 'layout_type')) { $oDB->addColumn('layouts', 'layout_type', 'char', 1, 'P', true); } $args = new stdClass(); $args->layout = '.'; $output = executeQueryArray('layout.getLayoutDotList', $args); if ($output->data && count($output->data) > 0) { foreach ($output->data as $layout) { $layout_path = explode('.', $layout->layout); if (count($layout_path) != 2) { continue; } if (is_dir(sprintf(_XE_PATH_ . 'themes/%s/layouts/%s', $layout_path[0], $layout_path[1]))) { $args->layout = implode('|@|', $layout_path); $args->layout_srl = $layout->layout_srl; $output = executeQuery('layout.updateLayout', $args); Rhymix\Framework\Cache::delete('layout:' . $args->layout_srl); } } } return new Object(0, 'success_updated'); }
/** * Returns table information * * Used for finding column type info (string/numeric) <br /> * Obtains the table info from XE's XML schema files * * @param object $query_id * @param bool $table_name * @return array */ function getTableInfo($query_id, $table_name) { $column_type = array(); $module = ''; $id_args = explode('.', $query_id); if (count($id_args) == 2) { $target = 'modules'; $module = $id_args[0]; $id = $id_args[1]; } else { if (count($id_args) == 3) { $target = $id_args[0]; $targetList = array('modules' => 1, 'addons' => 1, 'widgets' => 1); if (!isset($targetList[$target])) { return; } $module = $id_args[1]; $id = $id_args[2]; } } // get column properties from the table $table_file = sprintf('%s%s/%s/schemas/%s.xml', _XE_PATH_, 'modules', $module, $table_name); if (!file_exists($table_file)) { $searched_list = FileHandler::readDir(_XE_PATH_ . 'modules'); $searched_count = count($searched_list); for ($i = 0; $i < $searched_count; $i++) { $table_file = sprintf('%s%s/%s/schemas/%s.xml', _XE_PATH_, 'modules', $searched_list[$i], $table_name); if (file_exists($table_file)) { break; } } } if (file_exists($table_file)) { $table_xml = FileHandler::readFile($table_file); $xml_parser = new XmlParser(); $table_obj = $xml_parser->parse($table_xml); if ($table_obj->table) { if (isset($table_obj->table->column) && !is_array($table_obj->table->column)) { $table_obj->table->column = array($table_obj->table->column); } foreach ($table_obj->table->column as $k => $v) { $column_type[$v->attrs->name] = $v->attrs->type; } } } return $column_type; }
/** * @brief 위젯의 종류와 정보를 구함 * 다운로드되어 있는 위젯의 종류 (생성과 다른 의미) **/ function getDownloadedWidgetStyleList() { // 다운받은 위젯과 설치된 위젯의 목록을 구함 $searched_list = FileHandler::readDir('./widgetstyles'); $searched_count = count($searched_list); if (!$searched_count) { return; } sort($searched_list); // 찾아진 위젯 목록을 loop돌면서 필요한 정보를 간추려 return for ($i = 0; $i < $searched_count; $i++) { // 위젯의 이름 $widgetStyle = $searched_list[$i]; // 해당 위젯의 정보를 구함 $widgetStyle_info = $this->getWidgetStyleInfo($widgetStyle); $list[] = $widgetStyle_info; } return $list; }
/** * @brief 기본 설정 **/ function dispPointAdminConfig() { // 레벨 아이콘 목록 구함 $level_icon_list = FileHandler::readDir("./modules/point/icons"); Context::set('level_icon_list', $level_icon_list); // 그룹 목록 가져오기 $oMemberModel =& getModel('member'); $group_list = $oMemberModel->getGroups(); $selected_group_list = array(); if (count($group_list)) { foreach ($group_list as $key => $val) { if ($val->is_admin == 'Y' || $val->is_default == 'Y') { continue; } $selected_group_list[$key] = $val; } } Context::set('group_list', $selected_group_list); // 템플릿 지정 $this->setTemplateFile('config'); }
/** * @brief Default configurations */ function dispPointAdminConfig() { // Get the list of level icons $level_icon_list = FileHandler::readDir("./modules/point/icons"); Context::set('level_icon_list', $level_icon_list); // Get the list of groups $oMemberModel = getModel('member'); $group_list = $oMemberModel->getGroups(); $selected_group_list = array(); if (count($group_list)) { foreach ($group_list as $key => $val) { $selected_group_list[$key] = $val; } } Context::set('group_list', $selected_group_list); //Security $security = new Security(); $security->encodeHTML('group_list..title', 'group_list..description'); // Set the template $this->setTemplateFile('config'); }
/** * @brief popup window to display in popup window request is to add content */ function getPopupContent() { // Bringing a list of emoticons directory $emoticon_dirs = FileHandler::readDir($this->emoticon_path); $emoticon_list = array(); if ($emoticon_dirs) { foreach ($emoticon_dirs as $emoticon) { if (preg_match("/^([a-z0-9\\_]+)\$/i", $emoticon)) { $emoticon_list[] = $emoticon; } } } Context::set('emoticon_list', $emoticon_list); // The first emoticon image files in the directory Wanted $emoticons = $this->getEmoticons($emoticon_list[0]); Context::set('emoticons', $emoticons); // Pre-compiled source code to compile template return to $tpl_path = $this->component_path . 'tpl'; $tpl_file = 'popup.html'; $oTemplate =& TemplateHandler::getInstance(); return $oTemplate->compile($tpl_path, $tpl_file); }
/** * @brief popup window요청시 popup window에 출력할 내용을 추가하면 된다 **/ function getPopupContent() { // 이모티콘 디렉토리 목록을 가져옴 $emoticon_dirs = FileHandler::readDir($this->emoticon_path); $emoticon_list = array(); if ($emoticon_dirs) { foreach ($emoticon_dirs as $emoticon) { if (preg_match("/^([a-z0-9\\_]+)\$/i", $emoticon)) { $emoticon_list[] = $emoticon; } } } Context::set('emoticon_list', $emoticon_list); // 첫번째 이모티콘 디렉토리의 이미지 파일을 구함 $emoticons = $this->getEmoticons($emoticon_list[0]); Context::set('emoticons', $emoticons); // 템플릿을 미리 컴파일해서 컴파일된 소스를 return $tpl_path = $this->component_path . 'tpl'; $tpl_file = 'popup.html'; $oTemplate =& TemplateHandler::getInstance(); return $oTemplate->compile($tpl_path, $tpl_file); }
/** * @brief 애드온의 종류와 정보를 구함 **/ function getAddonList($site_srl = 0) { // activated된 애드온 목록을 구함 $inserted_addons = $this->getInsertedAddons($site_srl); // 다운받은 애드온과 설치된 애드온의 목록을 구함 $searched_list = FileHandler::readDir('./addons'); $searched_count = count($searched_list); if (!$searched_count) { return; } sort($searched_list); for ($i = 0; $i < $searched_count; $i++) { // 애드온의 이름 $addon_name = $searched_list[$i]; // 애드온의 경로 (files/addons가 우선) $path = $this->getAddonPath($addon_name); // 해당 애드온의 정보를 구함 unset($info); $info = $this->getAddonInfoXml($addon_name, $site_srl); $info->addon = $addon_name; $info->path = $path; $info->activated = false; // DB에 입력되어 있는지 확인 if (!in_array($addon_name, array_keys($inserted_addons))) { // DB에 입력되어 있지 않으면 입력 (model에서 이런짓 하는거 싫지만 귀찮아서.. ㅡ.ㅜ) $oAddonAdminController =& getAdminController('addon'); $oAddonAdminController->doInsert($addon_name, $site_srl); // 활성화 되어 있는지 확인 } else { if ($inserted_addons[$addon_name]->is_used == 'Y') { $info->activated = true; } } $list[] = $info; } return $list; }
/** * @brief Wanted photos of the type and information * Download a widget with type (generation and other means) */ function getDownloadedWidgetStyleList() { // 've Downloaded the widget and the widget's list of installed Wanted $searched_list = FileHandler::readDir('./widgetstyles'); $searched_count = count($searched_list); if (!$searched_count) { return; } sort($searched_list); // D which pertain to the list of widgets loop spins return statement review the information you need for ($i = 0; $i < $searched_count; $i++) { // The name of the widget $widgetStyle = $searched_list[$i]; // Wanted information on the Widget $widgetStyle_info = $this->getWidgetStyleInfo($widgetStyle); $list[] = $widgetStyle_info; } return $list; }
/** * Saved file list for User Layout * @param int $layout_srl * @return array files info */ function getUserLayoutFileList($layout_srl) { $file_list = array(basename($this->getUserLayoutHtml($layout_srl)), basename($this->getUserLayoutFaceOffCss($layout_srl)), basename($this->getUserLayoutIni($layout_srl)), basename($this->getUserLayoutCss($layout_srl))); $image_path = $this->getUserLayoutImagePath($layout_srl); $image_list = FileHandler::readDir($image_path, '/(.*(?:swf|jpg|jpeg|gif|bmp|png)$)/i'); foreach ($image_list as $image) { $file_list[] = 'images/' . $image; } return $file_list; }
/** * @brief 개별 모듈의 설치 **/ function installModule($module, $module_path) { // db instance생성 $oDB =& DB::getInstance(); // 해당 모듈의 schemas 디렉토리를 검사하여 schema xml파일이 있으면 생성 $schema_dir = sprintf('%s/schemas/', $module_path); $schema_files = FileHandler::readDir($schema_dir, NULL, false, true); $file_cnt = count($schema_files); for ($i = 0; $i < $file_cnt; $i++) { $file = trim($schema_files[$i]); if (!$file || substr($file, -4) != '.xml') { continue; } $output = $oDB->createTableByXmlFile($file); } // 테이블 설치후 module instance를 만들고 install() method를 실행 unset($oModule); $oModule =& getClass($module); if (method_exists($oModule, 'moduleInstall')) { $oModule->moduleInstall(); } return new Object(); }
/** * @brief Add a form for editor addition setup */ function triggerDispEditorAdditionSetup(&$obj) { $current_module_srl = Context::get('module_srl'); $current_module_srls = Context::get('module_srls'); if (!$current_module_srl && !$current_module_srls) { // Get information of the current module $current_module_info = Context::get('current_module_info'); $current_module_srl = $current_module_info->module_srl; if (!$current_module_srl) { return new Object(); } } // Get editors settings $oEditorModel = getModel('editor'); $editor_config = $oEditorModel->getEditorConfig($current_module_srl); Context::set('editor_config', $editor_config); $oModuleModel = getModel('module'); // Get a list of editor skin $editor_skin_list = FileHandler::readDir(_XE_PATH_ . 'modules/editor/skins'); Context::set('editor_skin_list', $editor_skin_list); $skin_info = $oModuleModel->loadSkinInfo($this->module_path, $editor_config->editor_skin); Context::set('editor_colorset_list', $skin_info->colorset); $skin_info = $oModuleModel->loadSkinInfo($this->module_path, $editor_config->comment_editor_skin); Context::set('editor_comment_colorset_list', $skin_info->colorset); $contents = FileHandler::readDir(_XE_PATH_ . 'modules/editor/styles'); $content_style_list = array(); for ($i = 0, $c = count($contents); $i < $c; $i++) { $style = $contents[$i]; $info = $oModuleModel->loadSkinInfo($this->module_path, $style, 'styles'); $content_style_list[$style] = new stdClass(); $content_style_list[$style]->title = $info->title; } Context::set('content_style_list', $content_style_list); // Get a group list $oMemberModel = getModel('member'); $site_module_info = Context::get('site_module_info'); $group_list = $oMemberModel->getGroups($site_module_info->site_srl); Context::set('group_list', $group_list); //Security $security = new Security(); $security->encodeHTML('group_list..title'); $security->encodeHTML('group_list..description'); $security->encodeHTML('content_style_list..'); $security->encodeHTML('editor_comment_colorset_list..title'); // Set a template file $oTemplate =& TemplateHandler::getInstance(); $tpl = $oTemplate->compile($this->module_path . 'tpl', 'editor_module_config'); $obj .= $tpl; return new Object(); }
/** * @brief when menu add in sitemap, select module list * this menu showing with trigger * @param int $site_srl * @return array */ function getModuleListInSitemap($site_srl = 0) { $oModuleModel = getModel('module'); $moduleList = array('page'); $output = $oModuleModel->getModuleListByInstance($site_srl); if (is_array($output->data)) { foreach ($output->data as $value) { if ($value->instanceCount > 1) { $moduleList[] = $value->module; } } } // after trigger $output = ModuleHandler::triggerCall('menu.getModuleListInSitemap', 'after', $moduleList); if (!$output->toBool()) { return $output; } $localModuleList = array_unique($moduleList); $oAutoinstallModel = getModel('autoinstall'); // get have instance $remotePackageList = $oAutoinstallModel->getHaveInstance(array('path')); $remoteModuleList = array(); foreach ($remotePackageList as $package) { if (strpos($package->path, './modules/') !== 0) { continue; } $pathInfo = explode('/', $package->path); $remoteModuleList[] = $pathInfo[2]; } // all module list $allModuleList = FileHandler::readDir('./modules', '/^([a-zA-Z0-9_-]+)$/'); // union have instance and all module list $haveInstance = array_intersect($remoteModuleList, $allModuleList); $haveDirectory = array_intersect($localModuleList, $allModuleList); // union $moduleList = array_unique(array_merge($haveDirectory, $haveInstance)); $moduleInfoList = array(); Context::loadLang('modules/page/lang'); if (is_array($moduleList)) { foreach ($moduleList as $value) { $moduleInfo = $oModuleModel->getModuleInfoXml($value); if ($value == 'page') { $pageTypeName = Context::getLang('page_type_name'); $moduleInfo->title = $pageTypeName['ARTICLE']; $moduleInfoList['ARTICLE'] = $moduleInfo; $wModuleInfo = clone $moduleInfo; unset($wModuleInfo->default_skin, $wModuleInfo->default_mskin); $wModuleInfo->title = $pageTypeName['WIDGET']; $wModuleInfo->no_skin = 'Y'; $moduleInfoList['WIDGET'] = $wModuleInfo; $oModuleInfo = clone $moduleInfo; unset($oModuleInfo->default_skin, $oModuleInfo->default_mskin); $oModuleInfo->title = $pageTypeName['OUTSIDE']; $oModuleInfo->no_skin = 'Y'; $moduleInfoList['OUTSIDE'] = $oModuleInfo; } else { $moduleInfoList[$value] = $moduleInfo; } } } return $moduleInfoList; }
/** * @brief Install an each module */ function installModule($module, $module_path) { // create db instance $oDB =& DB::getInstance(); // Create a table if the schema xml exists in the "schemas" directory of the module $schema_dir = sprintf('%s/schemas/', $module_path); $schema_files = FileHandler::readDir($schema_dir, NULL, false, true); $file_cnt = count($schema_files); for ($i = 0; $i < $file_cnt; $i++) { $file = trim($schema_files[$i]); if (!$file || substr($file, -4) != '.xml') { continue; } $output = $oDB->createTableByXmlFile($file); if ($output === false) { throw new Exception('msg_create_table_failed'); } } // Create a table and module instance and then execute install() method unset($oModule); $oModule = getClass($module); if (method_exists($oModule, 'moduleInstall')) { $oModule->moduleInstall(); } return new Object(); }
/** * Get default skin name */ function getModuleDefaultSkin($module_name, $skin_type = 'P', $site_srl = 0, $updateCache = true) { $target = $skin_type == 'M' ? 'mskin' : 'skin'; if (!$site_srl) { $site_srl = 0; } $designInfoFile = sprintf(_XE_PATH_ . 'files/site_design/design_%s.php', $site_srl); if (is_readable($designInfoFile)) { include $designInfoFile; $skinName = $designInfo->module->{$module_name}->{$target}; } if (!$skinName) { $dir = $skin_type == 'M' ? 'm.skins/' : 'skins/'; $moduleSkinPath = ModuleHandler::getModulePath($module_name) . $dir; if (is_dir($moduleSkinPath . 'default')) { $skinName = 'default'; } else { if (is_dir($moduleSkinPath . 'xe_default')) { $skinName = 'xe_default'; } else { $skins = FileHandler::readDir($moduleSkinPath); if (count($skins) > 0) { $skinName = $skins[0]; } else { $skinName = NULL; } } } if ($updateCache && $skinName) { if (!isset($designInfo->module->{$module_name})) { $designInfo->module->{$module_name} = new stdClass(); } $designInfo->module->{$module_name}->{$target} = $skinName; $oAdminController = getAdminController('admin'); $oAdminController->makeDefaultDesignFile($designInfo, $site_srl); } } return $skinName; }
/** * Uninstall module. * * Call module's moduleUninstall() and drop all tables related module * * @return Object */ function uninstallModule() { $path_array = explode("/", $this->package->path); $target_name = array_pop($path_array); $oModule = getModule($target_name, "class"); if (!$oModule) { return new Object(-1, 'msg_invalid_request'); } if (!method_exists($oModule, "moduleUninstall")) { return new Object(-1, 'msg_invalid_request'); } $output = $oModule->moduleUninstall(); if (is_subclass_of($output, 'Object') && !$output->toBool()) { return $output; } $schema_dir = sprintf('%s/schemas/', $this->package->path); $schema_files = FileHandler::readDir($schema_dir); $oDB = DB::getInstance(); if (is_array($schema_files)) { foreach ($schema_files as $file) { $filename_arr = explode(".", $file); $filename = array_shift($filename_arr); $oDB->dropTable($filename); } } return new Object(); }
function dispTextyleToolConfigCommunication() { $editor_skin_list = FileHandler::readDir(_XE_PATH_ . 'modules/editor/skins'); Context::set('editor_skin_list', $editor_skin_list); $oRssModel =& getModel('rss'); Context::set('rss_config', $oRssModel->getRssModuleConfig($this->module_srl)); }
} for ($j = 0; $j < count($tags); $j++) { $tag_list[] = $tags[$j]->string->body; } if (count($tag_list)) { $obj->tags = implode(',', $tag_list); } break; } } // Document srl $obj->document_srl = $document_srl; $obj->module_srl = $this->module_srl; // Attachment if (is_dir($tmp_uploaded_path)) { $file_list = FileHandler::readDir($tmp_uploaded_path); $file_count = count($file_list); if ($file_count) { $oFileController =& getController('file'); for ($i = 0; $i < $file_count; $i++) { $file_info['tmp_name'] = sprintf('%s%s', $tmp_uploaded_path, $file_list[$i]); $file_info['name'] = $file_list[$i]; $moved_filename = sprintf('./files/attach/images/%s/%s/%s', $this->module_srl, $document_srl, $file_info['name']); if (file_exists($moved_filename)) { continue; } $fileOutput = $oFileController->insertFile($file_info, $this->module_srl, $document_srl, 0, true); $uploaded_filename = $fileOutput->get('uploaded_filename'); $source_filename = $fileOutput->get('source_filename'); $obj->content = str_replace($uploaded_target_path . $source_filename, sprintf('/files/attach/images/%s/%s%s', $this->module_srl, getNumberingPath($document_srl, 3), $uploaded_filename), $obj->content); }
/** * returns list of supported dbms list * this method is private * @return array return supported DBMS list */ function _getSupportedList() { static $get_supported_list = ''; if (is_array($get_supported_list)) { $this->supported_list = $get_supported_list; return $this->supported_list; } $get_supported_list = array(); $db_classes_path = _XE_PATH_ . "classes/db/"; $filter = "/^DB([^\\.]+)\\.class\\.php/i"; $supported_list = FileHandler::readDir($db_classes_path, $filter, TRUE); // after creating instance of class, check is supported for ($i = 0; $i < count($supported_list); $i++) { $db_type = $supported_list[$i]; $class_name = sprintf("DB%s%s", strtoupper(substr($db_type, 0, 1)), strtolower(substr($db_type, 1))); $class_file = sprintf(_XE_PATH_ . "classes/db/%s.class.php", $class_name); if (!file_exists($class_file)) { continue; } unset($oDB); require_once $class_file; $oDB = new $class_name(); if (!$oDB) { continue; } $obj = new stdClass(); $obj->db_type = $db_type; $obj->enable = $oDB->isSupported() ? TRUE : FALSE; $get_supported_list[] = $obj; } // sort @usort($get_supported_list, array($this, '_sortDBMS')); $this->supported_list = $get_supported_list; return $this->supported_list; }
/** * Get shop user skin file list * * @author Arnia (dev@xpressengine.org) * @param $module_srl * @return string[] */ public function getShopUserSkinFileList($module_srl) { $skin_path = $this->getShopPath($module_srl); $skin_file_list = FileHandler::readDir($skin_path, '/(\.html|\.htm|\.css)$/'); return $skin_file_list; }
/** * @brief Caching a list of editor component (editorModel::getComponentList) * For the editor component list, use a caching file because of DB query and Xml parsing **/ function makeCache($filter_enabled = true, $site_srl) { $oEditorModel =& getModel('editor'); if ($filter_enabled) { $args->enabled = "Y"; } if ($site_srl) { $args->site_srl = $site_srl; $output = executeQuery('editor.getSiteComponentList', $args); } else { $output = executeQuery('editor.getComponentList', $args); } $db_list = $output->data; // Get a list of files $downloaded_list = FileHandler::readDir(_XE_PATH_ . 'modules/editor/components'); // Get information about log-in status and its group $is_logged = Context::get('is_logged'); if ($is_logged) { $logged_info = Context::get('logged_info'); if ($logged_info->group_list && is_array($logged_info->group_list)) { $group_list = array_keys($logged_info->group_list); } else { $group_list = array(); } } // Get xml information for looping DB list if (!is_array($db_list)) { $db_list = array($db_list); } foreach ($db_list as $component) { if (in_array($component->component_name, array('colorpicker_text', 'colorpicker_bg'))) { continue; } $component_name = $component->component_name; if (!$component_name) { continue; } if (!in_array($component_name, $downloaded_list)) { continue; } unset($xml_info); $xml_info = $oEditorModel->getComponentXmlInfo($component_name); $xml_info->enabled = $component->enabled; if ($component->extra_vars) { $extra_vars = unserialize($component->extra_vars); if ($extra_vars->target_group) { $xml_info->target_group = $extra_vars->target_group; } if ($extra_vars->mid_list && count($extra_vars->mid_list)) { $xml_info->mid_list = $extra_vars->mid_list; } /* // Permisshin check if you are granted if($extra_vars->target_group) { // Stop using if not logged-in if(!$is_logged) continue; // Compare a target group with the current logged-in user group $target_group = $extra_vars->target_group; unset($extra_vars->target_group); $is_granted = false; foreach($group_list as $group_srl) { if(in_array($group_srl, $target_group)) { $is_granted = true; break; } } if(!$is_granted) continue; } // Check if the target module exists if($extra_vars->mid_list && count($extra_vars->mid_list) && Context::get('mid')) { if(!in_array(Context::get('mid'), $extra_vars->mid_list)) continue; }*/ // Check the configuration of the editor component if ($xml_info->extra_vars) { foreach ($xml_info->extra_vars as $key => $val) { $xml_info->extra_vars->{$key}->value = $extra_vars->{$key}; } } } $component_list->{$component_name} = $xml_info; // Get buttons, icons, images $icon_file = _XE_PATH_ . 'modules/editor/components/' . $component_name . '/icon.gif'; $component_icon_file = _XE_PATH_ . 'modules/editor/components/' . $component_name . '/component_icon.gif'; if (file_exists($icon_file)) { $component_list->{$component_name}->icon = true; } if (file_exists($component_icon_file)) { $component_list->{$component_name}->component_icon = true; } } // Return if it checks enabled only if ($filter_enabled) { $cache_file = $oEditorModel->getCacheFile($filter_enabled, $site_srl); $buff = sprintf('<?php if(!defined("__ZBXE__")) exit(); $component_list = unserialize("%s"); ?>', str_replace('"', '\\"', serialize($component_list))); FileHandler::writeFile($cache_file, $buff); return $component_list; } // Get xml_info of downloaded list foreach ($downloaded_list as $component_name) { if (in_array($component_name, array('colorpicker_text', 'colorpicker_bg'))) { continue; } // Pass if configured if ($component_list->{$component_name}) { continue; } // Insert data into the DB $oEditorController =& getAdminController('editor'); $oEditorController->insertComponent($component_name, false, $site_srl); // Add to component_list unset($xml_info); $xml_info = $oEditorModel->getComponentXmlInfo($component_name); $xml_info->enabled = 'N'; $component_list->{$component_name} = $xml_info; } $cache_file = $oEditorModel->getCacheFile($filter_enabled, $site_srl); $buff = sprintf('<?php if(!defined("__ZBXE__")) exit(); $component_list = unserialize("%s"); ?>', str_replace('"', '\\"', serialize($component_list))); FileHandler::writeFile($cache_file, $buff); return $component_list; }
/** * @brief Return a list of the editor skin */ function getEditorSkinList() { return FileHandler::readDir('./modules/editor/skins'); }
/** * @brief Administrator Setting page * Settings to enable/disable editor component and other features */ function dispEditorAdminIndex() { $component_count = 0; $site_module_info = Context::get('site_module_info'); $site_srl = (int) $site_module_info->site_srl; // Get a type of component $oEditorModel = getModel('editor'); $oModuleModel = getModel('module'); $editor_config = $oModuleModel->getModuleConfig('editor'); if (!$editor_config) { $editor_config = new stdClass(); } //editor_config init if (!$editor_config->editor_height) { $editor_config->editor_height = 300; } if (!$editor_config->comment_editor_height) { $editor_config->comment_editor_height = 100; } if (!$editor_config->editor_skin) { $editor_config->editor_skin = 'ckeditor'; } if (!$editor_config->comment_editor_skin) { $editor_config->comment_editor_skin = 'ckeditor'; } if (!$editor_config->sel_editor_colorset) { $editor_config->sel_editor_colorset = 'moono'; } if (!$editor_config->sel_comment_editor_colorset) { $editor_config->sel_comment_editor_colorset = 'moono'; } $component_list = $oEditorModel->getComponentList(false, $site_srl, true); $editor_skin_list = FileHandler::readDir(_XE_PATH_ . 'modules/editor/skins'); $skin_info = $oModuleModel->loadSkinInfo($this->module_path, $editor_config->editor_skin); $contents = FileHandler::readDir(_XE_PATH_ . 'modules/editor/styles'); $content_style_list = array(); for ($i = 0, $c = count($contents); $i < $c; $i++) { $style = $contents[$i]; $info = $oModuleModel->loadSkinInfo($this->module_path, $style, 'styles'); $content_style_list[$style] = new stdClass(); $content_style_list[$style]->title = $info->title; } // Get install info, update info, count $oAutoinstallModel = getModel('autoinstall'); foreach ($component_list as $component_name => $xml_info) { $component_count++; $xml_info->path = './modules/editor/components/' . $xml_info->component_name; $xml_info->delete_url = $oAutoinstallModel->getRemoveUrlByPath($xml_info->path); $xml_info->package_srl = $oAutoinstallModel->getPackageSrlByPath($xml_info->path); if ($xml_info->package_srl) { $targetpackages[$xml_info->package_srl] = 0; } } if (is_array($targetpackages)) { $packages = $oAutoinstallModel->getInstalledPackages(array_keys($targetpackages)); } foreach ($component_list as $component_name => $xml_info) { if ($packages[$xml_info->package_srl]) { $xml_info->need_update = $packages[$xml_info->package_srl]->need_update; } } $editor_config_default = array('editor_height' => 300, 'comment_editor_height' => 100); //editor preview $config = $oEditorModel->getEditorConfig(); $option = new stdClass(); $option->allow_fileupload = false; $option->content_style = $config->content_style; $option->content_font = $config->content_font; $option->content_font_size = $config->content_font_size; $option->content_line_height = $config->content_line_height; $option->content_paragraph_spacing = $config->content_paragraph_spacing; $option->content_word_break = $config->content_word_break; $option->additional_css = $config->additional_css ?: array(); $option->enable_autosave = false; $option->enable_default_component = true; $option->enable_component = true; $option->disable_html = false; $option->height = $config->editor_height; $option->skin = $config->editor_skin; $option->content_key_name = 'dummy_content'; $option->primary_key_name = 'dummy_key'; $option->colorset = $config->sel_editor_colorset; $editor = $oEditorModel->getEditor(0, $option); Context::set('preview_editor', $editor); $option_com = new stdClass(); $option_com->allow_fileupload = false; $option_com->content_style = $config->content_style; $option_com->content_font = $config->content_font; $option_com->content_font_size = $config->content_font_size; $option_com->content_line_height = $config->content_line_height; $option_com->content_paragraph_spacing = $config->content_paragraph_spacing; $option_com->content_word_break = $config->content_word_break; $option_com->additional_css = $config->additional_css ?: array(); $option_com->enable_autosave = false; $option_com->enable_default_component = true; $option_com->enable_component = true; $option_com->disable_html = false; $option_com->height = $config->comment_editor_height; $option_com->skin = $config->comment_editor_skin; $option_com->content_key_name = 'dummy_content2'; $option_com->primary_key_name = 'dummy_key2'; $option_com->content_style = $config->comment_content_style; $option_com->colorset = $config->sel_comment_editor_colorset; $editor_comment = $oEditorModel->getEditor(0, $option_com); Context::set('preview_editor_comment', $editor_comment); Context::set('editor_config', $editor_config); Context::set('editor_skin_list', $editor_skin_list); Context::set('editor_colorset_list', $skin_info->colorset); Context::set('content_style_list', $content_style_list); Context::set('component_list', $component_list); Context::set('component_count', $component_count); Context::set('editor_config_default', $editor_config_default); foreach ($config->additional_css as $additional_css_url) { Context::loadFile(array($additional_css_url)); } $security = new Security(); $security->encodeHTML('component_list....'); $this->setTemplatePath($this->module_path . 'tpl'); $this->setTemplateFile('admin_index'); }