diff --git a/application/controllers/AuthenticationController.php b/application/controllers/AuthenticationController.php
index e47b9f1f2..9a5979019 100644
--- a/application/controllers/AuthenticationController.php
+++ b/application/controllers/AuthenticationController.php
@@ -58,8 +58,8 @@ class AuthenticationController extends ActionController
*/
public function loginAction()
{
- $this->replaceLayout = true;
$credentials = new Credential();
+ $this->_helper->layout->setLayout('inline');
$this->view->form = new LoginForm();
$this->view->form->setRequest($this->_request);
$this->view->title = "Icinga Web Login";
@@ -98,10 +98,10 @@ class AuthenticationController extends ActionController
*/
public function logoutAction()
{
+ $this->_helper->layout->setLayout('inline');
$auth = AuthManager::getInstance(null, array(
'writeSession' => $this->modifiesSession
));
- $this->replaceLayout = true;
$auth->removeAuthorization();
$this->redirectToLogin();
}
diff --git a/application/views/scripts/authentication/login.phtml b/application/views/scripts/authentication/login.phtml
index 45ec5603d..9b56c817c 100644
--- a/application/views/scripts/authentication/login.phtml
+++ b/application/views/scripts/authentication/login.phtml
@@ -1,4 +1,3 @@
-
Login
@@ -10,3 +9,16 @@
+
+
\ No newline at end of file
diff --git a/library/Icinga/Web/Controller/ActionController.php b/library/Icinga/Web/Controller/ActionController.php
index e5ee5a5b3..d5f71e908 100755
--- a/library/Icinga/Web/Controller/ActionController.php
+++ b/library/Icinga/Web/Controller/ActionController.php
@@ -50,13 +50,6 @@ use \Icinga\Web\Request;
*/
class ActionController extends Zend_Controller_Action
{
- /**
- * True to mark this layout to not render the full layout
- *
- * @var bool
- */
- protected $replaceLayout = false;
-
/**
* Whether the controller requires the user to be authenticated
*
@@ -171,13 +164,14 @@ class ActionController extends Zend_Controller_Action
/**
* Return the URI that can be used to request the current action
*
- * @return string return the path to this action: //
+ * @return string return the path to this action: //?
*/
public function getRequestUrl()
{
- return $this->_request->getModuleName() . '/' .
- $this->_request->getControllerName() . '/' .
- $this->_request->getActionName();
+ $base = $this->_request->getModuleName() . '/' .
+ $this->_request->getControllerName() . '/' .
+ $this->_request->getActionName();
+ return $_SERVER['QUERY_STRING'] !== '' ? $base . '?' . $_SERVER['QUERY_STRING'] : $base;
}
/**
diff --git a/library/Icinga/Web/Url.php b/library/Icinga/Web/Url.php
index fe58df966..ba1eeb920 100644
--- a/library/Icinga/Web/Url.php
+++ b/library/Icinga/Web/Url.php
@@ -31,6 +31,13 @@ class Url
*/
private $params = array();
+ /**
+ * The site anchor after the '#'
+ *
+ * @var string
+ */
+ private $anchor = '';
+
/**
* The relative path of this Url, without query parameters
*
@@ -108,7 +115,16 @@ class Url
}
$urlObject->setBaseUrl($request->getBaseUrl());
+ /*
+ * Fetch fragment manually and remove it from the url, to 'help' the parse_url() function
+ * parsing the url properly. Otherwise calling the function with a fragment, but without a
+ * query will cause unpredictable behaviour.
+ */
+ $fragment = self::getUrlFragment($url);
+ $url = self::stripUrlFragment($url);
+
$urlParts = parse_url($url);
+
if (isset($urlParts["path"])) {
$urlObject->setPath($urlParts["path"]);
}
@@ -117,11 +133,43 @@ class Url
parse_str($urlParts["query"], $urlParams);
$params = array_merge($urlParams, $params);
}
+ if ($fragment !== '') {
+ $urlObject->setAnchor($fragment);
+ }
$urlObject->setParams($params);
return $urlObject;
}
+ /**
+ * Get the fragment of a given url
+ *
+ * @param $url The url containing the fragment.
+ *
+ * @return string The fragment without the '#'
+ */
+ private static function getUrlFragment($url)
+ {
+ $url = parse_url($url);
+ if (isset($url['fragment'])) {
+ return $url['fragment'];
+ } else {
+ return '';
+ }
+ }
+
+ /**
+ * Remove the fragment-part of a given url
+ *
+ * @param $url string The url to strip from its fragment
+ *
+ * @return string The url without the fragment.
+ */
+ private static function stripUrlFragment($url)
+ {
+ return preg_replace('/#.*$/', '', $url);
+ }
+
/**
* Overwrite the baseUrl.
*
@@ -179,9 +227,9 @@ class Url
public function getRelativeUrl()
{
if (empty($this->params)) {
- return ltrim($this->path, '/');
+ return ltrim($this->path, '/') . $this->anchor;
}
- return ltrim($this->path, '/').'?'.http_build_query($this->params);
+ return ltrim($this->path, '/') . '?' . http_build_query($this->params) . $this->anchor;
}
/**
@@ -280,6 +328,16 @@ class Url
return $this;
}
+ /**
+ * Set the url anchor-part
+ *
+ * @param $anchor The site's anchor string without the '#'
+ */
+ public function setAnchor($anchor)
+ {
+ $this->anchor = '#' . $anchor;
+ }
+
/**
* Remove provided key (if string) or keys (if array of string) from the query parameter array
*