page->requested);
if( !empty($parts[2]) ){
if( $this->SetCurrLayout($parts[2]) ){
$this->EditLayout();
return;
}
//default layout
}elseif( $this->SetCurrLayout($config['gpLayout']) ){
$this->EditLayout();
return;
}
//redirect
$url = \gp\tool::GetUrl('Admin_Theme_Content','',false);
\gp\tool::Redirect($url,302);
}
/**
* Set the current layout
*
*/
protected function SetCurrLayout($layout){
global $langmessage, $gpLayouts;
if( !isset($gpLayouts[$layout]) ){
return false;
}
$this->curr_layout = $layout;
$this->SetLayoutArray();
$this->page->SetTheme($layout);
if( !$this->page->gpLayout ){
message($langmessage['OOPS'].' (Theme Not Found)');
parent::RunScript();
return false;
}
\gp\tool\Output::TemplateSettings();
return true;
}
/**
* Edit layout properties
* Layout Identification
* Content Arrangement
* Gadget Visibility
*
*/
public function EditLayout(){
$GLOBALS['GP_ARRANGE_CONTENT'] = true;
$this->layout_slug = 'Admin_Theme_Content/Edit/'.rawurlencode($this->curr_layout);
$this->cmds['ShowThemeImages'] = '';
$this->cmds['SelectContent'] = '';
$this->cmds['LayoutMenu'] = '';
$this->cmds['LayoutMenuSave'] = 'ReturnHeader';
//show the layout (displayed within an iframe)
$this->cmds['SaveCSS'] = 'ShowInIframe';
$this->cmds['PreviewCSS'] = 'ShowInIframe';
$this->cmds['addcontent'] = 'ShowInIframe';
$this->cmds['RemoveArea'] = 'ShowInIframe';
$this->cmds['DragArea'] = 'ShowInIframe';
$this->cmds['in_iframe'] = 'ShowInIframe';
\gp\tool\Plugins::Action('edit_layout_cmd',array($this->curr_layout));
$cmd = \gp\tool::GetCommand();
$this->LayoutCommands();
$this->RunCommands($cmd);
}
public function DefaultDisplay(){
global $langmessage;
$layout_info = \gp\tool::LayoutInfo($this->curr_layout,false);
$this->page->label = $langmessage['layouts'] . ' ยป '.$layout_info['label'];
$this->LayoutEditor($this->curr_layout, $layout_info );
}
/**
* Prepare the page for css editing
*
*/
public function ShowInIframe(){
$this->LoremIpsum();
$cmd = \gp\tool::GetCommand();
$this->page->show_admin_content = false;
\gp\admin\Tools::$show_toolbar = false;
//
$this->page->head .= '';
if( $cmd != 'PreviewCSS' ){
$this->page->head .= '';
}
}
/**
* Display the toolbar for layout editing
*
*/
public function LayoutEditor($layout, $layout_info ){
global $langmessage, $gpAdmin;
$_REQUEST += array('gpreq' => 'body'); //force showing only the body as a complete html document
$this->page->get_theme_css = false;
$this->page->css_user[] = '/include/thirdparty/codemirror/lib/codemirror.css';
$this->page->head_js[] = '/include/thirdparty/codemirror/lib/codemirror.js';
$this->page->head_js[] = '/include/thirdparty/codemirror/mode/css/css.js';
$this->page->css_admin[] = '/include/css/theme_content_outer.scss';
$this->page->head_js[] = '/include/js/theme_content_outer.js';
//custom css
$css = $this->layoutCSS($this->curr_layout);
$dir = $layout_info['dir'].'/'.$layout_info['theme_color'];
$style_type = \gp\tool\Output::StyleType($dir);
$style_type_info = array();
switch ($style_type) {
case 'scss':
$style_type_info['name'] = 'Scss';
$style_type_info['link'] = 'http://sass-lang.com/';
break;
case 'less':
$style_type_info['name'] = 'Less';
$style_type_info['link'] = 'http://lesscss.org/';
break;
default:
$style_type_info['name'] = 'CSS';
$style_type_info['link'] = 'https://developer.mozilla.org/docs/Web/CSS';
}
//Iframe
echo '';
$url = \gp\tool::GetUrl('Admin_Theme_Content/Edit/'.rawurlencode($layout),'cmd=in_iframe');
echo '';
echo '
';
//CSS Editing
ob_start();
echo '';
echo '
';
//show site in iframe
echo '
'; //#theme_editor
$this->page->admin_html = ob_get_clean();
}
/**
* Display all the layouts available in a