mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-08 03:01:43 +09:00
layout module
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@8920 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
d48bcf6a6a
commit
2601043ee8
18 changed files with 767 additions and 510 deletions
|
|
@ -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("<style type=\"text/css\" charset=\"UTF-8\">".$code_css."</style>");
|
||||
// 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');
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue