[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 | if (!defined('DC_RC_PATH')) { return; } |
---|
| 13 | |
---|
| 14 | class adminGenericList |
---|
| 15 | { |
---|
| 16 | protected $core; |
---|
| 17 | protected $rs; |
---|
| 18 | protected $rs_count; |
---|
| 19 | |
---|
| 20 | public function __construct($core,$rs,$rs_count) |
---|
| 21 | { |
---|
| 22 | $this->core =& $core; |
---|
| 23 | $this->rs =& $rs; |
---|
| 24 | $this->rs_count = $rs_count; |
---|
[1600] | 25 | $this->html_prev = __('« prev.'); |
---|
| 26 | $this->html_next = __('next »'); |
---|
[0] | 27 | } |
---|
| 28 | } |
---|
| 29 | |
---|
| 30 | class adminPostList extends adminGenericList |
---|
| 31 | { |
---|
| 32 | public function display($page,$nb_per_page,$enclose_block='') |
---|
| 33 | { |
---|
| 34 | if ($this->rs->isEmpty()) |
---|
| 35 | { |
---|
| 36 | echo '<p><strong>'.__('No entry').'</strong></p>'; |
---|
| 37 | } |
---|
| 38 | else |
---|
| 39 | { |
---|
| 40 | $pager = new pager($page,$this->rs_count,$nb_per_page,10); |
---|
| 41 | $pager->html_prev = $this->html_prev; |
---|
| 42 | $pager->html_next = $this->html_next; |
---|
| 43 | $pager->var_page = 'page'; |
---|
[1476] | 44 | $entries = array(); |
---|
| 45 | if (isset($_REQUEST['entries'])) { |
---|
| 46 | foreach ($_REQUEST['entries'] as $v) { |
---|
| 47 | $entries[(integer)$v]=true; |
---|
| 48 | } |
---|
| 49 | } |
---|
[0] | 50 | $html_block = |
---|
[1600] | 51 | '<table class="clear"><caption class="hidden">'.__('Entries list').'</caption><tr>'. |
---|
[1508] | 52 | '<th colspan="2" class="first">'.__('Title').'</th>'. |
---|
[1600] | 53 | '<th scope="col">'.__('Date').'</th>'. |
---|
| 54 | '<th scope="col">'.__('Category').'</th>'. |
---|
| 55 | '<th scope="col">'.__('Author').'</th>'. |
---|
| 56 | '<th scope="col">'.__('Comments').'</th>'. |
---|
| 57 | '<th scope="col">'.__('Trackbacks').'</th>'. |
---|
| 58 | '<th scope="col">'.__('Status').'</th>'. |
---|
[0] | 59 | '</tr>%s</table>'; |
---|
| 60 | |
---|
| 61 | if ($enclose_block) { |
---|
| 62 | $html_block = sprintf($enclose_block,$html_block); |
---|
| 63 | } |
---|
| 64 | |
---|
[1415] | 65 | echo '<p class="pagination">'.__('Page(s)').' : '.$pager->getLinks().'</p>'; |
---|
[0] | 66 | |
---|
| 67 | $blocks = explode('%s',$html_block); |
---|
| 68 | |
---|
| 69 | echo $blocks[0]; |
---|
| 70 | |
---|
| 71 | while ($this->rs->fetch()) |
---|
| 72 | { |
---|
[1476] | 73 | echo $this->postLine(isset($entries[$this->rs->post_id])); |
---|
[0] | 74 | } |
---|
| 75 | |
---|
| 76 | echo $blocks[1]; |
---|
| 77 | |
---|
[1415] | 78 | echo '<p class="pagination">'.__('Page(s)').' : '.$pager->getLinks().'</p>'; |
---|
[0] | 79 | } |
---|
| 80 | } |
---|
| 81 | |
---|
[1476] | 82 | private function postLine($checked) |
---|
[0] | 83 | { |
---|
| 84 | if ($this->core->auth->check('categories',$this->core->blog->id)) { |
---|
| 85 | $cat_link = '<a href="category.php?id=%s">%s</a>'; |
---|
| 86 | } else { |
---|
| 87 | $cat_link = '%2$s'; |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | if ($this->rs->cat_title) { |
---|
| 91 | $cat_title = sprintf($cat_link,$this->rs->cat_id, |
---|
| 92 | html::escapeHTML($this->rs->cat_title)); |
---|
| 93 | } else { |
---|
[1364] | 94 | $cat_title = __('(No cat)'); |
---|
[0] | 95 | } |
---|
| 96 | |
---|
| 97 | $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; |
---|
| 98 | switch ($this->rs->post_status) { |
---|
| 99 | case 1: |
---|
[1353] | 100 | $img_status = sprintf($img,__('Published'),'check-on.png'); |
---|
[0] | 101 | break; |
---|
| 102 | case 0: |
---|
[1353] | 103 | $img_status = sprintf($img,__('Unpublished'),'check-off.png'); |
---|
[0] | 104 | break; |
---|
| 105 | case -1: |
---|
[1353] | 106 | $img_status = sprintf($img,__('Scheduled'),'scheduled.png'); |
---|
[0] | 107 | break; |
---|
| 108 | case -2: |
---|
[1353] | 109 | $img_status = sprintf($img,__('Pending'),'check-wrn.png'); |
---|
[0] | 110 | break; |
---|
| 111 | } |
---|
| 112 | |
---|
| 113 | $protected = ''; |
---|
| 114 | if ($this->rs->post_password) { |
---|
[1353] | 115 | $protected = sprintf($img,__('Protected'),'locker.png'); |
---|
[0] | 116 | } |
---|
| 117 | |
---|
| 118 | $selected = ''; |
---|
| 119 | if ($this->rs->post_selected) { |
---|
[1353] | 120 | $selected = sprintf($img,__('Selected'),'selected.png'); |
---|
[0] | 121 | } |
---|
| 122 | |
---|
| 123 | $attach = ''; |
---|
| 124 | $nb_media = $this->rs->countMedia(); |
---|
| 125 | if ($nb_media > 0) { |
---|
| 126 | $attach_str = $nb_media == 1 ? __('%d attachment') : __('%d attachments'); |
---|
| 127 | $attach = sprintf($img,sprintf($attach_str,$nb_media),'attach.png'); |
---|
| 128 | } |
---|
| 129 | |
---|
| 130 | $res = '<tr class="line'.($this->rs->post_status != 1 ? ' offline' : '').'"'. |
---|
| 131 | ' id="p'.$this->rs->post_id.'">'; |
---|
| 132 | |
---|
| 133 | $res .= |
---|
| 134 | '<td class="nowrap">'. |
---|
[1476] | 135 | form::checkbox(array('entries[]'),$this->rs->post_id,$checked,'','',!$this->rs->isEditable()).'</td>'. |
---|
[1600] | 136 | '<td class="maximal" scope="row"><a href="'.$this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id).'">'. |
---|
[0] | 137 | html::escapeHTML($this->rs->post_title).'</a></td>'. |
---|
| 138 | '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->post_dt).'</td>'. |
---|
| 139 | '<td class="nowrap">'.$cat_title.'</td>'. |
---|
[1146] | 140 | '<td class="nowrap">'.html::escapeHTML($this->rs->user_id).'</td>'. |
---|
[0] | 141 | '<td class="nowrap">'.$this->rs->nb_comment.'</td>'. |
---|
| 142 | '<td class="nowrap">'.$this->rs->nb_trackback.'</td>'. |
---|
| 143 | '<td class="nowrap status">'.$img_status.' '.$selected.' '.$protected.' '.$attach.'</td>'. |
---|
| 144 | '</tr>'; |
---|
| 145 | |
---|
| 146 | return $res; |
---|
| 147 | } |
---|
| 148 | } |
---|
| 149 | |
---|
| 150 | class adminPostMiniList extends adminGenericList |
---|
| 151 | { |
---|
| 152 | public function display($page,$nb_per_page,$enclose_block='') |
---|
| 153 | { |
---|
| 154 | if ($this->rs->isEmpty()) |
---|
| 155 | { |
---|
| 156 | echo '<p><strong>'.__('No entry').'</strong></p>'; |
---|
| 157 | } |
---|
| 158 | else |
---|
| 159 | { |
---|
| 160 | $pager = new pager($page,$this->rs_count,$nb_per_page,10); |
---|
| 161 | $pager->html_prev = $this->html_prev; |
---|
| 162 | $pager->html_next = $this->html_next; |
---|
| 163 | $pager->var_page = 'page'; |
---|
| 164 | |
---|
| 165 | $html_block = |
---|
[1600] | 166 | '<table class="clear"><caption class="hidden">'.__('Entries list').'</caption><tr>'. |
---|
| 167 | '<th scope="col">'.__('Title').'</th>'. |
---|
| 168 | '<th scope="col">'.__('Date').'</th>'. |
---|
| 169 | '<th scope="col">'.__('Author').'</th>'. |
---|
| 170 | '<th scope="col">'.__('Status').'</th>'. |
---|
[0] | 171 | '</tr>%s</table>'; |
---|
| 172 | |
---|
| 173 | if ($enclose_block) { |
---|
| 174 | $html_block = sprintf($enclose_block,$html_block); |
---|
| 175 | } |
---|
| 176 | |
---|
[1415] | 177 | echo '<p class="pagination">'.__('Page(s)').' : '.$pager->getLinks().'</p>'; |
---|
[0] | 178 | |
---|
| 179 | $blocks = explode('%s',$html_block); |
---|
| 180 | |
---|
| 181 | echo $blocks[0]; |
---|
| 182 | |
---|
| 183 | while ($this->rs->fetch()) |
---|
| 184 | { |
---|
| 185 | echo $this->postLine(); |
---|
| 186 | } |
---|
| 187 | |
---|
| 188 | echo $blocks[1]; |
---|
| 189 | |
---|
[1415] | 190 | echo '<p class="pagination">'.__('Page(s)').' : '.$pager->getLinks().'</p>'; |
---|
[0] | 191 | } |
---|
| 192 | } |
---|
| 193 | |
---|
| 194 | private function postLine() |
---|
| 195 | { |
---|
| 196 | $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; |
---|
| 197 | switch ($this->rs->post_status) { |
---|
| 198 | case 1: |
---|
[1353] | 199 | $img_status = sprintf($img,__('Published'),'check-on.png'); |
---|
[0] | 200 | break; |
---|
| 201 | case 0: |
---|
[1353] | 202 | $img_status = sprintf($img,__('Unpublished'),'check-off.png'); |
---|
[0] | 203 | break; |
---|
| 204 | case -1: |
---|
[1353] | 205 | $img_status = sprintf($img,__('Scheduled'),'scheduled.png'); |
---|
[0] | 206 | break; |
---|
| 207 | case -2: |
---|
[1353] | 208 | $img_status = sprintf($img,__('Pending'),'check-wrn.png'); |
---|
[0] | 209 | break; |
---|
| 210 | } |
---|
| 211 | |
---|
| 212 | $protected = ''; |
---|
| 213 | if ($this->rs->post_password) { |
---|
[1353] | 214 | $protected = sprintf($img,__('Protected'),'locker.png'); |
---|
[0] | 215 | } |
---|
| 216 | |
---|
| 217 | $selected = ''; |
---|
| 218 | if ($this->rs->post_selected) { |
---|
[1353] | 219 | $selected = sprintf($img,__('Selected'),'selected.png'); |
---|
[0] | 220 | } |
---|
| 221 | |
---|
| 222 | $attach = ''; |
---|
| 223 | $nb_media = $this->rs->countMedia(); |
---|
| 224 | if ($nb_media > 0) { |
---|
| 225 | $attach_str = $nb_media == 1 ? __('%d attachment') : __('%d attachments'); |
---|
| 226 | $attach = sprintf($img,sprintf($attach_str,$nb_media),'attach.png'); |
---|
| 227 | } |
---|
| 228 | |
---|
| 229 | $res = '<tr class="line'.($this->rs->post_status != 1 ? ' offline' : '').'"'. |
---|
| 230 | ' id="p'.$this->rs->post_id.'">'; |
---|
| 231 | |
---|
| 232 | $res .= |
---|
[1600] | 233 | '<td scope="row" class="maximal"><a href="'.$this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id).'" '. |
---|
[0] | 234 | 'title="'.html::escapeHTML($this->rs->getURL()).'">'. |
---|
| 235 | html::escapeHTML($this->rs->post_title).'</a></td>'. |
---|
| 236 | '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->post_dt).'</td>'. |
---|
[1146] | 237 | '<td class="nowrap">'.html::escapeHTML($this->rs->user_id).'</td>'. |
---|
[0] | 238 | '<td class="nowrap status">'.$img_status.' '.$selected.' '.$protected.' '.$attach.'</td>'. |
---|
| 239 | '</tr>'; |
---|
| 240 | |
---|
| 241 | return $res; |
---|
| 242 | } |
---|
| 243 | } |
---|
| 244 | |
---|
| 245 | class adminCommentList extends adminGenericList |
---|
| 246 | { |
---|
| 247 | public function display($page,$nb_per_page,$enclose_block='') |
---|
| 248 | { |
---|
| 249 | if ($this->rs->isEmpty()) |
---|
| 250 | { |
---|
| 251 | echo '<p><strong>'.__('No comment').'</strong></p>'; |
---|
| 252 | } |
---|
| 253 | else |
---|
| 254 | { |
---|
| 255 | $pager = new pager($page,$this->rs_count,$nb_per_page,10); |
---|
| 256 | $pager->html_prev = $this->html_prev; |
---|
| 257 | $pager->html_next = $this->html_next; |
---|
| 258 | $pager->var_page = 'page'; |
---|
| 259 | |
---|
| 260 | $html_block = |
---|
[1587] | 261 | '<table><caption class="hidden">'.__('Comments and trackbacks list').'</caption><tr>'. |
---|
[1600] | 262 | '<th colspan="3" scope="col" abbr="comm" class="first">'.__('Type and author').'</th>'. |
---|
[1587] | 263 | '<th scope="col">'.__('Date').'</th>'. |
---|
| 264 | '<th scope="col" class="txt-center">'.__('Status').'</th>'. |
---|
| 265 | '<th scope="col" abbr="entry">'.__('Entry title').'</th>'. |
---|
[0] | 266 | '</tr>%s</table>'; |
---|
[1587] | 267 | |
---|
[0] | 268 | if ($enclose_block) { |
---|
| 269 | $html_block = sprintf($enclose_block,$html_block); |
---|
| 270 | } |
---|
| 271 | |
---|
[1415] | 272 | echo '<p class="pagination">'.__('Page(s)').' : '.$pager->getLinks().'</p>'; |
---|
[0] | 273 | |
---|
| 274 | $blocks = explode('%s',$html_block); |
---|
| 275 | |
---|
| 276 | echo $blocks[0]; |
---|
| 277 | |
---|
| 278 | while ($this->rs->fetch()) |
---|
| 279 | { |
---|
| 280 | echo $this->commentLine(); |
---|
| 281 | } |
---|
| 282 | |
---|
| 283 | echo $blocks[1]; |
---|
| 284 | |
---|
[1415] | 285 | echo '<p class="pagination">'.__('Page(s)').' : '.$pager->getLinks().'</p>'; |
---|
[0] | 286 | } |
---|
| 287 | } |
---|
| 288 | |
---|
| 289 | private function commentLine() |
---|
| 290 | { |
---|
| 291 | global $author, $status, $sortby, $order, $nb_per_page; |
---|
| 292 | |
---|
| 293 | $author_url = |
---|
| 294 | 'comments.php?n='.$nb_per_page. |
---|
| 295 | '&status='.$status. |
---|
| 296 | '&sortby='.$sortby. |
---|
| 297 | '&order='.$order. |
---|
| 298 | '&author='.rawurlencode($this->rs->comment_author); |
---|
| 299 | |
---|
| 300 | $post_url = $this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id); |
---|
| 301 | |
---|
| 302 | $comment_url = 'comment.php?id='.$this->rs->comment_id; |
---|
| 303 | |
---|
| 304 | $comment_dt = |
---|
| 305 | dt::dt2str($this->core->blog->settings->system->date_format.' - '. |
---|
| 306 | $this->core->blog->settings->system->time_format,$this->rs->comment_dt); |
---|
| 307 | |
---|
| 308 | $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; |
---|
| 309 | switch ($this->rs->comment_status) { |
---|
| 310 | case 1: |
---|
[1353] | 311 | $img_status = sprintf($img,__('Published'),'check-on.png'); |
---|
[0] | 312 | break; |
---|
| 313 | case 0: |
---|
[1353] | 314 | $img_status = sprintf($img,__('Unpublished'),'check-off.png'); |
---|
[0] | 315 | break; |
---|
| 316 | case -1: |
---|
[1353] | 317 | $img_status = sprintf($img,__('Pending'),'check-wrn.png'); |
---|
[0] | 318 | break; |
---|
| 319 | case -2: |
---|
[1353] | 320 | $img_status = sprintf($img,__('Junk'),'junk.png'); |
---|
[0] | 321 | break; |
---|
| 322 | } |
---|
| 323 | |
---|
[1508] | 324 | $post_title = html::escapeHTML($this->rs->post_title); |
---|
[1587] | 325 | if (mb_strlen($post_title) > 60) { |
---|
| 326 | $post_title = mb_strcut($post_title,0,57).'...'; |
---|
[0] | 327 | } |
---|
| 328 | |
---|
| 329 | $res = '<tr class="line'.($this->rs->comment_status != 1 ? ' offline' : '').'"'. |
---|
| 330 | ' id="c'.$this->rs->comment_id.'">'; |
---|
| 331 | |
---|
| 332 | $res .= |
---|
| 333 | '<td class="nowrap">'. |
---|
| 334 | form::checkbox(array('comments[]'),$this->rs->comment_id,'','','',0).'</td>'. |
---|
[1587] | 335 | '<td class="status class="txt-center">'. |
---|
| 336 | '<a href="'.$comment_url.'">'. |
---|
| 337 | '<img src="images/edit-mini.png" alt="" title="'.__('Edit').'" /> '. |
---|
| 338 | '</a>'.'</td>'. |
---|
| 339 | '<td class="maximal" scope="row">'.($this->rs->comment_trackback ? __('trackback from') : __('comment from')).' '. |
---|
| 340 | '<a href="'.$author_url.'">'.html::escapeHTML($this->rs->comment_author).'</a></td>'. |
---|
[1508] | 341 | '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->comment_dt).'</td>'. |
---|
[1587] | 342 | '<td class="nowrap status txt-center">'.$img_status.'</td>'. |
---|
[1508] | 343 | '<td class="nowrap"><a href="'.$post_url.'">'. |
---|
| 344 | html::escapeHTML($post_title).'</a>'. |
---|
[1587] | 345 | ($this->rs->post_type != 'post' ? ' ('.html::escapeHTML($this->rs->post_type).')' : '').'</td>'; |
---|
[0] | 346 | |
---|
| 347 | $res .= '</tr>'; |
---|
| 348 | |
---|
| 349 | return $res; |
---|
| 350 | } |
---|
| 351 | } |
---|
| 352 | |
---|
| 353 | class adminUserList extends adminGenericList |
---|
| 354 | { |
---|
| 355 | public function display($page,$nb_per_page,$enclose_block='') |
---|
| 356 | { |
---|
| 357 | if ($this->rs->isEmpty()) |
---|
| 358 | { |
---|
| 359 | echo '<p><strong>'.__('No user').'</strong></p>'; |
---|
| 360 | } |
---|
| 361 | else |
---|
| 362 | { |
---|
| 363 | $pager = new pager($page,$this->rs_count,$nb_per_page,10); |
---|
| 364 | $pager->html_prev = $this->html_prev; |
---|
| 365 | $pager->html_next = $this->html_next; |
---|
| 366 | $pager->var_page = 'page'; |
---|
| 367 | |
---|
| 368 | $html_block = |
---|
[1600] | 369 | '<table class="clear"><caption class="hidden">'.__('Users list').'</caption><tr>'. |
---|
| 370 | '<th colspan="2" scope="col" class="first">'.__('Username').'</th>'. |
---|
| 371 | '<th scope="col">'.__('First Name').'</th>'. |
---|
| 372 | '<th scope="col">'.__('Last Name').'</th>'. |
---|
| 373 | '<th scope="col">'.__('Display name').'</th>'. |
---|
| 374 | '<th scope="col" class="nowrap">'.__('Entries').'</th>'. |
---|
[0] | 375 | '</tr>%s</table>'; |
---|
| 376 | |
---|
| 377 | if ($enclose_block) { |
---|
| 378 | $html_block = sprintf($enclose_block,$html_block); |
---|
| 379 | } |
---|
| 380 | |
---|
[1415] | 381 | echo '<p class="pagination">'.__('Page(s)').' : '.$pager->getLinks().'</p>'; |
---|
[0] | 382 | |
---|
| 383 | $blocks = explode('%s',$html_block); |
---|
| 384 | |
---|
| 385 | echo $blocks[0]; |
---|
| 386 | |
---|
| 387 | while ($this->rs->fetch()) |
---|
| 388 | { |
---|
| 389 | echo $this->userLine(); |
---|
| 390 | } |
---|
| 391 | |
---|
| 392 | echo $blocks[1]; |
---|
| 393 | |
---|
[1415] | 394 | echo '<p class="pagination">'.__('Page(s)').' : '.$pager->getLinks().'</p>'; |
---|
[0] | 395 | } |
---|
| 396 | } |
---|
| 397 | |
---|
| 398 | private function userLine() |
---|
| 399 | { |
---|
| 400 | $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; |
---|
| 401 | $img_status = ''; |
---|
| 402 | |
---|
| 403 | $p = $this->core->getUserPermissions($this->rs->user_id); |
---|
| 404 | |
---|
| 405 | if (isset($p[$this->core->blog->id]['p']['admin'])) { |
---|
| 406 | $img_status = sprintf($img,__('admin'),'admin.png'); |
---|
| 407 | } |
---|
| 408 | if ($this->rs->user_super) { |
---|
| 409 | $img_status = sprintf($img,__('superadmin'),'superadmin.png'); |
---|
| 410 | } |
---|
| 411 | return |
---|
| 412 | '<tr class="line">'. |
---|
| 413 | '<td class="nowrap">'.form::hidden(array('nb_post[]'),(integer) $this->rs->nb_post). |
---|
[860] | 414 | form::checkbox(array('users[]'),$this->rs->user_id).'</td>'. |
---|
[1600] | 415 | '<td class="maximal" scope="row"><a href="user.php?id='.$this->rs->user_id.'">'. |
---|
[0] | 416 | $this->rs->user_id.'</a> '.$img_status.'</td>'. |
---|
[1146] | 417 | '<td class="nowrap">'.html::escapeHTML($this->rs->user_firstname).'</td>'. |
---|
| 418 | '<td class="nowrap">'.html::escapeHTML($this->rs->user_name).'</td>'. |
---|
| 419 | '<td class="nowrap">'.html::escapeHTML($this->rs->user_displayname).'</td>'. |
---|
[0] | 420 | '<td class="nowrap"><a href="posts.php?user_id='.$this->rs->user_id.'">'. |
---|
| 421 | $this->rs->nb_post.'</a></td>'. |
---|
| 422 | '</tr>'; |
---|
| 423 | } |
---|
| 424 | } |
---|
| 425 | ?> |
---|