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


PHP FinderIndexer::setState方法代码示例

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


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

示例1: testSetStateBadData

 /**
  * Tests the setState method with an invalid data object
  *
  * @return  void
  *
  * @since   3.0
  */
 public function testSetStateBadData()
 {
     // Set up our test object
     $test = new Registry();
     $test->set('string', 'Testing FinderIndexer::setState()');
     // Attempt to set the state
     $this->assertFalse(FinderIndexer::setState($test), 'setState method is not compatible with Registry');
 }
开发者ID:Rai-Ka,项目名称:joomla-cms,代码行数:15,代码来源:FinderIndexerTest.php

示例2: batch

 /**
  * Method to run the next batch of content through the indexer.
  *
  * @return  void
  *
  * @since   2.5
  */
 public function batch()
 {
     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 batch process', 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();
     // Remove the script time limit.
     @set_time_limit(0);
     // Get the indexer state.
     $state = FinderIndexer::getState();
     // Reset the batch offset.
     $state->batchOffset = 0;
     // Update the indexer state.
     FinderIndexer::setState($state);
     // Import the finder plugins.
     JPluginHelper::importPlugin('finder');
     /*
      * We are going to swap out the raw document object with an HTML document
      * in order to work around some plugins that don't do proper environment
      * checks before trying to use HTML document functions.
      */
     $raw = clone JFactory::getDocument();
     $lang = JFactory::getLanguage();
     // Get the document properties.
     $attributes = array('charset' => 'utf-8', 'lineend' => 'unix', 'tab' => '  ', 'language' => $lang->getTag(), 'direction' => $lang->isRtl() ? 'rtl' : 'ltr');
     // Get the HTML document.
     $html = JDocument::getInstance('html', $attributes);
     $doc = JFactory::getDocument();
     // Swap the documents.
     $doc = $html;
     // Get the admin application.
     $admin = clone JFactory::getApplication();
     // Get the site app.
     $site = JApplication::getInstance('site');
     // Swap the app.
     $app = JFactory::getApplication();
     $app = $site;
     // Start the indexer.
     try {
         // Trigger the onBeforeIndex event.
         JEventDispatcher::getInstance()->trigger('onBeforeIndex');
         // Trigger the onBuildIndex event.
         JEventDispatcher::getInstance()->trigger('onBuildIndex');
         // Get the indexer state.
         $state = FinderIndexer::getState();
         $state->start = 0;
         $state->complete = 0;
         // Swap the documents back.
         $doc = $raw;
         // Swap the applications back.
         $app = $admin;
         // Send the response.
         $this->sendResponse($state);
     } catch (Exception $e) {
         // Swap the documents back.
         $doc = $raw;
         // Send the response.
         $this->sendResponse($e);
     }
 }
开发者ID:grlf,项目名称:eyedock,代码行数:82,代码来源:indexer.json.php

示例3: testSetStateBadData

 /**
  * Tests the setState method with an invalid data object
  *
  * @return  void
  *
  * @since   3.0
  */
 public function testSetStateBadData()
 {
     // Override the database in this method
     $this->saveFactoryDatabase();
     // Set up our test object
     $test = new JRegistry();
     $test->set('string', 'Testing FinderIndexer::setState()');
     // Attempt to set the state
     $this->assertThat(FinderIndexer::setState($test), $this->isFalse(), 'setState method is not compatible with JRegistry');
     // Restore the database
     $this->restoreFactoryDatabase();
 }
开发者ID:shoffmann52,项目名称:install-from-web-server,代码行数:19,代码来源:FinderIndexerTest.php

示例4: onBuildIndex

 /**
  * Method to index a batch of content items. This method can be called by
  * the indexer many times throughout the indexing process depending on how
  * much content is available for indexing. It is important to track the
  * progress correctly so we can display it to the user.
  *
  * @return  boolean  True on success.
  *
  * @since   2.5
  * @throws  Exception on error.
  */
 public function onBuildIndex()
 {
     // Get the indexer and adapter state.
     $iState = FinderIndexer::getState();
     $aState = $iState->pluginState[$this->context];
     // Check the progress of the indexer and the adapter.
     if ($iState->batchOffset == $iState->batchSize || $aState['offset'] == $aState['total']) {
         return true;
     }
     // Get the batch offset and size.
     $offset = (int) $aState['offset'];
     $limit = (int) ($iState->batchSize - $iState->batchOffset);
     // Get the content items to index.
     $items = $this->getItems($offset, $limit);
     // Iterate through the items and index them.
     for ($i = 0, $n = count($items); $i < $n; $i++) {
         // Index the item.
         $this->index($items[$i]);
         // Adjust the offsets.
         $offset++;
         $iState->batchOffset++;
         $iState->totalItems--;
     }
     // Update the indexer state.
     $aState['offset'] = $offset;
     $iState->pluginState[$this->context] = $aState;
     FinderIndexer::setState($iState);
     return true;
 }
开发者ID:fur81,项目名称:zofaxiopeu,代码行数:40,代码来源:adapter.php

示例5: onBuildIndex

 /**
  * Method to index a batch of content items. This method can be called by
  * the indexer many times throughout the indexing process depending on how
  * much content is available for indexing. It is important to track the
  * progress correctly so we can display it to the user.
  *
  * @return  boolean  True on success.
  *
  * @since   2.5
  * @throws  Exception on error.
  */
 public function onBuildIndex()
 {
     JLog::add('FinderIndexerAdapter::onBuildIndex', JLog::INFO);
     // Get the indexer and adapter state.
     $iState = FinderIndexer::getState();
     $aState = $iState->pluginState[$this->context];
     // Check the progress of the indexer and the adapter.
     if ($iState->batchOffset == $iState->batchSize || $aState['offset'] == $aState['total']) {
         return true;
     }
     // Get the batch offset and size.
     $offset = (int) $aState['offset'];
     $limit = (int) ($iState->batchSize - $iState->batchOffset);
     // Get the content items to index.
     $items = $this->getItems($offset, $limit);
     // Iterate through the items and index them.
     $item = null;
     foreach ($items as $item) {
         $this->index($item);
     }
     if ($item) {
         // Adjust the offsets.
         $iState->batchOffset = $iState->batchSize;
         $iState->totalItems -= $item->id - $offset;
         // Update the indexer state.
         $aState['offset'] = $item->id;
         $iState->pluginState[$this->context] = $aState;
         FinderIndexer::setState($iState);
     }
     unset($items, $item);
     return true;
 }
开发者ID:giabmf11,项目名称:Kunena-Forum,代码行数:43,代码来源:kunena.php


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