Пример #1
0
 public function getFormActionUrl(Customweb_Payment_Authorization_ITransaction $transaction, array $formData)
 {
     $completeUrl = $this->getRedirectionUrl($transaction, $formData);
     $url = new Customweb_Http_Url($completeUrl);
     return $url->getBaseUrl() . $url->getPath();
 }
Пример #2
0
 public static function replaceRelativeUrls($content, $baseUrl)
 {
     $baseUrl = trim($baseUrl, '/ ');
     $baseUrl .= '/';
     $object = new Customweb_Util_Html();
     $url = new Customweb_Http_Url($baseUrl);
     $object->baseUrl = $baseUrl;
     $object->baseDomain = $url->getBaseUrl();
     $patterns = array('/(href=")([^"]*)(")/', '/(href=\')([^\']*)(\')/', '/(src=")([^"]*)(")/', '/(src=\')([^\']*)(\')/', '/(srcset=")([^"]*)(")/', '/(srcset=\')([^\']*)(\')/');
     foreach ($patterns as $pattern) {
         $content = preg_replace_callback($pattern, array($object, 'replaceRelativeUrl'), $content);
     }
     return $content;
 }
Пример #3
0
 /**
  * This method converts all relative and absolute URLs to absolute URLs.
  *
  * @param string $href
  * @param Customweb_Http_Url $baseUrl
  * @return Customweb_Http_Url
  */
 public static function toAbsoluteUrl($href, Customweb_Http_Url $baseUrl)
 {
     if ($href instanceof Customweb_Http_Url) {
         return $href;
     }
     $href = (string) $href;
     $href = trim($href);
     // If the URL string contains :// then the protocol etc. defined.
     if (strstr($href, '://')) {
         return new Customweb_Http_Url($href);
     } else {
         // Append a slash at the begin, when there is no one. This
         // insures that we get always a valid URL.
         if (substr($href, 0, 1) !== '/') {
             $href = '/' . $href;
         }
         return new Customweb_Http_Url($baseUrl->getBaseUrl() . $href);
     }
 }
Пример #4
0
 /**
  * This method compares two URLs and check if they are equal.
  *
  * @param Customweb_Http_Url $url
  * @return boolean Equal or not
  */
 public function equals($url)
 {
     if (!($url instanceof Customweb_Core_Url || $url instanceof Customweb_Http_Url)) {
         throw new InvalidArgumentException("Expects that the parameter for equals must be of type 'Customweb_Core_Url'.");
     }
     return $this->__toString() == $url->__toString();
 }
 public function getParameters(Customweb_Payment_Authorization_ITransaction $transaction, array $formData)
 {
     $completeUrl = $this->getRedirectionUrl($transaction, $formData);
     $url = new Customweb_Http_Url($completeUrl);
     $parameters = $url->getQueryAsArray();
     foreach ($parameters as $key => $value) {
         $parameters[$key] = utf8_encode(stripcslashes(utf8_decode($value)));
     }
     return $parameters;
 }
Пример #6
0
 /**
  * This method sets the message body. If you want to send no body, then
  * you can set the body to NULL with this method.
  *
  * @param string|array $body Body
  * @return Customweb_Http_Request
  */
 public function setBody($body)
 {
     if (is_array($body)) {
         $this->body = Customweb_Http_Url::parseArrayToString($body, true);
     } else {
         $this->body = $body;
     }
     return $this;
 }