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