[ 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/tools/searchmng/ -> 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  $m->l10n->loadPlugin($m->user->lang, 'searchmng');
  25  $con =& pxDBConnect();
  26  $env  = (!empty($_GET['env'])) ? $_GET['env'] : 1;
  27  
  28  /*==============================================================================
  29   Functions needed for the lists
  30  ==============================================================================*/
  31  require_once $_PX_config['manager_path'].'/extinc/class.lum.php';
  32  require_once $_PX_config['manager_path'].'/inc/class.search.php';
  33  
  34  function line_res($data, $i)
  35  {
  36      global $_px_ptheme,$env;
  37      $reindex = sprintf('<a href="tools.php?p=searchmng&amp;op=index&amp;env='.$env.'&amp;id=%s" title="'.__('Index the resource').'"><img src="tools/searchmng/themes/'.$_px_ptheme.'/index.png" alt=" "/></a>',
  38          urlencode($data['identifier']));
  39      if (strlen($data['title']) > 50) {
  40          $data['title'] = '<span title="'.$data['title'].'">'.substr($data['title'],0,47).'...</span>';
  41      }
  42      $strings['ok'] = __('Up to date');
  43      $strings['old'] = __('Index too old');
  44      $strings['not'] = __('Not indexed');
  45  
  46      $status = '<img src="tools/searchmng/themes/'.$_px_ptheme.'/icon_%s.png" alt="%s"/>';
  47      $data['status'] = sprintf($status, $data['status'], $strings[$data['status']]);
  48      return '<tr><td>'.$data['status'].'</td><td>'.$data['title'].'</td><td>'.$data['date'].'</td><td>'.$data['total'].'</td><td>'.$reindex.'</td></tr>'."\n";
  49  }
  50  
  51  
  52  /*==============================================================================
  53   Process block
  54  ==============================================================================*/
  55  $s = new Search($con, $m->user->website);
  56  
  57  //-- Index a resource if asked --//
  58  if (!empty($_GET['op']) && 'index' == $_GET['op'] && !empty($_GET['id'])) {
  59      list($type, $id) = split('-', $_GET['id']);
  60      if ('art' == $type) $type = 'Article';
  61      else $type = 'News';
  62      $id = trim($id);
  63      if (false !== ($res = $m->getResourceByIdentifier($id, $type))) {
  64          if ($id == $res->f('resource_id')) {
  65              if (false !== $m->indexResource($res)) {
  66                  $msg =  __('The resource has been successfully indexed.');
  67                  header('Location: tools.php?p=searchmng&env='.$env.'&msg='.urlencode($msg));
  68                  exit;
  69              }
  70          }
  71      }
  72  }
  73  
  74  //-- Clean the index if asked --//
  75  if (!empty($_GET['op']) && 'clean' == $_GET['op']) {
  76      if (false !== ($words = $s->clean_index())) {
  77          $msg =  sprintf(__('The index has been cleaned with <strong>%s</strong> unused word(s) removed.'), $words);
  78          header('Location: tools.php?p=searchmng&msg='.urlencode($msg));
  79          exit;
  80      }
  81  }
  82  
  83  
  84  
  85  
  86  $rs = $s->get_indexed_resources_stats($m->user->website);
  87  $i = 0;
  88  while (($rs !== false) && !$rs->EOF()) {
  89      $indextime = date::unix($rs->f('lastindex'));
  90      $modiftime = date::unix($rs->f('modifdate'));
  91      if (0 == $indextime) {
  92          $rs_list[$i]['status'] = 'not';
  93      } elseif ($indextime < $modiftime) {
  94          $rs_list[$i]['status'] = 'old';
  95      } else {
  96          $rs_list[$i]['status'] = 'ok';
  97      }
  98      $rs_list[$i]['date'] = date(__('Y/m/d&\nb\sp;H:i:s'), $indextime);
  99      $rs_list[$i]['title'] = $rs->f('title');
 100      $rs_list[$i]['identifier'] = $rs->f('identifier');
 101      $rs_list[$i]['total'] = $rs->f('nbindex');
 102      $i++;
 103      $rs->moveNext();
 104  }
 105  
 106  /*==============================================================================
 107   Display block
 108  ==============================================================================*/
 109  ?>
 110  <h1><?php  echo __('Search Manager'); ?></h1>
 111  
 112  <h2><?php  echo __('Indexed resources'); ?></h2>
 113  <?php
 114  
 115  $objLum = new lum($env, 'line_res', $rs_list, 0, 20);
 116  $objLum->htmlHeader = '<table class="clean-table">'."\n".'<tr><th>'.__('Status').'</th><th>'.__('Resource title').'</th><th>'.__('Last indexation').'</th><th colspan="2">'.__('Number').'</th></tr>'."\n";
 117  
 118  $objLum->htmlLineStart = '';
 119  $objLum->htmlColStart = '';
 120  $objLum->htmlColEnd = '';
 121  $objLum->htmlLineEnd = '';
 122  $objLum->htmlFooter = '</table>'."\n";
 123  
 124  $objLum->htmlLinksStart = '<p class="small">';
 125  $objLum->htmlLinksEnd = '</p>';
 126  
 127  $objLum->htmlCurPgStart = '<strong>';
 128  $objLum->htmlCurPgEnd = '</strong>';
 129  
 130  $objLum->htmlPrev =  __('&laquo; previous page');
 131  $objLum->htmlNext =  __('&raquo; next page');
 132  $objLum->htmlPrevGrp = '...';
 133  $objLum->htmlNextGrp = '...';
 134  
 135  $objLum->htmlEmpty = '<p><strong>'. __('No resources.').'</strong></p>';
 136  $objLum->htmlLinksLib =  __('page(s):');
 137  
 138  echo $objLum->drawLinks();
 139  echo $objLum->drawPage();
 140  echo $objLum->drawLinks();
 141  $status = '<img src="tools/searchmng/themes/'.$_px_ptheme.'/icon_%s.png" alt="%s"/>';
 142  ?>
 143  <ul class="checklist">
 144  <li><?php echo sprintf($status,'ok',__('Up to date')).' '.__('Up to date'); ?></li>
 145  <li><?php echo sprintf($status,'old',__('Index too old')).' '.__('Index too old'); ?></li>
 146  <li><?php echo sprintf($status,'not',__('Not indexed')).' '.__('Not indexed'); ?></li>
 147  </ul>
 148  
 149  <h2><?php  echo __('Index maintenance'); ?></h2>
 150  <?php $url = 'tools.php?p=searchmng&amp;op=clean'; ?>
 151  <p><?php echo sprintf(__('<a href="%s">Clean the index of unused words</a>. This operation may take a long time and is database intensive.'), $url); ?></p>


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