[0] | 1 | <?php |
---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
| 3 | # |
---|
| 4 | # This file is part of Dotclear 2. |
---|
| 5 | # |
---|
[1179] | 6 | # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear |
---|
[0] | 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 | |
---|
[1912] | 33 | $page = !empty($_GET['page']) ? max(1,(integer) $_GET['page']) : 1; |
---|
[0] | 34 | $nb_per_page = 30; |
---|
| 35 | |
---|
| 36 | if (!empty($_GET['nb']) && (integer) $_GET['nb'] > 0) { |
---|
[792] | 37 | $nb_per_page = (integer) $_GET['nb']; |
---|
[0] | 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 | } |
---|
[1358] | 75 | dcPage::open(__('List of blogs'),$starting_script, |
---|
| 76 | dcPage::breadcrumb( |
---|
| 77 | array( |
---|
| 78 | __('System') => '', |
---|
| 79 | '<span class="page-title">'.__('List of blogs').'</span>' => '' |
---|
| 80 | )) |
---|
| 81 | ); |
---|
[0] | 82 | |
---|
| 83 | if (!empty($_GET['del'])) { |
---|
[1553] | 84 | dcPage::success(__('Blog has been successfully deleted.')); |
---|
[0] | 85 | } |
---|
| 86 | |
---|
| 87 | if (!$core->error->flag()) |
---|
| 88 | { |
---|
| 89 | if ($core->auth->isSuperAdmin()) { |
---|
[158] | 90 | echo '<p class="top-add"><a class="button add" href="blog.php">'.__('Create a new blog').'</a></p>'; |
---|
[0] | 91 | } |
---|
| 92 | |
---|
| 93 | if (!$show_filters) { |
---|
[1420] | 94 | echo '<p><a id="filter-control" class="form-control" href="#">'.__('Filter blogs list').'</a></p>'; |
---|
[0] | 95 | } |
---|
| 96 | |
---|
| 97 | echo |
---|
| 98 | '<form action="blogs.php" method="get" id="filters-form">'. |
---|
[1514] | 99 | '<h3 class="hidden">'.__('Filter blogs list').'</h3>'. |
---|
[0] | 100 | |
---|
[1420] | 101 | '<div class="table">'. |
---|
| 102 | '<div class="cell">'. |
---|
[1514] | 103 | '<h4>'.__('Filters').'</h4>'. |
---|
[1420] | 104 | '<p><label for="q" class="ib">'.__('Search:').'</label> '. |
---|
| 105 | form::field('q',20,255,html::escapeHTML($q)).'</p>'. |
---|
[0] | 106 | '</div>'. |
---|
| 107 | |
---|
[1420] | 108 | '<div class="cell filters-options">'. |
---|
[1514] | 109 | '<h4>'.__('Display options').'</h4>'. |
---|
[1420] | 110 | '<p><label for="sortby" class="ib">'.__('Order by:').'</label> '. |
---|
| 111 | form::combo('sortby',$sortby_combo,html::escapeHTML($sortby)).'</p>'. |
---|
| 112 | '<p><label for="order" class="ib">'.__('Sort:').'</label> '. |
---|
| 113 | form::combo('order',$order_combo,html::escapeHTML($order)).'</p>'. |
---|
[1426] | 114 | '<p><span class="label ib">'.__('Show').'</span> <label for="nb" class="classic">'. |
---|
[1420] | 115 | form::field('nb',3,3,$nb_per_page).' '.__('blogs per page').'</label></p>'. |
---|
[0] | 116 | '</div>'. |
---|
[1420] | 117 | '</div>'. |
---|
| 118 | |
---|
[1514] | 119 | '<p><input type="submit" value="'.__('Apply filters and display options').'" />'. |
---|
[1424] | 120 | '<br class="clear" /></p>'. //Opera sucks |
---|
[0] | 121 | '</form>'; |
---|
| 122 | |
---|
| 123 | # Show blogs |
---|
| 124 | if ($nb_blog == 0) |
---|
| 125 | { |
---|
| 126 | echo '<p><strong>'.__('No blog').'</strong></p>'; |
---|
| 127 | } |
---|
| 128 | else |
---|
| 129 | { |
---|
[1926] | 130 | $pager = new dcPager($page,$nb_blog,$nb_per_page,10); |
---|
[0] | 131 | |
---|
[1926] | 132 | echo $pager->getLinks(); |
---|
[0] | 133 | |
---|
| 134 | echo |
---|
[2002] | 135 | '<div class="table-outer">'. |
---|
[1668] | 136 | '<table class="clear"><caption class="hidden">'.__('Blogs list').'</caption><tr>'. |
---|
| 137 | '<th scope="col" class="nowrap">'.__('Blog id').'</th>'. |
---|
| 138 | '<th scope="col">'.__('Blog name').'</th>'. |
---|
| 139 | '<th scope="col" class="nowrap">'.__('Entries (all types)').'</th>'. |
---|
| 140 | '<th scope="col" class="nowrap">'.__('Last update').'</th>'. |
---|
| 141 | '<th scope="col" class="nowrap">'.__('Status').'</th>'. |
---|
[0] | 142 | '</tr>'; |
---|
| 143 | |
---|
| 144 | while ($rs->fetch()) { |
---|
| 145 | echo blogLine($rs); |
---|
| 146 | } |
---|
| 147 | |
---|
[2002] | 148 | echo '</table></div>'; |
---|
[0] | 149 | |
---|
[1926] | 150 | echo $pager->getLinks(); |
---|
[0] | 151 | } |
---|
| 152 | } |
---|
| 153 | |
---|
| 154 | dcPage::close(); |
---|
| 155 | |
---|
| 156 | function blogLine($rs) |
---|
| 157 | { |
---|
| 158 | global $core; |
---|
| 159 | |
---|
| 160 | $blog_id = html::escapeHTML($rs->blog_id); |
---|
| 161 | $edit_link = ''; |
---|
| 162 | |
---|
| 163 | if ($GLOBALS['core']->auth->isSuperAdmin()) { |
---|
| 164 | $edit_link = |
---|
[1668] | 165 | '<a href="blog.php?id='.$blog_id.'" title="'.sprintf(__('Edit blog settings for %s'),$blog_id).'">'. |
---|
| 166 | '<img src="images/edit-mini.png" alt="'.__('Edit blog settings').'" /> '.$blog_id.'</a> '; |
---|
[0] | 167 | } |
---|
| 168 | |
---|
| 169 | $img_status = $rs->blog_status == 1 ? 'check-on' : 'check-off'; |
---|
| 170 | $txt_status = $GLOBALS['core']->getBlogStatus($rs->blog_status); |
---|
| 171 | $img_status = sprintf('<img src="images/%1$s.png" alt="%2$s" title="%2$s" />',$img_status,$txt_status); |
---|
| 172 | $offset = dt::getTimeOffset($core->auth->getInfo('user_tz')); |
---|
| 173 | $blog_upddt = dt::str(__('%Y-%m-%d %H:%M'),strtotime($rs->blog_upddt) + $offset); |
---|
| 174 | |
---|
| 175 | return |
---|
| 176 | '<tr class="line">'. |
---|
[1668] | 177 | '<td class="nowrap">'.$edit_link.'</td>'. |
---|
[0] | 178 | '<td class="maximal"><a href="index.php?switchblog='.$rs->blog_id.'" '. |
---|
| 179 | 'title="'.sprintf(__('Switch to blog %s'),$rs->blog_id).'">'. |
---|
| 180 | html::escapeHTML($rs->blog_name).'</a></td>'. |
---|
[1668] | 181 | '<td class="nowrap count">'.$core->countBlogPosts($rs->blog_id).'</td>'. |
---|
| 182 | '<td class="nowrap count">'.$blog_upddt.'</td>'. |
---|
[0] | 183 | '<td class="status">'.$img_status.'</td>'. |
---|
| 184 | '</tr>'; |
---|
| 185 | } |
---|
| 186 | ?> |
---|