ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilForumExplorerGUI Class Reference

Class ilForumExplorerGUI. More...

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

Public Member Functions

 __construct (string $a_expl_id, object $a_parent_obj, string $a_parent_cmd, ilForumTopic $thread, ilForumPost $root)
 ilForumExplorerGUI constructor. More...
 
 getChildsOfNode ($parentNodeId)
 @inheritDoc More...
 
 setCurrentPage (int $currentPage)
 
 getChildren ($record, $environment=null)
 @inheritDoc More...
 
 getTreeLabel ()
 
 getTreeComponent ()
 @inheritDoc More...
 
 getNodeId ($a_node)
 @inheritDoc More...
 
 getNodeIcon ($node)
 @inheritDoc More...
 
 getNodeHref ($node)
 @inheritDoc More...
 
 getNodeContent ($a_node)
 @inheritDoc More...
 
- Public Member Functions inherited from ilTreeExplorerGUI
 __construct ($a_expl_id, $a_parent_obj, $a_parent_cmd, $a_tree)
 Constructor. More...
 
 getTree ()
 Get tree. More...
 
 setOrderField ($a_val, $a_numeric=false)
 Set order field. More...
 
 getOrderField ()
 Get order field. More...
 
 setTypeWhiteList ($a_val)
 Set type white list. More...
 
 getTypeWhiteList ()
 Get type white list. More...
 
 setTypeBlackList ($a_val)
 Set type black list. More...
 
 getTypeBlackList ()
 Get type black list. More...
 
 setPreloadChilds ($a_val)
 Set preload childs. More...
 
 getPreloadChilds ()
 Get preload childs. More...
 
 getSuccessorNode ($a_node_id, $a_type="")
 Get successor node (currently only(!) based on lft/rgt tree values) More...
 
 getChildsOfNode ($a_parent_node_id)
 Get childs of node. More...
 
 getNodeId ($a_node)
 Get id for node. More...
 
 getNodeIconAlt ($a_node)
 Get node icon alt attribute. More...
 
 getRootNode ()
 Get root node. More...
 
 setRootId ($a_root)
 
 setPathOpen ($a_id)
 Set node path to be opened. More...
 
 getHTML ($new=false)
 Get HTML. More...
 
 getChildren ($node, $environment=null)
 Get a list of records (that list can also be empty).Each record will be relayed to $this->build to retrieve a Node. Also, each record will be asked for Sub-Nodes using this function.
