Whups::getSearchResultColumns PHP Method

getSearchResultColumns() public static method

The results can depend on the current user preferences, which search function was executed, and the $columns parameter.
public static getSearchResultColumns ( integer $search_type = null, array $columns = null )
$search_type integer The type of search that was executed. Currently only 'block' is supported.
$columns array The columns to return, overriding the defaults for some $search_type.
    public static function getSearchResultColumns($search_type = null, $columns = null)
    {
        $all = array(_("Id") => 'id', _("Summary") => 'summary', _("State") => 'state_name', _("Type") => 'type_name', _("Priority") => 'priority_name', _("Queue") => 'queue_name', _("Requester") => 'user_id_requester', _("Owners") => 'owners', _("Created") => 'timestamp', _("Updated") => 'date_updated', _("Assigned") => 'date_assigned', _("Due") => 'due', _("Resolved") => 'date_resolved');
        if ($search_type != 'block') {
            return $all;
        }
        if (is_null($columns)) {
            $columns = array('summary', 'priority_name', 'state_name');
        }
        $result = array(_("Id") => 'id');
        foreach ($columns as $param) {
            if (($label = array_search($param, $all)) !== false) {
                $result[$label] = $param;
            }
        }
        return $result;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Generates a table with ticket information.
  *
  * @param array $tickets  A list of tickets.
  * @param string $tableClass  The DOM ID to use for the generated table.
  *
  * @return string  Table HTML code.
  */
 protected function _table($tickets, $tableId = null)
 {
     if (!$tableId) {
         $tableId = get_class($this);
     }
     $columns = isset($this->_params['columns']) ? $this->_params['columns'] : null;
     $sortby = $GLOBALS['prefs']->getValue('sortby');
     $sortdirclass = ' class="' . ($GLOBALS['prefs']->getValue('sortdir') ? 'sortup' : 'sortdown') . '"';
     $html = '<thead><tr><th' . ($sortby == 'id' ? $sortdirclass : '') . '>' . _("Id") . '</th>';
     foreach (Whups::getSearchResultColumns('block', $this->_params['columns']) as $name => $column) {
         if ($column == 'id') {
             continue;
         }
         $html .= '<th' . ($sortby == $column ? $sortdirclass : '') . '>' . $name . '</th>';
     }
     $html .= '</tr></thead><tbody>';
     Whups::sortTickets($tickets);
     foreach ($tickets as $ticket) {
         foreach (Whups::getSearchResultColumns('block', $columns) as $column) {
             $thevalue = Whups::formatColumn($ticket, $column);
             $sortval = '';
             if ($column == 'timestamp' || $column == 'due' || substr($column, 0, 5) == 'date_') {
                 $sortval = strlen($ticket[$column]) ? ' sortval="' . $ticket[$column] . '"' : '';
             }
             $html .= '<td' . $sortval . '>' . (strlen($thevalue) ? $thevalue : '&nbsp;') . '</td>';
         }
         $html .= '</tr>';
     }
     $GLOBALS['page_output']->addScriptFile('tables.js', 'horde');
     return '<table id="' . htmlspecialchars($tableId) . '" class="horde-table sortable" style="width:100%">' . $html . '</tbody></table>';
 }
All Usage Examples Of Whups::getSearchResultColumns