ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilForumMoveTopicsExplorer.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 require_once 'Services/Repository/classes/class.ilRepositoryExplorer.php';
5 
6 /*
7 * ilForumMoveTopicsExplorer
8 *
9 * @author Michael Jansen <mjansen@databay.de>
10 *
11 */
13 {
14  public $root_id = 0;
15  public $output = '';
16  public $ctrl = null;
17 
18  private $checked_item = null;
19  private $post_var = '';
20  private $form_items = array();
21  private $excluded_obj_id = 0;
22 
29  public function __construct($a_target, $a_session_variable)
30  {
31  global $tree, $ilCtrl;
32 
33  $this->ctrl = $ilCtrl;
34 
35  parent::__construct($a_target);
36  $this->tree = $tree;
37  $this->root_id = $this->tree->readRootId();
38  $this->order_column = 'title';
39  $this->setSessionExpandVariable($a_session_variable);
40 
41  // reset filter
42  $this->filter = array();
43 
44  $this->addFilter('root');
45  $this->addFilter('crs');
46  $this->addFilter('grp');
47  $this->addFilter('cat');
48  $this->addFilter('fold');
49  $this->addFilter('frm');
50 
51  $this->addFormItemForType('frm');
52 
53  $this->setFiltered(true);
55  }
56 
57  public function isClickable($a_type, $a_ref_id, $a_obj_id = 0)
58  {
59  return false;
60  }
61 
62  public function addFormItemForType($type)
63  {
64  $this->form_items[$type] = true;
65  }
66  public function removeFormItemForType($type)
67  {
68  $this->form_items[$type] = false;
69  }
70  public function setCheckedItem($a_checked_item)
71  {
72  $this->checked_item = $a_checked_item;
73  }
74  public function isItemChecked($a_id)
75  {
76  return $this->checked_item == $a_id ? true : false;
77  }
78  public function setPostVar($a_post_var)
79  {
80  $this->post_var = $a_post_var;
81  }
82  public function getPostVar()
83  {
84  return $this->post_var;
85  }
86 
87  public function excludeObjIdFromSelection($a_obj_id)
88  {
89  $this->excluded_obj_id = $a_obj_id;
90 
91  return $this;
92  }
93 
94  public function getExcludeObjId()
95  {
97  }
98 
99  public function buildFormItem($a_node_id, $a_type)
100  {
101  global $ilObjDataCache, $ilAccess;
102 
103  if(!array_key_exists($a_type, $this->form_items) || !$this->form_items[$a_type]) return '';
104 
105  if($ilObjDataCache->lookupObjId($a_node_id) == $this->getExcludeObjId()) return '';
106 
107  if(!$ilAccess->checkAccess('moderate_frm', '', $a_node_id)) return '';
108 
109  return ilUtil::formRadioButton((int)$this->isItemChecked($a_node_id), $this->post_var, $a_node_id);
110  }
111 
112  function formatObject(&$tpl, $a_node_id, $a_option, $a_obj_id = 0)
113  {
114  global $lng;
115 
116  if (!isset($a_node_id) or !is_array($a_option))
117  {
118  $this->ilias->raiseError(get_class($this)."::formatObject(): Missing parameter or wrong datatype! ".
119  "node_id: ".$a_node_id." options:".var_dump($a_option),$this->ilias->error_obj->WARNING);
120  }
121 
122  $pic = false;
123  foreach ($a_option["tab"] as $picture)
124  {
125  if ($picture == 'plus')
126  {
127  $tpl->setCurrentBlock("exp_desc");
128  $tpl->setVariable("EXP_DESC", $lng->txt("expand"));
129  $tpl->parseCurrentBlock();
130  $target = $this->createTarget('+',$a_node_id);
131  $tpl->setCurrentBlock("expander");
132  $tpl->setVariable("LINK_NAME", $a_node_id);
133  $tpl->setVariable("LINK_TARGET_EXPANDER", $target);
134  $tpl->setVariable("IMGPATH", $this->getImage("browser/plus.png"));
135  $tpl->parseCurrentBlock();
136  $pic = true;
137  }
138 
139  if ($picture == 'minus' && $this->show_minus)
140  {
141  $tpl->setCurrentBlock("exp_desc");
142  $tpl->setVariable("EXP_DESC", $lng->txt("collapse"));
143  $tpl->parseCurrentBlock();
144  $target = $this->createTarget('-',$a_node_id);
145  $tpl->setCurrentBlock("expander");
146  $tpl->setVariable("LINK_NAME", $a_node_id);
147  $tpl->setVariable("LINK_TARGET_EXPANDER", $target);
148  $tpl->setVariable("IMGPATH", $this->getImage("browser/minus.png"));
149  $tpl->parseCurrentBlock();
150  $pic = true;
151  }
152  }
153 
154  if (!$pic)
155  {
156  $tpl->setCurrentBlock("blank");
157  $tpl->setVariable("BLANK_PATH", $this->getImage("browser/blank.png"));
158  $tpl->parseCurrentBlock();
159  }
160 
161  if ($this->output_icons)
162  {
163  $tpl->setCurrentBlock("icon");
164  $tpl->setVariable("ICON_IMAGE" , $this->getImage("icon_".$a_option["type"].".png", $a_option["type"], $a_obj_id));
165 
166  $tpl->setVariable("TARGET_ID" , "iconid_".$a_node_id);
167  $this->iconList[] = "iconid_".$a_node_id;
168  $tpl->setVariable("TXT_ALT_IMG", $lng->txt($a_option["desc"]));
169  $tpl->parseCurrentBlock();
170  }
171 
172  if(strlen($formItem = $this->buildFormItem($a_node_id, $a_option['type'])))
173  {
174  $tpl->setCurrentBlock('check');
175  $tpl->setVariable('OBJ_CHECK', $formItem);
176  $tpl->parseCurrentBlock();
177  }
178 
179  if ($this->isClickable($a_option["type"], $a_node_id,$a_obj_id)) // output link
180  {
181  $tpl->setCurrentBlock("link");
182  //$target = (strpos($this->target, "?") === false) ?
183  // $this->target."?" : $this->target."&";
184  //$tpl->setVariable("LINK_TARGET", $target.$this->target_get."=".$a_node_id.$this->params_get);
185  $tpl->setVariable("LINK_TARGET", $this->buildLinkTarget($a_node_id, $a_option["type"]));
186 
187  $style_class = $this->getNodeStyleClass($a_node_id, $a_option["type"]);
188 
189  if ($style_class != "")
190  {
191  $tpl->setVariable("A_CLASS", ' class="'.$style_class.'" ' );
192  }
193 
194  if (($onclick = $this->buildOnClick($a_node_id, $a_option["type"], $a_option["title"])) != "")
195  {
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, true));
203  $tpl->setVariable("DESC", ilUtil::shortenText(
204  $this->buildDescription($a_option["description"], $a_node_id, $a_option["type"]), $this->textwidth, true));
205  $frame_target = $this->buildFrameTarget($a_option["type"], $a_node_id, $a_option["obj_id"]);
206  if ($frame_target != "")
207  {
208  $tpl->setVariable("TARGET", " target=\"".$frame_target."\"");
209  }
210  $tpl->parseCurrentBlock();
211  }
212  else // output text only
213  {
214  $tpl->setCurrentBlock("text");
215  $tpl->setVariable("OBJ_TITLE", ilUtil::shortenText(
216  $this->buildTitle($a_option["title"], $a_node_id, $a_option["type"]), $this->textwidth, true));
217  $tpl->setVariable("OBJ_DESC", ilUtil::shortenText(
218  $this->buildDescription($a_option["desc"], $a_node_id, $a_option["type"]), $this->textwidth, true));
219  $tpl->parseCurrentBlock();
220  }
221 
222  $tpl->setCurrentBlock("list_item");
223  $tpl->parseCurrentBlock();
224  $tpl->touchBlock("element");
225  }
226 
227  /*
228  * overwritten method from base class
229  * @access public
230  * @param integer obj_id
231  * @param integer array options
232  * @return string
233  */
234  function formatHeader(&$tpl, $a_obj_id,$a_option)
235  {
236  global $lng, $ilias, $tree;
237 
238  // custom icons
239  $path = ilObject::_getIcon($a_obj_id, "small", "root");
240 
241 
242  $tpl->setCurrentBlock("icon");
243  $nd = $tree->getNodeData(ROOT_FOLDER_ID);
244  $title = $nd["title"];
245  if ($title == "ILIAS")
246  {
247  $title = $lng->txt("repository");
248  }
249 
250  $tpl->setVariable("ICON_IMAGE", $path);
251  $tpl->setVariable("TXT_ALT_IMG", $title);
252  $tpl->parseCurrentBlock();
253 
254  if(strlen($formItem = $this->buildFormItem($a_obj_id, $a_option['type'])))
255  {
256  $tpl->setCurrentBlock('check');
257  $tpl->setVariable('OBJ_CHECK', $formItem);
258  $tpl->parseCurrentBlock();
259  }
260 
261  $tpl->setVariable('OBJ_TITLE', $title);
262  }
263 }
264 ?>