当前位置: 首页>>代码示例>>PHP>>正文


PHP FinderIndexer::resetState方法代码示例

本文整理汇总了PHP中FinderIndexer::resetState方法的典型用法代码示例。如果您正苦于以下问题:PHP FinderIndexer::resetState方法的具体用法?PHP FinderIndexer::resetState怎么用?PHP FinderIndexer::resetState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FinderIndexer的用法示例。


在下文中一共展示了FinderIndexer::resetState方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: start

 /**
  * Method to start the indexer.
  *
  * @return  void
  *
  * @since   2.5
  */
 public function start()
 {
     static $log;
     $params = JComponentHelper::getParams('com_finder');
     if ($params->get('enable_logging', '0')) {
         if ($log == null) {
             $options['format'] = '{DATE}\\t{TIME}\\t{LEVEL}\\t{CODE}\\t{MESSAGE}';
             $options['text_file'] = 'indexer.php';
             $log = JLog::addLogger($options);
         }
     }
     // Log the start
     JLog::add('Starting the indexer', JLog::INFO);
     // 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();
     // Reset the indexer state.
     FinderIndexer::resetState();
     // Import the finder plugins.
     JPluginHelper::importPlugin('finder');
     // Add the indexer language to JS
     JText::script('COM_FINDER_AN_ERROR_HAS_OCCURRED');
     JText::script('COM_FINDER_NO_ERROR_RETURNED');
     // Start the indexer.
     try {
         // Trigger the onStartIndex event.
         JEventDispatcher::getInstance()->trigger('onStartIndex');
         // Get the indexer state.
         $state = FinderIndexer::getState();
         $state->start = 1;
         // Send the response.
         $this->sendResponse($state);
     } catch (Exception $e) {
         $this->sendResponse($e);
     }
 }
开发者ID:grlf,项目名称:eyedock,代码行数:48,代码来源:indexer.json.php

示例2: start

 /**
  * Method to start the indexer.
  *
  * @return  void
  *
  * @since   2.5
  */
 public function start()
 {
     $params = JComponentHelper::getParams('com_finder');
     if ($params->get('enable_logging', '0')) {
         $options['format'] = '{DATE}\\t{TIME}\\t{LEVEL}\\t{CODE}\\t{MESSAGE}';
         $options['text_file'] = 'indexer.php';
         JLog::addLogger($options);
     }
     // Log the start
     JLog::add('Starting the indexer', JLog::INFO);
     // We don't want this form to be cached.
     $app = JFactory::getApplication();
     $app->setHeader('Expires', 'Mon, 1 Jan 2001 00:00:00 GMT', true);
     $app->setHeader('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT', true);
     $app->setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', false);
     $app->setHeader('Pragma', 'no-cache');
     // 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();
     // Reset the indexer state.
     FinderIndexer::resetState();
     // Import the finder plugins.
     JPluginHelper::importPlugin('finder');
     // Add the indexer language to JS
     JText::script('COM_FINDER_AN_ERROR_HAS_OCCURRED');
     JText::script('COM_FINDER_NO_ERROR_RETURNED');
     // Start the indexer.
     try {
         // Trigger the onStartIndex event.
         JFactory::getApplication()->triggerEvent('onStartIndex');
         // Get the indexer state.
         $state = FinderIndexer::getState();
         $state->start = 1;
         // Send the response.
         $this->sendResponse($state);
     } catch (Exception $e) {
         $this->sendResponse($e);
     }
 }
开发者ID:Rai-Ka,项目名称:joomla-cms,代码行数:47,代码来源:indexer.json.php

示例3: testResetState

 /**
  * Tests the resetState method
  *
  * @return  void
  *
  * @since   3.0
  */
 public function testResetState()
 {
     // Reset the state
     FinderIndexer::resetState();
     // Test we get a null object
     $this->assertNull(JFactory::getSession()->get('_finder.state', null));
 }
开发者ID:Rai-Ka,项目名称:joomla-cms,代码行数:14,代码来源:FinderIndexerTest.php

