4 include_once
'Services/YUI/classes/class.ilYuiUtil.php';
5 include_once
'Services/JSON/classes/class.ilJsonUtil.php';
72 $this->tpl =
new ilTemplate(
'tpl.frm_tree.html',
true,
true,
'Modules/Forum');
77 $tpl->addJavaScript(
'./Modules/Forum/js/treeview.js');
78 $tpl->addJavaScript(
'./Modules/Forum/js/treeview_extensions.js');
79 $tpl->addCss(
'./Modules/Forum/css/forum_tree.css');
82 $ilCtrl->setParameter($this->gui,
'thr_pk', $this->topic->getId());
83 $ilCtrl->setParameter($this->gui,
'backurl', null);
86 $this->tpl->setVariable(
'THR_TREE_STATE_URL', $ilCtrl->getLinkTarget($this->gui,
'setTreeStateAsynch',
'',
true,
false));
87 $this->tpl->setVariable(
'THR_TREE_FETCH_CHILDREN_URL', $ilCtrl->getLinkTarget($this->gui,
'fetchTreeChildrenAsync',
'',
true,
false));
90 $this->root_id = $this->topic->getFirstPostNode()->getId();
92 if(!is_array(
$_SESSION[
'frm'][$this->topic->getId()][
'openTreeNodes']))
94 $_SESSION[
'frm'][(int)$this->topic->getId()][
'openTreeNodes'] = array(0);
98 shuffle(
$_SESSION[
'frm'][(
int)$this->topic->getId()][
'openTreeNodes']);
110 $emptyOnLoad =
false;
112 $nodes_to_request =
$_SESSION[
'frm'][(int)$this->topic->getId()][
'openTreeNodes'];
113 if(!
$_SESSION[
'frm'][(
int)$this->topic->getId()][
'openTreeNodes'] ||
114 (count(
$_SESSION[
'frm'][(
int)$this->topic->getId()][
'openTreeNodes']) == 1 &&
$_SESSION[
'frm'][(
int)$this->topic->getId()][
'openTreeNodes'][0] == 0))
117 $nodes_to_request = array();
120 $objects = $this->topic->getNestedSetPostChildren(null, $nodes_to_request);
124 $onloadNodes = array();
125 $nodesFetchedWithChildren = array();
128 $pageHits = $frm->getPageHits();
130 include_once
'Services/JSON/classes/class.ilJsonUtil.php';
132 foreach($objects as $object)
134 if($object[
'pos_pk'] != $this->root_id &&
135 !in_array($object[
'parent_pos'], $onloadNodes)
141 if(in_array((
int)$object[
'parent_pos'], $onloadNodes) &&
142 !in_array((
int)$object[
'parent_pos'], $nodesFetchedWithChildren)
145 $nodesFetchedWithChildren[] = (int)$object[
'parent_pos'];
149 $object, $this->gui, $pageHits
152 $hasChildren = ($object[
'children'] >= 1);
154 $node =
new stdClass();
157 if($object[
'pos_pk'] == $this->root_id)
159 $this->tpl->setVariable(
'FRM_TREE_ROOT_NODE_VARIABLE',
'frmNode' . $object[
'pos_pk']);
161 $this->tpl->setVariable(
'FRM_TREE_ROOT_NODE_HAS_CHILDREN', $hasChildren ?
'true' :
'false');
165 $this->tpl->setCurrentBlock(
'frm_nodes');
166 $this->tpl->setVariable(
'FRM_NODES_VARNAME',
'frmNode' . $object[
'pos_pk']);
167 $this->tpl->setVariable(
'FRM_NODES_PARENT_VARNAME',
'frmNode' . $object[
'parent_pos']);
169 $this->tpl->setVariable(
'FRM_NODES_HAS_CHILDREN', $hasChildren ?
'true' :
'false');
170 $this->tpl->parseCurrentBlock();
173 $onloadNodes[] = (int)$object[
'pos_pk'];
178 $this->tpl->setVariable(
'THR_ONLOAD_NODES_FETCHED_WITH_CHILDREN',
ilJsonUtil::encode($nodesFetchedWithChildren));
183 $_SESSION[
'frm'][(int)$this->topic->getId()][
'openTreeNodes'] = array_unique(array_merge(array(0), $onloadNodes));
204 $ilCtrl->setParameter($gui,
'pos_pk', $object[
'pos_pk']);
207 $ilCtrl->setParameter($gui,
'offset', floor($object[
'counter'] / $pageHits) * $pageHits);
210 if($object[
'post_read'])
212 $url = $ilCtrl->getLinkTarget($gui,
'viewThread', $object[
'pos_pk']);
213 $link =
"<a class='small' href='" . $url .
"'>" . stripslashes($object[
'pos_subject']) .
"</a>";
215 $html .=
"<div class='frmTreeInfo'><span class='frmTitle' id='frm_node_" . $object[
'pos_pk'] .
"'>" . $link .
"</span><br />" .
216 "<span id='frm_node_desc_" . $object[
'pos_pk'] .
"' class='small'>";
220 $url = $ilCtrl->getLinkTarget($gui,
'markPostRead', $object[
'pos_pk']);
221 $link =
"<a class='small' href='" . $url .
"'>" . stripslashes($object[
'pos_subject']) .
"</a>";
223 $html .=
"<div class='frmTreeInfo'><span class='frmTitleBold' id='frm_node_" . $object[
'pos_pk'] .
"'>" . $link .
"</span><br />" .
224 "<span id='frm_node_desc_" . $object[
'pos_pk'] .
"' class='small'>";
227 require_once
'Modules/Forum/classes/class.ilForumAuthorInformation.php';
229 $object[
'pos_usr_id'],
230 $object[
'pos_usr_alias'],
231 $object[
'import_name']
233 $html .= $authorinfo->getAuthorShortName();
247 return $this->tpl->get();