Dotclear

Changeset 3402:8681798c6491


Ignore:
Timestamp:
11/11/16 00:10:02 (9 years ago)
Author:
Jean-Christian Denis
Branch:
default
Message:

Revamped blogs list with full dcAction system,
closes #1551 , closes #2217 , addresses #1566 , addresses #776

Files:
3 added
4 edited

Legend:

Unmodified
Added
Removed
  • admin/blogs.php

    r3400 r3402  
    1313require dirname(__FILE__).'/../inc/admin/prepend.php'; 
    1414 
    15 dcPage::check('usage,contentadmin'); 
     15dcPage::checkSuper(); 
    1616 
    1717# Filters 
     
    2222 
    2323$sortby_combo = array( 
    24 __('Last update') => 'blog_upddt', 
    25 __('Blog name') => 'UPPER(blog_name)', 
    26 __('Blog ID') => 'B.blog_id', 
    27 __('Status') => 'blog_status' 
     24     __('Last update') => 'blog_upddt', 
     25     __('Blog name') => 'UPPER(blog_name)', 
     26     __('Blog ID') => 'B.blog_id', 
     27     __('Status') => 'blog_status' 
    2828); 
    2929 
    3030$order_combo = array( 
    31 __('Descending') => 'desc', 
    32 __('Ascending') => 'asc' 
     31     __('Descending') => 'desc', 
     32     __('Ascending') => 'asc' 
    3333); 
    3434 
     35# Actions 
     36$blogs_actions_page = new dcBlogsActionsPage($core,$core->adminurl->get("admin.blogs")); 
     37 
     38if ($blogs_actions_page->process()) { 
     39     return; 
     40} 
     41 
     42# Requests 
    3543$q = !empty($_GET['q']) ? $_GET['q'] : ''; 
    3644$status = isset($_GET['status']) ? $_GET['status'] : ''; 
     
    8896          $rsStatic->lexicalSort(($sortby == 'UPPER(blog_name)' ? 'blog_name' : 'blog_id'),$order); 
    8997     } 
     98     $blog_list = new adminBlogList($core,$rs,$counter->f(0)); 
    9099} catch (Exception $e) { 
    91100     $core->error->add($e->getMessage()); 
     
    96105 
    97106dcPage::open(__('List of blogs'), 
    98      dcPage::jsFilterControl($show_filters), 
     107     dcPage::jsLoad('js/_blogs.js').dcPage::jsFilterControl($show_filters), 
    99108     dcPage::breadcrumb( 
    100109          array( 
     
    103112          )) 
    104113); 
    105  
    106 if (!empty($_GET['del'])) { 
    107      dcPage::success(__('Blog has been successfully deleted.')); 
    108 } 
    109114 
    110115if (!$core->error->flag()) 
     
    143148 
    144149     # Show blogs 
    145      if ($nb_blog == 0) 
    146      { 
    147           if( $show_filters ) { 
    148                echo '<p><strong>'.__('No blog matches the filter').'</strong></p>'; 
    149           } else { 
    150                echo '<p><strong>'.__('No blog').'</strong></p>'; 
    151           } 
    152      } 
    153      else 
    154      { 
    155           $pager = new dcPager($page,$nb_blog,$nb_per_page,10); 
     150     $blog_list->display($page,$nb_per_page, 
     151     '<form action="'.$core->adminurl->get("admin.blogs").'" method="post" id="form-blogs">'. 
    156152 
    157           echo $pager->getLinks(); 
     153     '%s'. 
    158154 
    159           echo 
    160           '<div class="table-outer">'. 
    161           '<table class="clear">'; 
     155     '<div class="two-cols">'. 
     156     '<p class="col checkboxes-helpers"></p>'. 
    162157 
    163           if( $show_filters ) { 
    164                echo '<caption>'.sprintf(__('%d blog matches the filter.','%d blogs match the filter.',$nb_blog),$nb_blog).'</caption>'; 
    165           } else { 
    166                echo '<caption class="hidden">'.__('Blogs list').'</caption>'; 
    167           } 
     158     '<p class="col right"><label for="action" class="classic">'.__('Selected blogs action:').'</label> '. 
     159     form::combo('action',$blogs_actions_page->getCombo(),'online','','','','title="'.__('Actions').'"'). 
     160     $core->formNonce(). 
     161     '<input id="do-action" type="submit" value="'.__('ok').'" /></p>'. 
     162     form::hidden(array('sortby'),$sortby). 
     163     form::hidden(array('order'),$order). 
     164     form::hidden(array('status'),$status). 
     165     form::hidden(array('page'),$page). 
     166     form::hidden(array('nb'),$nb_per_page). 
     167     '</div>'. 
    168168 
    169           echo 
    170           '<tr>'. 
    171           '<th scope="col" class="nowrap">'.__('Blog id').'</th>'. 
    172           '<th scope="col">'.__('Blog name').'</th>'. 
    173           '<th scope="col" class="nowrap">'.__('URL').'</th>'. 
    174           '<th scope="col" class="nowrap">'.__('Entries (all types)').'</th>'. 
    175           '<th scope="col" class="nowrap">'.__('Last update').'</th>'. 
    176           '<th scope="col" class="nowrap">'.__('Status').'</th>'. 
    177           '</tr>'; 
     169     '<div>'. 
     170     '<p>'.__('Please give your password to confirm the blog deletion.').'</p>'. 
     171     '<p><label for="pwd">'.__('Your password:').'</label> '. 
     172     form::password('pwd',20,255).'</p>'. 
     173     '</div>'. 
    178174 
    179           while ($rsStatic->fetch()) { 
    180                echo blogLine($rsStatic); 
    181           } 
     175     '</form>', 
     176     $show_filters 
     177     ); 
     178} 
    182179 
    183           echo '</table></div>'; 
    184  
    185           echo $pager->getLinks(); 
    186      } 
    187 } 
    188180dcPage::helpBlock('core_blogs'); 
    189181dcPage::close(); 
    190  
    191 function blogLine($rs) 
    192 { 
    193      global $core; 
    194  
    195      $blog_id = html::escapeHTML($rs->blog_id); 
    196      $edit_link = ''; 
    197  
    198      if ($GLOBALS['core']->auth->isSuperAdmin()) { 
    199           $edit_link = 
    200           '<a href="'.$core->adminurl->get("admin.blog",array('id' => $blog_id)).'"  title="'.sprintf(__('Edit blog settings for %s'),$blog_id).'">'. 
    201           '<img src="images/edit-mini.png" alt="'.__('Edit blog settings').'" /> '.$blog_id.'</a> '; 
    202      } else { 
    203           $edit_link = $blog_id; 
    204      } 
    205  
    206      $img_status = $rs->blog_status == 1 ? 'check-on' : ($rs->blog_status == 0 ? 'check-off' : 'check-wrn'); 
    207      $txt_status = $GLOBALS['core']->getBlogStatus($rs->blog_status); 
    208      $img_status = sprintf('<img src="images/%1$s.png" alt="%2$s" title="%2$s" />',$img_status,$txt_status); 
    209      $offset = dt::getTimeOffset($core->auth->getInfo('user_tz')); 
    210      $blog_upddt = dt::str(__('%Y-%m-%d %H:%M'),strtotime($rs->blog_upddt) + $offset); 
    211  
    212      return 
    213      '<tr class="line">'. 
    214      '<td class="nowrap">'.$edit_link.'</td>'. 
    215      '<td class="maximal"><a href="'.$core->adminurl->get("admin.home",array('switchblog' => $rs->blog_id)).'" '. 
    216      'title="'.sprintf(__('Switch to blog %s'),$rs->blog_id).'">'. 
    217      html::escapeHTML($rs->blog_name).'</a></td>'. 
    218      '<td class="nowrap"><a class="outgoing" href="'.html::escapeHTML($rs->blog_url).'">'.html::escapeHTML($rs->blog_url). 
    219      ' <img src="images/outgoing-blue.png" alt="" /></a></td>'. 
    220      '<td class="nowrap count">'.$core->countBlogPosts($rs->blog_id).'</td>'. 
    221      '<td class="nowrap count">'.$blog_upddt.'</td>'. 
    222      '<td class="status">'.$img_status.'</td>'. 
    223      '</tr>'; 
    224 } 
  • inc/admin/lib.pager.php

    r3265 r3402  
    662662} 
    663663 
     664class adminBlogList extends adminGenericList 
     665{ 
     666     public function display($page,$nb_per_page,$enclose_block='',$filter=false) 
     667     { 
     668          if ($this->rs->isEmpty()) 
     669          { 
     670               if($filter) { 
     671                    echo '<p><strong>'.__('No blog matches the filter').'</strong></p>'; 
     672               } else { 
     673                    echo '<p><strong>'.__('No blog').'</strong></p>'; 
     674               } 
     675          } 
     676          else 
     677          { 
     678               $blogs = array(); 
     679               if (isset($_REQUEST['blogs'])) { 
     680                    foreach ($_REQUEST['blogs'] as $v) { 
     681                         $blogs[$v]=true; 
     682                    } 
     683               } 
     684 
     685               $pager = new dcPager($page,$this->rs_count,$nb_per_page,10); 
     686 
     687               $cols = array( 
     688                    'blog' => '<th colspan="2" scope="col" abbr="comm" class="first nowrap">'.__('Blog id').'</th>', 
     689                    'name' => '<th scope="col" abbr="name">'.__('Blog name').'</th>', 
     690                    'url' => '<th scope="col" class="nowrap">'.__('URL').'</th>', 
     691                    'posts' => '<th scope="col" class="nowrap">'.__('Entries (all types)').'</th>', 
     692                    'upddt' => '<th scope="col" class="nowrap">'.__('Last update').'</th>', 
     693                    'status' => '<th scope="col" class="txt-center">'.__('Status').'</th>' 
     694               ); 
     695 
     696               $cols = new ArrayObject($cols); 
     697               $this->core->callBehavior('adminBlogListHeader',$this->core,$this->rs,$cols); 
     698 
     699               $html_block = 
     700               '<div class="table-outer"><table>'. 
     701               ($filter ? 
     702                    '<caption>'. 
     703                    sprintf(__('%d blog matches the filter.','%d blogs match the filter.',$this->rs_count),$this->rs_count). 
     704                    '</caption>' 
     705               : 
     706                    '<caption class="hidden">'.__('Blogs list').'</caption>' 
     707               ). 
     708               '<tr>'.implode(iterator_to_array($cols)).'</tr>%s</table></div>'; 
     709 
     710               if ($enclose_block) { 
     711                    $html_block = sprintf($enclose_block,$html_block); 
     712               } 
     713 
     714               $blocks = explode('%s',$html_block); 
     715 
     716               echo $pager->getLinks(); 
     717 
     718               echo $blocks[0]; 
     719 
     720               while ($this->rs->fetch()) { 
     721                    echo $this->blogLine(isset($blogs[$this->rs->blog_id])); 
     722               } 
     723 
     724               echo $blocks[1]; 
     725 
     726               echo $pager->getLinks(); 
     727          } 
     728     } 
     729 
     730     private function blogLine($checked=false) 
     731     { 
     732          $blog_id = html::escapeHTML($this->rs->blog_id); 
     733 
     734          $cols = array( 
     735               'check' =>  
     736                    '<td class="nowrap">'. 
     737                    form::checkbox(array('blogs[]'),$this->rs->blog_id,$checked,'','',0). 
     738                    '</td>', 
     739               'blog' =>  
     740                    '<td class="nowrap">'. 
     741                    '<a href="'.$this->core->adminurl->get("admin.blog",array('id' => $blog_id)).'"  '. 
     742                    'title="'.sprintf(__('Edit blog settings for %s'),$blog_id).'">'. 
     743                    '<img src="images/edit-mini.png" alt="'.__('Edit blog settings').'" /> '.$blog_id.'</a> '. 
     744                    '</td>', 
     745               'name' =>  
     746                    '<td class="maximal">'. 
     747                    '<a href="'.$this->core->adminurl->get("admin.home",array('switchblog' => $this->rs->blog_id)).'" '. 
     748                    'title="'.sprintf(__('Switch to blog %s'),$this->rs->blog_id).'">'. 
     749                    html::escapeHTML($this->rs->blog_name).'</a>'. 
     750                    '</td>', 
     751               'url' => 
     752                    '<td class="nowrap">'. 
     753                    '<a class="outgoing" href="'. 
     754                    html::escapeHTML($this->rs->blog_url).'">'.html::escapeHTML($this->rs->blog_url). 
     755                    ' <img src="images/outgoing-blue.png" alt="" /></a></td>', 
     756               'posts' =>  
     757                    '<td class="nowrap count">'. 
     758                    $this->core->countBlogPosts($this->rs->blog_id). 
     759                    '</td>', 
     760               'upddt' =>  
     761                    '<td class="nowrap count">'. 
     762                    dt::str(__('%Y-%m-%d %H:%M'),strtotime($this->rs->blog_upddt) + dt::getTimeOffset($this->core->auth->getInfo('user_tz'))). 
     763                    '</td>', 
     764               'status' =>  
     765                    '<td class="nowrap status txt-center">'. 
     766                    sprintf( 
     767                         '<img src="images/%1$s.png" alt="%2$s" title="%2$s" />', 
     768                         ($this->rs->blog_status == 1 ? 'check-on' : ($this->rs->blog_status == 0 ? 'check-off' : 'check-wrn')), 
     769                         $this->core->getBlogStatus($this->rs->blog_status) 
     770                    ). 
     771                    '</td>' 
     772          ); 
     773 
     774          $cols = new ArrayObject($cols); 
     775          $this->core->callBehavior('adminBlogListValue',$this->core,$this->rs,$cols); 
     776 
     777          return  
     778          '<tr class="line" id="b'.$blog_id.'">'. 
     779          implode(iterator_to_array($cols)). 
     780          '</tr>'; 
     781     } 
     782} 
     783 
    664784class adminUserList extends adminGenericList 
    665785{ 
  • inc/core/class.dc.core.php

    r3400 r3402  
    10171017          } 
    10181018 
    1019           if (!empty($params['blog_status']) && $this->auth->isSuperAdmin()) { 
    1020                $where = 'AND blog_status = '.(integer) $params['blog_status'].' '; 
    1021           } 
    1022  
    1023           if (!empty($params['blog_id'])) { 
    1024                $where .= "AND B.blog_id = '".$this->con->escape($params['blog_id'])."' "; 
     1019          if (isset($params['blog_status']) && $params['blog_status'] !== '' && $this->auth->isSuperAdmin()) { 
     1020               $where .= 'AND blog_status = '.(integer) $params['blog_status'].' '; 
     1021          } 
     1022 
     1023          if (isset($params['blog_id']) && $params['blog_id'] !== '') { 
     1024               if (!is_array($params['blog_id'])) { 
     1025                    $params['blog_id'] = array($params['blog_id']); 
     1026               } 
     1027               $where .= 'AND B.blog_id '.$this->con->in($params['blog_id']); 
    10251028          } 
    10261029 
  • inc/prepend.php

    r3388 r3402  
    6868$__autoload['adminPostMiniList']    = dirname(__FILE__).'/admin/lib.pager.php'; 
    6969$__autoload['adminCommentList']     = dirname(__FILE__).'/admin/lib.pager.php'; 
     70$__autoload['adminBlogList']        = dirname(__FILE__).'/admin/lib.pager.php'; 
    7071$__autoload['adminUserList']        = dirname(__FILE__).'/admin/lib.pager.php'; 
    7172$__autoload['dcPager']              = dirname(__FILE__).'/admin/lib.pager.php'; 
     
    7778$__autoload['dcPostsActionsPage']    = dirname(__FILE__).'/admin/actions/class.dcactionposts.php'; 
    7879$__autoload['dcCommentsActionsPage'] = dirname(__FILE__).'/admin/actions/class.dcactioncomments.php'; 
     80$__autoload['dcBlogsActionsPage'] = dirname(__FILE__).'/admin/actions/class.dcactionblogs.php'; 
    7981$__autoload['dcActionsPage']         = dirname(__FILE__).'/admin/actions/class.dcaction.php'; 
    8082 
Note: See TracChangeset for help on using the changeset viewer.

Sites map