| Current Path : /home/magalijoj/www/blog/inc/admin/ |
| Current File : /home/magalijoj/www/blog/inc/admin/lib.pager.php |
<?php
# ***** BEGIN LICENSE BLOCK *****
# This file is part of DotClear.
# Copyright (c) 2005 Olivier Meunier and contributors. All rights
# reserved.
#
# DotClear is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# DotClear is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with DotClear; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# ***** END LICENSE BLOCK *****
class adminGenericList
{
protected $core;
protected $rs;
protected $rs_count;
public function __construct(&$core,&$rs,$rs_count)
{
$this->core =& $core;
$this->rs =& $rs;
$this->rs_count = $rs_count;
}
}
class adminPostList extends adminGenericList
{
public function display($page,$nb_per_page,$enclose_block='')
{
if ($this->rs->isEmpty())
{
echo '<p><strong>'.__('No entry').'</strong></p>';
}
else
{
$pager = new pager($page,$this->rs_count,$nb_per_page,10);
$pager->var_page = 'page';
$html_block =
'<table class="clear"><tr>'.
'<th colspan="2">'.__('Title').'</th>'.
'<th>'.__('Date').'</th>'.
'<th>'.__('Category').'</th>'.
'<th>'.__('Author').'</th>'.
'<th>'.__('Comments').'</th>'.
'<th>'.__('Trackbacks').'</th>'.
'<th>'.__('Status').'</th>'.
'</tr>%s</table>';
if ($enclose_block) {
$html_block = sprintf($enclose_block,$html_block);
}
echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>';
$blocks = explode('%s',$html_block);
echo $blocks[0];
while ($this->rs->fetch())
{
echo $this->postLine();
}
echo $blocks[1];
echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>';
}
}
private function postLine()
{
if ($this->core->auth->check('categories',$this->core->blog->id)) {
$cat_link = '<a href="category.php?id=%s">%s</a>';
} else {
$cat_link = '%2$s';
}
if ($this->rs->cat_title) {
$cat_title = sprintf($cat_link,$this->rs->cat_id,
html::escapeHTML($this->rs->cat_title));
} else {
$cat_title = __('None');
}
$img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />';
switch ($this->rs->post_status) {
case 1:
$img_status = sprintf($img,__('published'),'check-on.png');
break;
case 0:
$img_status = sprintf($img,__('unpublished'),'check-off.png');
break;
case -1:
$img_status = sprintf($img,__('scheduled'),'scheduled.png');
break;
case -2:
$img_status = sprintf($img,__('pending'),'check-wrn.png');
break;
}
$protected = '';
if ($this->rs->post_password) {
$protected = sprintf($img,__('protected'),'locker.png');
}
$selected = '';
if ($this->rs->post_selected) {
$selected = sprintf($img,__('selected'),'selected.png');
}
$attach = '';
$nb_media = $this->rs->countMedia();
if ($nb_media > 0) {
$attach_str = $nb_media == 1 ? __('%d attachment') : __('%d attachments');
$attach = sprintf($img,sprintf($attach_str,$nb_media),'attach.png');
}
$res = '<tr class="line'.($this->rs->post_status != 1 ? ' offline' : '').'"'.
' id="p'.$this->rs->post_id.'">';
$res .=
'<td class="nowrap">'.
form::checkbox(array('entries[]'),$this->rs->post_id,'','','',!$this->rs->isEditable()).'</td>'.
'<td class="maximal"><a href="post.php?id='.$this->rs->post_id.'">'.
html::escapeHTML($this->rs->post_title).'</a></td>'.
'<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->post_dt).'</td>'.
'<td class="nowrap">'.$cat_title.'</td>'.
'<td class="nowrap">'.$this->rs->user_id.'</td>'.
'<td class="nowrap">'.$this->rs->nb_comment.'</td>'.
'<td class="nowrap">'.$this->rs->nb_trackback.'</td>'.
'<td class="nowrap status">'.$img_status.' '.$selected.' '.$protected.' '.$attach.'</td>'.
'</tr>';
return $res;
}
}
class adminCommentList extends adminGenericList
{
public function display($page,$nb_per_page,$enclose_block='')
{
if ($this->rs->isEmpty())
{
echo '<p><strong>'.__('No comment').'</strong></p>';
}
else
{
$pager = new pager($page,$this->rs_count,$nb_per_page,10);
$pager->var_page = 'page';
$html_block =
'<table><tr>'.
'<th colspan="2">'.__('Entry title').'</th>'.
'<th>'.__('Date').'</th>'.
'<th>'.__('Author').'</th>'.
'<th>'.__('Type').'</th>'.
'<th>'.__('Status').'</th>'.
'<th> </th>'.
'</tr>%s</table>';
if ($enclose_block) {
$html_block = sprintf($enclose_block,$html_block);
}
echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>';
$blocks = explode('%s',$html_block);
echo $blocks[0];
while ($this->rs->fetch())
{
echo $this->commentLine();
}
echo $blocks[1];
echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>';
}
}
private function commentLine()
{
global $author, $status, $sortby, $order, $nb_per_page;
$author_url =
'comments.php?n='.$nb_per_page.
'&status='.$status.
'&sortby='.$sortby.
'&order='.$order.
'&author='.rawurlencode($this->rs->comment_author);
$post_url = 'post.php?id='.$this->rs->post_id;
$comment_url = 'comment.php?id='.$this->rs->comment_id;
$comment_dt =
dt::dt2str($this->core->blog->settings->date_format.' - '.
$this->core->blog->settings->time_format,$this->rs->comment_dt);
$img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />';
switch ($this->rs->comment_status) {
case 1:
$img_status = sprintf($img,__('published'),'check-on.png');
break;
case 0:
$img_status = sprintf($img,__('unpublished'),'check-off.png');
break;
case -1:
$img_status = sprintf($img,__('pending'),'check-wrn.png');
break;
case -2:
$img_status = sprintf($img,__('junk'),'junk.png');
break;
}
$comment_author = html::escapeHTML($this->rs->comment_author);
if (mb_strlen($comment_author) > 20) {
$comment_author = mb_strcut($comment_author,0,17).'...';
}
$res = '<tr class="line'.($this->rs->comment_status != 1 ? ' offline' : '').'"'.
' id="c'.$this->rs->comment_id.'">';
$res .=
'<td class="nowrap">'.
form::checkbox(array('comments[]'),$this->rs->comment_id,'','','',0).'</td>'.
'<td class="maximal"><a href="'.$post_url.'">'.
html::escapeHTML($this->rs->post_title).'</a></td>'.
'<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->comment_dt).'</td>'.
'<td class="nowrap"><a href="'.$author_url.'">'.$comment_author.'</a></td>'.
'<td class="nowrap">'.($this->rs->comment_trackback ? __('trackback') : __('comment')).'</td>'.
'<td class="nowrap status">'.$img_status.'</td>'.
'<td class="nowrap status"><a href="'.$comment_url.'">'.
'<img src="images/edit-mini.png" alt="" title="'.__('Edit this comment').'" /></a></td>';
$res .= '</tr>';
return $res;
}
}
class adminUserList extends adminGenericList
{
public function display($page,$nb_per_page,$enclose_block='')
{
if ($this->rs->isEmpty())
{
echo '<p><strong>'.__('No user').'</strong></p>';
}
else
{
$pager = new pager($page,$this->rs_count,$nb_per_page,10);
$pager->var_page = 'page';
$html_block =
'<table class="clear"><tr>'.
'<th colspan="2">'.__('User ID').'</th>'.
'<th>'.__('Firstname').'</th>'.
'<th>'.__('Name').'</th>'.
'<th>'.__('Display name').'</th>'.
'<th class="nowrap">'.__('Entries').'</th>'.
'</tr>%s</table>';
if ($enclose_block) {
$html_block = sprintf($enclose_block,$html_block);
}
echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>';
$blocks = explode('%s',$html_block);
echo $blocks[0];
while ($this->rs->fetch())
{
echo $this->userLine();
}
echo $blocks[1];
echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>';
}
}
private function userLine()
{
return
'<tr class="line">'.
'<td class="nowrap">'.form::hidden(array('nb_post[]'),(integer) $this->rs->nb_post).
form::checkbox(array('user_id[]'),$this->rs->user_id).'</td>'.
'<td class="maximal"><a href="user.php?id='.$this->rs->user_id.'">'.
$this->rs->user_id.'</a></td>'.
'<td class="nowrap">'.$this->rs->user_firstname.'</td>'.
'<td class="nowrap">'.$this->rs->user_name.'</td>'.
'<td class="nowrap">'.$this->rs->user_displayname.'</td>'.
'<td class="nowrap">'.$this->rs->nb_post.'</td>'.
'</tr>';
}
}
?>