%s
',__METHOD__);
if (DEBUGTMP||DEBUGTMPSUB) printf('* %s [GETquery:%s]
',__METHOD__,get_request('query','REQUEST'));
if (DEBUGTMP||DEBUGTMPSUB) printf('* %s [Page:%s]
',__METHOD__,get_request('page','REQUEST'));
$this->template_id = $this->getTemplateChoice();
$this->page = get_request('page','REQUEST',false,1);
if ($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() {
if (DEBUGTMP) printf('%s
',__METHOD__);
$server = $this->getServer();
$this->drawTitle(_('Search'));
$this->drawSubTitle();
echo "\n";
$baseDNs = $server->getBaseDN();
echo '
';
echo ' '; echo ' '; $this->drawResultsTable($base,count($results)); echo ' '; echo ' '; foreach ($results as $dn => $dndetails) { $dndetails = array_change_key_case($dndetails); # Temporarily set our DN, for rendering that leverages our DN (eg: JpegPhoto) $this->template->setDN($dn); echo '
'; } echo ' |
';
echo ' '; echo ' '; $this->drawResultsTable($base,count($results)); echo ' '; echo ' '; if (! $results) { echo _('Search returned no results'); echo ' |
'; foreach (explode(',',$this->template->getAttrDisplayOrder()) as $attr) { echo ' | '; $this->draw('Name',$afattrs[$attr]); echo ' | '; } echo '||
', htmlspecialchars($href), IMGDIR,get_icon($server->getIndex(),$dn)); # We'll clone our attribute factory attributes, since we need to add the values to them for rendering. foreach (explode(',',$this->template->getAttrDisplayOrder()) as $attr) { # If the entry is blank, we'll draw an empty box and continue. if (! isset($dndetails[$attr])) { echo ' | '; continue; } # Special case for DNs if ($attr == 'dn') { $dn_display = strlen($dn) > 40 ? sprintf('%s...',htmlspecialchars($dn),htmlspecialchars(substr($dn,0,40))) : htmlspecialchars($dn); printf(' | %s | ',htmlspecialchars($href),$dn_display); continue; } # Set our object with our values $afattrs[$attr]->clearValue(); if (is_array($dndetails[$attr])) $afattrs[$attr]->initValue($dndetails[$attr]); else $afattrs[$attr]->initValue(array($dndetails[$attr])); echo ''; $this->draw('CurrentValues',$afattrs[$attr]); echo ' | '; } echo '
%s | ', $this->getAjaxRef($base), $this->getAjaxRef($base), ($show == $this->getAjaxRef($base) ? '#F0F0F0' : '#E0E0E0'), $base); } echo '
%s: %s (%s %s) | ',_('Entries found'),
number_format($results),$this->template->resultsdata[$base]['time'],_('seconds'));
if ($_SESSION[APPCONFIG]->isCommandAvailable('export')) {
$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 results'));
}
printf('[ %s:',IMGDIR,_('Format'));
foreach (array('list','table') as $f) {
echo ' ';
if (get_request('format','REQUEST') == $f) {
printf('%s',_($f));
} else {
$query_string = array_to_query_string($_GET,array('format','cmd'));
$query_string .= sprintf('&format=%s&show=%s',$f,$this->getAjaxRef($base));
printf('%s',htmlspecialchars($query_string),_($f));
}
}
echo ' ]';
echo ' '; printf('%s: %s',_('Base DN'),$base); echo ' '; printf('%s: %s',_('Filter performed'),htmlspecialchars($this->template->resultsdata[$base]['filter'])); echo ' | ';
echo '