-
Notifications
You must be signed in to change notification settings - Fork 2
/
post_index.php
102 lines (79 loc) · 2.9 KB
/
post_index.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
<?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/>.
*/
require_once "lib/header.php";
require_once "lib/Booru.php";
require_once "lib/Styler.php";
$site = new Booru( $_GET['site'] );
$styler = new Styler( $site );
//Change limit
if( isset( $_GET['limit'] ) )
$site->change_fetch_amount( $_GET['limit'] );
//Get parameters
$search = $_GET["search"];
$page = $_GET["page"];
$post_index = $site->index( $search );
$index = $post_index->get_page( $page );
$page_amount = $post_index->get_page_amount();
$layout = new mainLayout();
$layout->navigation = $styler->main_navigation( $search );
//Add favicon
$favicon = new htmlObject( 'link' );
$favicon->attributes[ 'rel' ] = 'icon';
$favicon->attributes[ 'href' ] = '/' . $_GET['site'] . '/favicon/index/';
$layout->page->html->head->content[] = $favicon;
//Set title
$title = "Index";
if( $search )
$title .= ": " . $search;
if( $page > 1 )
$title .= " - Page " . $page;
$layout->page->html->title = $title;
$layout->main->addClass( 'post_list' );
$layout->sidebar->addClass( 'post_list_info' );
//Set sizing options
if( $site->get_api()->thumbnail_size() >= 192 )
$layout->main->addClass( 'size_medium' );
//Set page relationships
if( $page > 1 )
$layout->page->html->addSequence( "prev", $site->index_link( $page-1, $search ) );
if( $page+1 <= $page_amount )
$layout->page->html->addSequence( "next", $site->index_link( $page+1, $search ) );
if( $index ){
//Write list
$list = new htmlList();
foreach( $index as $i )
$list->addItem( array(
$styler->post_thumb( $i )
, $styler->post_details( $i )
) );
$layout->main->content[] = $list;
}
else //Nothing to display
$layout->main->content[] = new htmlObject( 'p', 'No posts found' );
//Add page navigation
$page_links = $styler->page_index_nav( $post_index, $page );
if( $page_links )
$layout->main->content[] = $page_links;
//Side-panel
//Add similar tags if low amount of pages
if( $page_amount < 2 ){
$tag = new DTTag( $site->get_code() );
$tags = $tag->similar_tags( $search );
$layout->sidebar->content[] = $styler->tag_list( $tags, 'Similar tags' );
}
//Add related tags
$tags = $post_index->related_tags();
$layout->sidebar->content[] = $styler->tag_list( $tags, 'Related tags' );
$layout->page->write();
?>