ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilForumExplorerGUI Class Reference

Class ilForumExplorerGUI. More...

+ Inheritance diagram for ilForumExplorerGUI:
+ Collaboration diagram for ilForumExplorerGUI:

Public Member Functions

 __construct ($a_expl_id, $a_parent_obj, $a_parent_cmd)
 {Constructor.} More...
 
 setThread (ilForumTopic $thread, ilForumPost $firstNode)
 
 isNodeClickable ($a_node)
 Is node clickable?
Parameters
mixed$a_nodenode object/array
Returns
boolean node clickable true/false
More...
 
 getRootNode ()
 {Get root node.Please note that the class does not make any requirements how nodes are represented (array or object)
Returns
mixed root node object/array
} More...
 
 getChildsOfNode ($a_parent_node_id)
 {Get childs of node.
Parameters
string$a_parent_idparent node id
Returns
array childs
} More...
 
 preloadChildren ()
 
 getNodeContent ($a_node)
 {Get content of a node.
Parameters
mixed$a_nodenode array or object
Returns
string content of the node
} More...
 
 getNodeHref ($a_node)
 {Get href for node.
Parameters
mixed$a_nodenode object/array
Returns
string href attribute
} More...
 
 getNodeId ($a_node)
 {Get id of a node.
Parameters
mixed$a_nodenode array or object
Returns
string id of node
} More...
 
 getNodeIcon ($a_node)
 {Get node icon path.
Parameters
mixed$a_nodenode object/array
Returns
string image file path
} More...
 
 beforeRendering ()
 Before rendering. More...
 
 getHTML ()
 {Get HTML.} More...
 
- Public Member Functions inherited from ilExplorerBaseGUI
 __construct ($a_expl_id, $a_parent_obj, $a_parent_cmd)
 Constructor. More...
 
 setChildLimit ($a_val)
 Set child limit. More...
 
 getChildLimit ()
 Get child limit. More...
 
 setSearchTerm ($a_val)
 Set search term. More...
 
 getSearchTerm ()
 Get search term. More...
 
 setMainTemplate (ilTemplate $a_main_tpl=null)
 Set main template (that is responsible for adding js/css) More...
 
 getRootNode ()
 Get root node. More...
 
 getChildsOfNode ($a_parent_node_id)
 Get childs of node. More...
 
 getNodeContent ($a_node)
 Get content of a node. More...
 
 getNodeId ($a_node)
 Get id of a node. More...
 
 getNodeHref ($a_node)
 Get href for node. More...
 
 nodeHasVisibleChilds ($a_node)
 Node has childs? More...
 
 sortChilds ($a_childs, $a_parent_node_id)
 Sort childs. More...
 
 getNodeIcon ($a_node)
 Get node icon path. More...
 
 getNodeIconAlt ($a_node)
 Get node icon alt attribute. More...
 
 getNodeTarget ($a_node)
 Get node target (frame) attribute. More...
 
 getNodeOnClick ($a_node)
 Get node onclick attribute. More...
 
 isNodeVisible ($a_node)
 Is node visible? More...
 
 isNodeHighlighted ($a_node)
 Is node highlighted? More...
 
 isNodeClickable ($a_node)
 Is node clickable? More...
 
 getId ()
 Get id of explorer element. More...
 
 setSkipRootNode ($a_val)
 Set skip root node. More...
 
 getSkipRootNode ()
 Get skip root node. More...
 
 setAjax ($a_val)
 Set ajax. More...
 
 getAjax ()
 Get ajax. More...
 
 setSecondaryHighlightedNodes ($a_val)
 Set secondary (background) highlighted nodes. More...
 
 getSecondaryHighlightedNodes ()
 Get secondary (background) highlighted nodes. More...
 
 setNodeOpen ($a_id)
 Set node to be opened (additional custom opened node, not standard expand behaviour) More...
 
 setSelectMode ($a_postvar, $a_multi=false)
 Set select mode (to deactivate, pass an empty string as postvar) More...
 
 setNodeSelected ($a_id)
 Set node to be opened (additional custom opened node, not standard expand behaviour) More...
 
 setOfflineMode ($a_val)
 Set offline mode. More...
 
 getOfflineMode ()
 Get offline mode. More...
 
 handleCommand ()
 Handle explorer internal command. More...
 
 getContainerId ()
 Get container id. More...
 
 openNode ()
 Open node. More...
 
 closeNode ()
 Close node. More...
 
 getNodeAsync ()
 Get node asynchronously. More...
 
 beforeRendering ()
 Before rendering. More...
 
 getOnLoadCode ()
 Get on load code. More...
 
 getHTML ()
 Get HTML. More...
 
 renderNode ($a_node, $tpl)
 Render node. More...
 
 renderChilds ($a_node_id, $tpl)
 Render childs. More...
 
 getDomNodeIdForNodeId ($a_node_id)
 Get DOM node id for node id. More...
 
 getNodeIdForDomNodeId ($a_dom_node_id)
 Get node id for dom node id. More...
 
 listItemStart ($tpl, $a_node)
 List item start. More...
 
 listItemEnd ($tpl)
 List item end. More...
 
 listStart ($tpl)
 List start. More...
 
 listEnd ($tpl)
 List end. More...
 
 isNodeOnclickEnabled ()
 
 setNodeOnclickEnabled ($nodeOnclickEnabled)
 
 isEnableDnd ()
 
 setEnableDnd ($enable_dnd)
 Enable Drag & Drop functionality. More...
 

