[ Index ]
 

Code source de LifeType 1.2.4

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/class/summary/action/ -> summarysearchaction.class.php (source)

   1  <?php
   2  
   3      lt_include( PLOG_CLASS_PATH."class/summary/action/summaryaction.class.php" );
   4      lt_include( PLOG_CLASS_PATH."class/summary/dao/summarystatsconstants.class.php" );
   5      lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
   6      lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
   7      lt_include( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
   8  
   9       class SummarySearchAction extends SummaryAction
  10       {
  11          var $_searchTerms;
  12          var $_searchType;
  13  
  14          function SummarySearchAction( $actionInfo, $request )
  15          {
  16              $this->SummaryAction( $actionInfo, $request );            
  17  
  18              // validation stuff
  19              $this->registerFieldValidator( "searchTerms", new StringValidator());
  20              $this->registerFieldValidator( "searchType", new IntegerValidator());
  21              
  22              $view = new SummaryView( "summaryerror" );
  23              $view->setErrorMessage( $this->_locale->tr("error_incorrect_search_terms" ));
  24              $this->setValidationErrorView( $view );
  25          }
  26          
  27          /**
  28           * carry out the search and execute it
  29           */
  30          function perform()
  31          {
  32              lt_include( PLOG_CLASS_PATH."class/dao/searchengine.class.php" );    
  33              lt_include( PLOG_CLASS_PATH."class/data/pager/pager.class.php" );
  34              lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
  35      
  36              $tf = new Textfilter();
  37              $this->_searchTerms = $tf->filterAllHTML( $this->_request->getValue( "searchTerms" ));
  38              $this->_searchType  = $this->_request->getValue( "searchType" );    
  39      
  40              $search = new SearchEngine();
  41  
  42              // number of items per page
  43              $config =& Config::getConfig();
  44              $itemsPerPage = $config->getValue( "summary_items_per_page", SUMMARY_DEFAULT_ITEMS_PER_PAGE );
  45              
  46              // execute the search and check if there is any result
  47              $results = $search->siteSearch( $this->_searchTerms, 
  48                                              $this->_searchType, 
  49                                             -1, 
  50                                             false,
  51                                             View::getCurrentPageFromRequest(),
  52                                             $itemsPerPage );
  53                  
  54              // get the total number of results, for the pager
  55              $numResults = $search->getNumSiteSearchResults( $this->_searchTerms, $this->_searchType, -1, false );
  56  
  57              // no results
  58              if( !$results || empty($results)) {
  59                  // if not, then quit
  60                  $this->_view = new SummaryView( "summaryerror" );
  61                  $this->_view->setErrorMessage( $this->_locale->tr("error_no_search_results" ));
  62                  return false;    
  63              }
  64              
  65              // but if so, then continue...
  66              $this->_view = new SummaryView( "searchresults" );
  67              $this->_view->setValue( "searchresults", $results );
  68              $this->_view->setValue( "searchtype", $this->_searchType );
  69              
  70              // finally, set up the pager and pass it to the view
  71              $pager = new Pager( "?op=summarySearch&amp;searchTerms=".$this->_searchTerms."&amp;searchType=".$this->_searchType."&amp;page=",
  72                                  View::getCurrentPageFromRequest(),
  73                                  $numResults,
  74                                  $itemsPerPage 
  75                                );
  76              $this->_view->setValue( "pager", $pager );
  77              
  78              $this->setCommonData();            
  79              
  80              return true;
  81          }
  82       }
  83  ?>


Généré le : Mon Nov 26 21:04:15 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics