configurable theme precedence rules, and passing the page owner to the pcss theme settings.
This commit is contained in:
parent
4c30cddbfc
commit
d6133c861c
45
boot.php
45
boot.php
@ -1915,6 +1915,27 @@ function current_theme(){
|
|||||||
$app_base_themes = array('redbasic');
|
$app_base_themes = array('redbasic');
|
||||||
|
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
$page_theme = null;
|
||||||
|
|
||||||
|
// Find the theme that belongs to the channel whose stuff we are looking at
|
||||||
|
|
||||||
|
if($a->profile_uid && $a->profile_uid != local_user()) {
|
||||||
|
$r = q("select channel_theme from channel where channel_id = %d limit 1",
|
||||||
|
intval($a->profile_uid)
|
||||||
|
);
|
||||||
|
if($r)
|
||||||
|
$page_theme = $r[0]['channel_theme'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allow folks to over-rule channel themes and always use their own on their own site.
|
||||||
|
// The default is for channel themes to take precedence over your own on pages belonging
|
||||||
|
// to that channel.
|
||||||
|
|
||||||
|
if($page_theme && local_user() && local_user() != $a->profile_url) {
|
||||||
|
if(get_pconfig(local_user(),'system','always_my_theme'))
|
||||||
|
$page_theme = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// $mobile_detect = new Mobile_Detect();
|
// $mobile_detect = new Mobile_Detect();
|
||||||
// $is_mobile = $mobile_detect->isMobile() || $mobile_detect->isTablet();
|
// $is_mobile = $mobile_detect->isMobile() || $mobile_detect->isTablet();
|
||||||
@ -1933,6 +1954,9 @@ function current_theme(){
|
|||||||
else {
|
else {
|
||||||
$system_theme = ((isset($a->config['system']['theme'])) ? $a->config['system']['theme'] : '');
|
$system_theme = ((isset($a->config['system']['theme'])) ? $a->config['system']['theme'] : '');
|
||||||
$theme_name = ((isset($_SESSION) && x($_SESSION,'theme')) ? $_SESSION['theme'] : $system_theme);
|
$theme_name = ((isset($_SESSION) && x($_SESSION,'theme')) ? $_SESSION['theme'] : $system_theme);
|
||||||
|
|
||||||
|
if($page_theme)
|
||||||
|
$theme_name = $page_theme;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($theme_name &&
|
if($theme_name &&
|
||||||
@ -1961,8 +1985,10 @@ function current_theme(){
|
|||||||
function current_theme_url($installing = false) {
|
function current_theme_url($installing = false) {
|
||||||
global $a;
|
global $a;
|
||||||
$t = current_theme();
|
$t = current_theme();
|
||||||
|
$uid = '';
|
||||||
|
$uid = (($a->profile_uid) ? '?f=&puid=' . $a->profile_uid : '');
|
||||||
if(file_exists('view/theme/' . $t . '/php/style.php'))
|
if(file_exists('view/theme/' . $t . '/php/style.php'))
|
||||||
return('view/theme/' . $t . '/php/style.pcss');
|
return('view/theme/' . $t . '/php/style.pcss' . $uid);
|
||||||
return('view/theme/' . $t . '/css/style.css');
|
return('view/theme/' . $t . '/css/style.css');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2343,6 +2369,19 @@ function head_get_icon() {
|
|||||||
return $icon;
|
return $icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_controlling_channel_id() {
|
// Used from within PCSS themes to set theme parameters. If there's a
|
||||||
return get_app()->profile_uid;
|
// puid request variable, that is the "page owner" and normally their theme
|
||||||
|
// settings take precedence; unless a local user sets the "always_my_theme"
|
||||||
|
// system pconfig, which means they don't want to see anybody else's theme
|
||||||
|
// settings except their own while on this site.
|
||||||
|
|
||||||
|
function get_theme_uid() {
|
||||||
|
$uid = (($_REQUEST['puid']) ? intval($_REQUEST['puid']) : 0);
|
||||||
|
if(local_user()) {
|
||||||
|
if((get_pconfig(local_user(),'system','always_my_theme')) || (! $uid))
|
||||||
|
return local_user();
|
||||||
|
if(! $uid)
|
||||||
|
return local_user();
|
||||||
|
}
|
||||||
|
return $uid;
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ function network_init(&$a) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$channel = $a->get_channel();
|
$channel = $a->get_channel();
|
||||||
|
$a->profile_uid = local_user();
|
||||||
head_set_icon($channel['xchan_photo_s']);
|
head_set_icon($channel['xchan_photo_s']);
|
||||||
|
|
||||||
$is_a_date_query = false;
|
$is_a_date_query = false;
|
||||||
|
@ -1 +1 @@
|
|||||||
2013-07-16.376
|
2013-07-17.377
|
||||||
|
@ -23,7 +23,7 @@ function theme_content(&$a) {
|
|||||||
|
|
||||||
function theme_post(&$a) {
|
function theme_post(&$a) {
|
||||||
if(!local_user()) { return; }
|
if(!local_user()) { return; }
|
||||||
|
|
||||||
if (isset($_POST['redbasic-settings-submit'])) {
|
if (isset($_POST['redbasic-settings-submit'])) {
|
||||||
set_pconfig(local_user(), 'redbasic', 'font_size', $_POST['redbasic_font_size']);
|
set_pconfig(local_user(), 'redbasic', 'font_size', $_POST['redbasic_font_size']);
|
||||||
set_pconfig(local_user(), 'redbasic', 'line_height', $_POST['redbasic_line_height']);
|
set_pconfig(local_user(), 'redbasic', 'line_height', $_POST['redbasic_line_height']);
|
||||||
@ -37,6 +37,7 @@ function theme_post(&$a) {
|
|||||||
set_pconfig(local_user(), 'redbasic', 'colour_scheme', $_POST['redbasic_colour_scheme']);
|
set_pconfig(local_user(), 'redbasic', 'colour_scheme', $_POST['redbasic_colour_scheme']);
|
||||||
set_pconfig(local_user(), 'redbasic', 'radius', $_POST['redbasic_radius']);
|
set_pconfig(local_user(), 'redbasic', 'radius', $_POST['redbasic_radius']);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// We probably don't want these if we're having global settings, but we'll comment out for now, just in case
|
// We probably don't want these if we're having global settings, but we'll comment out for now, just in case
|
||||||
|
@ -3,9 +3,11 @@
|
|||||||
// the get_config bits, though this is untested.
|
// the get_config bits, though this is untested.
|
||||||
// We also need to eventually. Use the page owners settings for everybody - get_pconfig(page_owner()) or whatever that would look like.
|
// We also need to eventually. Use the page owners settings for everybody - get_pconfig(page_owner()) or whatever that would look like.
|
||||||
|
|
||||||
$uid = get_controlling_channel_id();
|
|
||||||
|
|
||||||
load_pconfig($uid,'redbasic');
|
$uid = get_theme_uid();
|
||||||
|
|
||||||
|
if($uid)
|
||||||
|
load_pconfig($uid,'redbasic');
|
||||||
|
|
||||||
$line_height = false;
|
$line_height = false;
|
||||||
$redbasic_font_size = false;
|
$redbasic_font_size = false;
|
||||||
|
Reference in New Issue
Block a user