[ Index ]
 

Code source de Dotclear 2.0-beta6

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/admin/ -> blogs.php (source)

   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  require dirname(__FILE__).'/../inc/admin/prepend.php';
  24  
  25  dcPage::check('usage,contentadmin');
  26  
  27  # Filters
  28  $sortby_combo = array(
  29  __('Last update') => 'blog_upddt',
  30  __('Number of entries') => 'nb_post',
  31  __('Blog name') => 'UPPER(blog_name)',
  32  __('Blog ID') => 'B.blog_id'
  33  );
  34  
  35  $order_combo = array(
  36  __('Descending') => 'desc',
  37  __('Ascending') => 'asc'
  38  );
  39  
  40  $q = !empty($_GET['q']) ? $_GET['q'] : '';
  41  $sortby = !empty($_GET['sortby']) ? $_GET['sortby'] : 'blog_upddt';
  42  $order = !empty($_GET['order']) ? $_GET['order'] : 'desc';
  43  
  44  $page = !empty($_GET['page']) ? $_GET['page'] : 1;
  45  $nb_per_page =  30;
  46  
  47  if (!empty($_GET['nb']) && (integer) $_GET['nb'] > 0) {
  48      $nb_per_page = $_GET['nb'];
  49  }
  50  
  51  $show_filters = false;
  52      
  53  # - Search filter
  54  if ($q) {
  55      $params['q'] = $q;
  56      $show_filters = true;
  57  }
  58  
  59  # - Sortby and order filter
  60  if ($sortby !== '' && in_array($sortby,$sortby_combo)) {
  61      if ($order !== '' && in_array($order,$order_combo)) {
  62          $params['order'] = $sortby.' '.$order;
  63      }
  64      
  65      if ($sortby != 'blog_upddt' || $order != 'desc') {
  66          $show_filters = true;
  67      }
  68  }
  69  
  70  $params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page);
  71  
  72  try {
  73      $counter = $core->getBlogs($params,1);
  74      $rs = $core->getBlogs($params);
  75      $nb_blog = $counter->f(0);
  76  } catch (Exception $e) {
  77      $core->error->add($e->getMessage());
  78  }
  79  
  80  /* DISPLAY
  81  -------------------------------------------------------- */
  82  $starting_script = '';
  83  if (!$show_filters) {
  84      $starting_script .= dcPage::jsLoad('js/filter-controls.js');
  85  }
  86  dcPage::open(__('List of blogs'),$starting_script);
  87  
  88  if (!empty($_GET['del'])) {
  89      echo '<p class="message">'.__('Blog has been successfully deleted.').'</p>';
  90  }
  91  
  92  echo '<h2>'.__('List of blogs').'</h2>';
  93  
  94  if (!$core->error->flag())
  95  {
  96      if ($core->auth->isSuperAdmin()) {
  97          echo '<p><strong><a href="blog.php">'.__('Create a new blog').'</a></strong></p>';
  98      }
  99      
 100      if (!$show_filters) {
 101          echo '<p><a id="filter-control" class="form-control" href="#">'.__('Filters').'</a></p>';
 102      }
 103      
 104      echo
 105      '<form action="blogs.php" method="get" id="filters-form">'.
 106      '<fieldset class="two-cols"><legend>'.__('Filters').'</legend>'.
 107      
 108      '<div class="col">'.
 109      '<p><label>'.__('Order by:').' '.
 110      form::combo('sortby',$sortby_combo,html::escapeHTML($sortby)).
 111      '</label> '.
 112      '<label>'.__('Sort:').' '.
 113      form::combo('order',$order_combo,html::escapeHTML($order)).
 114      '</label></p>'.
 115      '</div>'.
 116      
 117      '<div class="col">'.
 118      '<p><label>'.__('Search:').' '.
 119      form::field('q',20,255,html::escapeHTML($q)).
 120      '</label></p>'.
 121      '<p><label class="classic">'.    form::field('nb',3,3,$nb_per_page).' '.
 122      __('Blogs per page').'</label> '.
 123      '<input type="submit" value="'.__('filter').'" /></p>'.
 124      '</div>'.
 125      
 126      '<br class="clear" />'. //Opera sucks
 127      '</fieldset>'.
 128      '</form>';
 129      
 130      # Show blogs
 131      if ($nb_blog == 0)
 132      {
 133          echo '<p><strong>'.__('No blog').'</strong></p>';
 134      }
 135      else
 136      {
 137          $pager = new pager($page,$nb_blog,$nb_per_page,10);
 138          $pager->var_page = 'page';
 139          
 140          echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>';
 141          
 142          echo
 143          '<table class="clear"><tr>'.
 144          '<th>'.__('Blog name').'</th>'.
 145          '<th class="nowrap">'.__('Last update').'</th>'.
 146          '<th class="nowrap">'.__('Entries').'</th>'.
 147          '<th class="nowrap">'.__('Blog ID').'</th>'.
 148          '<th>&nbsp;</th>'.
 149          '<th class="nowrap">'.__('Status').'</th>'.
 150          '</tr>';
 151          
 152          while ($rs->fetch()) {
 153              echo blogLine($rs);
 154          }
 155          
 156          echo '</table>';
 157          
 158          echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>';
 159      }
 160  }
 161  
 162  dcPage::close();
 163  
 164  function blogLine(&$rs)
 165  {
 166      $blog_id = html::escapeHTML($rs->blog_id);
 167      
 168      $edit_link = '';
 169      
 170      if ($GLOBALS['core']->auth->isSuperAdmin()) {
 171          $edit_link = 
 172          '<a href="blog.php?id='.$blog_id.'" '.
 173          'title="'.sprintf(__('Edit blog %s'),$blog_id).'">'.
 174          __('edit').'</a>';
 175      }
 176      
 177      $img_status = $rs->blog_status == 1 ? 'check-on' : 'check-off';
 178      $txt_status = $GLOBALS['core']->getBlogStatus($rs->blog_status);
 179      $img_status = sprintf('<img src="images/%1$s.png" alt="%2$s" title="%2$s" />',$img_status,$txt_status);
 180      
 181      return
 182      '<tr class="line">'.
 183      '<td class="maximal"><a href="index.php?switchblog='.$rs->blog_id.'" '.
 184      'title="'.sprintf(__('Switch to blog %s'),$rs->blog_id).'">'.
 185      html::escapeHTML($rs->blog_name).'</a></td>'.
 186      '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$rs->blog_upddt).'</td>'.
 187      '<td class="nowrap">'.$rs->nb_post.'</td>'.
 188      '<td class="nowrap">'.$blog_id.'</td>'.
 189      '<td>'.$edit_link.'</td>'.
 190      '<td class="status">'.$img_status.'</td>'.
 191      '</tr>';
 192  }
 193  ?>


Généré le : Fri Feb 23 22:16:06 2007 par Balluche grâce à PHPXref 0.7