Esempio n. 1
0
 /**
  * name: render
  * params:
  */
 public function render($additional_values = null)
 {
     $out = "";
     $out .= "<table cellspacing=\"" . $this->cellspacing . "\" cellpadding=\"" . $this->cellpadding . "\" class=\"" . $this->cssclass . "\" id=\"" . $this->client_id() . "\">" . spchr::endl;
     if ($this->datasource !== null) {
         $types = $this->datasource->get_header()->get_types();
         $names = $this->datasource->get_header()->get_names();
         $header_items = array_values($this->datasource->get_header()->get_items());
         $out .= "<tr>" . spchr::endl;
         $header_class = $this->headercellclass;
         $base_url = $this->base_url;
         $sortby_param = $this->get_sortby_param();
         $current_sorting = $this->get_sorting();
         $current_direction = $this->get_sort_direction();
         $direction_param = $this->get_sort_direction_param();
         if (!is_null($additional_values)) {
             extract($additional_values);
         }
         foreach ($header_items as $hitem) {
             if (!$hitem->get_visible()) {
                 continue;
             }
             $sortable = $hitem->is_sortable();
             $sortname = $hitem->get_name();
             $title = $hitem->get_title();
             $direction = $current_sorting == $hitem->get_name() && $current_direction != sorting::SORT_DIR_DESC ? sorting::SORT_DIR_DESC : sorting::SORT_DIR_ASC;
             $params = $this->url_params($sortby_param, $direction_param);
             ob_start();
             eval($this->header_template);
             $result = ob_get_contents();
             $out .= spchr::tab . "<td class=\"{$header_class}\">" . spchr::endl;
             $out .= spchr::tab2 . $result . spchr::endl;
             $out .= spchr::tab . "</td>" . spchr::endl;
             ob_end_clean();
         }
         $out .= "</tr>" . spchr::endl;
         $values = $this->datasource->get_values();
         if (count($values)) {
             foreach ($values as $num => $columns) {
                 $col_id = 0;
                 $out .= "<tr>" . spchr::endl;
                 foreach ($columns as $data) {
                     if (!$this->datasource->get_header()->is_visible($names[$col_id])) {
                         $col_id++;
                         continue;
                     }
                     $out .= spchr::tab . "<td class=\"" . $this->cellclass . "\">" . spchr::endl;
                     $out .= spchr::tab2 . $header_items[$col_id]->get_formatter()->format($data, $types[$col_id], $col_id++, $columns) . spchr::endl;
                     $out .= spchr::tab . "</td>" . spchr::endl;
                 }
                 $out .= "</tr>" . spchr::endl;
             }
         } else {
             $out .= '<tr><td colspan="' . sizeof($header_items) . '">' . $this->no_data_message . '</td></tr>';
         }
     } else {
         $out .= '<tr><td>' . $this->no_data_message . '</td></tr>';
     }
     $out .= "</table>" . spchr::endl;
     return $out;
 }