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


PHP StringUtil::getWords方法代码示例

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


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

示例1: testFromHtmlWithLi

    public function testFromHtmlWithLi()
    {
        $sHtml = <<<EOT
\t\t<ul>
\t\t<li>Test1</li><li>Test2</li><li>Test3</li>
\t\t</ul>
EOT;
        $this->assertSame(array('test1', 'test2', 'test3'), StringUtil::getWords($sHtml, true));
    }
开发者ID:rapila,项目名称:cms-base,代码行数:9,代码来源:UtilGetWordsTests.php

示例2: display

 public function display(Template $oTemplate, $bIsPreview = false)
 {
     $sTemplateName = $this->oPage->getTemplateNameUsed();
     $sLanguageId = Session::language();
     $oListTemplate = null;
     $oItemTemplatePrototype = null;
     try {
         $oListTemplate = new Template("search_results/{$sTemplateName}");
         $oItemTemplatePrototype = new Template("search_results/{$sTemplateName}_item");
     } catch (Exception $e) {
         $oListTemplate = new Template("search_results/default");
         $oItemTemplatePrototype = new Template("search_results/default_item");
     }
     $aResults = array();
     $sWords = isset($_REQUEST['q']) ? $_REQUEST['q'] : '';
     if ($sWords) {
         $aWords = StringUtil::getWords($sWords, false, '%');
         $oSearchWordQuery = SearchIndexWordQuery::create();
         foreach ($aWords as $sWord) {
             $sWord = Synonyms::rootFor($sWord);
             $sComparison = Criteria::EQUAL;
             if (strpos($sWord, '%') !== false) {
                 $sComparison = Criteria::LIKE;
             }
             $oSearchWordQuery->addOr(SearchIndexWordPeer::WORD, $sWord, $sComparison);
         }
         $oSearchWordQuery->joinSearchIndex()->useQuery('SearchIndex')->joinPage()->useQuery('Page')->active(true)->filterByIsProtected(false)->endUse()->endUse();
         foreach ($oSearchWordQuery->find() as $oSearchIndexWord) {
             $iId = $oSearchIndexWord->getSearchIndexId();
             if (isset($aResults[$iId])) {
                 $aResults[$iId] += $oSearchIndexWord->getCount();
             } else {
                 $aResults[$iId] = $oSearchIndexWord->getCount();
             }
         }
         arsort($aResults);
     }
     $oListTemplate->replaceIdentifier('count', count($aResults));
     $oListTemplate->replaceIdentifier('search_string', $sWords);
     if (count($aResults) === 0) {
         $oListTemplate->replaceIdentifier('no_results', TranslationPeer::getString('wns.search.no_results', null, null, array('search_string' => $sWords)));
     }
     foreach ($aResults as $iIndexId => $iCount) {
         $oIndex = SearchIndexQuery::create()->findPk(array($iIndexId, $sLanguageId));
         if (!$oIndex || !$oIndex->getPage()) {
             continue;
         }
         $oItemTemplate = clone $oItemTemplatePrototype;
         $oIndex->renderListItem($oItemTemplate);
         $oItemTemplate->replaceIdentifier('count', $iCount);
         $oListTemplate->replaceIdentifierMultiple('items', $oItemTemplate);
     }
     $oTemplate->replaceIdentifier('search_results', $oListTemplate);
 }
开发者ID:rapila,项目名称:plugin-full_text_search,代码行数:54,代码来源:SearchResultPageTypeModule.php

示例3: getWords

 public function getWords()
 {
     $oUsedTemplate = new Template($this->oPage->getTemplateNameUsed());
     $sTemplateContents = '';
     foreach ($oUsedTemplate->identifiersMatching('container', Template::$ANY_VALUE) as $oTemplateIdentifier) {
         if ($oTemplateIdentifier->hasParameter('declaration_only')) {
             // Container exists only to appear in admin area, not be rendered in frontend (at least not directly)
             continue;
         }
         $sTemplateContents .= $oTemplateIdentifier->__toString();
     }
     foreach ($oUsedTemplate->identifiersMatching('autofill', Template::$ANY_VALUE) as $oTemplateIdentifier) {
         $sTemplateContents .= $oTemplateIdentifier->__toString();
     }
     $sTemplate = new Template($sTemplateContents, null, true);
     $this->display($sTemplate, false);
     return StringUtil::getWords($sTemplate, true);
 }
开发者ID:rapila,项目名称:cms-base,代码行数:18,代码来源:PageTypeModule.php