Protected Member Functions

 getNodeTemplateInstance ()
 Factory method for a new instance of a node template. More...
 
 getNodeTitleClasses (array $node_config)
 
 getUnlinkedNodeContentClass ()
 
- Protected Member Functions inherited from ilExplorerBaseGUI
 isNodeSelectable ($a_node)
 Is node selectable? More...
 
 getNodeToggleOnClick ($a_node)
 Get onclick attribute for node toggling. More...
 
 getSelectOnClick ($a_node)
 Get onclick attribute for selecting radio/checkbox. More...
 
 isNodeOpen ($node_id)
 Get all open nodes. More...
 
 getJSTreePlugins ()
 

Protected Attributes

 $js_explorer_frm_path = './Modules/Forum/js/ilForumExplorer.js'
 
 $thread
 
 $max_entries = PHP_INT_MAX
 
 $tpl
 
 $ctrl
 
 $preloaded = false
 
 $preloaded_children = array()
 
 $node_id_to_parent_node_id_map = array()
 
 $root_node = null
 
 $authorInformation = []
 
- Protected Attributes inherited from ilExplorerBaseGUI
 $log
 
 $ctrl
 
 $tpl
 
 $skip_root_node = false
 
 $ajax = false
 
 $custom_open_nodes = array()
 
 $selected_nodes = array()
 
 $select_postvar = ""
 
 $offline_mode = false
 
 $sec_highl_nodes = array()
 
 $enable_dnd = false
 
 $search_term = ""
 
 $child_limit = 0
 

Private Member Functions

 getAuthorInformationByNode (array $node)
 

Additional Inherited Members

- Static Public Member Functions inherited from ilExplorerBaseGUI
static getLocalExplorerJsPath ()
 Get local path of explorer js. More...
 
static getLocalJsTreeJsPath ()
 Get local path of jsTree js. More...
 
static getLocalJsTreeCssPath ()
 Get local path of jsTree js. More...
 
static createHTMLExportDirs ($a_target_dir)
 Create html export directories. More...
 
static init ($a_main_tpl=null)
 Init JS. More...
 
- Static Protected Attributes inherited from ilExplorerBaseGUI
static $js_tree_path = "./libs/bower/bower_components/jstree/dist/jstree.js"
 
static $js_tree_path_css = "./libs/bower/bower_components/jstree/dist/themes/default/style.min.css"
 
static $js_expl_path = "./Services/UIComponent/Explorer2/js/Explorer2.js"
 

Detailed Description

Class ilForumExplorerGUI.

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de

Definition at line 8 of file class.ilForumExplorerGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilForumExplorerGUI::__construct (   $a_expl_id,
  $a_parent_obj,
  $a_parent_cmd 
)

{Constructor.}

Reimplemented from ilExplorerBaseGUI.

Definition at line 61 of file class.ilForumExplorerGUI.php.

62 {
63 global $DIC;
64
65 parent::__construct($a_expl_id, $a_parent_obj, $a_parent_cmd);
66
67 $this->setSkipRootNode(false);
68 $this->setAjax(true);
69
70 $this->tpl = $DIC->ui()->mainTemplate();
71 $this->ctrl = $DIC->ctrl();
72
73 $frm = new ilForum();
74 $this->max_entries = (int) $frm->getPageHits();
75 }
setSkipRootNode($a_val)
Set skip root node.
Class Forum core functions for forum.
global $DIC
Definition: saml.php:7

References $DIC, ilExplorerBaseGUI\setAjax(), and ilExplorerBaseGUI\setSkipRootNode().

+ Here is the call graph for this function:

