예제 #1
0
파일: Modifier.php 프로젝트: forxer/tao
 /**
  * Converts text line breaks into HTML paragraphs and HTML line breaks.
  *
  * @param string $string String to transform
  * @return string
  */
 public function nlToPbr($string)
 {
     $string = trim($string);
     $string = Modifiers::linebreaks($string);
     $string = str_replace("\n", '<br />', $string);
     $string = str_replace('<br /><br />', "</p>\n<p>", $string);
     $string = str_replace('<p></p>', '', $string);
     return '<p>' . $string . '</p>' . PHP_EOL;
 }
예제 #2
0
파일: Model.php 프로젝트: forxer/tao
 protected function setSearchIndexableData(array &$data, $locale = 'fr')
 {
     if ($this->isSearchIndexable() && (!isset($data[$this->getSearchWordsColumn()]) || empty($data[$this->getSearchWordsColumn()]))) {
         $words = '';
         foreach ($data as $column => $values) {
             if (in_array($column, $this->getSearchIndexableColumns())) {
                 $words .= $values . ' ';
             }
         }
         $words = Modifiers::toIndexes($words);
         $aStopWords = $this->app['stopwords']->get($locale);
         $data[$this->getSearchWordsColumn()] = implode(' ', array_diff($words, $aStopWords));
     }
 }
예제 #3
0
 protected function searchColumn(QueryBuilder $queryBuilder, $model, $from, $in = null, array $params = [])
 {
     if (null === $in) {
         $in = $from;
     }
     if ($this->aCriteria[$from]) {
         $this->aCriteria[$from . '-words'] = Modifiers::toIndexes($this->aCriteria[$from]);
         if (!empty($this->aCriteria[$from . '-words'])) {
             $queryBuilder->searchInColumn($model, $in, $this->aCriteria[$from . '-words'], $params);
         } else {
             $this->aCriteria[$from] = $this->aCriteria[$from . '-words'] = null;
         }
     } else {
         $this->aCriteria[$from] = $this->aCriteria[$from . '-words'] = null;
     }
 }