Whups::formatColumn PHP Method

formatColumn() public static method

Formats a ticket property for a tabular ticket listing.
public static formatColumn ( array $info, string $value ) : string
$info array A ticket information hash.
$value string The column/property to format.
return string The formatted property.
    public static function formatColumn($info, $value)
    {
        $url = self::urlFor('ticket', $info['id']);
        $thevalue = isset($info[$value]) ? $info[$value] : '';
        if ($value == 'timestamp' || $value == 'due' || substr($value, 0, 5) == 'date_') {
            require_once 'Horde/Form/Type.php';
            $thevalue = Horde_Form_Type_date::getFormattedTime($thevalue, $GLOBALS['prefs']->getValue('report_time_format'), false);
        } elseif ($value == 'user_id_requester') {
            $thevalue = $info['requester_formatted'];
        } elseif ($value == 'id' || $value == 'summary') {
            $thevalue = Horde::link($url) . '<strong>' . htmlspecialchars($thevalue) . '</strong></a>';
        } elseif ($value == 'owners') {
            if (!empty($info['owners_formatted'])) {
                $thevalue = implode(', ', $info['owners_formatted']);
            }
        }
        return $thevalue;
    }

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>';
 }