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