full theming support

This commit is contained in:
Mike Macgirvin 2010-08-16 05:23:26 -07:00
parent 4bcf380296
commit 30e3a65c0f
10 changed files with 58 additions and 18 deletions

View File

@ -131,7 +131,9 @@ class App {
function init_pagehead() { function init_pagehead() {
if(file_exists("view/head.tpl")) if(file_exists("view/head.tpl"))
$s = file_get_contents("view/head.tpl"); $s = file_get_contents("view/head.tpl");
$this->page['htmlhead'] = replace_macros($s,array('$baseurl' => $this->get_baseurl())); $this->page['htmlhead'] = replace_macros($s,array(
'$baseurl' => $this->get_baseurl()
));
} }
}} }}

View File

@ -328,6 +328,7 @@ CREATE TABLE IF NOT EXISTS `user` (
`nickname` char(255) NOT NULL, `nickname` char(255) NOT NULL,
`email` char(255) NOT NULL, `email` char(255) NOT NULL,
`timezone` char(128) NOT NULL, `timezone` char(128) NOT NULL,
`theme` char(255) NOT NULL,
`pubkey` text NOT NULL, `pubkey` text NOT NULL,
`prvkey` text NOT NULL, `prvkey` text NOT NULL,
`verified` tinyint(1) unsigned NOT NULL DEFAULT '0', `verified` tinyint(1) unsigned NOT NULL DEFAULT '0',

View File

@ -10,6 +10,7 @@ if((x($_SESSION,'authenticated')) && (! ($_POST['auth-params'] == 'login'))) {
unset($_SESSION['is_visitor']); unset($_SESSION['is_visitor']);
unset($_SESSION['administrator']); unset($_SESSION['administrator']);
unset($_SESSION['cid']); unset($_SESSION['cid']);
unset($_SESSION['theme']);
notice( t('Logged out.') . EOL); notice( t('Logged out.') . EOL);
goaway($a->get_baseurl()); goaway($a->get_baseurl());
} }
@ -20,6 +21,7 @@ if((x($_SESSION,'authenticated')) && (! ($_POST['auth-params'] == 'login'))) {
goaway($a->get_baseurl()); goaway($a->get_baseurl());
} }
$a->user = $r[0]; $a->user = $r[0];
$_SESSION['theme'] = $a->user['theme'];
if(strlen($a->user['timezone'])) if(strlen($a->user['timezone']))
date_default_timezone_set($a->user['timezone']); date_default_timezone_set($a->user['timezone']);
@ -54,7 +56,7 @@ else {
goaway($a->get_baseurl()); goaway($a->get_baseurl());
} }
$_SESSION['uid'] = $r[0]['uid']; $_SESSION['uid'] = $r[0]['uid'];
$_SESSION['admin'] = $r[0]['admin']; $_SESSION['theme'] = $r[0]['theme'];
$_SESSION['authenticated'] = 1; $_SESSION['authenticated'] = 1;
$_SESSION['my_url'] = $a->get_baseurl() . '/profile/' . $r[0]['nickname']; $_SESSION['my_url'] = $a->get_baseurl() . '/profile/' . $r[0]['nickname'];

View File

@ -26,6 +26,7 @@ $a->init_pagehead();
session_start(); session_start();
if((x($_SESSION,'authenticated')) || (x($_POST['auth-params']))) if((x($_SESSION,'authenticated')) || (x($_POST['auth-params'])))
require("auth.php"); require("auth.php");
@ -106,12 +107,18 @@ $a->page['content'] .= $debug_text;
if($a->module != 'install') if($a->module != 'install')
require_once("nav.php"); require_once("nav.php");
$a->page['htmlhead'] = replace_macros($a->page['htmlhead'], array(
'$stylesheet' => $a->get_baseurl() . '/view/theme/'
. ((x($_SESSION,'theme')) ? $_SESSION['theme'] : 'default')
. '/style.css'
));
$page = $a->page; $page = $a->page;
$profile = $a->profile; $profile = $a->profile;
header("Content-type: text/html; charset=utf-8"); header("Content-type: text/html; charset=utf-8");
$template = "view/" $template = "view/"
. ((x($a->page,'theme')) ? $a->page['theme'] . '/' : "" )
. ((x($a->page,'template')) ? $a->page['template'] : 'default' ) . ((x($a->page,'template')) ? $a->page['template'] : 'default' )
. ".php"; . ".php";