Member Function Documentation

◆ beforeRendering()

ilForumExplorerGUI::beforeRendering ( )

Before rendering.

Reimplemented from ilExplorerBaseGUI.

Definition at line 283 of file class.ilForumExplorerGUI.php.

284 {
285 if (isset($_GET['post_created_below']) && (int) $_GET['post_created_below'] > 0) {
286 $parent = (int) $_GET['post_created_below'];
287 do {
288 $this->setNodeOpen((int) $parent);
289 } while ($parent = $this->node_id_to_parent_node_id_map[$parent]);
290
291 $this->store->set("on_" . $this->id, serialize(array_unique(array_merge($this->open_nodes, $this->custom_open_nodes))));
292 }
293 }
$_GET["client_id"]
setNodeOpen($a_id)
Set node to be opened (additional custom opened node, not standard expand behaviour)

References $_GET, and ilExplorerBaseGUI\setNodeOpen().

+ Here is the call graph for this function:

◆ getAuthorInformationByNode()

ilForumExplorerGUI::getAuthorInformationByNode ( array  $node)
private
Parameters
array$node
Returns
\ilForumAuthorInformation

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

247 {
248 if (isset($this->authorInformation[(int) $node['pos_pk']])) {
249 return $this->authorInformation[(int) $node['pos_pk']];
250 }
251
252 return $this->authorInformation[(int) $node['pos_pk']] = new ilForumAuthorInformation(
253 $node['pos_author_id'],
254 $node['pos_display_user_id'],
255 $node['pos_usr_alias'],
256 $node['import_name']
257 );
258 }

Referenced by getNodeContent(), and getNodeIcon().

+ Here is the caller graph for this function:

◆ getChildsOfNode()

ilForumExplorerGUI::getChildsOfNode (   $a_parent_node_id)

{Get childs of node.

Parameters
string$a_parent_idparent node id
Returns
array childs
}

Reimplemented from ilExplorerBaseGUI.

Definition at line 138 of file class.ilForumExplorerGUI.php.

139 {
140 if ($this->preloaded) {
141 if (isset($this->preloaded_children[$a_parent_node_id])) {
142 return $this->preloaded_children[$a_parent_node_id];
143 }
144
145 return [];
146 }
147
148 return $this->thread->getNestedSetPostChildren($a_parent_node_id, 1);
149 }

◆ getHTML()

ilForumExplorerGUI::getHTML ( )

{Get HTML.}

Reimplemented from ilExplorerBaseGUI.

Definition at line 298 of file class.ilForumExplorerGUI.php.

299 {
300 $this->preloadChildren();
301
302 $html = parent::getHTML();
303
304 $this->tpl->addOnLoadCode('il.ForumExplorer.init(' . json_encode(array(
305 'selectors' => array(
306 'container' => '#' . $this->getContainerId(),
307 'unlinked_content' => '.' . $this->getUnlinkedNodeContentClass()
308 )
309 )) . ');');
310
311 $this->tpl->addJavascript($this->js_explorer_frm_path);
312
313 return $html;
314 }
getContainerId()
Get container id.
$html
Definition: example_001.php:87

References $html, ilExplorerBaseGUI\getContainerId(), getUnlinkedNodeContentClass(), and preloadChildren().

+ Here is the call graph for this function:

◆ getNodeContent()

ilForumExplorerGUI::getNodeContent (   $a_node)

{Get content of a node.

Parameters
mixed$a_nodenode array or object
Returns
string content of the node
}

Reimplemented from ilExplorerBaseGUI.

Definition at line 172 of file class.ilForumExplorerGUI.php.

173 {
174 $tpl = $this->getNodeTemplateInstance();
175
176 $tpl->setCurrentBlock('node-content-block');
177 $tpl->setVariable('TITLE', $a_node['pos_subject']);
178 $tpl->setVariable('TITLE_CLASSES', implode(' ', $this->getNodeTitleClasses($a_node)));
179 $tpl->parseCurrentBlock();
180
181 if ($this->root_node->getId() == $a_node['pos_pk']) {
182 return $tpl->get();
183 }
184
185 $authorinfo = $this->getAuthorInformationByNode($a_node);
186
187 $tpl->setCurrentBlock('unlinked-node-content-block');
188 $tpl->setVariable('UNLINKED_CONTENT_CLASS', $this->getUnlinkedNodeContentClass());
189 $tpl->setVariable('AUTHOR', $authorinfo->getAuthorShortName());
190 $tpl->setVariable('DATE', ilDatePresentation::formatDate(new ilDateTime($a_node['pos_date'], IL_CAL_DATETIME)));
191 $tpl->parseCurrentBlock();
192
193 return $tpl->get();
194 }
const IL_CAL_DATETIME
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
@classDescription Date and time handling
getNodeTemplateInstance()
Factory method for a new instance of a node template.
getNodeTitleClasses(array $node_config)

