ILIAS  release_8 Revision v8.24
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)
 
 getChildsOfNode ($a_parent_node_id)
 Get childs of node. More...
 
 getChildren ($record, $environment=null)
 Get a list of records (that list can also be empty). More...
 
 getTreeLabel ()
 
 getTreeComponent ()
 
 getNodeId ($a_node)
 Get id for node. More...
 
 getNodeIcon ($a_node)
 Get node icon path. More...
 
 getNodeHref ($a_node)
 Get href for node. More...
 
 getNodeContent ($a_node)
 Get content of a node. More...
 
- Public Member Functions inherited from ilTreeExplorerGUI
 __construct (string $a_expl_id, $a_parent_obj, string $a_parent_cmd, ilTree $a_tree, string $a_node_parameter_name="node_id")
 
 getTree ()
 
 setOrderField (string $a_val, bool $a_numeric=false)
 
 getOrderField ()
 
 setTypeWhiteList (array $a_val)
 Set type white list. More...
 
 getTypeWhiteList ()
 Get type white list. More...
 
 setTypeBlackList (array $a_val)
 Set type black list. More...
 
 getTypeBlackList ()
 Get type black list. More...
 
 setPreloadChilds (bool $a_val)
 
 getPreloadChilds ()
 
 getSuccessorNode ( $a_node_id, string $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 ($record, $environment=null)
 Get a list of records (that list can also be empty). More...
 
 build (\ILIAS\UI\Component\Tree\Node\Factory $factory, $record, $environment=null)
 
 getTreeLabel ()
 
 getTreeComponent ()
 
 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
 setChildLimit (int $a_val)
 
 getChildLimit ()
 
 setSearchTerm (string $a_val)
 
 getSearchTerm ()
 
 setMainTemplate (ilGlobalTemplateInterface $a_main_tpl=null)
 
 getRootNode ()
 Get root node. More...
 
 getChildsOfNode ($a_parent_node_id)
 Get children 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 children Please note that this standard method may not be optimal depending on what a derived class does in isNodeVisible. More...
 
 sortChilds (array $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 (bool $a_val)
 
 getSkipRootNode ()
 
 setAjax (bool $a_val)
 
 getAjax ()
 
 setSecondaryHighlightedNodes (array $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 (string $a_postvar, bool $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 (bool $a_val)
 
 getOfflineMode ()
 
 handleCommand ()
 Handle explorer internal command. More...
 
 getContainerId ()
 
 openNode ()
 Open node. More...
 
 closeNode ()
 Close node. More...
 
 getNodeAsync ()
 Get node asynchronously. More...
 
 beforeRendering ()
 Before rendering. More...
 
 getOnLoadCode ()
 Get on load code. More...
 
 getHTML ()
 
 renderNode ($a_node, ilTemplate $tpl)
 Render node. More...
 
 renderChilds ($a_node_id, ilTemplate $tpl)
 Render childs. More...
 
 getDomNodeIdForNodeId ($a_node_id)
 Get DOM node id for node id. More...
 
 getNodeIdForDomNodeId (string $a_dom_node_id)
 Get node id for dom node id. More...
 
 listItemStart (ilTemplate $tpl, $a_node)
 List item start. More...
 
 listItemEnd (ilTemplate $tpl)
 
 listStart (ilTemplate $tpl)
 
 listEnd (ilTemplate $tpl)
 
 isNodeOnclickEnabled ()
 
 setNodeOnclickEnabled (bool $nodeOnclickEnabled)
 
 isEnableDnd ()
 
 setEnableDnd (bool $enable_dnd)
 
- 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

 preloadChilds ()
 
 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...
 
- Protected Member Functions inherited from ilTreeExplorerGUI
 preloadChilds ()
 
 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 ()
 
- 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 ()
 
 isNodeRequested (string $a_node_id)
 

Private Member Functions

 getRootNodeId ()
 
 getAuthorInformationByNode (array $node)
 

Private Attributes

ilForumTopic $thread
 
ilForumPost $root_node
 
int $max_entries
 
array $preloaded_children = []
 
array $authorInformation = []
 

Additional Inherited Members

- Static Public Member Functions inherited from ilExplorerBaseGUI
static getLocalExplorerJsPath ()
 
static getLocalJsTreeJsPath ()
 
static getLocalJsTreeCssPath ()
 
static createHTMLExportDirs (string $a_target_dir)
 
static init (ilGlobalTemplateInterface $a_main_tpl=null)
 
- Protected Attributes inherited from ilTreeExplorerGUI
ilLanguage $lng
 
Psr Http Message ServerRequestInterface $httpRequest
 
ilTree $tree = null
 
string $tree_label = ""
 
string $order_field = ""
 
bool $order_field_numeric = false
 
array $type_white_list = array()
 
array $type_black_list = array()
 
array $childs = array()
 
bool $preloaded = false
 
bool $preload_childs = false
 
array $root_node_data = null
 
array $all_childs = array()
 
 $root_id = 0
 
ILIAS DI UIServices $ui
 
- Protected Attributes inherited from ilExplorerBaseGUI
string $node_parameter_name
 
ilLogger $log
 
ilCtrl $ctrl
 
ilGlobalTemplateInterface $tpl
 
bool $skip_root_node = false
 
bool $ajax = false
 
array $custom_open_nodes = array()
 
array $selected_nodes = array()
 
string $select_postvar = ""
 
bool $offline_mode = false
 
array $sec_highl_nodes = array()
 
bool $enable_dnd = false
 
string $search_term = ""
 
array $open_nodes = []
 
ilSessionIStorage $store
 
bool $select_multi = false
 
 $parent_obj
 
int $child_limit = 0
 
string $parent_cmd = ''
 
string $requested_exp_cmd = ""
 
string $requested_exp_cont = ""
 
string $requested_searchterm = ""
 
string $requested_node_id = ""
 
string $id
 
- Static Protected Attributes inherited from ilExplorerBaseGUI
static string $js_tree_path = "./node_modules/jstree/dist/jstree.js"
 
static string $js_tree_path_css = "./node_modules/jstree/dist/themes/default/style.min.css"
 
static string $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 27 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 
)

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

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

References $DIC, $thread, ILIAS\GlobalScreen\Provider\__construct(), ILIAS\Repository\ctrl(), 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

Creates at tree node, can be overwritten in derivatives if another node type should be used.

Reimplemented from ilTreeExplorerGUI.

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

140 $nodeIconPath = $this->getNodeIcon($record);
141
142 $icon = null;
143 if ($nodeIconPath !== '') {
144 $icon = $this->ui
145 ->factory()
146 ->symbol()
147 ->icon()
148 ->custom($nodeIconPath, $this->getNodeIconAlt($record));
149 }
150
151 if ((int) $record['pos_pk'] === $this->root_node->getId()) {
152 $node = $factory->simple($this->getNodeContent($record), $icon);
153 } else {
154 $authorInfo = $this->getAuthorInformationByNode($record);
155 $creationDate = ilDatePresentation::formatDate(new ilDateTime($record['pos_date'], IL_CAL_DATETIME));
156 $bylineString = $authorInfo->getAuthorShortName() . ', ' . $creationDate;
157
158 $node = $factory->bylined($this->getNodeContent($record), $bylineString, $icon);
159 }
160
161 return $node;
162 }
const IL_CAL_DATETIME
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
@classDescription Date and time handling
getNodeContent($a_node)
Get content of a node.
getAuthorInformationByNode(array $node)
getNodeIcon($a_node)
Get node icon path.
getNodeIconAlt($a_node)
Get node icon alt attribute.
This describes a Tree Node.
Definition: Node.php:31
$factory
Definition: metadata.php:75

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

+ Here is the call graph for this function:

◆ getAuthorInformationByNode()

ilForumExplorerGUI::getAuthorInformationByNode ( array  $node)
private

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

70 {
71 return $this->authorInformation[(int) $node['pos_pk']] ?? ($this->authorInformation[(int) $node['pos_pk']] = new ilForumAuthorInformation(
72 (int) ($node['pos_author_id'] ?? 0),
73 (int) $node['pos_display_user_id'],
74 (string) $node['pos_usr_alias'],
75 (string) $node['import_name']
76 ));
77 }

References ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ getChildren()

ilForumExplorerGUI::getChildren (   $record,
  $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.

Reimplemented from ilTreeExplorerGUI.

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

105 : array
106 {
107 return $this->getChildsOfNode((int) $record['pos_pk']);
108 }
getChildsOfNode($a_parent_node_id)
Get childs of node.

References getChildsOfNode().

+ Here is the call graph for this function:

◆ getChildsOfNode()

ilForumExplorerGUI::getChildsOfNode (   $a_parent_node_id)

Get childs of node.

Parameters
int | string$a_parent_node_idparent id
Returns
array childs

Reimplemented from ilTreeExplorerGUI.

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

79 : array
80 {
81 if ($this->preloaded) {
82 return $this->preloaded_children[$a_parent_node_id] ?? [];
83 }
84
85 return $this->thread->getNestedSetPostChildren($a_parent_node_id, 1);
86 }

Referenced by getChildren().

+ Here is the caller graph for this function:

◆ getNodeContent()

ilForumExplorerGUI::getNodeContent (   $a_node)

Get content of a node.

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

Reimplemented from ilExplorerBaseGUI.

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

213 : string
214 {
215 return $a_node['pos_subject'];
216 }

◆ getNodeHref()

ilForumExplorerGUI::getNodeHref (   $a_node)

Get href for node.

Parameters
object | array$a_node
Returns
string href attribute

Reimplemented from ilExplorerBaseGUI.

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

186 : string
187 {
188 if ($this->getRootNodeId() === (int) $a_node['pos_pk']) {
189 return '';
190 }
191
192 $this->ctrl->setParameter($this->parent_obj, 'backurl', null);
193
194 if (isset($a_node['counter']) && $a_node['counter'] > 0) {
195 $page = (int) floor(($a_node['counter'] - 1) / $this->max_entries);
196 $this->ctrl->setParameter($this->parent_obj, 'page', $page);
197 }
198
199 if (isset($a_node['post_read']) && $a_node['post_read']) {
200 $this->ctrl->setParameter($this->parent_obj, 'pos_pk', null);
201 $url = $this->ctrl->getLinkTarget($this->parent_obj, $this->parent_cmd, (string) $a_node['pos_pk']);
202 } else {
203 $this->ctrl->setParameter($this->parent_obj, 'pos_pk', $a_node['pos_pk']);
204 $url = $this->ctrl->getLinkTarget($this->parent_obj, 'markPostRead', (string) $a_node['pos_pk']);
205 $this->ctrl->setParameter($this->parent_obj, 'pos_pk', null);
206 }
207
208 $this->ctrl->setParameter($this->parent_obj, 'page', null);
209
210 return $url;
211 }
$url

References $url, ILIAS\Repository\ctrl(), and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ getNodeIcon()

ilForumExplorerGUI::getNodeIcon (   $a_node)

Get node icon path.

Parameters
object | array$a_node
Returns
string image file path

Reimplemented from ilExplorerBaseGUI.

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

177 : string
178 {
179 if ($this->getRootNodeId() === (int) $a_node['pos_pk']) {
180 return ilObject::_getIcon(0, 'tiny', 'frm');
181 }
182
183 return $this->getAuthorInformationByNode($a_node)->getProfilePicture();
184 }
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.

References ilObject\_getIcon().

+ Here is the call graph for this function:

◆ getNodeId()

ilForumExplorerGUI::getNodeId (   $a_node)

Get id for node.

Parameters
object | array$a_node
Returns
string

Reimplemented from ilTreeExplorerGUI.

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

172 : int
173 {
174 return (isset($a_node['pos_pk']) ? (int) $a_node['pos_pk'] : 0);
175 }

◆ getNodeStateToggleCmdClasses()

ilForumExplorerGUI::getNodeStateToggleCmdClasses (   $record)
protected

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.

Parameters
$record
Returns
array

Reimplemented from ilTreeExplorerGUI.

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

164 : array
165 {
166 return [
167 ilRepositoryGUI::class,
168 ilObjForumGUI::class,
169 ];
170 }

◆ getRootNodeId()

ilForumExplorerGUI::getRootNodeId ( )
private

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

64 : int
65 {
66 return $this->root_node->getId();
67 }

◆ getTreeComponent()

ilForumExplorerGUI::getTreeComponent ( )

Reimplemented from ilTreeExplorerGUI.

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

115 : Tree
116 {
117 $rootNode = [
118 [
119 'pos_pk' => $this->root_node->getId(),
120 'pos_subject' => $this->root_node->getSubject(),
121 'pos_author_id' => $this->root_node->getPosAuthorId(),
122 'pos_display_user_id' => $this->root_node->getDisplayUserId(),
123 'pos_usr_alias' => $this->root_node->getUserAlias(),
124 'pos_date' => $this->root_node->getCreateDate(),
125 'import_name' => $this->root_node->getImportName(),
126 'post_read' => $this->root_node->isPostRead()
127 ]
128 ];
129
130 return $this->ui->factory()->tree()
131 ->expandable($this->getTreeLabel(), $this)
132 ->withData($rootNode)
133 ->withHighlightOnNodeClick(false);
134 }
This describes a Tree Control.
Definition: Tree.php:29

References getTreeLabel(), and ILIAS\Repository\ui().

+ Here is the call graph for this function:

◆ getTreeLabel()

ilForumExplorerGUI::getTreeLabel ( )

Reimplemented from ilTreeExplorerGUI.

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

110 : string
111 {
112 return $this->lng->txt("frm_posts");
113 }

References ILIAS\Repository\lng().

Referenced by getTreeComponent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ preloadChilds()

ilForumExplorerGUI::preloadChilds ( )
protected

Reimplemented from ilTreeExplorerGUI.

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

88 : void
89 {
90 $this->preloaded_children = [];
91
92 $children = $this->thread->getNestedSetPostChildren($this->root_node->getId());
93
94 array_walk($children, function ($node, $key): void {
95 if (!array_key_exists((int) $node['pos_pk'], $this->preloaded_children)) {
96 $this->preloaded_children[(int) $node['pos_pk']] = [];
97 }
98
99 $this->preloaded_children[(int) $node['parent_pos']][$node['pos_pk']] = $node;
100 });
101
102 $this->preloaded = true;
103 }
string $key
Consumer key/client ID value.
Definition: System.php:193

References ILIAS\LTI\ToolProvider\$key, and ILIAS\Repository\int().

+ Here is the call graph for this function:

Field Documentation

◆ $authorInformation

array ilForumExplorerGUI::$authorInformation = []
private

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

◆ $max_entries

int ilForumExplorerGUI::$max_entries
private

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

◆ $preloaded_children

array ilForumExplorerGUI::$preloaded_children = []
private

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

◆ $root_node

ilForumPost ilForumExplorerGUI::$root_node
private

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

◆ $thread

ilForumTopic ilForumExplorerGUI::$thread
private

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

Referenced by __construct().


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