ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f87
ilForumExplorer Class Reference

Class ilForumExplorer class for explorer view of forum posts. More...

+ Collaboration diagram for ilForumExplorer:

Public Member Functions

 __construct (ilObjForumGUI $gui, ilForumTopic $topic, ilForumProperties $properties)
 Constructor public. More...
 
 render ()
 
 fillTreeTemplate ()
 
 getHtml ()
 This method returns the tree html for the forum template public. More...
 

Static Public Member Functions

static getTreeNodeHtml ($object, ilObjForumGUI $gui, $pageHits)
 Returns the html used for a single forum tree node public. More...
 

Protected Attributes

 $tpl
 
 $gui
 
 $topic
 
 $properties
 
 $root_id
 

Detailed Description

Class ilForumExplorer class for explorer view of forum posts.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Nadia Ahmad nahma.nosp@m.d@da.nosp@m.tabay.nosp@m..de
Andreas Kordosz akord.nosp@m.osz@.nosp@m.datab.nosp@m.ay.d.nosp@m.e
Version
$Id$

Definition at line 17 of file class.ilForumExplorer.php.

Constructor & Destructor Documentation

◆ __construct()

ilForumExplorer::__construct ( ilObjForumGUI  $gui,
ilForumTopic  $topic,
ilForumProperties  $properties 
)

Constructor public.

Definition at line 64 of file class.ilForumExplorer.php.

References $_SESSION, $gui, $ilCtrl, $properties, $topic, $tpl, ilYuiUtil\getLocalPath(), and ilYuiUtil\initConnection().

65  {
66  global $tpl, $ilCtrl;
67 
68  $this->gui = $gui;
69  $this->topic = $topic;
70  $this->properties = $properties;
71 
72  $this->tpl = new ilTemplate('tpl.frm_tree.html', true, true, 'Modules/Forum');
73 
75  $tpl->addJavaScript(ilYuiUtil::getLocalPath() . '/yahoo/yahoo-min.js');
76  $tpl->addJavaScript(ilYuiUtil::getLocalPath() . '/event/event-min.js');
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');
80 
81  // Set ref_id for urls
82  $ilCtrl->setParameter($this->gui, 'thr_pk', $this->topic->getId());
83  $ilCtrl->setParameter($this->gui, 'backurl', null);
84 
85  // Set urls for async commands
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));
88 
89  // Fetch root id of the thread node
90  $this->root_id = $this->topic->getFirstPostNode()->getId();
91 
92  if(!is_array($_SESSION['frm'][$this->topic->getId()]['openTreeNodes']))
93  {
94  $_SESSION['frm'][(int)$this->topic->getId()]['openTreeNodes'] = array(0);
95  }
96 
97  // Prevent key gaps
98  shuffle($_SESSION['frm'][(int)$this->topic->getId()]['openTreeNodes']);
99  }
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
static initConnection()
Init YUI Connection module.
global $ilCtrl
Definition: ilias.php:18
special template class to simplify handling of ITX/PEAR
static getLocalPath($a_name="")
Get local path of a YUI js file.
+ Here is the call graph for this function:

Member Function Documentation

◆ fillTreeTemplate()

ilForumExplorer::fillTreeTemplate ( )

Definition at line 108 of file class.ilForumExplorer.php.

References $_SESSION, and ilJsonUtil\encode().

Referenced by render().

