issue 2367 modify a function of preivew.

git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@11214 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
devjin 2012-09-12 07:23:49 +00:00
parent ba47c3ea18
commit 393e7813d9
4 changed files with 130 additions and 3 deletions

View file

@ -19,6 +19,7 @@
<action name="dispLayoutAdminCopyLayout" type="view" />
<action name="dispLayoutPreview" type="view" />
<action name="dispLayoutPreviewWithModule" type="view" />
<action name="procLayoutAdminUpdate" type="controller" ruleset="updateLayout" />
<action name="procLayoutAdminCodeUpdate" type="controller" ruleset="codeUpdate" />

View file

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

View file

@ -29,7 +29,8 @@
<tr loop="$layout => $no, $item">
<td class="nowr" rowspan="{count($layout)}" cond="$no === 0" >{$count++}</td>
<td class="nowr" rowspan="{count($layout)}" cond="$no === 0" >{$layout_name}</td>
<td class="title">{$item->title}</td>
<!--td class="title">{$item->title}</td-->
<td class="title __title" data-layout_srl="{$item->layout_srl}" data-skin="xe_v3_default">{$item->title}</td>
<td class="nowr">{zdate($item->regdate, "Y-m-d")}</td>
<td class="nowr"><a href="{getUrl('act', 'dispLayoutAdminModify', 'layout_srl', $item->layout_srl)}">{$lang->cmd_layout_management}</a></td>
<td class="nowr"><a href="{getUrl('act', 'dispLayoutAdminEdit', 'layout_srl', $item->layout_srl)}">{$lang->cmd_layout_edit}</a></td>
@ -48,3 +49,13 @@
</tbody>
</table>
</div>
<iframe id="preview_iframe" src="" style="z-index:10;width:1024px;height:768px;filter:progid:DXImageTransform.Microsoft.Matrix(M11=0.25,M22=0.25,SizingMethod='auto expand');-webkit-transform-origin:0 0; -webkit-transform: scale(.25);position:absolute"></iframe>
<script>
jQuery('.__title').click(function (){
var $ = jQuery;
var layout_srl = $(this).data('layout_srl');
var skin = $(this).data('skin');
var url = current_url.setQuery('act', 'dispLayoutPreviewWithModule').setQuery('module', 'board').setQuery('mid', 'testboard3').setQuery('layout_srl', layout_srl).setQuery('skin', skin);
$('#preview_iframe').attr('src', url);
});
</script>

View file

@ -0,0 +1,22 @@
<query id="getMenuItemByUrl" action="select">
<tables>
<table name="menu_item" alias="MI"/>
</tables>
<columns>
<column name="*" />
</columns>
<conditions>
<condition operation="equal" column="MI.url" var="url" notnull="notnull" />
<query operation="in" column="MI.menu_srl" notnull="notnull" alias="getSiteSrl" pipe="and" >
<tables>
<table name="menu" alias="M" />
</tables>
<columns>
<column name="menu_srl" />
</columns>
<conditions>
<condition operation="equal" column="M.site_srl" var = "site_srl" defaut = "0" notnull="notnull" />
</conditions>
</query>
</conditions>
</query>