ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilECSNodeMappingCmsExplorer.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once './Services/UIComponent/Explorer/classes/class.ilExplorer.php';
5 
13 {
14  const SEL_TYPE_CHECK = 1;
15  const SEL_TYPE_RADIO = 2;
16 
17  private $server_id;
18  private $mid;
19  private $tree_id;
20 
21  private $checked_items = array();
22  private $post_var = '';
23  private $form_items = array();
24  private $type = 0;
25 
26  public function __construct($a_target, $a_server_id, $a_mid, $a_tree_id)
27  {
28  global $tree;
29 
30  parent::__construct($a_target);
31 
32  $this->type = self::SEL_TYPE_CHECK;
33  $this->setOrderColumn('title');
34  $this->setTitleLength(1024);
35 
36  // reset filter
37  $this->filter = array();
38  $this->addFormItemForType('');
39 
40  $this->server_id = $a_server_id;
41  $this->mid = $a_mid;
42  $this->tree_id = $a_tree_id;
43  }
44 
48  public function setTree(ilECSCmsTree $tree)
49  {
50  $this->tree = $tree;
51  }
52 
60  public function isClickable($a_type, $a_ref_id = 0, $a_obj_id = 0)
61  {
62  return false;
63  }
64 
69  public function addFormItemForType($type)
70  {
71  $this->form_items[$type] = true;
72  }
73 
74  public function removeFormItemForType($type)
75  {
76  $this->form_items[$type] = false;
77  }
78 
79  public function setCheckedItems($a_checked_items = array())
80  {
81  $this->checked_items = $a_checked_items;
82  }
83 
84  public function isItemChecked($a_id)
85  {
86  return in_array($a_id, $this->checked_items) ? true : false;
87  }
88 
89  public function setPostVar($a_post_var)
90  {
91  $this->post_var = $a_post_var;
92  }
93  public function getPostVar()
94  {
95  return $this->post_var;
96  }
97 
98  public function buildFormItem($a_node_id, $a_type)
99  {
100  if (!array_key_exists($a_type, $this->form_items) || !$this->form_items[$a_type]) {
101  return '';
102  }
103 
104  include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsData.php';
106  $this->server_id,
107  $this->mid,
108  $this->tree_id,
109  $a_node_id
110  );
111 
112  if ($status == ilECSCmsData::MAPPING_DELETED) {
113  return ilUtil::formCheckbox((int) $this->isItemChecked($a_node_id), $this->post_var, $a_node_id, true);
114  }
115  switch ($this->type) {
116  case self::SEL_TYPE_CHECK:
117  return ilUtil::formCheckbox((int) $this->isItemChecked($a_node_id), $this->post_var, $a_node_id);
118  break;
119 
120  case self::SEL_TYPE_RADIO:
121  return ilUtil::formRadioButton((int) $this->isItemChecked($a_node_id), $this->post_var, $a_node_id);
122  break;
123  }
124  }
125 
126  public function formatObject($tpl, $a_node_id, $a_option, $a_obj_id = 0)
127  {
128  global $lng;
129 
130  if (!isset($a_node_id) or !is_array($a_option)) {
131  $this->ilias->raiseError(get_class($this) . "::formatObject(): Missing parameter or wrong datatype! " .
132  "node_id: " . $a_node_id . " options:" . var_dump($a_option), $this->ilias->error_obj->WARNING);
133  }
134 
135  $pic = false;
136  foreach ($a_option["tab"] as $picture) {
137  if ($picture == 'plus') {
138  $tpl->setCurrentBlock("expander");
139  $tpl->setVariable("EXP_DESC", $lng->txt("expand"));
140  $target = $this->createTarget('+', $a_node_id);
141  $tpl->setVariable("LINK_NAME", $a_node_id);
142  $tpl->setVariable("LINK_TARGET_EXPANDER", $target);
143  $tpl->setVariable("IMGPATH", $this->getImage("browser/plus.png"));
144  $tpl->parseCurrentBlock();
145  $pic = true;
146  }
147 
148  if ($picture == 'minus' && $this->show_minus) {
149  $tpl->setCurrentBlock("expander");
150  $tpl->setVariable("EXP_DESC", $lng->txt("collapse"));
151  $target = $this->createTarget('-', $a_node_id);
152  $tpl->setVariable("LINK_NAME", $a_node_id);
153  $tpl->setVariable("LINK_TARGET_EXPANDER", $target);
154  $tpl->setVariable("IMGPATH", $this->getImage("browser/minus.png"));
155  $tpl->parseCurrentBlock();
156  $pic = true;
157  }
158  }
159 
160  if (!$pic) {
161  $tpl->setCurrentBlock("blank");
162  $tpl->setVariable("BLANK_PATH", $this->getImage("browser/blank.png"));
163  $tpl->parseCurrentBlock();
164  }
165 
166  if ($this->output_icons) {
167  $tpl->setCurrentBlock("icon");
168  $tpl->setVariable("ICON_IMAGE", $this->getImage("icon_cat.svg", $a_option["type"], $a_obj_id));
169 
170  $tpl->setVariable("TARGET_ID", "iconid_" . $a_node_id);
171  $this->iconList[] = "iconid_" . $a_node_id;
172  $tpl->setVariable("TXT_ALT_IMG", $lng->txt($a_option["desc"]));
173  $tpl->parseCurrentBlock();
174  }
175 
176  if (strlen($formItem = $this->buildFormItem($a_node_id, $a_option['type']))) {
177  $tpl->setCurrentBlock('check');
178  $tpl->setVariable('OBJ_CHECK', $formItem);
179  $tpl->parseCurrentBlock();
180  }
181 
182  if ($this->isClickable($a_option["type"], $a_node_id, $a_obj_id)) { // output link
183  $tpl->setCurrentBlock("link");
184  //$target = (strpos($this->target, "?") === false) ?
185  // $this->target."?" : $this->target."&";
186  //$tpl->setVariable("LINK_TARGET", $target.$this->target_get."=".$a_node_id.$this->params_get);
187  $tpl->setVariable("LINK_TARGET", $this->buildLinkTarget($a_node_id, $a_option["type"]));
188 
189  $style_class = $this->getNodeStyleClass($a_node_id, $a_option["type"]);
190 
191  if ($style_class != "") {
192  $tpl->setVariable("A_CLASS", ' class="' . $style_class . '" ');
193  }
194 
195  if (($onclick = $this->buildOnClick($a_node_id, $a_option["type"], $a_option["title"])) != "") {
196  $tpl->setVariable("ONCLICK", "onClick=\"$onclick\"");
197  }
198 
199  $tpl->setVariable("LINK_NAME", $a_node_id);
200  $tpl->setVariable("TITLE", ilUtil::shortenText(
201  $this->buildTitle($a_option["title"], $a_node_id, $a_option["type"]),
202  $this->textwidth,
203  true
204  ));
205  $tpl->setVariable("DESC", ilUtil::shortenText(
206  $this->buildDescription($a_option["description"], $a_node_id, $a_option["type"]),
207  $this->textwidth,
208  true
209  ));
210  $frame_target = $this->buildFrameTarget($a_option["type"], $a_node_id, $a_option["obj_id"]);
211  if ($frame_target != "") {
212  $tpl->setVariable("TARGET", " target=\"" . $frame_target . "\"");
213  }
214  $tpl->parseCurrentBlock();
215  } else { // output text only
216  $tpl->setCurrentBlock("text");
217  $tpl->setVariable("OBJ_TITLE", ilUtil::shortenText(
218  $this->buildTitle($a_option["title"], $a_node_id, $a_option["type"]),
219  $this->textwidth,
220  true
221  ));
222  $tpl->setVariable("OBJ_DESC", ilUtil::shortenText(
223  $this->buildDescription($a_option["desc"], $a_node_id, $a_option["type"]),
224  $this->textwidth,
225  true
226  ));
227  $tpl->parseCurrentBlock();
228  }
229 
230  $tpl->setCurrentBlock("list_item");
231  $tpl->parseCurrentBlock();
232  $tpl->touchBlock("element");
233  }
234 
235 
236 
237  /*
238  * overwritten method from base class
239  * @access public
240  * @param integer obj_id
241  * @param integer array options
242  * @return string
243  */
244  public function formatHeader($tpl, $a_obj_id, $a_option)
245  {
246  global $lng, $ilias;
247 
248  // custom icons
249  $path = ilObject::_getIcon($a_obj_id, "tiny", "root");
250 
251 
252  $tpl->setCurrentBlock("icon");
253  $nd = $this->tree->getNodeData($this->getRoot());
254 
255  $title = $nd["title"];
256 
257  $tpl->setVariable("ICON_IMAGE", $path);
258  $tpl->setVariable("TXT_ALT_IMG", $title);
259  $tpl->parseCurrentBlock();
260 
261  if (strlen($formItem = $this->buildFormItem($a_obj_id, $a_option['type']))) {
262  $tpl->setCurrentBlock('check');
263  $tpl->setVariable('OBJ_CHECK', $formItem);
264  $tpl->parseCurrentBlock();
265  }
266 
267  $tpl->setVariable('OBJ_TITLE', $this->buildTitle($title, $a_obj_id, ''));
268  }
269 
270  public function buildTitle($title, $a_obj_id, $a_type)
271  {
272  if (strlen($title) >= 22) {
273  #$title = substr($title, 0,22).'...';
274  }
275 
276  include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsData.php';
278  $this->server_id,
279  $this->mid,
280  $this->tree_id,
281  $a_obj_id
282  );
283 
284 
285 
286  switch ($status) {
288  return '<font style="font-weight: bold">' . $title . '</font>';
289 
291  return '<font style="font-weight: bold;font-style: italic">' . $title . '</font>';
292 
294  return '<font style="font-style: italic">' . $title . '</font>';
295 
297  return $title;
298 
300  return '<font class="warning">' . $title . '</font>';
301 
302  default:
303  return $title;
304  }
305  }
306 }
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
const MAPPING_PENDING_DISCONNECTABLE
formatObject($tpl, $a_node_id, $a_option, $a_obj_id=0)
static shortenText( $a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
buildFrameTarget($a_type, $a_child=0, $a_obj_id=0)
get frame target (may be overwritten by derived classes)
getNodeStyleClass($a_id, $a_type)
get style class for node
buildLinkTarget($a_node_id, $a_type)
get link target (may be overwritten by derived classes)
static lookupStatusByObjId($a_server_id, $a_mid, $a_tree_id, $obj_id)
Lookup status.
setTitleLength($a_length)
Set max title length.
isClickable($a_type, $a_ref_id=0, $a_obj_id=0)
no item is clickable
setOrderColumn($a_column)
set the order column public
createTarget($a_type, $a_node_id, $a_highlighted_subtree=false, $a_append_anch=true)
Creates Get Parameter private.
buildOnClick($a_node_id, $a_type, $a_title)
get onclick event handling (may be overwritten by derived classes)
$a_type
Definition: workflow.php:92
$nd
Definition: error.php:10
__construct($a_target, $a_server_id, $a_mid, $a_tree_id)
getRoot()
get root id
redirection script todo: (a better solution should control the processing via a xml file) ...
Create styles array
The data for the language used.
static formRadioButton($checked, $varname, $value, $onclick=null, $disabled=false)
??? public
Class ilExplorer class for explorer view in admin frame.
getImage($a_name, $a_type="", $a_obj_id="")
get image path (may be overwritten by derived classes)
const MAPPING_PENDING_NOT_DISCONNECTABLE
buildDescription($a_desc, $a_id, $a_type)
standard implementation for description, may be overwritten by derived classes
static formCheckbox($checked, $varname, $value, $disabled=false)
??? public
setTree(ilECSCmsTree $tree)
Set cms tree.