Dotclear


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

File:
1 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 } 
Note: See TracChangeset for help on using the changeset viewer.

Sites map