Index: library/Zend/Navigation/Page/Mvc.php =================================================================== --- library/Zend/Navigation/Page/Mvc.php (revision 24692) +++ library/Zend/Navigation/Page/Mvc.php (working copy) @@ -94,7 +94,6 @@ */ protected $_resetParams = true; - /** * Whether href should be encoded when assembling URL * @@ -104,6 +103,14 @@ protected $_encodeUrl = true; /** + * Scheme to use when assembling URL + * + * @see getHref() + * @var string + */ + protected $_scheme; + + /** * Cached href * * The use of this variable minimizes execution time when getHref() is @@ -122,6 +129,14 @@ */ protected static $_urlHelper = null; + /** + * View helper for assembling URLs with schemes + * + * @see getHref() + * @var Zend_View_Helper_ServerUrl + */ + protected static $_schemeHelper = null; + // Accessors: /** @@ -229,6 +244,17 @@ $this->getResetParams(), $this->getEncodeUrl()); + // Use scheme? + $scheme = $this->getScheme(); + if (null !== $scheme) { + if (null === self::$_schemeHelper) { + require_once 'Zend/View/Helper/ServerUrl.php'; + self::$_schemeHelper = new Zend_View_Helper_ServerUrl(); + } + + $url = self::$_schemeHelper->setScheme($scheme)->serverUrl($url); + } + // Add the fragment identifier if it is set $fragment = $this->getFragment(); if (null !== $fragment) { @@ -468,6 +494,39 @@ } /** + * Sets scheme to use when assembling URL + * + * @see getHref() + * + * @param string|null $scheme scheme + * @return Zend_Navigation_Page_Mvc fluent interface, returns self + */ + public function setScheme($scheme) + { + if (null !== $scheme && !is_string($scheme)) { + require_once 'Zend/Navigation/Exception.php'; + throw new Zend_Navigation_Exception( + 'Invalid argument: $scheme must be a string or null' + ); + } + + $this->_scheme = $scheme; + return $this; + } + + /** + * Returns scheme to use when assembling URL + * + * @see getHref() + * + * @return string|null scheme or null + */ + public function getScheme() + { + return $this->_scheme; + } + + /** * Sets action helper for assembling URLs * * @see getHref() @@ -480,6 +539,19 @@ self::$_urlHelper = $uh; } + /** + * Sets view helper for assembling URLs with schemes + * + * @see getHref() + * + * @param Zend_View_Helper_ServerUrl $sh scheme helper + * @return void + */ + public static function setSchemeHelper(Zend_View_Helper_ServerUrl $sh) + { + self::$_schemeHelper = $sh; + } + // Public methods: /** @@ -499,6 +571,8 @@ 'route' => $this->getRoute(), 'reset_params' => $this->getResetParams(), 'encodeUrl' => $this->getEncodeUrl(), - )); + 'scheme' => $this->getScheme(), + ) + ); } }