本文整理汇总了PHP中Icinga\Data\Filter\Filter类的典型用法代码示例。如果您正苦于以下问题:PHP Filter类的具体用法?PHP Filter怎么用?PHP Filter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Filter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: filterAction
public function filterAction()
{
$flat = array();
$filter = Filter::fromQueryString('vars.bpconfig=*');
Benchmark::measure('ready');
$objs = IcingaHost::loadAll($this->db());
Benchmark::measure('db done');
foreach ($objs as $host) {
$flat[$host->id] = (object) array();
foreach ($host->getProperties() as $k => $v) {
$flat[$host->id]->{$k} = $v;
}
}
Benchmark::measure('objects ready');
$vars = IcingaHostVar::loadAll($this->db());
Benchmark::measure('vars loaded');
foreach ($vars as $var) {
if (!array_key_exists($var->host_id, $flat)) {
continue;
}
// Templates?
$flat[$var->host_id]->{'vars.' . $var->varname} = $var->varvalue;
}
Benchmark::measure('vars done');
foreach ($flat as $host) {
if ($filter->matches($host)) {
echo $host->object_name . "\n";
}
}
return;
Benchmark::measure('all done');
}
开发者ID:plarivee,项目名称:icingaweb2-module-director,代码行数:32,代码来源:BenchmarkCommand.php
示例2: filter
protected function filter()
{
if ($this->filter === null) {
$this->filter = Filter::fromQueryString($this->filter_expression);
}
return $this->filter;
}
开发者ID:dgoeger,项目名称:icingadirector,代码行数:7,代码来源:SyncRule.php
示例3: showAction
public function showAction()
{
$this->setAutorefreshInterval(15);
$checkNowForm = new CheckNowCommandForm();
$checkNowForm->setObjects($this->serviceList)->handleRequest();
$this->view->checkNowForm = $checkNowForm;
$this->serviceList->setColumns(array('host_display_name', 'host_handled', 'host_name', 'host_problem', 'host_state', 'service_acknowledged', 'service_active_checks_enabled', 'service_description', 'service_display_name', 'service_handled', 'service_in_downtime', 'service_is_flapping', 'service_last_state_change', 'service_notifications_enabled', 'service_passive_checks_enabled', 'service_problem', 'service_state'));
$acknowledgedObjects = $this->serviceList->getAcknowledgedObjects();
if (!empty($acknowledgedObjects)) {
$removeAckForm = new RemoveAcknowledgementCommandForm();
$removeAckForm->setObjects($acknowledgedObjects)->handleRequest();
$this->view->removeAckForm = $removeAckForm;
}
$this->setAutorefreshInterval(15);
$this->view->rescheduleAllLink = Url::fromRequest()->setPath('monitoring/services/reschedule-check');
$this->view->downtimeAllLink = Url::fromRequest()->setPath('monitoring/services/schedule-downtime');
$this->view->processCheckResultAllLink = Url::fromRequest()->setPath('monitoring/services/process-check-result');
$this->view->addCommentLink = Url::fromRequest()->setPath('monitoring/services/add-comment');
$this->view->deleteCommentLink = Url::fromRequest()->setPath('monitoring/services/delete-comment');
$this->view->stats = $this->serviceList->getServiceStateSummary();
$this->view->objects = $this->serviceList;
$this->view->unhandledObjects = $this->serviceList->getUnhandledObjects();
$this->view->problemObjects = $this->serviceList->getProblemObjects();
$this->view->downtimeUnhandledLink = Url::fromPath('monitoring/services/schedule-downtime')->setQueryString($this->serviceList->getUnhandledObjects()->objectsFilter()->toQueryString());
$this->view->downtimeLink = Url::fromPath('monitoring/services/schedule-downtime')->setQueryString($this->serviceList->getProblemObjects()->objectsFilter()->toQueryString());
$this->view->acknowledgedObjects = $acknowledgedObjects;
$this->view->acknowledgeLink = Url::fromPath('monitoring/services/acknowledge-problem')->setQueryString($this->serviceList->getUnacknowledgedObjects()->objectsFilter()->toQueryString());
$this->view->unacknowledgedObjects = $this->serviceList->getUnacknowledgedObjects();
$this->view->objectsInDowntime = $this->serviceList->getObjectsInDowntime();
$this->view->inDowntimeLink = Url::fromPath('monitoring/list/services')->setQueryString($this->serviceList->getObjectsInDowntime()->objectsFilter(array('host' => 'host_name', 'service' => 'service_description'))->toQueryString());
$this->view->showDowntimesLink = Url::fromPath('monitoring/downtimes/show')->setQueryString($this->serviceList->getObjectsInDowntime()->objectsFilter()->andFilter(Filter::where('object_type', 'service'))->toQueryString());
$this->view->commentsLink = Url::fromRequest()->setPath('monitoring/list/comments');
$this->view->sendCustomNotificationLink = Url::fromRequest()->setPath('monitoring/services/send-custom-notification');
}
开发者ID:kobmaki,项目名称:icingaweb2,代码行数:34,代码来源:ServicesController.php
示例4: render
/**
* {@inheritdoc}
*/
public function render()
{
$repo = new AnnouncementIniRepository();
$etag = $repo->getEtag();
$cookie = new AnnouncementCookie();
if ($cookie->getEtag() !== $etag) {
$cookie->setEtag($etag);
$cookie->setNextActive($repo->findNextActive());
Icinga::app()->getResponse()->setCookie($cookie);
}
$acked = array();
foreach ($cookie->getAcknowledged() as $hash) {
$acked[] = Filter::expression('hash', '!=', $hash);
}
$acked = Filter::matchAll($acked);
$announcements = $repo->findActive();
$announcements->applyFilter($acked);
if ($announcements->hasResult()) {
$html = '<ul role="alert" id="announcements">';
foreach ($announcements as $announcement) {
$ackForm = new AcknowledgeAnnouncementForm();
$ackForm->populate(array('hash' => $announcement->hash));
$html .= '<li><div>' . $this->view()->escape($announcement->message) . '</div>' . $ackForm . '</li>';
}
$html .= '</ul>';
return $html;
}
// Force container update on XHR
return '<div style="display: none;"></div>';
}
开发者ID:0svald,项目名称:icingaweb2,代码行数:33,代码来源:Announcements.php
示例5: getFilterOrExitIfEmpty
/**
* Get the filter from URL parameters or exit immediately if the filter is empty
*
* @return Filter
*/
protected function getFilterOrExitIfEmpty()
{
$filter = Filter::fromQueryString((string) $this->params);
if ($filter->isEmpty()) {
$this->getResponse()->json()->setFailData(array('filter' => 'Filter is required and must not be empty'))->sendResponse();
}
return $filter;
}
开发者ID:0svald,项目名称:icingaweb2,代码行数:13,代码来源:ActionsController.php
示例6: testAction
public function testAction()
{
$pdb = new PuppetDbApi('v4', 'pe2015.example.com');
// $filter = Filter::fromQueryString('type=Nagios_host&exported=true');
// echo FilterRenderer::forFilter($filter)->toJson();
$facts = $pdb->fetchFacts(Filter::fromQueryString('name=kernel|name=osfamily|name=partitions'));
// certname=pe2015.example.com
}
开发者ID:Thomas-Gelf,项目名称:icingaweb2-module-puppetdb,代码行数:8,代码来源:FilterCommand.php
示例7: objectsFilter
/**
* Returns a Filter that matches all hosts in this list
*
* @return Filter
*/
public function objectsFilter($columns = array('host' => 'host'))
{
$filterExpression = array();
foreach ($this as $host) {
$filterExpression[] = Filter::where($columns['host'], $host->getName());
}
return FilterOr::matchAny($filterExpression);
}
开发者ID:thorebahr,项目名称:icingaweb2,代码行数:13,代码来源:HostList.php
示例8: init
public function init()
{
$serviceList = new ServiceList($this->backend);
$this->applyRestriction('monitoring/filter/objects', $serviceList);
$serviceList->addFilter(Filter::fromQueryString((string) $this->params->without(array('service_problem', 'service_handled', 'view'))));
$this->serviceList = $serviceList;
$this->view->listAllLink = Url::fromRequest()->setPath('monitoring/list/services');
$this->getTabs()->add('show', array('title' => sprintf($this->translate('Show summarized information for %u services'), count($this->serviceList)), 'label' => $this->translate('Services') . sprintf(' (%d)', count($this->serviceList)), 'url' => Url::fromRequest(), 'icon' => 'services'))->extend(new DashboardAction())->activate('show');
}
开发者ID:NerdGZ,项目名称:icingaweb2,代码行数:9,代码来源:ServicesController.php
示例9: applyRestriction
/**
* Apply a restriction on the given data view
*
* @param string $restriction The name of restriction
* @param Filterable $filterable The filterable to restrict
*
* @return Filterable The filterable
*/
protected static function applyRestriction($restriction, Filterable $filterable)
{
$restrictions = Filter::matchAny();
foreach (Manager::getInstance()->getRestrictions($restriction) as $filter) {
$restrictions->addFilter(Filter::fromQueryString($filter));
}
$filterable->applyFilter($restrictions);
return $filterable;
}
开发者ID:hsanjuan,项目名称:icingaweb2,代码行数:17,代码来源:MonitoringMenuItemRenderer.php
示例10: init
public function init()
{
$hostList = new HostList($this->backend);
$hostList->setFilter(Filter::fromQueryString((string) $this->params));
$this->applyRestriction('monitoring/filter/objects', $hostList);
$this->hostList = $hostList;
$this->getTabs()->add('show', array('title' => sprintf($this->translate('Show summarized information for %u hosts'), count($this->hostList)), 'label' => $this->translate('Hosts') . sprintf(' (%d)', count($this->hostList)), 'url' => Url::fromRequest(), 'icon' => 'host'))->extend(new DashboardAction())->activate('show');
$this->view->listAllLink = Url::fromRequest()->setPath('monitoring/list/hosts');
}
开发者ID:hsanjuan,项目名称:icingaweb2,代码行数:9,代码来源:HostsController.php
示例11: filterChainToArray
protected function filterChainToArray(Filter $filter)
{
if ($filter instanceof FilterAnd) {
$op = 'and';
} elseif ($filter instanceof FilterOr) {
$op = 'or';
} elseif ($filter instanceof FilterNot) {
$op = 'not';
} else {
throw new QueryException('Cannot render filter: %s', $filter);
}
$parts = array($op);
if (!$filter->isEmpty()) {
foreach ($filter->filters() as $f) {
$parts[] = $this->filterToArray($f);
}
}
return $parts;
}
开发者ID:Thomas-Gelf,项目名称:icingaweb2-module-puppetdb,代码行数:19,代码来源:FilterRenderer.php
示例12: init
public function init()
{
$hostList = new HostList($this->backend);
$this->applyRestriction('monitoring/filter/objects', $hostList);
$hostList->addFilter(Filter::fromQueryString((string) $this->params));
$this->hostList = $hostList;
$this->hostList->setColumns(array('host_acknowledged', 'host_active_checks_enabled', 'host_display_name', 'host_event_handler_enabled', 'host_flap_detection_enabled', 'host_handled', 'host_in_downtime', 'host_is_flapping', 'host_last_state_change', 'host_name', 'host_notifications_enabled', 'host_obsessing', 'host_passive_checks_enabled', 'host_problem', 'host_state', 'instance_name'));
$this->view->baseFilter = $this->hostList->getFilter();
$this->getTabs()->add('show', array('label' => $this->translate('Hosts') . sprintf(' (%d)', count($this->hostList)), 'title' => sprintf($this->translate('Show summarized information for %u hosts'), count($this->hostList)), 'url' => Url::fromRequest()))->extend(new DashboardAction())->extend(new MenuAction())->activate('show');
$this->view->listAllLink = Url::fromRequest()->setPath('monitoring/list/hosts');
}
开发者ID:0svald,项目名称:icingaweb2,代码行数:11,代码来源:HostsController.php
示例13: init
/**
* Fetch all comments matching the current filter and add tabs
*
* @throws Zend_Controller_Action_Exception
*/
public function init()
{
$this->filter = Filter::fromQueryString(str_replace('comment_id', 'comment_internal_id', (string) $this->params));
$query = $this->backend->select()->from('comment', array('id' => 'comment_internal_id', 'objecttype' => 'object_type', 'comment' => 'comment_data', 'author' => 'comment_author_name', 'timestamp' => 'comment_timestamp', 'type' => 'comment_type', 'persistent' => 'comment_is_persistent', 'expiration' => 'comment_expiration', 'host_name', 'service_description', 'host_display_name', 'service_display_name'))->addFilter($this->filter);
$this->applyRestriction('monitoring/filter/objects', $query);
$this->comments = $query->getQuery()->fetchAll();
if (false === $this->comments) {
throw new Zend_Controller_Action_Exception($this->translate('Comment not found'));
}
$this->getTabs()->add('comments', array('title' => $this->translate('Display detailed information about multiple comments.'), 'icon' => 'comment', 'label' => $this->translate('Comments') . sprintf(' (%d)', count($this->comments)), 'url' => 'monitoring/comments/show'))->activate('comments');
}
开发者ID:NerdGZ,项目名称:icingaweb2,代码行数:16,代码来源:CommentsController.php
示例14: argumentsAction
public function argumentsAction()
{
$this->getTabs()->activate('arguments');
$this->view->title = $this->translate('Command arguments');
$this->view->table = $this->loadTable('icingaCommandArgument')->setCommandObject($this->object)->setFilter(Filter::where('command', $this->params->get('name')));
$form = $this->view->form = $this->loadForm('icingaCommandArgument')->setCommandObject($this->object);
if ($id = $this->params->shift('argument_id')) {
$form->loadObject($id);
}
$form->handleRequest();
}
开发者ID:dgoeger,项目名称:icingadirector,代码行数:11,代码来源:CommandController.php
示例15: render
public function render()
{
$url = Url::fromRequest();
$view = $this->view();
$html = ' <form method="post" class="inline" action="' . $url . '"><input type="text" name="q" style="width: 8em" class="search" value="" placeholder="' . t('Add filter...') . '" /></form>';
// $html .= $this->renderFilter($this->filter);
$editorUrl = clone $url;
$editorUrl->setParam('modifyFilter', true);
if ($this->filter->isEmpty()) {
$title = t('Filter this list');
$txt = $view->icon('plus');
$remove = '';
} else {
$txt = t('Filtered');
$title = t('Modify this filter');
$remove = ' <a href="' . Url::fromRequest()->setParams(array()) . '" title="' . t('Remove this filter') . '">' . $view->icon('cancel') . '</a>';
}
$filter = $this->filter->isEmpty() ? '' : ': ' . $this->filter;
$html .= ($filter ? '<p>' : ' ') . '<a href="' . $editorUrl . '" title="' . $title . '">' . $txt . '</a>' . $this->shorten($filter, 72) . $remove . ($filter ? '</p>' : '');
return $html;
}
开发者ID:kobmaki,项目名称:icingaweb2,代码行数:21,代码来源:FilterWidget.php
示例16: renderSearch
public function renderSearch()
{
$html = ' <form method="post" class="search inline dontprint" action="' . $this->preservedUrl() . '"><input type="text" name="q" style="width: 8em" class="search" value="" placeholder="' . t('Search...') . '" /></form>';
if ($this->filter->isEmpty()) {
$title = t('Filter this list');
} else {
$title = t('Modify this filter');
if (!$this->filter->isEmpty()) {
$title .= ': ' . $this->filter;
}
}
return $html . '<a href="' . $this->preservedUrl()->with('modifyFilter', true) . '" aria-label="' . $title . '" title="' . $title . '">' . '<i aria-hidden="true" class="icon-filter"></i>' . '</a>';
}
开发者ID:trigoesrodrigo,项目名称:icingaweb2,代码行数:13,代码来源:FilterEditor.php
示例17: createElements
/**
* Create and add elements to this form
*
* @param array $formData The data sent by the user
*/
public function createElements(array $formData)
{
// TODO(jom): Fetching already existing members to prevent the user from mistakenly creating duplicate
// memberships (no matter whether the data source permits it or not, a member does never need to be
// added more than once) should be kept at backend level (GroupController::fetchUsers) but this does
// not work currently as our ldap protocol stuff is unable to handle our filter implementation..
$members = $this->backend->select()->from('group_membership', array('user_name'))->where('group_name', $this->groupName)->fetchColumn();
$filter = empty($members) ? Filter::matchAll() : Filter::not(Filter::where('user_name', $members));
$users = $this->ds->select()->from('user', array('user_name'))->applyFilter($filter)->fetchColumn();
if (!empty($users)) {
$this->addElement('multiselect', 'user_name', array('multiOptions' => array_combine($users, $users), 'label' => $this->translate('Backend Users'), 'description' => $this->translate('Select one or more users (fetched from your user backends) to add as group member'), 'class' => 'grant-permissions'));
}
$this->addElement('textarea', 'users', array('required' => empty($users), 'label' => $this->translate('Users'), 'description' => $this->translate('Provide one or more usernames separated by comma to add as group member')));
$this->setTitle(sprintf($this->translate('Add members for group %s'), $this->groupName));
$this->setSubmitLabel($this->translate('Add'));
}
开发者ID:0svald,项目名称:icingaweb2,代码行数:21,代码来源:AddMemberForm.php
示例18: applyRestriction
/**
* Apply a restriction on the given data view
*
* @param string $restriction The name of restriction
* @param Filterable $view The filterable to restrict
*
* @return Filterable The filterable
*/
protected function applyRestriction($restriction, Filterable $view)
{
$restrictions = Filter::matchAny();
$restrictions->setAllowedFilterColumns(array('host_name', 'hostgroup_name', 'service_description', 'servicegroup_name', function ($c) {
return preg_match('/^_(?:host|service)_/', $c);
}));
foreach ($this->getRestrictions($restriction) as $filter) {
try {
$restrictions->addFilter(Filter::fromQueryString($filter));
} catch (QueryException $e) {
throw new ConfigurationError($this->translate('Cannot apply restriction %s using the filter %s. You can only use the following columns: %s'), $restriction, $filter, implode(', ', array('host_name', 'hostgroup_name', 'service_description', 'servicegroup_name', '_(host|service)_<customvar-name>')), $e);
}
}
$view->applyFilter($restrictions);
return $view;
}
开发者ID:hsanjuan,项目名称:icingaweb2,代码行数:24,代码来源:Controller.php
示例19: getFilter
/**
* Return the corresponding filter-object
*
* @returns Filter
*/
public function getFilter()
{
$baseFilter = Filter::matchAny(Filter::expression('type', '=', 'hard_state'));
if ($this->getValue('objecttype', 'hosts') === 'hosts') {
$objectTypeFilter = Filter::expression('object_type', '=', 'host');
} else {
$objectTypeFilter = Filter::expression('object_type', '=', 'service');
}
$states = array('cnt_down_hard' => Filter::expression('state', '=', '1'), 'cnt_unreachable_hard' => Filter::expression('state', '=', '2'), 'cnt_up' => Filter::expression('state', '=', '0'), 'cnt_critical_hard' => Filter::expression('state', '=', '2'), 'cnt_warning_hard' => Filter::expression('state', '=', '1'), 'cnt_unknown_hard' => Filter::expression('state', '=', '3'), 'cnt_ok' => Filter::expression('state', '=', '0'));
$state = $this->getValue('state', 'cnt_critical_hard');
$stateFilter = $states[$state];
if (in_array($state, array('cnt_ok', 'cnt_up'))) {
return Filter::matchAll($objectTypeFilter, $stateFilter);
}
return Filter::matchAll($baseFilter, $objectTypeFilter, $stateFilter);
}
开发者ID:hsanjuan,项目名称:icingaweb2,代码行数:21,代码来源:StatehistoryForm.php
示例20: onSuccess
/**
* {@inheritdoc}
*/
public function onSuccess()
{
$cookie = new AnnouncementCookie();
$repo = new AnnouncementIniRepository();
$query = $repo->findActive();
$filter = array();
foreach ($cookie->getAcknowledged() as $hash) {
$filter[] = Filter::expression('hash', '=', $hash);
}
$query->addFilter(Filter::matchAny($filter));
$acknowledged = array();
foreach ($query as $row) {
$acknowledged[] = $row->hash;
}
$acknowledged[] = $this->getElement('hash')->getValue();
$cookie->setAcknowledged($acknowledged);
$this->getResponse()->setCookie($cookie);
return true;
}
开发者ID:0svald,项目名称:icingaweb2,代码行数:22,代码来源:AcknowledgeAnnouncementForm.php
注:本文中的Icinga\Data\Filter\Filter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论