Do only escape a qlink's label manually if necessary

This commit is contained in:
Johannes Meyer 2015-02-24 11:35:25 +01:00
parent 907134cee2
commit 8e8bab0795
17 changed files with 155 additions and 143 deletions

View File

@ -26,21 +26,25 @@
<tr>
<td>
<?= $this->qlink(
$this->icon('edit') . ' ' . $this->escape($name),
$name,
'config/editresource',
array('resource' => $name),
array('title' => sprintf($this->translate('Edit resource %s'), $name)),
false
array(
'icon' => 'edit',
'title' => sprintf($this->translate('Edit resource %s'), $name)
)
); ?>
</td>
<td>
<center>
<?= $this->qlink(
$this->icon('cancel'),
'',
'config/removeresource',
array('resource' => $name),
array('title' => sprintf($this->translate('Remove resource %s'), $name)),
false
array(
'icon' => 'cancel',
'title' => sprintf($this->translate('Remove resource %s'), $name)
)
); ?>
</center>
</td>

View File

@ -24,11 +24,13 @@
</th>
<th>
<?= $this->qlink(
$this->icon('cancel'),
'',
'dashboard/remove-pane',
array('pane' => $pane->getName()),
array('title' => sprintf($this->translate('Remove pane %s'), $pane->getName())),
false
array(
'icon' => 'cancel',
'title' => sprintf($this->translate('Remove pane %s'), $pane->getName())
)
); ?>
</th>
</tr>
@ -61,11 +63,13 @@
</td>
<td>
<?= $this->qlink(
$this->icon('cancel'),
'',
'dashboard/remove-dashlet',
array('pane' => $pane->getName(), 'dashlet' => $dashlet->getTitle()),
array('title' => sprintf($this->translate('Remove dashlet %s from pane %s'), $dashlet->getTitle(), $pane->getName())),
false
array(
'icon' => 'cancel',
'title' => sprintf($this->translate('Remove dashlet %s from pane %s'), $dashlet->getTitle(), $pane->getName())
)
); ?>
</td>
</tr>

View File

@ -11,20 +11,24 @@
<tr>
<td class="action">
<?= $this->qlink(
$this->icon('edit') . ' ' . $this->escape($backendNames[$i]),
$backendNames[$i],
'config/editAuthenticationBackend',
array('auth_backend' => $backendNames[$i]),
array('title' => sprintf($this->translate('Edit authentication backend %s'), $backendNames[$i])),
false
array(
'icon' => 'edit',
'title' => sprintf($this->translate('Edit authentication backend %s'), $backendNames[$i])
)
); ?>
</td>
<td>
<?= $this->qlink(
$this->icon('cancel'),
'',
'config/removeAuthenticationBackend',
array('auth_backend' => $backendNames[$i]),
array('title' => sprintf($this->translate('Remove authentication backend %s'), $backendNames[$i])),
false
array(
'icon' => 'cancel',
'title' => sprintf($this->translate('Remove authentication backend %s'), $backendNames[$i])
)
); ?>
</td>
<td>

View File

