<?php
  
$objectCount = count($objects);

$links = array();
for ($i = 0; $i < $objectCount && $i < 5; $i++) {
    $object = $objects[$i];    

    if ($this->is_service) {
        $links[] = $this->qlink(
            $object->host_name . ' ' . $object->service_description,
            'monitoring/show/service',
            array(
                'host' => $object->host_name,
                'service' => $object->service_description
            )
        );
    } else {
        $links[] =  $this->qlink(
            $object->host_name,
            'monitoring/show/host',
            array(
                'host' => $object->host_name
            )
        );
    }
}

if ($this->is_service) {
    $objectName = $this->translate('Services');
    $link = 'monitoring/list/services';
    $target = array(
        'host'    => $this->hostquery,
        'service' => $this->servicequery
    );
} else {
    $objectName = $this->translate('Hosts');
    $link = 'monitoring/list/hosts';
    $target = array(
        'host' => $this->hostquery
    );
}

$more = clone $this->url;


?><tr class="newsection" data-base-target="_next">
<th><?= $this->qlink(
    $this->translate('List all'),
    $more->setPath($link),
    null,
    array('title' => $this->translate('List all selected objects'))
) ?></th>
<td colspan="3">
<?php

echo implode(', ', $links);

if ($objectCount > 5) {
    echo ' ' . sprintf($this->translate('and %d more'), count($objects) - 5);
}

?>
</td>
</tr>
