%s'; return sprintf ($formatter, $li_class,$href,$img_src,$img_alt,$img_alt); } else { $formatter = ''; return sprintf ($formatter, $li_class,$img_src_nolink,$img_alt,$img_alt); } } public function setURL() { parent::setURL(); $url = parse_url($_SERVER['REQUEST_URI']); if (isset($url['query'])) { parse_str($url['query'],$args); } else { $args=array(); } # Removing session information if (session_id()) { if (isset($args[session_name()])) unset($args[session_name()]); } if (isset($args[$this->var_page])) { unset($args[$this->var_page]); } if (isset($args['ok'])) { unset($args['ok']); } $this->form_hidden = ''; foreach ($args as $k=>$v) { if (is_array($v)) { foreach ($v as $k2=>$v2) { $this->form_hidden .= form::hidden(array($k.'[]'),html::escapeHTML($v2)); } } else { $this->form_hidden .= form::hidden(array($k),html::escapeHTML($v)); } } $this->form_action = $url['path']; } /** * Pager Links * * Returns pager links * * @return string */ public function getLinks() { $this->setURL(); $htmlFirst = $this->getLink( "first", sprintf($this->page_url,1), "images/pagination/first.png", "images/pagination/no-first.png", __('First page'), ($this->env > 1) ); $htmlPrev = $this->getLink( "prev", sprintf($this->page_url,$this->env-1), "images/pagination/previous.png", "images/pagination/no-previous.png", __('Previous page'), ($this->env > 1) ); $htmlNext = $this->getLink( "next", sprintf($this->page_url,$this->env+1), "images/pagination/next.png", "images/pagination/no-next.png", __('Next page'), ($this->env < $this->nb_pages) ); $htmlLast = $this->getLink( "last", sprintf($this->page_url,$this->nb_pages), "images/pagination/last.png", "images/pagination/no-last.png", __('Last page'), ($this->env < $this->nb_pages) ); $htmlCurrent = '
  • '. sprintf(__('Page %s / %s'),$this->env,$this->nb_pages). '
  • '; $htmlDirect = ($this->nb_pages > 1 ? sprintf('
  • '.__('Direct access page %s'), form::field(array($this->var_page),3,10)). ''.$this->form_hidden.'
  • ' : ''); $res = '
    '. '
    '. '
    '. '
    ' ; return $this->nb_elements > 0 ? $res : ''; } } 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; $this->html_prev = __('« prev.'); $this->html_next = __('next »'); } public function userColumns($type,$cols) { $cols_user = @$this->core->auth->user_prefs->interface->cols; if (is_array($cols_user)) { if (isset($cols_user[$type])) { foreach ($cols_user[$type] as $cn => $cd) { if (!$cd && isset($cols[$cn])) { unset($cols[$cn]); } } } } } } class adminPostList extends adminGenericList { public function display($page,$nb_per_page,$enclose_block='',$filter=false) { if ($this->rs->isEmpty()) { if( $filter ) { echo '

    '.__('No entry matches the filter').'

    '; } else { echo '

    '.__('No entry').'

    '; } } else { $pager = new dcPager($page,$this->rs_count,$nb_per_page,10); $entries = array(); if (isset($_REQUEST['entries'])) { foreach ($_REQUEST['entries'] as $v) { $entries[(integer)$v]=true; } } $html_block = '
    '. ''; if( $filter ) { $html_block .= ''; } else { $nb_published = $this->core->blog->getPosts(array('post_status' => 1),true)->f(0); $nb_pending = $this->core->blog->getPosts(array('post_status' => -2),true)->f(0); $nb_programmed = $this->core->blog->getPosts(array('post_status' => -1),true)->f(0); $nb_unpublished = $this->core->blog->getPosts(array('post_status' => 0),true)->f(0); $html_block .= ''; } $cols = array( 'title' => '', 'date' => '', 'category' => '', 'author' => '', 'comments' => '', 'trackbacks' => '', 'status' => '' ); $cols = new ArrayObject($cols); $this->core->callBehavior('adminPostListHeader',$this->core,$this->rs,$cols); // Cope with optional columns $this->userColumns('posts',$cols); $html_block .= ''.implode(iterator_to_array($cols)).'%s
    '.sprintf(__('List of %s entries matching the filter.'), $this->rs_count).''. sprintf(__('List of entries (%s)'),$this->rs_count). ($nb_published ? sprintf( __(', published (1)',', published (%s)',$nb_published), $this->core->adminurl->get('admin.posts',array('status' => 1)), $nb_published) : ''). ($nb_pending ? sprintf( __(', pending (1)',', pending (%s)',$nb_pending), $this->core->adminurl->get('admin.posts',array('status' => -2)), $nb_pending) : ''). ($nb_programmed ? sprintf(__(', programmed (1)',', programmed (%s)',$nb_programmed), $this->core->adminurl->get('admin.posts',array('status' => -1)), $nb_programmed) : ''). ($nb_unpublished ? sprintf(__(', unpublished (1)',', unpublished (%s)',$nb_unpublished), $this->core->adminurl->get('admin.posts',array('status' => 0)), $nb_unpublished) : ''). '
    '.__('Title').''.__('Date').''.__('Category').''.__('Author').''.__('Status').'
    '; if ($enclose_block) { $html_block = sprintf($enclose_block,$html_block); } echo $pager->getLinks(); $blocks = explode('%s',$html_block); echo $blocks[0]; while ($this->rs->fetch()) { echo $this->postLine(isset($entries[$this->rs->post_id])); } echo $blocks[1]; echo $pager->getLinks(); } } private function postLine($checked) { if ($this->core->auth->check('categories',$this->core->blog->id)) { $cat_link = '%s'; } 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 = __('(No cat)'); } $img = '%1$s'; $sts_class = ''; switch ($this->rs->post_status) { case 1: $img_status = sprintf($img,__('Published'),'check-on.png'); $sts_class = 'sts-online'; break; case 0: $img_status = sprintf($img,__('Unpublished'),'check-off.png'); $sts_class = 'sts-offline'; break; case -1: $img_status = sprintf($img,__('Scheduled'),'scheduled.png'); $sts_class = 'sts-scheduled'; break; case -2: $img_status = sprintf($img,__('Pending'),'check-wrn.png'); $sts_class = 'sts-pending'; 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 = ''; $cols = array( 'check' => ''. form::checkbox(array('entries[]'),$this->rs->post_id,$checked,'','',!$this->rs->isEditable()). '', 'title' => ''. html::escapeHTML($this->rs->post_title).'', 'date' => ''.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->post_dt).'', 'category' => ''.$cat_title.'', 'author' => ''.html::escapeHTML($this->rs->user_id).'', 'comments' => ''.$this->rs->nb_comment.'', 'trackbacks' => ''.$this->rs->nb_trackback.'', 'status' => ''.$img_status.' '.$selected.' '.$protected.' '.$attach.'' ); $cols = new ArrayObject($cols); $this->core->callBehavior('adminPostListValue',$this->core,$this->rs,$cols); // Cope with optional columns $this->userColumns('posts',$cols); $res .= implode(iterator_to_array($cols)); $res .= ''; return $res; } } class adminPostMiniList extends adminGenericList { public function display($page,$nb_per_page,$enclose_block='') { if ($this->rs->isEmpty()) { echo '

    '.__('No entry').'

    '; } else { $pager = new dcPager($page,$this->rs_count,$nb_per_page,10); $html_block = '
    '. ''; $cols = array( 'title' => '', 'date' => '', 'author' => '', 'status' => '' ); $cols = new ArrayObject($cols); $this->core->callBehavior('adminPostMiniListHeader',$this->core,$this->rs,$cols); // Cope with optional columns $this->userColumns('posts',$cols); $html_block .= ''.implode(iterator_to_array($cols)).'%s
    '.__('Title').''.__('Date').''.__('Author').''.__('Status').'
    '; if ($enclose_block) { $html_block = sprintf($enclose_block,$html_block); } echo $pager->getLinks(); $blocks = explode('%s',$html_block); echo $blocks[0]; while ($this->rs->fetch()) { echo $this->postLine(); } echo $blocks[1]; echo $pager->getLinks(); } } private function postLine() { $img = '%1$s'; $sts_class = ''; switch ($this->rs->post_status) { case 1: $img_status = sprintf($img,__('Published'),'check-on.png'); $sts_class = 'sts-online'; break; case 0: $img_status = sprintf($img,__('Unpublished'),'check-off.png'); $sts_class = 'sts-offline'; break; case -1: $img_status = sprintf($img,__('Scheduled'),'scheduled.png'); $sts_class = 'sts-scheduled'; break; case -2: $img_status = sprintf($img,__('Pending'),'check-wrn.png'); $sts_class = 'sts-pending'; 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 = ''; $cols = array( 'title' => ''. html::escapeHTML($this->rs->post_title).'', 'date' => ''.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->post_dt).'', 'author' => ''.html::escapeHTML($this->rs->user_id).'', 'status' => ''.$img_status.' '.$selected.' '.$protected.' '.$attach.'' ); $cols = new ArrayObject($cols); $this->core->callBehavior('adminPostMiniListValue',$this->core,$this->rs,$cols); // Cope with optional columns $this->userColumns('posts',$cols); $res .= implode(iterator_to_array($cols)); $res .= ''; return $res; } } class adminCommentList extends adminGenericList { public function display($page,$nb_per_page,$enclose_block='',$filter=false,$spam=false) { if ($this->rs->isEmpty()) { if( $filter ) { echo '

    '.__('No comments or trackbacks matches the filter').'

    '; } else { echo '

    '.__('No comments').'

    '; } } else { // Get antispam filters' name $filters = array(); if ($spam) { if (class_exists('dcAntispam')) { dcAntispam::initFilters(); $fs = dcAntispam::$filters->getFilters(); foreach ($fs as $fid => $f) { $filters[$fid] = $f->name; } } } $pager = new dcPager($page,$this->rs_count,$nb_per_page,10); $comments = array(); if (isset($_REQUEST['comments'])) { foreach ($_REQUEST['comments'] as $v) { $comments[(integer)$v]=true; } } $html_block = '
    '. ''; if( $filter ) { $html_block .= ''; } else { $nb_published = $this->core->blog->getComments(array('comment_status' => 1),true)->f(0); $nb_spam = $this->core->blog->getComments(array('comment_status' => -2),true)->f(0); $nb_pending = $this->core->blog->getComments(array('comment_status' => -1),true)->f(0); $nb_unpublished = $this->core->blog->getComments(array('comment_status' => 0),true)->f(0); $html_block .= ''; } $cols = array( 'type' => '', 'author' => '', 'date' => '', 'status' => '' ); if ($spam) { $cols['ip'] = ''; $cols['spam_filter'] = ''; } $cols['entry'] = ''; $cols = new ArrayObject($cols); $this->core->callBehavior('adminCommentListHeader',$this->core,$this->rs,$cols); $html_block .= ''.implode(iterator_to_array($cols)).'%s
    '. sprintf(__( 'Comment or trackback matching the filter.', 'List of %s comments or trackbacks matching the filter.', $this->rs_count), $this->rs_count). ''. sprintf(__('List of comments and trackbacks (%s)'),$this->rs_count). ($nb_published ? sprintf( __(', published (1)',', published (%s)',$nb_published), $this->core->adminurl->get('admin.comments',array('status' => 1)), $nb_published) : ''). ($nb_spam ? sprintf( __(', spam (1)',', spam (%s)',$nb_spam), $this->core->adminurl->get('admin.comments',array('status' => -2)), $nb_spam) : ''). ($nb_pending ? sprintf(__(', pending (1)',', pending (%s)',$nb_pending), $this->core->adminurl->get('admin.comments',array('status' => -1)), $nb_pending) : ''). ($nb_unpublished ? sprintf(__(', unpublished (1)',', unpublished (%s)',$nb_unpublished), $this->core->adminurl->get('admin.comments',array('status' => 0)), $nb_unpublished) : ''). '
    '.__('Type').''.__('Author').''.__('Date').''.__('Status').''.__('IP').''.__('Spam filter').''.__('Entry').'
    '; if ($enclose_block) { $html_block = sprintf($enclose_block,$html_block); } echo $pager->getLinks(); $blocks = explode('%s',$html_block); echo $blocks[0]; while ($this->rs->fetch()) { echo $this->commentLine(isset($comments[$this->rs->comment_id]),$spam,$filters); } echo $blocks[1]; echo $pager->getLinks(); } } private function commentLine($checked=false,$spam=false,$filters=array()) { global $core, $author, $status, $sortby, $order, $nb_per_page; $author_url = $this->core->adminurl->get('admin.comments',array( 'n' => $nb_per_page, 'status' => $status, 'sortby' => $sortby, 'order' => $order, 'author' => $this->rs->comment_author )); $post_url = $this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id); $comment_url = $this->core->adminurl->get('admin.comment',array('id' => $this->rs->comment_id)); $comment_dt = dt::dt2str($this->core->blog->settings->system->date_format.' - '. $this->core->blog->settings->system->time_format,$this->rs->comment_dt); $img = '%1$s'; $sts_class = ''; switch ($this->rs->comment_status) { case 1: $img_status = sprintf($img,__('Published'),'check-on.png'); $sts_class = 'sts-online'; break; case 0: $img_status = sprintf($img,__('Unpublished'),'check-off.png'); $sts_class = 'sts-offline'; break; case -1: $img_status = sprintf($img,__('Pending'),'check-wrn.png'); $sts_class = 'sts-pending'; break; case -2: $img_status = sprintf($img,__('Junk'),'junk.png'); $sts_class = 'sts-junk'; break; } $post_title = html::escapeHTML($this->rs->post_title); if (mb_strlen($post_title) > 70) { $post_title = mb_strcut($post_title,0,67).'...'; } $comment_title = sprintf(__('Edit the %1$s from %2$s'), $this->rs->comment_trackback ? __('trackback') : __('comment'), html::escapeHTML($this->rs->comment_author)); $res = ''; $cols = array( 'check' => ''. form::checkbox(array('comments[]'),$this->rs->comment_id,$checked,'','',0).'', 'type' => ''. ''. ''.__('Edit').' '. ($this->rs->comment_trackback ? __('trackback') : __('comment')).' '.'', 'author' => ''. html::escapeHTML($this->rs->comment_author).'', 'date' => ''.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->comment_dt).'', 'status' => ''.$img_status.'' ); if ($spam) { $filter_name = ''; if ($this->rs->comment_spam_filter) { if (isset($filters[$this->rs->comment_spam_filter])) { $filter_name = $filters[$this->rs->comment_spam_filter]; } else { $filter_name = $this->rs->comment_spam_filter; } } $cols['ip'] = ' $this->rs->comment_ip)).'">'. $this->rs->comment_ip.''; $cols['spam_filter'] = ''.$filter_name.''; } $cols['entry'] = ''.$post_title.''. ($this->rs->post_type != 'post' ? ' ('.html::escapeHTML($this->rs->post_type).')' : '').''; $cols = new ArrayObject($cols); $this->core->callBehavior('adminCommentListValue',$this->core,$this->rs,$cols); $res .= implode(iterator_to_array($cols)); $res .= ''; return $res; } } class adminUserList extends adminGenericList { public function display($page,$nb_per_page,$enclose_block='',$filter=false) { if ($this->rs->isEmpty()) { if( $filter ) { echo '

    '.__('No user matches the filter').'

    '; } else { echo '

    '.__('No user').'

    '; } } else { $pager = new dcPager($page,$this->rs_count,$nb_per_page,10); $html_block = '
    '. ''; if( $filter ) { $html_block .= ''; } else { $html_block .= ''; } $cols = array( 'username' => '', 'first_name' => '', 'last_name' => '', 'display_name' => '', 'entries' => '' ); $cols = new ArrayObject($cols); $this->core->callBehavior('adminUserListHeader',$this->core,$this->rs,$cols); $html_block .= ''.implode(iterator_to_array($cols)).'%s
    '.sprintf(__('List of %s users match the filter.'), $this->rs_count).'
    '.__('Username').''.__('First Name').''.__('Last Name').''.__('Display name').''.__('Entries (all types)').'
    '; if ($enclose_block) { $html_block = sprintf($enclose_block,$html_block); } echo $pager->getLinks(); $blocks = explode('%s',$html_block); echo $blocks[0]; while ($this->rs->fetch()) { echo $this->userLine(); } echo $blocks[1]; echo $pager->getLinks(); } } private function userLine() { $img = '%1$s'; $img_status = ''; $p = $this->core->getUserPermissions($this->rs->user_id); if (isset($p[$this->core->blog->id]['p']['admin'])) { $img_status = sprintf($img,__('admin'),'admin.png'); } if ($this->rs->user_super) { $img_status = sprintf($img,__('superadmin'),'superadmin.png'); } $res = ''; $cols = array( 'check' => ''.form::hidden(array('nb_post[]'),(integer) $this->rs->nb_post). form::checkbox(array('users[]'),$this->rs->user_id).'', 'username' => ''. $this->rs->user_id.' '.$img_status.'', 'first_name' => ''.html::escapeHTML($this->rs->user_firstname).'', 'last_name' => ''.html::escapeHTML($this->rs->user_name).'', 'display_name' => ''.html::escapeHTML($this->rs->user_displayname).'', 'entries' => ''. $this->rs->nb_post.'' ); $cols = new ArrayObject($cols); $this->core->callBehavior('adminUserListValue',$this->core,$this->rs,$cols); $res .= implode(iterator_to_array($cols)); $res .= ''; return $res; } }