-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpost.php
128 lines (93 loc) · 3.71 KB
/
post.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
/* This file is part of BooruSurfer.
BooruSurfer is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
BooruSurfer is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with BooruSurfer. If not, see <http://www.gnu.org/licenses/>.
*/
include "lib/header.php";
require_once "lib/Booru.php";
require_once "lib/Styler.php";
$site = new Booru( $_GET['site'] );
$styler = new Styler( $site );
//Retrive post
$id = $_GET["id"];
$post = $site->post( $id );
if( $post ){
$layout = new mainLayout();
$layout->navigation = $styler->main_navigation();
$layout->page->html->title = 'Post: ' . $post->name();
$layout->main->addClass( 'post' );
$layout->sidebar->addClass( 'post_info' );
$thumbnail = new htmlObject( 'link' );
$preview = $post->get_image( 'preview' );
$image = $post->get_image();
//Add favicon
$favicon = new htmlObject( 'link' );
$favicon->attributes[ 'rel' ] = 'icon';
$favicon->attributes[ 'href' ] = '/' . $_GET['site'] . '/favicon/post/';
$layout->page->html->head->content[] = $favicon;
//Add opera speeddial thumbnail
$speeddial = new htmlObject( 'link' );
$speeddial->attributes[ 'rel' ] = 'image_src';
$speeddial->attributes[ 'href' ] = $preview['url'];
$layout->page->html->head->content[] = $speeddial;
$image_container = new htmlObject( 'div', NULL, toClass( 'container' ) );
$image_container->content[] = $styler->post_preview( $post, 'image' );
//Notes
$notes = $site->notes( $post );
if( $notes )
foreach( $notes as $note )
$image_container->content[] = $styler->note( $note, $post );
$layout->main->content[] = $image_container;
//Comments
$comments = $site->comments( $post );
if( $comments ){
$container = new htmlObject( 'div' );
$container->addClass( 'comments' );
$layout->all->addClass( 'has_comments' );
foreach( $comments as $comment )
$container->content[] = $styler->comment( $comment, $post );
$layout->all->content[] = $container;
}
//Fill sidebar
$layout->sidebar->content[] = new htmlObject( "h3", "Info:" );
$layout->sidebar->content[] = $styler->post_info( $post, true );
// $layout->sidebar->content[] = new htmlLink( post_siteurl( $id ), "On-site link" );
if( $post->parent_id() ){
$parent = $site->post( $post->parent_id() );
$img = new htmlObject( "section", NULL, toClass( "post_parent") );
$img->content[] = $styler->post_thumb( $parent );
$layout->sidebar->content[] = new htmlObject( "h3", "Parent:" );
$layout->sidebar->content[] = $img;
}
if( $post->has_children() ){
$index_child = $site->index( "parent:" . $post->id() );
$children = $index_child->get_page( 1 );
$layout->sidebar->content[] = new htmlObject( "h3", "Children:" );
$img = new htmlObject( "section", NULL, toClass( "post_children") );
//Add children
foreach( $children as $child ){
if( $child->id() != $post->id() ){
$img->content[] = $styler->post_thumb( $child );
}
}
$layout->sidebar->content[] = $img;
}
$layout->sidebar->content[] = new htmlObject( "h3", "Tags:" );
$tags = $post->get_tags();
$layout->sidebar->content[] = $styler->tag_list( $tags );
$layout->page->write();
}
else{
//No post to display : \
echo "The post was not found";
//TODO: error page
}
?>