Returns
array
More...
 
 build (\ILIAS\UI\Component\Tree\Node\Factory $factory, $record, $environment=null)
 
 getTreeLabel ()
 
 getTreeComponent ()
 Get Tree UI. More...
 
 toggleExplorerNodeState ()
 Should be called by an ilCtrl-enabled command class if a tree node toggle action should be processed. 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 ($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...
 
- Public Member Functions inherited from ILIAS\UI\Component\Tree\TreeRecursion
 getChildren ( $record, $environment=null)
 Get a list of records (that list can also be empty). More...
 
 build (Node\Factory $factory, $record, $environment=null)
 Build and return a Node. More...
 

Protected Member Functions

 initPosting ()
 
 preloadChilds ()
 @inheritDoc More...
 
 createNode (\ILIAS\UI\Component\Tree\Node\Factory $factory, $record)
 @inheritDoc More...
 
 getNodeStateToggleCmdClasses ($record)
 @inheritDoc More...
 
- Protected Member Functions inherited from ilTreeExplorerGUI
 preloadChilds ()
 Preload childs. More...
 
 matches ($node)
 Does a node match a search term (or is search term empty) More...
 
 getRootId ()
 
 createNode (\ILIAS\UI\Component\Tree\Node\Factory $factory, $record)
 Creates at tree node, can be overwritten in derivatives if another node type should be used. More...
 
 getNodeStateToggleCmdClasses ($record)
 Should return an array of ilCtrl-enabled command classes which should be used to build the URL for the expand/collapse actions applied on a tree node. More...
 
 render ()
 Render tree. More...
 
- 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

 $thread
 
 $root_node
 
 $node_id_to_parent_node_id_map = []
 
 $max_entries = PHP_INT_MAX
 
 $preloaded_children = []
 
 $authorInformation = []
 
 $currentPostingId = 0
 
- Protected Attributes inherited from ilTreeExplorerGUI
 $lng
 
 $httpRequest
 
 $tree = null
 
 $tree_label = ""
 
 $order_field = ""
 
 $order_field_numeric = false
 
 $type_white_list = array()
 
 $type_black_list = array()
 
 $childs = array()
 
 $preloaded = false
 
 $preload_childs = false
 
 $root_node_data = null
 
 $all_childs = array()
 
 $ui
 
- 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 = ""
 
 $open_nodes = []
 
 $store
 
 $parent_obj
 
 $child_limit = 0
 
 $parent_cmd = ''
 

Private Member Functions

 getAuthorInformationByNode (array $node)
 

Private Attributes

 $currentPage = 0
 

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 11 of file class.ilForumExplorerGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilForumExplorerGUI::__construct ( string  $a_expl_id,
object  $a_parent_obj,
string  $a_parent_cmd,
ilForumTopic  $thread,
ilForumPost  $root 
)

ilForumExplorerGUI constructor.

Parameters
$a_expl_id
$a_parent_obj
$a_parent_cmd
ilForumTopic$thread
ilForumPost$root

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

46 {
47 global $DIC;
48
49 parent::__construct($a_expl_id, $a_parent_obj, $a_parent_cmd, $DIC->repositoryTree());
50
51 $this->setSkipRootNode(false);
52 $this->setAjax(false);
53 $this->setPreloadChilds(true);
54
55 $this->thread = $thread;
56 $this->root_node = $root;
57
58 $this->ctrl->setParameter($this->parent_obj, 'thr_pk', $this->thread->getId());
59
60 $frm = new ilForum();
61 $this->max_entries = (int) $frm->getPageHits();
62
63 $this->initPosting();
64
65 $this->setNodeOpen($this->root_node->getId());
66 }
setSkipRootNode($a_val)
Set skip root node.
setNodeOpen($a_id)
Set node to be opened (additional custom opened node, not standard expand behaviour)
Class Forum core functions for forum.
setPreloadChilds($a_val)
Set preload childs.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$DIC
Definition: xapitoken.php:46

References $DIC, $thread, ILIAS\GlobalScreen\Provider\__construct(), initPosting(), ilExplorerBaseGUI\setAjax(), ilExplorerBaseGUI\setNodeOpen(), ilTreeExplorerGUI\setPreloadChilds(), and ilExplorerBaseGUI\setSkipRootNode().

+ Here is the call graph for this function:

Member Function Documentation

◆ createNode()

ilForumExplorerGUI::createNode ( \ILIAS\UI\Component\Tree\Node\Factory  $factory,
  $record 
)
protected

@inheritDoc

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

177 $nodeIconPath = $this->getNodeIcon($record);
178
179 $icon = null;
180 if (is_string($nodeIconPath) && strlen($nodeIconPath) > 0) {
181 $icon = $this->ui
182 ->factory()
183 ->symbol()
184 ->icon()
185 ->custom($nodeIconPath, $this->getNodeIconAlt($record));
186 }
187
188 if ((int) $record['pos_pk'] === (int) $this->root_node->getId()) {
189 $node = $factory->simple($this->getNodeContent($record), $icon);
190 } else {
191 $authorInfo = $this->getAuthorInformationByNode($record);
192 $creationDate = ilDatePresentation::formatDate(new ilDateTime($record['pos_date'], IL_CAL_DATETIME));
193 $bylineString = $authorInfo->getAuthorShortName() . ', ' . $creationDate;
194
195 $node = $factory->bylined($this->getNodeContent($record), $bylineString, $icon);
196 }
197
198 return $node;
199 }
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
getNodeContent($a_node)
@inheritDoc
getNodeIconAlt($a_node)
Get node icon alt attribute.
This describes a Tree Node.
Definition: Node.php:16
$factory
Definition: metadata.php:58
ui()
Definition: ui.php:5

