timeline: if a section is set to hidden and the user is not capable of editing a...
[moodle-blog-course-format.git] / lib / tablelib.php
blob9c7477483d31db386089333f11a37cd21b0c981e
1 <?php // $Id$
3 define('TABLE_VAR_SORT', 1);
4 define('TABLE_VAR_HIDE', 2);
5 define('TABLE_VAR_SHOW', 3);
6 define('TABLE_VAR_IFIRST', 4);
7 define('TABLE_VAR_ILAST', 5);
8 define('TABLE_VAR_PAGE', 6);
10 class flexible_table {
12 var $uniqueid = NULL;
13 var $attributes = array();
14 var $headers = array();
15 var $columns = array();
16 var $column_style = array();
17 var $column_class = array();
18 var $column_suppress = array();
19 var $column_nosort = array('userpic');
20 var $setup = false;
21 var $sess = NULL;
22 var $baseurl = NULL;
23 var $request = array();
25 var $is_collapsible = false;
26 var $is_sortable = false;
27 var $use_pages = false;
28 var $use_initials = false;
30 var $maxsortkeys = 2;
31 var $pagesize = 30;
32 var $currpage = 0;
33 var $totalrows = 0;
34 var $sort_default_column = NULL;
35 var $sort_default_order = SORT_ASC;
37 /**
38 * Constructor
39 * @param int $uniqueid
40 * @todo Document properly
42 function flexible_table($uniqueid) {
43 $this->uniqueid = $uniqueid;
44 $this->request = array(
45 TABLE_VAR_SORT => 'tsort',
46 TABLE_VAR_HIDE => 'thide',
47 TABLE_VAR_SHOW => 'tshow',
48 TABLE_VAR_IFIRST => 'tifirst',
49 TABLE_VAR_ILAST => 'tilast',
50 TABLE_VAR_PAGE => 'page'
54 /**
55 * Sets the is_sortable variable to the given boolean, sort_default_column to
56 * the given string, and the sort_default_order to the given integer.
57 * @param bool $bool
58 * @param string $defaultcolumn
59 * @param int $defaultorder
60 * @return void
62 function sortable($bool, $defaultcolumn = NULL, $defaultorder = SORT_ASC) {
63 $this->is_sortable = $bool;
64 $this->sort_default_column = $defaultcolumn;
65 $this->sort_default_order = $defaultorder;
68 /**
69 * Do not sort using this column
70 * @param string column name
72 function no_sorting($column) {
73 $this->column_nosort[] = $column;
76 /**
77 * Is the column sortable?
78 * @param string column name, null means table
79 * @return bool
81 function is_sortable($column=null) {
82 if (empty($column)) {
83 return $this->is_sortable;
85 if (!$this->is_sortable) {
86 return false;
88 return !in_array($column, $this->column_nosort);
91 /**
92 * Sets the is_collapsible variable to the given boolean.
93 * @param bool $bool
94 * @return void
96 function collapsible($bool) {
97 $this->is_collapsible = $bool;
101 * Sets the use_pages variable to the given boolean.
102 * @param bool $bool
103 * @return void
105 function pageable($bool) {
106 $this->use_pages = $bool;
110 * Sets the use_initials variable to the given boolean.
111 * @param bool $bool
112 * @return void
114 function initialbars($bool) {
115 $this->use_initials = $bool;
119 * Sets the pagesize variable to the given integer, the totalrows variable
120 * to the given integer, and the use_pages variable to true.
121 * @param int $perpage
122 * @param int $total
123 * @return void
125 function pagesize($perpage, $total) {
126 $this->pagesize = $perpage;
127 $this->totalrows = $total;
128 $this->use_pages = true;
132 * Assigns each given variable in the array to the corresponding index
133 * in the request class variable.
134 * @param array $variables
135 * @return void
137 function set_control_variables($variables) {
138 foreach($variables as $what => $variable) {
139 if(isset($this->request[$what])) {
140 $this->request[$what] = $variable;
146 * Gives the given $value to the $attribute index of $this->attributes.
147 * @param string $attribute
148 * @param mixed $value
149 * @return void
151 function set_attribute($attribute, $value) {
152 $this->attributes[$attribute] = $value;
156 * I think that what this method does is set the column so that if the same data appears in
157 * consecutive rows, then it is not repeated.
159 * For example, in the quiz overview report, the fullname column is set to be suppressed, so
160 * that when one student has made multiple attempts, their name is only printed in the row
161 * for their first attempt.
162 * @param integer $column the index of a column.
164 function column_suppress($column) {
165 if(isset($this->column_suppress[$column])) {
166 $this->column_suppress[$column] = true;
171 * Sets the given $column index to the given $classname in $this->column_class.
172 * @param integer $column
173 * @param string $classname
174 * @return void
176 function column_class($column, $classname) {
177 if(isset($this->column_class[$column])) {
178 $this->column_class[$column] = ' '.$classname; // This space needed so that classnames don't run together in the HTML
183 * Sets the given $column index and $property index to the given $value in $this->column_style.
184 * @param integer $column
185 * @param string $property
186 * @param mixed $value
187 * @return void
189 function column_style($column, $property, $value) {
190 if(isset($this->column_style[$column])) {
191 $this->column_style[$column][$property] = $value;
196 * Sets all columns of the given $property to the given $value in $this->column_style.
197 * @param integer $property
198 * @param string $value
199 * @return void
201 function column_style_all($property, $value) {
202 foreach(array_keys($this->columns) as $column) {
203 $this->column_style[$column][$property] = $value;
208 * Sets $this->reseturl to the given $url, and $this->baseurl to the given $url plus ? or &amp;
209 * @param type? $url
210 * @return type?
212 function define_baseurl($url) {
213 $this->reseturl = $url;
214 if(!strpos($url, '?')) {
215 $this->baseurl = $url.'?';
217 else {
218 $this->baseurl = $url.'&amp;';
223 * @todo Document
224 * @return type?
226 function define_columns($columns) {
227 $this->columns = array();
228 $this->column_style = array();
229 $this->column_class = array();
230 $colnum = 0;
232 foreach($columns as $column) {
233 $this->columns[$column] = $colnum++;
234 $this->column_style[$column] = array();
235 $this->column_class[$column] = '';
236 $this->column_suppress[$column] = false;
241 * @todo Document
242 * @return type?
244 function define_headers($headers) {
245 $this->headers = $headers;
249 * @todo Document
250 * @return type?
252 function make_styles_string(&$styles) {
253 if(empty($styles)) {
254 return '';
257 $string = ' style="';
258 foreach($styles as $property => $value) {
259 $string .= $property.':'.$value.';';
261 $string .= '"';
262 return $string;
266 * @todo Document
267 * @return type?
269 function make_attributes_string(&$attributes) {
270 if(empty($attributes)) {
271 return '';
274 $string = ' ';
275 foreach($attributes as $attr => $value) {
276 $string .= ($attr.'="'.$value.'" ');
279 return $string;
283 * @todo Document
284 * @return type?
286 function setup() {
287 global $SESSION, $CFG;
289 if(empty($this->columns) || empty($this->uniqueid)) {
290 return false;
293 if (!isset($SESSION->flextable)) {
294 $SESSION->flextable = array();
297 if(!isset($SESSION->flextable[$this->uniqueid])) {
298 $SESSION->flextable[$this->uniqueid] = new stdClass;
299 $SESSION->flextable[$this->uniqueid]->uniqueid = $this->uniqueid;
300 $SESSION->flextable[$this->uniqueid]->collapse = array();
301 $SESSION->flextable[$this->uniqueid]->sortby = array();
302 $SESSION->flextable[$this->uniqueid]->i_first = '';
303 $SESSION->flextable[$this->uniqueid]->i_last = '';
306 $this->sess = &$SESSION->flextable[$this->uniqueid];
308 if(!empty($_GET[$this->request[TABLE_VAR_SHOW]]) && isset($this->columns[$_GET[$this->request[TABLE_VAR_SHOW]]])) {
309 // Show this column
310 $this->sess->collapse[$_GET[$this->request[TABLE_VAR_SHOW]]] = false;
312 else if(!empty($_GET[$this->request[TABLE_VAR_HIDE]]) && isset($this->columns[$_GET[$this->request[TABLE_VAR_HIDE]]])) {
313 // Hide this column
314 $this->sess->collapse[$_GET[$this->request[TABLE_VAR_HIDE]]] = true;
315 if(array_key_exists($_GET[$this->request[TABLE_VAR_HIDE]], $this->sess->sortby)) {
316 unset($this->sess->sortby[$_GET[$this->request[TABLE_VAR_HIDE]]]);
320 // Now, update the column attributes for collapsed columns
321 foreach(array_keys($this->columns) as $column) {
322 if(!empty($this->sess->collapse[$column])) {
323 $this->column_style[$column]['width'] = '10px';
328 !empty($_GET[$this->request[TABLE_VAR_SORT]]) && $this->is_sortable($_GET[$this->request[TABLE_VAR_SORT]]) &&
329 (isset($this->columns[$_GET[$this->request[TABLE_VAR_SORT]]]) ||
330 (($_GET[$this->request[TABLE_VAR_SORT]] == 'firstname' || $_GET[$this->request[TABLE_VAR_SORT]] == 'lastname') && isset($this->columns['fullname']))
333 if(empty($this->sess->collapse[$_GET[$this->request[TABLE_VAR_SORT]]])) {
334 if(array_key_exists($_GET[$this->request[TABLE_VAR_SORT]], $this->sess->sortby)) {
335 // This key already exists somewhere. Change its sortorder and bring it to the top.
336 $sortorder = $this->sess->sortby[$_GET[$this->request[TABLE_VAR_SORT]]] == SORT_ASC ? SORT_DESC : SORT_ASC;
337 unset($this->sess->sortby[$_GET[$this->request[TABLE_VAR_SORT]]]);
338 $this->sess->sortby = array_merge(array($_GET[$this->request[TABLE_VAR_SORT]] => $sortorder), $this->sess->sortby);
340 else {
341 // Key doesn't exist, so just add it to the beginning of the array, ascending order
342 $this->sess->sortby = array_merge(array($_GET[$this->request[TABLE_VAR_SORT]] => SORT_ASC), $this->sess->sortby);
344 // Finally, make sure that no more than $this->maxsortkeys are present into the array
345 if(!empty($this->maxsortkeys) && ($sortkeys = count($this->sess->sortby)) > $this->maxsortkeys) {
346 while($sortkeys-- > $this->maxsortkeys) {
347 array_pop($this->sess->sortby);
353 // If we didn't sort just now, then use the default sort order if one is defined and the column exists
354 if(empty($this->sess->sortby) && !empty($this->sort_default_column) && (isset($this->columns[$this->sort_default_column])
355 || (in_array('fullname',$this->columns)
356 && in_array($this->sort_default_column,
357 array('firstname','lastname'))))) {
358 $this->sess->sortby = array ($this->sort_default_column => ($this->sort_default_order == SORT_DESC ? SORT_DESC : SORT_ASC));
361 if(isset($_GET[$this->request[TABLE_VAR_ILAST]])) {
362 if(empty($_GET[$this->request[TABLE_VAR_ILAST]]) || is_numeric(strpos(get_string('alphabet'), $_GET[$this->request[TABLE_VAR_ILAST]]))) {
363 $this->sess->i_last = $_GET[$this->request[TABLE_VAR_ILAST]];
367 if(isset($_GET[$this->request[TABLE_VAR_IFIRST]])) {
368 if(empty($_GET[$this->request[TABLE_VAR_IFIRST]]) || is_numeric(strpos(get_string('alphabet'), $_GET[$this->request[TABLE_VAR_IFIRST]]))) {
369 $this->sess->i_first = $_GET[$this->request[TABLE_VAR_IFIRST]];
373 if(empty($this->baseurl)) {
374 $getcopy = $_GET;
375 unset($getcopy[$this->request[TABLE_VAR_SHOW]]);
376 unset($getcopy[$this->request[TABLE_VAR_HIDE]]);
377 unset($getcopy[$this->request[TABLE_VAR_SORT]]);
378 unset($getcopy[$this->request[TABLE_VAR_IFIRST]]);
379 unset($getcopy[$this->request[TABLE_VAR_ILAST]]);
380 unset($getcopy[$this->request[TABLE_VAR_PAGE]]);
382 $strippedurl = strip_querystring(qualified_me());
384 if(!empty($getcopy)) {
385 $first = false;
386 $querystring = '';
387 foreach($getcopy as $var => $val) {
388 if(!$first) {
389 $first = true;
390 $querystring .= '?'.$var.'='.$val;
392 else {
393 $querystring .= '&amp;'.$var.'='.$val;
396 $this->reseturl = $strippedurl.$querystring;
397 $querystring .= '&amp;';
399 else {
400 $this->reseturl = $strippedurl;
401 $querystring = '?';
404 $this->baseurl = strip_querystring(qualified_me()) . $querystring;
407 // If it's "the first time" we 've been here, forget the previous initials filters
408 if(qualified_me() == $this->reseturl) {
409 $this->sess->i_first = '';
410 $this->sess->i_last = '';
413 $this->currpage = optional_param($this->request[TABLE_VAR_PAGE], 0);
414 $this->setup = true;
416 /// Always introduce the "flexible" class for the table if not specified
417 /// No attributes, add flexible class
418 if (empty($this->attributes)) {
419 $this->attributes['class'] = 'flexible';
420 /// No classes, add flexible class
421 } else if (!isset($this->attributes['class'])) {
422 $this->attributes['class'] = 'flexible';
423 /// No flexible class in passed classes, add flexible class
424 } else if (!in_array('flexible', explode(' ', $this->attributes['class']))) {
425 $this->attributes['class'] = trim('flexible ' . $this->attributes['class']);
431 * @todo Document
432 * @return type?
434 function get_sql_sort($uniqueid = NULL) {
435 if($uniqueid === NULL) {
436 // "Non-static" function call
437 if(!$this->setup) {
438 return false;
440 $sess = &$this->sess;
442 else {
443 // "Static" function call
444 global $SESSION;
445 if(empty($SESSION->flextable[$uniqueid])) {
446 return '';
448 $sess = &$SESSION->flextable[$uniqueid];
451 if(!empty($sess->sortby)) {
452 $sortstring = '';
453 foreach($sess->sortby as $column => $order) {
454 if(!empty($sortstring)) {
455 $sortstring .= ', ';
457 $sortstring .= $column.($order == SORT_ASC ? ' ASC' : ' DESC');
459 return $sortstring;
461 return '';
465 * @todo Document
466 * @return type?
468 function get_page_start() {
469 if(!$this->use_pages) {
470 return '';
472 return $this->currpage * $this->pagesize;
476 * @todo Document
477 * @return type?
479 function get_page_size() {
480 if(!$this->use_pages) {
481 return '';
483 return $this->pagesize;
487 * @todo Document
488 * @return type?
490 function get_sql_where() {
491 if(!isset($this->columns['fullname'])) {
492 return '';
495 $LIKE = sql_ilike();
496 if(!empty($this->sess->i_first) && !empty($this->sess->i_last)) {
497 return 'firstname '.$LIKE.' \''.$this->sess->i_first.'%\' AND lastname '.$LIKE.' \''.$this->sess->i_last.'%\'';
499 else if(!empty($this->sess->i_first)) {
500 return 'firstname '.$LIKE.' \''.$this->sess->i_first.'%\'';
502 else if(!empty($this->sess->i_last)) {
503 return 'lastname '.$LIKE.' \''.$this->sess->i_last.'%\'';
506 return '';
510 * @todo Document
511 * @return type?
513 function get_initial_first() {
514 if(!$this->use_initials) {
515 return NULL;
518 return $this->sess->i_first;
522 * @todo Document
523 * @return type?
525 function get_initial_last() {
526 if(!$this->use_initials) {
527 return NULL;
530 return $this->sess->i_last;
534 * @todo Document
535 * @return type?
537 function print_html() {
538 global $CFG;
540 if(!$this->setup) {
541 return false;
544 $colcount = count($this->columns);
546 // Do we need to print initial bars?
548 if($this->use_initials && isset($this->columns['fullname'])) {
550 $strall = get_string('all');
551 $alpha = explode(',', get_string('alphabet'));
553 // Bar of first initials
555 echo '<div class="initialbar firstinitial">'.get_string('firstname').' : ';
556 if(!empty($this->sess->i_first)) {
557 echo '<a href="'.$this->baseurl.$this->request[TABLE_VAR_IFIRST].'=">'.$strall.'</a>';
558 } else {
559 echo '<strong>'.$strall.'</strong>';
561 foreach ($alpha as $letter) {
562 if (isset($this->sess->i_first) && $letter == $this->sess->i_first) {
563 echo ' <strong>'.$letter.'</strong>';
564 } else {
565 echo ' <a href="'.$this->baseurl.$this->request[TABLE_VAR_IFIRST].'='.$letter.'">'.$letter.'</a>';
568 echo '</div>';
570 // Bar of last initials
572 echo '<div class="initialbar lastinitial">'.get_string('lastname').' : ';
573 if(!empty($this->sess->i_last)) {
574 echo '<a href="'.$this->baseurl.$this->request[TABLE_VAR_ILAST].'=">'.$strall.'</a>';
575 } else {
576 echo '<strong>'.$strall.'</strong>';
578 foreach ($alpha as $letter) {
579 if (isset($this->sess->i_last) && $letter == $this->sess->i_last) {
580 echo ' <strong>'.$letter.'</strong>';
581 } else {
582 echo ' <a href="'.$this->baseurl.$this->request[TABLE_VAR_ILAST].'='.$letter.'">'.$letter.'</a>';
585 echo '</div>';
589 // End of initial bars code
591 // Paging bar
592 if($this->use_pages) {
593 print_paging_bar($this->totalrows, $this->currpage, $this->pagesize, $this->baseurl, $this->request[TABLE_VAR_PAGE]);
596 if (empty($this->data)) {
597 print_heading(get_string('nothingtodisplay'));
598 return true;
602 $suppress_enabled = array_sum($this->column_suppress);
603 $suppress_lastrow = NULL;
604 // Start of main data table
606 echo '<table'.$this->make_attributes_string($this->attributes).'>';
608 echo '<tr>';
609 foreach($this->columns as $column => $index) {
610 $icon_hide = '';
611 $icon_sort = '';
613 if($this->is_collapsible) {
614 if(!empty($this->sess->collapse[$column])) {
615 // some headers contain < br/> tags, do not include in title
616 $icon_hide = ' <a href="'.$this->baseurl.$this->request[TABLE_VAR_SHOW].'='.$column.'"><img src="'.$CFG->pixpath.'/t/switch_plus.gif" title="'.get_string('show').' '.strip_tags($this->headers[$index]).'" alt="'.get_string('show').'" /></a>';
618 else if($this->headers[$index] !== NULL) {
619 // some headers contain < br/> tags, do not include in title
620 $icon_hide = ' <a href="'.$this->baseurl.$this->request[TABLE_VAR_HIDE].'='.$column.'"><img src="'.$CFG->pixpath.'/t/switch_minus.gif" title="'.get_string('hide').' '.strip_tags($this->headers[$index]).'" alt="'.get_string('hide').'" /></a>';
624 $primary_sort_column = '';
625 $primary_sort_order = '';
626 if(reset($this->sess->sortby)) {
627 $primary_sort_column = key($this->sess->sortby);
628 $primary_sort_order = current($this->sess->sortby);
631 switch($column) {
633 case 'fullname':
634 if($this->is_sortable($column)) {
635 $icon_sort_first = $icon_sort_last = '';
636 if($primary_sort_column == 'firstname') {
637 $lsortorder = get_string('asc');
638 if($primary_sort_order == SORT_ASC) {
639 $icon_sort_first = ' <img src="'.$CFG->pixpath.'/t/down.gif" alt="'.get_string('asc').'" />';
640 $fsortorder = get_string('asc');
642 else {
643 $icon_sort_first = ' <img src="'.$CFG->pixpath.'/t/up.gif" alt="'.get_string('desc').'" />';
644 $fsortorder = get_string('desc');
647 else if($primary_sort_column == 'lastname') {
648 $fsortorder = get_string('asc');
649 if($primary_sort_order == SORT_ASC) {
650 $icon_sort_last = ' <img src="'.$CFG->pixpath.'/t/down.gif" alt="'.get_string('asc').'" />';
651 $lsortorder = get_string('asc');
653 else {
654 $icon_sort_last = ' <img src="'.$CFG->pixpath.'/t/up.gif" alt="'.get_string('desc').'" />';
655 $lsortorder = get_string('desc');
657 } else {
658 $fsortorder = get_string('asc');
659 $lsortorder = get_string('asc');
661 $this->headers[$index] = '<a href="'.$this->baseurl.$this->request[TABLE_VAR_SORT].'=firstname">'.get_string('firstname').get_accesshide(get_string('sortby').' '.get_string('firstname').' '.$fsortorder).'</a> '.$icon_sort_first.' / '.
662 '<a href="'.$this->baseurl.$this->request[TABLE_VAR_SORT].'=lastname">'.get_string('lastname').get_accesshide(get_string('sortby').' '.get_string('lastname').' '.$lsortorder).'</a> '.$icon_sort_last;
664 break;
666 case 'userpic':
667 // do nothing, do not display sortable links
668 break;
670 default:
671 if($this->is_sortable($column)) {
672 if($primary_sort_column == $column) {
673 if($primary_sort_order == SORT_ASC) {
674 $icon_sort = ' <img src="'.$CFG->pixpath.'/t/down.gif" alt="'.get_string('asc').'" />';
675 $localsortorder = get_string('asc');
677 else {
678 $icon_sort = ' <img src="'.$CFG->pixpath.'/t/up.gif" alt="'.get_string('desc').'" />';
679 $localsortorder = get_string('desc');
681 } else {
682 $localsortorder = get_string('asc');
684 $this->headers[$index] = '<a href="'.$this->baseurl.$this->request[TABLE_VAR_SORT].'='.$column.'">'.$this->headers[$index].get_accesshide(get_string('sortby').' '.$this->headers[$index].' '.$localsortorder).'</a>';
688 if($this->headers[$index] === NULL) {
689 echo '<th class="header c'.$index.$this->column_class[$column].'" scope="col">&nbsp;</th>';
691 else if(!empty($this->sess->collapse[$column])) {
692 echo '<th class="header c'.$index.$this->column_class[$column].'" scope="col">'.$icon_hide.'</th>';
694 else {
695 // took out nowrap for accessibility, might need replacement
696 if (!is_array($this->column_style[$column])) {
697 // $usestyles = array('white-space:nowrap');
698 $usestyles = '';
699 } else {
700 // $usestyles = $this->column_style[$column]+array('white-space'=>'nowrap');
701 $usestyles = $this->column_style[$column];
703 echo '<th class="header c'.$index.$this->column_class[$column].'" '.$this->make_styles_string($usestyles).' scope="col">'.$this->headers[$index].$icon_sort.'<div class="commands">'.$icon_hide.'</div></th>';
707 echo '</tr>';
709 if(!empty($this->data)) {
710 $oddeven = 1;
711 $colbyindex = array_flip($this->columns);
712 foreach($this->data as $row) {
713 $oddeven = $oddeven ? 0 : 1;
714 echo '<tr class="r'.$oddeven.'">';
716 // If we have a separator, print it
717 if($row === NULL && $colcount) {
718 echo '<td colspan="'.$colcount.'"><div class="tabledivider"></div></td>';
720 else {
721 foreach($row as $index => $data) {
722 if($index >= $colcount) {
723 break;
725 $column = $colbyindex[$index];
726 echo '<td class="cell c'.$index.$this->column_class[$column].'"'.$this->make_styles_string($this->column_style[$column]).'>';
727 if(empty($this->sess->collapse[$column])) {
728 if($this->column_suppress[$column] && $suppress_lastrow !== NULL && $suppress_lastrow[$index] === $data) {
729 echo '&nbsp;';
731 else {
732 echo $data;
735 else {
736 echo '&nbsp;';
738 echo '</td>';
741 echo '</tr>';
742 if($suppress_enabled) {
743 $suppress_lastrow = $row;
748 echo '</table>';
750 // Paging bar
751 if($this->use_pages) {
752 print_paging_bar($this->totalrows, $this->currpage, $this->pagesize, $this->baseurl, $this->request[TABLE_VAR_PAGE]);
757 * @todo Document
758 * @return type?
760 function add_data($row) {
761 if(!$this->setup) {
762 return false;
764 $this->data[] = $row;
768 * @todo Document
769 * @return type?
771 function add_separator() {
772 if(!$this->setup) {
773 return false;
775 $this->data[] = NULL;
779 * Add a row of data to the table. This function takes an array with
780 * column names as keys.
781 * It ignores any elements with keys that are not defined as columns. It
782 * puts in empty strings into the row when there is no element in the passed
783 * array corresponding to a column in the table. It puts the row elements in
784 * the proper order.
785 * @param $rowwithkeys array
788 function add_data_keyed($rowwithkeys){
789 foreach (array_keys($this->columns) as $column){
790 if (isset($rowwithkeys[$column])){
791 $row [] = $rowwithkeys[$column];
792 } else {
793 $row[] ='';
796 $this->add_data($row);