[ Index ]
 

Code source de Dotclear 2.0-beta6

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

title

Body

[fermer]

/admin/ -> posts.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  # Getting categories
  28  try {
  29      $categories = $core->blog->getCategories();
  30  } catch (Exception $e) {
  31      $core->error->add($e->getMessage());
  32  }
  33  
  34  # Getting authors
  35  try {
  36      $users = $core->blog->getPostsUsers();
  37  } catch (Exception $e) {
  38      $core->error->add($e->getMessage());
  39  }
  40  
  41  # Getting dates
  42  try {
  43      $dates = $core->blog->getDates(array('type'=>'month'));
  44  } catch (Exception $e) {
  45      $core->error->add($e->getMessage());
  46  }
  47  
  48  # Getting langs
  49  try {
  50      $langs = $core->blog->getLangs();
  51  } catch (Exception $e) {
  52      $core->error->add($e->getMessage());
  53  }
  54  
  55  # Creating filter combo boxes
  56  if (!$core->error->flag())
  57  {
  58      # Filter form we'll put in html_block
  59      $users_combo = $categories_combo = array();
  60      $users_combo['-'] = $categories_combo['-'] = '';
  61      while ($users->fetch())
  62      {
  63          $user_cn = dcUtils::getUserCN($users->user_id,$users->user_name,
  64          $users->user_firstname,$users->user_displayname);
  65          
  66          if ($user_cn != $users->user_id) {
  67              $user_cn .= ' ('.$users->user_id.')';
  68          }
  69          
  70          $users_combo[$user_cn] = $users->user_id; 
  71      }
  72      
  73      while ($categories->fetch()) {
  74          $categories_combo[html::escapeHTML($categories->cat_title)] = $categories->cat_id;
  75      }
  76      
  77      $status_combo = array(
  78      '-' => ''
  79      );
  80      foreach ($core->blog->getAllPostStatus() as $k => $v) {
  81          $status_combo[$v] = (string) $k;
  82      }
  83      
  84      $selected_combo = array(
  85      '-' => '',
  86      __('selected') => '1',
  87      __('not selected') => '0'
  88      );
  89      
  90      # Months array
  91      $dt_m_combo['-'] = '';
  92      while ($dates->fetch()) {
  93          $dt_m_combo[dt::str('%B %Y',$dates->ts())] = $dates->year().$dates->month();
  94      }
  95      
  96      $lang_combo['-'] = '';
  97      while ($langs->fetch()) {
  98          $lang_combo[$langs->post_lang] = $langs->post_lang;
  99      }
 100      
 101      $sortby_combo = array(
 102      __('Date') => 'post_dt',
 103      __('Title') => 'post_title',
 104      __('Category') => 'cat_title',
 105      __('Author') => 'user_id',
 106      __('Status') => 'post_status',
 107      __('Selected') => 'post_selected'
 108      );
 109      
 110      $order_combo = array(
 111      __('Descending') => 'desc',
 112      __('Ascending') => 'asc'
 113      );
 114  }
 115  
 116  # Actions combo box
 117  $combo_action = array();
 118  if ($core->auth->check('publish,contentadmin',$core->blog->id))
 119  {
 120      $combo_action[__('publish')] = 'publish';
 121      $combo_action[__('unpublish')] = 'unpublish';
 122      $combo_action[__('schedule')] = 'schedule';
 123      $combo_action[__('mark as pending')] = 'pending';
 124  }
 125  $combo_action[__('change category')] = 'category';
 126  if ($core->auth->check('admin',$core->blog->id)) {
 127      $combo_action[__('change author')] = 'author';
 128  }
 129  if ($core->auth->check('delete,contentadmin',$core->blog->id))
 130  {
 131      $combo_action[__('delete')] = 'delete';
 132  }
 133  
 134  # --BEHAVIOR-- adminPostsActionsCombo
 135  $core->callBehavior('adminPostsActionsCombo',array(&$combo_action));
 136  
 137  /* Get posts
 138  -------------------------------------------------------- */
 139  $user_id = !empty($_GET['user_id']) ?    $_GET['user_id'] : '';
 140  $cat_id = !empty($_GET['cat_id']) ?    $_GET['cat_id'] : '';
 141  $status = isset($_GET['status']) ?    $_GET['status'] : '';
 142  $selected = isset($_GET['selected']) ?    $_GET['selected'] : '';
 143  $month = !empty($_GET['month']) ?        $_GET['month'] : '';
 144  $lang = !empty($_GET['lang']) ?        $_GET['lang'] : '';
 145  $sortby = !empty($_GET['sortby']) ?    $_GET['sortby'] : 'post_dt';
 146  $order = !empty($_GET['order']) ?        $_GET['order'] : 'desc';
 147  
 148  $show_filters = false;
 149  
 150  $page = !empty($_GET['page']) ? $_GET['page'] : 1;
 151  $nb_per_page =  30;
 152  
 153  if (!empty($_GET['nb']) && (integer) $_GET['nb'] > 0) {
 154      if ($nb_per_page != $_GET['nb']) {
 155          $show_filters = true;
 156      }
 157      $nb_per_page = (integer) $_GET['nb'];
 158  }
 159  
 160  $params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page);
 161  $params['no_content'] = true;
 162  
 163  # - User filter
 164  if ($user_id !== '' && in_array($user_id,$users_combo)) {
 165      $params['user_id'] = $user_id;
 166      $show_filters = true;
 167  }
 168  
 169  # - Categories filter
 170  if ($cat_id !== '' && in_array($cat_id,$categories_combo)) {
 171      $params['cat_id'] = $cat_id;
 172      $show_filters = true;
 173  }
 174  
 175  # - Status filter
 176  if ($status !== '' && in_array($status,$status_combo)) {
 177      $params['post_status'] = $status;
 178      $show_filters = true;
 179  }
 180  
 181  # - Selected filter
 182  if ($selected !== '' && in_array($selected,$selected_combo)) {
 183      $params['post_selected'] = $selected;
 184      $show_filters = true;
 185  }
 186  
 187  # - Month filter
 188  if ($month !== '' && in_array($month,$dt_m_combo)) {
 189      $params['post_month'] = substr($month,4,2);
 190      $params['post_year'] = substr($month,0,4);
 191      $show_filters = true;
 192  }
 193  
 194  # - Lang filter
 195  if ($lang !== '' && in_array($lang,$lang_combo)) {
 196      $params['post_lang'] = $lang;
 197      $show_filters = true;
 198  }
 199  
 200  # - Sortby and order filter
 201  if ($sortby !== '' && in_array($sortby,$sortby_combo)) {
 202      if ($order !== '' && in_array($order,$order_combo)) {
 203          $params['order'] = $sortby.' '.$order;
 204      }
 205      
 206      if ($sortby != 'post_dt' || $order != 'desc') {
 207          $show_filters = true;
 208      }
 209  }
 210  
 211  # Get posts
 212  try {
 213      $posts = $core->blog->getPosts($params);
 214      $counter = $core->blog->getPosts($params,true);
 215      $post_list = new adminPostList($core,$posts,$counter->f(0));
 216  } catch (Exception $e) {
 217      $core->error->add($e->getMessage());
 218  }
 219  
 220  /* DISPLAY
 221  -------------------------------------------------------- */
 222  $starting_script = dcPage::jsLoad('js/_posts_list.js');
 223  if (!$show_filters) {
 224      $starting_script .= dcPage::jsLoad('js/filter-controls.js');
 225  }
 226  
 227  dcPage::open(__('Entries'),$starting_script);
 228  
 229  if (!$core->error->flag())
 230  {
 231      echo '<h2>'.$core->blog->name.' &gt; '.__('Entries').'</h2>';
 232      
 233      if (!$show_filters) {
 234          echo '<p><a id="filter-control" class="form-control" href="#">'.
 235          __('Filters').'</a></p>';
 236      }
 237      
 238      echo
 239      '<form action="posts.php" method="get" id="filters-form">'.
 240      '<fieldset><legend>'.__('Filters').'</legend>'.
 241      '<div class="three-cols">'.
 242      '<div class="col">'.
 243      '<label>'.__('Author:').dcPage::help('posts','f_author').
 244      form::combo('user_id',$users_combo,$user_id).
 245      '</label> '.
 246      '<label>'.__('Category:').dcPage::help('posts','f_category').
 247      form::combo('cat_id',$categories_combo,$cat_id).
 248      '</label> '.
 249      '<label>'.__('Status:').dcPage::help('posts','f_status').
 250      form::combo('status',$status_combo,$status).
 251      '</label> '.
 252      '</div>'.
 253      
 254      '<div class="col">'.
 255      '<label>'.__('Selected:').dcPage::help('posts','f_selected').
 256      form::combo('selected',$selected_combo,$selected).
 257      '</label> '.
 258      '<label>'.__('Month:').dcPage::help('posts','f_month').
 259      form::combo('month',$dt_m_combo,$month).
 260      '</label> '.
 261      '<label>'.__('Lang:').dcPage::help('posts','f_lang').
 262      form::combo('lang',$lang_combo,$lang).
 263      '</label> '.
 264      '</div>'.
 265      
 266      '<div class="col">'.
 267      '<p><label>'.__('Order by:').dcPage::help('posts','f_sortby').
 268      form::combo('sortby',$sortby_combo,$sortby).
 269      '</label> '.
 270      '<label>'.__('Sort:').dcPage::help('posts','f_order').
 271      form::combo('order',$order_combo,$order).
 272      '</label></p>'.
 273      '<p><label class="classic">'.    form::field('nb',3,3,$nb_per_page).' '.
 274      __('Entries per page').dcPage::help('posts','f_nb').'</label> '.
 275      '<input type="submit" value="'.__('filter').'" /></p>'.
 276      '</div>'.
 277      '</div>'.
 278      '<br class="clear" />'. //Opera sucks
 279      '</fieldset>'.
 280      '</form>';
 281      
 282      # Show posts
 283      $post_list->display($page,$nb_per_page,
 284      '<form action="posts_actions.php" method="post" id="form-entries">'.
 285      
 286      '%s'.
 287      
 288      '<div class="two-cols">'.
 289      '<p class="col checkboxes-helpers"></p>'.
 290      
 291      '<p class="col right">'.__('Selected entries action:').
 292      dcPage::help('posts','p_actions').
 293      form::combo('action',$combo_action).
 294      '<input type="submit" value="'.__('ok').'" /></p>'.
 295      form::hidden(array('user_id'),$user_id).
 296      form::hidden(array('cat_id'),$cat_id).
 297      form::hidden(array('status'),$status).
 298      form::hidden(array('selected'),$selected).
 299      form::hidden(array('month'),$month).
 300      form::hidden(array('lang'),$lang).
 301      form::hidden(array('sortby'),$sortby).
 302      form::hidden(array('order'),$order).
 303      form::hidden(array('page'),$page).
 304      form::hidden(array('nb'),$nb_per_page).
 305      '</div>'.
 306      '</form>'
 307      );
 308  }
 309  
 310  dcPage::close();
 311  ?>


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