• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

content/classes/class.ilLMObjectGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 
00035 class ilLMObjectGUI
00036 {
00037         var $ilias;
00038         var $tpl;
00039         var $lng;
00040         var $obj;
00041         var $objDefinition;
00042         var $ctrl;
00043         var $content_object;
00044         var $actions;
00045 
00046 
00052         function ilLMObjectGUI(&$a_content_obj)
00053         {
00054                 global $ilias, $tpl, $lng, $objDefinition, $ilCtrl;
00055 
00056                 $this->ilias =& $ilias;
00057                 $this->tpl =& $tpl;
00058                 $this->lng =& $lng;
00059                 $this->ctrl =& $ilCtrl;
00060                 $this->objDefinition =& $objDefinition;
00061                 $this->content_object =& $a_content_obj;
00062         }
00063 
00064 
00072         function setActions($a_actions = "")
00073         {
00074                 if (is_array($a_actions))
00075                 {
00076                         foreach ($a_actions as $name => $lng)
00077                         {
00078                                 $this->actions[$name] = array("name" => $name, "lng" => $lng);
00079                         }
00080                 }
00081                 else
00082                 {
00083                         $this->actions = "";
00084                 }
00085         }
00086 
00087 
00095         function getTargetFrame($a_cmd, $a_target_frame = "")
00096         {
00097                 if ($this->target_frame[$a_cmd] != "")
00098                 {
00099                         return $this->target_frame[$a_cmd];
00100                 }
00101                 elseif (!empty($a_target_frame))
00102                 {
00103                         return "target=\"".$a_target_frame."\"";
00104                 }
00105                 else
00106                 {
00107                         return;
00108                 }
00109         }
00110 
00119         function getTemplateFile($a_cmd,$a_type = "")
00120         {
00121                 if (!$a_type)
00122                 {
00123                         $a_type = $_GET["type"];
00124                 }
00125 
00126                 $template = "tpl.".$a_type."_".$a_cmd.".html";
00127 
00128                 if (!$this->tpl->fileExists($template))
00129                 {
00130                         $template = "tpl.obj_".$a_cmd.".html";
00131                 }
00132 
00133                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", $template);
00134         }
00135 
00136 
00140         function create()
00141         {
00142                 global $rbacsystem;
00143 
00144                 $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
00145 
00146                 // fill in saved values in case of error
00147                 $data = array();
00148                 $data["fields"] = array();
00149                 $data["fields"]["title"] = $_SESSION["error_post_vars"]["Fobject"]["title"];
00150                 $data["fields"]["desc"] = $_SESSION["error_post_vars"]["Fobject"]["desc"];
00151 
00152                 $this->getTemplateFile("edit",$new_type);
00153 
00154                 foreach ($data["fields"] as $key => $val)
00155                 {
00156                         $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
00157                         $this->tpl->setVariable(strtoupper($key), $val);
00158 
00159                         if ($this->prepare_output)
00160                         {
00161                                 $this->tpl->parseCurrentBlock();
00162                         }
00163                 }
00164                 $this->ctrl->setParameter($this, "new_type", $new_type);
00165 //echo "<br>lmobjectgui_formaction";
00166 //echo ":".$this->ctrl->getFormAction($this, "", true).":";
00167                 $this->tpl->setVariable("FORMACTION",
00168                         $this->ctrl->getFormAction($this, "", true));
00169                 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
00170                 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00171                 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
00172                 $this->tpl->setVariable("CMD_SUBMIT", "save");
00173                 $this->tpl->setVariable("TARGET", $this->getTargetFrame("save"));
00174                 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00175 
00176         }
00177 
00178 
00182         function putInTree()
00183         {
00184                 $tree = new ilTree($this->content_object->getId());
00185                 $tree->setTableNames('lm_tree', 'lm_data');
00186                 $tree->setTreeTablePK("lm_id");
00187 
00188                 $parent_id = (!empty($_GET["obj_id"]))
00189                         ? $_GET["obj_id"]
00190                         : $tree->getRootId();
00191 
00192                 if (!empty($_GET["target"]))
00193                 {
00194                         $target = $_GET["target"];
00195                 }
00196                 else
00197                 {
00198                         // determine last child of current type
00199                         $childs =& $tree->getChildsByType($parent_id, $this->obj->getType());
00200                         if (count($childs) == 0)
00201                         {
00202                                 $target = IL_FIRST_NODE;
00203                         }
00204                         else
00205                         {
00206                                 $target = $childs[count($childs) - 1]["obj_id"];
00207                         }
00208                 }
00209                 if (!$tree->isInTree($this->obj->getId()))
00210                 {
00211                         $tree->insertNode($this->obj->getId(), $parent_id, $target);
00212                 }
00213         }
00214 
00215 
00219         function delete()
00220         {
00221                 $this->setTabs();
00222 
00223                 $cont_obj_gui =& new ilObjContentObjectGUI("",$this->content_object->getRefId(),
00224                         true, false);
00225                 $cont_obj_gui->delete($this->obj->getId());
00226         }
00227 
00228 
00232         function cancelDelete()
00233         {
00234                 session_unregister("saved_post");
00235                 $this->ctrl->redirect($this, $_GET["backcmd"]);
00236         }
00237 
00238 
00242         function confirmedDelete()
00243         {
00244                 $cont_obj_gui =& new ilObjContentObjectGUI("",$this->content_object->getRefId(),
00245                         true, false);
00246                 $cont_obj_gui->confirmedDelete($this->obj->getId());
00247                 $this->ctrl->redirect($this, $_GET["backcmd"]);
00248         }
00249 
00250 
00256         function showPossibleSubObjects($a_type)
00257         {
00258                 $d = $this->objDefinition->getCreatableSubObjects($a_type);
00259                 if (count($d) > 0)
00260                 {
00261                         foreach ($d as $row)
00262                         {
00263                                 $subobj[] = $row["name"];
00264                         }
00265                 }
00266 
00267                 if (is_array($subobj))
00268                 {
00269                         //build form
00270                         $opts = ilUtil::formSelect(12,"new_type",$subobj);
00271                         //$this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
00272                         $this->tpl->setCurrentBlock("add_object");
00273                         $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
00274                         //$this->tpl->setVariable("FORMACTION_OBJ_ADD", "adm_object.php?cmd=create&ref_id=".$_GET["ref_id"]);
00275                         $this->tpl->setVariable("BTN_NAME", "create");
00276                         $this->tpl->setVariable("TXT_ADD", $this->lng->txt("add"));
00277                         $this->tpl->parseCurrentBlock();
00278                 }
00279         }
00280 
00284         function add_cell($val, $link = "")
00285         {
00286                 if(!empty($link))
00287                 {
00288                         $this->tpl->setCurrentBlock("begin_link");
00289                         $this->tpl->setVariable("LINK_TARGET", $link);
00290                         $this->tpl->parseCurrentBlock();
00291                         $this->tpl->touchBlock("end_link");
00292                 }
00293 
00294                 $this->tpl->setCurrentBlock("text");
00295                 $this->tpl->setVariable("TEXT_CONTENT", $val);
00296                 $this->tpl->parseCurrentBlock();
00297                 $this->tpl->setCurrentBlock("table_cell");
00298                 $this->tpl->parseCurrentBlock();
00299         }
00300 
00301 
00307         function showActions()
00308         {
00309                 $notoperations = array();
00310                 $operations = array();
00311 
00312                 $operations = $this->actions;
00313 
00314                 if (count($operations) > 0)
00315                 {
00316                         foreach ($operations as $val)
00317                         {
00318                                 $this->tpl->setCurrentBlock("operation_btn");
00319                                 $this->tpl->setVariable("BTN_NAME", $val["lng"]);
00320                                 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt($val["lng"]));
00321                                 $this->tpl->parseCurrentBlock();
00322                         }
00323 
00324                         $this->tpl->setCurrentBlock("operation");
00325                         $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
00326                         $this->tpl->parseCurrentBlock();
00327                 }
00328         }
00329 
00333         function checkTree()
00334         {
00335                 $this->content_object->checkTree();
00336         }
00337 }
00338 ?>

Generated on Fri Dec 13 2013 10:18:29 for ILIAS Release_3_5_x_branch .rev 46805 by  doxygen 1.7.1