Exemple #1
0
 /**
  * Return a TH element that serves as a header for a column. Can be used
  * for either sortable or non-sortable columns.
  * 
  * @param String $title the displayable title for the column.
  * @param String $column (optional) Makes this column sortable by this (db) column name.
  * @param boolean $descendByDefault if true, when clicked for the first time,
  *        this column will be sorted in descending order. (false by default). 
  */
 public function columnHeader($title, $column = null, $descendByDefault = false)
 {
     $th = new HTMLElement("th");
     // If this column is sortable
     if ($column) {
         $href = Href::current();
         $href->set(PagingInfoPrefs::getOrderByColumnParamName($this->getName()), $column);
         $newSortOrder = $this->getNewSortOrderForColumn($column, $descendByDefault);
         $className = 'sortable';
         // If this column is sorted
         if ($this->pagingInfo->getOrderByColumn() != null && $this->pagingInfo->getOrderByColumn() == $column) {
             $className = $this->pagingInfo->isOrderByAscending() ? "orderAsc" : "orderDesc";
         }
         $href->set(PagingInfoPrefs::getOrderByAscendingParamName($this->getName()), $newSortOrder);
         $th->set('class', $className);
         $th->set('onclick', "button_click('{$href}')");
     }
     $th->setBody($title);
     return $th;
 }