[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 | |
---|
[3522] | 15 | dcPage::check('usage,contentadmin'); |
---|
[0] | 16 | |
---|
| 17 | # Filters |
---|
[3400] | 18 | $status_combo = array_merge( |
---|
| 19 | array('-' => ''), |
---|
| 20 | dcAdminCombos::getBlogStatusesCombo() |
---|
| 21 | ); |
---|
| 22 | |
---|
[0] | 23 | $sortby_combo = array( |
---|
[3402] | 24 | __('Last update') => 'blog_upddt', |
---|
| 25 | __('Blog name') => 'UPPER(blog_name)', |
---|
| 26 | __('Blog ID') => 'B.blog_id', |
---|
| 27 | __('Status') => 'blog_status' |
---|
[0] | 28 | ); |
---|
| 29 | |
---|
| 30 | $order_combo = array( |
---|
[3402] | 31 | __('Descending') => 'desc', |
---|
| 32 | __('Ascending') => 'asc' |
---|
[0] | 33 | ); |
---|
| 34 | |
---|
[3402] | 35 | # Actions |
---|
| 36 | |
---|
[3522] | 37 | if ($core->auth->isSuperAdmin()) { |
---|
| 38 | $blogs_actions_page = new dcBlogsActionsPage($core,$core->adminurl->get("admin.blogs")); |
---|
| 39 | if ($blogs_actions_page->process()) { |
---|
| 40 | return; |
---|
| 41 | } |
---|
[3402] | 42 | } |
---|
| 43 | |
---|
| 44 | # Requests |
---|
[0] | 45 | $q = !empty($_GET['q']) ? $_GET['q'] : ''; |
---|
[3400] | 46 | $status = isset($_GET['status']) ? $_GET['status'] : ''; |
---|
[0] | 47 | $sortby = !empty($_GET['sortby']) ? $_GET['sortby'] : 'blog_upddt'; |
---|
| 48 | $order = !empty($_GET['order']) ? $_GET['order'] : 'desc'; |
---|
[2145] | 49 | |
---|
[2137] | 50 | $show_filters = false; |
---|
[0] | 51 | |
---|
[1912] | 52 | $page = !empty($_GET['page']) ? max(1,(integer) $_GET['page']) : 1; |
---|
[0] | 53 | $nb_per_page = 30; |
---|
| 54 | |
---|
| 55 | if (!empty($_GET['nb']) && (integer) $_GET['nb'] > 0) { |
---|
[3649] | 56 | if ($nb_per_page != (integer) $_GET['nb']) { |
---|
[2137] | 57 | $show_filters = true; |
---|
| 58 | } |
---|
[792] | 59 | $nb_per_page = (integer) $_GET['nb']; |
---|
[0] | 60 | } |
---|
[2566] | 61 | |
---|
[0] | 62 | # - Search filter |
---|
| 63 | if ($q) { |
---|
| 64 | $params['q'] = $q; |
---|
| 65 | $show_filters = true; |
---|
| 66 | } |
---|
| 67 | |
---|
[3400] | 68 | # - Status filter |
---|
[3536] | 69 | if ($status !== '' && in_array($status,$status_combo,true)) { |
---|
[3400] | 70 | $params['blog_status'] = $status; |
---|
| 71 | $show_filters = true; |
---|
| 72 | } else { |
---|
| 73 | $status=''; |
---|
| 74 | } |
---|
| 75 | |
---|
[0] | 76 | # - Sortby and order filter |
---|
[3536] | 77 | if ($sortby !== '' && in_array($sortby,$sortby_combo,true)) { |
---|
| 78 | if ($order !== '' && in_array($order,$order_combo,true)) { |
---|
[0] | 79 | $params['order'] = $sortby.' '.$order; |
---|
| 80 | } |
---|
[3536] | 81 | } else { |
---|
| 82 | $sortby = 'blog_upddt'; |
---|
| 83 | $order = 'desc'; |
---|
| 84 | } |
---|
| 85 | if ($sortby != 'blog_upddt' || $order != 'desc') { |
---|
| 86 | $show_filters = true; |
---|
[0] | 87 | } |
---|
| 88 | |
---|
| 89 | $params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page); |
---|
| 90 | |
---|
| 91 | try { |
---|
| 92 | $counter = $core->getBlogs($params,1); |
---|
| 93 | $rs = $core->getBlogs($params); |
---|
| 94 | $nb_blog = $counter->f(0); |
---|
[3106] | 95 | $rsStatic = $rs->toStatic(); |
---|
[3403] | 96 | if (($sortby != 'blog_upddt') && ($sortby != 'blog_status')) { |
---|
[3106] | 97 | // Sort blog list using lexical order if necessary |
---|
| 98 | $rsStatic->extend('rsExtUser'); |
---|
| 99 | $rsStatic = $rsStatic->toExtStatic(); |
---|
| 100 | $rsStatic->lexicalSort(($sortby == 'UPPER(blog_name)' ? 'blog_name' : 'blog_id'),$order); |
---|
| 101 | } |
---|
[3402] | 102 | $blog_list = new adminBlogList($core,$rs,$counter->f(0)); |
---|
[0] | 103 | } catch (Exception $e) { |
---|
| 104 | $core->error->add($e->getMessage()); |
---|
| 105 | } |
---|
| 106 | |
---|
| 107 | /* DISPLAY |
---|
| 108 | -------------------------------------------------------- */ |
---|
[2136] | 109 | |
---|
[3397] | 110 | dcPage::open(__('List of blogs'), |
---|
[3402] | 111 | dcPage::jsLoad('js/_blogs.js').dcPage::jsFilterControl($show_filters), |
---|
[1358] | 112 | dcPage::breadcrumb( |
---|
| 113 | array( |
---|
| 114 | __('System') => '', |
---|
[2189] | 115 | __('List of blogs') => '' |
---|
[1358] | 116 | )) |
---|
| 117 | ); |
---|
[0] | 118 | |
---|
| 119 | if (!$core->error->flag()) |
---|
| 120 | { |
---|
| 121 | if ($core->auth->isSuperAdmin()) { |
---|
[2720] | 122 | echo '<p class="top-add"><a class="button add" href="'.$core->adminurl->get("admin.blog").'">'.__('Create a new blog').'</a></p>'; |
---|
[0] | 123 | } |
---|
[2566] | 124 | |
---|
[0] | 125 | echo |
---|
[2720] | 126 | '<form action="'.$core->adminurl->get("admin.blogs").'" method="get" id="filters-form">'. |
---|
[3397] | 127 | '<h3 class="out-of-screen-if-js">'.__('Show filters and display options').'</h3>'. |
---|
[2566] | 128 | |
---|
[1420] | 129 | '<div class="table">'. |
---|
| 130 | '<div class="cell">'. |
---|
[1514] | 131 | '<h4>'.__('Filters').'</h4>'. |
---|
[1420] | 132 | '<p><label for="q" class="ib">'.__('Search:').'</label> '. |
---|
| 133 | form::field('q',20,255,html::escapeHTML($q)).'</p>'. |
---|
[3522] | 134 | ($core->auth->isSuperAdmin() ? |
---|
| 135 | '<p><label for="status" class="ib">'.__('Status:').'</label> '. |
---|
| 136 | form::combo('status',$status_combo,$status).'</p>' : ''). |
---|
[0] | 137 | '</div>'. |
---|
[2566] | 138 | |
---|
[1420] | 139 | '<div class="cell filters-options">'. |
---|
[1514] | 140 | '<h4>'.__('Display options').'</h4>'. |
---|
[1420] | 141 | '<p><label for="sortby" class="ib">'.__('Order by:').'</label> '. |
---|
| 142 | form::combo('sortby',$sortby_combo,html::escapeHTML($sortby)).'</p>'. |
---|
| 143 | '<p><label for="order" class="ib">'.__('Sort:').'</label> '. |
---|
| 144 | form::combo('order',$order_combo,html::escapeHTML($order)).'</p>'. |
---|
[2566] | 145 | '<p><span class="label ib">'.__('Show').'</span> <label for="nb" class="classic">'. |
---|
[1420] | 146 | form::field('nb',3,3,$nb_per_page).' '.__('blogs per page').'</label></p>'. |
---|
[0] | 147 | '</div>'. |
---|
[1420] | 148 | '</div>'. |
---|
| 149 | |
---|
[3560] | 150 | '<p><input type="submit" value="'.__('Apply filters and display options').'" />'. |
---|
| 151 | '<br class="clear" /></p>'. //Opera sucks |
---|
[0] | 152 | '</form>'; |
---|
[2566] | 153 | |
---|
[0] | 154 | # Show blogs |
---|
[3402] | 155 | $blog_list->display($page,$nb_per_page, |
---|
[3522] | 156 | ($core->auth->isSuperAdmin() ? |
---|
| 157 | '<form action="'.$core->adminurl->get("admin.blogs").'" method="post" id="form-blogs">' : ''). |
---|
[2566] | 158 | |
---|
[3402] | 159 | '%s'. |
---|
[2566] | 160 | |
---|
[3522] | 161 | ($core->auth->isSuperAdmin() ? |
---|
[3536] | 162 | '<div class="two-cols clearfix">'. |
---|
[3522] | 163 | '<p class="col checkboxes-helpers"></p>'. |
---|
[2566] | 164 | |
---|
[3522] | 165 | '<p class="col right"><label for="action" class="classic">'.__('Selected blogs action:').'</label> '. |
---|
| 166 | form::combo('action',$blogs_actions_page->getCombo(),'online','','','','title="'.__('Actions').'"'). |
---|
| 167 | $core->formNonce(). |
---|
| 168 | '<input id="do-action" type="submit" value="'.__('ok').'" /></p>'. |
---|
| 169 | '</div>'. |
---|
[2566] | 170 | |
---|
[3536] | 171 | '<p><label for="pwd" class="classic">'.__('Please give your password to confirm blog(s) deletion:').'</label> '. |
---|
[3522] | 172 | form::password('pwd',20,255).'</p>'. |
---|
[2566] | 173 | |
---|
[3522] | 174 | form::hidden(array('sortby'),$sortby). |
---|
| 175 | form::hidden(array('order'),$order). |
---|
| 176 | form::hidden(array('status'),$status). |
---|
| 177 | form::hidden(array('page'),$page). |
---|
| 178 | form::hidden(array('nb'),$nb_per_page). |
---|
| 179 | |
---|
| 180 | '</form>' : ''), |
---|
[3402] | 181 | $show_filters |
---|
| 182 | ); |
---|
| 183 | } |
---|
[2566] | 184 | |
---|
[2314] | 185 | dcPage::helpBlock('core_blogs'); |
---|
[3403] | 186 | dcPage::close(); |
---|