示例#1
0
 function getForm()
 {
     if ($this->empty_filter && !$this->partial_result) {
         return '';
     }
     $str = '';
     $str .= '<div style="margin-bottom: 15px;">';
     $str .= '<form action="" method="GET">';
     // Add all others args of this page to avoid to lost a non relative parameter
     $args = args2formargs($this->org_request_arg, array('search_item', 'search_fields'));
     foreach ($args as $k => $v) {
         $str .= '<input type="hidden" name="' . $k . '" value="' . $v . '"/>';
     }
     $str .= '<table><tr>';
     $str .= '<td>' . _('Search for user pattern: ') . '</td>';
     $str .= '<td><input type="text" name="search_item" value="' . $this->search_item . '" /> ';
     $str .= '<input type="submit" value="' . _('Search') . '" /> ';
     $str .= '<input type="button" value="' . _('Reset filter') . '" onclick="this.form.search_item.value=\'\'; this.form.submit();"' . ($this->empty_filter ? ' disabled="disabled"' : '') . '/>';
     $str .= '</td>';
     $str .= '</tr><tr><td></td>';
     $str .= '<td>' . _('Search in: ');
     $str .= '<input type="checkbox" name="search_fields[]" value="login"';
     if (in_array('login', $this->search_fields)) {
         $str .= ' checked="checked"';
     }
     $str .= '>' . _('Login') . ' ';
     $str .= '<input type="checkbox" name="search_fields[]" value="displayname"';
     if (in_array('displayname', $this->search_fields)) {
         $str .= ' checked="checked"';
     }
     $str .= '>' . _('Display name') . ' ';
     $str .= '</td></tr>';
     $str .= '<tr><td></td>';
     $str .= '<td>';
     if ($this->partial_result == true) {
         $str .= '<span class="error">';
         $str .= sprintf(ngettext("<strong>Partial content:</strong> Only <strong>%d result</strong> displayed but there are more. Please restrict your search field.", "<strong>Partial content:</strong> Only <strong>%d results</strong> displayed but there are more. Please restrict your search field.", count($this->result)), count($this->result));
         $str .= '</span>';
     } else {
         if (strlen($this->search_item) > 0) {
             $str .= sprintf(ngettext('<strong>%d</strong> result for "%s".', '<strong>%d</strong> results for "%s".', count($this->result)), count($this->result), $this->search_item);
         }
     }
     $str .= '</td></tr>';
     $str .= '</table>';
     $str .= '</form>';
     $str .= '</div>';
     return $str;
 }
示例#2
0
function args2formargs($args, $blacklist = array(), $prev_parrtern = '')
{
    $ret = array();
    foreach ($args as $k => $v) {
        if (in_array($k, $blacklist)) {
            continue;
        }
        if (strlen($prev_parrtern) == 0) {
            $key = $k;
        } else {
            $key = $prev_parrtern . '[' . $k . ']';
        }
        if (is_array($v)) {
            $ret2 = args2formargs($v, array(), $key);
            $ret = array_merge($ret, $ret2);
        } else {
            $ret[$key] = $v;
        }
    }
    return $ret;
}