[ Index ]
 

Code source de Plume CMS 1.2.2

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/manager/ -> index.php (source)

   1  <?php
   2  /* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
   3  /*
   4  # ***** BEGIN LICENSE BLOCK *****
   5  # This file is part of Plume CMS, a website management application.
   6  # Copyright (C) 2001-2005 Loic d'Anterroches and contributors.
   7  #
   8  # Plume CMS is free software; you can redistribute it and/or modify
   9  # it under the terms of the GNU General Public License as published by
  10  # the Free Software Foundation; either version 2 of the License, or
  11  # (at your option) any later version.
  12  #
  13  # Plume CMS is distributed in the hope that it will be useful,
  14  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16  # GNU General Public License for more details.
  17  #
  18  # You should have received a copy of the GNU General Public License
  19  # along with this program; if not, write to the Free Software
  20  # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  21  #
  22  # ***** END LICENSE BLOCK ***** */
  23  
  24  require_once 'path.php';
  25  require_once $_PX_config['manager_path'].'/prepend.php';
  26  auth::checkAuth(PX_AUTH_NORMAL);
  27  
  28  $m = new Manager();
  29  $_px_theme = $m->user->getTheme();
  30  
  31  /* ========================================================== *
  32   *        Send the user to the requested public website       *
  33   * ========================================================== */
  34  if (!empty($_REQUEST['goto'])) {
  35      $site = $_REQUEST['switchid'];
  36      if (isset($m->user->wdata[$site]['website_url'])) {
  37          $location = $m->user->wdata[$site]['website_url'] .'/';     
  38          header('Location: '.$location);
  39          exit;
  40      }        
  41  }
  42  
  43  /* ========================================================== *
  44   *  Switch the user to the requested website in the manager   *
  45   * ========================================================== */
  46  if (!empty($_REQUEST['switchid'])) {
  47      $_SESSION['website_id'] = $_REQUEST['switchid'];
  48      $location = (!empty($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : 'index.php';
  49      if (false !== ($pos = strpos($location, '?'))) {
  50          $location = substr($location, 0, $pos);
  51      }
  52      header('Location: '.$location);
  53      exit;
  54  }
  55  
  56  
  57  /* ========================================================== *
  58   *                      Add sub menu items                    *
  59   * ========================================================== */
  60  $px_submenu->addItem(__('News'), 'news.php', 
  61               'themes/'.$_px_theme.'/images/ico_news.png', false);
  62  $px_submenu->addItem(__('Articles'), 'articles.php', 
  63               'themes/'.$_px_theme.'/images/ico_article.png', false);
  64  $px_submenu->addItem(__('Files or images'), 'xmedia.php', 
  65               'themes/'.$_px_theme.'/images/ico_image.png', false);
  66  
  67  
  68  /* ================================================= *
  69   *            list resources retrieval               *
  70   * ================================================= */
  71  
  72  //Get the category id and save it
  73  $cat_id = (!empty($_GET['cat_id'])) ? $_GET['cat_id'] : $m->user->getPref('list_index_cat_id');
  74  $m->user->savePref('list_index_cat_id', $cat_id, $_SESSION['website_id'], true);
  75  if ($cat_id == 'allcat') $cat_id = '';
  76  
  77  //Get the search query
  78  $px_q = (!empty($_GET['q'])) ? $_GET['q'] : '';
  79  
  80  //Get available months and selected
  81  list($first, $last, $arry_months) = $m->getArrayMonths(''/* All the types */, $cat_id);
  82  $px_m_s = $m->user->getPref('list_index_month');
  83  $px_m = (!empty($_GET['m'])) ? $_GET['m'] : ((!empty($px_m_s)) ? $px_m_s : $last);
  84  $m->user->savePref('list_index_month', $px_m, $_SESSION['website_id'], true);
  85  
  86  if ($px_m == 'alldate') {
  87      $px_m = $first;
  88      $px_end = date::stamp(0, 1 /*1 month after now */, 0);
  89  } else {
  90      $px_end = date::stamp(0, 1 /*1 month after $px_m */, 0, date::unix($px_m));
  91  }
  92  
  93  if (empty($px_q)) {
  94      $res = $m->getResources(''/* All users */, '' /* All status */, $cat_id, ''/*All types*/, $px_m /*Date start */, $px_end /*Date end */);
  95      //get again as possibly modified because of the 'alldate' case
  96      $px_m = $m->user->getPref('list_index_month');
  97  } else {
  98      $res = $m->searchResources($px_q, false /*Not only the online resources */, '' /*All the types */);
  99      //Search is made on all the date and all the categories
 100      $px_m = 'alldate';
 101      $cat_id = 'allcat';
 102  }
 103  
 104  /* ================================================= *
 105   *                title of the page                  *
 106   * ================================================= */
 107  
 108  $px_title =  __('Home'); // used in _top.php
 109  include dirname(__FILE__).'/mtemplates/_top.php';
 110  
 111  echo '<h1>'.__('Resource list').'</h1>'."\n\n";
 112  
 113  /* ================================================= *
 114   *           Form to select some resources           *
 115   * ================================================= */
 116  echo '<form action="index.php" method="GET"><p>';
 117  echo '<label for="m" style="display:inline;"><strong>'. __('Month:').' </strong></label>';
 118  echo form::comboBox('m', $arry_months, $px_m);
 119  echo ' <label for="cat_id" style="display:inline;"><strong>'. __('Category:').' </strong></label>';
 120  echo form::comboBox('cat_id', $m->getArrayCategories(true), $cat_id);
 121  echo ' <input type="hidden" name="op" id="op" value="list" /><input class="submit" type="submit" value="'. __('ok').'" />';
 122  echo '</p></form>';
 123  
 124  
 125  /* ================================================= *
 126   *                  list resources                   *
 127   * ================================================= */
 128  
 129  if ($res->isEmpty()) {
 130      echo '<p>'.__('No resource.').'</p>'."\n\n";
 131  } else {
 132      echo '<script type="text/javascript">'."\n<!--\n".
 133          "var js_post_ids = new Array('".implode("','",$res->getIDs('resource_id', 'content'))."');\n".
 134          "//-->\n</script>\n";
 135      
 136      echo '<p class="small"><a href="#" onclick="mOpenClose(js_post_ids,1); return false;">'. __('Show all').'</a>'.
 137          ' - <a href="#" onclick="mOpenClose(js_post_ids,-1); return false;">'. __('Hide all').'</a></p>';
 138      
 139          
 140      while (!$res->EOF()) {
 141          //edition links
 142          if ($m->asRightToEdit($res)) {
 143              $editlinks = '[<strong><a href="'.$res->f('type_id').'.php?resource_id='.$res->f('resource_id').'">'.__('edit').'</a></strong>]'; 
 144          } else {
 145              $editlinks = '[<strong><a href="'.$res->f('type_id').'.php?resource_id='.$res->f('resource_id').'">'.__('visualize').'</a></strong>]';        
 146          }
 147          
 148          switch ($res->f('status')) {
 149          case PX_RESOURCE_STATUS_VALIDE:
 150              $res_class = 'published';
 151              $res_img = '<img src="themes/'.$_px_theme.'/images/check_on.png" alt="'. __('Resource on-line').'" class="status" />';
 152              break;
 153          case PX_RESOURCE_STATUS_INEDITION:
 154              $res_class = 'published';
 155              $res_img = '<img src="themes/'.$_px_theme.'/images/check_edit.png" alt="'. __('Resource in edition').'" class="status" />';
 156              break;
 157          case PX_RESOURCE_STATUS_OFFLINE:
 158              $res_class = 'cancel';
 159              $res_img = '<img src="themes/'.$_px_theme.'/images/check_off.png" alt="'. __('Resource off-line').'" class="status" />';
 160              break;
 161          case PX_RESOURCE_STATUS_TOBEVALIDATED:
 162          default:
 163              $res_class = 'published';
 164              $res_img = '<img src="themes/'.$_px_theme.'/images/check_wait.png" alt="'. __('Resource waiting for validation').'" class="status" />';
 165              break;
 166          }
 167          
 168          echo '<div class="line '.$res_class.'" id="p'.$res->f('resource_id').'">'.
 169              '<p><a href="#" onclick="openClose(\'content'.$res->f('resource_id').'\',0); return false;">'.
 170              '<img src="themes/'.$_px_theme.'/images/plus.png" id="img_content'.$res->f('resource_id').'" '.
 171              'alt="'. __('show/hide').'" /></a> ';
 172          
 173          echo $res->f('title').' - '. __('by');
 174          
 175          $temp = '';
 176          while (!$res->extEOF('authors')) {
 177              $temp .= ' <strong>'.$res->extf('authors','user_realname').'</strong>';
 178              $res->extMoveNext('authors');
 179          }
 180          echo $temp;
 181          echo ' - '. __('in');
 182  
 183          $temp = '';
 184          while (!$res->extEOF('cats')) {
 185              $temp .= ' <em>'.$res->extf('cats','category_name').'</em>,';
 186              $res->extMoveNext('cats');
 187          }
 188          $temp = substr($temp, 0, -1); 
 189          echo $temp."<br />\n";
 190          echo $res_img.'<strong> '.date(__('Y/m/d \a\t H:i:s'), date::unix($res->f('modifdate'))).'</strong> '.$editlinks;
 191          echo "</p>\n\n";
 192          echo '<div id="content'.$res->f('resource_id').'" style="display:none;">';
 193          echo text::parseContent($res->f('description'))."\n";
 194          echo "\n<p><span class='small'>".__('Id to make a link:').' '.$res->f('identifier')."</span></p>\n<hr class='invisible' /></div></div>\n\n";
 195          
 196          $res->moveNext();
 197      }
 198  }
 199  
 200  /* ================================================= *
 201   *          Form to search in the resources          *
 202   * ================================================= */
 203  echo '<form action="index.php" method="GET"><p>';
 204  echo '<label for="q" style="display:inline;"><strong>'. __('Search:').' </strong></label>';
 205  echo form::textField('q', 30, 255, $px_q, '', 'accesskey="4"'); 
 206  echo ' <input class="submit" type="submit" value="'. __('ok').'" />';
 207  echo '</p></form>'."\n\n";
 208  
 209  include dirname(__FILE__).'/mtemplates/_bottom.php';
 210  
 211  ?>


Généré le : Mon Nov 26 11:57:01 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics