diff --git a/modules/admin/admin.admin.controller.php b/modules/admin/admin.admin.controller.php index bc97df6b0..419352d83 100644 --- a/modules/admin/admin.admin.controller.php +++ b/modules/admin/admin.admin.controller.php @@ -79,5 +79,70 @@ header('Location: '.getNotEncodedUrl('', 'module','admin')); } + + function procAdminInsertThemeInfo(){ + $vars = Context::getRequestVars(); + $theme_file = _XE_PATH_.'files/theme/theme_info.php'; + + $theme_output = sprintf('$theme_info->theme=\'%s\';', $vars->themeItem); + $theme_output = $theme_output.sprintf('$theme_info->layout=%s;', $vars->layout); + + $site_info = Context::get('site_module_info'); + + $args->site_srl = $site_info->site_srl; + $args->layout_srl = $vars->layout; + // layout submit + $output = executeQuery('layout.updateAllLayoutInSiteWithTheme', $args); + if (!$output->toBool()) return $output; + + $skin_args->site_srl = $site_info->site_srl; + + foreach($vars as $key=>$val){ + $pos = strpos($key, '-skin'); + if ($pos === false) continue; + if ($val != '__skin_none__'){ + $module = substr($key, 0, $pos); + $theme_output = $theme_output.sprintf('$theme_info->skin_info[%s]=\'%s\';', $module, $val); + $skin_args->skin = $val; + $skin_args->module = $module; + if ($module == 'page') + { + $article_output = executeQueryArray('page.getArticlePageSrls'); + if (count($article_output->data)>0){ + $article_module_srls = array(); + foreach($article_output->data as $val){ + $article_module_srls[] = $val->module_srl; + } + $skin_args->module_srls = implode(',', $article_module_srls); + } + } + $skin_output = executeQuery('module.updateAllModuleSkinInSiteWithTheme', $skin_args); + if (!$skin_output->toBool()) return $skin_output; + + $oModuleModel = &getModel('module'); + $module_config = $oModuleModel->getModuleConfig($module, $site_info->site_srl); + $module_config->skin = $val; + $oModuleController = &getController('module'); + $oModuleController->insertModuleConfig($module, $module_config, $site_info->site_srl); + } + } + + $theme_buff = sprintf( + '', + $theme_output + ); + // Save File + FileHandler::writeFile($theme_file, $theme_buff); + + if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) { + $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdminTheme'); + header('location:'.$returnUrl); + return; + } + else return $output; + } } ?> diff --git a/modules/admin/admin.admin.model.php b/modules/admin/admin.admin.model.php index 7a4c5f028..852f6e9d7 100644 --- a/modules/admin/admin.admin.model.php +++ b/modules/admin/admin.admin.model.php @@ -146,6 +146,159 @@ return $param; } + function getThemeList(){ + $path = _XE_PATH_.'themes'; + $list = FileHandler::readDir($path); + + $theme_info = array(); + if(count($list) > 0){ + foreach($list as $val){ + $theme_info[$val] = $this->getThemeInfo($val); + } + } + + return $theme_info; + } + + 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; + if(!$_xml_obj->theme) return; + + // 스킨이름 + $theme_info->name = $theme_name; + $theme_info->title = $xml_obj->title->body; + $thumbnail = './themes/'.$theme_name.'/thumbnail.png'; + $theme_info->thumbnail = (file_exists($thumbnail))?$thumbnail:null; + $theme_info->version = $xml_obj->version->body; + 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[] = $xml_obj->publisher; + else $publisher_list = $xml_obj->publisher; + + foreach($publisher_list as $publisher) { + unset($publisher_obj); + $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; + } + + $skin_infos = $xml_obj->skininfos; + if(is_array($skin_infos->layoutinfo))$layout_path = $skin_infos->layoutinfo[0]->directory->attrs->path; + else $layout_path = $skin_infos->layoutinfo->directory->attrs->path; + + $layout_parse = explode('/',$layout_path); + 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->path = $layout_path; + $theme_info->layout_info = $layout_info; + + $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; + break; + } + } + } + + if ($is_new_layout){ + $site_module_info = Context::get('site_module_info'); + $args->site_srl = (int)$site_module_info->site_srl; + $args->layout_srl = getNextSequence(); + $args->layout = $layout_info->name; + $args->title = $layout_info->name.'InTheme'; + $args->layout_type = "P"; + // Insert into the DB + $oLayoutAdminController = &getAdminController('layout'); + $output = $oLayoutAdminController->insertLayout($args); + } + + 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){ + unset($skin_info); + 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; + $skins[$module_name] = $skin_info; + + if ($is_theme){ + if (!$GLOBALS['__ThemeModuleSkin__'][$module_name]) $GLOBALS['__ThemeModuleSkin__'][$module_name] = array(); + $GLOBALS['__ThemeModuleSkin__'][$module_name][$skin_info->name] = $oModuleModel->loadSkinInfo($skin_info->path, '', ''); + } + } + $theme_info->skin_infos = $skins; + + $GLOBALS['__ThemeInfo__'][$theme_name] = $theme_info; + return $theme_info; + } + + function getModulesSkinList(){ + if ($GLOBALS['__ThemeModuleSkin__']['__IS_PARSE__']) return $GLOBALS['__ThemeModuleSkin__']; + $searched_list = FileHandler::readDir('./modules'); + sort($searched_list); + + $searched_count = count($searched_list); + if(!$searched_count) return; + + $oModuleModel = &getModel('module'); + foreach($searched_list as $val) { + $skin_list = $oModuleModel->getSkins('./modules/'.$val); + + if (is_array($skin_list) && count($skin_list) > 0){ + if(!$GLOBALS['__ThemeModuleSkin__'][$val]) $GLOBALS['__ThemeModuleSkin__'][$val] = array(); + $GLOBALS['__ThemeModuleSkin__'][$val] = array_merge($GLOBALS['__ThemeModuleSkin__'][$val], $skin_list); + } + } + $GLOBALS['__ThemeModuleSkin__']['__IS_PARSE__'] = true; + + return $GLOBALS['__ThemeModuleSkin__']; + } + function getAdminMenuLang() { $currentLang = Context::getLangType(); diff --git a/modules/admin/admin.admin.view.php b/modules/admin/admin.admin.view.php index ed3c13a08..f7daf51dc 100644 --- a/modules/admin/admin.admin.view.php +++ b/modules/admin/admin.admin.view.php @@ -7,6 +7,8 @@ class adminAdminView extends admin { + var $layout_list; + /** * @brief Initilization * @return none @@ -452,4 +454,53 @@ unset($_SESSION['enviroment_gather']); } } + + function dispAdminTheme(){ + // choice theme file + $theme_file = _XE_PATH_.'files/theme/theme_info.php'; + if(is_readable($theme_file)){ + @include($theme_file); + Context::set('current_layout', $theme_info->layout); + Context::set('theme_info', $theme_info); + } + else{ + $oModuleModel = &getModel('module'); + $default_mid = $oModuleModel->getDefaultMid(); + Context::set('current_layout', $default_mid->layout_srl); + } + + // layout list + $oLayoutModel = &getModel('layout'); + // theme 정보 읽기 + + $oAdminModel = &getAdminModel('admin'); + $theme_list = $oAdminModel->getThemeList(); + $layouts = $oLayoutModel->getLayoutList(0); + $layout_list = array(); + if (is_array($layouts)){ + foreach($layouts as $val){ + unset($layout_info); + $layout_info = $oLayoutModel->getLayout($val->layout_srl); + $layout_parse = explode('.', $layout_info->layout); + if (count($layout_parse) == 2){ + $thumb_path = sprintf('./themes/%s/layout/%s/thumbnail.png', $layout_parse[0], $layout_parse[1]); + } + else{ + $thumb_path = './layouts/'.$layout_info->layout.'/thumbnail.png'; + } + $layout_info->thumbnail = (is_readable($thumb_path))?$thumb_path:null; + $layout_list[] = $layout_info; + } + } +// debugPrint($layout_list); + Context::set('theme_list', $theme_list); + Context::set('layout_list', $layout_list); + + // 설치된module 정보 가져오기 + $module_list = $oAdminModel->getModulesSkinList(); + Context::set('module_list', $module_list); + + $this->setTemplateFile('theme'); + } + } diff --git a/modules/admin/admin.class.php b/modules/admin/admin.class.php index d45fa7a37..b21fd1a58 100644 --- a/modules/admin/admin.class.php +++ b/modules/admin/admin.class.php @@ -30,6 +30,9 @@ $this->_createXeAdminMenu(); } + $theme_dir = _XE_PATH_.'files/theme'; + if(!is_dir($theme_dir)) return true; + return false; } @@ -38,6 +41,10 @@ * @return new Object **/ function moduleUpdate() { + $theme_dir = _XE_PATH_.'files/theme'; + if(!is_dir($theme_dir)){ + FileHandler::makeDir($theme_dir); + } return new Object(); } @@ -82,8 +89,60 @@ $menuSrl = $args->menu_srl; unset($args); + $adminUrl = getUrl('', 'module', 'admin'); + $gnbList = array( + 'dashboard'=>array( + 'url'=>$adminUrl, + 'lnbList'=>array() + ), + 'site'=>array( + 'url'=>$adminUrl, + 'lnbList'=>array() + ), + 'user'=>array( + 'url'=>$adminUrl, + 'lnbList'=>array('userList'=>$adminUrl, 'setting'=>$adminUrl, 'point'=>$adminUrl) + ), + 'content'=>array( + 'url'=>getUrl('', 'module', 'admin', 'act', 'dispDocumentAdminList'), + 'lnbList'=>array( + 'document'=>getUrl('', 'module', 'admin', 'act', 'dispDocumentAdminList'), + 'comment'=>$adminUrl, + 'trackback'=>$adminUrl, + 'file'=>$adminUrl, + 'poll'=>$adminUrl, + 'dataMigration'=>$adminUrl + ) + ), + 'theme'=>array( + 'url'=>getUrl('', 'module', 'admin', 'act', 'dispAdminTheme'), + 'lnbList'=>array() + ), + 'extensions'=>array( + 'url'=>$adminUrl, + 'lnbList'=>array('easyInstaller'=>$adminUrl, 'installedLayout'=>$adminUrl, 'installedModule'=>$adminUrl, 'installedWidget'=>$adminUrl, 'installedAddon'=>$adminUrl, 'WYSIWYGEditor'=>$adminUrl, 'spamFilter'=>$adminUrl) + ), + 'configuration'=>array( + 'url'=>$adminUrl, + 'lnbList'=>array('general'=>$adminUrl, 'fileUpload'=>$adminUrl) + ) + ); + + $oMemberModel = &getModel('member'); + $output = $oMemberModel->getAdminGroup(array('group_srl')); + $adminGroupSrl = $output->group_srl; + + // common argument setting + $args->open_window = 'N'; + $args->expand = 'N'; + $args->normal_btn = ''; + $args->hover_btn = ''; + $args->active_btn = ''; + $args->group_srls = $adminGroupSrl; + // gnb item create $gnbList = array('dashboard', 'site', 'user', 'content', 'theme', 'extensions', 'configuration'); + foreach($gnbList AS $key=>$value) { //insert menu item diff --git a/modules/admin/conf/module.xml b/modules/admin/conf/module.xml index 12b18c666..7711d491a 100644 --- a/modules/admin/conf/module.xml +++ b/modules/admin/conf/module.xml @@ -5,10 +5,13 @@ + + + diff --git a/modules/admin/ruleset/insertThemeInfo.xml b/modules/admin/ruleset/insertThemeInfo.xml new file mode 100644 index 000000000..73d19183a --- /dev/null +++ b/modules/admin/ruleset/insertThemeInfo.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/modules/admin/tpl/img/iconArrow.gif b/modules/admin/tpl/img/iconArrow.gif index eff3728a4..d0e1202a9 100644 Binary files a/modules/admin/tpl/img/iconArrow.gif and b/modules/admin/tpl/img/iconArrow.gif differ diff --git a/modules/admin/tpl/theme.html b/modules/admin/tpl/theme.html new file mode 100644 index 000000000..4c108e76f --- /dev/null +++ b/modules/admin/tpl/theme.html @@ -0,0 +1,106 @@ +

Theme

+

{$XE_VALIDATOR_ERROR}

+
+ +
+

Theme Setting

+

테마는 레이아웃을 포함하여 현재 설치된 모듈의 스킨을 묶은 개념입니다. 테마를 선택하면 'Skin Setting' 항목을 알아서 선택합니다. 테마 일부가 마음에 들지 않으면 'Skin Setting'에서 테마 일부를 다시 설정 할 수 있습니다.

+
    +
  • +

    선택한 테마

    +
      + {@$current_theme = ($theme_info)?$theme_info->theme:'user_define'} + +
    • + Thumbnail does not exist + checked="checked" /> + +
        +
      • › 버전: {$val->version}
      • +
      • › 제작: {$val->publisher}
      • +
      • › 설명: {$val->description}
      • +
      • › 경로: {$val->path}
      • +
      +
    • + +
    • + By You + checked="checked" /> + +
        +
      • › 설명: 관리자가 설정한 테마입니다. 테마를 설정하지 않은 경우 디폴트로 노출됩니다.
      • +
      +
    • +
    +
  • +
+
+
+

Skin Setting

+

테마의 일부가 마음에 들지 않으면 스킨을 직접 선택하세요. 스킨을 직접 선택하면 'Theme Setting' 설정은 'User Defined'로 설정됩니다.

+
    +
  • +

    선택한 레이아웃

    +
      + +
    • + Thumbnail does not exist + layout_srl == $current_layout)-->checked="checked" /> + +
        +
      • › 버전: {$val->version}
      • +
      • › 제작: + + {$author->name} + +
      • +
      • › 설명: {$val->description}
      • +
      • › 경로: {$val->path}
      • +
      • › 설정: Edit
      • +
      +
    • + +
    +
  • + + +
  • +

    선택한 {$key} 스킨

    +
      + +
    • + + + +
        +
      • 선택한 테마에는 이 항목에 대한 스킨 정보가 없습니다. 스킨을 직접 선택하세요.
      • +
      +
    • + + +
    • + Thumbnail does not exist + skin_info[$key] == $skey)-->checked="checked" /> + +
        +
      • › 버전: {$sval->version}
      • +
      • › 제작: + + {$author->name} + +
      • +
      • › 설명: {$sval->description}
      • +
      • › 설정: Edit
      • +
      +
    • + +
    +
  • + + +
+
+
+ +
+