Beispiel #1
0
 /**
  * Display list/table body.
  *
  * This includes groups and data rows.
  *
  * @access protected
  */
 function display_body()
 {
     // BODY START:
     $this->display_body_start();
     // Prepare data for grouping:
     $group_by_all = array();
     if (!empty($this->group_by)) {
         $group_by_all['row'] = is_array($this->group_by) ? $this->group_by : array($this->group_by);
     }
     if (!empty($this->group_by_obj_prop)) {
         $group_by_all['obj_prop'] = is_array($this->group_by_obj_prop) ? $this->group_by_obj_prop : array($this->group_by_obj_prop);
     }
     $this->current_group_count = array();
     // useful in parse_col_content()
     foreach ($this->rows as $row) {
         // For each row/line:
         /*
          * GROUP ROW stuff:
          */
         if (!empty($group_by_all)) {
             // We are grouping (by SQL and/or object property)...
             $group_depth = 0;
             $group_changed = false;
             foreach ($group_by_all as $type => $names) {
                 foreach ($names as $name) {
                     if ($type == 'row') {
                         $value = $row->{$name};
                     } elseif ($type == 'obj_prop') {
                         $this->current_Obj = $this->Cache->instantiate($row);
                         // useful also for parse_col_content() below
                         $value = $this->current_Obj->{$name};
                     } else {
                         debug_die('Invalid Results-group_by-type: ' . var_export($type, true));
                     }
                     if ($this->current_group_ID[$group_depth] != $value) {
                         // Group changed here:
                         $this->current_group_ID[$group_depth] = $value;
                         if (!isset($this->current_group_count[$group_depth])) {
                             $this->current_group_count[$group_depth] = 0;
                         } else {
                             $this->current_group_count[$group_depth]++;
                         }
                         // unset sub-group identifiers:
                         for ($i = $group_depth + 1, $n = count($this->current_group_ID); $i < $n; $i++) {
                             unset($this->current_group_ID[$i]);
                         }
                         $group_changed = true;
                         break 2;
                     }
                     $group_depth++;
                 }
             }
             if ($group_changed) {
                 // We have just entered a new group!
                 echo $this->params['grp_line_start'];
                 // TODO: dh> support grp_line_start_odd, grp_line_start_last, grp_line_start_odd_last - as defined in _adminUI_general.class.php
                 $col_count = 0;
                 foreach ($this->grp_cols as $grp_col) {
                     // For each column:
                     if (isset($grp_col['td_class'])) {
                         // We have a class for the total column
                         $class = $grp_col['td_class'];
                     } else {
                         // We have no class for the total column
                         $class = '';
                     }
                     if ($col_count == 0 && isset($this->params['grp_col_start_first'])) {
                         // Display first column column start:
                         $output = $this->params['grp_col_start_first'];
                         // Add the total column class in the grp col start first param class:
                         $output = str_replace('$class$', $class, $output);
                     } elseif ($col_count == count($this->grp_cols) - 1 && isset($this->params['grp_col_start_last'])) {
                         // Last column can get special formatting:
                         $output = $this->params['grp_col_start_last'];
                         // Add the total column class in the grp col start end param class:
                         $output = str_replace('$class$', $class, $output);
                     } else {
                         // Display regular column start:
                         $output = $this->params['grp_col_start'];
                         // Replace the "class_attrib" in the grp col start param by the td column class
                         $output = str_replace('$class_attrib$', 'class="' . $class . '"', $output);
                     }
                     if (isset($grp_col['td_colspan'])) {
                         $colspan = $grp_col['td_colspan'];
                         if ($colspan < 0) {
                             // We want to substract columns from the total count
                             $colspan = $this->nb_cols + $colspan;
                         } elseif ($colspan == 0) {
                             // use $nb_cols
                             $colspan = $this->nb_cols;
                         }
                         $output = str_replace('$colspan_attrib$', 'colspan="' . $colspan . '"', $output);
                     } else {
                         // remove non-HTML attrib:
                         $output = str_replace('$colspan_attrib$', '', $output);
                     }
                     // Contents to output:
                     $output .= $this->parse_col_content($grp_col['td']);
                     //echo $output;
                     eval("echo '{$output}';");
                     echo '</td>';
                     $col_count++;
                 }
                 echo $this->params['grp_line_end'];
             }
         }
         /*
          * DATA ROW stuff:
          */
         if (!empty($this->ID_col) && empty($row->{$this->ID_col})) {
             // We have detected an empty data row which we want to ignore... (happens with empty groups)
             continue;
         }
         if (!is_null($this->Cache)) {
             // We want to instantiate an object for the row and cache it:
             // We also keep a local ref in case we want to use it for display:
             $this->current_Obj =& $this->Cache->instantiate($row);
         }
         // Check for fadeout
         $fadeout_line = false;
         if (!empty($this->fadeout_array)) {
             foreach ($this->fadeout_array as $key => $crit) {
                 // echo 'fadeout '.$key.'='.$crit;
                 if (isset($row->{$key}) && in_array($row->{$key}, $crit)) {
                     // Col is in the fadeout list
                     // TODO: CLEAN THIS UP!
                     $fadeout_line = true;
                     break;
                 }
             }
         }
         // LINE START:
         $this->display_line_start($this->current_idx == count($this->rows) - 1, $fadeout_line);
         foreach ($this->cols as $col) {
             // For each column:
             // COL START:
             $this->display_col_start();
             // Contents to output:
             $output = $this->parse_col_content($col['td']);
             #pre_dump( '{'.$output.'}' );
             eval("echo '{$output}';");
             // COL START:
             $this->display_col_end();
         }
         // LINE END:
         $this->display_line_end();
         $this->next_idx();
     }
     // BODY END:
     $this->display_body_end();
 }