Browse Source

full theming support

pull/1/head
Mike Macgirvin 11 years ago
parent
commit
30e3a65c0f
10 changed files with 58 additions and 18 deletions
  1. +3
    -1
      boot.php
  2. +1
    -0
      database.sql
  3. +3
    -1
      include/auth.php
  4. +8
    -1
      index.php
  5. +1
    -0
      mod/profile.php
  6. +21
    -12
      mod/settings.php
  7. +2
    -1
      view/acl_selectors.php
  8. +1
    -1
      view/head.tpl
  9. +6
    -0
      view/settings.tpl
  10. +12
    -1
      view/theme/default/style.css

+ 3
- 1
boot.php View File

@ -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()
));
}
}}


+ 1
- 0
database.sql View File

@ -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',


+ 3
- 1
include/auth.php View File

@ -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'];


+ 8
- 1
index.php View File

@ -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";


+ 1
- 0
mod/profile.php View File

@ -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;
}}


+ 21
- 12
mod/settings.php View File

@ -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;


+ 2
- 1
view/acl_selectors.php View File

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

+ 1
- 1
view/head.tpl View File

@ -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>


+ 6
- 0
view/settings.tpl View File

@ -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>


view/style.css → view/theme/default/style.css View File


Loading…
Cancel
Save