turn theme configuration into a class object

This commit is contained in:
redmatrix 2016-09-01 22:10:56 -07:00
parent e5c077243c
commit b3efdf2109
3 changed files with 127 additions and 122 deletions

View File

@ -276,9 +276,9 @@ class Settings extends \Zotlabs\Web\Controller {
$newschema = $_POST['schema'];
if($newschema === '---')
$newschema = '';
}
theme_post($a);
$theme_config->post();
}
}
}
@ -1042,10 +1042,10 @@ class Settings extends \Zotlabs\Web\Controller {
require_once($themeconfigfile);
if(class_exists(ucfirst($theme) . 'Config')) {
$clsname = ucfirst($theme) . 'Config';
$theme_config = new $clsname();
$schemas = $theme_config->get_schemas();
$thm_config = new $clsname();
$schemas = $thm_config->get_schemas();
$theme_config = $thm_config->get();
}
$theme_config = theme_content($a);
}
// logger('schemas: ' . print_r($schemas,true));

View File

@ -24,9 +24,8 @@ class Theme_info extends \Zotlabs\Web\Controller {
$schemalist[] = [ 'key' => $k, 'val' => $v ];
}
}
$theme_config = $th_config->get();
}
$theme_config = theme_content($a);
}
$info = get_theme_info($theme);
if($info) {

View File

@ -1,6 +1,7 @@
<?php
class RedbasicConfig {
function get_schemas() {
$scheme_choices = array();
$scheme_choices["---"] = t("Focus (Hubzilla default)");
@ -16,15 +17,13 @@ class RedbasicConfig {
}
return $scheme_choices;
}
function get() {
if(!local_channel()) {
return;
}
function theme_content(&$a) {
if(!local_channel()) { return;}
$arr = array();
// $arr['schema'] = get_pconfig(local_channel(),'redbasic', 'schema' );
$arr['narrow_navbar'] = get_pconfig(local_channel(),'redbasic', 'narrow_navbar' );
$arr['nav_bg'] = get_pconfig(local_channel(),'redbasic', 'nav_bg' );
$arr['nav_gradient_top'] = get_pconfig(local_channel(),'redbasic', 'nav_gradient_top' );
@ -54,14 +53,15 @@ function theme_content(&$a) {
$arr['nav_min_opacity']=get_pconfig(local_channel(),"redbasic","nav_min_opacity");
$arr['top_photo']=get_pconfig(local_channel(),"redbasic","top_photo");
$arr['reply_photo']=get_pconfig(local_channel(),"redbasic","reply_photo");
return redbasic_form($a, $arr);
return $this->form($arr);
}
function theme_post(&$a) {
if(!local_channel()) { return;}
function post() {
if(!local_channel()) {
return;
}
if (isset($_POST['redbasic-settings-submit'])) {
// set_pconfig(local_channel(), 'redbasic', 'schema', $_POST['redbasic_schema']);
set_pconfig(local_channel(), 'redbasic', 'narrow_navbar', $_POST['redbasic_narrow_navbar']);
set_pconfig(local_channel(), 'redbasic', 'nav_bg', $_POST['redbasic_nav_bg']);
set_pconfig(local_channel(), 'redbasic', 'nav_gradient_top', $_POST['redbasic_nav_gradient_top']);
@ -94,15 +94,13 @@ function theme_post(&$a) {
}
}
function redbasic_form(&$a, $arr) {
function form($arr) {
if(feature_enabled(local_channel(),'advanced_theming'))
$expert = 1;
$t = get_markup_template('theme_settings.tpl');
$o .= replace_macros($t, array(
$o .= replace_macros(get_markup_template('theme_settings.tpl'), array(
'$submit' => t('Submit'),
'$baseurl' => z_root(),
'$theme' => App::$channel['channel_theme'],
@ -141,3 +139,11 @@ function redbasic_form(&$a, $arr) {
return $o;
}
}