References $tpl, ilDatePresentation\formatDate(), getAuthorInformationByNode(), getNodeTemplateInstance(), getNodeTitleClasses(), getUnlinkedNodeContentClass(), and IL_CAL_DATETIME.

+ Here is the call graph for this function:

◆ getNodeHref()

ilForumExplorerGUI::getNodeHref (   $a_node)

{Get href for node.

Parameters
mixed$a_nodenode object/array
Returns
string href attribute
}

Reimplemented from ilExplorerBaseGUI.

Definition at line 226 of file class.ilForumExplorerGUI.php.

227 {
228 $this->ctrl->setParameter($this->parent_obj, 'backurl', null);
229 $this->ctrl->setParameter($this->parent_obj, 'pos_pk', $a_node['pos_pk']);
230
231 if (isset($a_node['counter'])) {
232 $this->ctrl->setParameter($this->parent_obj, 'offset', floor($a_node['counter'] / $this->max_entries) * $this->max_entries);
233 }
234
235 if (isset($a_node['post_read']) && $a_node['post_read']) {
236 return $this->ctrl->getLinkTarget($this->parent_obj, $this->parent_cmd, $a_node['pos_pk']);
237 } else {
238 return $this->ctrl->getLinkTarget($this->parent_obj, 'markPostRead', $a_node['pos_pk']);
239 }
240 }

◆ getNodeIcon()

ilForumExplorerGUI::getNodeIcon (   $a_node)

{Get node icon path.

Parameters
mixed$a_nodenode object/array
Returns
string image file path
}

Reimplemented from ilExplorerBaseGUI.

Definition at line 271 of file class.ilForumExplorerGUI.php.

272 {
273 if ($this->root_node->getId() == $a_node['pos_pk']) {
274 return ilObject::_getIcon(0, 'tiny', 'frm');
275 }
276
277 return $this->getAuthorInformationByNode($a_node)->getProfilePicture();
278 }

References getAuthorInformationByNode().

+ Here is the call graph for this function:

◆ getNodeId()

ilForumExplorerGUI::getNodeId (   $a_node)

{Get id of a node.

Parameters
mixed$a_nodenode array or object
Returns
string id of node
}

Reimplemented from ilExplorerBaseGUI.

Definition at line 263 of file class.ilForumExplorerGUI.php.

264 {
265 return $a_node['pos_pk'];
266 }

◆ getNodeTemplateInstance()

ilForumExplorerGUI::getNodeTemplateInstance ( )
protected

Factory method for a new instance of a node template.

Returns
ilTemplate

Definition at line 130 of file class.ilForumExplorerGUI.php.

131 {
132 return new ilTemplate('tpl.tree_node_content.html', true, true, 'Modules/Forum');
133 }
special template class to simplify handling of ITX/PEAR

Referenced by getNodeContent().

+ Here is the caller graph for this function:

◆ getNodeTitleClasses()

ilForumExplorerGUI::getNodeTitleClasses ( array  $node_config)
protected
Parameters
array$node_config
Returns
array

Definition at line 200 of file class.ilForumExplorerGUI.php.

201 {
202 $node_title_classes = array('ilForumTreeTitle');
203
204 if ($this->root_node->getId() == $node_config['pos_pk']) {
205 return $node_title_classes;
206 }
207
208 if (isset($node_config['post_read']) && !$node_config['post_read']) {
209 $node_title_classes[] = 'ilForumTreeTitleUnread';
210 }
211
212 return $node_title_classes;
213 }

Referenced by getNodeContent().

+ Here is the caller graph for this function:

◆ getRootNode()

ilForumExplorerGUI::getRootNode ( )

{Get root node.Please note that the class does not make any requirements how nodes are represented (array or object)

Returns
mixed root node object/array
}

Reimplemented from ilExplorerBaseGUI.

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

109 {
110 if (null === $this->root_node) {
111 $this->root_node = $this->thread->getFirstPostNode();
112 }
113
114 return array(
115 'pos_pk' => $this->root_node->getId(),
116 'pos_subject' => $this->root_node->getSubject(),
117 'pos_author_id' => $this->root_node->getPosAuthorId(),
118 'pos_display_user_id' => $this->root_node->getDisplayUserId(),
119 'pos_usr_alias' => $this->root_node->getUserAlias(),
120 'pos_date' => $this->root_node->getCreateDate(),
121 'import_name' => $this->root_node->getImportName(),
122 'post_read' => $this->root_node->isPostRead()
123 );
124 }

