ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilMailExplorer.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3
7
15{
18
20 protected $currentFolderId = 0;
21
27 public function __construct($parentObject, $userId)
28 {
29 $this->parentObject = $parentObject;
30
31 $this->tree = new ilTree($userId);
32 $this->tree->setTableNames('mail_tree', 'mail_obj_data');
33
34 parent::__construct('mail_exp', $parentObject, '', $this->tree);
35
36 $this->initFolder();
37
38 $this->setSkipRootNode(true);
39 $this->setAjax(false);
40 $this->setOrderField('title,m_type');
41 }
42
46 protected function initFolder() : void
47 {
48 $folderId = (int) ($this->httpRequest->getParsedBody()['mobj_id'] ?? 0);
49 if (0 === $folderId) {
50 $folderId = (int) ($this->httpRequest->getQueryParams()['mobj_id'] ?? 0);
51 }
52
53 $this->currentFolderId = (int) $folderId;
54 }
55
59 public function getTreeLabel()
60 {
61 return $this->lng->txt("mail_folders");
62 }
63
67 public function getTreeComponent() : Tree
68 {
69 $f = $this->ui->factory();
70
71 $tree = $f->tree()
72 ->expandable($this->getTreeLabel(), $this)
73 ->withData($this->tree->getChilds((int) $this->tree->readRootId()))
74 ->withHighlightOnNodeClick(false);
75
76 return $tree;
77 }
78
82 public function build(
84 $record,
85 $environment = null
86 ) : Node {
87 $node = parent::build($factory, $record, $environment);
88
89 return $node->withHighlighted($this->currentFolderId === (int) $record['child']);
90 }
91
95 protected function getNodeStateToggleCmdClasses($record) : array
96 {
97 return [
98 'ilMailGUI',
99 ];
100 }
101
105 public function getNodeContent($node)
106 {
107 $content = $node['title'];
108
109 if ($node['child'] == $this->getNodeId($this->getRootNode())) {
110 $content = $this->lng->txt('mail_folders');
111 } elseif ($node['depth'] < 3) {
112 $content = $this->lng->txt('mail_' . $node['title']);
113 }
114
115 return $content;
116 }
117
118 public function getNodeIconAlt($a_node)
119 {
120 $content = $a_node['title'];
121
122 if ($a_node['child'] == $this->getNodeId($this->getRootNode())) {
123 $content = $this->lng->txt('mail_folders');
124 } elseif ($a_node['depth'] < 3) {
125 $content = $this->lng->txt('mail_' . $a_node['title']);
126 }
127
128 return $content;
129 }
130
134 public function getNodeIcon($node)
135 {
136 if ($node['child'] == $this->getNodeId($this->getRootNode())) {
137 $icon = ilUtil::getImagePath('icon_mail.svg');
138 } else {
139 $iconType = $node['m_type'];
140 if ($node['m_type'] === 'user_folder') {
141 $iconType = 'local';
142 }
143
144 $icon = ilUtil::getImagePath('icon_' . $iconType . '.svg');
145 }
146
147 return $icon;
148 }
149
153 public function getNodeHref($node)
154 {
155 if ($node['child'] == $this->getNodeId($this->getRootNode())) {
156 $node['child'] = 0;
157 }
158
159 $this->ctrl->setParameterByClass('ilMailFolderGUI', 'mobj_id', $node['child']);
160 $href = $this->ctrl->getLinkTargetByClass(['ilMailGUI', 'ilMailFolderGUI'], '', '', false, false);
161 $this->ctrl->clearParametersByClass('ilMailFolderGUI');
162
163 return $href;
164 }
165}
An exception for terminatinating execution or to throw for unit testing.
setSkipRootNode($a_val)
Set skip root node.
Class Mail Explorer class for explorer view for mailboxes.
build(Factory $factory, $record, $environment=null)
@inheritDoc
getNodeIcon($node)
@inheritDoc
getNodeContent($node)
@inheritDoc
getNodeIconAlt($a_node)
Get node icon alt attribute.
getNodeStateToggleCmdClasses($record)
@inheritDoc
getTreeComponent()
@inheritDoc
__construct($parentObject, $userId)
ilMailExplorer constructor.
getNodeHref($node)
@inheritDoc
Explorer class that works on tree objects (Services/Tree)
setOrderField($a_val, $a_numeric=false)
Set order field.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
This describes a Tree Node.
Definition: Node.php:16
This describes a Tree Control.
Definition: Tree.php:14
$factory
Definition: metadata.php:58
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
ui()
Definition: ui.php:5