@ -29,12 +29,13 @@ $nextXAxisPage = $currentXAxisPage < $totalXAxisPages ? $currentXAxisPage + 1 :
<td>
<?php if ($prevYAxisPage): ?>
<?= $this->qlink(
$this->icon('up-open'),
'',
Url::fromRequest(),
array(
'page' => $currentXAxisPage . ',' . $prevYAxisPage
),
array(
'icon' => 'up-open',
'data-base-target' => '_self',
'title' => sprintf(
$showText,
@ -44,8 +45,7 @@ $nextXAxisPage = $currentXAxisPage < $totalXAxisPages ? $currentXAxisPage + 1 :
$prevYAxisPage * $yAxisPages->itemCountPerPage,
$yAxisPages->totalItemCount
)
),
false
)
); ?>
<?php else: ?>
<?= $this->icon('up-open'); ?>
@ -57,12 +57,13 @@ $nextXAxisPage = $currentXAxisPage < $totalXAxisPages ? $currentXAxisPage + 1 :
<td>
<?php if ($prevXAxisPage): ?>
<?= $this->qlink(
$this->icon('left-open'),
'',
Url::fromRequest(),
array(
'page' => $prevXAxisPage . ',' . $currentYAxisPage
),
array(
'icon' => 'left-open',
'data-base-target' => '_self',
'title' => sprintf(
$showText,
@ -72,8 +73,7 @@ $nextXAxisPage = $currentXAxisPage < $totalXAxisPages ? $currentXAxisPage + 1 :
$prevXAxisPage * $xAxisPages->itemCountPerPage,
$xAxisPages->totalItemCount
)
),
false
)
); ?>
<?php else: ?>
<?= $this->icon('left-open'); ?>
@ -83,12 +83,13 @@ $nextXAxisPage = $currentXAxisPage < $totalXAxisPages ? $currentXAxisPage + 1 :
<td>
<?php if ($nextXAxisPage): ?>
<?= $this->qlink(
$this->icon('right-open'),
'',
Url::fromRequest(),
array(
'page' => $nextXAxisPage . ',' . $currentYAxisPage
),
array(
'icon' => 'right-open',
'data-base-target' => '_self',
'title' => sprintf(
$showText,
@ -111,12 +112,13 @@ $nextXAxisPage = $currentXAxisPage < $totalXAxisPages ? $currentXAxisPage + 1 :
<td>
<?php if ($nextYAxisPage): ?>
<?= $this->qlink(
$this->icon('down-open'),
'',
Url::fromRequest(),
array(
'page' => $currentXAxisPage . ',' . $nextYAxisPage
),
array(
'icon' => 'down-open',
'data-base-target' => '_self',
'title' => sprintf(
$showText,
@ -126,8 +128,7 @@ $nextXAxisPage = $currentXAxisPage < $totalXAxisPages ? $currentXAxisPage + 1 :
$nextYAxisPage === $yAxisPages->last ? $yAxisPages->totalItemCount : $nextYAxisPage * $yAxisPages->itemCountPerPage,
$yAxisPages->totalItemCount
)
),
false
)
); ?>
<?php else: ?>
<?= $this->icon('down-open'); ?>

View File

@ -56,11 +56,13 @@
<td><?= $this->escape($role->groups) ?></td>
<td>
<?= $this->qlink(
$this->icon('cancel'),
'',
'roles/remove',
array('role' => $name),
array('title' => sprintf($this->translate('Remove role %s'), $name)),
false
array(
'icon' => 'cancel',
'title' => sprintf($this->translate('Remove role %s'), $name)
)
); ?>
</td>
</tr>

View File

@ -28,15 +28,23 @@ $this->addHelperFunction('url', function ($path = null, $params = null) {
});
$this->addHelperFunction('qlink', function ($title, $url, $params = null, $properties = null, $escape = true) use ($view) {
if ($properties && array_key_exists('title', $properties) && !array_key_exists('aria-label', $properties)) {
$properties['aria-label'] = $properties['title'];
$icon = '';
if ($properties) {
if (array_key_exists('title', $properties) && !array_key_exists('aria-label', $properties)) {
$properties['aria-label'] = $properties['title'];
}
if (array_key_exists('icon', $properties)) {
$icon = $view->icon($properties['icon']);
unset($properties['icon']);
}
}
return sprintf(
'<a href="%s"%s>%s</a>',
$view->url($url, $params),
$view->propertiesToString($properties),
$escape ? $view->escape($title) : $title
$icon . ($escape ? $view->escape($title) : $title)
);
});

View File

@ -310,8 +310,8 @@ class FilterEditor extends AbstractWidget
$this->preservedUrl()->with('removeFilter', $filter->getId()),
null,
array(
'title' => t('Remove this part of your filter'),
'class' => 'icon-cancel'
'icon' => 'icon-cancel',
'title' => t('Remove this part of your filter')
)
);
}
@ -323,8 +323,8 @@ class FilterEditor extends AbstractWidget
$this->preservedUrl()->with('addFilter', $filter->getId()),
null,
array(
'title' => t('Add another filter'),
'class' => 'icon-plus'
'icon' => 'icon-plus',
'title' => t('Add another filter')
)
);
}
@ -336,8 +336,8 @@ class FilterEditor extends AbstractWidget
$this->preservedUrl()->with('stripFilter', $filter->getId()),
null,
array(
'title' => t('Strip this filter'),
'class' => 'icon-minus'
'icon' => 'icon-minus',
'title' => t('Strip this filter')
)
);
}
@ -349,8 +349,8 @@ class FilterEditor extends AbstractWidget
$this->preservedUrl()->without('addFilter'),
null,
array(
'title' => t('Cancel this operation'),
'class' => 'icon-cancel'
'icon' => 'icon-cancel',
'title' => t('Cancel this operation')
)
);
}

View File