◆ getUnlinkedNodeContentClass()

ilForumExplorerGUI::getUnlinkedNodeContentClass ( )
protected
Returns
string

Definition at line 218 of file class.ilForumExplorerGUI.php.

219 {
220 return 'ilForumTreeUnlinkedContent';
221 }

Referenced by getHTML(), and getNodeContent().

+ Here is the caller graph for this function:

◆ isNodeClickable()

ilForumExplorerGUI::isNodeClickable (   $a_node)

Is node clickable?

Parameters
mixed$a_nodenode object/array
Returns
boolean node clickable true/false

Reimplemented from ilExplorerBaseGUI.

Definition at line 94 of file class.ilForumExplorerGUI.php.

95 {
96 $result = parent::isNodeClickable($a_node);
97 if (!$result) {
98 return false;
99 }
100
101 return $this->root_node->getId() != $a_node['pos_pk'];
102 }
$result

References $result.

◆ preloadChildren()

ilForumExplorerGUI::preloadChildren ( )

Definition at line 154 of file class.ilForumExplorerGUI.php.

155 {
156 $this->preloaded_children = array();
157 $this->node_id_to_parent_node_id_map = array();
158
159 $children = $this->thread->getNestedSetPostChildren($this->root_node->getId());
160
161 array_walk($children, function (&$a_node, $key) {
162 $this->node_id_to_parent_node_id_map[(int) $a_node['pos_pk']] = (int) $a_node['parent_pos'];
163 $this->preloaded_children[(int) $a_node['parent_pos']][$a_node['pos_pk']] = $a_node;
164 });
165
166 $this->preloaded = true;
167 }
$key
Definition: croninfo.php:18

References $key.

Referenced by getHTML().

+ Here is the caller graph for this function:

◆ setThread()

ilForumExplorerGUI::setThread ( ilForumTopic  $thread,
ilForumPost  $firstNode 
)
Parameters
ilForumTopic$thread
ilForumPost$firstNode

Definition at line 81 of file class.ilForumExplorerGUI.php.

82 {
83 $this->thread = $thread;
84 $this->root_node = $firstNode;
85 $this->root_node->setIsRead($this->root_node->isRead($this->root_node->getPosAuthorId()));
86 $this->setNodeOpen($this->root_node->getId());
87
88 $this->ctrl->setParameter($this->parent_obj, 'thr_pk', $this->thread->getId());
89 }
setIsRead($a_is_read)

References $thread, ilForumPost\setIsRead(), and ilExplorerBaseGUI\setNodeOpen().

+ Here is the call graph for this function:

Field Documentation

◆ $authorInformation

ilForumExplorerGUI::$authorInformation = []
protected

Definition at line 56 of file class.ilForumExplorerGUI.php.

◆ $ctrl

ilForumExplorerGUI::$ctrl
protected

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

◆ $js_explorer_frm_path

ilForumExplorerGUI::$js_explorer_frm_path = './Modules/Forum/js/ilForumExplorer.js'
protected

Definition at line 13 of file class.ilForumExplorerGUI.php.

◆ $max_entries

ilForumExplorerGUI::$max_entries = PHP_INT_MAX
protected

Definition at line 23 of file class.ilForumExplorerGUI.php.

◆ $node_id_to_parent_node_id_map

ilForumExplorerGUI::$node_id_to_parent_node_id_map = array()
protected

Definition at line 48 of file class.ilForumExplorerGUI.php.

◆ $preloaded

ilForumExplorerGUI::$preloaded = false
protected

Definition at line 38 of file class.ilForumExplorerGUI.php.

◆ $preloaded_children

ilForumExplorerGUI::$preloaded_children = array()
protected

Definition at line 43 of file class.ilForumExplorerGUI.php.

◆ $root_node

ilForumExplorerGUI::$root_node = null
protected

Definition at line 53 of file class.ilForumExplorerGUI.php.

◆ $thread

ilForumExplorerGUI::$thread
protected

Definition at line 18 of file class.ilForumExplorerGUI.php.

Referenced by setThread().

◆ $tpl

ilForumExplorerGUI::$tpl
protected

Definition at line 28 of file class.ilForumExplorerGUI.php.

Referenced by getNodeContent().


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