protected function tabs() { if ($this->view->tabs === null) { $this->view->tabs = Widget::create('tabs'); } return $this->view->tabs; }
/** * Show a group */ public function showAction() { $this->assertPermission('config/authentication/groups/show'); $groupName = $this->params->getRequired('group'); $backend = $this->getUserGroupBackend($this->params->getRequired('backend')); $group = $backend->select(array('group_name', 'created_at', 'last_modified'))->where('group_name', $groupName)->fetchRow(); if ($group === false) { $this->httpNotFound(sprintf($this->translate('Group "%s" not found'), $groupName)); } $members = $backend->select()->from('group_membership', array('user_name'))->where('group_name', $groupName); $filterEditor = Widget::create('filterEditor')->setQuery($members)->setSearchColumns(array('user'))->preserveParams('limit', 'sort', 'dir', 'view', 'backend', 'group')->ignoreParams('page')->handleRequest($this->getRequest()); $members->applyFilter($filterEditor->getFilter()); $this->setupFilterControl($filterEditor); $this->setupPaginationControl($members); $this->setupLimitControl(); $this->setupSortControl(array('user_name' => $this->translate('Username'), 'created_at' => $this->translate('Created at'), 'last_modified' => $this->translate('Last modified')), $members); $this->view->group = $group; $this->view->backend = $backend; $this->view->members = $members; $this->createShowTabs($backend->getName(), $groupName)->activate('group/show'); if ($this->hasPermission('config/authentication/groups/edit') && $backend instanceof Reducible) { $removeForm = new Form(); $removeForm->setUidDisabled(); $removeForm->setAction(Url::fromPath('group/removemember', array('backend' => $backend->getName(), 'group' => $groupName))); $removeForm->addElement('hidden', 'user_name', array('isArray' => true, 'decorators' => array('ViewHelper'))); $removeForm->addElement('hidden', 'redirect', array('value' => Url::fromPath('group/show', array('backend' => $backend->getName(), 'group' => $groupName)), 'decorators' => array('ViewHelper'))); $removeForm->addElement('button', 'btn_submit', array('escape' => false, 'type' => 'submit', 'class' => 'link-like', 'value' => 'btn_submit', 'decorators' => array('ViewHelper'), 'label' => $this->view->icon('trash'), 'title' => $this->translate('Remove this member'))); $this->view->removeForm = $removeForm; } }
/** * Show a user */ public function showAction() { $this->assertPermission('config/authentication/users/show'); $userName = $this->params->getRequired('user'); $backend = $this->getUserBackend($this->params->getRequired('backend')); $user = $backend->select(array('user_name', 'is_active', 'created_at', 'last_modified'))->where('user_name', $userName)->fetchRow(); if ($user === false) { $this->httpNotFound(sprintf($this->translate('User "%s" not found'), $userName)); } $memberships = $this->loadMemberships(new User($userName))->select(); $filterEditor = Widget::create('filterEditor')->setQuery($memberships)->setSearchColumns(array('group_name'))->preserveParams('limit', 'sort', 'dir', 'view', 'backend', 'user')->ignoreParams('page')->handleRequest($this->getRequest()); $memberships->applyFilter($filterEditor->getFilter()); $this->setupFilterControl($filterEditor); $this->setupPaginationControl($memberships); $this->setupLimitControl(); $this->setupSortControl(array('group_name' => $this->translate('Group')), $memberships); if ($this->hasPermission('config/authentication/groups/edit')) { $extensibleBackends = $this->loadUserGroupBackends('Icinga\\Data\\Extensible'); $this->view->showCreateMembershipLink = !empty($extensibleBackends); } else { $this->view->showCreateMembershipLink = false; } $this->view->user = $user; $this->view->backend = $backend; $this->view->memberships = $memberships; $this->createShowTabs($backend->getName(), $userName)->activate('user/show'); if ($this->hasPermission('config/authentication/groups/edit')) { $removeForm = new Form(); $removeForm->setUidDisabled(); $removeForm->addElement('hidden', 'user_name', array('isArray' => true, 'value' => $userName, 'decorators' => array('ViewHelper'))); $removeForm->addElement('hidden', 'redirect', array('value' => Url::fromPath('user/show', array('backend' => $backend->getName(), 'user' => $userName)), 'decorators' => array('ViewHelper'))); $removeForm->addElement('button', 'btn_submit', array('escape' => false, 'type' => 'submit', 'class' => 'link-like', 'value' => 'btn_submit', 'decorators' => array('ViewHelper'), 'label' => $this->view->icon('trash'), 'title' => $this->translate('Cancel this membership'))); $this->view->removeForm = $removeForm; } }
/** * Display the list of all modules */ public function modulesAction() { $this->assertPermission('config/modules'); // Overwrite tabs created in init // @TODO(el): This seems not natural to me. Module configuration should have its own controller. $this->view->tabs = Widget::create('tabs')->add('modules', array('label' => $this->translate('Modules'), 'title' => $this->translate('List intalled modules'), 'url' => 'config/modules'))->activate('modules'); $this->view->modules = Icinga::app()->getModuleManager()->select()->from('modules')->order('enabled', 'desc')->order('name'); $this->setupLimitControl(); $this->setupPaginationControl($this->view->modules); }
/** * Create a FilterEditor widget and apply the user's chosen filter options on the given filterable * * The widget is set on the `filterEditor' view property only if the current view has not been requested as compact. * The optional $filterColumns parameter should be an array of key-value pairs where the key is the name of the * column and the value the label to show to the user. The optional $searchColumns parameter should be an array * of column names to be used to handle quick searches. * * If the given filterable is an instance of Icinga\Data\FilterColumns, $filterable->getFilterColumns() and * $filterable->getSearchColumns() is called to provide the respective columns if $filterColumns or $searchColumns * is not given. * * @param Filterable $filterable The filterable to create a filter editor for * @param array $filterColumns The filter columns to offer to the user * @param array $searchColumns The search columns to utilize for quick searches * @param array $preserveParams The url parameters to preserve * * @return $this * * @todo Preserving and ignoring parameters should be configurable (another two method params? property magic?) */ protected function setupFilterControl(Filterable $filterable, array $filterColumns = null, array $searchColumns = null, array $preserveParams = null) { $defaultPreservedParams = array('limit', 'sort', 'dir', 'backend', 'view', '_dev'); $editor = Widget::create('filterEditor'); call_user_func_array(array($editor, 'preserveParams'), array_merge($defaultPreservedParams, $preserveParams ?: array())); $editor->setQuery($filterable)->ignoreParams('page')->setColumns($filterColumns)->setSearchColumns($searchColumns)->handleRequest($this->getRequest()); if (!$this->view->compact) { $this->view->filterEditor = $editor; } return $this; }
protected function setImportTabs() { $this->view->tabs = Widget::create('tabs')->add('importsource', array('label' => $this->translate('Import source'), 'url' => 'director/list/importsource'))->add('importrun', array('label' => $this->translate('Import history'), 'url' => 'director/list/importrun'))->add('syncrule', array('label' => $this->translate('Sync rule'), 'url' => 'director/list/syncrule')); return $this->view->tabs; }
/** * Get the module configuration tabs * * @return \Icinga\Web\Widget\Tabs */ public function getConfigTabs() { $this->launchConfigScript(); $tabs = Widget::create('tabs'); /** @var \Icinga\Web\Widget\Tabs $tabs */ $tabs->add('info', array('url' => 'config/module', 'urlParams' => array('name' => $this->getName()), 'label' => 'Module: ' . $this->getName())); foreach ($this->configTabs as $name => $config) { $tabs->add($name, $config); } return $tabs; }
/** * Create a FilterEditor widget and apply the user's chosen filter options on the given filterable * * The widget is set on the `filterEditor' view property only if the current view has not been requested as compact. * The optional $filterColumns parameter should be an array of key-value pairs where the key is the name of the * column and the value the label to show to the user. The optional $searchColumns parameter should be an array * of column names to be used to handle quick searches. * * If the given filterable is an instance of Icinga\Data\FilterColumns, $filterable->getFilterColumns() and * $filterable->getSearchColumns() is called to provide the respective columns if $filterColumns or $searchColumns * is not given. * * @param Filterable $filterable The filterable to create a filter editor for * @param array $filterColumns The filter columns to offer to the user * @param array $searchColumns The search columns to utilize for quick searches * * @return $this * * @todo Preserving and ignoring parameters should be configurable (another two method params? property magic?) */ protected function setupFilterControl(Filterable $filterable, array $filterColumns = null, array $searchColumns = null) { $editor = Widget::create('filterEditor')->setQuery($filterable)->preserveParams('limit', 'sort', 'dir', 'format', 'view', 'user', 'group', 'backend', 'stateType', 'addColumns', 'problems', '_dev')->ignoreParams('page')->setColumns($filterColumns)->setSearchColumns($searchColumns)->handleRequest($this->getRequest()); if (!$this->view->compact) { $this->view->filterEditor = $editor; } return $this; }
protected function tabs() { return Widget::create('tabs')->add('guide', array('label' => $this->translate('Style Guide'), 'url' => 'doc/style/guide'))->add('font', array('label' => $this->translate('Icons'), 'title' => $this->translate('List all available icons'), 'url' => 'doc/style/font')); }
<?php /* Icinga Web 2 | (c) 2014 Icinga Development Team | GPLv2+ */ namespace Icinga\Web\View; use Icinga\Authentication\Auth; use Icinga\Web\Widget; $this->addHelperFunction('auth', function () { return Auth::getInstance(); }); $this->addHelperFunction('widget', function ($name, $options = null) { return Widget::create($name, $options); });
/** * Apply filters on a DataView * * @param DataView $dataView The DataView to apply filters on * * @return DataView $dataView */ protected function filterQuery(DataView $dataView) { $editor = Widget::create('filterEditor')->setQuery($dataView)->preserveParams('limit', 'sort', 'dir', 'format', 'view', 'backend', 'stateType', 'addColumns', '_dev', 'problems')->ignoreParams('page')->setSearchColumns($dataView->getSearchColumns())->handleRequest($this->getRequest()); $dataView->applyFilter($editor->getFilter()); $this->setupFilterControl($editor); $this->view->filter = $editor->getFilter(); $this->handleFormatRequest($dataView); return $dataView; }
public function getFilterEditor(Request $request) { $filterEditor = Widget::create('filterEditor')->setColumns(array_keys($this->getColumns()))->setSearchColumns($this->getSearchColumns())->preserveParams('limit', 'sort', 'dir', 'view', 'backend')->ignoreParams('page')->handleRequest($request); $filter = $filterEditor->getFilter(); $this->setFilter($filter); return $filterEditor; }