ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
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, $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  {
102  return '';
103  }
104 
105  include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsData.php';
107  $this->server_id,
108  $this->mid,
109  $this->tree_id,
110  $a_node_id
111  );
112 
113  if($status == ilECSCmsData::MAPPING_DELETED)
114  {
115  return ilUtil::formCheckbox((int)$this->isItemChecked($a_node_id), $this->post_var, $a_node_id,true);
116  }
117  switch($this->type)
118  {
119  case self::SEL_TYPE_CHECK:
120  return ilUtil::formCheckbox((int)$this->isItemChecked($a_node_id), $this->post_var, $a_node_id);
121  break;
122 
123  case self::SEL_TYPE_RADIO:
124  return ilUtil::formRadioButton((int)$this->isItemChecked($a_node_id), $this->post_var, $a_node_id);
125  break;
126  }
127  }
128 
129  function formatObject(&$tpl, $a_node_id, $a_option, $a_obj_id = 0)
130  {
131  global $lng;
132 
133  if (!isset($a_node_id) or !is_array($a_option))
134  {
135  $this->ilias->raiseError(get_class($this)."::formatObject(): Missing parameter or wrong datatype! ".
136  "node_id: ".$a_node_id." options:".var_dump($a_option),$this->ilias->error_obj->WARNING);
137  }
138 
139  $pic = false;
140  foreach ($a_option["tab"] as $picture)
141  {
142  if ($picture == 'plus')
143  {
144  $tpl->setCurrentBlock("exp_desc");
145  $tpl->setVariable("EXP_DESC", $lng->txt("expand"));
146  $tpl->parseCurrentBlock();
147  $target = $this->createTarget('+',$a_node_id);
148  $tpl->setCurrentBlock("expander");
149  $tpl->setVariable("LINK_NAME", $a_node_id);
150  $tpl->setVariable("LINK_TARGET_EXPANDER", $target);
151  $tpl->setVariable("IMGPATH", $this->getImage("browser/plus.png"));
152  $tpl->parseCurrentBlock();
153  $pic = true;
154  }
155 
156  if ($picture == 'minus' && $this->show_minus)
157  {
158  $tpl->setCurrentBlock("exp_desc");
159  $tpl->setVariable("EXP_DESC", $lng->txt("collapse"));
160  $tpl->parseCurrentBlock();
161  $target = $this->createTarget('-',$a_node_id);
162  $tpl->setCurrentBlock("expander");
163  $tpl->setVariable("LINK_NAME", $a_node_id);
164  $tpl->setVariable("LINK_TARGET_EXPANDER", $target);
165  $tpl->setVariable("IMGPATH", $this->getImage("browser/minus.png"));
166  $tpl->parseCurrentBlock();
167  $pic = true;
168  }
169  }
170 
171  if (!$pic)
172  {
173  $tpl->setCurrentBlock("blank");
174  $tpl->setVariable("BLANK_PATH", $this->getImage("browser/blank.png"));
175  $tpl->parseCurrentBlock();
176  }
177 
178  if ($this->output_icons)
179  {
180  $tpl->setCurrentBlock("icon");
181  $tpl->setVariable("ICON_IMAGE" , $this->getImage("icon_cat_s.png", $a_option["type"], $a_obj_id));
182 
183  $tpl->setVariable("TARGET_ID" , "iconid_".$a_node_id);
184  $this->iconList[] = "iconid_".$a_node_id;
185  $tpl->setVariable("TXT_ALT_IMG", $lng->txt($a_option["desc"]));
186  $tpl->parseCurrentBlock();
187  }
188 
189  if(strlen($formItem = $this->buildFormItem($a_node_id, $a_option['type'])))
190  {
191  $tpl->setCurrentBlock('check');
192  $tpl->setVariable('OBJ_CHECK', $formItem);
193  $tpl->parseCurrentBlock();
194  }
195 
196  if ($this->isClickable($a_option["type"], $a_node_id,$a_obj_id)) // output link
197  {
198  $tpl->setCurrentBlock("link");
199  //$target = (strpos($this->target, "?") === false) ?
200  // $this->target."?" : $this->target."&";
201  //$tpl->setVariable("LINK_TARGET", $target.$this->target_get."=".$a_node_id.$this->params_get);
202  $tpl->setVariable("LINK_TARGET", $this->buildLinkTarget($a_node_id, $a_option["type"]));
203 
204  $style_class = $this->getNodeStyleClass($a_node_id, $a_option["type"]);
205 
206  if ($style_class != "")
207  {
208  $tpl->setVariable("A_CLASS", ' class="'.$style_class.'" ' );
209  }
210 
211  if (($onclick = $this->buildOnClick($a_node_id, $a_option["type"], $a_option["title"])) != "")
212  {
213  $tpl->setVariable("ONCLICK", "onClick=\"$onclick\"");
214  }
215 
216  $tpl->setVariable("LINK_NAME", $a_node_id);
217  $tpl->setVariable("TITLE", ilUtil::shortenText(
218  $this->buildTitle($a_option["title"], $a_node_id, $a_option["type"]),
219  $this->textwidth, true));
220  $tpl->setVariable("DESC", ilUtil::shortenText(
221  $this->buildDescription($a_option["description"], $a_node_id, $a_option["type"]), $this->textwidth, true));
222  $frame_target = $this->buildFrameTarget($a_option["type"], $a_node_id, $a_option["obj_id"]);
223  if ($frame_target != "")
224  {
225  $tpl->setVariable("TARGET", " target=\"".$frame_target."\"");
226  }
227  $tpl->parseCurrentBlock();
228  }
229  else // output text only
230  {
231  $tpl->setCurrentBlock("text");
232  $tpl->setVariable("OBJ_TITLE", ilUtil::shortenText(
233  $this->buildTitle($a_option["title"], $a_node_id, $a_option["type"]), $this->textwidth, true));
234  $tpl->setVariable("OBJ_DESC", ilUtil::shortenText(
235  $this->buildDescription($a_option["desc"], $a_node_id, $a_option["type"]), $this->textwidth, true));
236  $tpl->parseCurrentBlock();
237  }
238 
239  $tpl->setCurrentBlock("list_item");
240  $tpl->parseCurrentBlock();
241  $tpl->touchBlock("element");
242  }
243 
244 
245 
246  /*
247  * overwritten method from base class
248  * @access public
249  * @param integer obj_id
250  * @param integer array options
251  * @return string
252  */
253  function formatHeader(&$tpl, $a_obj_id,$a_option)
254  {
255  global $lng, $ilias;
256 
257  // custom icons
258  $path = ilObject::_getIcon($a_obj_id, "tiny", "root");
259 
260 
261  $tpl->setCurrentBlock("icon");
262  $nd = $this->tree->getNodeData($this->getRoot());
263 
264  $title = $nd["title"];
265 
266  $tpl->setVariable("ICON_IMAGE", $path);
267  $tpl->setVariable("TXT_ALT_IMG", $title);
268  $tpl->parseCurrentBlock();
269 
270  if(strlen($formItem = $this->buildFormItem($a_obj_id, $a_option['type'])))
271  {
272  $tpl->setCurrentBlock('check');
273  $tpl->setVariable('OBJ_CHECK', $formItem);
274  $tpl->parseCurrentBlock();
275  }
276 
277  $tpl->setVariable('OBJ_TITLE', $this->buildTitle($title, $a_obj_id, ''));
278  }
279 
280  public function buildTitle($title, $a_obj_id, $a_type)
281  {
282  if(strlen($title) >= 22)
283  {
284  #$title = substr($title, 0,22).'...';
285  }
286 
287  include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsData.php';
289  $this->server_id,
290  $this->mid,
291  $this->tree_id,
292  $a_obj_id
293  );
294 
295 
296 
297  switch($status)
298  {
300  return '<font style="font-weight: bold">'.$title.'</font>';
301 
303  return '<font style="font-weight: bold;font-style: italic">'.$title.'</font>';
304 
306  return '<font style="font-style: italic">'.$title.'</font>';
307 
309  return $title;
310 
312  return '<font class="warning">'.$title.'</font>';
313 
314  default:
315  return $title;
316  }
317 
318  }
319 
320 
321 }
322 ?>