Ejemplo n.º 1
0
 /**
  * Method to optimize the index and perform any necessary cleanup.
  *
  * @return  void
  *
  * @since   2.5
  */
 public function optimize()
 {
     // We don't want this form to be cached.
     header('Pragma: no-cache');
     header('Cache-Control: no-cache');
     header('Expires: -1');
     // Check for a valid token. If invalid, send a 403 with the error message.
     JSession::checkToken('request') or $this->sendResponse(new Exception(JText::_('JINVALID_TOKEN'), 403));
     // Put in a buffer to silence noise.
     ob_start();
     // Import the finder plugins.
     JPluginHelper::importPlugin('finder');
     try {
         // Optimize the index.
         FinderIndexer::optimize();
         // Get the indexer state.
         $state = FinderIndexer::getState();
         $state->start = 0;
         $state->complete = 1;
         // Send the response.
         $this->sendResponse($state);
     } catch (Exception $e) {
         $this->sendResponse($e);
     }
 }