private function fixComment($text) { $escaped = \Latte\Runtime\Filters::escapeHtml($text, ENT_COMPAT); $esmiled = $this->smileReplace($escaped); $reg = '#(http://|ftp://|(www\\.))([\\w\\-]*\\.[\\w\\-\\.]*([/?][^\\s]*)?)#'; return preg_replace_callback($reg, 'self::createLink', $esmiled); }
/** * @param mixed $value * @return mixed */ protected function formatValue($value) { if ($value === NULL || is_bool($value)) { return $this->applyReplacement($value); } elseif (is_scalar($value)) { $value = \Latte\Runtime\Filters::escapeHtml($value); $replaced = $this->applyReplacement($value); if ($value !== $replaced && is_scalar($replaced)) { return $replaced; } } return $value instanceof \DateTime ? $value->format($this->dateFormat) : date($this->dateFormat, is_numeric($value) ? $value : strtotime($value)); //@todo notice for "01.01.1970" }
/** * @param mixed $column * @param array $conditions * @param int $limit * @return array * @throws Exception */ public function suggest($column, array $conditions, $limit) { $data = $this->data; foreach ($conditions as $condition) { $data = $this->makeWhere($condition, $data); } array_slice($data, 1, $limit); $items = []; foreach ($data as $row) { if (is_string($column)) { $value = (string) $row[$column]; } elseif (is_callable($column)) { $value = (string) $column($row); } else { $type = gettype($column); throw new Exception("Column of suggestion must be string or callback, {$type} given."); } $items[$value] = \Latte\Runtime\Filters::escapeHtml($value); } sort($items); return array_values($items); }
/** * Returns links for types. * * @param string $annotation * @param ElementReflectionInterface $reflectionElement * @return string */ public function typeLinks($annotation, ElementReflectionInterface $reflectionElement) { $links = []; // typehints can not contains spaces // valid typehint is: // [TYPE[|TYPE[|...]][SPACE[METHOD|PARAM][DESCRIPTION]] $parts = explode(' ', $annotation); foreach (explode('|', $parts[0]) as $type) { $type = $this->getTypeName($type, false); $links[] = $this->resolveLink($type, $reflectionElement) ?: LatteFilters::escapeHtml(ltrim($type, '\\')); } return implode('|', $links); }
/** * @param mixed $value * @return mixed */ protected function formatValue($value) { $value = is_string($value) ? \Latte\Runtime\Filters::escapeHtml($value) : $value; return $this->applyReplacement($value); }
/** * Returns links for types. * * @param string $annotation * @param ElementReflectionInterface $reflectionElement * @return string */ public function typeLinks($annotation, ElementReflectionInterface $reflectionElement) { $links = []; list($types) = Strings::split($annotation); if (!empty($types) && $types[0] === '$') { $types = null; } foreach (explode('|', $types) as $type) { $type = $this->getTypeName($type, false); $links[] = $this->resolveLink($type, $reflectionElement) ?: LatteFilters::escapeHtml(ltrim($type, '\\')); } return implode('|', $links); }
/** * @param string $url * @param Html|string $text * @param bool $escape * @param array $classes * @return string */ public function build($url, $text, $escape = TRUE, array $classes = []) { return Html::el('a')->href($url)->setHtml($escape ? Filters::escapeHtml($text) : $text)->addAttributes(['class' => $classes])->render(); }
/** * @param mixed $column * @param array $conditions * @param int $limit * @return array * @throws Exception */ public function suggest($column, array $conditions, $limit) { $qb = clone $this->qb; $qb->setMaxResults($limit); if (is_string($column)) { $mapping = isset($this->filterMapping[$column]) ? $this->filterMapping[$column] : current($qb->getRootAliases()) . '.' . $column; $qb->select($mapping)->distinct()->orderBy($mapping); } foreach ($conditions as $condition) { $this->makeWhere($condition, $qb); } $items = []; $data = $qb->getQuery()->getScalarResult(); foreach ($data as $row) { if (is_string($column)) { $value = (string) current($row); } elseif (is_callable($column)) { $value = (string) $column($row); } else { $type = gettype($column); throw new Exception("Column of suggestion must be string or callback, {$type} given."); } $items[$value] = \Latte\Runtime\Filters::escapeHtml($value); } is_callable($column) && sort($items); return array_values($items); }
/** * @param mixed $column * @param array $conditions * @param int $limit * @return array * @throws Exception */ public function suggest($column, array $conditions, $limit) { $fluent = clone $this->fluent; if (is_string($column)) { $fluent->removeClause('SELECT')->select("DISTINCT %n", $column)->orderBy("%n", $column, 'ASC'); } foreach ($conditions as $condition) { $this->makeWhere($condition, $fluent); } $items = []; $data = $fluent->fetchAll(0, $limit); foreach ($data as $row) { if (is_string($column)) { $value = (string) $row[$column]; } elseif (is_callable($column)) { $value = (string) $column($row); } else { $type = gettype($column); throw new Exception("Column of suggestion must be string or callback, {$type} given."); } $items[$value] = \Latte\Runtime\Filters::escapeHtml($value); } is_callable($column) && sort($items); return array_values($items); }
/** * @param mixed $column * @param array $conditions * @param int $limit * @return array * @throws Exception */ public function suggest($column, array $conditions, $limit) { $selection = clone $this->selection; is_string($column) && $selection->select("DISTINCT {$column}")->order($column); $selection->limit($limit); foreach ($conditions as $condition) { $this->makeWhere($condition, $selection); } $items = []; foreach ($selection as $row) { if (is_string($column)) { $value = (string) $row[$column]; } elseif (is_callable($column)) { $value = (string) $column($row); } else { $type = gettype($column); throw new Exception("Column of suggestion must be string or callback, {$type} given."); } $items[$value] = \Latte\Runtime\Filters::escapeHtml($value); } is_callable($column) && sort($items); return array_values($items); }