admin_links[] = array(
$page->title,
' ' . $langmessage['theme'] . ' Cajón ',
'cmd=ThemeCajonSettingsForm',
'class="theme-cajon-adminbar-button" data-cmd="gpabox" title="' . $langmessage['theme'] . ' ' . $langmessage['Settings'] . '"'
);
self::LoadConfig();
$page->head_js[] = $addonRelativeCode . '/assets/theme_settings/settings.js';
$page->head_script .= "\n" . 'var ThemeCajonConfig = ' . json_encode(self::$config, JSON_FORCE_OBJECT) . ';' . "\n\n";
switch( $cmd ){
case 'ThemeCajonSettingsForm':
ob_start();
echo '
';
echo '
' . $langmessage['theme'] . ' Cajón » ' . $langmessage['Settings'] . '
';
self::SettingsForm('page');
echo '';
echo '';
$page->contentBuffer = ob_get_clean();
return 'return';
break;
case 'ThemeCajonSaveSettings':
self::SaveConfig();
return true;
break;
}
return $cmd;
}
static function LoadConfig(){
global $addonPathCode, $addonPathData, $addonRelativeCode;
$config_file = $addonPathData . '/config.php';
if( file_exists($config_file) ){
include $config_file;
}else{
include $addonPathCode . '/assets/theme_settings/default_config.php';
}
self::$config = $config;
// msg('$config = ' . pre($config));
}
static function SaveConfig(){
global $addonPathData, $langmessage;
$config = array(
'logo_img_url' => ( !empty($_POST['logo_img_url']) ? htmlspecialchars($_POST['logo_img_url']) : '' ),
'logo_img_url_enc' => ( !empty($_POST['logo_img_url']) ? implode('/', array_map('rawurlencode', explode('/', htmlspecialchars_decode($_POST['logo_img_url'])))) : '' ),
'logo_img_shape' => ( !empty($_POST['logo_img_shape']) ? htmlspecialchars($_POST['logo_img_shape']) : 'default' ),
'logo_img_size' => ( !empty($_POST['logo_img_size']) ? htmlspecialchars($_POST['logo_img_size']) : 'medium' ),
'logo_img_border' => ( !empty($_POST['logo_img_border']) ? htmlspecialchars($_POST['logo_img_border']) : 'none' ),
'logo_img_collapsed' => ( isset($_POST['logo_img_collapsed']) ? 'show' : 'hide' ),
'navbar_variant' => ( !empty($_POST['navbar_variant']) ? htmlspecialchars($_POST['navbar_variant']) : 'inverse' ),
'navbar_position' => ( !empty($_POST['navbar_position']) ? htmlspecialchars($_POST['navbar_position']) : 'left' ),
);
$config_file = $addonPathData . '/config.php';
if( \gp\tool\Files::SaveData($config_file, 'config', $config) ){
msg($langmessage['SAVED']);
}else{
msg($langmessage['OOPS']);
}
}
static function SettingsForm($render_mode='admin'){
global $langmessage, $config, $page;
$form_action = $page->gp_index ? \gp\tool::GetUrl($page->title) : \gp\tool::GetUrl('/Admin_Theme_Cajon_Admin');
$data_cmd = $page->gp_index ? ' data-cmd="gppost" ' : '';
$admin_box_close = $page->gp_index ? 'admin_box_close ' : '';
echo '';
}
} /* class ThemeCajon_Settings --end */