full theming support
This commit is contained in:
parent
4bcf380296
commit
30e3a65c0f
4
boot.php
4
boot.php
|
@ -131,7 +131,9 @@ class App {
|
|||
function init_pagehead() {
|
||||
if(file_exists("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()
|
||||
));
|
||||
}
|
||||
|
||||
}}
|
||||
|
|
|
@ -328,6 +328,7 @@ CREATE TABLE IF NOT EXISTS `user` (
|
|||
`nickname` char(255) NOT NULL,
|
||||
`email` char(255) NOT NULL,
|
||||
`timezone` char(128) NOT NULL,
|
||||
`theme` char(255) NOT NULL,
|
||||
`pubkey` text NOT NULL,
|
||||
`prvkey` text NOT NULL,
|
||||
`verified` tinyint(1) unsigned NOT NULL DEFAULT '0',
|
||||
|
|
|
@ -10,6 +10,7 @@ if((x($_SESSION,'authenticated')) && (! ($_POST['auth-params'] == 'login'))) {
|
|||
unset($_SESSION['is_visitor']);
|
||||
unset($_SESSION['administrator']);
|
||||
unset($_SESSION['cid']);
|
||||
unset($_SESSION['theme']);
|
||||
notice( t('Logged out.') . EOL);
|
||||
goaway($a->get_baseurl());
|
||||
}
|
||||
|
@ -20,6 +21,7 @@ if((x($_SESSION,'authenticated')) && (! ($_POST['auth-params'] == 'login'))) {
|
|||
goaway($a->get_baseurl());
|
||||
}
|
||||
$a->user = $r[0];
|
||||
$_SESSION['theme'] = $a->user['theme'];
|
||||
if(strlen($a->user['timezone']))
|
||||
date_default_timezone_set($a->user['timezone']);
|
||||
|
||||
|
@ -54,7 +56,7 @@ else {
|
|||
goaway($a->get_baseurl());
|
||||
}
|
||||
$_SESSION['uid'] = $r[0]['uid'];
|
||||
$_SESSION['admin'] = $r[0]['admin'];
|
||||
$_SESSION['theme'] = $r[0]['theme'];
|
||||
$_SESSION['authenticated'] = 1;
|
||||
$_SESSION['my_url'] = $a->get_baseurl() . '/profile/' . $r[0]['nickname'];
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ $a->init_pagehead();
|
|||
|
||||
session_start();
|
||||
|
||||
|
||||
if((x($_SESSION,'authenticated')) || (x($_POST['auth-params'])))
|
||||
require("auth.php");
|
||||
|
||||
|
@ -106,12 +107,18 @@ $a->page['content'] .= $debug_text;
|
|||
if($a->module != 'install')
|
||||
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;
|
||||
$profile = $a->profile;
|
||||
|
||||
header("Content-type: text/html; charset=utf-8");
|
||||
|
||||
$template = "view/"
|
||||
. ((x($a->page,'theme')) ? $a->page['theme'] . '/' : "" )
|
||||
. ((x($a->page,'template')) ? $a->page['template'] : 'default' )
|
||||
. ".php";
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ function profile_load(&$a, $username, $profile = 0) {
|
|||
$a->page['template'] = 'profile';
|
||||
|
||||
$a->page['title'] = $a->profile['name'];
|
||||
$_SESSION['theme'] = $a->profile['theme'];
|
||||
|
||||
return;
|
||||
}}
|
||||
|
|
|
@ -52,6 +52,7 @@ function settings_post(&$a) {
|
|||
}
|
||||
}
|
||||
|
||||
$theme = notags(trim($_POST['theme']));
|
||||
$username = notags(trim($_POST['username']));
|
||||
$email = notags(trim($_POST['email']));
|
||||
$timezone = notags(trim($_POST['timezone']));
|
||||
|
@ -131,9 +132,7 @@ function settings_post(&$a) {
|
|||
$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 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, `theme` = '%s' WHERE `uid` = %d LIMIT 1",
|
||||
dbesc($username),
|
||||
dbesc($email),
|
||||
dbesc($timezone),
|
||||
|
@ -142,24 +141,19 @@ function settings_post(&$a) {
|
|||
dbesc($str_contact_deny),
|
||||
dbesc($str_group_deny),
|
||||
intval($notify),
|
||||
dbesc($theme),
|
||||
intval($_SESSION['uid'])
|
||||
);
|
||||
if($r)
|
||||
notice( t('Settings updated.') . EOL);
|
||||
|
||||
$_SESSION['theme'] = $theme;
|
||||
if($email_changed && $a->config['register_policy'] == REGISTER_VERIFY) {
|
||||
|
||||
// FIXME - set to un-verified, blocked and redirect to logout
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 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];
|
||||
goaway($a->get_baseurl() . '/settings' );
|
||||
}
|
||||
|
||||
|
||||
|
@ -179,6 +173,8 @@ function settings_content(&$a) {
|
|||
$timezone = $a->user['timezone'];
|
||||
$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");
|
||||
|
||||
|
@ -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' => $nickname,
|
||||
|
@ -217,7 +225,8 @@ function settings_content(&$a) {
|
|||
'$sel_notify2' => (($notify & NOTIFY_CONFIRM) ? ' checked="checked" ' : ''),
|
||||
'$sel_notify3' => (($notify & NOTIFY_WALL) ? ' 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;
|
||||
|
|
|
@ -129,3 +129,4 @@ function populate_acl($user = null) {
|
|||
return $o;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||
<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]>
|
||||
<script type="text/javascript" src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
|
|
|
@ -25,6 +25,12 @@ $zoneselect
|
|||
</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-menu" onClick="openClose('settings-default-perms-select');" />$permissions</div>
|
||||
<div id="settings-default-perms-menu-end"></div>
|
||||
|
|
|
@ -302,6 +302,7 @@ input#dfrn-url {
|
|||
#settings-email-end,
|
||||
#settings-nick-end,
|
||||
#settings-timezone-end,
|
||||
#settings-theme-end,
|
||||
#settings-password-end,
|
||||
#settings-confirm-end,
|
||||
#notify1-end,
|
||||
|
@ -317,6 +318,7 @@ input#dfrn-url {
|
|||
#settings-email-label,
|
||||
#settings-nick-label,
|
||||
#settings-timezone-label,
|
||||
#settings-theme-label,
|
||||
#settings-password-label,
|
||||
#settings-confirm-label,
|
||||
#settings-label-notify1,
|
||||
|
@ -332,6 +334,7 @@ input#dfrn-url {
|
|||
#settings-email,
|
||||
#settings-nick,
|
||||
#timezone-select,
|
||||
#theme-select,
|
||||
#settings-password,
|
||||
#settings-confirm,
|
||||
#notify1,
|
||||
|
@ -343,6 +346,14 @@ input#dfrn-url {
|
|||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
#settings-theme-label {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
#theme-select {
|
||||
margin-top: 20px;
|
||||
width: 207px;
|
||||
}
|
||||
#settings-notify-desc {
|
||||
margin-top: 20px;
|
||||
margin-bottom: 20px;
|
Loading…
Reference in a new issue