issue 92 add Theme

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@8656 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
devjin 2011-07-26 10:05:00 +00:00
parent 5a60bfa3d6
commit ab85943d7e
8 changed files with 446 additions and 0 deletions

View file

@ -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(
'<?php '.
'if(!defined("__ZBXE__")) exit(); '.
'%s'.
'?>',
$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;
}
}
?>

View file

@ -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();

View file

@ -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');
}
}

View file

@ -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

View file

@ -5,10 +5,13 @@
<actions>
<action name="dispAdminIndex" type="view" standalone="true" index="true" />
<action name="dispAdminConfig" type="view" standalone="true" />
<action name="dispAdminTheme" type="view" standalone="true" menu_name="theme" menu_index="true" />
<action name="dispAdminMenuSetup" type="view" standalone="true" menu_name="adminMenuSetup" menu_index="true" />
<action name="procAdminRecompileCacheFile" type="controller" standalone="true" />
<action name="procAdminLogout" type="controller" standalone="true" />
<action name="procAdminInsertThemeInfo" type="controller" standalone="true" ruleset="insertThemeInfo" />
<action name="getAdminFTPList" type="model" standalone="true" />
</actions>
<menus>

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<ruleset version="1.5.0">
<customrules>
</customrules>
<fields>
<field name="themeItem" required="true" />
<field name="layout" required="true" rule="number" />
</fields>
</ruleset>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 849 B

After

Width:  |  Height:  |  Size: 812 B

Before After
Before After

View file

@ -0,0 +1,106 @@
<h1 class="h1">Theme</h1>
<p class="xe_validator_error">{$XE_VALIDATOR_ERROR}</p>
<form ruleset="insertThemeInfo" action="./" method="post" class="form">
<input type="hidden" name="act" value="procAdminInsertThemeInfo">
<fieldset id="theme">
<h2 class="h2">Theme Setting</h2>
<p>테마는 레이아웃을 포함하여 현재 설치된 모듈의 스킨을 묶은 개념입니다. 테마를 선택하면 'Skin Setting' 항목을 알아서 선택합니다. 테마 일부가 마음에 들지 않으면 'Skin Setting'에서 테마 일부를 다시 설정 할 수 있습니다.</p>
<ul class="thumbPreview">
<li>
<p class="q">선택한 테마</p>
<ul class="a">
{@$current_theme = ($theme_info)?$theme_info->theme:'user_define'}
<!--@foreach($theme_list as $key=>$val)-->
<li class="i">
<span class="thumb"><!--@if($val->thumbnail)--><img src="{$val->thumbnail}" alt="" /><!--@else-->Thumbnail does not exist<!--@end--></span>
<input type="radio" name="themeItem" id="{$key}" value="{$key}" <!--@if($key == $current_theme)-->checked="checked"<!--@end--> />
<label for="{$key}">{$val->title}({$key})</label>
<ul>
<li>&rsaquo; 버전: {$val->version}</li>
<li>&rsaquo; 제작: {$val->publisher}</li>
<li>&rsaquo; 설명: {$val->description}</li>
<li>&rsaquo; 경로: {$val->path}</li>
</ul>
</li>
<!--@end-->
<li class="i userDefine">
<span class="thumb">By You</span>
<input type="radio" name="themeItem" id="theme_user_define" value="user_define" <!--@if($current_theme == 'user_define')-->checked="checked"<!--@end--> />
<label for="theme_user_define">User Defined</label>
<ul>
<li>&rsaquo; 설명: 관리자가 설정한 테마입니다. 테마를 설정하지 않은 경우 디폴트로 노출됩니다.</li>
</ul>
</li>
</ul>
</li>
</ul>
</fieldset>
<fieldset id="skin">
<h2 class="h2">Skin Setting</h2>
<p>테마의 일부가 마음에 들지 않으면 스킨을 직접 선택하세요. 스킨을 직접 선택하면 'Theme Setting' 설정은 'User Defined'로 설정됩니다. <button type="button" class="showAll"></button></p>
<ul class="thumbPreview">
<li>
<p class="q">선택한 레이아웃</p>
<ul class="a">
<!--@foreach($layout_list as $val)-->
<li class="i">
<span class="thumb"><!--@if($val->thumbnail)--><img src="{$val->thumbnail}" alt="" /><!--@else-->Thumbnail does not exist<!--@end--></span>
<input type="radio" name="layout" id="layout_{$val->layout_srl}" value="{$val->layout_srl}" <!--@if($val->layout_srl == $current_layout)-->checked="checked"<!--@end--> />
<label for="layout_{$val->layout_srl}">{$val->layout_title.'('.$val->layout.')'}</label>
<ul>
<li>&rsaquo; 버전: {$val->version}</li>
<li>&rsaquo; 제작:
<!--@foreach($val->author as $author)-->
<!--@if($author->homepage)--><a href="{$author->homepage}" onclick="window.open(this.href);return false;"><!--@end-->{$author->name}<!--@if($author->homepage)--></a><!--@end-->
<!--@endforeach-->
</li>
<li>&rsaquo; 설명: {$val->description}</li>
<li>&rsaquo; 경로: {$val->path}</li>
<li>&rsaquo; 설정: <a href="#">Edit</a></li>
</ul>
</li>
<!--@end-->
</ul>
</li>
<!--@foreach($module_list as $key=>$val)-->
<!--@if($key != '__IS_PARSE__')-->
<li>
<p class="q">선택한 {$key} 스킨</p>
<ul class="a">
<!--@if(!$theme_info->skin_info[$key])-->
<li class="i noDirection">
<span class="thumb"></span>
<input type="radio" name="{$key}-skin" id="{$key}_none" value="__skin_none__" checked="checked" />
<label for="{$key}_none">선택한 {$key} 스킨 없음</label>
<ul>
<li>선택한 테마에는 이 항목에 대한 스킨 정보가 없습니다. 스킨을 직접 선택하세요.</li>
</ul>
</li>
<!--@end-->
<!--@foreach($val as $skey=>$sval)-->
<li class="i">
<span class="thumb"><!--@if($sval->thumbnail)--><img src="{$sval->thumbnail}" alt="" /><!--@else-->Thumbnail does not exist<!--@end--></span>
<input type="radio" name="{$key}-skin" id="{$key.'_'.$skey}" value="{$skey}" <!--@if($theme_info->skin_info[$key] == $skey)-->checked="checked"<!--@end--> />
<label for="{$key.'_'.$skey}">{$sval->title.'('.$skey.')'}</label>
<ul>
<li>&rsaquo; 버전: {$sval->version}</li>
<li>&rsaquo; 제작:
<!--@foreach($sval->author as $author)-->
<!--@if($author->homepage)--><a href="{$author->homepage}" onclick="window.open(this.href);return false;"><!--@end-->{$author->name}<!--@if($author->homepage)--></a><!--@end-->
<!--@endforeach-->
</li>
<li>&rsaquo; 설명: {$sval->description}</li>
<li>&rsaquo; 설정: <a href="#">Edit</a></li>
</ul>
</li>
<!--@end-->
</ul>
</li>
<!--@end-->
<!--@end-->
</ul>
</fieldset>
<div class="btnArea">
<span class="btn medium"><input type="submit" value="Save" /></span>
</div>
</form>