Merge pull request #1715 from rabuzarus/theme_uid

use local theme settings for visitors
This commit is contained in:
fabrixxm 2015-06-30 08:41:07 +02:00
commit 5a23bd400c
8 changed files with 161 additions and 80 deletions

View file

@ -358,6 +358,7 @@ if(! class_exists('App')) {
public $config; public $config;
public $page; public $page;
public $profile; public $profile;
public $profile_uid;
public $user; public $user;
public $cid; public $cid;
public $contact; public $contact;
@ -1446,10 +1447,33 @@ if(! function_exists('current_theme')) {
$a = get_app(); $a = get_app();
$page_theme = null;
// Find the theme that belongs to the user whose stuff we are looking at
if($a->profile_uid && ($a->profile_uid != local_user())) {
$r = q("select theme from user where uid = %d limit 1",
intval($a->profile_uid)
);
if($r)
$page_theme = $r[0]['theme'];
}
// Allow folks to over-rule user themes and always use their own on their own site.
// This works only if the user is on the same server
if($page_theme && local_user() && (local_user() != $a->profile_uid)) {
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();
$is_mobile = $a->is_mobile || $a->is_tablet; $is_mobile = $a->is_mobile || $a->is_tablet;
$standard_system_theme = ((isset($a->config['system']['theme'])) ? $a->config['system']['theme'] : '');
$standard_theme_name = ((isset($_SESSION) && x($_SESSION,'theme')) ? $_SESSION['theme'] : $standard_system_theme);
if($is_mobile) { if($is_mobile) {
if(isset($_SESSION['show-mobile']) && !$_SESSION['show-mobile']) { if(isset($_SESSION['show-mobile']) && !$_SESSION['show-mobile']) {
$system_theme = ''; $system_theme = '';
@ -1466,9 +1490,12 @@ if(! function_exists('current_theme')) {
} }
} }
} }
if(!$is_mobile || ($system_theme === '' && $theme_name === '')) { else {
$system_theme = ((isset($a->config['system']['theme'])) ? $a->config['system']['theme'] : ''); $system_theme = $standard_system_theme;
$theme_name = ((isset($_SESSION) && x($_SESSION,'theme')) ? $_SESSION['theme'] : $system_theme); $theme_name = $standard_theme_name;
if($page_theme)
$theme_name = $page_theme;
} }
if($theme_name && if($theme_name &&
@ -1496,9 +1523,13 @@ if(! function_exists('current_theme')) {
if(! function_exists('current_theme_url')) { if(! function_exists('current_theme_url')) {
function current_theme_url() { function current_theme_url() {
global $a; global $a;
$t = current_theme(); $t = current_theme();
$opts = (($a->profile_uid) ? '?f=&puid=' . $a->profile_uid : '');
if (file_exists('view/theme/' . $t . '/style.php')) if (file_exists('view/theme/' . $t . '/style.php'))
return($a->get_baseurl() . '/view/theme/' . $t . '/style.pcss'); return($a->get_baseurl() . '/view/theme/' . $t . '/style.pcss' . $opts);
return($a->get_baseurl() . '/view/theme/' . $t . '/style.css'); return($a->get_baseurl() . '/view/theme/' . $t . '/style.css');
} }
} }

View file

@ -90,14 +90,15 @@ if(! function_exists('profile_load')) {
} }
$a->profile = $r[0]; $a->profile = $r[0];
$a->profile_uid = $r[0]['profile_uid'];
$a->profile['mobile-theme'] = get_pconfig($a->profile['profile_uid'], 'system', 'mobile_theme'); $a->profile['mobile-theme'] = get_pconfig($a->profile['profile_uid'], 'system', 'mobile_theme');
$a->profile['network'] = NETWORK_DFRN; $a->profile['network'] = NETWORK_DFRN;
$a->page['title'] = $a->profile['name'] . " @ " . $a->config['sitename']; $a->page['title'] = $a->profile['name'] . " @ " . $a->config['sitename'];
if (!$profiledata) // if (!$profiledata)
$_SESSION['theme'] = $a->profile['theme']; // $_SESSION['theme'] = $a->profile['theme'];
$_SESSION['mobile-theme'] = $a->profile['mobile-theme']; $_SESSION['mobile-theme'] = $a->profile['mobile-theme'];
@ -726,3 +727,19 @@ function zrl($s,$force = false) {
return $s . $achar . 'zrl=' . urlencode($mine); return $s . $achar . 'zrl=' . urlencode($mine);
return $s; return $s;
} }
// Used from within PCSS themes to set theme parameters. If there's a
// 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();
}
return $uid;
}

View file

@ -29,6 +29,7 @@ function photos_init(&$a) {
return; return;
$a->data['user'] = $r[0]; $a->data['user'] = $r[0];
$a->profile_uid = $r[0]['uid'];
$profilephoto = $a->get_cached_avatar_image($a->get_baseurl() . '/photo/profile/' . $a->data['user']['uid'] . '.jpg'); $profilephoto = $a->get_cached_avatar_image($a->get_baseurl() . '/photo/profile/' . $a->data['user']['uid'] . '.jpg');

View file

@ -27,6 +27,7 @@ function videos_init(&$a) {
return; return;
$a->data['user'] = $r[0]; $a->data['user'] = $r[0];
$a->profile_uid = $r[0]['uid'];
$profilephoto = $a->get_cached_avatar_image($a->get_baseurl() . '/photo/profile/' . $a->data['user']['uid'] . '.jpg'); $profilephoto = $a->get_cached_avatar_image($a->get_baseurl() . '/photo/profile/' . $a->data['user']['uid'] . '.jpg');

View file

@ -2,10 +2,28 @@
if (file_exists("$THEMEPATH/style.css")){ if (file_exists("$THEMEPATH/style.css")){
echo file_get_contents("$THEMEPATH/style.css"); echo file_get_contents("$THEMEPATH/style.css");
} }
$uid = get_theme_uid();
$s_colorset = get_config('duepuntozero','colorset'); $s_colorset = get_config('duepuntozero','colorset');
$uid = local_user();
$colorset = get_pconfig( $uid, 'duepuntozero', 'colorset'); $colorset = get_pconfig( $uid, 'duepuntozero', 'colorset');
if (!x($colorset)) if (!x($colorset))
$colorset = $s_colorset; $colorset = $s_colorset;
if ($colorset) {
if ($colorset == 'greenzero')
$setcss = file_get_contents('view/theme/duepuntozero/deriv/greenzero.css');
if ($colorset == 'purplezero')
$setcss = file_get_contents('view/theme/duepuntozero/deriv/purplezero.css');
if ($colorset == 'easterbunny')
$setcss = file_get_contents('view/theme/duepuntozero/deriv/easterbunny.css');
if ($colorset == 'darkzero')
$setcss = file_get_contents('view/theme/duepuntozero/deriv/darkzero.css');
if ($colorset == 'comix')
$setcss = file_get_contents('view/theme/duepuntozero/deriv/comix.css');
if ($colorset == 'slackr')
$setcss = file_get_contents('view/theme/duepuntozero/deriv/slackr.css');
}
echo $setcss;
?> ?>

View file

@ -1,12 +1,14 @@
<?php <?php
$uid = get_theme_uid();
$color=false; $color=false;
$quattro_align=false; $quattro_align=false;
$site_color = get_config("quattro","color"); $site_color = get_config("quattro","color");
$site_quattro_align = get_config("quattro", "align" ); $site_quattro_align = get_config("quattro", "align" );
if (local_user()) { if ($uid) {
$color = get_pconfig(local_user(), "quattro","color"); $color = get_pconfig( $uid, "quattro","color");
$quattro_align = get_pconfig(local_user(), 'quattro', 'align' ); $quattro_align = get_pconfig( $uid, 'quattro', 'align' );
} }
if ($color===false) $color=$site_color; if ($color===false) $color=$site_color;
@ -39,9 +41,9 @@
if ($site_textarea_font_size===false) $site_textarea_font_size="20"; if ($site_textarea_font_size===false) $site_textarea_font_size="20";
if ($site_post_font_size===false) $site_post_font_size="12"; if ($site_post_font_size===false) $site_post_font_size="12";
if (local_user()) { if ($uid) {
$textarea_font_size = get_pconfig(local_user(), "quattro","tfs"); $textarea_font_size = get_pconfig( $uid, "quattro","tfs");
$post_font_size = get_pconfig(local_user(), "quattro","pfs"); $post_font_size = get_pconfig( $uid, "quattro","pfs");
} }
if ($textarea_font_size===false) $textarea_font_size = $site_textarea_font_size; if ($textarea_font_size===false) $textarea_font_size = $site_textarea_font_size;

30
view/theme/vier/style.php Normal file
View file

@ -0,0 +1,30 @@
<?php
if (file_exists("$THEMEPATH//style.css")){
echo file_get_contents("$THEMEPATH//style.css");
}
$uid = get_theme_uid();
$style = get_pconfig( $uid, 'vier', 'style');
if ($style == "")
$style = get_config('vier', 'style');
if ($style == "")
$style = "plus";
if ($style == "flat")
$stylecss = file_get_contents('view/theme/vier/flat.css');
else if ($style == "netcolour")
$stylecss = file_get_contents('view/theme/vier/netcolour.css');
else if ($style == "breathe")
$stylecss = file_get_contents('view/theme/vier/breathe.css');
else if ($style == "plus")
$stylecss = file_get_contents('view/theme/vier/plus.css');
else if ($style == "dark")
$stylecss = file_get_contents('view/theme/vier/dark.css');
echo $stylecss;

View file

@ -16,25 +16,6 @@ $baseurl = $a->get_baseurl();
$a->theme_info = array(); $a->theme_info = array();
$style = get_pconfig(local_user(), 'vier', 'style');
if ($style == "")
$style = get_config('vier', 'style');
if ($style == "")
$style = "plus";
if ($style == "flat")
$a->page['htmlhead'] .= '<link rel="stylesheet" href="view/theme/vier/flat.css" type="text/css" media="screen"/>'."\n";
else if ($style == "netcolour")
$a->page['htmlhead'] .= '<link rel="stylesheet" href="view/theme/vier/netcolour.css" type="text/css" media="screen"/>'."\n";
else if ($style == "breathe")
$a->page['htmlhead'] .= '<link rel="stylesheet" href="view/theme/vier/breathe.css" type="text/css" media="screen"/>'."\n";
else if ($style == "plus")
$a->page['htmlhead'] .= '<link rel="stylesheet" href="view/theme/vier/plus.css" type="text/css" media="screen"/>'."\n";
else if ($style == "dark")
$a->page['htmlhead'] .= '<link rel="stylesheet" href="view/theme/vier/dark.css" type="text/css" media="screen"/>'."\n";
$a->page['htmlhead'] .= <<< EOT $a->page['htmlhead'] .= <<< EOT
<script type="text/javascript"> <script type="text/javascript">