From 393e7813d98a725c09796245da04c900f8df5361 Mon Sep 17 00:00:00 2001 From: devjin Date: Wed, 12 Sep 2012 07:23:49 +0000 Subject: [PATCH] issue 2367 modify a function of preivew. git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@11214 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- modules/layout/conf/module.xml | 1 + modules/layout/layout.view.php | 97 ++++++++++++++++++- .../layout/tpl/layout_all_instance_list.html | 13 ++- modules/menu/queries/getMenuItemByUrl.xml | 22 +++++ 4 files changed, 130 insertions(+), 3 deletions(-) create mode 100644 modules/menu/queries/getMenuItemByUrl.xml diff --git a/modules/layout/conf/module.xml b/modules/layout/conf/module.xml index e6c88917f..78399427b 100644 --- a/modules/layout/conf/module.xml +++ b/modules/layout/conf/module.xml @@ -19,6 +19,7 @@ + diff --git a/modules/layout/layout.view.php b/modules/layout/layout.view.php index 6dcda6966..f6f20b18e 100644 --- a/modules/layout/layout.view.php +++ b/modules/layout/layout.view.php @@ -31,11 +31,104 @@ $this->setTemplateFile('layout_detail_info'); } + + /** + * Preview a layout with module. + * + * @return Object + **/ + public function dispLayoutPreviewWithModule() + { + // 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'); + } + + $layoutSrl = Context::get('layout_srl'); + $moduleSrl = Context::get('module_srl'); + $module = Context::get('module'); + $mid = Context::get('mid'); + $skin = Context::get('skin'); + + // Get the layout information. + if(!$layoutSrl || !$module) + { + return new Object(-1, 'msg_invalid_request'); + } + + $oLayoutModel = getModel('layout'); + $layoutInfo = $oLayoutModel->getLayout($layoutSrl); + + if(!$layoutInfo) + { + return new Object(-1, 'msg_invalid_request'); + } + + // Set names and values of extra_vars to $layout_info + if($layoutInfo->extra_var_count) + { + foreach($layoutInfo->extra_var as $var_id => $val) + { + $layoutInfo->{$var_id} = $val->value; + } + } + + // menu in layout information becomes an argument for Context:: set + if($layoutInfo->menu_count) + { + foreach($layoutInfo->menu as $menu_id => $menu) + { + if(file_exists($menu->php_file)) @include($menu->php_file); + Context::set($menu_id, $menu); + } + } + + Context::set('layout_info', $layoutInfo); + + // Get the module information. + $oModuleHandler = new ModuleHandler($module, '', $mid, '', $moduleSrl); + $oModuleHandler->act = ''; + + if ($oModuleHandler->init()) + { + $oModule = $oModuleHandler->procModule(); + + if($skin) + { + $template_path = sprintf("%sskins/%s/",$oModule->module_path, $skin); + $oModule->setTemplatePath($template_path); + } + require_once("./classes/display/HTMLDisplayHandler.php"); + $handler = new HTMLDisplayHandler(); + $output = $handler->toDoc($oModule); + Context::set('content', $output); + } + else + { + Context::set('content', Context::getLang('layout_preview_content')); + } + + // Compile + $oTemplate = &TemplateHandler::getInstance(); + $layout_path = $layoutInfo->path; + $layout_file = 'layout'; + $layout_tpl = $oTemplate->compile($layout_path, $layout_file); + Context::set('layout','none'); + + // Convert widgets and others + $oContext = &Context::getInstance(); + Context::set('layout_tpl', $layout_tpl); + $this->setTemplateFile('layout_preview'); + } /** * Preview a layout * @return void|Object (void : success, Object : fail) **/ - function dispLayoutPreview() { + 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'); @@ -91,7 +184,7 @@ // Delete Temporary Files FileHandler::removeFile($edited_layout_file); $this->setTemplateFile('layout_preview'); - } + } ?> diff --git a/modules/layout/tpl/layout_all_instance_list.html b/modules/layout/tpl/layout_all_instance_list.html index b9c3ea247..99fc6d2f5 100644 --- a/modules/layout/tpl/layout_all_instance_list.html +++ b/modules/layout/tpl/layout_all_instance_list.html @@ -29,7 +29,8 @@ {$count++} {$layout_name} - {$item->title} + + {$item->title} {zdate($item->regdate, "Y-m-d")} {$lang->cmd_layout_management} {$lang->cmd_layout_edit} @@ -48,3 +49,13 @@ + + diff --git a/modules/menu/queries/getMenuItemByUrl.xml b/modules/menu/queries/getMenuItemByUrl.xml new file mode 100644 index 000000000..89049c9c4 --- /dev/null +++ b/modules/menu/queries/getMenuItemByUrl.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + +
+ + + + + + + + + +