/**
  * execute command
  */
 function &executeCommand()
 {
     global $ilTabs, $lng, $ilAccess, $tpl, $ilCtrl;
     if ($this->ctrl->getRedirectSource() == "ilinternallinkgui") {
         $this->explorer();
         return;
     }
     $next_class = $this->ctrl->getNextClass($this);
     $cmd = $this->ctrl->getCmd();
     $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
     if ($new_type != "" && ($cmd != "confirmRemove" && $cmd != "copyToClipboard" && $cmd != "pasteFromClipboard")) {
         $this->setCreationMode(true);
     }
     if (!$this->getCreationMode()) {
         $tree =& $this->object->getTree();
         if ($_GET["mepitem_id"] == "") {
             $_GET["mepitem_id"] = $tree->getRootId();
         }
     }
     if ($cmd == "create") {
         switch ($_POST["new_type"]) {
             case "mob":
                 $this->ctrl->redirectByClass("ilobjmediaobjectgui", "create");
                 break;
             case "fold":
                 // todo
                 $this->ctrl->redirectByClass("ilobjfoldergui", "create");
                 break;
         }
     }
     switch ($next_class) {
         case 'ilmediapoolpagegui':
             $this->prepareOutput();
             $this->addHeaderAction();
             $this->setMediaPoolPageTabs();
             include_once "./Modules/MediaPool/classes/class.ilMediaPoolPageGUI.php";
             $mep_page_gui = new ilMediaPoolPageGUI($_GET["mepitem_id"], $_GET["old_nr"]);
             if (!$ilAccess->checkAccess("write", "", $this->object->getRefId())) {
                 $mep_page_gui->setEnableEditing(false);
             }
             $ret = $this->ctrl->forwardCommand($mep_page_gui);
             if ($ret != "") {
                 $tpl->setContent($ret);
             }
             $this->tpl->show();
             break;
         case "ilobjmediaobjectgui":
             //$cmd.="Object";
             if ($cmd == "create" || $cmd == "save" || $cmd == "cancel") {
                 $ret_obj = $_GET["mepitem_id"];
                 $ilObjMediaObjectGUI =& new ilObjMediaObjectGUI("", 0, false, false);
                 $ilObjMediaObjectGUI->setWidthPreset($this->object->getDefaultWidth());
                 $ilObjMediaObjectGUI->setHeightPreset($this->object->getDefaultHeight());
             } else {
                 $ret_obj = $tree->getParentId($_GET["mepitem_id"]);
                 $ilObjMediaObjectGUI =& new ilObjMediaObjectGUI("", ilMediaPoolItem::lookupForeignId($_GET["mepitem_id"]), false, false);
                 $this->ctrl->setParameter($this, "mepitem_id", $this->getParentFolderId());
                 $ilTabs->setBackTarget($lng->txt("back"), $this->ctrl->getLinkTarget($this, $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia"));
             }
             if ($this->ctrl->getCmdClass() == "ilinternallinkgui") {
                 $this->ctrl->setReturn($this, "explorer");
             } else {
                 $this->ctrl->setParameter($this, "mepitem_id", $ret_obj);
                 $this->ctrl->setReturn($this, $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia");
                 $this->ctrl->setParameter($this, "mepitem_id", $_GET["mepitem_id"]);
             }
             $this->getTemplate();
             $ilObjMediaObjectGUI->setTabs();
             $this->setLocator();
             //$ret =& $ilObjMediaObjectGUI->executeCommand();
             $ret = $this->ctrl->forwardCommand($ilObjMediaObjectGUI);
             if ($cmd == "save" && $ret != false) {
                 $mep_item = new ilMediaPoolItem();
                 $mep_item->setTitle($ret->getTitle());
                 $mep_item->setType("mob");
                 $mep_item->setForeignId($ret->getId());
                 $mep_item->create();
                 $parent = $_GET["mepitem_id"] == "" ? $tree->getRootId() : $_GET["mepitem_id"];
                 $tree->insertNode($mep_item->getId(), $parent);
                 ilUtil::redirect("ilias.php?baseClass=ilMediaPoolPresentationGUI&cmd=listMedia&ref_id=" . $_GET["ref_id"] . "&mepitem_id=" . $_GET["mepitem_id"]);
             } else {
                 $this->tpl->show();
             }
             break;
         case "ilobjfoldergui":
             // todo
             $this->addHeaderAction();
             $folder_gui = new ilObjFolderGUI("", 0, false, false);
             $this->ctrl->setReturn($this, "listMedia");
             $cmd .= "Object";
             switch ($cmd) {
                 case "createObject":
                     $this->prepareOutput();
                     $folder_gui =& new ilObjFolderGUI("", 0, false, false);
                     $folder_gui->setFormAction("save", $this->ctrl->getFormActionByClass("ilobjfoldergui"));
                     $folder_gui->createObject();
                     $this->tpl->show();
                     break;
                 case "saveObject":
                     //$folder_gui->setReturnLocation("save", $this->ctrl->getLinkTarget($this, "listMedia"));
                     $parent = $_GET["mepitem_id"] == "" ? $tree->getRootId() : $_GET["mepitem_id"];
                     $folder_gui->setFolderTree($tree);
                     $folder_gui->saveObject($parent);
                     //$this->ctrl->redirect($this, "listMedia");
                     break;
                 case "editObject":
                     $this->prepareOutput();
                     $folder_gui =& new ilObjFolderGUI("", ilMediaPoolItem::lookupForeignId($_GET["mepitem_id"]), false, false);
                     $this->ctrl->setParameter($this, "foldereditmode", "1");
                     $folder_gui->setFormAction("update", $this->ctrl->getFormActionByClass("ilobjfoldergui"));
                     $folder_gui->editObject();
                     $this->tpl->show();
                     break;
                 case "updateObject":
                     $folder_gui =& new ilObjFolderGUI("", ilMediaPoolItem::lookupForeignId($_GET["mepitem_id"]), false, false);
                     $this->ctrl->setParameter($this, "mepitem_id", $this->getParentFolderId());
                     $this->ctrl->setReturn($this, "listMedia");
                     $folder_gui->updateObject(true);
                     // this returns to parent
                     break;
                 case "cancelObject":
                     if ($_GET["foldereditmode"]) {
                         $this->ctrl->setParameter($this, "mepitem_id", $this->getParentFolderId());
                     }
                     $this->ctrl->redirect($this, "listMedia");
                     break;
             }
             break;
         case "ileditclipboardgui":
             $this->prepareOutput();
             $this->addHeaderAction();
             $this->ctrl->setReturn($this, $_GET["mep_mode"] ? $_GET["mep_mode"] : "listMedia");
             $clip_gui = new ilEditClipboardGUI();
             $clip_gui->setMultipleSelections(true);
             $clip_gui->setInsertButtonTitle($lng->txt("mep_copy_to_mep"));
             $ilTabs->setTabActive("clipboard");
             //$ret =& $clip_gui->executeCommand();
             $ret =& $this->ctrl->forwardCommand($clip_gui);
             $this->tpl->show();
             break;
         case 'ilinfoscreengui':
             $this->prepareOutput();
             $this->addHeaderAction();
             $this->infoScreen();
             $this->tpl->show();
             break;
         case 'ilpermissiongui':
             $this->prepareOutput();
             $this->addHeaderAction();
             include_once "Services/AccessControl/classes/class.ilPermissionGUI.php";
             $perm_gui =& new ilPermissionGUI($this);
             $ret =& $this->ctrl->forwardCommand($perm_gui);
             $this->tpl->show();
             break;
         case "ilexportgui":
             $this->prepareOutput();
             $this->addHeaderAction();
             include_once "./Services/Export/classes/class.ilExportGUI.php";
             $exp_gui = new ilExportGUI($this);
             $exp_gui->addFormat("xml");
             $ret = $this->ctrl->forwardCommand($exp_gui);
             $this->tpl->show();
             break;
         case "ilfilesystemgui":
             $this->prepareOutput();
             $this->addHeaderAction();
             $ilTabs->clearTargets();
             $ilTabs->setBackTarget($lng->txt("back"), $ilCtrl->getLinkTarget($this, "listMedia"));
             $mset = new ilSetting("mobs");
             if (trim($mset->get("upload_dir")) != "") {
                 include_once "./Services/FileSystem/classes/class.ilFileSystemGUI.php";
                 $fs_gui = new ilFileSystemGUI($mset->get("upload_dir"));
                 $fs_gui->setPostDirPath(true);
                 $fs_gui->setTableId("mepud" . $this->object->getId());
                 $fs_gui->setAllowFileCreation(false);
                 $fs_gui->setAllowDirectoryCreation(false);
                 $fs_gui->clearCommands();
                 $fs_gui->addCommand($this, "selectUploadDirFiles", $this->lng->txt("mep_sel_upload_dir_files"), false, true);
                 //$fs_gui->addCommand($this, "assignFullscreenObject", $this->lng->txt("cont_assign_full"));
                 $ret =& $this->ctrl->forwardCommand($fs_gui);
             }
             $this->tpl->show();
             break;
         case "ilcommonactiondispatchergui":
             include_once "Services/Object/classes/class.ilCommonActionDispatcherGUI.php";
             $gui = ilCommonActionDispatcherGUI::getInstanceFromAjaxCall();
             $this->ctrl->forwardCommand($gui);
             break;
         default:
             $this->prepareOutput();
             $this->addHeaderAction();
             $cmd = $this->ctrl->getCmd("frameset");
             $this->{$cmd}();
             if (!$this->getCreationMode()) {
                 $this->tpl->show();
             }
             break;
     }
 }