/** * (non-PHPdoc) * @see IfwPsn_Vendor_Zend_Validate_Interface::isValid() */ public function isValid($value) { $this->_setValue($value); // Validate the URI $valid = IfwPsn_Vendor_Zend_Uri::check($value); if ($valid) { return true; } else { $this->_error(self::MSG_URI); return false; } }
/** * Validates if a string is valid as a sitemap location * * @link http://www.sitemaps.org/protocol.php#locdef <loc> * * @param string $value value to validate * @return boolean */ public function isValid($value) { if (!is_string($value)) { $this->_error(self::INVALID); return false; } $this->_setValue($value); $result = IfwPsn_Vendor_Zend_Uri::check($value); if ($result !== true) { $this->_error(self::NOT_VALID); return false; } return true; }
/** * Get a specific cookie according to a URI and name * * @param IfwPsn_Vendor_Zend_Uri_Http|string $uri The uri (domain and path) to match * @param string $cookie_name The cookie's name * @param int $ret_as Whether to return cookies as objects of IfwPsn_Vendor_Zend_Http_Cookie or as strings * @return IfwPsn_Vendor_Zend_Http_Cookie|string */ public function getCookie($uri, $cookie_name, $ret_as = self::COOKIE_OBJECT) { if (is_string($uri)) { $uri = IfwPsn_Vendor_Zend_Uri::factory($uri); } if (!$uri instanceof IfwPsn_Vendor_Zend_Uri_Http) { require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Http/Exception.php'; throw new IfwPsn_Vendor_Zend_Http_Exception('Invalid URI specified'); } // Get correct cookie path $path = $uri->getPath(); $path = substr($path, 0, strrpos($path, '/')); if (!$path) { $path = '/'; } if (isset($this->cookies[$uri->getHost()][$path][$cookie_name])) { $cookie = $this->cookies[$uri->getHost()][$path][$cookie_name]; switch ($ret_as) { case self::COOKIE_OBJECT: return $cookie; break; case self::COOKIE_STRING_CONCAT_STRICT: return rtrim(trim($cookie->__toString()), ';'); break; case self::COOKIE_STRING_ARRAY: case self::COOKIE_STRING_CONCAT: return $cookie->__toString(); break; default: require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Http/Exception.php'; throw new IfwPsn_Vendor_Zend_Http_Exception("Invalid value passed for \$ret_as: {$ret_as}"); break; } } else { return false; } }
/** * Sets server url (scheme and host-related stuff without request URI) * * E.g. http://www.example.com * * @param string $serverUrl server URL to set (only * scheme and host) * @throws IfwPsn_Vendor_Zend_Uri_Exception if invalid server URL * @return IfwPsn_Vendor_Zend_View_Helper_Navigation_Sitemap fluent interface, returns * self */ public function setServerUrl($serverUrl) { require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Uri.php'; $uri = IfwPsn_Vendor_Zend_Uri::factory($serverUrl); $uri->setFragment(''); $uri->setPath(''); $uri->setQuery(''); if ($uri->valid()) { $this->_serverUrl = $uri->getUri(); } else { require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Uri/Exception.php'; $e = new IfwPsn_Vendor_Zend_Uri_Exception(sprintf('Invalid server URL: "%s"', $serverUrl)); $e->setView($this->view); throw $e; } return $this; }
/** * Set the URI for the next request * * @param IfwPsn_Vendor_Zend_Uri_Http|string $uri * @return IfwPsn_Vendor_Zend_Http_Client * @throws IfwPsn_Vendor_Zend_Http_Client_Exception */ public function setUri($uri) { if ($uri instanceof IfwPsn_Vendor_Zend_Uri_Http) { // clone the URI in order to keep the passed parameter constant $uri = clone $uri; } elseif (is_string($uri)) { $uri = IfwPsn_Vendor_Zend_Uri::factory($uri); } if (!$uri instanceof IfwPsn_Vendor_Zend_Uri_Http) { /** @see IfwPsn_Vendor_Zend_Http_Client_Exception */ require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Http/Client/Exception.php'; throw new IfwPsn_Vendor_Zend_Http_Client_Exception('Passed parameter is not a valid HTTP URI.'); } // Set auth if username and password has been specified in the uri if ($uri->getUsername() && $uri->getPassword()) { $this->setAuth($uri->getUsername(), $uri->getPassword()); } // We have no ports, set the defaults if (!$uri->getPort()) { $uri->setPort($uri->getScheme() == 'https' ? 443 : 80); } $this->uri = $uri; return $this; }
/** * Constructor * * If a $uri is passed, the object will attempt to populate itself using * that information. * * @param string|IfwPsn_Vendor_Zend_Uri $uri * @return void * @throws IfwPsn_Vendor_Zend_Controller_Request_Exception when invalid URI passed */ public function __construct($uri = null) { if (null !== $uri) { if (!$uri instanceof IfwPsn_Vendor_Zend_Uri) { $uri = IfwPsn_Vendor_Zend_Uri::factory($uri); } if ($uri->valid()) { $path = $uri->getPath(); $query = $uri->getQuery(); if (!empty($query)) { $path .= '?' . $query; } $this->setRequestUri($path); } else { require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Controller/Request/Exception.php'; throw new IfwPsn_Vendor_Zend_Controller_Request_Exception('Invalid URI provided to constructor'); } } else { $this->setRequestUri(); } }