1 | <?php |
---|
2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
3 | # |
---|
4 | # This file is part of Dotclear 2. |
---|
5 | # |
---|
6 | # Copyright (c) 2003-2010 Olivier Meunier & Association Dotclear |
---|
7 | # Licensed under the GPL version 2.0 license. |
---|
8 | # See LICENSE file or |
---|
9 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
10 | # |
---|
11 | # -- END LICENSE BLOCK ----------------------------------------- |
---|
12 | |
---|
13 | require dirname(__FILE__).'/../inc/admin/prepend.php'; |
---|
14 | |
---|
15 | dcPage::check('usage,contentadmin'); |
---|
16 | |
---|
17 | # Filters |
---|
18 | $sortby_combo = array( |
---|
19 | __('Last update') => 'blog_upddt', |
---|
20 | __('Blog name') => 'UPPER(blog_name)', |
---|
21 | __('Blog ID') => 'B.blog_id' |
---|
22 | ); |
---|
23 | |
---|
24 | $order_combo = array( |
---|
25 | __('Descending') => 'desc', |
---|
26 | __('Ascending') => 'asc' |
---|
27 | ); |
---|
28 | |
---|
29 | $q = !empty($_GET['q']) ? $_GET['q'] : ''; |
---|
30 | $sortby = !empty($_GET['sortby']) ? $_GET['sortby'] : 'blog_upddt'; |
---|
31 | $order = !empty($_GET['order']) ? $_GET['order'] : 'desc'; |
---|
32 | |
---|
33 | $page = !empty($_GET['page']) ? $_GET['page'] : 1; |
---|
34 | $nb_per_page = 30; |
---|
35 | |
---|
36 | if (!empty($_GET['nb']) && (integer) $_GET['nb'] > 0) { |
---|
37 | $nb_per_page = $_GET['nb']; |
---|
38 | } |
---|
39 | |
---|
40 | $show_filters = false; |
---|
41 | |
---|
42 | # - Search filter |
---|
43 | if ($q) { |
---|
44 | $params['q'] = $q; |
---|
45 | $show_filters = true; |
---|
46 | } |
---|
47 | |
---|
48 | # - Sortby and order filter |
---|
49 | if ($sortby !== '' && in_array($sortby,$sortby_combo)) { |
---|
50 | if ($order !== '' && in_array($order,$order_combo)) { |
---|
51 | $params['order'] = $sortby.' '.$order; |
---|
52 | } |
---|
53 | |
---|
54 | if ($sortby != 'blog_upddt' || $order != 'desc') { |
---|
55 | $show_filters = true; |
---|
56 | } |
---|
57 | } |
---|
58 | |
---|
59 | $params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page); |
---|
60 | |
---|
61 | try { |
---|
62 | $counter = $core->getBlogs($params,1); |
---|
63 | $rs = $core->getBlogs($params); |
---|
64 | $nb_blog = $counter->f(0); |
---|
65 | } catch (Exception $e) { |
---|
66 | $core->error->add($e->getMessage()); |
---|
67 | } |
---|
68 | |
---|
69 | /* DISPLAY |
---|
70 | -------------------------------------------------------- */ |
---|
71 | $starting_script = ''; |
---|
72 | if (!$show_filters) { |
---|
73 | $starting_script .= dcPage::jsLoad('js/filter-controls.js'); |
---|
74 | } |
---|
75 | dcPage::open(__('List of blogs'),$starting_script); |
---|
76 | |
---|
77 | if (!empty($_GET['del'])) { |
---|
78 | echo '<p class="message">'.__('Blog has been successfully deleted.').'</p>'; |
---|
79 | } |
---|
80 | |
---|
81 | echo '<h2>'.__('List of blogs').'</h2>'; |
---|
82 | |
---|
83 | if (!$core->error->flag()) |
---|
84 | { |
---|
85 | if ($core->auth->isSuperAdmin()) { |
---|
86 | echo '<p class="top-add"><a class="button add" href="blog.php">'.__('Create a new blog').'</a></p>'; |
---|
87 | } |
---|
88 | |
---|
89 | if (!$show_filters) { |
---|
90 | echo '<p><a id="filter-control" class="form-control" href="#">'.__('Filters').'</a></p>'; |
---|
91 | } |
---|
92 | |
---|
93 | echo |
---|
94 | '<form action="blogs.php" method="get" id="filters-form">'. |
---|
95 | '<fieldset class="two-cols"><legend>'.__('Filters').'</legend>'. |
---|
96 | |
---|
97 | '<div class="col">'. |
---|
98 | '<p><label for="sortby">'.__('Order by:').' '. |
---|
99 | form::combo('sortby',$sortby_combo,html::escapeHTML($sortby)). |
---|
100 | '</label> '. |
---|
101 | '<label for="order">'.__('Sort:').' '. |
---|
102 | form::combo('order',$order_combo,html::escapeHTML($order)). |
---|
103 | '</label></p>'. |
---|
104 | '</div>'. |
---|
105 | |
---|
106 | '<div class="col">'. |
---|
107 | '<p><label for="q">'.__('Search:').' '. |
---|
108 | form::field('q',20,255,html::escapeHTML($q)). |
---|
109 | '</label></p>'. |
---|
110 | '<p><label for="nb" class="classic">'. form::field('nb',3,3,$nb_per_page).' '. |
---|
111 | __('Blogs per page').'</label> '. |
---|
112 | '<input type="submit" value="'.__('Apply filters').'" /></p>'. |
---|
113 | '</div>'. |
---|
114 | |
---|
115 | '<br class="clear" />'. //Opera sucks |
---|
116 | '</fieldset>'. |
---|
117 | '</form>'; |
---|
118 | |
---|
119 | # Show blogs |
---|
120 | $blogs_list = new adminBlogList($core,$rs,$nb_blog); |
---|
121 | $blogs_list->display($page,$nb_per_page); |
---|
122 | } |
---|
123 | |
---|
124 | dcPage::close(); |
---|
125 | |
---|
126 | ?> |
---|