예제 #1
0
 /**
  * Method to get the indexer state.
  *
  * @return  object  The indexer state object.
  *
  * @since   2.5
  */
 public static function getState()
 {
     // First, try to load from the internal state.
     if (!empty(self::$state)) {
         return self::$state;
     }
     // If we couldn't load from the internal state, try the session.
     $session = JFactory::getSession();
     $data = $session->get('_finder.state', null);
     // If the state is empty, load the values for the first time.
     if (empty($data)) {
         $data = new JObject();
         // Load the default configuration options.
         $data->options = JComponentHelper::getParams('com_finder');
         // Setup the weight lookup information.
         $data->weights = array(self::TITLE_CONTEXT => round($data->options->get('title_multiplier', 1.7), 2), self::TEXT_CONTEXT => round($data->options->get('text_multiplier', 0.7), 2), self::META_CONTEXT => round($data->options->get('meta_multiplier', 1.2), 2), self::PATH_CONTEXT => round($data->options->get('path_multiplier', 2.0), 2), self::MISC_CONTEXT => round($data->options->get('misc_multiplier', 0.3), 2));
         // Set the current time as the start time.
         $data->startTime = JFactory::getDate()->toSql();
         // Set the remaining default values.
         $data->batchSize = (int) $data->options->get('batch_size', 50);
         $data->batchOffset = 0;
         $data->totalItems = 0;
         $data->pluginState = array();
     }
     // Setup the profiler if debugging is enabled.
     if (JFactory::getApplication()->get('debug')) {
         self::$profiler = JProfiler::getInstance('FinderIndexer');
     }
     // Setup the stemmer.
     if ($data->options->get('stem', 1) && $data->options->get('stemmer', 'porter_en')) {
         FinderIndexerHelper::$stemmer = FinderIndexerStemmer::getInstance($data->options->get('stemmer', 'porter_en'));
     }
     // Set the state.
     self::$state = $data;
     return self::$state;
 }