示例4: createIndexes

 public function createIndexes(InputInterface $input, OutputInterface $output)
 {
     $output->writeln(\JText::_('FINDER_CLI_INDEX_PURGE'));
     require_once JPATH_ADMINISTRATOR . '/components/com_finder/helpers/indexer/indexer.php';
     // Initialize the time value.
     $this->time = microtime(true);
     // Remove the script time limit.
     @set_time_limit(0);
     $_SERVER['HTTP_HOST'] = 'domain.com';
     // Disable caching.
     $config = \JFactory::getConfig();
     $config->set('caching', 0);
     $config->set('cache_handler', 'file');
     // Reset the indexer state.
     \FinderIndexer::resetState();
     // Import the finder plugins.
     \JPluginHelper::importPlugin('finder');
     // Starting Indexer.
     $output->writeln(\JText::_('FINDER_CLI_STARTING_INDEXER'));
     // Trigger the onStartIndex event.
     \JEventDispatcher::getInstance()->trigger('onStartIndex');
     // Remove the script time limit.
     @set_time_limit(0);
     // Get the indexer state.
     $state = \FinderIndexer::getState();
     // Setting up plugins.
     $output->writeln(\JText::_('FINDER_CLI_SETTING_UP_PLUGINS'));
     // Trigger the onBeforeIndex event.
     \JEventDispatcher::getInstance()->trigger('onBeforeIndex');
     // Startup reporting.
     $output->writeln(\JText::sprintf('FINDER_CLI_SETUP_ITEMS', $state->totalItems, round(microtime(true) - $this->time, 3)), true);
     // Get the number of batches.
     $t = (int) $state->totalItems;
     $c = (int) ceil($t / $state->batchSize);
     $c = $c === 0 ? 1 : $c;
     try {
         // Process the batches.
         for ($i = 0; $i < $c; $i++) {
             // Set the batch start time.
             $this->qtime = microtime(true);
             // Reset the batch offset.
             $state->batchOffset = 0;
             // Trigger the onBuildIndex event.
             \JEventDispatcher::getInstance()->trigger('onBuildIndex');
             // Batch reporting.
             $output->writeln("<info>" . \JText::sprintf('FINDER_CLI_BATCH_COMPLETE', $i + 1, round(microtime(true) - $this->qtime, 3)) . "</info>");
         }
     } catch (Exception $e) {
         // Reset the indexer state.
         \FinderIndexer::resetState();
         throw new \RuntimeException($e->getMessage());
     }
     // Reset the indexer state.
     \FinderIndexer::resetState();
 }
开发者ID:eitamar,项目名称:joomlatools-console,代码行数:55,代码来源:Index.php

示例5: _index

 /**
  * Run the indexer
  *
  * @return  void
  *
  * @since   2.5
  */
 private function _index()
 {
     // initialize the time value
     $this->_time = microtime(true);
     // import library dependencies
     require_once JPATH_ADMINISTRATOR . '/components/com_finder/helpers/indexer/indexer.php';
     jimport('joomla.application.component.helper');
     // fool the system into thinking we are running as JSite with Finder as the active component
     JFactory::getApplication('site');
     $_SERVER['HTTP_HOST'] = 'domain.com';
     define('JPATH_COMPONENT_ADMINISTRATOR', JPATH_ADMINISTRATOR . '/components/com_finder');
     // Disable caching.
     $config = JFactory::getConfig();
     $config->set('caching', 0);
     $config->set('cache_handler', 'file');
     // Reset the indexer state.
     FinderIndexer::resetState();
     // Import the finder plugins.
     JPluginHelper::importPlugin('finder');
     // Starting Indexer.
     $this->out(JText::_('FINDER_CLI_STARTING_INDEXER'), true);
     // Trigger the onStartIndex event.
     JDispatcher::getInstance()->trigger('onStartIndex');
     // Remove the script time limit.
     @set_time_limit(0);
     // Get the indexer state.
     $state = FinderIndexer::getState();
     // Setting up plugins.
     $this->out(JText::_('FINDER_CLI_SETTING_UP_PLUGINS'), true);
     // Trigger the onBeforeIndex event.
     JDispatcher::getInstance()->trigger('onBeforeIndex');
     // Startup reporting.
     $this->out(JText::sprintf('FINDER_CLI_SETUP_ITEMS', $state->totalItems, round(microtime(true) - $this->_time, 3)), true);
     // Get the number of batches.
     $t = (int) $state->totalItems;
     $c = (int) ceil($t / $state->batchSize);
     $c = $c === 0 ? 1 : $c;
     // Process the batches.
     for ($i = 0; $i < $c; $i++) {
         // Set the batch start time.
         $this->_qtime = microtime(true);
         // Reset the batch offset.
         $state->batchOffset = 0;
         // Trigger the onBuildIndex event.
         JDispatcher::getInstance()->trigger('onBuildIndex');
         // Batch reporting.
         $this->out(JText::sprintf('FINDER_CLI_BATCH_COMPLETE', $i + 1, round(microtime(true) - $this->_qtime, 3)), true);
     }
     // Total reporting.
     $this->out(JText::sprintf('FINDER_CLI_PROCESS_COMPLETE', round(microtime(true) - $this->_time, 3)), true);
     // Reset the indexer state.
     FinderIndexer::resetState();
 }
