예제 #1
0
파일: search.php 프로젝트: Cythral/futurebb
 function addKeyword($keyword, $locations)
 {
     //when adding a keyword, index its locations
     $keyword = strtolower($keyword);
     $word = new SearchWord($keyword);
     $word->setLocations(explode(',', $locations));
     $this->keywords[$keyword] = $word;
 }
 /**
  * Reads a didYouMean element and adds the content to the result object.
  * @param DOMNode $didYouMeanNode the node being inspected
  * @param GetSearchRecommendationResultBase $resultObj the result object to fill
  */
 private function readDidYouMean(DOMNode $didYouMeanNode, GetSearchRecommendationResultBase $resultObj)
 {
     //didyoumean string
     foreach ($didYouMeanNode->childNodes as $wordNode) {
         if ($wordNode->nodeName == "word") {
             $word = new SearchWord();
             $word->setWord($wordNode->textContent);
             //read word attributes
             foreach ($wordNode->attributes as $attribute) {
                 switch ($attribute->name) {
                     case "bold":
                         if ($attribute->value == "true") {
                             $word->setWrong(TRUE);
                         }
                         break;
                     case "searchRefiningOptions":
                         $word->setSearchRefiningOption($attribute->value);
                         break;
                 }
             }
             $resultObj->addDidYouMeanWord($word);
         }
     }
 }