References ilTreeExplorerGUI\getNodeIconAlt(), and ui().

+ Here is the call graph for this function:

◆ getAuthorInformationByNode()

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

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

217 {
218 if (isset($this->authorInformation[(int) $node['pos_pk']])) {
219 return $this->authorInformation[(int) $node['pos_pk']];
220 }
221
222 return $this->authorInformation[(int) $node['pos_pk']] = new ilForumAuthorInformation(
223 $node['pos_author_id'],
224 $node['pos_display_user_id'],
225 $node['pos_usr_alias'],
226 $node['import_name']
227 );
228 }

◆ getChildren()

ilForumExplorerGUI::getChildren (   $record,
  $environment = null 
)

@inheritDoc

Reimplemented from ilTreeExplorerGUI.

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

131 : array
132 {
133 return $this->getChildsOfNode((int) $record['pos_pk']);
134 }
getChildsOfNode($parentNodeId)
@inheritDoc

References getChildsOfNode().

+ Here is the call graph for this function:

◆ getChildsOfNode()

ilForumExplorerGUI::getChildsOfNode (   $parentNodeId)

@inheritDoc

Reimplemented from ilTreeExplorerGUI.

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

85 {
86 if ($this->preloaded) {
87 if (isset($this->preloaded_children[$parentNodeId])) {
88 return $this->preloaded_children[$parentNodeId];
89 }
90
91 return [];
92 }
93
94 return $this->thread->getNestedSetPostChildren($parentNodeId, 1);
95 }

Referenced by getChildren().

+ Here is the caller graph for this function:

◆ getNodeContent()

ilForumExplorerGUI::getNodeContent (   $a_node)

@inheritDoc

Reimplemented from ilExplorerBaseGUI.

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

284 {
285 return $a_node['pos_subject'];
286 }

◆ getNodeHref()

ilForumExplorerGUI::getNodeHref (   $node)

@inheritDoc

Reimplemented from ilExplorerBaseGUI.

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

254 {
255 if ((int) $this->root_node->getId() === (int) $node['pos_pk']) {
256 return '';
257 }
258
259 $this->ctrl->setParameter($this->parent_obj, 'backurl', null);
260
261 if (isset($node['counter']) && $node['counter'] > 0) {
262 $page = (int) floor(($node['counter'] - 1) / $this->max_entries);
263 $this->ctrl->setParameter($this->parent_obj, 'page', $page);
264 }
265
266 if (isset($node['post_read']) && $node['post_read']) {
267 $this->ctrl->setParameter($this->parent_obj, 'pos_pk', null);
268 $url = $this->ctrl->getLinkTarget($this->parent_obj, $this->parent_cmd, $node['pos_pk'], false, false);
269 } else {
270 $this->ctrl->setParameter($this->parent_obj, 'pos_pk', $node['pos_pk']);
271 $url = $this->ctrl->getLinkTarget($this->parent_obj, 'markPostRead', $node['pos_pk'], false, false);
272 $this->ctrl->setParameter($this->parent_obj, 'pos_pk', null);
273 }
274
275 $this->ctrl->setParameter($this->parent_obj, 'page', null);
276
277 return $url;
278 }
$url

References $url.

◆ getNodeIcon()

ilForumExplorerGUI::getNodeIcon (   $node)

@inheritDoc

Reimplemented from ilExplorerBaseGUI.

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

242 {
243 if ((int) $this->root_node->getId() === (int) $node['pos_pk']) {
244 return ilObject::_getIcon(0, 'tiny', 'frm');
245 }
246
247 return $this->getAuthorInformationByNode($node)->getProfilePicture();
248 }

◆ getNodeId()

ilForumExplorerGUI::getNodeId (   $a_node)

@inheritDoc

Reimplemented from ilTreeExplorerGUI.

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

234 {
235 return $a_node['pos_pk'];
236 }

