2 import(
'Dataface/ResultList.php');
41 $path = explode(
'-', $rowid);
48 if ( isset($this->relationship) ){
51 $record =& $this->record->getRelatedRecord($this->relationship,
$index-1);
61 while ( !empty(
$path) ){
62 $currid = array_shift(
$path);
63 $record =& $root->getChild(intval($currid)-1);
65 $null = null;
return $null;
87 if ( $depth == 0 )
return $rows;
91 if ( !isset($root ) )
return $rows;
93 if ( empty($rowid) and isset($this->relationship) ){
95 $it = $root->getRelationshipIterator($this->relationship);
97 while ( $it->hasNext() ){
98 $curr_rowid = strval($i++);
100 $rowRecord =& $row->toRecord();
101 $rows[$curr_rowid] = array(
'record'=>& $rowRecord,
'rowid'=>$curr_rowid,
'hasChildren'=>
false);
102 $numrows = count($rows);
103 $this->
getSubrows($rows, $curr_rowid, $rowRecord, $depth-1);
104 if ( count($rows)>$numrows) $rows[$curr_rowid][
'hasChildren'] =
true;
105 unset($rowRecord);unset($row);
108 $children = $root->getChildren();
109 if ( isset($children) ){
111 foreach (array_keys($children) as $childkey){
112 $curr_rowid = $rowid.(!empty($rowid)?
'-':
'').strval($i++);
113 $rowRecord =& $children[$childkey];
114 $rows[$curr_rowid] = array(
'record'=>&$rowRecord,
'rowid'=>$curr_rowid,
'hasChildren'=>
false);
115 $numrows = count($rows);
116 $this->
getSubrows($rows, $curr_rowid, $rowRecord, $depth-1);
117 if ( count($rows)>$numrows) $rows[$curr_rowid][
'hasChildren'] =
true;
133 if ( isset($this->relationship) ){
134 $rel =& $this->record->_table->getRelationship($this->relationship);
135 $table =$rel->getDomainTable();
137 $destTables =& $rel->getDestinationTables();
138 $table = $destTables[0]->tablename;
141 $table = $this->record->_table->tablename;
142 $rel =& $this->record->_table->getChildrenRelationship();
145 $default_order_column = $rel->getOrderColumn();
152 $this->
getSubrows($rows, $rowid, $null, $depth);
155 foreach ( array_keys($rows) as $curr_rowid ){
156 $path = explode(
'-',$curr_rowid);
157 $level = count(
$path);
158 $class = ( $rows[$curr_rowid][
'hasChildren'] ?
'folder':
'doc');
159 echo
"<tr id=\"$curr_rowid\">";
161 $keyString = implode(
'-',$rows[$curr_rowid][
'record']->getValuesAsStrings(
162 array_keys($rows[$curr_rowid][
'record']->_table->keys())
165 echo
"<td class=\"$rowClass\"><input id=\"remove_".$keyString.
"_checkbox\" type=\"checkbox\" name=\"--remkeys[]\" value=\"".$keyString.
"\"/></td>";
167 <td><div class=\"tier{$level}\"><a href=\"#\" ";
168 if ( $class ==
'folder'){
169 echo
"onclick=\"TreeTable.prototype.trees['$treetableid'].toggleRows(this)\" ";
171 $url = $rows[$curr_rowid][
'record']->getURL();
172 $editURL = $rows[$curr_rowid][
'record']->getURL(
'-action=edit');
173 $deleteURL = $rows[$curr_rowid][
'record']->getURL(
'-action=delete');
174 echo
"class=\"$class\"></a></td>
175 <td><a href=\"$url\">".$rows[$curr_rowid][
'record']->getTitle().
"</a></td>";
179 if ( $col == $default_order_column ){
183 echo
"<a href=\"#\" onclick=\"moveUp(".(intval(
$path[count(
$path)-1])-1).
")\" title=\"Move up\"><img src=\"".DATAFACE_URL.
"/images/arrowUp.gif\"/></a>";
187 <a href=\"#\" onclick=\"moveDown(".(intval(
$path[count(
$path)-1])-1).
")\" title=\"Move down\"><img src=\"".DATAFACE_URL.
"/images/arrowDown.gif\"/></a>";
193 if ( $rows[$curr_rowid][
'record']->_table->hasField($col) ){
195 echo
"<a href=\"$url\">".$rows[$curr_rowid][
'record']->htmlValue($col).
"</a>";
209 $out = ob_get_contents();
217 function toHtml($depth=3, $treetableid=
'treetable'){
219 if ( isset($this->relationship) ){
220 $rel =& $this->record->_table->getRelationship($this->relationship);
221 $table =$rel->getDomainTable();
223 $destTables =& $rel->getDestinationTables();
224 $table = $destTables[0]->tablename;
227 $table = $this->record->_table->tablename;
228 $rel =& $this->record->_table->getChildrenRelationship();
240 $default_order_column = $rel->getOrderColumn();
241 if ( isset($default_order_column) ){
243 df_display(array(
'redirectUrl'=>
$_SERVER[
'PHP_SELF'].
'?'.
$_SERVER[
'QUERY_STRING']),
'Dataface_MoveUpForm.html');
247 if ( !defined(
'Dataface_TreeTable_JAVASCRIPT_LOADED') ){
248 define(
'Dataface_TreeTable_JAVASCRIPT_LOADED',
true);
249 echo
'<script language="javascript" type="text/javascript" src="'.DATAFACE_URL.
'/js/TreeTable.js"></script>';
251 echo
'<form action="'.$_SERVER[
'PHP_SELF'].
'" method="GET" onsubmit="return validateTTForm(this);">';
252 echo
"<table width=\"100%\" id=\"$treetableid\" class=\"treetable\">";
254 echo
"<thead><tr><th><!-- checkbox column --></th><th><!-- Icon column --></th><th>Title</th>";
256 echo
"<th>$col</th>";
258 echo
"</tr></thead><tbody>";
261 echo
"</tbody></table>";
262 import(
'Dataface/ActionTool.php');
264 $actions = $actionsTool->getActions(array(
'category'=>
'selected_records_actions'));
265 if (count($actions)>0 ){
266 echo
" Perform on selected records:
267 <select name=\"-action\">";
268 foreach (array_keys($actions) as $i){
269 echo
"<option value=\"".$actions[$i][
'name'].
"\">".$actions[$i][
'label'].
"</option>
279 echo
"<input type=\"submit\" value=\"Submit\"/>";
282 import(
'Dataface/Utilities.php');
285 $q = array(
'-table'=>$this->record->_table->tablename);
286 foreach ( array_keys($this->record->_table->keys()) as $tkey){
287 $q[
'--__keys__'][$tkey] =
'='.$this->record->strval($tkey);
292 echo
'<input type="hidden" name="-redirect" value="'.$_SERVER[
'REQUEST_URI'].
'"/>';
295 <script language=\"javascript\" type=\"text/javascript \"><!--
296 TreeTable.prototype.trees['$treetableid'] = new TreeTable('$treetableid','');
299 $out = ob_get_contents();