mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 15:54:03 +02:00
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);
|
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
|
## Using widgets
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ Widgets are normally created in the controller and added to the view:
|
|||||||
$this->view->myWidget = new MyWidget();
|
$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:
|
a reference to your current view, you can just pass it to the *render()* method:
|
||||||
|
|
||||||
// in your template
|
// in your template
|
||||||
@ -41,7 +41,7 @@ Tab bar, you just have to call:
|
|||||||
|
|
||||||
$tabbar = new Tabs();
|
$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
|
done in the preDispatch function
|
||||||
|
|
||||||
### Adding tabs
|
### Adding tabs
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
* Module action controller
|
* Module action controller
|
||||||
*/
|
*/
|
||||||
namespace Icinga\Web\Controller;
|
namespace Icinga\Web\Controller;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for all module action controllers
|
* 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
|
* Add a set of parameters to the query part if the keys don't exist yet
|
||||||
*
|
*
|
||||||
* @param array $params The parameters to add
|
* @param array $params The parameters to add
|
||||||
* @return $this
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function addParams(array $params)
|
public function addParams(array $params)
|
||||||
{
|
{
|
||||||
@ -210,6 +210,18 @@ class Url
|
|||||||
return $this;
|
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
|
* Overwrite the parameters used in the query part
|
||||||
*
|
*
|
||||||
@ -338,7 +350,8 @@ class Url
|
|||||||
* Alias for @see Url::getAbsoluteUrl()
|
* Alias for @see Url::getAbsoluteUrl()
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function __toString() {
|
public function __toString()
|
||||||
|
{
|
||||||
return $this->getAbsoluteUrl();
|
return $this->getAbsoluteUrl();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,16 +28,16 @@
|
|||||||
|
|
||||||
namespace Icinga\Web\Widget;
|
namespace Icinga\Web\Widget;
|
||||||
|
|
||||||
use Icinga\Application\Icinga;
|
use \Icinga\Application\Icinga;
|
||||||
use \Icinga\Application\Config as IcingaConfig;
|
use \Icinga\Application\Config as IcingaConfig;
|
||||||
use Icinga\Application\Logger;
|
use \Icinga\Application\Logger;
|
||||||
use Icinga\Exception\ConfigurationError;
|
use \Icinga\Exception\ConfigurationError;
|
||||||
use Icinga\Web\Widget\Widget;
|
use \Icinga\Web\Widget\Widget;
|
||||||
use Icinga\Web\Widget\Dashboard\Pane;
|
use \Icinga\Web\Widget\Dashboard\Pane;
|
||||||
use Icinga\Web\Widget\Dashboard\Component as DashboardComponent;
|
use \Icinga\Web\Widget\Dashboard\Component as DashboardComponent;
|
||||||
|
|
||||||
use Icinga\Web\Url;
|
use \Icinga\Web\Url;
|
||||||
use Zend_View_Abstract;
|
use \Zend_View_Abstract;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dashboards display multiple views on a single page
|
* Dashboards display multiple views on a single page
|
||||||
|
@ -28,9 +28,8 @@
|
|||||||
|
|
||||||
namespace Icinga\Web\Widget;
|
namespace Icinga\Web\Widget;
|
||||||
|
|
||||||
use Icinga\Exception\ProgrammingError;
|
use \Icinga\Web\Url;
|
||||||
use Icinga\Web\Url;
|
use \Zend_View_Abstract;
|
||||||
use Zend_View_Abstract;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A single tab, usually used through the tabs widget
|
* A single tab, usually used through the tabs widget
|
||||||
@ -45,9 +44,6 @@ use Zend_View_Abstract;
|
|||||||
* base URL
|
* base URL
|
||||||
* @property string $urlParams Action URL Parameters
|
* @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
|
class Tab implements Widget
|
||||||
{
|
{
|
||||||
@ -221,7 +217,7 @@ class Tab implements Widget
|
|||||||
$caption = '<i class="icon-' . $this->iconCls . '"></i> ' . $caption;
|
$caption = '<i class="icon-' . $this->iconCls . '"></i> ' . $caption;
|
||||||
}
|
}
|
||||||
if ($this->url !== null) {
|
if ($this->url !== null) {
|
||||||
$this->url->addParams($this->urlParams);
|
$this->url->overwriteParams($this->urlParams);
|
||||||
$tab = '<a href="' . $this->url->getAbsoluteUrl() . '">' . $caption . '</a>';
|
$tab = '<a href="' . $this->url->getAbsoluteUrl() . '">' . $caption . '</a>';
|
||||||
} else {
|
} else {
|
||||||
$tab = $caption;
|
$tab = $caption;
|
||||||
|
@ -28,8 +28,8 @@
|
|||||||
|
|
||||||
namespace Icinga\Web\Widget\Tabextension;
|
namespace Icinga\Web\Widget\Tabextension;
|
||||||
|
|
||||||
use Icinga\Web\Widget\Tabs;
|
use \Icinga\Web\Widget\Tabs;
|
||||||
use Icinga\Web\Url;
|
use \Icinga\Web\Url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tabextension that adds the basket command
|
* Tabextension that adds the basket command
|
||||||
@ -43,13 +43,16 @@ class BasketAction implements Tabextension
|
|||||||
*/
|
*/
|
||||||
public function apply(Tabs $tabs)
|
public function apply(Tabs $tabs)
|
||||||
{
|
{
|
||||||
$tabs->addAsDropdown('basket', array(
|
$tabs->addAsDropdown(
|
||||||
'title' => 'URL Basket',
|
'basket',
|
||||||
'icon' => 'img/classic/basket.png',
|
array(
|
||||||
'url' => Url::fromPath('basket/add'),
|
'title' => 'URL Basket',
|
||||||
'urlParams' => array(
|
'icon' => 'img/classic/basket.png',
|
||||||
'url' => Url::fromRequest()->getRelativeUrl()
|
'url' => Url::fromPath('basket/add'),
|
||||||
|
'urlParams' => array(
|
||||||
|
'url' => Url::fromRequest()->getRelativeUrl()
|
||||||
|
)
|
||||||
)
|
)
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -28,10 +28,10 @@
|
|||||||
|
|
||||||
namespace Icinga\Web\Widget\Tabextension;
|
namespace Icinga\Web\Widget\Tabextension;
|
||||||
|
|
||||||
use Icinga\Web\Url;
|
use \Icinga\Web\Url;
|
||||||
use Icinga\Config\Config as IcingaConfig;
|
use \Icinga\Config\Config as IcingaConfig;
|
||||||
use Icinga\Web\Widget\Tabs;
|
use \Icinga\Web\Widget\Tabs;
|
||||||
use Icinga\Web\Widget\Dashboard;
|
use \Icinga\Web\Widget\Dashboard;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tabextension that allows to add the current URL to a 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
|
class DashboardAction implements Tabextension
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* Applies the dashboard actions to the provided tabset
|
||||||
|
*
|
||||||
|
* @param Tabs The tabs object to extend with
|
||||||
* @see Tabextension::apply()
|
* @see Tabextension::apply()
|
||||||
*/
|
*/
|
||||||
public function apply(Tabs $tabs)
|
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()
|
* @see Tabextension::apply()
|
||||||
*/
|
*/
|
||||||
public function apply(Tabs $tabs)
|
public function apply(Tabs $tabs)
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
namespace Icinga\Web\Widget\Tabextension;
|
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.
|
* Tabextension interface that allows to extend a tabbar with reusable components.
|
||||||
|
@ -28,11 +28,11 @@
|
|||||||
|
|
||||||
namespace Icinga\Web\Widget;
|
namespace Icinga\Web\Widget;
|
||||||
|
|
||||||
use Icinga\Exception\ProgrammingError;
|
use \Icinga\Exception\ProgrammingError;
|
||||||
use Icinga\Web\Widget\Tabextension\Tabextension;
|
use \Icinga\Web\Widget\Tabextension\Tabextension;
|
||||||
use Zend_View_Abstract;
|
use \Zend_View_Abstract;
|
||||||
|
|
||||||
use Countable;
|
use \Countable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Navigation tab widget
|
* Navigation tab widget
|
||||||
|
@ -90,6 +90,5 @@ class Monitoring_SummaryController extends ModuleActionController
|
|||||||
$this->view->summary = $query->paginate();
|
$this->view->summary = $query->paginate();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// @codingStandardsIgnoreEnd
|
// @codingStandardsIgnoreEnd
|
||||||
|
@ -87,9 +87,7 @@ var onLinkTagClick = function(ev) {
|
|||||||
'.layout-main-detail * a' : {
|
'.layout-main-detail * a' : {
|
||||||
'click' : onLinkTagClick
|
'click' : onLinkTagClick
|
||||||
},
|
},
|
||||||
/* 'a' : {
|
|
||||||
'click' : onOuterLinkClick
|
|
||||||
},*/
|
|
||||||
'.layout-main-detail .icinga-container#icinga-detail' : {
|
'.layout-main-detail .icinga-container#icinga-detail' : {
|
||||||
'focus' : expandDetailView
|
'focus' : expandDetailView
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
// @codingStandardsIgnoreStart
|
||||||
// {{{ICINGA_LICENSE_HEADER}}}
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
/**
|
/**
|
||||||
* This file is part of Icinga 2 Web.
|
* This file is part of Icinga 2 Web.
|
||||||
@ -45,3 +46,5 @@ class ViewMock extends Zend_View_Abstract
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @codingStandardsIgnoreEnd
|
Loading…
x
Reference in New Issue
Block a user