开发者ID:raeldc,项目名称:joomla-cms,代码行数:60,代码来源:run.php

示例6: index

 /**
  * Run the indexer.
  *
  * @return  void
  *
  * @since   2.5
  */
 private function index()
 {
     require_once JPATH_ADMINISTRATOR . '/components/com_finder/helpers/indexer/indexer.php';
     // Disable caching.
     $config = JFactory::getConfig();
     $config->set('caching', 0);
     $config->set('cache_handler', 'file');
     // Reset the indexer state.
     FinderIndexer::resetState();
     // Import the finder plugins.
     JPluginHelper::importPlugin('finder');
     // Starting Indexer.
     $this->out(JText::_('FINDER_CLI_STARTING_INDEXER'), true);
     // Trigger the onStartIndex event.
     JFactory::getApplication()->triggerEvent('onStartIndex');
     // Remove the script time limit.
     @set_time_limit(0);
     // Get the indexer state.
     $state = FinderIndexer::getState();
     // Setting up plugins.
     $this->out(JText::_('FINDER_CLI_SETTING_UP_PLUGINS'), true);
     // Trigger the onBeforeIndex event.
     JFactory::getApplication()->triggerEvent('onBeforeIndex');
     // Startup reporting.
     $this->out(JText::sprintf('FINDER_CLI_SETUP_ITEMS', $state->totalItems, round(microtime(true) - $this->time, 3)), true);
     // Get the number of batches.
     $t = (int) $state->totalItems;
     $c = (int) ceil($t / $state->batchSize);
     $c = $c === 0 ? 1 : $c;
     try {
         // Process the batches.
         for ($i = 0; $i < $c; $i++) {
             // Set the batch start time.
             $this->qtime = microtime(true);
             // Reset the batch offset.
             $state->batchOffset = 0;
             // Trigger the onBuildIndex event.
             JFactory::getApplication()->triggerEvent('onBuildIndex');
             // Batch reporting.
             $this->out(JText::sprintf('FINDER_CLI_BATCH_COMPLETE', $i + 1, round(microtime(true) - $this->qtime, 3)), true);
         }
     } catch (Exception $e) {
         // Display the error
         $this->out($e->getMessage(), true);
         // Reset the indexer state.
         FinderIndexer::resetState();
         // Close the app
         $this->close($e->getCode());
     }
     // Reset the indexer state.
     FinderIndexer::resetState();
 }
开发者ID:Rai-Ka,项目名称:joomla-cms,代码行数:59,代码来源:finder_indexer.php

示例7: testResetState

 /**
  * Tests the resetState method
  *
  * @return  void
  *
  * @since   3.0
  */
 public function testResetState()
 {
     // Override the database in this method
     $this->saveFactoryDatabase();
     // Reset the state
     FinderIndexer::resetState();
     // Test we get a null object
     $this->assertThat(JFactory::getSession()->get('_finder.state', null), $this->isNull());
     // Restore the database
     $this->restoreFactoryDatabase();
 }
开发者ID:shoffmann52,项目名称:install-from-web-server,代码行数:18,代码来源:FinderIndexerTest.php


注:本文中的FinderIndexer::resetState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。