summaryrefslogtreecommitdiff
path: root/app/Helper
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-12-22 19:06:03 +0100
committerFrederic Guillot <fred@kanboard.net>2015-12-22 19:06:03 +0100
commit6f9af3659c9146a2ac1b08d70610bf96398ec073 (patch)
tree21cbbca979a30d133d421881d6aa6e6af8096199 /app/Helper
parentc83f589b22cd548c6de10bfb0c18f767ba7dffd8 (diff)
Added the possiblity to define custom routes from plugins
Diffstat (limited to 'app/Helper')
-rw-r--r--app/Helper/App.php15
-rw-r--r--app/Helper/Url.php14
2 files changed, 22 insertions, 7 deletions
diff --git a/app/Helper/App.php b/app/Helper/App.php
index 33729f2b..6e6028fc 100644
--- a/app/Helper/App.php
+++ b/app/Helper/App.php
@@ -2,15 +2,28 @@
namespace Kanboard\Helper;
+use Kanboard\Core\Base;
+
/**
* Application helpers
*
* @package helper
* @author Frederic Guillot
*/
-class App extends \Kanboard\Core\Base
+class App extends Base
{
/**
+ * Get plugin name from route
+ *
+ * @access public
+ * @return string
+ */
+ public function getPluginName()
+ {
+ return $this->router->getPlugin();
+ }
+
+ /**
* Get router controller
*
* @access public
diff --git a/app/Helper/Url.php b/app/Helper/Url.php
index 6ada8068..720297cf 100644
--- a/app/Helper/Url.php
+++ b/app/Helper/Url.php
@@ -103,8 +103,8 @@ class Url extends Base
*/
public function dir()
{
- if (empty($this->directory) && isset($_SERVER['REQUEST_METHOD'])) {
- $this->directory = str_replace('\\', '/', dirname($_SERVER['PHP_SELF']));
+ if ($this->directory === '' && $this->request->getMethod() !== '') {
+ $this->directory = str_replace('\\', '/', dirname($this->request->getServerVariable('PHP_SELF')));
$this->directory = $this->directory !== '/' ? $this->directory.'/' : '/';
$this->directory = str_replace('//', '/', $this->directory);
}
@@ -120,13 +120,13 @@ class Url extends Base
*/
public function server()
{
- if (empty($_SERVER['SERVER_NAME'])) {
+ if ($this->request->getServerVariable('SERVER_NAME') === '') {
return 'http://localhost/';
}
$url = $this->request->isHTTPS() ? 'https://' : 'http://';
- $url .= $_SERVER['SERVER_NAME'];
- $url .= $_SERVER['SERVER_PORT'] == 80 || $_SERVER['SERVER_PORT'] == 443 ? '' : ':'.$_SERVER['SERVER_PORT'];
+ $url .= $this->request->getServerVariable('SERVER_NAME');
+ $url .= $this->request->getServerVariable('SERVER_PORT') == 80 || $this->request->getServerVariable('SERVER_PORT') == 443 ? '' : ':'.$this->request->getServerVariable('SERVER_PORT');
$url .= $this->dir() ?: '/';
return $url;
@@ -147,13 +147,15 @@ class Url extends Base
*/
private function build($separator, $controller, $action, array $params = array(), $csrf = false, $anchor = '', $absolute = false)
{
- $path = $this->router->findUrl($controller, $action, $params);
+ $path = $this->route->findUrl($controller, $action, $params);
$qs = array();
if (empty($path)) {
$qs['controller'] = $controller;
$qs['action'] = $action;
$qs += $params;
+ } else {
+ unset($params['plugin']);
}
if ($csrf) {