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

content/classes/class.ilObjSAHSLearningModuleGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2005 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 require_once "classes/class.ilObjectGUI.php";
00025 require_once("classes/class.ilFileSystemGUI.php");
00026 require_once("classes/class.ilTabsGUI.php");
00027 
00037 class ilObjSAHSLearningModuleGUI extends ilObjectGUI
00038 {
00044         function ilObjSAHSLearningModuleGUI($a_data,$a_id,$a_call_by_reference, $a_prepare_output = true)
00045         {
00046                 global $lng;
00047 
00048                 $lng->loadLanguageModule("content");
00049                 $this->type = "sahs";
00050                 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output);
00051                 $this->tabs_gui =& new ilTabsGUI();
00052 
00053         }
00054 
00058         function executeCommand()
00059         {
00060                 $this->fs_gui =& new ilFileSystemGUI($this->object->getDataDirectory());
00061                 $this->getTemplate();
00062                 $this->setLocator();
00063                 $this->setTabs();
00064 
00065                 $next_class = $this->ctrl->getNextClass($this);
00066                 $cmd = $this->ctrl->getCmd();
00067 
00068                 switch($next_class)
00069                 {
00070                         case 'ilmdeditorgui':
00071 
00072                                 include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
00073 
00074                                 $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
00075                                 $md_gui->addObserver($this->object,'MDUpdateListener','General');
00076 
00077                                 $this->ctrl->forwardCommand($md_gui);
00078                                 break;
00079 
00080                         case "ilfilesystemgui":
00081                                 //$ret =& $this->fs_gui->executeCommand();
00082                                 $ret =& $this->ctrl->forwardCommand($this->fs_gui);
00083                                 break;
00084 
00085                         default:
00086                                 $cmd = $this->ctrl->getCmd("frameset");
00087                                 $ret =& $this->$cmd();
00088                                 break;
00089                 }
00090                 $this->tpl->show();
00091         }
00092 
00093 
00094         function viewObject()
00095         {
00096                 //add template for view button
00097                 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00098 
00099                 // view button
00100                 $this->tpl->setCurrentBlock("btn_cell");
00101                 $this->tpl->setVariable("BTN_LINK","content/sahs_presentation.php?ref_id=".$this->object->getRefID());
00102                 $this->tpl->setVariable("BTN_TARGET"," target=\"ilContObj".$this->object->getID()."\" ");
00103                 $this->tpl->setVariable("BTN_TXT",$this->lng->txt("view"));
00104                 $this->tpl->parseCurrentBlock();
00105 
00106                 // view button
00107                 $this->tpl->setCurrentBlock("btn_cell");
00108                 $this->tpl->setVariable("BTN_LINK","content/sahs_edit.php?ref_id=".$this->object->getRefID());
00109                 $this->tpl->setVariable("BTN_TARGET"," target=\"bottom\" ");
00110                 $this->tpl->setVariable("BTN_TXT",$this->lng->txt("edit"));
00111                 $this->tpl->parseCurrentBlock();
00112         }
00113 
00117         function properties()
00118         {
00119         }
00120 
00124         function saveProperties()
00125         {
00126         }
00127 
00128 
00132         function createObject()
00133         {
00134                 $this->importObject();
00135         }
00136 
00142         function importObject()
00143         {
00144                 // display import form
00145                 // print_r($this->lng);
00146                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.slm_import.html");
00147                 $this->tpl->setVariable("FORMACTION", $this->getFormAction("save","adm_object.php?cmd=gateway&ref_id=".
00148                         $_GET["ref_id"]."&new_type=sahs"));
00149 
00150                 $this->tpl->setVariable("BTN_NAME", "save");
00151 
00152                 $this->tpl->setVariable("TXT_SELECT_LMTYPE", $this->lng->txt("type"));
00153                 $this->tpl->setVariable("TXT_TYPE_AICC", $this->lng->txt("lm_type_aicc"));
00154                 $this->tpl->setVariable("TXT_TYPE_HACP", $this->lng->txt("lm_type_hacp"));
00155                 $this->tpl->setVariable("TXT_TYPE_SCORM", $this->lng->txt("lm_type_scorm"));
00156 
00157                 $this->tpl->setVariable("TXT_UPLOAD", $this->lng->txt("upload"));
00158                 $this->tpl->setVariable("TXT_IMPORT_LM", $this->lng->txt("import_lm"));
00159                 $this->tpl->setVariable("TXT_SELECT_FILE", $this->lng->txt("select_file"));
00160                 $this->tpl->setVariable("TXT_VALIDATE_FILE", $this->lng->txt("cont_validate_file"));
00161 
00162                 // get the value for the maximal uploadable filesize from the php.ini (if available)
00163                 $umf=get_cfg_var("upload_max_filesize");
00164                 // get the value for the maximal post data from the php.ini (if available)
00165                 $pms=get_cfg_var("post_max_size");
00166 
00167                 // use the smaller one as limit
00168                 $max_filesize=min($umf, $pms);
00169                 if (!$max_filesize) $max_filesize=max($umf, $pms);
00170                 // gives out the limit as a littel notice :)
00171                 $this->tpl->setVariable("TXT_FILE_INFO", $this->lng->txt("file_notice")." $max_filesize.");
00172         }
00173 
00180         function uploadObject()
00181         {
00182                 global $_FILES, $rbacsystem;
00183 
00184                 // check if file was uploaded
00185                 $source = $_FILES["scormfile"]["tmp_name"];
00186                 if (($source == 'none') || (!$source))
00187                 {
00188                         $this->ilias->raiseError("No file selected!",$this->ilias->error_obj->MESSAGE);
00189                 }
00190                 // check create permission
00191                 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], "sahs"))
00192                 {
00193                         $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->WARNING);
00194                 }
00195                 // get_cfg_var("upload_max_filesize"); // get the may filesize form t he php.ini
00196                 switch ($__FILES["scormfile"]["error"])
00197                 {
00198                         case UPLOAD_ERR_INI_SIZE:
00199                                 $this->ilias->raiseError($this->lng->txt("err_max_file_size_exceeds"),$this->ilias->error_obj->MESSAGE);
00200                                 break;
00201 
00202                         case UPLOAD_ERR_FORM_SIZE:
00203                                 $this->ilias->raiseError($this->lng->txt("err_max_file_size_exceeds"),$this->ilias->error_obj->MESSAGE);
00204                                 break;
00205 
00206                         case UPLOAD_ERR_PARTIAL:
00207                                 $this->ilias->raiseError($this->lng->txt("err_partial_file_upload"),$this->ilias->error_obj->MESSAGE);
00208                                 break;
00209 
00210                         case UPLOAD_ERR_NO_FILE:
00211                                 $this->ilias->raiseError($this->lng->txt("err_no_file_uploaded"),$this->ilias->error_obj->MESSAGE);
00212                                 break;
00213                 }
00214 
00215                 $file = pathinfo($_FILES["scormfile"]["name"]);
00216                 $name = substr($file["basename"], 0, strlen($file["basename"]) - strlen($file["extension"]) - 1);
00217                 if ($name == "")
00218                 {
00219                         $name = $this->lng->txt("no_title");
00220                 }
00221 
00222                 // create and insert object in objecttree
00223                 switch ($_POST["sub_type"])
00224                 {
00225                         case "scorm":
00226                                 include_once("content/classes/class.ilObjSCORMLearningModule.php");
00227                                 $newObj = new ilObjSCORMLearningModule();
00228                                 break;
00229 
00230                         case "aicc":
00231                                 include_once("content/classes/class.ilObjAICCLearningModule.php");
00232                                 $newObj = new ilObjAICCLearningModule();
00233                                 break;
00234 
00235                         case "hacp":
00236                                 include_once("content/classes/class.ilObjHACPLearningModule.php");
00237                                 $newObj = new ilObjHACPLearningModule();
00238                                 break;
00239                 }
00240 
00241                 //$newObj->setType("slm");
00242                 //$dummy_meta =& new ilMetaData();
00243                 //$dummy_meta->setObject($newObj);
00244                 //$newObj->assignMetaData($dummy_meta);
00245                 $newObj->setTitle($name);
00246                 $newObj->setSubType($_POST["sub_type"]);
00247                 $newObj->setDescription("");
00248                 $newObj->create();
00249                 $newObj->createReference();
00250                 $newObj->putInTree($_GET["ref_id"]);
00251                 $newObj->setPermissions($_GET["ref_id"]);
00252                 $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
00253 
00254                 // create data directory, copy file to directory
00255                 $newObj->createDataDirectory();
00256 
00257                 // copy uploaded file to data directory
00258                 $file_path = $newObj->getDataDirectory()."/".$_FILES["scormfile"]["name"];
00259                 
00260                 ilUtil::moveUploadedFile($_FILES["scormfile"]["tmp_name"],
00261                         $_FILES["scormfile"]["name"], $file_path);
00262 
00263                 //move_uploaded_file($_FILES["scormfile"]["tmp_name"], $file_path);
00264 
00265                 ilUtil::unzip($file_path);
00266                 ilUtil::renameExecutables($newObj->getDataDirectory());
00267 
00268                 $newObj->readObject();
00269 
00270         }
00271 
00272         function upload()
00273         {
00274                 $this->uploadObject();
00275         }
00276 
00280         function saveObject()
00281         {
00282                 global $rbacadmin;
00283 
00284                 $this->uploadObject();
00285 
00286                 sendInfo( $this->lng->txt("lm_added"), true);
00287                 ilUtil::redirect($this->getReturnLocation("save","adm_object.php?".$this->link_params));
00288 
00289         }
00290 
00294         function perm()
00295         {
00296                 $this->setFormAction("permSave", "sahs_edit.php?cmd=permSave&ref_id=".$_GET["ref_id"].
00297                         "&obj_id=".$_GET["obj_id"]);
00298                 $this->setFormAction("addRole", "sahs_edit.php?ref_id=".$_GET["ref_id"].
00299                         "&obj_id=".$_GET["obj_id"]."&cmd=addRole");
00300                 $this->permObject();
00301         }
00302 
00306         function info()
00307         {
00308                 $this->infoObject();
00309         }
00310 
00314         function permSave()
00315         {
00316                 $this->setReturnLocation("permSave",
00317                         "sahs_edit.php?ref_id=".$_GET["ref_id"]."&obj_id=".$_GET["obj_id"]."&cmd=perm");
00318                 $this->permSaveObject();
00319         }
00320 
00324         function addRole()
00325         {
00326                 $this->setReturnLocation("addRole",
00327                         "sahs_edit.php?ref_id=".$_GET["ref_id"]."&obj_id=".$_GET["obj_id"]."&cmd=perm");
00328                 $this->addRoleObject();
00329         }
00330 
00334         function owner()
00335         {
00336                 $this->ownerObject();
00337         }
00338 
00343 /*
00344         function chooseMetaSectionObject($a_target = "")
00345         {
00346                 if ($a_target == "")
00347                 {
00348                         $a_target = "adm_object.php?ref_id=".$this->object->getRefId();
00349                 }
00350 
00351                 include_once "classes/class.ilMetaDataGUI.php";
00352                 $meta_gui =& new ilMetaDataGUI();
00353                 $meta_gui->setObject($this->object);
00354                 $meta_gui->edit("ADM_CONTENT", "adm_content",
00355                         $a_target, $_REQUEST["meta_section"]);
00356         }
00357 */
00362 /*
00363         function chooseMetaSection()
00364         {
00365                 $this->chooseMetaSectionObject($this->ctrl->getLinkTarget($this));
00366         }
00367 */
00368 
00373 /*
00374         function addMetaObject($a_target = "")
00375         {
00376                 if ($a_target == "")
00377                 {
00378                         $a_target = "adm_object.php?ref_id=".$this->object->getRefId();
00379                 }
00380 
00381                 include_once "classes/class.ilMetaDataGUI.php";
00382                 $meta_gui =& new ilMetaDataGUI();
00383                 $meta_gui->setObject($this->object);
00384                 $meta_name = $_POST["meta_name"] ? $_POST["meta_name"] : $_GET["meta_name"];
00385                 $meta_index = $_POST["meta_index"] ? $_POST["meta_index"] : $_GET["meta_index"];
00386                 if ($meta_index == "")
00387                         $meta_index = 0;
00388                 $meta_path = $_POST["meta_path"] ? $_POST["meta_path"] : $_GET["meta_path"];
00389                 $meta_section = $_POST["meta_section"] ? $_POST["meta_section"] : $_GET["meta_section"];
00390                 if ($meta_name != "")
00391                 {
00392                         $meta_gui->meta_obj->add($meta_name, $meta_path, $meta_index);
00393                 }
00394                 else
00395                 {
00396                         sendInfo($this->lng->txt("meta_choose_element"), true);
00397                 }
00398                 $meta_gui->edit("ADM_CONTENT", "adm_content", $a_target, $meta_section);
00399         }
00400 */
00401 
00406 /*
00407         function addMeta()
00408         {
00409                 $this->addMetaObject($this->ctrl->getLinkTarget($this));
00410         }
00411 */
00412 
00417 /*
00418         function deleteMetaObject($a_target = "")
00419         {
00420                 if ($a_target == "")
00421                 {
00422                         $a_target = "adm_object.php?ref_id=".$this->object->getRefId();
00423                 }
00424 
00425                 include_once "classes/class.ilMetaDataGUI.php";
00426                 $meta_gui =& new ilMetaDataGUI();
00427                 $meta_gui->setObject($this->object);
00428                 $meta_index = $_POST["meta_index"] ? $_POST["meta_index"] : $_GET["meta_index"];
00429                 $meta_gui->meta_obj->delete($_GET["meta_name"], $_GET["meta_path"], $meta_index);
00430                 $meta_gui->edit("ADM_CONTENT", "adm_content", $a_target, $_GET["meta_section"]);
00431         }
00432 */
00433 
00438 /*
00439         function deleteMeta()
00440         {
00441                 $this->deleteMetaObject($this->ctrl->getLinkTarget($this));
00442         }
00443 */
00444 
00449 /*
00450         function editMetaObject($a_target = "")
00451         {
00452                 if ($a_target == "")
00453                 {
00454                         $a_target = "adm_object.php?ref_id=".$this->object->getRefId();
00455                 }
00456 
00457                 include_once "classes/class.ilMetaDataGUI.php";
00458                 $meta_gui =& new ilMetaDataGUI();
00459                 $meta_gui->setObject($this->object);
00460                 $meta_gui->edit("ADM_CONTENT", "adm_content", $a_target, $_GET["meta_section"]);
00461         }
00462 */
00463 
00468 /*
00469         function editMeta()
00470         {
00471                 $this->editMetaObject($this->ctrl->getLinkTarget($this));
00472         }
00473 */
00474 
00479 /*
00480         function saveMetaObject($a_target = "")
00481         {
00482                 if ($a_target == "")
00483                 {
00484                         $a_target = "adm_object.php?cmd=editMeta&ref_id=".$this->object->getRefId();
00485                 }
00486 
00487                 include_once "classes/class.ilMetaDataGUI.php";
00488                 $meta_gui =& new ilMetaDataGUI();
00489                 $meta_gui->setObject($this->object);
00490                 $meta_gui->save($_POST["meta_section"]);
00491                 ilUtil::redirect(ilUtil::appendUrlParameterString($a_target,
00492                         "meta_section=" . $_POST["meta_section"]));
00493         }
00494 */
00495 
00500 /*
00501         function saveMeta()
00502         {
00503                 $this->saveMetaObject($this->ctrl->getLinkTarget($this, "editMeta"));
00504         }
00505 */
00506 
00507 
00511         function getTemplate()
00512         {
00513                 global $lng;
00514 
00515                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
00516                 //$this->tpl->setVariable("HEADER", $a_header_title);
00517                 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00518                 //$this->tpl->setVariable("TXT_LOCATOR",$this->lng->txt("locator"));
00519         }
00520 
00521 
00527         function frameset()
00528         {
00529                 $this->tpl = new ilTemplate("tpl.sahs_edit_frameset.html", false, false, "content");
00530                 $this->tpl->setVariable("REF_ID",$this->ref_id);
00531                 $this->tpl->show();
00532         }
00533 
00537         function setLocator($a_tree = "", $a_id = "", $scriptname="adm_object.php")
00538         {
00539                 global $ilias_locator, $tree;
00540                 if (!defined("ILIAS_MODULE"))
00541                 {
00542                         parent::setLocator();
00543                 }
00544                 else
00545                 {
00546                         $a_tree =& $tree;
00547                         $a_id = $_GET["ref_id"];
00548 
00549                         $this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html");
00550 
00551                         $path = $a_tree->getPathFull($a_id);
00552 
00553                         // this is a stupid workaround for a bug in PEAR:IT
00554                         $modifier = 1;
00555 
00556                         if (!empty($_GET["obj_id"]))
00557                         {
00558                                 $modifier = 0;
00559                         }
00560 
00561                         // ### AA 03.11.10 added new locator GUI class ###
00562                         $i = 1;
00563 
00564                         if ($this->object->getType() != "grp" && ($_GET["cmd"] == "delete" || $_GET["cmd"] == "edit"))
00565                         {
00566                                 unset($path[count($path) - 1]);
00567                         }
00568 
00569                         foreach ($path as $key => $row)
00570                         {
00571 
00572                                 if ($key < count($path) - $modifier)
00573                                 {
00574                                         $this->tpl->touchBlock("locator_separator");
00575                                 }
00576 
00577                                 $this->tpl->setCurrentBlock("locator_item");
00578                                 if ($row["child"] != $a_tree->getRootId())
00579                                 {
00580                                         $this->tpl->setVariable("ITEM", $row["title"]);
00581                                 }
00582                                 else
00583                                 {
00584                                         $this->tpl->setVariable("ITEM", $this->lng->txt("repository"));
00585                                 }
00586                                 if($row["type"] == "sahs")
00587                                 {
00588                                         $this->tpl->setVariable("LINK_ITEM", "sahs_edit.php?ref_id=".$row["child"]."&type=".$row["type"]);
00589                                 }
00590                                 else
00591                                 {
00592                                         $this->tpl->setVariable("LINK_ITEM", "../repository.php?cmd=frameset&ref_id=".$row["child"]);
00593                                         $t_frame = ilFrameTargetInfo::_getFrame("MainContent");
00594                                         $this->tpl->setVariable("LINK_TARGET", " target=\"$t_frame\" ");
00595                                 }
00596                                 //$this->tpl->setVariable("LINK_TARGET", " target=\"bottom\" ");
00597 
00598                                 $this->tpl->parseCurrentBlock();
00599 
00600                                 $this->tpl->setCurrentBlock("locator");
00601 
00602                                 // ### AA 03.11.10 added new locator GUI class ###
00603                                 // navigate locator
00604                                 if ($row["child"] != $a_tree->getRootId())
00605                                 {
00606                                         $ilias_locator->navigate($i++,$row["title"],"../repository.php?ref_id=".$row["child"],"bottom");
00607                                 }
00608                                 else
00609                                 {
00610                                         $ilias_locator->navigate($i++,$this->lng->txt("repository"),"../repository.php?ref_id=".$row["child"],"bottom");
00611                                 }
00612                         }
00613 
00614                         $this->tpl->setVariable("TXT_LOCATOR",$debug.$this->lng->txt("locator"));
00615                         $this->tpl->parseCurrentBlock();
00616                 }
00617 
00618         }
00619 
00620 
00624         function setTabs()
00625         {
00626                 $this->getTabs($this->tabs_gui);
00627                 $this->tpl->setVariable("TABS", $this->tabs_gui->getHTML());
00628                 $this->tpl->setVariable("HEADER", $this->object->getTitle());
00629         }
00630 
00636         function getTabs(&$tabs_gui)
00637         {
00638                 global $rbacsystem;
00639                 
00640                 if ($this->ctrl->getCmd() == "delete")
00641                 {
00642                         return;
00643                 }
00644 
00645                 // properties
00646                 $tabs_gui->addTarget("properties",
00647                         $this->ctrl->getLinkTarget($this, "properties"), "properties",
00648                         get_class($this));
00649 
00650                 // file system gui tabs
00651                 if (is_object($this->fs_gui))
00652                 {
00653                         $this->fs_gui->getTabs($tabs_gui);
00654                 }
00655 
00656                 // tracking data
00657                 $tabs_gui->addTarget("cont_tracking_data",
00658                         $this->ctrl->getLinkTarget($this, "showTrackingItems"), "showTrackingItems",
00659                         get_class($this));
00660 
00661                 // edit meta
00662 /*
00663                 $tabs_gui->addTarget("meta_data",
00664                         $this->ctrl->getLinkTarget($this, "editMeta"), "editMeta",
00665                         get_class($this));
00666 */
00667                 $tabs_gui->addTarget("meta_data",
00668                          $this->ctrl->getLinkTargetByClass('ilmdeditorgui',''),
00669                          "meta_data", get_class($this));
00670 
00671                 // perm
00672                 if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
00673                 {
00674                         $tabs_gui->addTarget("perm_settings",
00675                                 $this->ctrl->getLinkTarget($this, "perm"), array("perm", "info"),
00676                                 get_class($this));
00677                 }
00678 
00679                 // owner
00680 /*
00681                 $tabs_gui->addTarget("owner",
00682                         $this->ctrl->getLinkTarget($this, "owner"), "owner",
00683                         get_class($this));
00684 */
00685         }
00686 
00687 
00688 
00689 } // END class.ilObjSAHSLearningModule
00690 ?>

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