Framework  3.9
data_view.inc
Go to the documentation of this file.
1 <?php
6 /**************************************************************
7 
8  Copyright (c) 2007-2010 Sonjara, Inc
9 
10  Permission is hereby granted, free of charge, to any person
11  obtaining a copy of this software and associated documentation
12  files (the "Software"), to deal in the Software without
13  restriction, including without limitation the rights to use,
14  copy, modify, merge, publish, distribute, sublicense, and/or sell
15  copies of the Software, and to permit persons to whom the
16  Software is furnished to do so, subject to the following
17  conditions:
18 
19  The above copyright notice and this permission notice shall be
20  included in all copies or substantial portions of the Software.
21 
22  Except as contained in this notice, the name(s) of the above
23  copyright holders shall not be used in advertising or otherwise
24  to promote the sale, use or other dealings in this Software
25  without prior written authorization.
26 
27  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
28  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
29  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
30  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
31  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
32  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
33  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
34  OTHER DEALINGS IN THE SOFTWARE.
35 
36 *****************************************************************/
37 
38 require_once realpath(dirname(__FILE__))."/data_column.inc";
39 require_once realpath(dirname(__FILE__))."/join.inc";
40 require_once realpath(dirname(__FILE__))."/excel.inc";
41 require_once realpath(dirname(__FILE__))."/facet_manager.inc";
42 
55 class DataListView implements FacetFilterable
56 {
57  var $columns;
59  var $cssClass;
60  var $id;
61  var $sortable;
62  var $pageSize;
63  var $cssStyle;
69  var $filter;
70  var $excelFile;
71  var $paginate = true;
72  var $summary;
73  var $zebra;
74 
75  // Scrolling Table parameters
76 
77  var $height;
78  var $scrollable = false;
79  var $resizable = true;
80 
81  // Javascript interaction parameters
82 
83  var $rowId = false;
84  var $rowIdFormat = null;
85  var $dragReorder = false;
86  var $reorderHandler = null;
87  var $dragColumnReorder = false;
89  var $hideExcelIcon = false;
90  var $onRowClick = null;
91  var $onRowHover = null;
92 
93  var $dragText = "";
94  // Selection and Commands
95 
96  var $selectable = false;
97  var $showSelectAll = false;
98  var $menu = null;
99  var $contextMenu = null;
100  var $commandMenuIcon = "/fakoli/images/data_view_menu.png";
101  var $toolbarCallbacks = array();
102  static $includesWritten = false;
103 
114  function DataListView($items, $id, $cssClass = "list", $sortable = true, $pageSize = 0, $filter = false)
115  {
116  $this->items = $items;
117  $this->id = $id;
118  $this->cssClass = $cssClass;
119  $this->sortable = $sortable;
120  $this->filter = $filter;
121  $this->pageSize = $pageSize;
122  $this->cssStyle = null;
123  $this->emptyMessage = "No matching items.";
124  $this->onStartRow = null;
125  $this->excelFile = null;
126  $this->summary = null;
127  $this->zebra = true;
128  $this->totalCallbacks = array();
129  $this->tagRowCallbacks = array();
130 
131  return $this;
132  }
133 
134 
135  function getID()
136  {
137  return $this->id;
138  }
139 
140  function scrollable($height = 300, $resizable = true)
141  {
142  $this->scrollable = true;
143  $this->height = $height;
144  $this->resizable = $resizable;
145  }
146 
153  function enableDragReorder($handler)
154  {
155  $this->sortable = false;
156  $this->filter = false;
157  $this->pageSize = 0;
158  $this->paginate = false;
159  $this->dragReorder = true;
160  $this->rowId = true;
161  $this->zebra = false;
162 
163  $this->reorderHandler = $handler;
164  }
165 
178  function column($title, $format, $sortable = false, $style = null, $typeHint = null, $onExport = null, $sortFormat = null)
179  {
180  $this->columns[] = new DataColumn($title, $format, $sortable, $style, $typeHint, $onExport, $sortFormat);
181  return $this;
182  }
183 
198  function exportColumn($title, $format, $sortable = false, $style = null, $typeHint = null, $onExport = null, $sortFormat = null)
199  {
200  $column = new DataColumn($title, $format, $sortable, $style, $typeHint, $onExport, $sortFormat);
201  $column->exportOnly = true;
202  $this->columns[] = $column;
203  return $this;
204  }
205 
210  function setColumnOrder($order)
211  {
212  $columnsByTitle = reindexList($this->columns, "title");
213  $columns = array();
214  foreach($order as $title)
215  {
216  if (array_key_exists($title, $columnsByTitle))
217  {
218  $columns[] = $columnsByTitle[$title];
219  }
220  }
221 
222  $this->columns = $columns;
223  }
224 
230  function selector($format = "")
231  {
232  if (!$format && count($this->items))
233  {
234  $pk = $this->items[0]->primary_key;
235  $format = "<input type='checkbox' class='checkbox' name='{$pk}[]' id='{$pk}_{{$pk}}' value='{{$pk}}'/>";
236  }
237 
238  if($format == "radio" && count($this->items) ){
239  $pk = $this->items[0]->primary_key;
240  $format = "<input type='radio' class='radio' name='{$pk}[]' id='{$pk}_{{$pk}}' value='{{$pk}}'/>";
241  }
242 
243  $this->column("&nbsp;", $format, false, "text-align: center");
244  $this->selectable = true;
245  return $this;
246  }
247 
248  function formatRowId($item)
249  {
250  if ($this->rowIdFormat)
251  {
252  return $item->format($this->rowIdFormat);
253  }
254 
255  $pk = $item->getPrimaryKey();
256  return "{$pk}_" . $item->$pk;
257  }
258 
266  function commandMenu()
267  {
268  if ($this->menu) return $this->menu;
269 
270  $this->menu = new ContextMenu($this->id . "_menu", "#{$this->id}_menu_button");
271  $this->menu->trigger = "click";
272  $this->menu->position = "element";
273 
274  if ($this->showSelectAll)
275  {
276  $this->menu->command("toggle_select_all", "Select All", "new DOMEvent(event).stop(); SortingTable.toggleSelect(this, '{$this->id}');", false);
277  }
278  return $this->menu;
279  }
280 
287  function contextMenu()
288  {
289  if ($this->contextMenu) return $this->contextMenu;
290 
291  $this->contextMenu = new ContextMenu($this->id . "_context_menu", "#{$this->id}");
292  $this->contextMenu->trigger = "contextmenu";
293  $this->contextMenu->position = "pointer";
294 
295  if ($this->showSelectAll)
296  {
297  $this->contextMenu->command("toggle_select_all", "Select All", "new DOMEvent(event).stop(); SortingTable.toggleSelect(this, '{$this->id}');", false);
298  }
299  return $this->contextMenu;
300  }
301 
308  function addToolbarCallback($callback)
309  {
310  $this->toolbarCallbacks[] = $callback;
311  }
312 
320  function footerText($text = "", $style = "", $colspan = 1)
321  {
322  $this->footerColumns[] = new FooterTextColumn($text, $style, $colspan);
323  return $this;
324  }
325 
333  function footerValue($callback, $style = "", $colspan = 1)
334  {
335  $this->footerColumns[] = new FooterValueColumn($callback, $style, $colspan);
336  return $this;
337  }
338 
347  function footerTotal($field, $style = "text-align: right", $colspan = 1, $typeHint = Number)
348  {
349  $column = new FooterTotalColumn($field, $template = "", $style, $colspan, $typeHint);
350  $this->footerColumns[] = $column;
351  $this->totalCallbacks[] = array($column, onStartRow);
352 
353  return $this;
354  }
355 
360  function setID($id = null)
361  {
362  if ($this->id) return;
363  if ($id)
364  {
365  $this->id = $id;
366  return;
367  }
368 
369  $this->id = makeRandomString(6);
370  }
371 
376  function addFacetTaggingHandler($handler)
377  {
378  $this->tagRowCallbacks[] = $handler;
379  }
380 
384  function getExcelLink()
385  {
386  $qs = appendToQueryString(getFullQueryString(), "__excel={$this->id}");
387  return baseURI().$qs;
388  }
389 
395  function autoPopulate($item)
396  {
397  if (count($this->columns) > 0) return;
398 
399  $fields = $item->getFieldArray();
400  foreach($fields as $field)
401  {
402  if ($item->primary_key == $field) continue;
403 
404  $this->column($item->prettifyFieldName($field), "{".$field."}", $true);
405  }
406  }
407 
412  function writeScript()
413  {
414  $this->setID(); // Set to a default ID if none was specified.
415 
416  if ($_REQUEST["__column_order"])
417  {
418  $this->setColumnOrder(explode("|", $_REQUEST["__column_order"]));
419  }
420 
421  if ($this->excelFile && $_REQUEST["__excel"] == $this->id)
422  {
423  $this->writeExcelFile($this->excelFile);
424  }
425 
426  if (count($this->items) == 0) return;
427 
429  {
430  $script =
431  "\t<script type='text/javascript' src='/fakoli/js/sorting_table.js'></script>\n".
432  "\t<script type='text/javascript' src='/fakoli/js/paginating_table.js'></script>\n".
433  "\t<script type='text/javascript' src='/fakoli/js/filtering_table.js'></script>\n".
434  "\t<script type='text/javascript' src='/fakoli/js/scrolling_table.js'></script>\n";
435 
437  }
438 
439  $constructor = "";
440  if (!$this->sortable && $this->pageSize <= 0 && !$this->filter && !$this->dragReorder)
441  {
442  return "";
443  }
444 
445  $zebra = $this->zebra ? "true" : "false";
446 
447  if ($this->pageSize > 0 AND $this->paginate)
448  {
449  $constructor = "\n\t\tvar {$this->id}_paginator = new PaginatingTable('{$this->id}', '{$this->id}_paginator', {per_page: {$this->pageSize}, zebra: $zebra});";
450  }
451  else
452  {
453  $constructor = "\n\t\tvar {$this->id}_paginator = false;";
454  }
455 
456  if ($this->filter !== false)
457  {
458  $constructor .= "\n\t\tvar {$this->id}_filter = new FilteringTable('{$this->id}', '{$this->id}_filter', {column: {$this->filter}, paginator: {$this->id}_paginator});";
459  }
460  else
461  {
462  $constructor .= "\n\t\tvar {$this->id}_filter = false;";
463  }
464 
465  if ($this->sortable)
466  {
467  $constructor .= "\n\t\tvar {$this->id}_sort = new SortingTable('{$this->id}', { paginator: {$this->id}_paginator, filter: {$this->id}_filter, zebra: $zebra});";
468  }
469 
470  if ($this->selectable)
471  {
472  $constructor .= "\n\t\tdocument.id('{$this->id}').getSelectedValues = function() { var values = []; this.getElements(\"input[type='checkbox']\").each(function(e) { if (e.checked) values.push(e.value); }); return values; };";
473  }
474 
475  if ($this->scrollable)
476  {
477  $constructor .= "\n\t\tnew ScrollingTable('{$this->id}');";
478  }
479 
480  if ($constructor || $this->dragReorder || $this->dragColumnReorder)
481  {
482  $script .= "\t<script type='text/javascript'>\n\twindow.addEvent('domready', function()\n{";
483  $script .= $constructor;
484 
485  if ($this->dragReorder)
486  {
487  $script .= "\n\t\tnew DraggableTable('#{$this->id} tbody', '{$this->reorderHandler}', '{$this->items[0]->primary_key}');";
488  }
489 
490  if ($this->dragColumnReorder)
491  {
492  $options = ($this->columnReorderCallback) ? ", {onColumnsReordered: $this->columnReorderCallback}" : "";
493  $script .= "\n\tnew DraggableColumnTable('{$this->id}'$options);";
494  }
495 
496  $script .= "\n\t});\n\t</script>\n";
497  }
498 
499 
500  if ($this->menu) $script .= $this->menu->writeScript();
501  if ($this->contextMenu) $script .= $this->contextMenu->writeScript();
502 
503  return $script;
504  }
505 
509  function drawView()
510  {
511  trace("Number of Items: ".count($this->items), 3);
512 
513  if (count($this->items) > 0)
514  {
515  if (!count($this->columns)) $this->autoPopulate($this->items[0]); // Autopopulate the column list from the first object, if not specified
516  $attrs = "";
517  if ($this->id)
518  {
519  $attrs .= " id='{$this->id}'";
520  }
521 
522  if ($this->cssClass)
523  {
524  $attrs .= " class='{$this->cssClass}";
525  if ($this->sortable) $attrs .=" sortable";
526  if ($this->scrollable) $attrs.= " scroll";
527  if ($this->dragReorder) $attrs .= " reorder";
528  $attrs .= "'";
529  }
530 
531  if ($this->cssStyle)
532  {
533  $attrs .= " style='{$this->cssStyle}'";
534  }
535 
536  if ($this->summary)
537  {
538  $attrs .= " summary='".htmlSafe($this->summary)."'";
539  }
540 
541  /*
542  * JDG 6/15/2010 - if the cssStyle has a width setting, either px or
543  * &, apply that width style to the filter and paginator to avoid
544  * formatting problems.
545  */
546  $width = 'width: 100%';
547  if (preg_match("/^\\width:.*?\\d{1,5}px|width:.*?\\d{1,3}%/", $this->cssStyle, $matches))
548  $width = $matches[0];
549 
550 ?>
551  <div style="<?echo $width ?>">
552  <?php
553  if($this->pageSize)
554  {
555  ?>
556  <div style="float: right;" class="paginator"><ul id="<?echo $this->id?>_paginator"></ul></div>
557  <?php
558  }
559 
560  if($this->filter)
561  {
562  ?>
563  <div style="float: left" class="filter" id="<?echo $this->id?>_filter"></div>
564  <?php
565  }
566 
567  if ($this->dragReorder)
568  {
569  echo $this->dragText;
570  }
571  ?>
572  </div>
573 
574  <?php
575  if ($this->scrollable)
576  {
577  $tbodyAttrs = " style='height: ".($this->height - 24)."px'";
578  echo "<div class='scrollContainer' style='height: {$this->height}px'>";
579  }
580  ?>
581  <table border="0" cellpadding="0" cellspacing="0"<?echo $attrs?>>
582  <thead>
583  <tr>
584 <?php
585  $first = true;
586 
587  foreach($this->columns as $column)
588  {
589  if ($column->exportOnly) continue;
590 
591  $attrs = "";
592  $cssClass = "";
593 
594  if (!$column->sortable)
595  {
596  $cssClass = trim($cssClass." nosort");
597  }
598 
599  if ($cssClass)
600  {
601  $attrs .= " class='$cssClass'";
602  }
603 
604  if (preg_match("/^\\width:.*?\\d{1,3}px|width:.*?\\d{1,3}%/", $column->style, $matches))
605  {
606  $attrs .= " style='{$matches[0]}'";
607  }
608 
609  if ($column->sortFormat) $attrs .= " data-sort='true'";
610 ?>
611  <th<?echo $attrs?>>
612 <?php
613 
614  if ($first)
615  {
616  if ($this->excelFile)
617  {
618  $qs = $this->getExcelLink();
619  }
620 
621  if ($this->excelFile && !$this->menu && !$this->hideExcelIcon)
622  {
623 ?>
624  <a href='<?echo $qs?>' style="float: left"><img src="/fakoli/images/msexcel_icon_small.png" alt="Excel" style="border: none; display:inline-block;vertical-align: middle"/></a>
625 <?
626  }
627  else if ($this->menu)
628  {
629  if ($this->excelFile)
630  {
631  $this->menu->command($this->id."_excel", "Save as Excel...", $qs, true, "/fakoli/images/msexcel_icon_small.png");
632  }
633 ?>
634  <img id="<?echo $this->id?>_menu_button" src="<?echo $this->commandMenuIcon?>" alt="Table Menu" style="border: none; display:inline-block;vertical-align: middle"/>
635 <?
636  }
637 
638  if ($this->contextMenu && $this->excelFile)
639  {
640  $this->menu->command($this->id."_context_excel", "Save as Excel...", $qs, true, "/fakoli/images/msexcel_icon_small.png");
641  }
642 
643  foreach($this->toolbarCallbacks as $callback)
644  {
645  echo "<div style='display: inline-block; float: left'>";
646  echo call_user_func($callback, $this);
647  echo "</div>";
648  }
649  }
650  $first = false;
651 ?>
652 <?echo $column->title?></th>
653 <?
654  }
655 ?>
656  </tr>
657  </thead>
658  <tbody<?echo $tbodyAttrs?>>
659 <?
660  foreach($this->items as $item)
661  {
662  $cl = array();
663  if($this->rowId)
664  $rowId = $this->formatRowId($item);
665 
666  if ($this->onStartRow)
667  {
668  $retval = call_user_func($this->onStartRow, $item);
669  if ($retval === false) continue; // return false to indicate row should be skipped
670  if ($retval) $cl[] = $retval; // return a string to indicate a css class for the row
671  }
672 
673  $dataAttrs = array();
674  foreach($this->tagRowCallbacks as $cb)
675  {
676  $dataAttrs = call_user_func($cb, $item, $dataAttrs);
677  }
678 
679  $rowAttrs = "";
680  foreach($dataAttrs as $name => $value)
681  {
682  $rowAttrs .= " ".$name."='".$value."'";
683  }
684 
685  foreach($this->totalCallbacks as $cb)
686  {
687  call_user_func($cb, $item);
688  }
689 
690  $onclick = "";
691 
692  if ($this->onRowClick)
693  {
694  $onclick = " onclick=\"" . $item->format($this->onRowClick) . "\" onmouseover=\"this.addClass('hover');";
695  if ($this->onRowHover) $onlick .= $item->format($this->onRowHover);
696  $onclick .=" return false;\" onmouseout=\"this.removeClass('hover'); return false;\"";
697  $cl[] = "clickable";
698  }
699 
700  $cl = implode(" ", $cl);
701  if ($cl) $cl = "class='$cl'";
702  if ($rowId) $rowId = "id='$rowId' ";
703 ?>
704  <tr <?echo $rowId?><?php echo $cl?><?echo $onclick?><?echo $rowAttrs?>>
705 <?php
706  foreach($this->columns as $column)
707  {
708  if ($column->exportOnly) continue;
709 
710  $attrs = "";
711  $cssClass = "";
712 
713  if (preg_match("/^[\\w_]*$/", $column->style))
714  {
715  $cssClass = $column->style;
716  }
717  else
718  {
719  $attrs .= " style='{$column->style}'";
720  }
721 
722  if ($cssClass)
723  {
724  $attrs .= " class='$cssClass'";
725  }
726 
727  if ($column->sortFormat) $attrs .= " data-sort='".htmlentities($item->format($column->sortFormat))."'";
728 ?>
729  <td<?echo $attrs?>><?echo $column->format($item)?></td>
730 <?php
731  }
732 ?>
733  </tr>
734 <?php
735  }
736 ?>
737  </tbody>
738 <?php
739  if ($this->onDrawFooter) call_user_func($this->onDrawFooter);
740 
741  if (count($this->footerColumns) > 0)
742  {
743 ?>
744  <tfoot>
745  <tr>
746 <?php
747  foreach($this->footerColumns as $column)
748  {
749  $attrs = "";
750  $cssClass = "";
751  if ($column->style)
752  {
753  if (preg_match("/^[\\w_]*$/", $column->style))
754  {
755  $attrs .= " class='{$column->style}'";
756  }
757  else
758  {
759  $attrs .= " style='{$column->style}'";
760  }
761  }
762 
763  if ($column->colspan > 1)
764  {
765  if (!$this->dragColumnReorder)
766  {
767  $attrs .= " colspan='{$column->colspan}'";
768  ?>
769  <td<?echo $attrs?>><?echo $column->format()?></td>
770 <?php
771  }
772  else if (preg_match("/text-align:\\s*right/i", $column->style))
773  {
774  for($i = 1; $i < $column->colspan; ++$i)
775  {
776  echo "<td>&nbsp;</td>";
777  }
778 ?>
779 <td<?echo $attrs?>><?echo $column->format()?></td>
780 <?
781  }
782  else
783  {
784 ?>
785 <td<?echo $attrs?>><?echo $column->format()?></td>
786 <?
787  for($i = 1; $i < $column->colspan; ++$i)
788  {
789  echo "<td>&nbsp;</td>";
790  }
791  }
792  }
793  else
794  {
795 ?>
796 <td<?echo $attrs?>><?echo $column->format()?></td>
797 <?
798  }
799  }
800 ?>
801  </tr>
802  </tfoot>
803 <?php
804  }
805 ?>
806  </table>
807 <?php
808  if ($this->scrollable) echo "</div>";
809 
810  if ($this->menu) echo $this->menu->writeMenu();
811  if ($this->contextMenu) echo $this->contextMenu->writeMenu();
812  }
813  else
814  {
815  echo "<p><em>{$this->emptyMessage}</em></p>";
816  }
817  }
818 
823  function drawViewToString()
824  {
825  ob_start();
826  $this->drawView();
827  $out = ob_get_contents();
828  ob_end_clean();
829  return $out;
830  }
831 
839  function writeExcelFile($file)
840  {
841  $x = ExcelFileWriter::create($file);
842 
843  $c = 0;
844  foreach($this->columns as $column)
845  {
846  $x->writeHeading(0, $c, stripHTMLTags(stripHTML($column->title)));
847  ++$c;
848  }
849 
850  $r = 1;
851  foreach($this->items as $item)
852  {
853  $c = 0;
854  if ($this->onStartRow)
855  {
856  $retval = call_user_func($this->onStartRow, $item);
857  if ($retval === false) continue;
858  }
859 
860  foreach($this->totalCallbacks as $cb)
861  {
862  call_user_func($cb, $item);
863  }
864 
865  foreach($this->columns as $column)
866  {
867  if (is_callable($column->onExport))
868  {
869  $val = call_user_func($column->onExport, $item, $column);
870  }
871  else if ($column->onExport)
872  {
873  $val = $item->format($column->onExport);
874  }
875  else
876  {
877  $val = $column->format($item);
878  }
879 
880  switch($column->typeHint)
881  {
882  case String:
883 
884  $x->writeText($r, $c, stripHTMLTags(stripHTML($val)));
885  break;
886 
887  case Text:
888 
889  $x->writeText($r, $c, stripHTMLTags(stripHTML($val)), true);
890  break;
891 
892  case Number:
893 
894  $x->writeNumber($r, $c, $val);
895  break;
896 
897  case Currency:
898 
899  $val = str_replace(array("$", ","), array("", ""), $val);
900  $x->writeCurrency($r, $c, $val);
901  break;
902 
903  case Percentage:
904 
905  $x->writePercentage($r, $c, $val);
906  break;
907 
908  default:
909 
910  /* JDG 5/11/10 currency export fix */
911  if (preg_match("/^[\\d\\,\\.\\$]+$/", $val))
912  {
913  $val = str_replace(array("$", ","), array("", ""), $val);
914  $x->writeNumber($r, $c, $val);
915  }
916  else
917  {
918  // No HTML required in Excel output
919  $x->writeText($r, $c, stripHTMLTags(stripHTML($val)));
920  }
921  }
922 
923  ++$c;
924  }
925  ++$r;
926  }
927 
928  $c = 0;
929 
930  if ($this->footerColumns)
931  {
932  foreach($this->footerColumns as $column)
933  {
934  $val = $column->format();
935  /* JDG 5/11/10 currency export fix */
936  if (preg_match("/^[\\d\\,\\.]+$/", $val))
937  {
938  $val = str_replace(",", "", $val);
939  $x->writeFooterNumber($r, $c, $val);
940  }
941  else
942  {
943  // No HTML required in Excel output
944  $x->writeFooter($r, $c, stripHTMLTags(stripHTML($val)));
945  }
946  $c += $column->colspan;
947  }
948  }
949 
950  $x->send();
951 
952  session_write_close();
953  exit();
954  }
955 }
Represents a column in a DataListView output table.
Definition: data_column.inc:39
DataListView displays a list of DataItems (or InnerJoinResults) in tabular format.
Definition: data_view.inc:56
static create($filename)
Definition: excel.inc:48
selector($format="")
Adds a selector column to the DataListView.
Definition: data_view.inc:230
$tagRowCallbacks
Array of callbacks for adding extra attributes to each row.
Definition: data_view.inc:67
$totalCallbacks
Array of callbacks for totalling columns.
Definition: data_view.inc:68
commandMenu()
Adds a command menu to the table that can contain a list of operations that can be performed on subse...
Definition: data_view.inc:266
static $includesWritten
Definition: data_view.inc:102
$columnReorderCallback
Javascript callback function that is triggered when columns are reordered.
Definition: data_view.inc:88
$id
ID of the table in the output script.
Definition: data_view.inc:60
setColumnOrder($order)
Override the column order.
Definition: data_view.inc:210
$zebra
Specifies whether alternate rows in the table should be striped.
Definition: data_view.inc:73
$onRowClick
Javascript callback function that is triggered with a row is clicked.
Definition: data_view.inc:90
$pageSize
Specifies the number of items per page - set to zero for unpaginated.
Definition: data_view.inc:62
$cssStyle
Optional additional inline styles to apply to the table.
Definition: data_view.inc:63
addToolbarCallback($callback)
Registers a toolbar callback.
Definition: data_view.inc:308
footerText($text="", $style="", $colspan=1)
Adds a text column to the table footer.
Definition: data_view.inc:320
$rowId
whether to include an id tag for each tr row
Definition: data_view.inc:83
formatRowId($item)
Definition: data_view.inc:248
$cssClass
Optional CSS class to apply to the table.
Definition: data_view.inc:59
addFacetTaggingHandler($handler)
Adds a row tagging handler.
Definition: data_view.inc:376
footerValue($callback, $style="", $colspan=1)
Adds a value column to the table footer.
Definition: data_view.inc:333
$reorderHandler
Handler script that implements reordering records.
Definition: data_view.inc:86
$sortable
Specifies whether to enable client-side sorting for this table.
Definition: data_view.inc:61
$onRowHover
Javascript callback function that is triggered with a row is hovered over.
Definition: data_view.inc:91
writeExcelFile($file)
Writes the data table out as an Excel File.
Definition: data_view.inc:839
$dragColumnReorder
Enable drag & drop column reordering and show/hide capabilities.
Definition: data_view.inc:87
$contextMenu
Right-click context menu for selection based operations.
Definition: data_view.inc:99
exportColumn($title, $format, $sortable=false, $style=null, $typeHint=null, $onExport=null, $sortFormat=null)
Adds a column definition to the DataListView that is only output when exporting the table to Excel.
Definition: data_view.inc:198
$paginate
Specifies whether table should be paginated (false for view only pages)
Definition: data_view.inc:71
writeScript()
Write the Javascript to implement the table output.
Definition: data_view.inc:412
drawViewToString()
Render the table view and return the generated HTML as a string.
Definition: data_view.inc:823
enableDragReorder($handler)
Turns on drag & drop item reordering for the table.
Definition: data_view.inc:153
contextMenu()
Adds a right-click context menu to the table that can contain a list of operations that can be perfor...
Definition: data_view.inc:287
$summary
Human-readable summary of the information contained in the table (for usability/accessiblity purposes...
Definition: data_view.inc:72
drawView()
Writes the HTML for the data table to the output buffer.
Definition: data_view.inc:509
$menu
Command menu for selection-based operations.
Definition: data_view.inc:98
$dragText
Optional text to display above reorderable table.
Definition: data_view.inc:93
autoPopulate($item)
Automatically build the table columns from the given DataItem.
Definition: data_view.inc:395
$rowIdFormat
Optionally specify a custom row ID format.
Definition: data_view.inc:84
$emptyMessage
Message to display when no items are present in the data set.
Definition: data_view.inc:64
$onDrawfooter
Callback hook that gets called after all rows have been drawn.
Definition: data_view.inc:66
$columns
The column definitions for the table.
Definition: data_view.inc:57
$toolbarCallbacks
Override this callback to add toolbar links into the first header cell.
Definition: data_view.inc:101
$dragReorder
Enabled drag & drop reordering.
Definition: data_view.inc:85
$footerColumns
The footer column definitions for the table.
Definition: data_view.inc:58
$onStartRow
Callback hook that gets called at the start of each row.
Definition: data_view.inc:65
$hideExcelIcon
Suppress the automatic Excel icon if you want an external link.
Definition: data_view.inc:89
$commandMenuIcon
Icon to use for the command menu dropdown.
Definition: data_view.inc:100
$excelFile
Filename for automatic Excel export.
Definition: data_view.inc:70
$showSelectAll
Show Select All button for selectable tables.
Definition: data_view.inc:97
setID($id=null)
Sets the client-side ID for this DataListView.
Definition: data_view.inc:360
scrollable($height=300, $resizable=true)
Definition: data_view.inc:140
$filter
Specifies whether to enable client-side filtering for this table.
Definition: data_view.inc:69
$selectable
Whether the table provides a selection mechanism.
Definition: data_view.inc:96
column($title, $format, $sortable=false, $style=null, $typeHint=null, $onExport=null, $sortFormat=null)
Adds a column definition to the DataListView.
Definition: data_view.inc:178
footerTotal($field, $style="text-align: right", $colspan=1, $typeHint=Number)
Sums the total for a column.
Definition: data_view.inc:347
getExcelLink()
Get the Excel Link.
Definition: data_view.inc:384
DataListView($items, $id, $cssClass="list", $sortable=true, $pageSize=0, $filter=false)
Creates a new DataListView object.
Definition: data_view.inc:114
stripHTMLTags($text)
Removes all HTML tags from the specified string.
Definition: functions.inc:1491
trace($msg, $lvl=3, $callStack=null)
Send output to the trace log.
Definition: functions.inc:1010
stripHTML($text)
Definition: functions.inc:847
baseURI($uri=null)
Returns the base URI for the current script, with the query string removed.
Definition: functions.inc:1582
getFullQueryString($includePOST=true)
Generates a query string containing the values passed to this page.
Definition: functions.inc:1634
appendToQueryString($qs, $params)
Appends the specified parameters to the supplied query string.
Definition: functions.inc:1594
makeRandomString($len)
Creates a randomized string of characters.
Definition: functions.inc:1735
reindexList($list, $field, $autoPromote=true)
Reindex an indexed or grouped query result by a different field.
Definition: data_item.inc:1898