Code style fixes, fix documentation, fix tab parameters not being overwritten
refs #4512
This commit is contained in:
parent
49d56f1eab
commit
0b479e3796
|
@ -12,7 +12,7 @@ simple interface, only providing a 'render' method that takes a view and returns
|
|||
public function render(Zend_View_Abstract $view);
|
||||
}
|
||||
|
||||
When implementing own Widgets you just have to make sure that your provide this render method.
|
||||
When implementing own Widgets you just have to make sure that you provide this render method.
|
||||
|
||||
## Using widgets
|
||||
|
||||
|
@ -24,7 +24,7 @@ Widgets are normally created in the controller and added to the view:
|
|||
$this->view->myWidget = new MyWidget();
|
||||
}
|
||||
|
||||
The HTML is then rendered in the template using the *render()* method described above. As the '$this' scope in a view is your
|
||||
The HTML is then rendered in the template using the *render()* method described above. As the '$this' scope in a view is
|
||||
a reference to your current view, you can just pass it to the *render()* method:
|
||||
|
||||
// in your template
|
||||
|
@ -41,7 +41,7 @@ Tab bar, you just have to call:
|
|||
|
||||
$tabbar = new Tabs();
|
||||
|
||||
**Note** : When using an ActionController, there's already an empty tabs object created unter $this->view->tabs. This is
|
||||
**Note** : When using an ActionController, there's already an empty tabs object created under $this->view->tabs. This is
|
||||
done in the preDispatch function
|
||||
|
||||
### Adding tabs
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
* Module action controller
|
||||
*/
|
||||
namespace Icinga\Web\Controller;
|
||||
|
||||
/**
|
||||
* Base class for all module action controllers
|
||||
*
|
||||
|
|
|
@ -201,8 +201,8 @@ class Url
|
|||
/**
|
||||
* Add a set of parameters to the query part if the keys don't exist yet
|
||||
*
|
||||
* @param array $params The parameters to add
|
||||
* @return $this
|
||||
* @param array $params The parameters to add
|
||||
* @return self
|
||||
*/
|
||||
public function addParams(array $params)
|
||||
{
|
||||
|
@ -210,6 +210,18 @@ class Url
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set and overwrite the given params if one if the same key already exists
|
||||
*
|
||||
* @param array $params The parameters to set
|
||||
* @return self
|
||||
*/
|
||||
public function overwriteParams(array $params)
|
||||
{
|
||||
$this->params = array_merge($this->params, $params);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrite the parameters used in the query part
|
||||
*
|
||||
|
@ -338,7 +350,8 @@ class Url
|
|||
* Alias for @see Url::getAbsoluteUrl()
|
||||
* @return mixed
|
||||
*/
|
||||
public function __toString() {
|
||||
public function __toString()
|
||||
{
|
||||
return $this->getAbsoluteUrl();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,16 +28,16 @@
|
|||
|
||||
namespace Icinga\Web\Widget;
|
||||
|
||||
use Icinga\Application\Icinga;
|
||||
use \Icinga\Application\Icinga;
|
||||
use \Icinga\Application\Config as IcingaConfig;
|
||||
use Icinga\Application\Logger;
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
use Icinga\Web\Widget\Widget;
|
||||
use Icinga\Web\Widget\Dashboard\Pane;
|
||||
use Icinga\Web\Widget\Dashboard\Component as DashboardComponent;
|
||||
use \Icinga\Application\Logger;
|
||||
use \Icinga\Exception\ConfigurationError;
|
||||
use \Icinga\Web\Widget\Widget;
|
||||
use \Icinga\Web\Widget\Dashboard\Pane;
|
||||
use \Icinga\Web\Widget\Dashboard\Component as DashboardComponent;
|
||||
|
||||
use Icinga\Web\Url;
|
||||
use Zend_View_Abstract;
|
||||
use \Icinga\Web\Url;
|
||||
use \Zend_View_Abstract;
|
||||
|
||||
/**
|
||||
* Dashboards display multiple views on a single page
|
||||
|
|
|
@ -28,9 +28,8 @@
|
|||
|
||||
namespace Icinga\Web\Widget;
|
||||
|
||||
use Icinga\Exception\ProgrammingError;
|
||||
use Icinga\Web\Url;
|
||||
use Zend_View_Abstract;
|
||||
use \Icinga\Web\Url;
|
||||
use \Zend_View_Abstract;
|
||||
|
||||
/**
|
||||
* A single tab, usually used through the tabs widget
|
||||
|
@ -45,9 +44,6 @@ use Zend_View_Abstract;
|
|||
* base URL
|
||||
* @property string $urlParams Action URL Parameters
|
||||
*
|
||||
* @copyright Copyright (c) 2013 Icinga-Web Team <info@icinga.org>
|
||||
* @author Icinga-Web Team <info@icinga.org>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
|
||||
*/
|
||||
class Tab implements Widget
|
||||
{
|
||||
|
@ -221,7 +217,7 @@ class Tab implements Widget
|
|||
$caption = '<i class="icon-' . $this->iconCls . '"></i> ' . $caption;
|
||||
}
|
||||
if ($this->url !== null) {
|
||||
$this->url->addParams($this->urlParams);
|
||||
$this->url->overwriteParams($this->urlParams);
|
||||
$tab = '<a href="' . $this->url->getAbsoluteUrl() . '">' . $caption . '</a>';
|
||||
} else {
|
||||
$tab = $caption;
|
||||
|
|
|
@ -28,8 +28,8 @@
|
|||
|
||||
namespace Icinga\Web\Widget\Tabextension;
|
||||
|
||||
use Icinga\Web\Widget\Tabs;
|
||||
use Icinga\Web\Url;
|
||||
use \Icinga\Web\Widget\Tabs;
|
||||
use \Icinga\Web\Url;
|
||||
|
||||
/**
|
||||
* Tabextension that adds the basket command
|
||||
|
@ -43,13 +43,16 @@ class BasketAction implements Tabextension
|
|||
*/
|
||||
public function apply(Tabs $tabs)
|
||||
{
|
||||
$tabs->addAsDropdown('basket', array(
|
||||
'title' => 'URL Basket',
|
||||
'icon' => 'img/classic/basket.png',
|
||||
'url' => Url::fromPath('basket/add'),
|
||||
'urlParams' => array(
|
||||
'url' => Url::fromRequest()->getRelativeUrl()
|
||||
$tabs->addAsDropdown(
|
||||
'basket',
|
||||
array(
|
||||
'title' => 'URL Basket',
|
||||
'icon' => 'img/classic/basket.png',
|
||||
'url' => Url::fromPath('basket/add'),
|
||||
'urlParams' => array(
|
||||
'url' => Url::fromRequest()->getRelativeUrl()
|
||||
)
|
||||
)
|
||||
));
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,10 +28,10 @@
|
|||
|
||||
namespace Icinga\Web\Widget\Tabextension;
|
||||
|
||||
use Icinga\Web\Url;
|
||||
use Icinga\Config\Config as IcingaConfig;
|
||||
use Icinga\Web\Widget\Tabs;
|
||||
use Icinga\Web\Widget\Dashboard;
|
||||
use \Icinga\Web\Url;
|
||||
use \Icinga\Config\Config as IcingaConfig;
|
||||
use \Icinga\Web\Widget\Tabs;
|
||||
use \Icinga\Web\Widget\Dashboard;
|
||||
|
||||
/**
|
||||
* Tabextension that allows to add the current URL to a dashboard
|
||||
|
@ -41,6 +41,9 @@ use Icinga\Web\Widget\Dashboard;
|
|||
class DashboardAction implements Tabextension
|
||||
{
|
||||
/**
|
||||
* Applies the dashboard actions to the provided tabset
|
||||
*
|
||||
* @param Tabs The tabs object to extend with
|
||||
* @see Tabextension::apply()
|
||||
*/
|
||||
public function apply(Tabs $tabs)
|
||||
|
|
|
@ -117,6 +117,10 @@ class OutputFormat implements Tabextension
|
|||
}
|
||||
|
||||
/**
|
||||
* Applies the format selectio to the provided tabset
|
||||
*
|
||||
* @param Tabs The tabs object to extend with
|
||||
*
|
||||
* @see Tabextension::apply()
|
||||
*/
|
||||
public function apply(Tabs $tabs)
|
||||
|
@ -125,4 +129,4 @@ class OutputFormat implements Tabextension
|
|||
$tabs->addAsDropdown($tab->getName(), $tab);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
namespace Icinga\Web\Widget\Tabextension;
|
||||
|
||||
use Icinga\Web\Widget\Tabs;
|
||||
use \Icinga\Web\Widget\Tabs;
|
||||
|
||||
/**
|
||||
* Tabextension interface that allows to extend a tabbar with reusable components.
|
||||
|
|
|
@ -28,11 +28,11 @@
|
|||
|
||||
namespace Icinga\Web\Widget;
|
||||
|
||||
use Icinga\Exception\ProgrammingError;
|
||||
use Icinga\Web\Widget\Tabextension\Tabextension;
|
||||
use Zend_View_Abstract;
|
||||
use \Icinga\Exception\ProgrammingError;
|
||||
use \Icinga\Web\Widget\Tabextension\Tabextension;
|
||||
use \Zend_View_Abstract;
|
||||
|
||||
use Countable;
|
||||
use \Countable;
|
||||
|
||||
/**
|
||||
* Navigation tab widget
|
||||
|
|
|
@ -90,6 +90,5 @@ class Monitoring_SummaryController extends ModuleActionController
|
|||
$this->view->summary = $query->paginate();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
|
|
@ -87,9 +87,7 @@ var onLinkTagClick = function(ev) {
|
|||
'.layout-main-detail * a' : {
|
||||
'click' : onLinkTagClick
|
||||
},
|
||||
/* 'a' : {
|
||||
'click' : onOuterLinkClick
|
||||
},*/
|
||||
|
||||
'.layout-main-detail .icinga-container#icinga-detail' : {
|
||||
'focus' : expandDetailView
|
||||
}
|
||||
|
|
|
@ -86,4 +86,4 @@ class RequestMock
|
|||
{
|
||||
return $this->query;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
// @codingStandardsIgnoreStart
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
/**
|
||||
* This file is part of Icinga 2 Web.
|
||||
|
@ -44,4 +45,6 @@ class ViewMock extends Zend_View_Abstract
|
|||
protected function _run()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreEnd
|
Loading…
Reference in New Issue