ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilECSNodeMappingCmsExplorer.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27{
28 public const SEL_TYPE_CHECK = 1;
29 public const SEL_TYPE_RADIO = 2;
30
31 private int $server_id;
32 private int $mid;
33 private int $tree_id;
34
35 private array $checked_items = array();
36 private string $post_var = '';
37 private array $form_items = array();
38 private int $type;
39
40 public function __construct(string $a_target, int $a_server_id, int $a_mid, int $a_tree_id)
41 {
42 parent::__construct($a_target);
43
44 $this->type = self::SEL_TYPE_CHECK;
45 $this->setOrderColumn('title');
46 $this->setTitleLength(1024);
47
48 // reset filter
49 $this->filter = array();
50 $this->addFormItemForType('');
51
52 $this->server_id = $a_server_id;
53 $this->mid = $a_mid;
54 $this->tree_id = $a_tree_id;
55 }
56
60 public function setTree(ilECSCmsTree $tree): void
61 {
62 $this->tree = $tree;
63 }
64
68 public function isClickable(string $type, int $ref_id = 0): bool
69 {
70 return false;
71 }
72
76 public function addFormItemForType($type): void
77 {
78 $this->form_items[$type] = true;
79 }
80
81 public function removeFormItemForType($type): void
82 {
83 $this->form_items[$type] = false;
84 }
85
86 public function setCheckedItems($a_checked_items = array()): void
87 {
88 $this->checked_items = $a_checked_items;
89 }
90
91 public function isItemChecked($a_id): bool
92 {
93 return in_array($a_id, $this->checked_items, true) ? true : false;
94 }
95
96 public function setPostVar($a_post_var): void
97 {
98 $this->post_var = $a_post_var;
99 }
100 public function getPostVar(): string
101 {
102 return $this->post_var;
103 }
104
105 public function buildFormItem($a_node_id, $a_type): string
106 {
107 if (!array_key_exists($a_type, $this->form_items) || !$this->form_items[$a_type]) {
108 return '';
109 }
110
112 $this->server_id,
113 $this->mid,
114 $this->tree_id,
115 $a_node_id
116 );
117
118 if ($status === ilECSCmsData::MAPPING_DELETED) {
120 $this->isItemChecked($a_node_id),
121 $this->post_var,
122 $a_node_id,
123 true
124 );
125 }
126 switch ($this->type) {
129 $this->isItemChecked($a_node_id),
130 $this->post_var,
131 $a_node_id
132 );
133 break;
134
137 $this->isItemChecked($a_node_id),
138 $this->post_var,
139 $a_node_id
140 );
141 break;
142 }
143
144 return '';
145 }
146
147 public function formatObject($tpl, $a_node_id, $a_option, $a_obj_id = 0): void
148 {
149 global $DIC;
150 if (!isset($a_node_id) || !is_array($a_option)) {
151 $this->error->raiseError(get_class($this) . "::formatObject(): Missing parameter or wrong datatype! " .
152 "node_id: " . $a_node_id . " options:" . print_r($a_option, true), $this->error->WARNING);
153 }
154
155 $pic = false;
156 foreach ($a_option["tab"] as $picture) {
157 if ($picture === 'plus') {
158 $tpl->setCurrentBlock("expander");
159 $tpl->setVariable("EXP_DESC", $this->lng->txt("expand"));
160 $target = $this->createTarget('+', $a_node_id);
161 $tpl->setVariable("LINK_NAME", $a_node_id);
162 $tpl->setVariable("LINK_TARGET_EXPANDER", $target);
163 $tpl->setVariable("IMGPATH", $this->getImage("browser/plus.png"));
165 $pic = true;
166 }
167
168 if ($picture === 'minus' && $this->show_minus) {
169 $tpl->setCurrentBlock("expander");
170 $tpl->setVariable("EXP_DESC", $this->lng->txt("collapse"));
171 $target = $this->createTarget('-', $a_node_id);
172 $tpl->setVariable("LINK_NAME", $a_node_id);
173 $tpl->setVariable("LINK_TARGET_EXPANDER", $target);
174 $tpl->setVariable("IMGPATH", $this->getImage("browser/minus.png"));
176 $pic = true;
177 }
178 }
179
180 if (!$pic) {
181 $tpl->setCurrentBlock("blank");
182 $tpl->setVariable("BLANK_PATH", $this->getImage("browser/blank.png"));
184 }
185
186 if ($this->output_icons) {
187 $tpl->setCurrentBlock("icon");
188 $tpl->setVariable("ICON_IMAGE", $this->getImage("standard/icon_cat.svg", $a_option["type"], $a_obj_id));
189
190 $tpl->setVariable("TARGET_ID", "iconid_" . $a_node_id);
191 $this->iconList[] = "iconid_" . $a_node_id;
192 $tpl->setVariable("TXT_ALT_IMG", $this->lng->txt($a_option["desc"]));
194 }
195
196 if ($formItem = ($this->buildFormItem($a_node_id, $a_option['type']) !== '')) {
197 $tpl->setCurrentBlock('check');
198 $tpl->setVariable('OBJ_CHECK', $formItem);
200 }
201
202 if ($this->isClickable($a_option["type"], $a_node_id)) { // output link
203 $tpl->setCurrentBlock("link");
204 //$target = (strpos($this->target, "?") === false) ?
205 // $this->target."?" : $this->target."&";
206 //$tpl->setVariable("LINK_TARGET", $target.$this->target_get."=".$a_node_id.$this->params_get);
207 $tpl->setVariable("LINK_TARGET", $this->buildLinkTarget($a_node_id, $a_option["type"]));
208
209 $style_class = $this->getNodeStyleClass($a_node_id, $a_option["type"]);
210
211 if ($style_class !== "") {
212 $tpl->setVariable("A_CLASS", ' class="' . $style_class . '" ');
213 }
214
215 if (($onclick = $this->buildOnClick($a_node_id, $a_option["type"], $a_option["title"])) !== "") {
216 $tpl->setVariable("ONCLICK", "onClick=\"$onclick\"");
217 }
218
219 $tpl->setVariable("LINK_NAME", $a_node_id);
221 "TITLE",
223 $this->buildTitle($a_option["title"], $a_node_id, $a_option["type"]),
224 $this->textwidth,
225 true
226 )
227 );
229 "DESC",
231 $this->buildDescription($a_option["description"], $a_node_id, $a_option["type"]),
232 $this->textwidth,
233 true
234 )
235 );
236 $frame_target = $this->buildFrameTarget($a_option["type"], $a_node_id, $a_option["obj_id"]);
237 if ($frame_target !== "") {
238 $tpl->setVariable("TARGET", " target=\"" . $frame_target . "\"");
239 }
240 } else { // output text only
241 $tpl->setCurrentBlock("text");
243 "OBJ_TITLE",
245 $this->buildTitle($a_option["title"], $a_node_id, $a_option["type"]),
246 $this->textwidth,
247 true
248 )
249 );
251 "OBJ_DESC",
253 $this->buildDescription($a_option["desc"], $a_node_id, $a_option["type"]),
254 $this->textwidth,
255 true
256 )
257 );
258 }
260
261 $tpl->setCurrentBlock("list_item");
263 $tpl->touchBlock("element");
264 }
265
266
267
268 /*
269 * overwritten method from base class
270 * @access public
271 * @param integer obj_id
272 * @param integer array options
273 * @return string
274 */
275 public function formatHeader(ilTemplate $tpl, $a_obj_id, array $a_option): void
276 {
277 // custom icons
278 $path = ilObject::_getIcon((int) $a_obj_id, "tiny", "root");
279
280
281 $tpl->setCurrentBlock("icon");
282 $nd = $this->tree->getNodeData($this->getRoot());
283
284 $title = $nd["title"];
285
286 $tpl->setVariable("ICON_IMAGE", $path);
287 $tpl->setVariable("TXT_ALT_IMG", $title);
289
290 if ($formItem = ($this->buildFormItem($a_obj_id, $a_option['type']) !== '')) {
291 $tpl->setCurrentBlock('check');
292 $tpl->setVariable('OBJ_CHECK', $formItem);
294 }
295
296 $tpl->setVariable('OBJ_TITLE', $this->buildTitle($title, $a_obj_id, ''));
297 }
298
299 public function buildTitle(string $a_title, $a_id, string $a_type): string
300 {
302 $this->server_id,
303 $this->mid,
304 $this->tree_id,
305 $a_id
306 );
307
308
309
310 switch ($status) {
312 return '<font style="font-weight: bold">' . $a_title . '</font>';
313
315 return '<font style="font-weight: bold;font-style: italic">' . $a_title . '</font>';
316
318 return '<font style="font-style: italic">' . $a_title . '</font>';
319
321 return '<font class="warning">' . $a_title . '</font>';
322
324 default:
325 return $a_title;
326 }
327 }
328}
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
error(string $a_errmsg)
return true
const MAPPING_PENDING_DISCONNECTABLE
const MAPPING_PENDING_NOT_DISCONNECTABLE
static lookupStatusByObjId(int $a_server_id, int $a_mid, int $a_tree_id, int $obj_id)
Lookup status.
__construct(string $a_target, int $a_server_id, int $a_mid, int $a_tree_id)
formatObject($tpl, $a_node_id, $a_option, $a_obj_id=0)
formatHeader(ilTemplate $tpl, $a_obj_id, array $a_option)
buildTitle(string $a_title, $a_id, string $a_type)
setTree(ilECSCmsTree $tree)
Set cms tree.
isClickable(string $type, int $ref_id=0)
no item is clickable
class for explorer view in admin frame
buildOnClick( $a_node_id, string $a_type, string $a_title)
setOrderColumn(string $a_column)
getNodeStyleClass( $a_id, string $a_type)
buildFrameTarget(string $a_type, $a_child=0, $a_obj_id=0)
buildDescription(string $a_desc, $a_id, string $a_type)
getImage(string $a_name, string $a_type="", $a_obj_id="")
setTitleLength(int $a_length)
buildLinkTarget( $a_node_id, string $a_type)
string $frame_target
createTarget(string $a_type, $a_node_id, bool $a_highlighted_subtree=false, bool $a_append_anch=true)
ilGlobalTemplateInterface $tpl
static formRadioButton(bool $checked, string $varname, string $value, ?string $onclick=null, bool $disabled=false)
static formCheckbox(bool $checked, string $varname, string $value, bool $disabled=false)
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
static shortenTextExtended(string $a_str, int $a_len, bool $a_dots=false, bool $a_next_blank=false, bool $a_keep_extension=false)
special template class to simplify handling of ITX/PEAR
$nd
Definition: error.php:30
setVariable(string $variable, $value='')
Sets the given variable to the given value.
touchBlock(string $block)
overwrites ITX::touchBlock.
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
$ref_id
Definition: ltiauth.php:66
$path
Definition: ltiservices.php:30
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
filter(string $filter_id, $class_path, string $cmd, bool $activated=true, bool $expanded=true)
global $DIC
Definition: shib_login.php:26