summaryrefslogtreecommitdiffstats
path: root/library/vendor/Zend/View/Helper/BaseUrl.php
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 12:39:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 12:39:39 +0000
commit8ca6cc32b2c789a3149861159ad258f2cb9491e3 (patch)
tree2492de6f1528dd44eaa169a5c1555026d9cb75ec /library/vendor/Zend/View/Helper/BaseUrl.php
parentInitial commit. (diff)
downloadicingaweb2-upstream.tar.xz
icingaweb2-upstream.zip
Adding upstream version 2.11.4.upstream/2.11.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'library/vendor/Zend/View/Helper/BaseUrl.php')
-rw-r--r--library/vendor/Zend/View/Helper/BaseUrl.php114
1 files changed, 114 insertions, 0 deletions
diff --git a/library/vendor/Zend/View/Helper/BaseUrl.php b/library/vendor/Zend/View/Helper/BaseUrl.php
new file mode 100644
index 0000000..48f8049
--- /dev/null
+++ b/library/vendor/Zend/View/Helper/BaseUrl.php
@@ -0,0 +1,114 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_View
+ * @subpackage Helper
+ * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
+ * @version $Id$
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+
+/** @see Zend_View_Helper_Abstract */
+
+/**
+ * Helper for retrieving the BaseUrl
+ *
+ * @package Zend_View
+ * @subpackage Helper
+ * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class Zend_View_Helper_BaseUrl extends Zend_View_Helper_Abstract
+{
+ /**
+ * BaseUrl
+ *
+ * @var string
+ */
+ protected $_baseUrl;
+
+ /**
+ * Returns site's base url, or file with base url prepended
+ *
+ * $file is appended to the base url for simplicity
+ *
+ * @param string|null $file
+ * @return string
+ */
+ public function baseUrl($file = null)
+ {
+ // Get baseUrl
+ $baseUrl = $this->getBaseUrl();
+
+ // Remove trailing slashes
+ if (null !== $file) {
+ $file = '/' . ltrim($file, '/\\');
+ }
+
+ return $baseUrl . $file;
+ }
+
+ /**
+ * Set BaseUrl
+ *
+ * @param string $base
+ * @return Zend_View_Helper_BaseUrl
+ */
+ public function setBaseUrl($base)
+ {
+ $this->_baseUrl = rtrim($base, '/\\');
+ return $this;
+ }
+
+ /**
+ * Get BaseUrl
+ *
+ * @return string
+ */
+ public function getBaseUrl()
+ {
+ if ($this->_baseUrl === null) {
+ /** @see Zend_Controller_Front */
+ $baseUrl = Zend_Controller_Front::getInstance()->getBaseUrl();
+
+ // Remove scriptname, eg. index.php from baseUrl
+ $baseUrl = $this->_removeScriptName($baseUrl);
+
+ $this->setBaseUrl($baseUrl);
+ }
+
+ return $this->_baseUrl;
+ }
+
+ /**
+ * Remove Script filename from baseurl
+ *
+ * @param string $url
+ * @return string
+ */
+ protected function _removeScriptName($url)
+ {
+ if (!isset($_SERVER['SCRIPT_NAME'])) {
+ // We can't do much now can we? (Well, we could parse out by ".")
+ return $url;
+ }
+
+ if (($pos = strripos($url, basename($_SERVER['SCRIPT_NAME']))) !== false) {
+ $url = substr($url, 0, $pos);
+ }
+
+ return $url;
+ }
+}