From 2601043ee8eb57280bc84675058bd9563cca46c6 Mon Sep 17 00:00:00 2001 From: flyskyko Date: Fri, 26 Aug 2011 08:48:29 +0000 Subject: [PATCH] layout module git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@8920 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- modules/layout/conf/module.xml | 32 +- modules/layout/lang/lang.xml | 62 ++-- modules/layout/layout.admin.controller.php | 62 ++-- modules/layout/layout.admin.view.php | 236 ++++++++++---- modules/layout/layout.model.php | 154 +++++---- modules/layout/layout.view.php | 58 ++++ modules/layout/queries/getLayoutList.xml | 1 + modules/layout/ruleset/codeUpdate.xml | 5 +- modules/layout/ruleset/deleteLayout.xml | 6 + modules/layout/ruleset/imageUpload.xml | 2 +- modules/layout/tpl/css/adminEdit.css | 3 + modules/layout/tpl/header.html | 20 +- modules/layout/tpl/installed_layout_list.html | 57 ++++ modules/layout/tpl/js/adminEdit.js | 24 ++ modules/layout/tpl/js/adminList.js | 8 + modules/layout/tpl/layout_edit.html | 205 ++++++------ modules/layout/tpl/layout_instance_list.html | 43 +++ modules/layout/tpl/layout_modify.html | 299 ++++++++---------- 18 files changed, 767 insertions(+), 510 deletions(-) create mode 100644 modules/layout/ruleset/deleteLayout.xml create mode 100644 modules/layout/tpl/css/adminEdit.css create mode 100644 modules/layout/tpl/installed_layout_list.html create mode 100644 modules/layout/tpl/js/adminEdit.js create mode 100644 modules/layout/tpl/js/adminList.js create mode 100644 modules/layout/tpl/layout_instance_list.html diff --git a/modules/layout/conf/module.xml b/modules/layout/conf/module.xml index 8192f25f4..42bda6b44 100644 --- a/modules/layout/conf/module.xml +++ b/modules/layout/conf/module.xml @@ -4,27 +4,31 @@ - - - - - - + - - + + + + + + + + + + + + + + - - - + - - + @@ -33,7 +37,7 @@ Installed Layout - 레이아웃 + 설치된 레이아웃 Installed Layout Installed Layout Installed Layout diff --git a/modules/layout/lang/lang.xml b/modules/layout/lang/lang.xml index d5c35031a..038126150 100644 --- a/modules/layout/lang/lang.xml +++ b/modules/layout/lang/lang.xml @@ -24,7 +24,7 @@ - + @@ -203,7 +203,7 @@ Por usar la configuración del diseño y el menú de conección, completa con varios módulos la forma de la página web que a ser mostrados
* Esos diseños que no pueden ser modificados ni eliminados son propios de blog y de otros módulos, por lo cual para la configuración de ellos debe hacerse en los modulos correspondientes.]]>
Yerleşim düzeni ayarını ve menü bağlantısını kullandığınzda, websitelerin çeşitli modüllerle tamamlanmış şekilleri gösterilecektir.
* Blogların veya diğer modüllerin varsayılan yerleşim düzenlerini silemezseniz; onları, kendi ayar sayfalarından silmeniz gerekmektedir. ]]>
Bằng cách sử dụng thiết lập giao diện và kết nối Menu, hình dạng hoàn thành của Website sẽ được trình bày bổ xung với nhiều Module.
Giao diện nào xuất hiện (*) là những giao diện không thể xóa hay điều chỉnh được Module. ]]>
- +
- + @@ -308,7 +308,7 @@ - + @@ -319,7 +319,7 @@ - + @@ -329,7 +329,7 @@ - + @@ -340,7 +340,7 @@ - + @@ -351,7 +351,7 @@ - + @@ -362,7 +362,7 @@ - + @@ -373,7 +373,7 @@ - + @@ -384,7 +384,7 @@ - + @@ -395,7 +395,7 @@ - + @@ -406,7 +406,7 @@ - + @@ -417,7 +417,7 @@ - + @@ -428,7 +428,7 @@ - + @@ -439,7 +439,7 @@ - + @@ -450,7 +450,7 @@ - + @@ -461,7 +461,7 @@ - + @@ -472,7 +472,7 @@ - + @@ -483,7 +483,7 @@ - + @@ -494,7 +494,7 @@ - + @@ -505,7 +505,7 @@ - + @@ -515,7 +515,7 @@ - + @@ -525,7 +525,7 @@ - + @@ -535,7 +535,7 @@ - + @@ -545,7 +545,7 @@ - + @@ -555,7 +555,7 @@ - + @@ -565,7 +565,7 @@ - + @@ -575,7 +575,7 @@ - + @@ -1001,4 +1001,8 @@ + + + + \ No newline at end of file diff --git a/modules/layout/layout.admin.controller.php b/modules/layout/layout.admin.controller.php index 1d015db0c..2e1c537a5 100644 --- a/modules/layout/layout.admin.controller.php +++ b/modules/layout/layout.admin.controller.php @@ -13,6 +13,7 @@ function init() { } + // deprecated /** * @brief Create a new layout * Insert a title into "layouts" table in order to create a layout @@ -26,19 +27,20 @@ $args->title = Context::get('title'); $args->layout_type = Context::get('layout_type'); if(!$args->layout_type) $args->layout_type = "P"; - // Insert into the DB + + // Insert into the DB $output = $this->insertLayout($args); if(!$output->toBool()) return $output; - // initiate if it is faceoff layout - $this->initLayout($args->layout_srl, $args->layout); - // Return result - $this->add('layout_srl', $args->layout_srl); - if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) { - $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispLayoutAdminContent'); - header('location:'.$returnUrl); - return; - } + // initiate if it is faceoff layout + $this->initLayout($args->layout_srl, $args->layout); + + // update layout info + Context::set('layout_srl', $args->layout_srl); + $output = $this->procLayoutAdminUpdate(); + if (!$output->toBool()) return $output; + + $this->setRedirectUrl(Context::get('success_return_url')); } // Insert layout information into the DB @@ -157,7 +159,7 @@ $extra_vars->{$name} = $filename; } } - // Save header script into "config" of layout module + // Save header script into "config" of layout module $oModuleModel = &getModel('module'); $oModuleController = &getController('module'); $layout_config->header_script = Context::get('header_script'); @@ -170,15 +172,8 @@ $output = $this->updateLayout($args); if(!$output->toBool()) return $output; - //$this->setLayoutPath('./common/tpl'); - //$this->setLayoutFile('default_layout.html'); - //$this->setTemplatePath($this->module_path.'tpl'); - //$this->setTemplateFile("top_refresh.html"); - if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) { - $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispLayoutAdminModify', 'layout_srl', Context::get('layout_srl')); - header('location:'.$returnUrl); - return; - } + $this->setRedirectUrl(Context::get('error_return_url')); + return new Object(); } function updateLayout($args) { @@ -189,7 +184,7 @@ FileHandler::removeFile($cache_file); //remove from cache $oCacheHandler = &CacheHandler::getInstance('object'); - if($oCacheHandler->isSupport()) + if($oCacheHandler->isSupport()) { $cache_key = 'object:'.$args->layout_srl; $oCacheHandler->delete($cache_key); @@ -204,6 +199,7 @@ **/ function procLayoutAdminDelete() { $layout_srl = Context::get('layout_srl'); + $this->setRedirectUrl(Context::get('error_return_url')); return $this->deleteLayout($layout_srl); } @@ -220,7 +216,7 @@ $output = executeQuery("layout.deleteLayout", $args); //remove from cache $oCacheHandler = &CacheHandler::getInstance('object'); - if($oCacheHandler->isSupport()) + if($oCacheHandler->isSupport()) { $cache_key = 'object:'.$layout_srl; $oCacheHandler->delete($cache_key); @@ -234,10 +230,12 @@ * @brief Adding Layout Code **/ function procLayoutAdminCodeUpdate() { + $mode = Context::get('mode'); + if ($mode == 'reset') return $this->procLayoutAdminCodeReset(); + $layout_srl = Context::get('layout_srl'); $code = Context::get('code'); $code_css = Context::get('code_css'); - $return_url = Context::get('_return_url'); $is_post = (Context::getRequestMethod() == 'POST'); if(!$layout_srl || !$code) return new Object(-1, 'msg_invalid_request'); @@ -248,11 +246,7 @@ $layout_css_file = $oLayoutModel->getUserLayoutCss($layout_srl); FileHandler::writeFile($layout_css_file, $code_css); - if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) { - $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispLayoutAdminEdit', 'layout_srl', $layout_srl); - header('location:'.$returnUrl); - return; - } + $this->setRedirectUrl(Context::get('error_return_url')); $this->setMessage('success_updated'); } @@ -279,6 +273,7 @@ $this->initLayout($layout_srl, $info->layout); $this->setMessage('success_reset'); + $this->setRedirectUrl(Context::get('error_return_url')); } @@ -297,11 +292,7 @@ $this->setTemplatePath($this->module_path.'tpl'); $this->setTemplateFile("top_refresh.html"); - if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) { - $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispLayoutAdminEdit', 'layout_srl', Context::get('layout_srl')); - header('location:'.$returnUrl); - return; - } + $this->setRedirectUrl(Context::get('error_return_url')); } /** @@ -344,9 +335,10 @@ $layout_srl = Context::get('layout_srl'); $this->removeUserLayoutImage($layout_srl,$filename); $this->setMessage('success_deleted'); + $this->setRedirectUrl(Context::get('error_return_url')); } - + // deprecated /** * @brief Save layout configuration * save in "ini" format for faceoff @@ -449,6 +441,7 @@ } } + // deprecated /** * @brief faceoff export * @@ -483,6 +476,7 @@ exit(); } + // deprecated /** * @brief faceoff import * diff --git a/modules/layout/layout.admin.view.php b/modules/layout/layout.admin.view.php index cf80565ba..05a367a7b 100644 --- a/modules/layout/layout.admin.view.php +++ b/modules/layout/layout.admin.view.php @@ -14,10 +14,168 @@ $this->setTemplatePath($this->module_path.'tpl'); } + /** + * @brief Display a installed layout list + **/ + function dispLayoutAdminInstalledList() { + // Set a layout list + $oLayoutModel = &getModel('layout'); + $layout_list = $oLayoutModel->getDownloadedLayoutList('P', true); + Context::set('type', 'P'); + + $pcLayoutCount = $oLayoutModel->getInstalledLayoutCount('P'); + $mobileLayoutCount = $oLayoutModel->getInstalledLayoutCount('M'); + Context::set('pcLayoutCount', $pcLayoutCount); + Context::set('mobileLayoutCount', $mobileLayoutCount); + $this->setTemplateFile('installed_layout_list'); + + $security = new Security($layout_list); + $layout_list = $security->encodeHTML('..', '..author..'); + + foreach($layout_list as $no => $layout_info) + { + $layout_list[$no]->description = nl2br(trim($layout_info->description)); + } + Context::set('layout_list', $layout_list); + } + + /** + * @brief Display a installed mobile layout list + */ + function dispLayoutAdminInstalledMobileList() { + // Set a layout list + $oLayoutModel = &getModel('layout'); + $layout_list = $oLayoutModel->getDownloadedLayoutList('M', true); + Context::set('type', 'M'); + + $pcLayoutCount = $oLayoutModel->getInstalledLayoutCount('P'); + $mobileLayoutCount = $oLayoutModel->getInstalledLayoutCount('M'); + Context::set('pcLayoutCount', $pcLayoutCount); + Context::set('mobileLayoutCount', $mobileLayoutCount); + $this->setTemplateFile('installed_layout_list'); + + $security = new Security($layout_list); + $layout_info = $security->encodeHTML('..', '..author..'); + + foreach($layout_list as $no => $layout_info) + { + $layout_list[$no]->description = nl2br(trim($layout_info->description)); + } + Context::set('layout_list', $layout_list); + } + + /** + * @brief Display list of pc layout instance + */ + function dispLayoutAdminInstanceList() + { + $type = Context::get('type'); + $layout = Context::get('layout'); + + if (!in_array($type, array('P', 'M'))) $type = 'P'; + if (!$layout) return $this->stop('msg_invalid_request'); + + $oLayoutModel = &getModel('layout'); + $layout_info = $oLayoutModel->getLayoutInfo($layout, null, $type); + if (!$layout_info) return $this->stop('msg_invalid_request'); + + Context::set('layout_info', $layout_info); + + $columnList = array('layout_srl', 'layout', 'module_srl', 'title', 'regdate'); + $layout_list = $oLayoutModel->getLayoutInstanceList(0, $type, $layout, $columnList); + Context::set('layout_list', $layout_list); + + $this->setTemplateFile('layout_instance_list'); + + $security = new Security(); + $security->encodeHTML('layout_list..'); + } + + /** + * @brief Layout setting page + * Once select a layout with empty value in the DB, then adjust values + **/ + function dispLayoutAdminInsert() { + $oModel = &getModel('layout'); + $type = Context::get('type'); + if (!in_array($type, array('P', 'M'))) $type = 'P'; + + // Get layout info + $layout = Context::get('layout'); + $layout_info = $oModel->getLayoutInfo($layout, null, $type); + if (!$layout_info) return $this->stop('msg_invalid_request'); + + // get Menu list + $oMenuAdminModel = &getAdminModel('menu'); + $menu_list = $oMenuAdminModel->getMenus(); + Context::set('menu_list', $menu_list); + + $security = new Security(); + $security->encodeHTML('menu_list..'); + + $security = new Security($layout_info); + $layout_info = $security->encodeHTML('.', 'author..', 'extra_var..', 'extra_var....'); + + $layout_info->description = nl2br(trim($layout_info->description)); + if (!is_object($layout_info->extra_var)) $layout_info->extra_var = new StdClass(); + foreach($layout_info->extra_var as $var_name => $val) + { + if (isset($layout_info->{$var_name}->description)) + $layout_info->{$var_name}->description = nl2br(trim($val->description)); + } + Context::set('selected_layout', $layout_info); + + $this->setTemplateFile('layout_modify'); + } + + /** + * @brief Insert Layout details + **/ + function dispLayoutAdminModify() { + // Set the layout after getting layout information + $layout_srl = Context::get('layout_srl'); + + // Get layout information + $oLayoutModel = &getModel('layout'); + $layout_info = $oLayoutModel->getLayout($layout_srl); + + // Error appears if there is no layout information is registered + if(!$layout_info) return $this->stop('msg_invalid_request'); + + // If faceoff, no need to display the path + if($layout_info->type == 'faceoff') unset($layout_info->path); + + // Get a menu list + $oMenuAdminModel = &getAdminModel('menu'); + $menu_list = $oMenuAdminModel->getMenus(); + Context::set('menu_list', $menu_list); + + $security = new Security(); + $security->encodeHTML('menu_list..'); + + $security = new Security($layout_info); + $layout_info = $security->encodeHTML('.', 'author..', 'extra_var..', 'extra_var....'); + + $layout_info->description = nl2br(trim($layout_info->description)); + if (!is_object($layout_info->extra_var)) $layout_info->extra_var = new StdClass(); + foreach($layout_info->extra_var as $var_name => $val) + { + if (isset($layout_info->{$var_name}->description)) + $layout_info->{$var_name}->description = nl2br(trim($val->description)); + } + Context::set('selected_layout', $layout_info); + + $this->setTemplateFile('layout_modify'); + } + + // deprecated /** * @brief The first page of the layout admin **/ function dispLayoutAdminContent() { + $path = Context::get('path'); + if (!$path) return $this->stop('msg_invalid_request'); + $oLayoutModel = &getModel('layout'); $columnList = array('layout_srl', 'layout', 'module_srl', 'title', 'regdate'); $layout_list = $oLayoutModel->getLayoutList(0, 'P', $columnList); @@ -26,6 +184,7 @@ $this->setTemplateFile('index'); } + // deprecated function dispLayoutAdminMobileContent() { $oLayoutModel = &getModel('layout'); $columnList = array('layout_srl', 'layout', 'module_srl', 'title', 'regdate'); @@ -36,42 +195,6 @@ } - /** - * @brief Layout setting page - * Once select a layout with empty value in the DB, then adjust values - **/ - function dispLayoutAdminInsert() { - // Set layout list - $oLayoutModel = &getModel('layout'); - $layout_type = Context::get('layout_type'); - $layout_list = $oLayoutModel->getDownloadedLayoutList($layout_type); - Context::set('layout_list', $layout_list); - - $this->setTemplateFile('insert_layout'); - } - - /** - * @brief Insert Layout details - **/ - function dispLayoutAdminModify() { - // Set the layout after getting layout information - $layout_srl = Context::get('layout_srl'); - // Get layout information - $oLayoutModel = &getModel('layout'); - $layout_info = $oLayoutModel->getLayout($layout_srl); - // Error appears if there is no layout information is registered - if(!$layout_info) return $this->dispLayoutAdminContent(); - // If faceoff, no need to display the path - if($layout_info->type == 'faceoff') unset($layout_info->path); - Context::set('selected_layout', $layout_info); - // Get a menu list - $oMenuAdminModel = &getAdminModel('menu'); - $menu_list = $oMenuAdminModel->getMenus(); - Context::set('menu_list', $menu_list); - - $this->setTemplateFile('layout_modify'); - } - /** * @brief Edit layout codes **/ @@ -83,7 +206,7 @@ $layout_info = $oLayoutModel->getLayout($layout_srl); // Error appears if there is no layout information is registered if(!$layout_info) return $this->dispLayoutAdminContent(); - Context::set('selected_layout', $layout_info); + // Get Layout Code $oLayoutModel = &getModel('layout'); $layout_file = $oLayoutModel->getUserLayoutHtml($layout_info->layout_srl); @@ -117,29 +240,21 @@ Context::set('widget_list', $widget_list); $this->setTemplateFile('layout_edit'); + + $security = new Security($layout_info); + $layout_info = $security->encodeHTML('.', '.author..'); + Context::set('selected_layout', $layout_info); + + $security = new Security(); + $security->encodeHTML('layout_code_css', 'layout_code', 'widget_list..title'); + // debugPrint(Context::get('selected_layout')); + // debugPrint(Context::get('layout_code_css')); + // debugPrint(Context::get('layout_code')); + // debugPrint(Context::get('layout_image_list')); + // debugPrint(Context::get('layout_image_path')); + // debugPrint(Context::get('widget_list')); } - /** - * @brief Display a layout list - **/ - function dispLayoutAdminDownloadedList() { - // Set a layout list - $oLayoutModel = &getModel('layout'); - $layout_list = $oLayoutModel->getDownloadedLayoutList(); - Context::set('layout_list', $layout_list); - - $this->setTemplateFile('downloaded_layout_list'); - } - - function dispLayoutAdminDownloadedMobileList() { - // Set a layout list - $oLayoutModel = &getModel('layout'); - $layout_list = $oLayoutModel->getDownloadedLayoutList(0, "M"); - Context::set('layout_list', $layout_list); - - $this->setTemplateFile('downloaded_mlayout_list'); - } - /** * @brief Preview a layout **/ @@ -175,6 +290,7 @@ // Temporary save the codes $edited_layout_file = sprintf('./files/cache/layout/tmp.tpl'); FileHandler::writeFile($edited_layout_file, $code); + // Compile $oTemplate = &TemplateHandler::getInstance(); @@ -192,6 +308,7 @@ } + // deprecated /** * @brief Pop-up details of the layout(conf/info.xml) **/ @@ -206,7 +323,7 @@ $this->setTemplateFile('layout_detail_info'); } - + // deprecated /** * @brief Modify admin layout of faceoff **/ @@ -253,6 +370,7 @@ $this->setTemplateFile('faceoff_layout_edit'); } + // deprecated function dispLayoutAdminLayoutImageList(){ $layout_srl = Context::get('layout_srl'); $oLayoutModel = &getModel('layout'); diff --git a/modules/layout/layout.model.php b/modules/layout/layout.model.php index 0d5d44fe4..7ea04d684 100644 --- a/modules/layout/layout.model.php +++ b/modules/layout/layout.model.php @@ -15,6 +15,7 @@ function init() { } + // deprecated /** * @brief Get a layout list created in the DB * If you found a new list, it means that the layout list is inserted to the DB @@ -26,12 +27,27 @@ } $args->site_srl = $site_srl; $args->layout_type = $layout_type; - $output = executeQuery('layout.getLayoutList', $args, $columnList); - if(!$output->data) return; - if(is_array($output->data)) return $output->data; - return array($output->data); + $output = executeQueryArray('layout.getLayoutList', $args, $columnList); + return $output->data; } + /** + * @brief Get layout instance list + **/ + function getLayoutInstanceList($siteSrl = 0, $layoutType = 'P', $layout = null, $columnList = array()) + { + if (!$siteSrl) + { + $siteModuleInfo = Context::get('site_module_info'); + $siteSrl = (int)$siteModuleInfo->site_srl; + } + $args->site_srl = $siteSrl; + $args->layout_type = $layoutType; + $args->layout = $layout; + $output = executeQueryArray('layout.getLayoutList', $args, $columnList); + return $output->data; + } + /** * @brief Get one of layout information created in the DB * Return DB info + XML info of the generated layout @@ -52,9 +68,9 @@ $layout_info = $this->getLayoutInfo($layout, $output->data, $output->data->layout_type); //insert in cache if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key,$layout_info); - } + } return $layout_info; - + } /** @@ -63,10 +79,7 @@ function getLayoutPath($layout_name, $layout_type = "P") { if($layout_name == 'faceoff'){ $class_path = './modules/layout/faceoff/'; - }else if(strpos($layout_name, '.') !== false){ - $layout_parse = explode('.', $layout_name); - $class_path = sprintf('./themes/%s/layout/%s/', $layout_parse[0], $layout_parse[1]); - }else if($layout_type == "M") { + }else if($layout_type == "M") { $class_path = sprintf("./m.layouts/%s/", $layout_name); } else @@ -79,36 +92,84 @@ /** * @brief Get a type and information of the layout - * A type of downloaded layout + * A type of downloaded layout **/ - function getDownloadedLayoutList($layout_type = "P") { - // Get a list of downloaded layout and installed layout - if($layout_type == "M") - { - $directory = "./m.layouts"; - } - else - { - $directory = "./layouts"; - } + function getDownloadedLayoutList($layout_type = "P", $withAutoinstallInfo = false) { + if ($withAutoinstallInfo) $oAutoinstallModel = &getModel('autoinstall'); - $searched_list = FileHandler::readDir($directory); + // Get a list of downloaded layout and installed layout + $searched_list = $this->_getInstalledLayoutDirectories($layout_type); $searched_count = count($searched_list); if(!$searched_count) return; natcasesort($searched_list); // Return information for looping searched list of layouts + $list = array(); for($i=0;$i<$searched_count;$i++) { // Name of the layout $layout = $searched_list[$i]; // Get information of the layout $layout_info = $this->getLayoutInfo($layout, null, $layout_type); + if ($withAutoinstallInfo) + { + // get easyinstall remove url + $packageSrl = $oAutoinstallModel->getPackageSrlByPath($layout_info->path); + $layout_info->remove_url = $oAutoinstallModel->getRemoveUrlByPackageSrl($packageSrl); + + // get easyinstall need update + $package = $oAutoinstallModel->getInstalledPackages($packageSrl); + $layout_info->need_update = $package[$packageSrl]->need_update; + + // get easyinstall update url + if ($layout_info->need_update) + { + $layout_info->update_url = $oAutoinstallModel->getUpdateUrlByPackageSrl($packageSrl); + } + } $list[] = $layout_info; } return $list; } + /** + * @brief Get a count of layout + * @param $layout_type: a type of layout(P|M) + * @return int + **/ + function getInstalledLayoutCount($layoutType = 'P') + { + $searchedList = $this->_getInstalledLayoutDirectories($layoutType); + return count($searchedList); + } + + /** + * @brief Get list of layouts directory + * @param $layoutType: a type of layout(P|M) + * @return array + **/ + function _getInstalledLayoutDirectories($layoutType = 'P') + { + if ($layoutType == 'M') + { + $directory = './m.layouts'; + $globalValueKey = 'MOBILE_LAYOUT_DIRECTOIES'; + } + else + { + $directory = './layouts'; + $globalValueKey = 'PC_LAYOUT_DIRECTORIES'; + } + + if ($GLOBALS[$globalValueKey]) return $GLOBALS[$globalValueKey]; + + $searchedList = FileHandler::readDir($directory); + if (!$searchedList) $searchedList = array(); + $GLOBALS[$globalValueKey] = $searchedList; + + return $searchedList; + } + /** * @brief Get information by reading conf/info.xml in the module * It uses caching to reduce time for xml parsing .. @@ -296,21 +357,7 @@ } } - if ($xml_obj->skins){ - $buff .= '$layout_info->skins = array();'; - $buff .= '$layout_info->skins["module"] = array();'; - $buff .= '$layout_info->skins["widget"] = array();'; - $skins = $xml_obj->skins->skin; - - if (is_array($skins)){ - foreach($skins as $val){ - $buff .= '$layout_info->skins["'.$val->attrs->type.'"]["'.$val->attrs->name.'"] = "'.$val->attrs->skin.'";'; - } - }else{ - $buff .= '$layout_info->skins["'.$skins->attrs->type.'"]["'.$skins->attrs->name.'"] = "'.$skins->attrs->skin.'";'; - } - } } else { // Layout title, version and other information @@ -515,7 +562,7 @@ } /** - * @brief user layout cache + * @brief user layout cache * todo It may need to remove the file itself **/ function getUserLayoutCache($layout_srl,$lang_type){ @@ -523,7 +570,7 @@ } /** - * @brief layout cache + * @brief layout cache **/ function getLayoutCache($layout_name,$lang_type){ return sprintf("./files/cache/layout/%s.%s.cache.php",$layout_name,$lang_type); @@ -633,36 +680,5 @@ Context::addBodyHeader($oTemplate->compile($this->module_path.'/tpl', 'faceoff_layout_menu')); } } - - function getThemaXml($layout_path){ - if(!$layout_path) return; - - $xml_file = sprintf("%sconf/thema.xml", $layout_path); - if(!file_exists($xml_file)) return; - - $oXmlParser = new XmlParser(); - $tmp_xml_obj = $oXmlParser->loadXmlFile($xml_file); - $xml_obj = $tmp_xml_obj->thema; - - if(!$xml_obj) return; - - $thema_info->layout_name = $xml_obj->name->body; - $thema_info->skins = array(); - $thema_info->skins['module'] = array(); - $thema_info->skins['widget'] = array(); - - $skins = $xml_obj->skins->skin; - if ($skins){ - if (is_array($skins)){ - foreach($skins as $val){ - $thema_info->skins[$val->attrs->type][$val->attrs->name] = $val->attrs->skin; - } - }else{ - $thema_info->skins[$skins->attrs->type][$skins->attrs->name] = $skins->attrs->skin; - } - } - return $thema_info; - - } } ?> diff --git a/modules/layout/layout.view.php b/modules/layout/layout.view.php index c1aed24ff..772996ccc 100644 --- a/modules/layout/layout.view.php +++ b/modules/layout/layout.view.php @@ -27,6 +27,64 @@ $this->setLayoutFile('popup_layout'); // Set a template file $this->setTemplateFile('layout_detail_info'); + } + + /** + * @brief Preview a layout + **/ + function dispLayoutPreview() { + // admin check + // this act is admin view but in normal view because do not load admin css/js files + $logged_info = Context::get('logged_info'); + if ($logged_info->is_admin != 'Y') return $this->stop('msg_invalid_request'); + + $layout_srl = Context::get('layout_srl'); + $code = Context::get('code'); + $code_css = Context::get('code_css'); + if(!$layout_srl || !$code) return new Object(-1, 'msg_invalid_request'); + // Get the layout information + $oLayoutModel = &getModel('layout'); + $layout_info = $oLayoutModel->getLayout($layout_srl); + if(!$layout_info) return new Object(-1, 'msg_invalid_request'); + // Separately handle the layout if its type is faceoff + if($layout_info && $layout_info->type == 'faceoff') $oLayoutModel->doActivateFaceOff($layout_info); + // Apply CSS directly + Context::addHtmlHeader(""); + // Set names and values of extra_vars to $layout_info + if($layout_info->extra_var_count) { + foreach($layout_info->extra_var as $var_id => $val) { + $layout_info->{$var_id} = $val->value; + } + } + // menu in layout information becomes an argument for Context:: set + if($layout_info->menu_count) { + foreach($layout_info->menu as $menu_id => $menu) { + if(file_exists($menu->php_file)) @include($menu->php_file); + Context::set($menu_id, $menu); + } + } + + Context::set('layout_info', $layout_info); + Context::set('content', Context::getLang('layout_preview_content')); + // Temporary save the codes + $edited_layout_file = sprintf('./files/cache/layout/tmp.tpl'); + FileHandler::writeFile($edited_layout_file, $code); + + // Compile + $oTemplate = &TemplateHandler::getInstance(); + + $layout_path = $layout_info->path; + $layout_file = 'layout'; + + $layout_tpl = $oTemplate->compile($layout_path, $layout_file, $edited_layout_file); + Context::set('layout','none'); + // Convert widgets and others + $oContext = &Context::getInstance(); + Context::set('layout_tpl', $layout_tpl); + // Delete Temporary Files + FileHandler::removeFile($edited_layout_file); + $this->setTemplateFile('layout_preview'); + } } ?> diff --git a/modules/layout/queries/getLayoutList.xml b/modules/layout/queries/getLayoutList.xml index 047a476b4..612762ab2 100644 --- a/modules/layout/queries/getLayoutList.xml +++ b/modules/layout/queries/getLayoutList.xml @@ -8,6 +8,7 @@ + diff --git a/modules/layout/ruleset/codeUpdate.xml b/modules/layout/ruleset/codeUpdate.xml index 0c7e5501a..d20389403 100644 --- a/modules/layout/ruleset/codeUpdate.xml +++ b/modules/layout/ruleset/codeUpdate.xml @@ -1,10 +1,7 @@ - - - - + diff --git a/modules/layout/ruleset/deleteLayout.xml b/modules/layout/ruleset/deleteLayout.xml new file mode 100644 index 000000000..1d29b70f9 --- /dev/null +++ b/modules/layout/ruleset/deleteLayout.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/modules/layout/ruleset/imageUpload.xml b/modules/layout/ruleset/imageUpload.xml index 0c7e5501a..e00d16354 100644 --- a/modules/layout/ruleset/imageUpload.xml +++ b/modules/layout/ruleset/imageUpload.xml @@ -4,7 +4,7 @@ - + diff --git a/modules/layout/tpl/css/adminEdit.css b/modules/layout/tpl/css/adminEdit.css new file mode 100644 index 000000000..fe84194c6 --- /dev/null +++ b/modules/layout/tpl/css/adminEdit.css @@ -0,0 +1,3 @@ +.uploaded_image_list {list-style: none; margin: 0; padding: 0;} +.uploaded_image_list li {display: inline-block; margin-right: 10px;} +.uploaded_image_list img {border: 1px #ccc solid; padding: 3px; width: 96px; height: 96px;} \ No newline at end of file diff --git a/modules/layout/tpl/header.html b/modules/layout/tpl/header.html index 7f8ee133c..d61aaf0d1 100644 --- a/modules/layout/tpl/header.html +++ b/modules/layout/tpl/header.html @@ -1,17 +1,5 @@ - +

