Пример #1
0
 /**
  * @see \Ableron\Core\Router\Route\RouteInterface::match()
  */
 public function match(Uri $moduleRequestUri, HttpRequest $request)
 {
     // prepare module request URI
     $moduleRequestUriNormalized = $this->routeParameters['isCaseSensitive'] ? $moduleRequestUri->getPath() : StringUtil::toLowerCase($moduleRequestUri->getPath());
     // handle "exactMath"
     if ($this->routeParameters['exactMatch'] !== null) {
         $exactMatchPattern = $this->routeParameters['isCaseSensitive'] ? $this->routeParameters['exactMatch'] : StringUtil::toLowerCase($this->routeParameters['exactMatch']);
         return $exactMatchPattern === $moduleRequestUriNormalized ? $this : null;
     }
     // handle "startsWith"
     if ($this->routeParameters['startsWith'] !== null) {
         $startsWithPattern = $this->routeParameters['isCaseSensitive'] ? $this->routeParameters['startsWith'] : StringUtil::toLowerCase($this->routeParameters['startsWith']);
         return StringUtil::startsWith($moduleRequestUriNormalized, $startsWithPattern) ? $this : null;
     }
     // no match
     return null;
 }
Пример #2
0
 /**
  * @see \Ableron\Core\Form\FormInterface::getOpenTag()
  */
 public function getOpenTag()
 {
     // get form attributes
     $formAttributes = $this->attributes->toArray();
     // if name is set but and id is not, treat element name as id
     if (!$this->attributes->containsKey('id') && $this->attributes->containsKey(self::ATTR_NAME)) {
         $formAttributes['id'] = $this->attributes->get([self::ATTR_NAME]);
     }
     // declare attribute strings
     $attributeStrings = array();
     // build attribute string
     foreach ($formAttributes as $formAttributeName => $formAttributeValue) {
         // make key lower case
         $formAttributeName = StringUtil::toLowerCase($formAttributeName);
         // skip boolean attributes which values are "false" (false = default)
         if ($formAttributeValue === false) {
             continue;
         }
         // compose attribute
         $attributeStrings[] = sprintf('%s="%s"', StringUtil::encodeHtml($formAttributeName), StringUtil::encodeHtml($formAttributeValue));
     }
     // build final HTML tag
     return sprintf('<form %s>', implode(' ', $attributeStrings));
 }
 /**
  * @see \Ableron\Lib\Collections\Abstracts\AbstractMap::__construct()
  */
 public function __construct(array $elements = array())
 {
     parent::__construct(function ($key) {
         return StringUtil::toLowerCase($key);
     }, null, $elements);
 }
Пример #4
0
 /**
  * Normalizes the given token.
  *
  * If $tokenIsParameterValue equals to FALSE, the given token is expected to
  * be a primary type, a sub type or a parameter name.
  *
  * @param string $token The token to normalize
  * @param bool $tokenIsParameterValue Whether the given token is a parameter value
  * @return string
  */
 public static function normalizeToken($token, $tokenIsParameterValue = false)
 {
     return $tokenIsParameterValue ? StringUtil::dequote(self::stripComments($token)) : StringUtil::toLowerCase(self::stripComments($token));
 }
Пример #5
0
 /**
  * Normalizes the given host name according to RFC-3986.
  * Additionally normalizes IPv6 addresses.
  *
  * Makes the host name lower case.
  * Makes the percent encodings upper case.
  * Makes sure percent encoding is applied only when necessary.
  * Reduces a given IPv6 address to its shortest representation.
  *
  * @param string $host The host name to normalize
  * @return string
  */
 public static function normalizeHost($host)
 {
     // normalize encoding and character case
     $host = preg_replace_callback('/%[[:xdigit:]]{2}/', function ($match) {
         return strtoupper($match[0]);
     }, StringUtil::toLowerCase(self::encodeHost($host)));
     // normalize IPv6
     if (filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false) {
         $host = inet_ntop(inet_pton($host));
     }
     // return the normalized host
     return $host;
 }