View File

@ -34,6 +34,7 @@ function profile_load(&$a, $username, $profile = 0) {
$a->page['template'] = 'profile'; $a->page['template'] = 'profile';
$a->page['title'] = $a->profile['name']; $a->page['title'] = $a->profile['name'];
$_SESSION['theme'] = $a->profile['theme'];
return; return;
}} }}

View File

@ -52,6 +52,7 @@ function settings_post(&$a) {
} }
} }
$theme = notags(trim($_POST['theme']));
$username = notags(trim($_POST['username'])); $username = notags(trim($_POST['username']));
$email = notags(trim($_POST['email'])); $email = notags(trim($_POST['email']));
$timezone = notags(trim($_POST['timezone'])); $timezone = notags(trim($_POST['timezone']));
@ -131,9 +132,7 @@ function settings_post(&$a) {
$str_contact_deny = implode('',$contact_deny); $str_contact_deny = implode('',$contact_deny);
} }
$r = q("UPDATE `user` SET `username` = '%s', `email` = '%s', `timezone` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `notify-flags` = %d, `theme` = '%s' WHERE `uid` = %d LIMIT 1",
$r = q("UPDATE `user` SET `username` = '%s', `email` = '%s', `timezone` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `notify-flags` = %d WHERE `uid` = %d LIMIT 1",
dbesc($username), dbesc($username),
dbesc($email), dbesc($email),
dbesc($timezone), dbesc($timezone),
@ -142,24 +141,19 @@ function settings_post(&$a) {
dbesc($str_contact_deny), dbesc($str_contact_deny),
dbesc($str_group_deny), dbesc($str_group_deny),
intval($notify), intval($notify),
dbesc($theme),
intval($_SESSION['uid']) intval($_SESSION['uid'])
); );
if($r) if($r)
notice( t('Settings updated.') . EOL); notice( t('Settings updated.') . EOL);
$_SESSION['theme'] = $theme;
if($email_changed && $a->config['register_policy'] == REGISTER_VERIFY) { if($email_changed && $a->config['register_policy'] == REGISTER_VERIFY) {
// FIXME - set to un-verified, blocked and redirect to logout // FIXME - set to un-verified, blocked and redirect to logout
} }
goaway($a->get_baseurl() . '/settings' );
// Refresh the content display with new data
$r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
intval($_SESSION['uid']));
if(count($r))
$a->user = $r[0];
} }
@ -179,6 +173,8 @@ function settings_content(&$a) {
$timezone = $a->user['timezone']; $timezone = $a->user['timezone'];
$notify = $a->user['notify-flags']; $notify = $a->user['notify-flags'];
if(! strlen($a->user['timezone']))
$timezone = date_default_timezone_get();
$nickname_block = file_get_contents("view/settings_nick_set.tpl"); $nickname_block = file_get_contents("view/settings_nick_set.tpl");
@ -193,6 +189,18 @@ function settings_content(&$a) {
)); ));
} }
$theme_selector = '<select name="theme" id="theme-select" >';
$files = glob('view/theme/*');
if($files) {
foreach($files as $file) {
$f = basename($file);
$selected = (($f == $_SESSION['theme']) || ($f == 'default' && (! x($_SESSION,'theme')))
? ' selected="selected" ' : '' );
$theme_selector .= '<option val="' . basename($file) . '"' . $selected . '>' . basename($file) . '</option>';
}
}
$theme_selector .= '</select>';
$nickname_block = replace_macros($nickname_block,array( $nickname_block = replace_macros($nickname_block,array(
'$nickname' => $nickname, '$nickname' => $nickname,
@ -217,7 +225,8 @@ function settings_content(&$a) {
'$sel_notify2' => (($notify & NOTIFY_CONFIRM) ? ' checked="checked" ' : ''), '$sel_notify2' => (($notify & NOTIFY_CONFIRM) ? ' checked="checked" ' : ''),
'$sel_notify3' => (($notify & NOTIFY_WALL) ? ' checked="checked" ' : ''), '$sel_notify3' => (($notify & NOTIFY_WALL) ? ' checked="checked" ' : ''),
'$sel_notify4' => (($notify & NOTIFY_COMMENT) ? ' checked="checked" ' : ''), '$sel_notify4' => (($notify & NOTIFY_COMMENT) ? ' checked="checked" ' : ''),
'$sel_notify5' => (($notify & NOTIFY_MAIL) ? ' checked="checked" ' : '') '$sel_notify5' => (($notify & NOTIFY_MAIL) ? ' checked="checked" ' : ''),
'$theme' => $theme_selector
)); ));
return $o; return $o;

View File

@ -128,4 +128,5 @@ function populate_acl($user = null) {
$o .= '<div id="acl-wrapper-end"></div>' . "\r\n"; $o .= '<div id="acl-wrapper-end"></div>' . "\r\n";
return $o; return $o;
} }

