';
$this->ColorSelector();
}
/**
* Display a list of all the titles using the current layout
*
*/
public function ShowTitles(){
global $langmessage;
//affected titles
$titles_count = $this->TitlesCount($this->curr_layout);
echo '
';
echo '';
}
}
/**
* Display gadgets and their status for the current layout
*
*/
public function ShowGadgets(){
global $langmessage, $config;
$gadget_info = \gp\tool\Output::WhichGadgets($this->curr_layout);
echo '
';
}
/**
* Create a drop-down menu for the layout options
*
*/
public function LayoutOptions($layout,$info){
global $langmessage, $config;
//theme name
echo '
';
}
}
/**
* Get number of handlers
*
*/
public function HandlersCount($layout_info){
$handlers_count = 0;
if( isset($layout_info['handlers']) && is_array($layout_info['handlers']) ){
foreach($layout_info['handlers'] as $val){
$int = count($val);
if( $int === 0){
$handlers_count++;
}
$handlers_count += $int;
}
}
return $handlers_count;
}
/**
* Get the custom css for a layout if it exists
*
*/
public function LayoutCSS($layout){
$custom_file = $this->LayoutCSSFile($layout);
if( file_exists($custom_file) ){
return file_get_contents($custom_file);
}
return '';
}
/**
* Save the custom.css or custom.scss file
*
*/
public function SaveCustom($layout, $css){
global $langmessage;
//delete css file if empty
if( empty($css) ){
return $this->RemoveCSS($layout);
}
//save if not empt
$custom_file = $this->LayoutCSSFile($layout);
if( !\gp\tool\Files::Save($custom_file,$css) ){
message($langmessage['OOPS'].' (CSS not saved)');
return false;
}
return true;
}
/**
* Get the path of the custom css file
*
*/
public function LayoutCSSFile($layout){
$layout_info = \gp\tool::LayoutInfo($layout,false);
$dir = $layout_info['dir'].'/'.$layout_info['theme_color'];
$style_type = \gp\tool\Output::StyleType($dir);
return \gp\tool\Output::CustomStyleFile($layout, $style_type);
}
/**
* Remove the custom css file for a layout
*
*/
public function RemoveCSS($layout){
global $gpLayouts;
$path = $this->LayoutCSSFile($layout);
if( file_exists($path) ){
unlink($path);
}
$dir = dirname($path);
$path = $dir.'/index.html';
if( file_exists($path) ){
unlink($path);
}
if( file_exists($dir) ){
\gp\tool\Files::RmDir($dir);
}
if( isset($gpLayouts[$layout]['css']) ){
unset($gpLayouts[$layout]['css']);
}
return true;
}
/**
* Save changes to the css settings for a layout
*
*/
public function CSSPreferences(){
global $langmessage, $gpLayouts;
$new_info = $gpLayouts[$this->curr_layout];
if( isset($_POST['menu_css_ordered']) ){
if( $_POST['menu_css_ordered'] === 'off' ){
$new_info['menu_css_ordered'] = false;
}else{
unset($new_info['menu_css_ordered']);
}
}
if( isset($_POST['menu_css_indexed']) ){
if( $_POST['menu_css_indexed'] === 'off' ){
$new_info['menu_css_indexed'] = false;
}else{
unset($new_info['menu_css_indexed']);
}
}
$gpLayouts[$this->curr_layout] = $new_info;
if( !$this->SaveLayouts(false) ){
return;
}
if( $this->layout_request || $this->page->gpLayout == $this->curr_layout ){
$this->page->SetTheme($this->curr_layout);
}
$content = $this->CSSPreferenceForm($this->curr_layout,$new_info);
$this->page->ajaxReplace = array();
$this->page->ajaxReplace[] = array('replace','#layout_css_ul_'.$this->curr_layout,$content);
}
/**
* Remove a gadget from a layout
* @return null
*
*/
public function RmGadget(){
global $langmessage;
//$this->page->ajaxReplace = array();
$gadget =& $_REQUEST['gadget'];
$handlers = $this->GetAllHandlers($this->curr_layout);
$this->PrepContainerHandlers($handlers,'GetAllGadgets','GetAllGadgets'); //make sure GetAllGadgets is set
$changed = false;
foreach($handlers as $container => $container_info){
foreach($container_info as $key => $gpOutCmd){
if( $gpOutCmd == $gadget ){
$changed = true;
unset($handlers[$container][$key]);
}
}
}
if( !$changed ){
message($langmessage['OOPS'].' (Not Changed)');
return;
}
$this->SaveHandlersNew($handlers,$this->curr_layout);
}
public static function GetRandColor(){
$colors = self::GetColors();
$color_key = array_rand($colors);
return $colors[$color_key];
}
public static function GetColors(){
return array(
'#ff0000', '#ff9900', '#ffff00', '#00ff00', '#00ffff', '#0000ff', '#9900ff', '#ff00ff',
'#f4cccc', '#fce5cd', '#fff2cc', '#d9ead3', '#d0e0e3', '#cfe2f3', '#d9d2e9', '#ead1dc',
'#ea9999', '#f9cb9c', '#ffe599', '#b6d7a8', '#a2c4c9', '#9fc5e8', '#b4a7d6', '#d5a6bd',
'#e06666', '#f6b26b', '#ffd966', '#93c47d', '#76a5af', '#6fa8dc', '#8e7cc3', '#c27ba0',
'#cc0000', '#e69138', '#f1c232', '#6aa84f', '#45818e', '#3d85c6', '#674ea7', '#a64d79',
'#990000', '#b45f06', '#bf9000', '#38761d', '#134f5c', '#0b5394', '#351c75', '#741b47',
);
}
/**
* Update theme hooks and references in any related layouts
*
*
*/
public function UpgradeTheme(){
global $langmessage, $gpLayouts;
$theme =& $_REQUEST['source'];
$theme_info = $this->ThemeInfo($theme);
if( !$theme_info ){
message($langmessage['OOPS'].' (Invalid Source)');
return false;
}
//install addon
$installer = new \gp\admin\Addon\Installer();
$installer->addon_folder_rel = dirname($theme_info['rel']);
$installer->code_folder_name = '_themes';
$installer->source = $theme_info['full_dir'];
$success = $installer->Install();
$installer->OutputMessages();
if( !$success ){
return;
}
$this->UpdateLayouts( $installer );
}
/**
* Update related layouts with new $theme_info
*
*/
public function UpdateLayouts( $installer ){
global $gpLayouts, $langmessage;
$theme_folder = basename($installer->dest);
if( strpos($installer->dest,'/data/_themes') !== false ){
$new_layout_info = $this->AvailableTheme('/data/_themes',true, $theme_folder);
}else{
$new_layout_info = $this->AvailableTheme('/themes',false, $theme_folder);
}
if( $new_layout_info === false ){
return;
}
if( $installer->has_hooks ){
$new_layout_info['addon_key'] = $installer->config_key;
}
// update each layout
foreach($gpLayouts as $layout => $layout_info){
if( !$this->SameTheme( $layout_info, $new_layout_info ) ){
continue;
}
unset( $layout_info['is_addon'], $layout_info['addon_id'], $layout_info['version'], $layout_info['name'], $layout_info['addon_key'] );
$layout_info += $new_layout_info;
$layout_info['theme'] = $theme_folder.'/'.basename($layout_info['theme']);
$gpLayouts[$layout] = $layout_info;
}
$this->SaveLayouts();
}
/**
* Return true if two layouts use the same theme
*
*/
public function SameTheme($layout_info, $new_layout_info ){
//if we have addon ids
if( isset($new_layout_info['addon_id']) && isset($layout_info['addon_id']) && $layout_info['addon_id'] == $new_layout_info['addon_id'] ){
return true;
}
if( isset($layout_info['is_addon']) && $layout_info['is_addon'] ){
$layout_info['rel'] = '/data/_themes/'.dirname($layout_info['theme']);
}else{
$layout_info['rel'] = '/themes/'.dirname($layout_info['theme']);
}
$keys = array('is_addon'=>'','rel'=>'');
$testa = array_intersect_key($layout_info,$keys);
$testb = array_intersect_key($new_layout_info,$keys);
if( $testa === $testb ){
return true;
}
return false;
}
/**
*
*/
public function RemoteInstallConfirmed($type='themes'){
$installer = parent::RemoteInstallConfirmed($type);
$this->GetPossible();
$this->UpdateLayouts( $installer );
}
/**
* Display some options before copying a layout
*
*/
public function CopyLayoutPrompt(){
global $langmessage, $gpLayouts;
$layout = $this->ReqLayout();
if( $layout === false ){
return;
}
$label = self::NewLabel($gpLayouts[$layout]['label']);
echo '
'.$langmessage['new_layout'].'
';
echo '';
}
/**
* Copy a layout
*
*/
public function CopyLayout(){
global $gpLayouts, $langmessage;
$copy_id = $this->ReqLayout();
if( $copy_id === false ){
return;
}
if( empty($_POST['label']) ){
message($langmessage['OOPS'].'(Empty Label)');
return;
}
$newLayout = $gpLayouts[$copy_id];
$newLayout['color'] = self::GetRandColor();
$newLayout['label'] = htmlspecialchars($_POST['label']);
//get new unique layout id
do{
$layout_id = rand(1000,9999);
}while( isset($gpLayouts[$layout_id]) );
$gpLayouts[$layout_id] = $newLayout;
if( !\gp\tool\Files::ArrayInsert($copy_id,$layout_id,$newLayout,$gpLayouts,1) ){
message($langmessage['OOPS'].'(Not Inserted)');
return;
}
//copy any css
$css = $this->layoutCSS($copy_id);
if( !$this->SaveCustom($layout_id, $css) ){
return false;
}
$this->SaveLayouts();
}
/**
* Save the gpLayouts data
*
*/
protected function SaveLayouts($notify_user = true){
global $gpLayouts;
if( \gp\admin\Tools::SavePagesPHP($notify_user, $notify_user) ){
return true;
}
if( is_array($this->gpLayouts_before) ){
$gpLayouts = $this->gpLayouts_before;
}
return false;
}
/**
* Save the config setting
*
*/
protected function SaveConfig(){
global $config;
if( \gp\admin\Tools::SaveConfig(true, true) ){
return true;
}
if( is_array($this->config_before) ){
$config = $this->config_before;
}
return false;
}
/**
* Create a new unique layout label
* @static
*/
public function NewLabel($label){
global $gpLayouts;
$labels = array();
foreach($gpLayouts as $info){
$labels[$info['label']] = true;
}
$len = strlen($label);
if( $len > 25 ){
$label = substr($label,0,$len-2);
}
if( substr($label,$len-2,1) === '_' && is_numeric(substr($label,$len-1,1)) ){
$label = substr($label,0,$len-2);
}
$int = 1;
do{
$new_label = $label.'_'.$int;
$int++;
}while( isset($labels[$new_label]) );
return $new_label;
}
public function LoremIpsum(){
global $langmessage, $gp_titles, $gp_menu;
ob_start();
echo '
H1 Lorem Ipsum Heading
';
echo '
Paragraph (larger): Lorem ipsum dolor sit amet, consectetur adipisicing elit, ';
echo 'sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ';
echo 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
';
echo '
H2 Lorem Ipsum Heading
';
echo '
Paragraph: Excepteur sint emphazize cupidatat non strong proident, sunt in ';
echo 'emphasized strong culpa qui officia anchor ';
echo 'deserunt underline mollit anim id est laborum. Duis aute irure dolor in reprehenderit in voluptate ';
echo 'velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui ';
echo 'abbr officia deserunt mollit mark anim id est code laborum.
';
echo '
Blockquote: Lorem ipsum dolor sit amet, consectetur adipisicing elit.
';
echo '
';
echo '
';
echo '
Unordered list
';
echo '
';
echo '
Lorem Ipsum unordered list item
';
echo '
Lorem Ipsum unordered list item
';
echo '
Lorem Ipsum unordered list item
';
echo '
Lorem Ipsum unordered list item
';
echo '
';
echo '
'; // /.gpCol-4
echo '
';
echo '
Ordered list
';
echo '';
echo '
Lorem Ipsum ordered list item
';
echo '
Lorem Ipsum ordered list item
';
echo '
Lorem Ipsum ordered list item
';
echo '
Lorem Ipsum ordered list item
';
echo '';
echo '
'; // /.gpCol-4
echo '
';
echo '
Description list
';
echo '
';
echo '
Lorem Ipsum term
Lorem Ipsum description
';
echo '
Lorem Ipsum term
Lorem Ipsum description
';
echo '
';
echo '
'; // /.gpCol-4
echo '
'; // /.gpRow
echo '';
echo '
';
echo '
';
echo '
H3 Lorem Ipsum Heading
';
echo '
H4 Lorem Ipsum Heading
';
echo '
H5 Lorem Ipsum Heading
';
echo '
H6 Lorem Ipsum Heading
';
echo '
Paragraph (smaller): Excepteur sint cupidatat non proident, sunt in ';
echo 'culpa qui officia deserunt mollit anim id est laborum. Duis aute irure dolor in reprehenderit ';
echo 'in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat ';
echo 'non proident.
Lead: Lorem ipsum dolor sit amet, consectetur adipisicing elit, ';
echo 'sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ';
echo 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
';
echo '
H2 Lorem Ipsum Heading + small
';
echo '
Default paragraph: Excepteur sint emphazize cupidatat non strong proident, sunt in ';
echo 'emphasized strong culpa qui officia anchor ';
echo 'deserunt underline mollit anim id est laborum. Duis aute irure dolor in reprehenderit in voluptate ';
echo 'velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint kbd occaecat cupidatat non proident, sunt in culpa qui ';
echo 'abbr officia deserunt mollit mark anim id est code laborum.
Blockquote: Lorem ipsum dolor sit amet, consectetur adipisicing elit.
';
echo '
';
echo '
';
echo '
Unordered list
';
echo '
';
echo '
Lorem Ipsum unordered list item
';
echo '
Lorem Ipsum unordered list item
';
echo '
Lorem Ipsum unordered list item
';
echo '
Lorem Ipsum unordered list item
';
echo '
';
echo '
'; // /.col-sm-4
echo '
';
echo '
Ordered list
';
echo '';
echo '
Lorem Ipsum ordered list item
';
echo '
Lorem Ipsum ordered list item
';
echo '
Lorem Ipsum ordered list item
';
echo '
Lorem Ipsum ordered list item
';
echo '';
echo '
'; // /.col-sm-4
echo '
';
echo '
Description list
';
echo '
';
echo '
Lorem Ipsum term
Lorem Ipsum description
';
echo '
Lorem Ipsum term
Lorem Ipsum description
';
echo '
';
echo '
'; // /.col-sm-4
echo '
'; // /.row
echo '
';
echo '
';
echo '
H3 Lorem Ipsum Heading + small
';
echo '
H4 Lorem Ipsum Heading + small
';
echo '
H5 Lorem Ipsum Heading + small
';
echo '
H6 Lorem Ipsum Heading + small
';
echo '
Small text paragraph: Excepteur sint cupidatat non proident, sunt in ';
echo 'culpa qui officia deserunt mollit anim id est laborum. Duis aute irure dolor in reprehenderit ';
echo 'in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat ';
echo 'non proident.