本文整理汇总了PHP中Icinga\Data\Filter\Filter类的典型用法代码示例。如果您正苦于以下问题:PHP Filter类的具体用法?PHP Filter怎么用?PHP Filter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Filter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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');
}
示例2: filter
protected function filter()
{
if ($this->filter === null) {
$this->filter = Filter::fromQueryString($this->filter_expression);
}
return $this->filter;
}
示例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');
}
示例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>';
}
示例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;
}
示例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
}
示例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);
}
示例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');
}
示例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;
}
示例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');
}
示例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;
}
示例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');
}
示例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');
}
示例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();
}
示例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;
}