| [ Index ] |
|
Code source de Dotclear 2.0-beta6 |
1 <?php 2 # ***** BEGIN LICENSE BLOCK ***** 3 # This file is part of DotClear. 4 # Copyright (c) 2005 Olivier Meunier and contributors. All rights 5 # reserved. 6 # 7 # DotClear is free software; you can redistribute it and/or modify 8 # it under the terms of the GNU General Public License as published by 9 # the Free Software Foundation; either version 2 of the License, or 10 # (at your option) any later version. 11 # 12 # DotClear is distributed in the hope that it will be useful, 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 # GNU General Public License for more details. 16 # 17 # You should have received a copy of the GNU General Public License 18 # along with DotClear; if not, write to the Free Software 19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 # 21 # ***** END LICENSE BLOCK ***** 22 23 class adminGenericList 24 { 25 protected $core; 26 protected $rs; 27 protected $rs_count; 28 29 public function __construct(&$core,&$rs,$rs_count) 30 { 31 $this->core =& $core; 32 $this->rs =& $rs; 33 $this->rs_count = $rs_count; 34 } 35 } 36 37 class adminPostList extends adminGenericList 38 { 39 public function display($page,$nb_per_page,$enclose_block='') 40 { 41 if ($this->rs->isEmpty()) 42 { 43 echo '<p><strong>'.__('No entry').'</strong></p>'; 44 } 45 else 46 { 47 $pager = new pager($page,$this->rs_count,$nb_per_page,10); 48 $pager->var_page = 'page'; 49 50 $html_block = 51 '<table class="clear"><tr>'. 52 '<th colspan="2">'.__('Title').'</th>'. 53 '<th>'.__('Date').'</th>'. 54 '<th>'.__('Category').'</th>'. 55 '<th>'.__('Author').'</th>'. 56 '<th>'.__('Comments').'</th>'. 57 '<th>'.__('Trackbacks').'</th>'. 58 '<th>'.__('Status').'</th>'. 59 '</tr>%s</table>'; 60 61 if ($enclose_block) { 62 $html_block = sprintf($enclose_block,$html_block); 63 } 64 65 echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>'; 66 67 $blocks = explode('%s',$html_block); 68 69 echo $blocks[0]; 70 71 while ($this->rs->fetch()) 72 { 73 echo $this->postLine(); 74 } 75 76 echo $blocks[1]; 77 78 echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>'; 79 } 80 } 81 82 private function postLine() 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 { 94 $cat_title = __('None'); 95 } 96 97 $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; 98 switch ($this->rs->post_status) { 99 case 1: 100 $img_status = sprintf($img,__('published'),'check-on.png'); 101 break; 102 case 0: 103 $img_status = sprintf($img,__('unpublished'),'check-off.png'); 104 break; 105 case -1: 106 $img_status = sprintf($img,__('scheduled'),'scheduled.png'); 107 break; 108 case -2: 109 $img_status = sprintf($img,__('pending'),'check-wrn.png'); 110 break; 111 } 112 113 $protected = ''; 114 if ($this->rs->post_password) { 115 $protected = sprintf($img,__('protected'),'locker.png'); 116 } 117 118 $selected = ''; 119 if ($this->rs->post_selected) { 120 $selected = sprintf($img,__('selected'),'selected.png'); 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">'. 135 form::checkbox(array('entries[]'),$this->rs->post_id,'','','',!$this->rs->isEditable()).'</td>'. 136 '<td class="maximal"><a href="post.php?id='.$this->rs->post_id.'">'. 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>'. 140 '<td class="nowrap">'.$this->rs->user_id.'</td>'. 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 adminCommentList 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 comment').'</strong></p>'; 157 } 158 else 159 { 160 $pager = new pager($page,$this->rs_count,$nb_per_page,10); 161 $pager->var_page = 'page'; 162 163 $html_block = 164 '<table><tr>'. 165 '<th colspan="2">'.__('Entry title').'</th>'. 166 '<th>'.__('Date').'</th>'. 167 '<th>'.__('Author').'</th>'. 168 '<th>'.__('Type').'</th>'. 169 '<th>'.__('Status').'</th>'. 170 '<th> </th>'. 171 '</tr>%s</table>'; 172 173 if ($enclose_block) { 174 $html_block = sprintf($enclose_block,$html_block); 175 } 176 177 echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>'; 178 179 $blocks = explode('%s',$html_block); 180 181 echo $blocks[0]; 182 183 while ($this->rs->fetch()) 184 { 185 echo $this->commentLine(); 186 } 187 188 echo $blocks[1]; 189 190 echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>'; 191 } 192 } 193 194 private function commentLine() 195 { 196 global $author, $status, $sortby, $order, $nb_per_page; 197 198 $author_url = 199 'comments.php?n='.$nb_per_page. 200 '&status='.$status. 201 '&sortby='.$sortby. 202 '&order='.$order. 203 '&author='.rawurlencode($this->rs->comment_author); 204 205 $post_url = 'post.php?id='.$this->rs->post_id; 206 207 $comment_url = 'comment.php?id='.$this->rs->comment_id; 208 209 $comment_dt = 210 dt::dt2str($this->core->blog->settings->date_format.' - '. 211 $this->core->blog->settings->time_format,$this->rs->comment_dt); 212 213 $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; 214 switch ($this->rs->comment_status) { 215 case 1: 216 $img_status = sprintf($img,__('published'),'check-on.png'); 217 break; 218 case 0: 219 $img_status = sprintf($img,__('unpublished'),'check-off.png'); 220 break; 221 case -1: 222 $img_status = sprintf($img,__('pending'),'check-wrn.png'); 223 break; 224 case -2: 225 $img_status = sprintf($img,__('junk'),'junk.png'); 226 break; 227 } 228 229 $comment_author = html::escapeHTML($this->rs->comment_author); 230 if (mb_strlen($comment_author) > 20) { 231 $comment_author = mb_strcut($comment_author,0,17).'...'; 232 } 233 234 $res = '<tr class="line'.($this->rs->comment_status != 1 ? ' offline' : '').'"'. 235 ' id="c'.$this->rs->comment_id.'">'; 236 237 $res .= 238 '<td class="nowrap">'. 239 form::checkbox(array('comments[]'),$this->rs->comment_id,'','','',0).'</td>'. 240 '<td class="maximal"><a href="'.$post_url.'">'. 241 html::escapeHTML($this->rs->post_title).'</a></td>'. 242 '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->comment_dt).'</td>'. 243 '<td class="nowrap"><a href="'.$author_url.'">'.$comment_author.'</a></td>'. 244 '<td class="nowrap">'.($this->rs->comment_trackback ? __('trackback') : __('comment')).'</td>'. 245 '<td class="nowrap status">'.$img_status.'</td>'. 246 '<td class="nowrap status"><a href="'.$comment_url.'">'. 247 '<img src="images/edit-mini.png" alt="" title="'.__('Edit this comment').'" /></a></td>'; 248 249 $res .= '</tr>'; 250 251 return $res; 252 } 253 } 254 255 class adminUserList extends adminGenericList 256 { 257 public function display($page,$nb_per_page,$enclose_block='') 258 { 259 if ($this->rs->isEmpty()) 260 { 261 echo '<p><strong>'.__('No user').'</strong></p>'; 262 } 263 else 264 { 265 $pager = new pager($page,$this->rs_count,$nb_per_page,10); 266 $pager->var_page = 'page'; 267 268 $html_block = 269 '<table class="clear"><tr>'. 270 '<th colspan="2">'.__('User ID').'</th>'. 271 '<th>'.__('Firstname').'</th>'. 272 '<th>'.__('Name').'</th>'. 273 '<th>'.__('Display name').'</th>'. 274 '<th class="nowrap">'.__('Entries').'</th>'. 275 '</tr>%s</table>'; 276 277 if ($enclose_block) { 278 $html_block = sprintf($enclose_block,$html_block); 279 } 280 281 echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>'; 282 283 $blocks = explode('%s',$html_block); 284 285 echo $blocks[0]; 286 287 while ($this->rs->fetch()) 288 { 289 echo $this->userLine(); 290 } 291 292 echo $blocks[1]; 293 294 echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>'; 295 } 296 } 297 298 private function userLine() 299 { 300 return 301 '<tr class="line">'. 302 '<td class="nowrap">'.form::hidden(array('nb_post[]'),(integer) $this->rs->nb_post). 303 form::checkbox(array('user_id[]'),$this->rs->user_id).'</td>'. 304 '<td class="maximal"><a href="user.php?id='.$this->rs->user_id.'">'. 305 $this->rs->user_id.'</a></td>'. 306 '<td class="nowrap">'.$this->rs->user_firstname.'</td>'. 307 '<td class="nowrap">'.$this->rs->user_name.'</td>'. 308 '<td class="nowrap">'.$this->rs->user_displayname.'</td>'. 309 '<td class="nowrap">'.$this->rs->nb_post.'</td>'. 310 '</tr>'; 311 } 312 } 313 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Fri Feb 23 22:16:06 2007 | par Balluche grâce à PHPXref 0.7 |