View File

@ -1,6 +1,6 @@
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<base href="$baseurl" /> <base href="$baseurl" />
<link rel="stylesheet" type="text/css" href="$baseurl/view/style.css" media="all" /> <link rel="stylesheet" type="text/css" href="$stylesheet" media="all" />
<!--[if IE]> <!--[if IE]>
<script type="text/javascript" src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <script type="text/javascript" src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>

View File

@ -25,6 +25,12 @@ $zoneselect
</div> </div>
<div id="settings-timezone-end" ></div> <div id="settings-timezone-end" ></div>
<div id="settings-theme-select">
<label id="settings-theme-label" for="theme-select" >Display Theme: </label>
$theme
</div>
<div id="settings-theme-end"></div>
<div id="settings-default-perms" class="settings-default-perms" > <div id="settings-default-perms" class="settings-default-perms" >
<div id="settings-default-perms-menu" onClick="openClose('settings-default-perms-select');" />$permissions</div> <div id="settings-default-perms-menu" onClick="openClose('settings-default-perms-select');" />$permissions</div>
<div id="settings-default-perms-menu-end"></div> <div id="settings-default-perms-menu-end"></div>

View File

@ -301,7 +301,8 @@ input#dfrn-url {
#settings-username-end, #settings-username-end,
#settings-email-end, #settings-email-end,
#settings-nick-end, #settings-nick-end,
#settings-timezone-end, #settings-timezone-end,
#settings-theme-end,
#settings-password-end, #settings-password-end,
#settings-confirm-end, #settings-confirm-end,
#notify1-end, #notify1-end,
@ -317,6 +318,7 @@ input#dfrn-url {
#settings-email-label, #settings-email-label,
#settings-nick-label, #settings-nick-label,
#settings-timezone-label, #settings-timezone-label,
#settings-theme-label,
#settings-password-label, #settings-password-label,
#settings-confirm-label, #settings-confirm-label,
#settings-label-notify1, #settings-label-notify1,
@ -332,6 +334,7 @@ input#dfrn-url {
#settings-email, #settings-email,
#settings-nick, #settings-nick,
#timezone-select, #timezone-select,
#theme-select,
#settings-password, #settings-password,
#settings-confirm, #settings-confirm,
#notify1, #notify1,
@ -343,6 +346,14 @@ input#dfrn-url {
margin-bottom: 20px; margin-bottom: 20px;
} }
#settings-theme-label {
margin-top: 20px;
}
#theme-select {
margin-top: 20px;
width: 207px;
}
#settings-notify-desc { #settings-notify-desc {
margin-top: 20px; margin-top: 20px;
margin-bottom: 20px; margin-bottom: 20px;