Lite theme updates. Incorporated more Danbooru custom themes to get

the aligning right.
This commit is contained in:
Zach Hall 2010-02-28 12:05:12 -08:00 committed by Shish
parent 556b3866a6
commit e9818e8b42
6 changed files with 251 additions and 56 deletions

View file

@ -0,0 +1,9 @@
<?php
class CustomPage extends Page {
var $left_enabled = true;
public function disable_left() {
$this->left_enabled = false;
}
}
?>

View file

@ -12,7 +12,7 @@ class Layout {
* turns the Page into HTML
*/
public function display_page(Page $page) {
global $config;
global $config, $user;
$theme_name = $config->get_string('theme', 'lite');
$site_name = $config->get_string('title');
@ -31,7 +31,11 @@ class Layout {
// Custom links: These appear on the menu.
$custom_links = "";
$custom_links .= $this->navlinks(make_link('user'), "Account", array("user", "setup", "admin", "profile"));
if($user->is_anonymous()) {
$custom_links .= $this->navlinks(make_link('user_admin/login'), "Account", array("user", "user_admin", "setup", "admin", "profile"));
} else {
$custom_links .= $this->navlinks(make_link('user'), "Account", array("user", "setup", "user_admin", "admin", "profile"));
}
$custom_links .= $this->navlinks(make_link('post/list'), "Posts", array("post", "view"));
$custom_links .= $this->navlinks(make_link('comment/list'), "Comments", array("comment"));
$custom_links .= $this->navlinks(make_link('tags'), "Tags", array("tags"));
@ -42,6 +46,31 @@ class Layout {
}
$menu .= "$custom_links</div>";
$left_block_html = "";
$main_block_html = "";
$sub_block_html = "";
$user_block_html = "";
foreach($page->blocks as $block) {
switch($block->section) {
case "left":
$left_block_html .= $this->block_to_html($block, true, "left");
break;
case "main":
$main_block_html .= $this->block_to_html($block, false, "main");
break;
case "user":
$user_block_html .= $block->body;
break;
case "subheading":
$sub_block_html .= $this->block_to_html($block, false, "main");
break;
default:
print "<p>error: {$block->header} using an unknown section ({$block->section})";
break;
}
}
$custom_sublinks = "<div class='sbar'>";
$cs = null;
// hack
@ -53,7 +82,7 @@ class Layout {
// php sucks
switch($qp[0]) {
default:
$cs = null;
$cs = $user_block_html;
break;
case "":
# FIXME: this assumes that the front page is
@ -105,29 +134,7 @@ class Layout {
}
if(is_null($cs)) {$custom_sublinks = "";} else {
$custom_sublinks .= "$cs</div>";}
$left_block_html = "";
$main_block_html = "";
$sub_block_html = "";
foreach($page->blocks as $block) {
switch($block->section) {
case "left":
$left_block_html .= $this->block_to_html($block, true, "left");
break;
case "main":
$main_block_html .= $this->block_to_html($block, false, "main");
break;
case "user":
$user_block_html .= $block->body;
break;
case "subheading":
$sub_block_html .= $this->block_to_html($block, false, "main");
break;
default:
print "<p>error: {$block->header} using an unknown section ({$block->section})";
break;
}
}
$debug = get_debug_info();
@ -138,6 +145,13 @@ class Layout {
if(strlen($page->heading) > 100) {
$wrapper = ' style="height: 3em; overflow: auto;"';
}
if($page->left_enabled==false) {
$left_block_html = "";
$main_block_html = "<div id='body_noleft'>$main_block_html</div>";
} else {
$left_block_html = "<div id='nav'>$left_block_html</div>";
$main_block_html = "<div id='body'>$main_block_html</div>";
}
print <<<EOD
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
@ -152,11 +166,12 @@ class Layout {
<body>
$menu
$custom_sublinks
$subheading
$sub_block_html
<div id="nav">$left_block_html</div>
<div id="body">$main_block_html</div>
$left_block_html
$main_block_html
<div id="footer">
Images &copy; their respective owners,

View file

@ -18,12 +18,12 @@ a.tab, a.tab:visited {
color:#000000;
text-decoration:none;
}
a.tab:hover, a.tab:active {
a.tab:hover, a.tab:active, .tab-selected {
color:#000000;
background-color:#FFFFFF;
background-color:#FFFFFE;
text-decoration:none;
}
.tab {
.tab, .tab-selected, .tframe, #tips {
-moz-border-radius:4px;
-webkit-border-radius:4px;
border:1px solid #C8D1DB;
@ -32,13 +32,8 @@ a.tab:hover, a.tab:active {
margin-right:2px;
padding:2px;
}
.tab-selected {
-moz-border-radius:4px;
-webkit-border-radius:4px;
padding:2px;
background:none repeat scroll 0 0 #FFFFFE;
border:1px solid #C8D1DB;
color:#333333;
.tframe {
margin:4px;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
@ -61,14 +56,14 @@ a.tab:hover, a.tab:active {
text-align: right;
}
.navside {
background:none repeat scroll 0 0 #CEDFF0;
text-align:left;
padding:4px;
font-size:85%;
border:1px solid #C3D2E0;
margin-bottom:5px;
-moz-border-radius:4px;
-webkit-border-radius:4px;
background:none repeat scroll 0 0 #CEDFF0;
text-align:left;
padding:4px;
font-size:85%;
border:1px solid #C3D2E0;
margin-bottom:5px;
-moz-border-radius:4px;
-webkit-border-radius:4px;
}
.highlighted {
background:none repeat scroll 0 0 #CEDFF0;
@ -79,22 +74,26 @@ margin-bottom:5px;
-webkit-border-radius:4px;
}
.navtop, .maintop {
font-size:110%;
border-bottom:0 none;
margin:0 0 0 0;
padding:2px 10px;
position:relative;
left:0px;
width:50%;
font-size:110%;
border-bottom:0 none;
margin:0 0 2px 0; /* top right bottom left */
padding:2px 10px;
position:relative;
left:0px;
width:50%;
}
.navtop {
top:5px;
top:7px;
}
.maintop {
top:0px;
margin-top:5px;
margin-bottom:5px;
}
#tips, #blotter1, #blotter2 {
margin-right:16px;
margin-left:16px;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
3 things common to all pages *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@ -113,7 +112,7 @@ THEAD {
}
TD {
vertical-align: top;
text-align: center;
text-align: left;
}
CODE {
background: #DEDEDE;
@ -266,6 +265,15 @@ UL {
text-align: left;
height: 1%;
}
#body_noleft {
margin-left: 4px;
margin-right: 16px;
margin-bottom:16px;
padding-left:4px;
padding-right:4px;
text-align: left;
height: 1%;
}
#body TABLE {
width: 90%;
margin: auto;

View file

@ -51,7 +51,7 @@ class Themelet {
*/
public function rr($html) {
return "
<div class='tab'>
<div class='tframe'>
$html
</div>
";

119
themes/lite/user.theme.php Normal file
View file

@ -0,0 +1,119 @@
<?php
class CustomUserPageTheme extends UserPageTheme {
public function display_login_page($page) {
global $config;
$page->set_title("Login");
$page->set_heading("Login");
$page->disable_left();
$html = "
<form action='".make_link("user_admin/login")."' method='POST'>
<table summary='Login Form'>
<tr>
<td width='70'><label for='user'>Name</label></td>
<td width='70'><input id='user' type='text' name='user'></td>
</tr>
<tr>
<td><label for='pass'>Password</label></td>
<td><input id='pass' type='password' name='pass'></td>
</tr>
<tr><td colspan='2'><input type='submit' value='Log In'></td></tr>
</table>
</form>
";
if($config->get_bool("login_signup_enabled")) {
$html .= "<small><a href='".make_link("user_admin/create")."'>Create Account</a></small>";
}
$page->add_block(new Block("Login", $html, "main", 90));
}
public function display_user_links($page, $user, $parts) {
// no block in this theme
}
public function display_login_block(Page $page) {
// no block in this theme
}
public function display_user_block($page, $user, $parts) {
$h_name = html_escape($user->name);
$html = "";
$blocked = array("Pools", "Pool Changes", "Alias Editor", "My Profile");
foreach($parts as $part) {
if(in_array($part["name"], $blocked)) continue;
$html .= "<a href='{$part["link"]}' class='tab'>{$part["name"]}</a>";
}
$page->add_block(new Block("User Links", $html, "user", 90));
}
public function display_signup_page($page) {
global $config;
$tac = $config->get_string("login_tac", "");
$tfe = new TextFormattingEvent($tac);
send_event($tfe);
$tac = $tfe->formatted;
if(empty($tac)) {$html = "";}
else {$html = "<p>$tac</p>";}
$html .= "
<form action='".make_link("user_admin/create")."' method='POST'>
<table style='width: 300px;'>
<tr><td>Name</td><td><input type='text' name='name'></td></tr>
<tr><td>Password</td><td><input type='password' name='pass1'></td></tr>
<tr><td>Repeat Password</td><td><input type='password' name='pass2'></td></tr>
<tr><td>Email (Optional)</td><td><input type='text' name='email'></td></tr>
<tr><td colspan='2'><input type='Submit' value='Create Account'></td></tr>
</table>
</form>
";
$page->set_title("Create Account");
$page->set_heading("Create Account");
$page->disable_left();
$page->add_block(new Block("Signup", $html));
}
public function display_ip_list($page, $uploads, $comments) {
$html = "<table id='ip-history' style='width: 400px;'>";
$html .= "<tr><td>Uploaded from: ";
foreach($uploads as $ip => $count) {
$html .= "<br>$ip ($count)";
}
$html .= "</td><td>Commented from:";
foreach($comments as $ip => $count) {
$html .= "<br>$ip ($count)";
}
$html .= "</td></tr>";
$html .= "<tr><td colspan='2'>(Most recent at top)</td></tr></table>";
$page->add_block(new Block("IPs", $html));
}
public function display_user_page(User $duser, $stats) {
global $page;
$page->disable_left();
parent::display_user_page($duser, $stats);
}
protected function build_options($duser) {
global $database;
global $config;
$html = "";
$html .= "
<form action='".make_link("user_admin/change_pass")."' method='POST'>
<input type='hidden' name='name' value='{$duser->name}'>
<input type='hidden' name='id' value='{$duser->id}'>
<table style='width: 300px;'>
<tr><td colspan='2'>Change Password</td></tr>
<tr><td>Password</td><td><input type='password' name='pass1'></td></tr>
<tr><td>Repeat Password</td><td><input type='password' name='pass2'></td></tr>
<tr><td colspan='2'><input type='Submit' value='Change Password'></td></tr>
</table>
</form>
";
return $html;
}
}
?>

View file

@ -0,0 +1,44 @@
<?php
class CustomViewImageTheme extends ViewImageTheme {
public function display_page($page, $image, $editor_parts) {
$page->set_title("Image {$image->id}: ".html_escape($image->get_tag_list()));
$page->set_heading(html_escape($image->get_tag_list()));
$page->add_block(new Block("Navigation", $this->build_navigation($image), "left", 0));
$page->add_block(new Block("Statistics", $this->build_stats($image), "left", 10));
$page->add_block(new Block(null, $this->build_image_editor($image, $editor_parts), "main", 10));
$page->add_block(new Block(null, $this->build_pin($image), "main", 11));
$page->add_block(new Block(null, "hello world", "subheading", 0));
}
private function build_stats($image) {
$h_owner = html_escape($image->get_owner()->name);
$h_ownerlink = "<a href='".make_link("user/$h_owner")."'>$h_owner</a>";
$h_ip = html_escape($image->owner_ip);
$h_date = autodate($image->posted);
$h_filesize = to_shorthand_int($image->filesize);
global $user;
if($user->is_admin()) {
$h_ownerlink .= " ($h_ip)";
}
$html = "
Id: {$image->id}
<br>Posted: $h_date by $h_ownerlink
<br>Size: {$image->width}x{$image->height}
<br>Filesize: $h_filesize
";
if(!is_null($image->source)) {
$h_source = html_escape($image->source);
if(substr($image->source, 0, 7) != "http://") {
$h_source = "http://" . $h_source;
}
$html .= "<br>Source: <a href='$h_source'>link</a>";
}
return $html;
}
}
?>