template_id = $this->getTemplateChoice(); $this->page = get_request('page','REQUEST',false,1); # If we are the default template, make sure we pressed search if ($this->template_id == 'none' && ! get_request('search','REQUEST')) $this->drawTemplateChoice(); elseif ($this->template_id) { $templates = $this->getTemplates(); $this->template = $templates->getTemplate($this->template_id); $this->template->accept(); $this->visitStart(); $this->visitEnd(); } } /** * Get our templates applicable for this object */ protected function getTemplates() { return new Queries($this->server_id); } /** * Are default queries enabled? */ protected function haveDefaultTemplate() { $server = $this->getServer(); if ($server->getValue('query','disable_default')) return false; else return true; } protected function drawTemplateChoice() { $server = $this->getServer(); $this->drawTitle(_('Search')); $this->drawSubTitle(); echo "\n"; $baseDNs = $server->getBaseDN(); printf('',JSDIR); echo '
'; } private function visitStart() { $this->drawTitle(_('Search Results')); $this->drawSubTitle(); echo '';
echo ' '; echo ' '; $this->drawResultsTable($base,count($results)); echo ' '; echo ' '; $format = get_request('format','REQUEST',false,$_SESSION[APPCONFIG]->getValue('search','display')); if ($format === 'list') { foreach ($results as $dndetails) { $dndetails = array_change_key_case($dndetails); # Temporarily set our DN, for rendering that leverages our DN (eg: JpegPhoto) $this->template->setDN($dndetails['dn']); echo '
'; } } else { # Display the results. if (!$results) { echo _('Search returned no results'); } else { printf(''; echo "\n\n"; } } echo ' |
%s | ', $this->getAjaxRef($base), $this->getAjaxRef($base), ($show == $this->getAjaxRef($base) ? '#F0F0F0' : '#E0E0E0'), htmlspecialchars($base)); } echo '
%s: %s (%s %s) | ',_('Entries found'),
number_format($results),$this->template->resultsdata[$base]['time'],_('seconds'));
if ($_SESSION[APPCONFIG]->isCommandAvailable('script','export') && $_SESSION[APPCONFIG]->isCommandAvailable('script','export_form')) {
$href = htmlspecialchars(sprintf('cmd.php?cmd=export_form&server_id=%s&scope=%s&dn=%s&filter=%s&attributes=%s',
$server->getIndex(),$this->template->resultsdata[$base]['scope'],
$base,rawurlencode($this->template->resultsdata[$base]['filter']),
rawurlencode(implode(', ',$this->template->resultsdata[$base]['attrs']))));
printf('[ %s ]',
$href,IMGDIR,_('export'));
}
printf('[ %s:',IMGDIR,_('Format'));
foreach (array('list','table') as $f) {
echo ' ';
if (get_request('format','REQUEST',false,$_SESSION[APPCONFIG]->getValue('search','display')) == $f) {
printf('%s',_($f));
} else {
$query_string = htmlspecialchars(sprintf('%s&format=%s&show=%s&focusbase=%s',array_to_query_string($_GET,array('format','meth')),$f,$this->getAjaxRef($base),$base));
if (isAjaxEnabled())
printf('%s',
$query_string,$query_string,_('Loading search'),_($f));
else
printf('%s',$query_string,_($f));
}
}
echo ' ]';
echo ' '; printf('%s: %s',_('Base DN'), htmlspecialchars($base)); echo ' '; printf('%s: %s',_('Filter performed'),htmlspecialchars($this->template->resultsdata[$base]['filter'])); echo ' | ';
echo '