00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 require_once("classes/class.ilMetaData.php");
00025 require_once("classes/class.ilMetaDataGUI.php");
00026
00037 class ilLMObjectGUI
00038 {
00039 var $ilias;
00040 var $tpl;
00041 var $lng;
00042 var $obj;
00043 var $objDefinition;
00044 var $ctrl;
00045 var $content_object;
00046 var $actions;
00047
00048
00054 function ilLMObjectGUI(&$a_content_obj)
00055 {
00056 global $ilias, $tpl, $lng, $objDefinition, $ilCtrl;
00057
00058 $this->ilias =& $ilias;
00059 $this->tpl =& $tpl;
00060 $this->lng =& $lng;
00061 $this->ctrl =& $ilCtrl;
00062 $this->objDefinition =& $objDefinition;
00063 $this->content_object =& $a_content_obj;
00064 }
00065
00066
00074 function setActions($a_actions = "")
00075 {
00076 if (is_array($a_actions))
00077 {
00078 foreach ($a_actions as $name => $lng)
00079 {
00080 $this->actions[$name] = array("name" => $name, "lng" => $lng);
00081 }
00082 }
00083 else
00084 {
00085 $this->actions = "";
00086 }
00087 }
00088
00089
00093 function addMeta()
00094 {
00095 $this->setTabs();
00096
00097 $meta_gui =& new ilMetaDataGUI();
00098 $meta_gui->setObject($this->obj);
00099 $meta_name = $_POST["meta_name"] ? $_POST["meta_name"] : $_GET["meta_name"];
00100 $meta_path = $_POST["meta_path"] ? $_POST["meta_path"] : $_GET["meta_path"];
00101 $meta_index = $_POST["meta_index"] ? $_POST["meta_index"] : $_GET["meta_index"];
00102 if ($meta_index == "")
00103 $meta_index = 0;
00104 $meta_section = $_POST["meta_section"] ? $_POST["meta_section"] : $_GET["meta_section"];
00105 if ($meta_name != "")
00106 {
00107 $meta_gui->meta_obj->add($meta_name, $meta_path, $meta_index);
00108 }
00109 else
00110 {
00111 sendInfo($this->lng->txt("meta_choose_element"));
00112 }
00113 $meta_gui->edit("ADM_CONTENT", "adm_content", $this->ctrl->getLinkTarget($this),
00114 $meta_section);
00115 }
00116
00117
00121 function deleteMeta()
00122 {
00123 $this->setTabs();
00124
00125 $meta_gui =& new ilMetaDataGUI();
00126 $meta_gui->setObject($this->obj);
00127 $meta_index = $_POST["meta_index"] ? $_POST["meta_index"] : $_GET["meta_index"];
00128 $meta_gui->meta_obj->delete($_GET["meta_name"], $_GET["meta_path"], $meta_index);
00129 $meta_gui->edit("ADM_CONTENT", "adm_content", $this->ctrl->getLinkTarget($this),
00130 $_GET["meta_section"]);
00131 }
00132
00133
00137 function chooseMetaSection()
00138 {
00139 $this->setTabs();
00140
00141 $meta_gui =& new ilMetaDataGUI();
00142 $meta_gui->setObject($this->obj);
00143 $meta_gui->edit("ADM_CONTENT", "adm_content", $this->ctrl->getLinkTarget($this),
00144 $_REQUEST["meta_section"]);
00145 }
00146
00147
00151 function editMeta()
00152 {
00153 $this->setTabs();
00154
00155 $meta_gui =& new ilMetaDataGUI();
00156 $meta_gui->setObject($this->obj);
00157 $meta_gui->edit("ADM_CONTENT", "adm_content", $this->ctrl->getLinkTarget($this),
00158 $_GET["meta_section"]);
00159 }
00160
00161
00165 function saveMeta()
00166 {
00167
00168 $meta_gui =& new ilMetaDataGUI();
00169 $meta_gui->setObject($this->obj);
00170
00171 $meta_gui->save($_POST["meta_section"]);
00172
00173
00174 sendInfo($this->lng->txt("msg_obj_modified"), true);
00175 $this->ctrl->redirect($this, "editMeta");
00176 }
00177
00178
00186 function getTargetFrame($a_cmd, $a_target_frame = "")
00187 {
00188 if ($this->target_frame[$a_cmd] != "")
00189 {
00190 return $this->target_frame[$a_cmd];
00191 }
00192 elseif (!empty($a_target_frame))
00193 {
00194 return "target=\"".$a_target_frame."\"";
00195 }
00196 else
00197 {
00198 return;
00199 }
00200 }
00201
00202
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00234 function getTemplateFile($a_cmd,$a_type = "")
00235 {
00236 if (!$a_type)
00237 {
00238 $a_type = $_GET["type"];
00239 }
00240
00241 $template = "tpl.".$a_type."_".$a_cmd.".html";
00242
00243 if (!$this->tpl->fileExists($template))
00244 {
00245 $template = "tpl.obj_".$a_cmd.".html";
00246 }
00247
00248 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", $template);
00249 }
00250
00251
00255 function create()
00256 {
00257 global $rbacsystem;
00258
00259 $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
00260
00261
00262 $data = array();
00263 $data["fields"] = array();
00264 $data["fields"]["title"] = $_SESSION["error_post_vars"]["Fobject"]["title"];
00265 $data["fields"]["desc"] = $_SESSION["error_post_vars"]["Fobject"]["desc"];
00266
00267 $this->getTemplateFile("edit",$new_type);
00268
00269 foreach ($data["fields"] as $key => $val)
00270 {
00271 $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
00272 $this->tpl->setVariable(strtoupper($key), $val);
00273
00274 if ($this->prepare_output)
00275 {
00276 $this->tpl->parseCurrentBlock();
00277 }
00278 }
00279 $this->ctrl->setParameter($this, "new_type", $new_type);
00280
00281
00282 $this->tpl->setVariable("FORMACTION",
00283 $this->ctrl->getFormAction($this, "", true));
00284 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
00285 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00286 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
00287 $this->tpl->setVariable("CMD_SUBMIT", "save");
00288 $this->tpl->setVariable("TARGET", $this->getTargetFrame("save"));
00289 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306 }
00307
00308
00312 function putInTree()
00313 {
00314 $tree = new ilTree($this->content_object->getId());
00315 $tree->setTableNames('lm_tree', 'lm_data');
00316 $tree->setTreeTablePK("lm_id");
00317
00318 $parent_id = (!empty($_GET["obj_id"]))
00319 ? $_GET["obj_id"]
00320 : $tree->getRootId();
00321
00322 if (!empty($_GET["target"]))
00323 {
00324 $target = $_GET["target"];
00325 }
00326 else
00327 {
00328
00329 $childs =& $tree->getChildsByType($parent_id, $this->obj->getType());
00330 if (count($childs) == 0)
00331 {
00332 $target = IL_FIRST_NODE;
00333 }
00334 else
00335 {
00336 $target = $childs[count($childs) - 1]["obj_id"];
00337 }
00338 }
00339 if (!$tree->isInTree($this->obj->getId()))
00340 {
00341 $tree->insertNode($this->obj->getId(), $parent_id, $target);
00342 }
00343 }
00344
00345
00349 function delete()
00350 {
00351 $this->setTabs();
00352
00353 $cont_obj_gui =& new ilObjContentObjectGUI("",$this->content_object->getRefId(),
00354 true, false);
00355 $cont_obj_gui->delete($this->obj->getId());
00356 }
00357
00358
00362 function cancelDelete()
00363 {
00364 session_unregister("saved_post");
00365 $this->ctrl->redirect($this, $_GET["backcmd"]);
00366 }
00367
00368
00372 function confirmedDelete()
00373 {
00374 $cont_obj_gui =& new ilObjContentObjectGUI("",$this->content_object->getRefId(),
00375 true, false);
00376 $cont_obj_gui->confirmedDelete($this->obj->getId());
00377 $this->ctrl->redirect($this, $_GET["backcmd"]);
00378 }
00379
00380
00386 function showPossibleSubObjects($a_type)
00387 {
00388 $d = $this->objDefinition->getCreatableSubObjects($a_type);
00389 if (count($d) > 0)
00390 {
00391 foreach ($d as $row)
00392 {
00393 $subobj[] = $row["name"];
00394 }
00395 }
00396
00397 if (is_array($subobj))
00398 {
00399
00400 $opts = ilUtil::formSelect(12,"new_type",$subobj);
00401
00402 $this->tpl->setCurrentBlock("add_object");
00403 $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
00404
00405 $this->tpl->setVariable("BTN_NAME", "create");
00406 $this->tpl->setVariable("TXT_ADD", $this->lng->txt("add"));
00407 $this->tpl->parseCurrentBlock();
00408 }
00409 }
00410
00414 function add_cell($val, $link = "")
00415 {
00416 if(!empty($link))
00417 {
00418 $this->tpl->setCurrentBlock("begin_link");
00419 $this->tpl->setVariable("LINK_TARGET", $link);
00420 $this->tpl->parseCurrentBlock();
00421 $this->tpl->touchBlock("end_link");
00422 }
00423
00424 $this->tpl->setCurrentBlock("text");
00425 $this->tpl->setVariable("TEXT_CONTENT", $val);
00426 $this->tpl->parseCurrentBlock();
00427 $this->tpl->setCurrentBlock("table_cell");
00428 $this->tpl->parseCurrentBlock();
00429 }
00430
00431
00437 function showActions()
00438 {
00439 $notoperations = array();
00440 $operations = array();
00441
00442 $operations = $this->actions;
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452 if (count($operations) > 0)
00453 {
00454 foreach ($operations as $val)
00455 {
00456 $this->tpl->setCurrentBlock("operation_btn");
00457 $this->tpl->setVariable("BTN_NAME", $val["lng"]);
00458 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt($val["lng"]));
00459 $this->tpl->parseCurrentBlock();
00460 }
00461
00462 $this->tpl->setCurrentBlock("operation");
00463 $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
00464 $this->tpl->parseCurrentBlock();
00465 }
00466 }
00467
00471 function checkTree()
00472 {
00473 $this->content_object->checkTree();
00474 }
00475 }
00476 ?>