109  {
110  $emptyOnLoad = false;
111 
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))
115  {
116  $emptyOnLoad = true;
117  $nodes_to_request = array();
118  }
119 
120  $objects = $this->topic->getNestedSetPostChildren(null, $nodes_to_request);
121 
122  $counter = 0;
123 
124  $onloadNodes = array();
125  $nodesFetchedWithChildren = array();
126 
127  $frm = new ilForum();
128  $pageHits = $frm->getPageHits();
129 
130  include_once 'Services/JSON/classes/class.ilJsonUtil.php';
131 
132  foreach($objects as $object)
133  {
134  if($object['pos_pk'] != $this->root_id &&
135  !in_array($object['parent_pos'], $onloadNodes)
136  )
137  {
138  continue;
139  }
140 
141  if(in_array((int)$object['parent_pos'], $onloadNodes) &&
142  !in_array((int)$object['parent_pos'], $nodesFetchedWithChildren)
143  )
144  {
145  $nodesFetchedWithChildren[] = (int)$object['parent_pos'];
146  }
147 
148  $html = self::getTreeNodeHtml(
149  $object, $this->gui, $pageHits
150  );
151 
152  $hasChildren = ($object['children'] >= 1);
153 
154  $node = new stdClass();
155  $node->html = $html;
156 
157  if($object['pos_pk'] == $this->root_id)
158  {
159  $this->tpl->setVariable('FRM_TREE_ROOT_NODE_VARIABLE', 'frmNode' . $object['pos_pk']);
160  $this->tpl->setVariable('FRM_TREE_ROOT_NODE_LINK', ilJsonUtil::encode($node));
161  $this->tpl->setVariable('FRM_TREE_ROOT_NODE_HAS_CHILDREN', $hasChildren ? 'true' : 'false');
162  }
163  else
164  {
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']);
168  $this->tpl->setVariable('FRM_NODES_LINK', ilJsonUtil::encode($node));
169  $this->tpl->setVariable('FRM_NODES_HAS_CHILDREN', $hasChildren ? 'true' : 'false');
170  $this->tpl->parseCurrentBlock();
171  }
172 
173  $onloadNodes[] = (int)$object['pos_pk'];
174 
175  ++$counter;
176  }
177  $this->tpl->setVariable('THR_ONLOAD_NODES', ilJsonUtil::encode($onloadNodes));
178  $this->tpl->setVariable('THR_ONLOAD_NODES_FETCHED_WITH_CHILDREN', ilJsonUtil::encode($nodesFetchedWithChildren));
179 
180  if($emptyOnLoad)
181  {
182  $this->tpl->setVariable('THR_OPEN_NODES', ilJsonUtil::encode($onloadNodes));
183  $_SESSION['frm'][(int)$this->topic->getId()]['openTreeNodes'] = array_unique(array_merge(array(0), $onloadNodes));
184  }
185  else
186  {
187  $this->tpl->setVariable('THR_OPEN_NODES', ilJsonUtil::encode($_SESSION['frm'][(int)$this->topic->getId()]['openTreeNodes']));
188  }
189  }
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
Class Forum core functions for forum.
static encode($mixed, $suppress_native=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getHtml()

ilForumExplorer::getHtml ( )

This method returns the tree html for the forum template public.

Returns
string

Definition at line 246 of file class.ilForumExplorer.php.

247  {
248  return $this->tpl->get();
249  }

◆ getTreeNodeHtml()

static ilForumExplorer::getTreeNodeHtml (   $object,
ilObjForumGUI  $gui,
  $pageHits 
)
static

Returns the html used for a single forum tree node public.

Definition at line 197 of file class.ilForumExplorer.php.

References $ilCtrl, ilDatePresentation\formatDate(), and IL_CAL_DATETIME.

Referenced by ilObjForumGUI\fetchTreeChildrenAsyncObject().

198  {
199  global $ilCtrl;
200 
201  $html = '';
202 
203  // Set pos_pk for urls
204  $ilCtrl->setParameter($gui, 'pos_pk', $object['pos_pk']);
205 
206  // Set offset
207  $ilCtrl->setParameter($gui, 'offset', floor($object['counter'] / $pageHits) * $pageHits);
208 
209  // @todo: HTML in PHP used because of performance issues of ilTemplate an big forum trees
210  if($object['post_read'])
211  {
212  $url = $ilCtrl->getLinkTarget($gui, 'viewThread', $object['pos_pk']);
213  $link = "<a class='small' href='" . $url . "'>" . stripslashes($object['pos_subject']) . "</a>";
214 
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'>";
217  }
218  else
219  {
220  $url = $ilCtrl->getLinkTarget($gui, 'markPostRead', $object['pos_pk']);
221  $link = "<a class='small' href='" . $url . "'>" . stripslashes($object['pos_subject']) . "</a>";
222 
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'>";
225  }
226 
227  require_once 'Modules/Forum/classes/class.ilForumAuthorInformation.php';
228  $authorinfo = new ilForumAuthorInformation(
229  $object['pos_author_id'],
230  $object['pos_display_user_id'],
231  $object['pos_usr_alias'],
232  $object['import_name']
233  );
234  $html .= $authorinfo->getAuthorShortName();
235  $html .= ", " . ilDatePresentation::formatDate(new ilDateTime($object['pos_date'], IL_CAL_DATETIME)) . "</span></div>";
236 
237  return $html;
238  }
const IL_CAL_DATETIME
global $ilCtrl
Definition: ilias.php:18
static formatDate(ilDateTime $date)
Format a date public.
Date and time handling
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ render()

ilForumExplorer::render ( )

Definition at line 101 of file class.ilForumExplorer.php.

References fillTreeTemplate().

102  {
103  $this->fillTreeTemplate();
104 
105  return $this;
106  }
+ Here is the call graph for this function:

Field Documentation

◆ $gui

ilForumExplorer::$gui
protected

Definition at line 33 of file class.ilForumExplorer.php.

Referenced by __construct().

◆ $properties

ilForumExplorer::$properties
protected

Definition at line 49 of file class.ilForumExplorer.php.

Referenced by __construct().

◆ $root_id

ilForumExplorer::$root_id
protected

Definition at line 57 of file class.ilForumExplorer.php.

◆ $topic

ilForumExplorer::$topic
protected

Definition at line 41 of file class.ilForumExplorer.php.

Referenced by __construct().

◆ $tpl

ilForumExplorer::$tpl
protected

Definition at line 25 of file class.ilForumExplorer.php.

Referenced by __construct().


The documentation for this class was generated from the following file: