/** * 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; }
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)); } }
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; } }