@ -19,11 +19,13 @@
<tr>
<td>
<?= $this->qlink(
$this->icon('edit') . ' ' . $this->escape($backendName),
$backendName,
'/monitoring/config/editbackend',
array('backend' => $backendName),
array('title' => sprintf($this->translate('Edit monitoring backend %s'), $backendName)),
false
array(
'icon' => 'edit',
'title' => sprintf($this->translate('Edit monitoring backend %s'), $backendName)
)
); ?>
<small>(<?= sprintf(
$this->translate('Type: %s'),
@ -32,11 +34,13 @@
</td>
<td>
<?= $this->qlink(
$this->icon('cancel'),
'',
'/monitoring/config/removebackend',
array('backend' => $backendName),
array('title' => sprintf($this->translate('Remove monitoring backend %s'), $backendName)),
false
array(
'icon' => 'cancel',
'title' => sprintf($this->translate('Remove monitoring backend %s'), $backendName)
)
); ?>
</td>
</tr>
@ -59,11 +63,13 @@
<tr>
<td>
<?= $this->qlink(
$this->icon('edit') . ' ' . $this->escape($instanceName),
$instanceName,
'/monitoring/config/editinstance',
array('instance' => $instanceName),
array('title' => sprintf($this->translate('Edit monitoring instance %s'), $instanceName)),
false
array(
'icon' => 'edit',
'title' => sprintf($this->translate('Edit monitoring instance %s'), $instanceName)
)
); ?>
<small>(<?= sprintf(
$this->translate('Type: %s'),
@ -72,11 +78,13 @@
</td>
<td>
<?= $this->qlink(
$this->icon('cancel'),
'',
'/monitoring/config/removeinstance',
array('instance' => $instanceName),
array('title' => sprintf($this->translate('Remove monitoring instance %s'), $instanceName)),
false
array(
'icon' => 'cancel',
'title' => sprintf($this->translate('Remove monitoring instance %s'), $instanceName)
)
); ?>
</td>
</tr>

View File

@ -14,31 +14,22 @@
<?= $checkNowForm; ?>
</div>
<div><?= $this->qlink(
$this->icon('reschedule') . ' ' . sprintf(
$this->translate('Reschedule the next check for all %u hosts'),
$hostCount
),
sprintf($this->translate('Reschedule the next check for all %u hosts'), $hostCount),
$rescheduleAllLink,
null,
null,
false
array('icon' => 'reschedule')
); ?></div>
<div><?= $this->qlink(
$this->icon('plug') . ' ' . sprintf($this->translate('Schedule a downtime for all %u hosts'), $hostCount),
sprintf($this->translate('Schedule a downtime for all %u hosts'), $hostCount),
$downtimeAllLink,
null,
null,
false
array('icon' => 'plug')
); ?></div>
<div><?= $this->qlink(
$this->icon('reply') . ' ' . sprintf(
$this->translate('Submit a passive check result for all %u hosts'),
$hostCount
),
sprintf($this->translate('Submit a passive check result for all %u hosts'), $hostCount),
$processCheckResultAllLink,
null,
null,
false
array('icon' => 'reply')
); ?></div>
<?php if (($unhandledCount = count($unhandledObjects)) > 0): ?>
<div>
@ -51,7 +42,7 @@
$unhandledCount
); ?></h3>
<div><?= $this->qlink(
$this->icon('plug') . ' ' . sprintf(
sprintf(
$this->translatePlural(
'Schedule a downtime for %u unhandled host problem',
'Schedule a downtime for %u unhandled host problems',
@ -61,11 +52,10 @@
),
$downtimeUnhandledLink,
null,
null,
false
array('icon' => 'plug')
); ?></div>
<div><?= $this->qlink(
$this->icon('ok') . ' ' . sprintf(
sprintf(
$this->translatePlural(
'Acknowledge %u unhandled host problem',
'Acknowledge %u unhandled host problems',
@ -75,8 +65,7 @@
),
$acknowledgeUnhandledLink,
null,
null,
false
array('icon' => 'ok')
); ?></div>
</div>
<?php endif ?>
@ -95,7 +84,7 @@
<?php endif ?>
<?php if (($inDowntimeCount = count($objectsInDowntime)) > 0): ?>
<h2><?= $this->qlink(
$this->icon('plug') . ' ' . sprintf(
sprintf(
$this->translatePlural(
'List %u host currently in downtime',
'List %u hosts currently in downtime',
@ -105,13 +94,12 @@
),
$inDowntimeLink,
null,
null,
false
array('icon' => 'plug')
); ?></h2>
<?php endif ?>
<?php if (($commentCount = count($objects->getComments())) > 0): ?>
<h2><?= $this->qlink(
$this->icon('comment') . ' ' . sprintf(
sprintf(
$this->translatePlural(
'List %u host comment',
'List %u host comments',
@ -121,8 +109,7 @@
),
$commentsLink,
null,
null,
false
array('icon' => 'comment')
); ?></h2>
<?php endif ?>
<?php endif ?>

View File

@ -17,16 +17,15 @@
foreach ($contacts as $contact): ?>
<div class="contact">
<?= $this->img('/static/gravatar', array('email' => $contact->contact_email)); ?>
<?= $this->qlink(
'<strong>' . $this->escape($contact->contact_name) . '</strong>',
<strong><?= $this->qlink(
$contact->contact_name,
'monitoring/show/contact',
array('contact' => $contact->contact_name),
array('title' => sprintf(
$this->translate('Show detailed information about %s'),
$contact->contact_alias
)),
false
); ?> (<?= $contact->contact_alias; ?>)
))
); ?></strong> (<?= $contact->contact_alias; ?>)
<div>
<?= $this->translate('Email'); ?>: <a href="mailto:<?= $contact->contact_email; ?>" title="<?= sprintf($this->translate('Send a mail to %s'), $contact->contact_alias); ?>" aria-label="<?= sprintf($this->translate('Send a mail to %s'), $contact->contact_alias); ?>">
<?= $this->escape($contact->contact_email); ?>

View File

@ -14,31 +14,22 @@
<?= $checkNowForm; ?>
</div>
<div><?= $this->qlink(
$this->icon('reschedule') . ' ' . sprintf(
$this->translate('Reschedule the next check for all %u services'),
$serviceCount
),
sprintf($this->translate('Reschedule the next check for all %u services'), $serviceCount),
$rescheduleAllLink,
null,
null,
false
array('icon' => 'reschedule')
); ?></div>
<div><?= $this->qlink(
$this->icon('plug') . ' ' . sprintf($this->translate('Schedule a downtime for all %u services'), $serviceCount),
sprintf($this->translate('Schedule a downtime for all %u services'), $serviceCount),
$downtimeAllLink,
null,
null,
false
array('icon' => 'plug')
); ?></div>
<div><?= $this->qlink(
$this->icon('reply') . ' ' . sprintf(
$this->translate('Submit a passive check result for all %u services'),
$serviceCount
),
sprintf($this->translate('Submit a passive check result for all %u services'), $serviceCount),
$processCheckResultAllLink,
null,
null,
false
array('icon' => 'reply')
); ?></div>
<?php if (($unhandledCount = count($unhandledObjects)) > 0): ?>
<div>
@ -51,7 +42,7 @@
$unhandledCount
); ?></h3>
<div><?= $this->qlink(
$this->icon('plug') . ' ' . sprintf(
sprintf(
$this->translatePlural(
'Schedule a downtime for %u unhandled service problem',
'Schedule a downtime for %u unhandled service problems',
@ -61,11 +52,10 @@
),
$downtimeUnhandledLink,
null,
null,
false
array('icon' => 'plug')
); ?></div>
<div><?= $this->qlink(
$this->icon('ok') . ' ' . sprintf(
sprintf(
$this->translatePlural(
'Acknowledge %u unhandled service problem',
'Acknowledge %u unhandled service problems',
@ -75,8 +65,7 @@
),
$acknowledgeUnhandledLink,
null,
null,
false
array('icon' => 'ok')
); ?></div>
</div>
<?php endif ?>
@ -95,7 +84,7 @@
<?php endif ?>
<?php if (($inDowntimeCount = count($objectsInDowntime)) > 0): ?>
<h2><?= $this->qlink(
$this->icon('plug') . ' ' . sprintf(
sprintf(
$this->translatePlural(
'List %u service currently in downtime',
'List %u services currently in downtime',
@ -105,13 +94,12 @@
),
$inDowntimeLink,
null,
null,
false
array('icon' => 'plug')
); ?></h2>
<?php endif ?>
<?php if (($commentCount = count($objects->getComments())) > 0): ?>
<h2><?= $this->qlink(
$this->icon('comment') . ' ' . sprintf(
sprintf(
$this->translatePlural(
'List %u service comment',
'List %u service comments',
@ -121,8 +109,7 @@
),
$commentsLink,
null,
null,
false
array('icon' => 'comment')
); ?></h2>
<?php endif ?>
<?php endif ?>

View File

@ -36,13 +36,15 @@ if ($object->acknowledged): ?>
}
?>
<?= $this->qlink(
$this->icon('ok') . ' ' . $this->translate('Acknowledge'),
$this->translate('Acknowledge'),
$ackLink,
null,
array('title' => $this->translate(
'Acknowledge this problem, suppress all future notifications for it and tag it as being handled'
)),
false
array(
'icon' => 'ok',
'title' => $this->translate(
'Acknowledge this problem, suppress all future notifications for it and tag it as being handled'
)
)
); ?>
<?php } else {
echo '&#45;';

View File

@ -29,29 +29,29 @@ if ($object->getType() === $object::TYPE_HOST) {
<?php if ($this->hasPermission('monitoring/command/schedule-check')) {
if ($isService) {
echo $this->qlink(
$this->icon('reschedule') . ' ' . $this->translate('Reschedule'),
$this->translate('Reschedule'),
'monitoring/service/reschedule-check',
array('host' => $object->getHost()->getName(), 'service' => $object->getName()),
array(
'icon' => 'reschedule',
'data-base-target' => '_self',
'title' => $this->translate(
'Schedule the next active check at a different time than the current one'
)
),
false
)
);
} else {
echo $this->qlink(
$this->icon('reschedule') . ' ' . $this->translate('Reschedule'),
$this->translate('Reschedule'),
'monitoring/host/reschedule-check',
array('host' => $object->getName()),
array(
'icon' => 'reschedule',
'data-base-target' => '_self',
'title' => $this->translate(
'Schedule the next active check at a different time than the current one'
)
),
false
)
);
}
} ?> <?= $this->timeUntil($object->next_check) ?>

View File

@ -13,19 +13,25 @@ $command = array_shift($parts);
$title = sprintf($this->translate('Submit a one time or so called passive result for the %s check'), $command);
if ($object->getType() === $object::TYPE_HOST) {
echo $this->qlink(
$this->icon('reply') . ' ' . $this->translate('Process check result'),
$this->translate('Process check result'),
'monitoring/host/process-check-result',
array('host' => $object->getName()),
array('data-base-target' => '_self', 'title' => $title),
false
array(
'icon' => 'reply',
'data-base-target' => '_self',
'title' => $title
)
);
} else {
echo $this->qlink(
$this->icon('reply') . ' ' . $this->translate('Process check result'),
$this->translate('Process check result'),
'monitoring/service/process-check-result',
array('host' => $object->getHost()->getName(), 'service' => $object->getName()),
array('data-base-target' => '_self', 'title' => $title),
false
array(
'icon' => 'reply',
'data-base-target' => '_self',
'title' => $title
)
);
}
} ?>

View File

@ -5,25 +5,25 @@
/** @type \Icinga\Module\Monitoring\Object\MonitoredObject $object */
if ($object->getType() === $object::TYPE_HOST) {
echo $this->qlink(
$this->icon('comment') . ' ' . $this->translate('Add comment'),
$this->translate('Add comment'),
'monitoring/host/add-comment',
array('host' => $object->getName()),
array(
'icon' => 'comment',
'data-base-target' => '_self',
'title' => $this->translate('Add a new comment to this host')
),
false
)
);
} else {
echo $this->qlink(
$this->icon('comment') . ' ' . $this->translate('Add comment'),
$this->translate('Add comment'),
'monitoring/service/add-comment',
array('host' => $object->getHost()->getName(), 'service' => $object->getName()),
array(
'icon' => 'comment',
'data-base-target' => '_self',
'title' => $this->translate('Add a new comment to this service')
),
false
)
);
}
} else {

View File

@ -5,29 +5,29 @@
/** @type \Icinga\Module\Monitoring\Object\MonitoredObject $object */
if ($object->getType() === $object::TYPE_HOST) {
echo $this->qlink(
$this->icon('plug') . ' ' . $this->translate('Schedule downtime'),
$this->translate('Schedule downtime'),
'monitoring/host/schedule-downtime',
array('host' => $object->getName()),
array(
'icon' => 'plug',
'data-base-target' => '_self',
'title' => $this->translate(
'Schedule a downtime to suppress all problem notifications within a specific period of time'
)
),
false
)
);
} else {
echo $this->qlink(
$this->icon('plug') . ' ' . $this->translate('Schedule downtime'),
$this->translate('Schedule downtime'),
'monitoring/service/schedule-downtime',
array('host' => $object->getHost()->getName(), 'service' => $object->getName()),
array(
'icon' => 'plug',
'data-base-target' => '_self',
'title' => $this->translate(
'Schedule a downtime to suppress all problem notifications within a specific period of time'
)
),
false
)
);
}
} else {

View File

@ -141,7 +141,7 @@ $output = $this->tickets ? preg_replace_callback(
<?= sprintf(
$this->translate('%s on %s', 'Service running on host'),
$hostContext ? $this->qlink(
$this->escape($event->service_display_name),
$event->service_display_name,
'monitoring/show/service',
array(
'host' => $event->host_name,