示例4: getWords

 /**
  * Returns the words for which this module should be listed in the site’s search index
  */
 public function getWords()
 {
     return StringUtil::getWords($this->renderFrontend(), true);
 }
开发者ID:rapila,项目名称:cms-base,代码行数:7,代码来源:FrontendModule.php

示例5: index

 private function index(array $aPath)
 {
     $oNavigationItem = $this->oRootNavigationItem;
     PageNavigationItem::clearCache();
     while (count($aPath) > 0) {
         $oNavigationItem = $oNavigationItem->namedChild(array_shift($aPath), $this->sLanguageId, true, true);
     }
     FilterModule::getFilters()->handleNavigationPathFound($this->oRootNavigationItem, $oNavigationItem);
     FrontendManager::$CURRENT_NAVIGATION_ITEM = $oNavigationItem;
     $oPageNavigationItem = $oNavigationItem;
     while (!$oPageNavigationItem instanceof PageNavigationItem) {
         $oPageNavigationItem = $oPageNavigationItem->getParent();
     }
     FrontendManager::$CURRENT_PAGE = $oPageNavigationItem->getMe();
     $oPage = FrontendManager::$CURRENT_PAGE;
     $bIsNotFound = false;
     FilterModule::getFilters()->handlePageHasBeenSet($oPage, $bIsNotFound, $oNavigationItem);
     FilterModule::getFilters()->handleRequestStarted();
     FilterModule::getFilters()->handlePageNotFoundDetectionComplete($bIsNotFound, $oPage, $oNavigationItem, array(&$bIsNotFound));
     if ($bIsNotFound) {
         return false;
     }
     $sDescription = $oNavigationItem->getDescription($this->sLanguageId);
     if ($sDescription === null) {
         $sDescription = $oPage->getDescription($this->sLanguageId);
     }
     $aKeywords = array();
     foreach ($oPage->getConsolidatedKeywords($this->sLanguageId, true) as $sKeyword) {
         $aKeywords = array_merge($aKeywords, StringUtil::getWords($sKeyword));
     }
     $sTitle = $oNavigationItem->getTitle($this->sLanguageId);
     $sLinkText = $oNavigationItem->getLinkText($this->sLanguageId);
     if (!$sLinkText) {
         $sLinkText = $sTitle;
     }
     $sName = $oNavigationItem->getName();
     // Page type can prevent indexing
     if (!self::doIndex($oPage->getPageType(), $oNavigationItem)) {
         return false;
     }
     $oPageType = PageTypeModule::getModuleInstance($oPage->getPageType(), $oPage, $oNavigationItem);
     $aWords = $oPageType->getWords();
     $aWords = array_merge($aWords, StringUtil::getWords($sDescription), $aKeywords, StringUtil::getWords($sTitle), StringUtil::getWords($sLinkText), array($sName));
     $aPagePath = $oPage->getLink();
     $aNavigationItemPath = $oNavigationItem->getLink();
     $sPath = implode('/', array_diff($aNavigationItemPath, $aPagePath));
     $oSearchIndex = new SearchIndex();
     $oSearchIndex->setPageId($oPage->getId());
     $oSearchIndex->setPath($sPath);
     $oSearchIndex->setLinkText($sLinkText);
     $oSearchIndex->setPageTitle($sTitle);
     $oSearchIndex->setLanguageId($this->sLanguageId);
     $oSearchIndex->save();
     foreach ($aWords as $sWord) {
         $sWord = Synonyms::rootFor($sWord, $this->sLanguageId);
         $oSearchIndexWord = SearchIndexWordQuery::create()->filterBySearchIndex($oSearchIndex)->filterByWord($sWord)->findOne();
         if ($oSearchIndexWord === null) {
             $oSearchIndexWord = new SearchIndexWord();
             $oSearchIndexWord->setSearchIndex($oSearchIndex);
             $oSearchIndexWord->setWord($sWord);
         } else {
             $oSearchIndexWord->incrementCount();
         }
         $oSearchIndexWord->save();
     }
     return true;
 }
开发者ID:rapila,项目名称:plugin-full_text_search,代码行数:67,代码来源:UpdateSearchIndexFileModule.php

示例6: getContentInfo

 public static function getContentInfo($oLanguageObject)
 {
     $sText = RichtextUtil::parseStorageForFrontendOutput(stream_get_contents($oLanguageObject->getData()));
     return implode(" ", StringUtil::getWords($sText, true));
 }
开发者ID:rapila,项目名称:cms-base,代码行数:5,代码来源:TextFrontendModule.php


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