37 require_once realpath(dirname(__FILE__)).
"/grouped_data_view.inc";
70 if ($this->cssClass) $attrs .=
" class='{$this->cssClass}'";
71 if ($this->groupStyles) $attrs .=
" style='{$this->groupStyles}'";
73 $cssClass = ($this->fixed || $this->parent->mode ==
'fixed') ?
"fixed" : ($this->expanded) ?
"expanded" :
"collapsed";
75 echo
"<h2 id=\"{$this->parent->group_id}[{$this->key}]\" $attrs>\n";
77 echo
"{$this->title}\n";
105 $this->cssStyle =
null;
106 $this->mode =
"accordian";
107 $this->tagRowCallbacks = array();
117 function group($title, $key, $expanded =
false, $fixed =
false)
131 if (count(
$groups) == 0)
return;
132 if (!$field) $field =
$groups[0]->getPrimaryKey();
134 $this->group_id = $field;
153 $this->tagRowCallbacks[] = $handler;
166 if(!is_callable($template))
167 return $group->format($template);
169 return call_user_func($template, $group);
175 if(count($this->items) == 0)
return;
177 $script =
"<script type='text/javascript' src='/fakoli/js/grouping_list.js'></script>\n";
179 $constructor .=
"\n\t\tvar {$this->id} = new GroupingList('{$this->id}', {mode: '{$this->mode}'});";
183 $script .=
"\t<script type='text/javascript'>\n\twindow.addEvent('domready', function()\n\t{";
184 $script .= $constructor;
185 $script .=
"\n\t});\n\t</script>\n";
194 if ($this->cssClass) $attrs .=
" class='{$this->cssClass}'";
195 if ($this->styles) $attrs .=
" style='{$this->styles}'";
197 echo
"<div id='{$this->id}' class='{$this->groupedListClass}'>\n";
199 if(count($this->groups) == 0)
201 foreach(array_keys($this->items) as $group)
203 $this->
group($group, $group);
207 if(count($this->groups) == 0)
return;
209 foreach($this->groups as $group)
211 if (array_key_exists($group->key, $this->items))
213 echo
"<div id='content_{$group->key}'>\n";
217 $itemsInGroup = $this->items[$group->key];
219 echo
"<ul id=\"subheading[{$group->key}]\" class=\"{$this->groupClass}\" $attrs>\n";
221 foreach($itemsInGroup as $item)
225 if ($this->onStartRow)
227 $css = call_user_func($this->onStartRow, $item);
228 if ($css ===
false)
continue;
231 if ($css) $css =
" class='$css'";
233 $dataAttrs = array();
234 foreach($this->tagRowCallbacks as $cb)
236 $dataAttrs = call_user_func($cb, $item, $dataAttrs);
240 foreach($dataAttrs as $name => $value)
242 $rowAttrs .=
" ".$name.
"='".$value.
"'";
245 echo
"<li {$css}{$rowAttrs}>";
247 if (is_callable($this->
format))
249 echo call_user_func($this->
format, $item);
251 else echo $item->format($this->
format);
273 $out = ob_get_contents();
Represents a grouped collection of data within a table.
$fixed
Specifies whether this group should be fixed (i.e. exempt from expand/collapse toggling).
$key
The key value for this data group.
$title
The text to display in the title for this data group.
$expanded
Boolean indicating whether this group should initially be expanded.
$parent
The parent GroupedDataListView object.
Represents a grouped collection of data within a table.
draw()
Draws the data group subheading within the table.
GroupListGroup($parent, $title, $key, $expanded=false, $fixed=false)
group($title, $key, $expanded=false, $fixed=false)
Adds a group to the view.
$groupedListClass
The css class for the entire grouped list div.
GroupedList($items, $id="grouped_list", $format, $cssClass="article_list", $groupClass="subheading")
$groupClass
Class for the ul that links the li list.
drawListToString()
Helpful utility function - generates the list HTML in an output buffer and returns the string represe...
addFacetTaggingHandler($handler)
Adds a row tagging handler.
$groupStyles
Styles for the group headings.
format($group, $template)
Outputs the text for the groupedBy title bar using the given group dataitem object.
$groups
The group definitions.
$tagRowCallbacks
Array of callbacks for adding extra attributes to each row.
groupBy($groups, $format=null, $field="")
Add groups based on the supplied list of DataItems.
$mode
The display mode for the table: fixed, tree, or accordian.