mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-20 10:35:15 +00:00
Basic schema support - but no actual schemas.
This commit is contained in:
parent
35db6ffa10
commit
41838fdfad
3 changed files with 45 additions and 3 deletions
|
@ -3,6 +3,7 @@
|
|||
function theme_content(&$a) {
|
||||
if(!local_user()) { return;}
|
||||
|
||||
$schema = get_pconfig(local_user(),'redbasic', 'schema' );
|
||||
$nav_colour = get_pconfig(local_user(),'redbasic', 'nav_colour' );
|
||||
$background_colour = get_pconfig(local_user(),'redbasic', 'background_colour' );
|
||||
$background_image = get_pconfig(local_user(),'redbasic', 'background_image' );
|
||||
|
@ -12,7 +13,7 @@ function theme_content(&$a) {
|
|||
$font_colour = get_pconfig(local_user(),'redbasic', 'font_colour' );
|
||||
$radius = get_pconfig(local_user(),'redbasic', 'radius' );
|
||||
$shadow = get_pconfig(local_user(),'redbasic', 'photo_shadow' );
|
||||
return redbasic_form($a, $nav_colour, $background_colour, $background_image, $item_colour, $item_opacity,
|
||||
return redbasic_form($a, $schema, $nav_colour, $background_colour, $background_image, $item_colour, $item_opacity,
|
||||
$font_size, $font_colour, $radius, $shadow);
|
||||
}
|
||||
|
||||
|
@ -20,6 +21,7 @@ function theme_post(&$a) {
|
|||
if(!local_user()) { return;}
|
||||
|
||||
if (isset($_POST['redbasic-settings-submit'])) {
|
||||
set_pconfig(local_user(), 'redbasic', 'schema', $_POST['redbasic_schema']);
|
||||
set_pconfig(local_user(), 'redbasic', 'nav_colour', $_POST['redbasic_nav_colour']);
|
||||
set_pconfig(local_user(), 'redbasic', 'background_colour', $_POST['redbasic_background_colour']);
|
||||
set_pconfig(local_user(), 'redbasic', 'background_image', $_POST['redbasic_background_image']);
|
||||
|
@ -32,9 +34,21 @@ function theme_post(&$a) {
|
|||
}
|
||||
}
|
||||
|
||||
function redbasic_form(&$a, $nav_colour, $background_colour, $background_image, $item_colour, $item_opacity,
|
||||
function redbasic_form(&$a, $schema, $nav_colour, $background_colour, $background_image, $item_colour, $item_opacity,
|
||||
$font_size, $font_colour, $radius, $shadow) {
|
||||
|
||||
$scheme_choices = array();
|
||||
$scheme_choices["---"] = t("Default");
|
||||
$files = glob('view/theme/' . current_theme() . '/schema/*');
|
||||
if($files) {
|
||||
foreach($files as $file) {
|
||||
$f = basename($file, ".php");
|
||||
$scheme_name = $f;
|
||||
$scheme_choices[$f] = $scheme_name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$nav_colours = array (
|
||||
'red' => 'red',
|
||||
'black' => 'black',
|
||||
|
@ -46,6 +60,7 @@ function redbasic_form(&$a, $nav_colour, $background_colour, $background_image,
|
|||
'$submit' => t('Submit'),
|
||||
'$baseurl' => $a->get_baseurl(),
|
||||
'$title' => t("Theme settings"),
|
||||
'$schema' => array('redbasic_schema', t('Set scheme'), $schema, '', $scheme_choices),
|
||||
'$nav_colour' => array('redbasic_nav_colour', t('Navigation bar colour'), $nav_colour, '', $nav_colours),
|
||||
'$background_colour' => array('redbasic_background_colour', t('Set the background colour'), $background_colour),
|
||||
'$background_image' => array('redbasic_background_image', t('Set the background image'), $background_image),
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
$search_background = '#EEEEEE';
|
||||
}
|
||||
|
||||
// Load the owners pconfig
|
||||
$background_colour = get_pconfig($uid, "redbasic", "background_colour");
|
||||
$background_image = get_pconfig($uid, "redbasic", "background_image");
|
||||
$item_colour = get_pconfig($uid, "redbasic", "item_colour");
|
||||
|
@ -36,8 +37,27 @@
|
|||
$font_size = get_pconfig($uid, "redbasic", "font_size");
|
||||
$font_colour = get_pconfig($uid, "redbasic", "font_colour");
|
||||
$radius = get_pconfig($uid, "redbasic", "radius");
|
||||
$shadow = get_pconfig($uid,"redbasic","photo_shadow");
|
||||
$shadow = get_pconfig($uid,"redbasic","photo_shadow");
|
||||
|
||||
// Now load the scheme. If a value is changed above, we'll keep the settings
|
||||
// If not, we'll keep those defined by the schema
|
||||
// Setting $scheme to '' wasn't working for some reason, so we'll check it's
|
||||
// not --- like the mobile theme does instead.
|
||||
|
||||
if (($schema) && ($schema != '---')) {
|
||||
$schemefile = 'view/theme/' . current_theme() . '/schema/' . $schema . '.php';
|
||||
require_once ($schemefile);
|
||||
}
|
||||
|
||||
// If we haven't got a schema, load the default. We shouldn't touch this - we
|
||||
// should leave it for admins to define for themselves.
|
||||
if (! $schema) {
|
||||
if(file_exists('view/theme/' . current_theme() . '/schema/default.php')) {
|
||||
$schemefile = 'view/theme/' . current_theme() . '/schema/' . 'default.php';
|
||||
require_once ($schemefile);
|
||||
}
|
||||
}
|
||||
|
||||
//Set some defaults - we have to do this after pulling owner settings, and we have to check for each setting
|
||||
//individually. If we don't, we'll have problems if a user has set one, but not all options.
|
||||
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
{{include file="field_select.tpl" field=$schema}}
|
||||
<div class="settings-submit-wrapper">
|
||||
<input type="submit" value="{{$submit}}" class="settings-submit" name="redbasic-settings-submit" />
|
||||
</div>
|
||||
|
||||
{{if $expert}}
|
||||
{{include file="field_select.tpl" field=$nav_colour}}
|
||||
{{include file="field_input.tpl" field=$background_colour}}
|
||||
{{include file="field_input.tpl" field=$background_image}}
|
||||
|
@ -11,3 +17,4 @@
|
|||
<div class="settings-submit-wrapper">
|
||||
<input type="submit" value="{{$submit}}" class="settings-submit" name="redbasic-settings-submit" />
|
||||
</div>
|
||||
{{/if}}
|
Loading…
Reference in a new issue