fixed PHP message

This commit is contained in:
Roland Gruber 2020-08-13 17:30:35 +02:00
parent 6c306bcb9e
commit c5b6c8132c
1 changed files with 72 additions and 79 deletions

View File

@ -210,8 +210,8 @@ class QueryRender extends PageRender {
echo '<br/>'; echo '<br/>';
echo '<br/>'; echo '<br/>';
switch(get_request('format','REQUEST',false,$_SESSION[APPCONFIG]->getValue('search','display'))) { $format = get_request('format','REQUEST',false,$_SESSION[APPCONFIG]->getValue('search','display'));
case 'list': if ($format === 'list') {
foreach ($results as $dndetails) { foreach ($results as $dndetails) {
$dndetails = array_change_key_case($dndetails); $dndetails = array_change_key_case($dndetails);
@ -221,22 +221,22 @@ class QueryRender extends PageRender {
echo '<table class="result" border="0">'; echo '<table class="result" border="0">';
echo '<tr class="list_title">'; echo '<tr class="list_title">';
printf('<td class="icon"><img src="%s/%s" alt="icon" /></td>',IMGDIR,get_icon($server->getIndex(),$dndetails['dn'])); printf('<td class="icon"><img src="%s/%s" alt="icon" /></td>', IMGDIR, get_icon($server->getIndex(), $dndetails['dn']));
printf('<td colspan="2"><a href="cmd.php?cmd=template_engine&amp;server_id=%s&amp;dn=%s">%s</a></td>', printf('<td colspan="2"><a href="cmd.php?cmd=template_engine&amp;server_id=%s&amp;dn=%s">%s</a></td>',
$server->getIndex(),$this->template->getDNEncode(),htmlspecialchars(get_rdn($dndetails['dn']))); $server->getIndex(), $this->template->getDNEncode(), htmlspecialchars(get_rdn($dndetails['dn'])));
echo '</tr>'; echo '</tr>';
printf('<tr class="list_item"><td class="blank">&nbsp;</td><td class="heading">dn</td><td class="value">%s</td></tr>', printf('<tr class="list_item"><td class="blank">&nbsp;</td><td class="heading">dn</td><td class="value">%s</td></tr>',
htmlspecialchars(dn_unescape($dndetails['dn']))); htmlspecialchars(dn_unescape($dndetails['dn'])));
# Iterate over each attribute for this entry # Iterate over each attribute for this entry
foreach (explode(',',$ado) as $attr) { foreach (explode(',', $ado) as $attr) {
# Ignore DN, we've already displayed it. # Ignore DN, we've already displayed it.
if ($attr == 'dn') if ($attr == 'dn')
continue; continue;
if (! isset($dndetails[$attr])) if (!isset($dndetails[$attr]))
continue; continue;
# Set our object with our values # Set our object with our values
@ -251,11 +251,11 @@ class QueryRender extends PageRender {
echo '<td class="blank">&nbsp;</td>'; echo '<td class="blank">&nbsp;</td>';
echo '<td class="heading">'; echo '<td class="heading">';
$this->draw('Name',$afattrs[$attr]); $this->draw('Name', $afattrs[$attr]);
echo '</td>'; echo '</td>';
echo '<td>'; echo '<td>';
$this->draw('CurrentValues',$afattrs[$attr]); $this->draw('CurrentValues', $afattrs[$attr]);
echo '</td>'; echo '</td>';
echo '</tr>'; echo '</tr>';
} }
@ -263,23 +263,20 @@ class QueryRender extends PageRender {
echo '</table>'; echo '</table>';
echo '<br/>'; echo '<br/>';
} }
break;
# Display the results.
case 'table':
if (! $results) {
echo _('Search returned no results');
continue;
} }
else {
# Display the results.
if (!$results) {
echo _('Search returned no results');
}
else {
printf('<form action="cmd.php" method="post" id="massform_%s">',$counter); printf('<form action="cmd.php" method="post" id="massform_%s">', $counter);
echo '<div>'; echo '<div>';
printf('<input type="hidden" name="server_id" value="%s" />',$server->getIndex()); printf('<input type="hidden" name="server_id" value="%s" />', $server->getIndex());
foreach ($this->template->resultsdata[$base]['attrs'] as $attr) foreach ($this->template->resultsdata[$base]['attrs'] as $attr)
printf('<input type="hidden" name="attrs[]" value="%s" />',$attr); printf('<input type="hidden" name="attrs[]" value="%s" />', $attr);
echo '</div>'; echo '</div>';
@ -290,9 +287,9 @@ class QueryRender extends PageRender {
echo '<td>&nbsp;</td>'; echo '<td>&nbsp;</td>';
echo '<td>&nbsp;</td>'; echo '<td>&nbsp;</td>';
foreach (explode(',',$ado) as $attr) { foreach (explode(',', $ado) as $attr) {
echo '<td>'; echo '<td>';
$this->draw('Name',$afattrs[$attr]); $this->draw('Name', $afattrs[$attr]);
echo '</td>'; echo '</td>';
} }
@ -308,21 +305,21 @@ class QueryRender extends PageRender {
$this->template->setDN($dndetails['dn']); $this->template->setDN($dndetails['dn']);
printf('<tr class="%s" id="tr_ma_%s" onclick="var cb=document.getElementById(\'ma_%s\'); cb.checked=!cb.checked;">', printf('<tr class="%s" id="tr_ma_%s" onclick="var cb=document.getElementById(\'ma_%s\'); cb.checked=!cb.checked;">',
$j%2 ? 'even' : 'odd',$j,$j); $j % 2 ? 'even' : 'odd', $j, $j);
# Is mass action enabled. # Is mass action enabled.
if ($_SESSION[APPCONFIG]->getValue('mass','enabled')) if ($_SESSION[APPCONFIG]->getValue('mass', 'enabled'))
printf('<td><input type="checkbox" id="ma_%s" name="dn[]" value="%s" onclick="this.checked=!this.checked;" /></td>',$j,$dndetails['dn']); printf('<td><input type="checkbox" id="ma_%s" name="dn[]" value="%s" onclick="this.checked=!this.checked;" /></td>', $j, $dndetails['dn']);
$href = sprintf('cmd=template_engine&server_id=%s&dn=%s',$server->getIndex(),$this->template->getDNEncode()); $href = sprintf('cmd=template_engine&server_id=%s&dn=%s', $server->getIndex(), $this->template->getDNEncode());
printf('<td class="icon"><a href="cmd.php?%s"><img src="%s/%s" alt="icon" /></a></td>', printf('<td class="icon"><a href="cmd.php?%s"><img src="%s/%s" alt="icon" /></a></td>',
htmlspecialchars($href), htmlspecialchars($href),
IMGDIR,get_icon($server->getIndex(),$dndetails['dn'])); IMGDIR, get_icon($server->getIndex(), $dndetails['dn']));
# We'll clone our attribute factory attributes, since we need to add the values to them for rendering. # We'll clone our attribute factory attributes, since we need to add the values to them for rendering.
foreach (explode(',',$ado) as $attr) { foreach (explode(',', $ado) as $attr) {
# If the entry is blank, we'll draw an empty box and continue. # If the entry is blank, we'll draw an empty box and continue.
if (! isset($dndetails[$attr])) { if (!isset($dndetails[$attr])) {
echo '<td>&nbsp;</td>'; echo '<td>&nbsp;</td>';
continue; continue;
} }
@ -330,10 +327,10 @@ class QueryRender extends PageRender {
# Special case for DNs # Special case for DNs
if ($attr == 'dn') { if ($attr == 'dn') {
$dn_display = strlen($dndetails['dn']) > 40 $dn_display = strlen($dndetails['dn']) > 40
? sprintf('<acronym title="%s">%s...</acronym>',htmlspecialchars($dndetails['dn']),htmlspecialchars(substr($dndetails['dn'],0,40))) ? sprintf('<acronym title="%s">%s...</acronym>', htmlspecialchars($dndetails['dn']), htmlspecialchars(substr($dndetails['dn'], 0, 40)))
: htmlspecialchars($dndetails['dn']); : htmlspecialchars($dndetails['dn']);
printf('<td><a href="cmd.php?%s">%s</a></td>',htmlspecialchars($href),$dn_display); printf('<td><a href="cmd.php?%s">%s</a></td>', htmlspecialchars($href), $dn_display);
continue; continue;
} }
@ -345,7 +342,7 @@ class QueryRender extends PageRender {
$afattrs[$attr]->initValue(array($dndetails[$attr])); $afattrs[$attr]->initValue(array($dndetails[$attr]));
echo '<td>'; echo '<td>';
$this->draw('CurrentValues',$afattrs[$attr]); $this->draw('CurrentValues', $afattrs[$attr]);
echo '</td>'; echo '</td>';
} }
@ -353,10 +350,10 @@ class QueryRender extends PageRender {
} }
# Is mass action enabled. # Is mass action enabled.
if ($_SESSION[APPCONFIG]->getValue('mass','enabled')) { if ($_SESSION[APPCONFIG]->getValue('mass', 'enabled')) {
printf('<tr class="%s">',++$j%2 ? 'odd' : 'even'); printf('<tr class="%s">', ++$j % 2 ? 'odd' : 'even');
printf('<td><input type="checkbox" name="allbox" value="1" onclick="CheckAll(1,\'massform_\',%s);" /></td>',$counter); printf('<td><input type="checkbox" name="allbox" value="1" onclick="CheckAll(1,\'massform_\',%s);" /></td>', $counter);
printf('<td colspan="%s">',2+count(explode(',',$ado))); printf('<td colspan="%s">', 2 + count(explode(',', $ado)));
foreach ($mass_actions as $display => $action) { foreach ($mass_actions as $display => $action) {
echo '<button type="submit" name="cmd" value="' . $action . '">' . $display . '</button>&nbsp;&nbsp;'; echo '<button type="submit" name="cmd" value="' . $action . '">' . $display . '</button>&nbsp;&nbsp;';
@ -370,11 +367,7 @@ class QueryRender extends PageRender {
echo '</table>'; echo '</table>';
echo '</form>'; echo '</form>';
echo "\n\n"; echo "\n\n";
}
break;
default:
printf('Have ID [%s], run this query for page [%s]',$this->template_id,$this->page);
} }
echo '</td></tr>'; echo '</td></tr>';