{$lang->installed_layout}

-

{$lang->layout_management}

- -
{nl2br($lang->about_layout)}
- - - - - +
+

{$XE_VALIDATOR_MESSAGE}

+
\ No newline at end of file diff --git a/modules/layout/tpl/installed_layout_list.html b/modules/layout/tpl/installed_layout_list.html new file mode 100644 index 000000000..cba868120 --- /dev/null +++ b/modules/layout/tpl/installed_layout_list.html @@ -0,0 +1,57 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ PC({$pcLayoutCount}) + PC({$pcLayoutCount}) + | + Mobile({$mobileLayoutCount}) + Mobile({$mobileLayoutCount}) +
{$lang->layout_name}{$lang->version}{$lang->author}{$lang->path}{$lang->cmd_delete}
+

{$layout->title}

+

{$layout->description}

+

+ {$lang->msg_avail_update} {$lang->msg_do_you_like_update} +

+
{$layout->version} + + {$author->name} + {$author->name} + + {$layout->path}{$lang->cmd_delete} +

{$layout->layout}

+

+ {$lang->msg_avail_update} {$lang->msg_do_you_like_update} +

+
--{$layout->path}{$lang->cmd_delete}
+
diff --git a/modules/layout/tpl/js/adminEdit.js b/modules/layout/tpl/js/adminEdit.js new file mode 100644 index 000000000..c0ffa12e3 --- /dev/null +++ b/modules/layout/tpl/js/adminEdit.js @@ -0,0 +1,24 @@ +jQuery(document).ready(function($){ + $('.uploaded_image').css('cursor', 'pointer'); + $('.uploaded_image_path').hide(); + $('.uploaded_image').bind('click', function(e){ + var path = $(this).siblings('.uploaded_image_path').html(); + var html = '
' + path + '
'; + + $('.selected_image_path').remove(); + $('.uploaded_image_list').after(html); + }); +}); + +function doPreviewLayoutCode() +{ + var $form = jQuery('#fo_layout'), $act = $form.find('input[name=act]'); + var og_act = $act.val(); + + $form.attr('target', '_LayoutPreview'); + $act.val('dispLayoutPreview'); + $form.submit(); + + $form.removeAttr('target'); + $act.val(og_act); +} \ No newline at end of file diff --git a/modules/layout/tpl/js/adminList.js b/modules/layout/tpl/js/adminList.js new file mode 100644 index 000000000..9610f3ff0 --- /dev/null +++ b/modules/layout/tpl/js/adminList.js @@ -0,0 +1,8 @@ +var ConfirmCheck = xe.createPlugin('confirm_check', { + API_BEFORE_VALIDATE: function(sender, params){ + return confirm(xe.lang.confirm_delete); + } +}); + +var Validator = xe.getApp('Validator')[0]; +Validator.registerPlugin(new ConfirmCheck()); \ No newline at end of file diff --git a/modules/layout/tpl/layout_edit.html b/modules/layout/tpl/layout_edit.html index 924c23d2d..14c40e641 100644 --- a/modules/layout/tpl/layout_edit.html +++ b/modules/layout/tpl/layout_edit.html @@ -1,127 +1,102 @@ - - + + + - -

{$selected_layout->layout_title}

+

{$selected_layout->layout_title}

- +

{$selected_layout->title} ver {$selected_layout->version} ({$selected_layout->layout})

+

{nl2br($lang->about_layout_code)}

-

{$selected_layout->title} ver {$selected_layout->version} ({$selected_layout->layout})

-

{nl2br($lang->about_layout_code)}

+

{$lang->layout_image_repository}

+

{nl2br($lang->about_layout_image_repository)}

-

{$lang->layout_image_repository}

-

{nl2br($lang->about_layout_image_repository)}

+
+
    +
  • + {@$ext=substr(strrchr($file,'.'),1)} +
    + + +
    +
    {$layout_image_path}{$file}
    +
    + + + + -
    -

    {$XE_VALIDATOR_MESSAGE}

    -
    - - - - + +
    +
  • +
+
+ + + +
    +
  • +

    {$lang->msg_layout_image_target}

    +
  • +
+
+ +
+
+
- - - - - - - - - - - -
- - {@$ext=substr(strrchr($file,'.'),1)} -
- - - - - - {$lang->cmd_delete} -
- -   -
-
- - - {$lang->msg_layout_image_target} -
- + +

{$lang->layout_migration}

+

{nl2br($lang->about_layout_migration)}

+ + + + + + + + + +
{$lang->layout_export}
+ {$lang->layout_btn_export} +

{$lang->about_layout_export}

+
{$lang->layout_import}
+
+ + + + + +
+

{$lang->about_layout_import}

+
+
- -

{$lang->layout_migration}

-

{nl2br($lang->about_layout_migration)}

- - - - - - - - - -
{$lang->layout_export}
- {$lang->layout_btn_export} -

{$lang->about_layout_export}

-
{$lang->layout_import}
-
- - - - - -
-

{$lang->about_layout_import}

-
- - - -
+ - - - - - - - - - - - - - - - - -
HTML
- - - {$widget->title} - -
CSS
- -
- - - - -
+

HTML

+
+ + + {$widget->title} + +
+ +

CSS

+
+ +
+
+ +
+
+ + +
- - diff --git a/modules/layout/tpl/layout_instance_list.html b/modules/layout/tpl/layout_instance_list.html new file mode 100644 index 000000000..1dd4ad4e6 --- /dev/null +++ b/modules/layout/tpl/layout_instance_list.html @@ -0,0 +1,43 @@ + + + + + +

{$layout_info->title} ver {$layout_info->version} ({$layout_info->layout})

+
+ + + + + + + + + + + + + + + + + + + + + +
{$lang->no}{$lang->title}{$lang->regdate}{$lang->cmd_layout_management}{$lang->cmd_layout_edit}{$lang->cmd_delete}
{$no+1}{$layout->title}{zdate($layout->regdate, "Y-m-d")}{$lang->cmd_layout_management}{$lang->cmd_layout_edit} +
+ + + + + +
+
+
+ \ No newline at end of file diff --git a/modules/layout/tpl/layout_modify.html b/modules/layout/tpl/layout_modify.html index d38be7994..9d705bb50 100644 --- a/modules/layout/tpl/layout_modify.html +++ b/modules/layout/tpl/layout_modify.html @@ -1,184 +1,145 @@ - + - +

{$selected_layout->layout_title}

+

{$selected_layout->title}

-

{$selected_layout->layout_title}

- - -
-

{$XE_VALIDATOR_MESSAGE}

-
-
+ - + + + +
    +
  • +

    {$lang->layout}

    +

    {$selected_layout->title} ver {$selected_layout->version} ({$selected_layout->layout})

    +
  • +
  • +

    {$lang->path}

    +

    {$selected_layout->path}

    +
  • +
  • +

    {$lang->description}

    +

    {$selected_layout->description}

    +
  • +
  • +

    {$lang->author}

    +

    {$selected_layout->author->name}

    +
  • +
  • +

    {$lang->header_script}

    +

    + +

    +

    {$lang->about_header_script}

    +
  • +
  • +

    {$lang->title}

    +

    + +

    +

    {$lang->about_title}

    +
  • +
- --- - - - + +
    + +
+

{$var->group}

+
    + {@$group = $var->group} + + {@$not_first = true} +
  • +

    {$var->title}

    +
    + - -
- - - - + - - - - - - + + +

+
+

+
- - - - - - + - - - - - - - - + + + + {@ + $_img_info = getImageSize($val->thumbnail); + $_height = $_img_info[1] + 40; + $_width = $img_info[0] + 20; + $_talign = 'center'; + } + + + {@ + $_width = 200; + $_height = 20; + $_talign = 'left'; + } + - + +
+ + + +
+
+
+
+ +

{$var->description}

+ + + - -
{$lang->layout}
{$selected_layout->title} ver {$selected_layout->version} ({$selected_layout->layout})
{$lang->path}
{$selected_layout->path}
{$lang->description}
{nl2br(trim($selected_layout->description))}
{$lang->author}
{$selected_layout->author->name}
{$lang->header_script}
- -

{$lang->about_header_script}

-
{$lang->title}
- -

{$lang->about_title}

-
+

{$lang->menu}

+
    +
  • +

    {$menu_info->title} ({$menu_name})

    +

    + + {$lang->cmd_management} +

    +
  • +
  • +

    {$lang->not_apply_menu}

    +

    + {$lang->about_not_apply_menu} +

    +
  • +
  • +

    {$lang->apply_mobile_view}

    +

    + {$lang->about_apply_mobile_view} +

    +
  • +
-{@$group = $var->group} -

{$group}

- --- +
+ + + +
- - - - - -
{$var->title}
- - - - - - - - - -
- image
- - -
- - - - - - - - - - - {@ $_img_info = getImageSize($val->thumbnail); $_height = $_img_info[1]+40; $_width = $_img_info[0]+20; $_talign = "center"; } - - {@ $_width = 200; $_height = 20; $_talign = "left"; } - - - -
- - - - - -
- - - -

{$var->description}

-
- -

{$lang->menu}

- --- - - - - - - - - - - - - - - - -
{$menu_info->title}
({$menu_name})
- - {$lang->cmd_management} -
{$lang->not_apply_menu}
- - {$lang->about_not_apply_menu} -
{$lang->apply_mobile_view}
- - {$lang->about_apply_mobile_view} -
- - -
- - + \ No newline at end of file