%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 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() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs);
return new Queries($this->server_id);
}
/**
* Are default queries enabled?
*/
protected function haveDefaultTemplate() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs);
$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();
printf('',JSDIR);
echo '
';
echo ' '; echo ' '; $this->drawResultsTable($base,count($results)); echo ' '; echo ' '; switch(get_request('format','REQUEST',false,$_SESSION[APPCONFIG]->getValue('search','display'))) { case '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 '
'; } break; # Display the results. case 'table': if (! $results) { echo _('Search returned no results'); continue; } printf(''; echo "\n\n"; break; default: printf('Have ID [%s], run this query for page [%s]',$this->template_id,$this->page); } 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 '