danbooru theme work
git-svn-id: file:///home/shish/svn/shimmie2/trunk@348 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
parent
e4e4e5a04c
commit
18cd6fbd99
@ -26,6 +26,7 @@ class Comment { // {{{
|
||||
$this->comment_id = $row['comment_id'];
|
||||
$this->image_id = $row['image_id'];
|
||||
$this->poster_ip = $row['poster_ip'];
|
||||
$this->posted = $row['posted'];
|
||||
}
|
||||
} // }}}
|
||||
|
||||
@ -170,7 +171,8 @@ class CommentList extends Extension {
|
||||
SELECT
|
||||
users.id as user_id, users.name as user_name,
|
||||
comments.comment as comment, comments.id as comment_id,
|
||||
comments.image_id as image_id, comments.owner_ip as poster_ip
|
||||
comments.image_id as image_id, comments.owner_ip as poster_ip,
|
||||
comments.posted as posted
|
||||
FROM comments
|
||||
LEFT JOIN users ON comments.owner_id=users.id
|
||||
ORDER BY comments.id DESC
|
||||
@ -191,7 +193,8 @@ class CommentList extends Extension {
|
||||
SELECT
|
||||
users.id as user_id, users.name as user_name,
|
||||
comments.comment as comment, comments.id as comment_id,
|
||||
comments.image_id as image_id, comments.owner_ip as poster_ip
|
||||
comments.image_id as image_id, comments.owner_ip as poster_ip,
|
||||
comments.posted as posted
|
||||
FROM comments
|
||||
LEFT JOIN users ON comments.owner_id=users.id
|
||||
WHERE comments.image_id=?
|
||||
|
109
themes/danbooru/comment.theme.php
Normal file
109
themes/danbooru/comment.theme.php
Normal file
@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
class CommentListTheme extends Themelet {
|
||||
public function display_page_start($page, $page_number, $total_pages) {
|
||||
$prev = $page_number - 1;
|
||||
$next = $page_number + 1;
|
||||
|
||||
$h_prev = ($page_number <= 1) ? "Prev" :
|
||||
"<a href='".make_link("comment/list/$prev")."'>Prev</a>";
|
||||
$h_index = "<a href='".make_link("index")."'>Index</a>";
|
||||
$h_next = ($page_number >= $total_pages) ? "Next" :
|
||||
"<a href='".make_link("comment/list/$next")."'>Next</a>";
|
||||
|
||||
$nav = "$h_prev | $h_index | $h_next";
|
||||
|
||||
$page->set_title("Comments");
|
||||
$page->set_heading("Comments");
|
||||
$page->add_block(new Block("Navigation", $nav, "left"));
|
||||
$page->add_block(new Paginator("comment/list", null, $page_number, $total_pages), 90);
|
||||
$page->disable_left();
|
||||
}
|
||||
|
||||
public function display_recent_comments($page, $comments) {
|
||||
// no recent comments in this theme
|
||||
//$html = $this->comments_to_html($comments, true);
|
||||
//$html .= "<p><a class='more' href='".make_link("comment/list")."'>Full List</a>";
|
||||
//$page->add_block(new Block("Comments", $html, "left"));
|
||||
}
|
||||
|
||||
public function display_comments($page, $comments, $postbox, $image_id) {
|
||||
$count = count($comments);
|
||||
if($postbox) {
|
||||
$page->add_block(new Block("$count Comments",
|
||||
$this->comments_to_html($comments).
|
||||
$this->build_postbox($image_id), "main", 30));
|
||||
}
|
||||
else {
|
||||
$page->add_block(new Block("$count Comments",
|
||||
$this->comments_to_html($comments), "main", 30));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function comments_to_html($comments, $trim=false) {
|
||||
$html = "";
|
||||
foreach($comments as $comment) {
|
||||
$html .= $this->comment_to_html($comment, $trim);
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
private function comment_to_html($comment, $trim=false) {
|
||||
global $user;
|
||||
|
||||
$tfe = new TextFormattingEvent($comment->comment);
|
||||
send_event($tfe);
|
||||
|
||||
$i_uid = int_escape($comment->owner_id);
|
||||
$h_name = html_escape($comment->owner_name);
|
||||
$h_poster_ip = html_escape($comment->poster_ip);
|
||||
$h_comment = ($trim ? substr($tfe->stripped, 0, 50)."..." : $tfe->formatted);
|
||||
$i_comment_id = int_escape($comment->comment_id);
|
||||
$i_image_id = int_escape($comment->image_id);
|
||||
$h_posted = html_escape($comment->posted);
|
||||
|
||||
$h_userlink = "<a class='username' href='".make_link("user/$h_name")."'>$h_name</a>";
|
||||
$h_dellink = $user->is_admin() ?
|
||||
" ($h_poster_ip, <a ".
|
||||
"onclick=\"return confirm('Delete comment by $h_name:\\n".$tfe->stripped."');\" ".
|
||||
"href='".make_link("comment/delete/$i_comment_id/$i_image_id")."'>Del</a>)" : "";
|
||||
$h_imagelink = $trim ? "<a href='".make_link("post/view/$i_image_id")."'>>>></a>\n" : "";
|
||||
return "<p class='comment'>$h_userlink $h_dellink<br/><b>Posted on $h_posted</b><br/>$h_comment</p>";
|
||||
}
|
||||
|
||||
// FIXME: privatise this
|
||||
public function build_postbox($image_id) {
|
||||
$i_image_id = int_escape($image_id);
|
||||
return "
|
||||
<form action='".make_link("comment/add")."' method='POST'>
|
||||
<input type='hidden' name='image_id' value='$i_image_id' />
|
||||
<textarea name='comment' rows='5' cols='50'></textarea>
|
||||
<br><input type='submit' value='Post' />
|
||||
</form>
|
||||
";
|
||||
}
|
||||
|
||||
|
||||
public function add_comment_list($page, $image, $comments, $position, $with_postbox) {
|
||||
$count = count($comments);
|
||||
|
||||
$html = "<div style='text-align: left'>";
|
||||
$html .= "<div style='float: left; margin-right: 16px;'>" . build_thumb_html($image) . "</div>";
|
||||
$html .= "<div style='float: right; margin-left: 16px; width: 200px; margin-bottom: 32px;'>";
|
||||
foreach($image->get_tag_array() as $tag) {
|
||||
$u_tag = url_escape($tag);
|
||||
$html .= "<br><a href='".make_link("post/list/$u_tag/1")."'>".html_escape($tag)."</a>";
|
||||
}
|
||||
$html .= "</div>";
|
||||
$html .= "<div style='margin-left: 250px;'>";
|
||||
$html .= "<b>$count Comments</b><br>";
|
||||
$html .= $this->comments_to_html($comments);
|
||||
$html .= "</div>";
|
||||
$html .= "</div>";
|
||||
$html .= "<div style='clear: both; display: block; height: 64px;'> </div>";
|
||||
|
||||
$page->add_block(new Block(null, $html, "main", $position));
|
||||
}
|
||||
}
|
||||
?>
|
@ -110,6 +110,15 @@ class Layout {
|
||||
// bzchan: prepare main title link
|
||||
$title_link = "<h1><a href='".make_link($front_page)."'>$site_name</a></h1>";
|
||||
|
||||
if($page->left_enabled) {
|
||||
$left = "<div id='nav'>$left_block_html</div>";
|
||||
$withleft = "withleft";
|
||||
}
|
||||
else {
|
||||
$left = "";
|
||||
$withleft = "";
|
||||
}
|
||||
|
||||
print <<<EOD
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
||||
<html>
|
||||
@ -130,8 +139,8 @@ $header_html
|
||||
</div>
|
||||
$subheading
|
||||
|
||||
<div id="nav">$left_block_html</div>
|
||||
<div id="body">$main_block_html</div>
|
||||
$left
|
||||
<div id="body" class="$withleft">$main_block_html</div>
|
||||
|
||||
<div id="footer">
|
||||
<hr>
|
||||
|
@ -1,6 +1,9 @@
|
||||
<?php
|
||||
|
||||
class Page extends GenericPage {
|
||||
// no changes from default
|
||||
var $left_enabled = true;
|
||||
public function disable_left() {
|
||||
$this->left_enabled = false;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -8,14 +8,9 @@ BODY {
|
||||
background-color:#FFFFFF;
|
||||
font: 80% verdana, sans-serif;
|
||||
padding: 1em 3em;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
/* bzchan: All H* tags tweaked */
|
||||
H1, H3 {
|
||||
|
||||
text-align: center;
|
||||
}
|
||||
H1 {
|
||||
font-size: 2em;
|
||||
margin-top: 0px;
|
||||
@ -126,14 +121,16 @@ A:hover {text-decoration: underline;}
|
||||
* the main part of each page *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#body {
|
||||
.withleft {
|
||||
margin-left: 160px;
|
||||
text-align: center;
|
||||
}
|
||||
#body TABLE {
|
||||
width: 90%;
|
||||
margin: auto;
|
||||
}
|
||||
.paginator {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -150,10 +147,6 @@ A:hover {text-decoration: underline;}
|
||||
padding: 8px 4px 8px 4px;
|
||||
}
|
||||
|
||||
#image_comments {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.setupblock {
|
||||
border: 1px solid #AAA;
|
||||
padding: 8px;
|
||||
@ -172,6 +165,11 @@ A:hover {text-decoration: underline;}
|
||||
background: #FAA;
|
||||
}
|
||||
|
||||
.comment .username {
|
||||
font-size: 1.5em;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* bzchan added *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
91
themes/danbooru/upload.theme.php
Normal file
91
themes/danbooru/upload.theme.php
Normal file
@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
class UploadTheme extends Themelet {
|
||||
public function display_block($page) {
|
||||
// this theme links to /upload
|
||||
// $page->add_block(new Block("Upload", $this->build_upload_block(), "left", 20));
|
||||
}
|
||||
|
||||
public function display_page($page) {
|
||||
global $config;
|
||||
$tl_enabled = ($config->get_string("transload_engine", "none") != "none");
|
||||
|
||||
$upload_list = "";
|
||||
for($i=0; $i<$config->get_int('upload_count'); $i++) {
|
||||
$n = $i + 1;
|
||||
$width = $tl_enabled ? "35%" : "80%";
|
||||
$upload_list .= "
|
||||
<tr>
|
||||
<td>File $n</td>
|
||||
<td style='width: $width;'><input accept='image/jpeg,image/png,image/gif' id='data$i' name='data$i' type='file'></td>
|
||||
";
|
||||
if($tl_enabled) {
|
||||
$upload_list .= "
|
||||
<td>URL $n</td>
|
||||
<td><input id='url$i' name='url$i' type='text'></td>
|
||||
";
|
||||
}
|
||||
$upload_list .= "
|
||||
</tr>
|
||||
";
|
||||
}
|
||||
$max_size = $config->get_int('upload_size');
|
||||
$max_kb = to_shorthand_int($max_size);
|
||||
$html = "
|
||||
<form enctype='multipart/form-data' action='".make_link("upload")."' method='POST'>
|
||||
<table id='large_upload_form'>
|
||||
$upload_list
|
||||
<tr><td>Tags</td><td colspan='3'><input id='tagBox' name='tags' type='text' value='tagme' autocomplete='off'></td></tr>
|
||||
<tr><td>Source</td><td colspan='3'><input name='source' type='text'></td></tr>
|
||||
<tr><td colspan='4'><input type='submit' value='Post'></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
<div id='upload_completions' style='clear: both;'><small>(Max file size is $max_kb)</small></div>
|
||||
";
|
||||
|
||||
$page->set_title("Upload");
|
||||
$page->set_heading("Upload");
|
||||
$page->add_block(new NavBlock());
|
||||
$page->add_block(new Block("Upload", $html, "main", 20));
|
||||
}
|
||||
|
||||
public function display_upload_status($page, $ok) {
|
||||
if($ok) {
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("index"));
|
||||
}
|
||||
else {
|
||||
$page->set_title("Upload Status");
|
||||
$page->set_heading("Upload Status");
|
||||
$page->add_block(new NavBlock());
|
||||
}
|
||||
}
|
||||
|
||||
public function display_upload_error($page, $title, $message) {
|
||||
$page->add_block(new Block($title, $message));
|
||||
}
|
||||
|
||||
private function build_upload_block() {
|
||||
global $config;
|
||||
|
||||
$upload_list = "";
|
||||
for($i=0; $i<$config->get_int('upload_count'); $i++) {
|
||||
if($i == 0) $style = ""; // "style='display:visible'";
|
||||
else $style = "style='display:none'";
|
||||
$upload_list .= "<input accept='image/jpeg,image/png,image/gif' size='10' ".
|
||||
"id='data$i' name='data$i' $style onchange=\"showUp('data".($i+1)."')\" type='file'>\n";
|
||||
}
|
||||
$max_size = $config->get_int('upload_size');
|
||||
$max_kb = to_shorthand_int($max_size);
|
||||
// <input type='hidden' name='max_file_size' value='$max_size' />
|
||||
return "
|
||||
<form enctype='multipart/form-data' action='".make_link("upload")."' method='POST'>
|
||||
$upload_list
|
||||
<input id='tagBox' name='tags' type='text' value='tagme' autocomplete='off'>
|
||||
<input type='submit' value='Post'>
|
||||
</form>
|
||||
<div id='upload_completions' style='clear: both;'><small>(Max file size is $max_kb)</small></div>
|
||||
";
|
||||
}
|
||||
}
|
||||
?>
|
94
themes/danbooru/view.theme.php
Normal file
94
themes/danbooru/view.theme.php
Normal file
@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
class ViewTheme extends Themelet {
|
||||
public function display_image_not_found($page, $image_id) {
|
||||
$page->set_title("Image not found");
|
||||
$page->set_heading("Image not found");
|
||||
$page->add_block(new NavBlock());
|
||||
$page->add_block(new Block("Image not found",
|
||||
"No image in the database has the ID #$image_id"));
|
||||
}
|
||||
|
||||
public function display_page($page, $image) {
|
||||
$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->id), "left", 0));
|
||||
$page->add_block(new Block("Image", $this->build_image_view($image), "main", 0));
|
||||
$page->add_block(new Block(null, $this->build_info($image), "main", 10));
|
||||
}
|
||||
|
||||
|
||||
|
||||
var $pin = null;
|
||||
|
||||
private function build_pin($image_id) {
|
||||
if(!is_null($this->pin)) {
|
||||
return $this->pin;
|
||||
}
|
||||
|
||||
global $database;
|
||||
|
||||
if(isset($_GET['search'])) {
|
||||
$search_terms = explode(' ', $_GET['search']);
|
||||
$query = "search=".url_escape($_GET['search']);
|
||||
}
|
||||
else {
|
||||
$search_terms = array();
|
||||
$query = null;
|
||||
}
|
||||
|
||||
$next = $database->get_next_image($image_id, $search_terms);
|
||||
$prev = $database->get_prev_image($image_id, $search_terms);
|
||||
|
||||
$h_prev = (!is_null($prev) ? "<a href='".make_link("post/view/{$prev->id}", $query)."'>Prev</a>" : "Prev");
|
||||
$h_index = "<a href='".make_link("index")."'>Index</a>";
|
||||
$h_next = (!is_null($next) ? "<a href='".make_link("post/view/{$next->id}", $query)."'>Next</a>" : "Next");
|
||||
|
||||
$this->pin = "$h_prev | $h_index | $h_next";
|
||||
return $this->pin;
|
||||
}
|
||||
|
||||
private function build_navigation($image_id) {
|
||||
$h_pin = $this->build_pin($image_id);
|
||||
$h_search = "
|
||||
<p><form action='".make_link("index")."' method='GET'>
|
||||
<input id='search_input' name='search' type='text'
|
||||
value='Search' autocomplete='off'>
|
||||
<input type='submit' value='Find' style='display: none;'>
|
||||
</form>
|
||||
<div id='search_completions'></div>";
|
||||
|
||||
return "$h_pin<br>$h_search";
|
||||
}
|
||||
|
||||
private function build_image_view($image) {
|
||||
$ilink = $image->get_image_link();
|
||||
return "<img id='main_image' src='$ilink'>";
|
||||
}
|
||||
|
||||
private function build_info($image) {
|
||||
global $user;
|
||||
$owner = $image->get_owner();
|
||||
$h_owner = html_escape($owner->name);
|
||||
$h_ip = html_escape($image->owner_ip);
|
||||
$h_source = html_escape($image->source);
|
||||
$i_owner_id = int_escape($owner->id);
|
||||
|
||||
$html = "";
|
||||
$html .= "<p>Posted on {$image->posted} by <a href='".make_link("user/$h_owner")."'>$h_owner</a>";
|
||||
if($user->is_admin()) {
|
||||
$html .= " ($h_ip)";
|
||||
}
|
||||
if(!is_null($image->source)) {
|
||||
if(substr($image->source, 0, 7) == "http://") {
|
||||
$html .= " (<a href='$h_source'>source</a>)";
|
||||
}
|
||||
else {
|
||||
$html .= " (<a href='http://$h_source'>source</a>)";
|
||||
}
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user