◆ getNodeStateToggleCmdClasses()

ilForumExplorerGUI::getNodeStateToggleCmdClasses (   $record)
protected

@inheritDoc

Reimplemented from ilTreeExplorerGUI.

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

204 : array
205 {
206 return [
207 'ilRepositoryGUI',
208 'ilObjForumGUI',
209 ];
210 }

◆ getTreeComponent()

ilForumExplorerGUI::getTreeComponent ( )

@inheritDoc

Reimplemented from ilTreeExplorerGUI.

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

147 : Tree
148 {
149 $rootNode = [
150 [
151 'pos_pk' => $this->root_node->getId(),
152 'pos_subject' => $this->root_node->getSubject(),
153 'pos_author_id' => $this->root_node->getPosAuthorId(),
154 'pos_display_user_id' => $this->root_node->getDisplayUserId(),
155 'pos_usr_alias' => $this->root_node->getUserAlias(),
156 'pos_date' => $this->root_node->getCreateDate(),
157 'import_name' => $this->root_node->getImportName(),
158 'post_read' => $this->root_node->isPostRead()
159 ]
160 ];
161
162 $tree = $this->ui->factory()->tree()
163 ->expandable($this->getTreeLabel(), $this)
164 ->withData($rootNode)
165 ->withHighlightOnNodeClick(false);
166
167 return $tree;
168 }
This describes a Tree Control.
Definition: Tree.php:14

References ilTreeExplorerGUI\$tree, getTreeLabel(), and ui().

+ Here is the call graph for this function:

◆ getTreeLabel()

ilForumExplorerGUI::getTreeLabel ( )
Returns
string

Reimplemented from ilTreeExplorerGUI.

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

140 {
141 return $this->lng->txt("frm_posts");
142 }

Referenced by getTreeComponent().

+ Here is the caller graph for this function:

◆ initPosting()

ilForumExplorerGUI::initPosting ( )
protected

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

71 : void
72 {
73 $postingId = (int) ($this->httpRequest->getParsedBody()['pos_pk'] ?? 0);
74 if (0 === $postingId) {
75 $postingId = (int) ($this->httpRequest->getQueryParams()['pos_pk'] ?? 0);
76 }
77
78 $this->currentPostingId = (int) $postingId;
79 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ preloadChilds()

ilForumExplorerGUI::preloadChilds ( )
protected

@inheritDoc

Reimplemented from ilTreeExplorerGUI.

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

109 {
110 $this->preloaded_children = [];
111 $this->node_id_to_parent_node_id_map = [];
112
113 $children = $this->thread->getNestedSetPostChildren($this->root_node->getId());
114
115 array_walk($children, function (&$node, $key) {
116 $this->node_id_to_parent_node_id_map[(int) $node['pos_pk']] = (int) $node['parent_pos'];
117
118 if (!array_key_exists((int) $node['pos_pk'], $this->preloaded_children)) {
119 $this->preloaded_children[(int) $node['pos_pk']] = [];
120 }
121
122 $this->preloaded_children[(int) $node['parent_pos']][$node['pos_pk']] = $node;
123 });
124
125 $this->preloaded = true;
126 }

◆ setCurrentPage()

ilForumExplorerGUI::setCurrentPage ( int  $currentPage)
Parameters
int$currentPage

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

100 : void
101 {
102 $this->currentPage = $currentPage;
103 }

References $currentPage.

Field Documentation

◆ $authorInformation

ilForumExplorerGUI::$authorInformation = []
protected

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

◆ $currentPage

ilForumExplorerGUI::$currentPage = 0
private

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

Referenced by setCurrentPage().

◆ $currentPostingId

ilForumExplorerGUI::$currentPostingId = 0
protected

Definition at line 32 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 = []
protected

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

◆ $preloaded_children

ilForumExplorerGUI::$preloaded_children = []
protected

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

◆ $root_node

ilForumExplorerGUI::$root_node
protected

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

◆ $thread

ilForumExplorerGUI::$thread
protected

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

Referenced by __construct().


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