| 1 | <?php | 
|---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- | 
|---|
| 3 | # | 
|---|
| 4 | # This file is part of Dotclear 2. | 
|---|
| 5 | # | 
|---|
| 6 | # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear | 
|---|
| 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 dcPager extends pager | 
|---|
| 15 | { | 
|---|
| 16 |      protected $form_action; | 
|---|
| 17 |      protected $form_hidden; | 
|---|
| 18 |       | 
|---|
| 19 |      protected function getLink($li_class,$href,$img_src,$img_src_nolink,$img_alt,$enable_link) { | 
|---|
| 20 |           if ($enable_link) { | 
|---|
| 21 |                $formatter = '<li class="%s btn"><a href="%s"><img src="%s" alt="%s"/></a><span class="hidden">%s</span></li>'; | 
|---|
| 22 |                return sprintf ($formatter, | 
|---|
| 23 |                     $li_class,$href,$img_src,$img_alt,$img_alt); | 
|---|
| 24 |           } else { | 
|---|
| 25 |                $formatter = '<li class="%s no-link btn"><img src="%s" alt="%s"/></li>'; | 
|---|
| 26 |                return sprintf ($formatter, | 
|---|
| 27 |                     $li_class,$img_src_nolink,$img_alt,$img_alt); | 
|---|
| 28 |           } | 
|---|
| 29 |      } | 
|---|
| 30 |      public function setURL() { | 
|---|
| 31 |           parent::setURL(); | 
|---|
| 32 |           $url = parse_url($_SERVER['REQUEST_URI']); | 
|---|
| 33 |           if (isset($url['query'])) { | 
|---|
| 34 |                parse_str($url['query'],$args); | 
|---|
| 35 |           } else { | 
|---|
| 36 |                $args=array(); | 
|---|
| 37 |           } | 
|---|
| 38 |           # Removing session information | 
|---|
| 39 |           if (session_id()) | 
|---|
| 40 |           { | 
|---|
| 41 |                if (isset($args[session_name()])) | 
|---|
| 42 |                     unset($args[session_name()]); | 
|---|
| 43 |           } | 
|---|
| 44 |           if (isset($args[$this->var_page])) { | 
|---|
| 45 |                unset($args[$this->var_page]); | 
|---|
| 46 |           } | 
|---|
| 47 |           if (isset($args['ok'])) { | 
|---|
| 48 |                unset($args['ok']); | 
|---|
| 49 |           } | 
|---|
| 50 |           $this->form_hidden = ''; | 
|---|
| 51 |           foreach ($args as $k=>$v) { | 
|---|
| 52 |                if (is_array($v)) { | 
|---|
| 53 |                     foreach ($v as $k2=>$v2) { | 
|---|
| 54 |                          $this->form_hidden .= form::hidden(array($k.'[]'),$v2); | 
|---|
| 55 |                     } | 
|---|
| 56 |                } else { | 
|---|
| 57 |                     $this->form_hidden .= form::hidden(array($k),$v); | 
|---|
| 58 |                } | 
|---|
| 59 |           } | 
|---|
| 60 |           $this->form_action = $url['path']; | 
|---|
| 61 |      } | 
|---|
| 62 |       | 
|---|
| 63 |      /** | 
|---|
| 64 |      * Pager Links | 
|---|
| 65 |      * | 
|---|
| 66 |      * Returns pager links | 
|---|
| 67 |      * | 
|---|
| 68 |      * @return string | 
|---|
| 69 |      */ | 
|---|
| 70 |      public function getLinks() | 
|---|
| 71 |      { | 
|---|
| 72 |           $this->setURL(); | 
|---|
| 73 |           $htmlFirst = $this->getLink( | 
|---|
| 74 |                "first", | 
|---|
| 75 |                sprintf($this->page_url,1), | 
|---|
| 76 |                "images/pagination/first.png", | 
|---|
| 77 |                "images/pagination/no-first.png", | 
|---|
| 78 |                __('First page'), | 
|---|
| 79 |                ($this->env > 1) | 
|---|
| 80 |           ); | 
|---|
| 81 |           $htmlPrev = $this->getLink( | 
|---|
| 82 |                "prev", | 
|---|
| 83 |                sprintf($this->page_url,$this->env-1), | 
|---|
| 84 |                "images/pagination/previous.png", | 
|---|
| 85 |                "images/pagination/no-previous.png", | 
|---|
| 86 |                __('Previous page'), | 
|---|
| 87 |                ($this->env > 1) | 
|---|
| 88 |           ); | 
|---|
| 89 |           $htmlNext = $this->getLink( | 
|---|
| 90 |                "next", | 
|---|
| 91 |                sprintf($this->page_url,$this->env+1), | 
|---|
| 92 |                "images/pagination/next.png", | 
|---|
| 93 |                "images/pagination/no-next.png", | 
|---|
| 94 |                __('Next page'), | 
|---|
| 95 |                ($this->env < $this->nb_pages) | 
|---|
| 96 |           ); | 
|---|
| 97 |           $htmlLast = $this->getLink( | 
|---|
| 98 |                "last", | 
|---|
| 99 |                sprintf($this->page_url,$this->nb_pages), | 
|---|
| 100 |                "images/pagination/last.png", | 
|---|
| 101 |                "images/pagination/no-last.png", | 
|---|
| 102 |                __('Last page'), | 
|---|
| 103 |                ($this->env < $this->nb_pages) | 
|---|
| 104 |           ); | 
|---|
| 105 |           $htmlCurrent =  | 
|---|
| 106 |                '<li class="active"><strong>'. | 
|---|
| 107 |                sprintf(__('Page %s / %s'),$this->env,$this->nb_pages). | 
|---|
| 108 |                '</strong></li>'; | 
|---|
| 109 |                 | 
|---|
| 110 |           $htmlDirect =  | 
|---|
| 111 |                ($this->nb_pages > 1 ? | 
|---|
| 112 |                     sprintf('<li class="direct-access">'.__('Direct access page %s'), | 
|---|
| 113 |                          form::field(array($this->var_page),3,10)). | 
|---|
| 114 |                     '<input type="submit" value="'.__('ok').'" class="reset" '. | 
|---|
| 115 |                     'name="ok" />'.$this->form_hidden.'</li>' : ''); | 
|---|
| 116 |            | 
|---|
| 117 |           $res =     | 
|---|
| 118 |                '<form action="'.$this->form_action.'" method="get">'. | 
|---|
| 119 |                '<div class="pager"><ul>'. | 
|---|
| 120 |                $htmlFirst. | 
|---|
| 121 |                $htmlPrev. | 
|---|
| 122 |                $htmlCurrent. | 
|---|
| 123 |                $htmlNext. | 
|---|
| 124 |                $htmlLast. | 
|---|
| 125 |                $htmlDirect. | 
|---|
| 126 |                '</ul>'. | 
|---|
| 127 |                '</div>'. | 
|---|
| 128 |                '</form>' | 
|---|
| 129 |           ; | 
|---|
| 130 |            | 
|---|
| 131 |           return $this->nb_elements > 0 ? $res : ''; | 
|---|
| 132 |      } | 
|---|
| 133 | } | 
|---|
| 134 |  | 
|---|
| 135 | class adminGenericList | 
|---|
| 136 | { | 
|---|
| 137 |      protected $core; | 
|---|
| 138 |      protected $rs; | 
|---|
| 139 |      protected $rs_count; | 
|---|
| 140 |       | 
|---|
| 141 |      public function __construct($core,$rs,$rs_count) | 
|---|
| 142 |      { | 
|---|
| 143 |           $this->core =& $core; | 
|---|
| 144 |           $this->rs =& $rs; | 
|---|
| 145 |           $this->rs_count = $rs_count; | 
|---|
| 146 |           $this->html_prev = __('« prev.'); | 
|---|
| 147 |           $this->html_next = __('next »'); | 
|---|
| 148 |      } | 
|---|
| 149 | } | 
|---|
| 150 |  | 
|---|
| 151 | class adminPostList extends adminGenericList | 
|---|
| 152 | { | 
|---|
| 153 |      public function display($page,$nb_per_page,$enclose_block='',$filter=false) | 
|---|
| 154 |      { | 
|---|
| 155 |           if ($this->rs->isEmpty()) | 
|---|
| 156 |           { | 
|---|
| 157 |                if( $filter ) { | 
|---|
| 158 |                     echo '<p><strong>'.__('No entry matches the filter').'</strong></p>'; | 
|---|
| 159 |                } else { | 
|---|
| 160 |                     echo '<p><strong>'.__('No entry').'</strong></p>'; | 
|---|
| 161 |                } | 
|---|
| 162 |           } | 
|---|
| 163 |           else | 
|---|
| 164 |           { | 
|---|
| 165 |                $pager = new dcPager($page,$this->rs_count,$nb_per_page,10); | 
|---|
| 166 |                $entries = array(); | 
|---|
| 167 |                if (isset($_REQUEST['entries'])) { | 
|---|
| 168 |                     foreach ($_REQUEST['entries'] as $v) { | 
|---|
| 169 |                          $entries[(integer)$v]=true; | 
|---|
| 170 |                     } | 
|---|
| 171 |                } | 
|---|
| 172 |                $html_block = | 
|---|
| 173 |                '<div class="table-outer">'. | 
|---|
| 174 |                '<table>'; | 
|---|
| 175 |                 | 
|---|
| 176 |                if( $filter ) { | 
|---|
| 177 |                     $html_block .= '<caption>'.sprintf(__('List of %s entries match the filter.'), $this->rs_count).'</caption>'; | 
|---|
| 178 |                } else { | 
|---|
| 179 |                     $html_block .= '<caption class="hidden">'.__('Entries list').'</caption>'; | 
|---|
| 180 |                } | 
|---|
| 181 |                           | 
|---|
| 182 |                $html_block .= '<tr>'. | 
|---|
| 183 |                '<th colspan="2" class="first">'.__('Title').'</th>'. | 
|---|
| 184 |                '<th scope="col">'.__('Date').'</th>'. | 
|---|
| 185 |                '<th scope="col">'.__('Category').'</th>'. | 
|---|
| 186 |                '<th scope="col">'.__('Author').'</th>'. | 
|---|
| 187 |                '<th scope="col"><img src="images/comments.png" alt="" title="'.__('Comments').'" /><span class="hidden">'.__('Comments').'</span></th>'. | 
|---|
| 188 |                '<th scope="col"><img src="images/trackbacks.png" alt="" title="'.__('Trackbacks').'" /><span class="hidden">'.__('Trackbacks').'</span></th>'. | 
|---|
| 189 |                '<th scope="col">'.__('Status').'</th>'. | 
|---|
| 190 |                '</tr>%s</table></div>'; | 
|---|
| 191 |                 | 
|---|
| 192 |                if ($enclose_block) { | 
|---|
| 193 |                     $html_block = sprintf($enclose_block,$html_block); | 
|---|
| 194 |                } | 
|---|
| 195 |                 | 
|---|
| 196 |                echo $pager->getLinks(); | 
|---|
| 197 |                 | 
|---|
| 198 |                $blocks = explode('%s',$html_block); | 
|---|
| 199 |                 | 
|---|
| 200 |                echo $blocks[0]; | 
|---|
| 201 |                 | 
|---|
| 202 |                while ($this->rs->fetch()) | 
|---|
| 203 |                { | 
|---|
| 204 |                     echo $this->postLine(isset($entries[$this->rs->post_id])); | 
|---|
| 205 |                } | 
|---|
| 206 |                 | 
|---|
| 207 |                echo $blocks[1]; | 
|---|
| 208 |                 | 
|---|
| 209 |                echo $pager->getLinks(); | 
|---|
| 210 |           } | 
|---|
| 211 |      } | 
|---|
| 212 |       | 
|---|
| 213 |      private function postLine($checked) | 
|---|
| 214 |      { | 
|---|
| 215 |           if ($this->core->auth->check('categories',$this->core->blog->id)) { | 
|---|
| 216 |                $cat_link = '<a href="category.php?id=%s">%s</a>'; | 
|---|
| 217 |           } else { | 
|---|
| 218 |                $cat_link = '%2$s'; | 
|---|
| 219 |           } | 
|---|
| 220 |            | 
|---|
| 221 |           if ($this->rs->cat_title) { | 
|---|
| 222 |                $cat_title = sprintf($cat_link,$this->rs->cat_id, | 
|---|
| 223 |                html::escapeHTML($this->rs->cat_title)); | 
|---|
| 224 |           } else { | 
|---|
| 225 |                $cat_title = __('(No cat)'); | 
|---|
| 226 |           } | 
|---|
| 227 |            | 
|---|
| 228 |           $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; | 
|---|
| 229 |           switch ($this->rs->post_status) { | 
|---|
| 230 |                case 1: | 
|---|
| 231 |                     $img_status = sprintf($img,__('Published'),'check-on.png'); | 
|---|
| 232 |                     break; | 
|---|
| 233 |                case 0: | 
|---|
| 234 |                     $img_status = sprintf($img,__('Unpublished'),'check-off.png'); | 
|---|
| 235 |                     break; | 
|---|
| 236 |                case -1: | 
|---|
| 237 |                     $img_status = sprintf($img,__('Scheduled'),'scheduled.png'); | 
|---|
| 238 |                     break; | 
|---|
| 239 |                case -2: | 
|---|
| 240 |                     $img_status = sprintf($img,__('Pending'),'check-wrn.png'); | 
|---|
| 241 |                     break; | 
|---|
| 242 |           } | 
|---|
| 243 |            | 
|---|
| 244 |           $protected = ''; | 
|---|
| 245 |           if ($this->rs->post_password) { | 
|---|
| 246 |                $protected = sprintf($img,__('Protected'),'locker.png'); | 
|---|
| 247 |           } | 
|---|
| 248 |            | 
|---|
| 249 |           $selected = ''; | 
|---|
| 250 |           if ($this->rs->post_selected) { | 
|---|
| 251 |                $selected = sprintf($img,__('Selected'),'selected.png'); | 
|---|
| 252 |           } | 
|---|
| 253 |            | 
|---|
| 254 |           $attach = ''; | 
|---|
| 255 |           $nb_media = $this->rs->countMedia(); | 
|---|
| 256 |           if ($nb_media > 0) { | 
|---|
| 257 |                $attach_str = $nb_media == 1 ? __('%d attachment') : __('%d attachments'); | 
|---|
| 258 |                $attach = sprintf($img,sprintf($attach_str,$nb_media),'attach.png'); | 
|---|
| 259 |           } | 
|---|
| 260 |            | 
|---|
| 261 |           $res = '<tr class="line'.($this->rs->post_status != 1 ? ' offline' : '').'"'. | 
|---|
| 262 |           ' id="p'.$this->rs->post_id.'">'; | 
|---|
| 263 |            | 
|---|
| 264 |           $res .= | 
|---|
| 265 |           '<td class="nowrap">'. | 
|---|
| 266 |           form::checkbox(array('entries[]'),$this->rs->post_id,$checked,'','',!$this->rs->isEditable()).'</td>'. | 
|---|
| 267 |           '<td class="maximal" scope="row"><a href="'.$this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id).'">'. | 
|---|
| 268 |           html::escapeHTML($this->rs->post_title).'</a></td>'. | 
|---|
| 269 |           '<td class="nowrap count">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->post_dt).'</td>'. | 
|---|
| 270 |           '<td class="nowrap">'.$cat_title.'</td>'. | 
|---|
| 271 |           '<td class="nowrap">'.html::escapeHTML($this->rs->user_id).'</td>'. | 
|---|
| 272 |           '<td class="nowrap count">'.$this->rs->nb_comment.'</td>'. | 
|---|
| 273 |           '<td class="nowrap count">'.$this->rs->nb_trackback.'</td>'. | 
|---|
| 274 |           '<td class="nowrap status">'.$img_status.' '.$selected.' '.$protected.' '.$attach.'</td>'. | 
|---|
| 275 |           '</tr>'; | 
|---|
| 276 |            | 
|---|
| 277 |           return $res; | 
|---|
| 278 |      } | 
|---|
| 279 | } | 
|---|
| 280 |  | 
|---|
| 281 | class adminPostMiniList extends adminGenericList | 
|---|
| 282 | { | 
|---|
| 283 |      public function display($page,$nb_per_page,$enclose_block='') | 
|---|
| 284 |      { | 
|---|
| 285 |           if ($this->rs->isEmpty()) | 
|---|
| 286 |           { | 
|---|
| 287 |                echo '<p><strong>'.__('No entry').'</strong></p>'; | 
|---|
| 288 |           } | 
|---|
| 289 |           else | 
|---|
| 290 |           { | 
|---|
| 291 |                $pager = new dcPager($page,$this->rs_count,$nb_per_page,10); | 
|---|
| 292 |                 | 
|---|
| 293 |                $html_block = | 
|---|
| 294 |                '<div class="table-outer clear">'. | 
|---|
| 295 |                '<table><caption class="hidden">'.__('Entries list').'</caption><tr>'. | 
|---|
| 296 |                '<th scope="col">'.__('Title').'</th>'. | 
|---|
| 297 |                '<th scope="col">'.__('Date').'</th>'. | 
|---|
| 298 |                '<th scope="col">'.__('Author').'</th>'. | 
|---|
| 299 |                '<th scope="col">'.__('Status').'</th>'. | 
|---|
| 300 |                '</tr>%s</table></div>'; | 
|---|
| 301 |                 | 
|---|
| 302 |                if ($enclose_block) { | 
|---|
| 303 |                     $html_block = sprintf($enclose_block,$html_block); | 
|---|
| 304 |                } | 
|---|
| 305 |                 | 
|---|
| 306 |                echo $pager->getLinks(); | 
|---|
| 307 |                 | 
|---|
| 308 |                $blocks = explode('%s',$html_block); | 
|---|
| 309 |                 | 
|---|
| 310 |                echo $blocks[0]; | 
|---|
| 311 |                 | 
|---|
| 312 |                while ($this->rs->fetch()) | 
|---|
| 313 |                { | 
|---|
| 314 |                     echo $this->postLine(); | 
|---|
| 315 |                } | 
|---|
| 316 |                 | 
|---|
| 317 |                echo $blocks[1]; | 
|---|
| 318 |                 | 
|---|
| 319 |                echo $pager->getLinks(); | 
|---|
| 320 |           } | 
|---|
| 321 |      } | 
|---|
| 322 |       | 
|---|
| 323 |      private function postLine() | 
|---|
| 324 |      { | 
|---|
| 325 |           $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; | 
|---|
| 326 |           switch ($this->rs->post_status) { | 
|---|
| 327 |                case 1: | 
|---|
| 328 |                     $img_status = sprintf($img,__('Published'),'check-on.png'); | 
|---|
| 329 |                     break; | 
|---|
| 330 |                case 0: | 
|---|
| 331 |                     $img_status = sprintf($img,__('Unpublished'),'check-off.png'); | 
|---|
| 332 |                     break; | 
|---|
| 333 |                case -1: | 
|---|
| 334 |                     $img_status = sprintf($img,__('Scheduled'),'scheduled.png'); | 
|---|
| 335 |                     break; | 
|---|
| 336 |                case -2: | 
|---|
| 337 |                     $img_status = sprintf($img,__('Pending'),'check-wrn.png'); | 
|---|
| 338 |                     break; | 
|---|
| 339 |           } | 
|---|
| 340 |            | 
|---|
| 341 |           $protected = ''; | 
|---|
| 342 |           if ($this->rs->post_password) { | 
|---|
| 343 |                $protected = sprintf($img,__('Protected'),'locker.png'); | 
|---|
| 344 |           } | 
|---|
| 345 |            | 
|---|
| 346 |           $selected = ''; | 
|---|
| 347 |           if ($this->rs->post_selected) { | 
|---|
| 348 |                $selected = sprintf($img,__('Selected'),'selected.png'); | 
|---|
| 349 |           } | 
|---|
| 350 |            | 
|---|
| 351 |           $attach = ''; | 
|---|
| 352 |           $nb_media = $this->rs->countMedia(); | 
|---|
| 353 |           if ($nb_media > 0) { | 
|---|
| 354 |                $attach_str = $nb_media == 1 ? __('%d attachment') : __('%d attachments'); | 
|---|
| 355 |                $attach = sprintf($img,sprintf($attach_str,$nb_media),'attach.png'); | 
|---|
| 356 |           } | 
|---|
| 357 |            | 
|---|
| 358 |           $res = '<tr class="line'.($this->rs->post_status != 1 ? ' offline' : '').'"'. | 
|---|
| 359 |           ' id="p'.$this->rs->post_id.'">'; | 
|---|
| 360 |            | 
|---|
| 361 |           $res .= | 
|---|
| 362 |           '<td scope="row" class="maximal"><a href="'.$this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id).'" '. | 
|---|
| 363 |           'title="'.html::escapeHTML($this->rs->getURL()).'">'. | 
|---|
| 364 |           html::escapeHTML($this->rs->post_title).'</a></td>'. | 
|---|
| 365 |           '<td class="nowrap count">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->post_dt).'</td>'. | 
|---|
| 366 |           '<td class="nowrap">'.html::escapeHTML($this->rs->user_id).'</td>'. | 
|---|
| 367 |           '<td class="nowrap status">'.$img_status.' '.$selected.' '.$protected.' '.$attach.'</td>'. | 
|---|
| 368 |           '</tr>'; | 
|---|
| 369 |            | 
|---|
| 370 |           return $res; | 
|---|
| 371 |      } | 
|---|
| 372 | } | 
|---|
| 373 |  | 
|---|
| 374 | class adminCommentList extends adminGenericList | 
|---|
| 375 | { | 
|---|
| 376 |      public function display($page,$nb_per_page,$enclose_block='',$filter=false) | 
|---|
| 377 |      { | 
|---|
| 378 |           if ($this->rs->isEmpty()) | 
|---|
| 379 |           { | 
|---|
| 380 |                if( $filter ) { | 
|---|
| 381 |                     echo '<p><strong>'.__('No comments or trackbacks matches the filter').'</strong></p>'; | 
|---|
| 382 |                } else { | 
|---|
| 383 |                     echo '<p><strong>'.__('No comment').'</strong></p>'; | 
|---|
| 384 |                } | 
|---|
| 385 |           } | 
|---|
| 386 |           else | 
|---|
| 387 |           { | 
|---|
| 388 |                $pager = new dcPager($page,$this->rs_count,$nb_per_page,10); | 
|---|
| 389 |                 | 
|---|
| 390 |                $comments = array(); | 
|---|
| 391 |                if (isset($_REQUEST['comments'])) { | 
|---|
| 392 |                     foreach ($_REQUEST['comments'] as $v) { | 
|---|
| 393 |                          $comments[(integer)$v]=true; | 
|---|
| 394 |                     } | 
|---|
| 395 |                }               | 
|---|
| 396 |                $html_block = | 
|---|
| 397 |                '<div class="table-outer">'. | 
|---|
| 398 |                '<table>'; | 
|---|
| 399 |                 | 
|---|
| 400 |                if( $filter ) { | 
|---|
| 401 |                     $html_block .= '<caption>'. | 
|---|
| 402 |                          sprintf(__( | 
|---|
| 403 |                               'Comment or trackback matching the filter.', | 
|---|
| 404 |                               'List of %s comments or trackbacks matching the filter.', | 
|---|
| 405 |                               $this->rs_count), $this->rs_count). | 
|---|
| 406 |                          '</caption>'; | 
|---|
| 407 |                } else { | 
|---|
| 408 |                     $html_block .= '<caption class="hidden">'.__('Comments and trackbacks list').'</caption>'; | 
|---|
| 409 |                } | 
|---|
| 410 |                           | 
|---|
| 411 |                $html_block .= '<tr>'. | 
|---|
| 412 |                '<th colspan="2" scope="col" abbr="comm" class="first">'.__('Type').'</th>'. | 
|---|
| 413 |                '<th scope="col">'.__('Author').'</th>'. | 
|---|
| 414 |                '<th scope="col">'.__('Date').'</th>'. | 
|---|
| 415 |                '<th scope="col" class="txt-center">'.__('Status').'</th>'. | 
|---|
| 416 |                '<th scope="col" abbr="entry">'.__('Entry').'</th>'. | 
|---|
| 417 |                '</tr>%s</table></div>'; | 
|---|
| 418 |  | 
|---|
| 419 |                if ($enclose_block) { | 
|---|
| 420 |                     $html_block = sprintf($enclose_block,$html_block); | 
|---|
| 421 |                } | 
|---|
| 422 |                 | 
|---|
| 423 |                echo $pager->getLinks(); | 
|---|
| 424 |                 | 
|---|
| 425 |                $blocks = explode('%s',$html_block); | 
|---|
| 426 |                 | 
|---|
| 427 |                echo $blocks[0]; | 
|---|
| 428 |                 | 
|---|
| 429 |                while ($this->rs->fetch()) | 
|---|
| 430 |                { | 
|---|
| 431 |                     echo $this->commentLine(isset($comments[$this->rs->comment_id])); | 
|---|
| 432 |                } | 
|---|
| 433 |                 | 
|---|
| 434 |                echo $blocks[1]; | 
|---|
| 435 |                 | 
|---|
| 436 |                echo $pager->getLinks(); | 
|---|
| 437 |           } | 
|---|
| 438 |      } | 
|---|
| 439 |       | 
|---|
| 440 |      private function commentLine($checked=false) | 
|---|
| 441 |      { | 
|---|
| 442 |           global $author, $status, $sortby, $order, $nb_per_page; | 
|---|
| 443 |            | 
|---|
| 444 |           $author_url = | 
|---|
| 445 |           'comments.php?n='.$nb_per_page. | 
|---|
| 446 |           '&status='.$status. | 
|---|
| 447 |           '&sortby='.$sortby. | 
|---|
| 448 |           '&order='.$order. | 
|---|
| 449 |           '&author='.rawurlencode($this->rs->comment_author); | 
|---|
| 450 |            | 
|---|
| 451 |           $post_url = $this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id); | 
|---|
| 452 |            | 
|---|
| 453 |           $comment_url = 'comment.php?id='.$this->rs->comment_id; | 
|---|
| 454 |            | 
|---|
| 455 |           $comment_dt = | 
|---|
| 456 |           dt::dt2str($this->core->blog->settings->system->date_format.' - '. | 
|---|
| 457 |           $this->core->blog->settings->system->time_format,$this->rs->comment_dt); | 
|---|
| 458 |            | 
|---|
| 459 |           $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; | 
|---|
| 460 |           switch ($this->rs->comment_status) { | 
|---|
| 461 |                case 1: | 
|---|
| 462 |                     $img_status = sprintf($img,__('Published'),'check-on.png'); | 
|---|
| 463 |                     break; | 
|---|
| 464 |                case 0: | 
|---|
| 465 |                     $img_status = sprintf($img,__('Unpublished'),'check-off.png'); | 
|---|
| 466 |                     break; | 
|---|
| 467 |                case -1: | 
|---|
| 468 |                     $img_status = sprintf($img,__('Pending'),'check-wrn.png'); | 
|---|
| 469 |                     break; | 
|---|
| 470 |                case -2: | 
|---|
| 471 |                     $img_status = sprintf($img,__('Junk'),'junk.png'); | 
|---|
| 472 |                     break; | 
|---|
| 473 |           } | 
|---|
| 474 |            | 
|---|
| 475 |           $post_title = html::escapeHTML($this->rs->post_title); | 
|---|
| 476 |           if (mb_strlen($post_title) > 70) { | 
|---|
| 477 |                $post_title = mb_strcut($post_title,0,67).'...'; | 
|---|
| 478 |           } | 
|---|
| 479 |           $comment_title = sprintf(__('Edit the %1$s from %2$s'), | 
|---|
| 480 |                $this->rs->comment_trackback ? __('trackback') : __('comment'), | 
|---|
| 481 |                html::escapeHTML($this->rs->comment_author)); | 
|---|
| 482 |            | 
|---|
| 483 |           $res = '<tr class="line'.($this->rs->comment_status != 1 ? ' offline' : '').'"'. | 
|---|
| 484 |           ' id="c'.$this->rs->comment_id.'">'; | 
|---|
| 485 |            | 
|---|
| 486 |           $res .= | 
|---|
| 487 |           '<td class="nowrap">'. | 
|---|
| 488 |           form::checkbox(array('comments[]'),$this->rs->comment_id,$checked,'','',0).'</td>'. | 
|---|
| 489 |           '<td class="nowrap" abbr="'.__('Type and author').'" scope="row">'. | 
|---|
| 490 |                '<a href="'.$comment_url.'" title="'.$comment_title.'">'. | 
|---|
| 491 |                '<img src="images/edit-mini.png" alt="'.__('Edit').'"/> '. | 
|---|
| 492 |                ($this->rs->comment_trackback ? __('trackback') : __('comment')).' '.'</a></td>'. | 
|---|
| 493 |           '<td class="nowrap maximal"><a href="'.$author_url.'">'.html::escapeHTML($this->rs->comment_author).'</a></td>'. | 
|---|
| 494 |           '<td class="nowrap count">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->comment_dt).'</td>'. | 
|---|
| 495 |           '<td class="nowrap status txt-center">'.$img_status.'</td>'. | 
|---|
| 496 |           '<td class="nowrap discrete"><a href="'.$post_url.'">'. | 
|---|
| 497 |           html::escapeHTML($post_title).'</a>'. | 
|---|
| 498 |           ($this->rs->post_type != 'post' ? ' ('.html::escapeHTML($this->rs->post_type).')' : '').'</td>'; | 
|---|
| 499 |            | 
|---|
| 500 |           $res .= '</tr>'; | 
|---|
| 501 |            | 
|---|
| 502 |           return $res; | 
|---|
| 503 |      } | 
|---|
| 504 | } | 
|---|
| 505 |  | 
|---|
| 506 | class adminUserList extends adminGenericList | 
|---|
| 507 | { | 
|---|
| 508 |      public function display($page,$nb_per_page,$enclose_block='',$filter=false) | 
|---|
| 509 |      { | 
|---|
| 510 |           if ($this->rs->isEmpty()) | 
|---|
| 511 |           { | 
|---|
| 512 |                if( $filter ) { | 
|---|
| 513 |                     echo '<p><strong>'.__('No user matches the filter').'</strong></p>'; | 
|---|
| 514 |                } else { | 
|---|
| 515 |                     echo '<p><strong>'.__('No user').'</strong></p>'; | 
|---|
| 516 |                } | 
|---|
| 517 |           } | 
|---|
| 518 |           else | 
|---|
| 519 |           { | 
|---|
| 520 |                $pager = new dcPager($page,$this->rs_count,$nb_per_page,10); | 
|---|
| 521 |                 | 
|---|
| 522 |                $html_block = | 
|---|
| 523 |                '<div class="table-outer clear">'. | 
|---|
| 524 |                '<table>'; | 
|---|
| 525 |                 | 
|---|
| 526 |                if( $filter ) { | 
|---|
| 527 |                     $html_block .= '<caption>'.sprintf(__('List of %s users match the filter.'), $this->rs_count).'</caption>'; | 
|---|
| 528 |                } else { | 
|---|
| 529 |                     $html_block .= '<caption class="hidden">'.__('Users list').'</caption>'; | 
|---|
| 530 |                } | 
|---|
| 531 |                           | 
|---|
| 532 |                $html_block .= '<tr>'. | 
|---|
| 533 |                '<th colspan="2" scope="col" class="first">'.__('Username').'</th>'. | 
|---|
| 534 |                '<th scope="col">'.__('First Name').'</th>'. | 
|---|
| 535 |                '<th scope="col">'.__('Last Name').'</th>'. | 
|---|
| 536 |                '<th scope="col">'.__('Display name').'</th>'. | 
|---|
| 537 |                '<th scope="col" class="nowrap">'.__('Entries (all types)').'</th>'. | 
|---|
| 538 |                '</tr>%s</table></div>'; | 
|---|
| 539 |                 | 
|---|
| 540 |                if ($enclose_block) { | 
|---|
| 541 |                     $html_block = sprintf($enclose_block,$html_block); | 
|---|
| 542 |                } | 
|---|
| 543 |                 | 
|---|
| 544 |                echo $pager->getLinks(); | 
|---|
| 545 |                 | 
|---|
| 546 |                $blocks = explode('%s',$html_block); | 
|---|
| 547 |                 | 
|---|
| 548 |                echo $blocks[0]; | 
|---|
| 549 |                 | 
|---|
| 550 |                while ($this->rs->fetch()) | 
|---|
| 551 |                { | 
|---|
| 552 |                     echo $this->userLine(); | 
|---|
| 553 |                } | 
|---|
| 554 |                 | 
|---|
| 555 |                echo $blocks[1]; | 
|---|
| 556 |                 | 
|---|
| 557 |                echo $pager->getLinks(); | 
|---|
| 558 |           } | 
|---|
| 559 |      } | 
|---|
| 560 |       | 
|---|
| 561 |      private function userLine() | 
|---|
| 562 |      { | 
|---|
| 563 |           $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; | 
|---|
| 564 |           $img_status = ''; | 
|---|
| 565 |            | 
|---|
| 566 |           $p = $this->core->getUserPermissions($this->rs->user_id); | 
|---|
| 567 |            | 
|---|
| 568 |           if (isset($p[$this->core->blog->id]['p']['admin'])) { | 
|---|
| 569 |                $img_status = sprintf($img,__('admin'),'admin.png'); | 
|---|
| 570 |           } | 
|---|
| 571 |           if ($this->rs->user_super) { | 
|---|
| 572 |                $img_status = sprintf($img,__('superadmin'),'superadmin.png'); | 
|---|
| 573 |           } | 
|---|
| 574 |           return | 
|---|
| 575 |           '<tr class="line">'. | 
|---|
| 576 |           '<td class="nowrap">'.form::hidden(array('nb_post[]'),(integer) $this->rs->nb_post). | 
|---|
| 577 |           form::checkbox(array('users[]'),$this->rs->user_id).'</td>'. | 
|---|
| 578 |           '<td class="maximal" scope="row"><a href="user.php?id='.$this->rs->user_id.'">'. | 
|---|
| 579 |           $this->rs->user_id.'</a> '.$img_status.'</td>'. | 
|---|
| 580 |           '<td class="nowrap">'.html::escapeHTML($this->rs->user_firstname).'</td>'. | 
|---|
| 581 |           '<td class="nowrap">'.html::escapeHTML($this->rs->user_name).'</td>'. | 
|---|
| 582 |           '<td class="nowrap">'.html::escapeHTML($this->rs->user_displayname).'</td>'. | 
|---|
| 583 |           '<td class="nowrap count"><a href="posts.php?user_id='.$this->rs->user_id.'">'. | 
|---|
| 584 |           $this->rs->nb_post.'</a></td>'. | 
|---|
| 585 |           '</tr>'; | 
|---|
| 586 |      } | 
|---|
| 587 | } | 
|---|