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("./content/classes/class.ilLMObjectGUI.php");
00025 require_once("./content/classes/class.ilLMPageObject.php");
00026 require_once("./content/classes/Pages/class.ilPageObjectGUI.php");
00027
00028 require_once ("content/classes/class.ilInternalLinkGUI.php");
00029
00042 class ilLMPageObjectGUI extends ilLMObjectGUI
00043 {
00044 var $obj;
00045
00052 function ilLMPageObjectGUI(&$a_content_obj)
00053 {
00054 global $ilias, $tpl, $lng;
00055
00056 parent::ilLMObjectGUI($a_content_obj);
00057
00058 }
00059
00060
00064 function setLMPageObject(&$a_pg_obj)
00065 {
00066 $this->obj =& $a_pg_obj;
00067 $this->obj->setLMId($this->content_object->getId());
00068 $this->actions = $this->objDefinition->getActions($this->obj->getType());
00069 }
00070
00074 function &executeCommand()
00075 {
00076 #echo "<br>:cmd:".$this->ctrl->getCmd().":cmdClass:".$this->ctrl->getCmdClass().":"; flush();
00077 $next_class = $this->ctrl->getNextClass($this);
00078 $cmd = $this->ctrl->getCmd();
00079
00080 switch($next_class)
00081 {
00082 case 'ilmdeditorgui':
00083
00084 $this->setTabs();
00085 include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
00086
00087 $md_gui =& new ilMDEditorGUI($this->content_object->getID(),
00088 $this->obj->getId(), $this->obj->getType());
00089 $md_gui->addObserver($this->obj,'MDUpdateListener','General');
00090
00091 $this->ctrl->forwardCommand($md_gui);
00092 break;
00093
00094 case "ilpageobjectgui":
00095
00096
00097
00098
00099 $showViewInFrameset = true;
00100
00101 $this->ctrl->setReturn($this, "view");
00102
00103
00104
00105
00106 $page_object =& $this->obj->getPageObject();
00107 $page_object->buildDom();
00108 $page_object->addUpdateListener($this, "updateHistory");
00109 $int_links = $page_object->getInternalLinks();
00110 $link_xml = $this->getLinkXML($int_links);
00111 $page_gui =& new ilPageObjectGUI($page_object);
00112
00113
00114 if ($showViewInFrameset)
00115 {
00116 $view_frame = ilFrameTargetInfo::_getFrame("MainContent");
00117 }
00118 else
00119 {
00120 $view_frame = "ilContObj".$this->content_object->getID();
00121 }
00122 $page_gui->setViewPageLink(ILIAS_HTTP_PATH."/goto.php?target=pg_".$this->obj->getId(),
00123 $view_frame);
00124
00125 $page_gui->setIntLinkHelpDefault("StructureObject", $_GET["ref_id"]);
00126 $page_gui->setTemplateTargetVar("ADM_CONTENT");
00127 $page_gui->setLinkXML($link_xml);
00128 $page_gui->enableChangeComments($this->content_object->isActiveHistoryUserComments());
00129 $page_gui->setFileDownloadLink("ilias.php?cmd=downloadFile&ref_id=".$_GET["ref_id"]."&baseClass=ilLMPresentationGUI");
00130 $page_gui->setFullscreenLink("ilias.php?cmd=fullscreen&ref_id=".$_GET["ref_id"]."&baseClass=ilLMPresentationGUI");
00131 $page_gui->setLinkParams("ref_id=".$this->content_object->getRefId());
00132 $page_gui->setSourcecodeDownloadScript("ilias.php?ref_id=".$_GET["ref_id"]."&baseClass=ilLMPresentationGUI");
00133 $page_gui->setPresentationTitle(
00134 ilLMPageObject::_getPresentationTitle($this->obj->getId(),
00135 $this->content_object->getPageHeader(), $this->content_object->isActiveNumbering()));
00136 $page_gui->setLocator($contObjLocator);
00137 $page_gui->setHeader($this->lng->txt("page").": ".$this->obj->getTitle());
00138 $page_gui->setEnabledActivation(true);
00139 $page_gui->setActivationListener($this, "activatePage");
00140 $page_gui->setActivated($this->obj->getActive());
00141 $ret =& $this->ctrl->forwardCommand($page_gui);
00142
00143 break;
00144
00145 default:
00146 $ret =& $this->$cmd();
00147 break;
00148 }
00149 }
00150
00151
00152
00153
00154
00155 function view()
00156 {
00157
00158 $this->ctrl->setCmdClass("ilpageobjectgui");
00159 $this->ctrl->setCmd("view");
00160 $this->executeCommand();
00161 $this->setTabs();
00162 }
00163
00164
00165
00166
00167 function preview()
00168 {
00169 $this->ctrl->setCmdClass("ilpageobjectgui");
00170 $this->ctrl->setCmd("preview");
00171 $this->executeCommand();
00172 $this->setTabs();
00173 }
00174
00178 function save()
00179 {
00180
00181 $this->obj =& new ilLMPageObject($this->content_object);
00182 $this->obj->setType("pg");
00183 $this->obj->setTitle(ilUtil::stripSlashes($_POST["Fobject"]["title"]));
00184 $this->obj->setDescription(ilUtil::stripSlashes($_POST["Fobject"]["desc"]));
00185 $this->obj->setLMId($this->content_object->getId());
00186 $this->obj->create();
00187
00188
00189
00190
00191 if ($_GET["obj_id"] != 0)
00192 {
00193 $this->putInTree();
00194
00195
00196 $this->checkTree();
00197
00198 ilUtil::redirect($this->ctrl->getLinkTargetByClass("ilStructureObjectGUI",
00199 "view", "", true));
00200 }
00201 }
00202
00206 function cancel()
00207 {
00208 sendInfo($this->lng->txt("msg_cancel"), true);
00209 if ($_GET["obj_id"] != 0)
00210 {
00211 ilUtil::redirect($this->ctrl->getLinkTargetByClass("ilStructureObjectGUI",
00212 "view", "", true));
00213 }
00214
00215 }
00216
00220 function getLinkXML($a_int_links)
00221 {
00222 if ($a_layoutframes == "")
00223 {
00224 $a_layoutframes = array();
00225 }
00226 $link_info = "<IntLinkInfos>";
00227 foreach ($a_int_links as $int_link)
00228 {
00229 $target = $int_link["Target"];
00230 if (substr($target, 0, 4) == "il__")
00231 {
00232 $target_arr = explode("_", $target);
00233 $target_id = $target_arr[count($target_arr) - 1];
00234 $type = $int_link["Type"];
00235 $targetframe = ($int_link["TargetFrame"] != "")
00236 ? $int_link["TargetFrame"]
00237 : "None";
00238
00239 switch($type)
00240 {
00241 case "PageObject":
00242 case "StructureObject":
00243 $lm_id = ilLMObject::_lookupContObjID($target_id);
00244 $cont_obj =& $this->content_object;
00245 if ($lm_id == $cont_obj->getId())
00246 {
00247 $ltarget = "";
00248 if ($type == "PageObject")
00249 {
00250 $this->ctrl->setParameter($this, "obj_id", $target_id);
00251 $href = $this->ctrl->getLinkTargetByClass(get_class($this), "view", "", true);
00252 }
00253 else
00254 {
00255 $this->ctrl->setParameterByClass("ilstructureobjectgui", "obj_id", $target_id);
00256 $href = $this->ctrl->getLinkTargetByClass("ilstructureobjectgui", "view", "", true);
00257 }
00258 $href = str_replace("&", "&", $href);
00259 $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
00260 }
00261 else
00262 {
00263 if ($type == "PageObject")
00264 {
00265 $href = "../goto.php?target=pg_".$target_id;
00266 }
00267 else
00268 {
00269 $href = "../goto.php?target=st_".$target_id;
00270 }
00271 $ltarget = "ilContObj".$lm_id;
00272 }
00273 break;
00274
00275 case "GlossaryItem":
00276 $ltarget = $nframe = "_blank";
00277 $href = "ilias.php?cmdClass=illmpresentationgui&baseClass=ilLMPresentationGUI&".
00278 "obj_type=$type&cmd=glossary&ref_id=".$_GET["ref_id"].
00279 "&obj_id=".$target_id."&frame=$nframe";
00280
00281
00282 break;
00283
00284 case "MediaObject":
00285 $ltarget = $nframe = "_blank";
00286 $href = "ilias.php?cmdClass=illmpresentationgui&baseClass=ilLMPresentationGUI&obj_type=$type&cmd=media&ref_id=".$_GET["ref_id"].
00287 "&mob_id=".$target_id."&frame=$nframe";
00288
00289
00290 break;
00291
00292 case "RepositoryItem":
00293 $obj_type = ilObject::_lookupType($target_id, true);
00294 $obj_id = ilObject::_lookupObjId($target_id);
00295 $href = "./goto.php?target=".$obj_type."_".$target_id;
00296 $t_frame = ilFrameTargetInfo::_getFrame("MainContent", $obj_type);
00297 $ltarget = $t_frame;
00298 break;
00299 }
00300 $link_info.="<IntLinkInfo Target=\"$target\" Type=\"$type\" ".
00301 "TargetFrame=\"$targetframe\" LinkHref=\"$href\" LinkTarget=\"$ltarget\" />";
00302 }
00303 }
00304 $link_info.= "</IntLinkInfos>";
00305
00306 return $link_info;
00307 }
00308
00309
00315 function history()
00316 {
00317 $this->setTabs();
00318
00319 require_once("classes/class.ilHistoryGUI.php");
00320 $hist_gui =& new ilHistoryGUI($this->obj->getId() ,
00321 $this->content_object->getType().":pg");
00322 $hist_html = $hist_gui->getHistoryTable(
00323 $this->ctrl->getParameterArray($this, "history"),
00324 $this->content_object->isActiveHistoryUserComments()
00325 );
00326
00327 $this->tpl->setVariable("ADM_CONTENT", $hist_html);
00328 }
00329
00333 function updateHistory()
00334 {
00335 require_once("classes/class.ilHistory.php");
00336 ilHistory::_createEntry($this->obj->getId(), "update",
00337 "", $this->content_object->getType().":pg",
00338 "", true);
00339 }
00340
00341
00345 function setTabs()
00346 {
00347 global $ilTabs;
00348
00349
00350 #include_once("classes/class.ilTabsGUI.php");
00351 #$tabs_gui =& new ilTabsGUI();
00352 $this->getTabs($ilTabs);
00353
00354 $this->tpl->setCurrentBlock("header_image");
00355 $this->tpl->setVariable("IMG_HEADER", ilUtil::getImagePath("icon_pg_b.gif"));
00356 $this->tpl->parseCurrentBlock();
00357 $this->tpl->setCurrentBlock("content");
00358
00359 #$this->tpl->setVariable("TABS", $tabs_gui->getHTML());
00360 $this->tpl->setVariable("HEADER",
00361 $this->lng->txt($this->obj->getType()).": ".$this->obj->getTitle());
00362 }
00363
00369 function getTabs(&$tabs_gui)
00370 {
00371
00372 $tabs_gui->addTarget("edit", $this->ctrl->getLinkTarget($this, "view")
00373 , array("", "view"), "ilpageobjectgui");
00374
00375 $tabs_gui->addTarget("cont_preview", $this->ctrl->getLinkTarget($this, "preview")
00376 , "preview", "ilpageobjectgui");
00377
00378
00379
00380
00381 $tabs_gui->addTarget("meta_data",
00382 $this->ctrl->getLinkTargetByClass('ilmdeditorgui',''),
00383 "", "ilmdeditorgui");
00384
00385 $tabs_gui->addTarget("history", $this->ctrl->getLinkTarget($this, "history")
00386 , "history", get_class($this));
00387
00388 $tabs = $this->ctrl->getTabs();
00389 foreach ($tabs as $tab)
00390 {
00391 $tabs_gui->addTarget($tab["lang_var"], $tab["link"]
00392 , $tab["cmd"], $tab["class"]);
00393 }
00394
00395
00396
00397
00398 }
00399
00405 function _goto($a_target, $a_target_ref_id = "")
00406 {
00407 global $rbacsystem, $ilErr, $lng, $ilAccess;
00408
00409
00410 $lm_id = ilLMObject::_lookupContObjID($a_target);
00411
00412
00413 $ref_ids = ilObject::_getAllReferences($lm_id);
00414
00415
00416 if (in_array($a_target_ref_id, $ref_ids))
00417 {
00418 $ref_ids = array_merge(array($a_target_ref_id), $ref_ids);
00419 }
00420
00421
00422 foreach ($ref_ids as $ref_id)
00423 {
00424
00425 if ($ilAccess->checkAccess("read", "", $ref_id))
00426 {
00427
00428
00429 $_GET["baseClass"] = "ilLMPresentationGUI";
00430 $_GET["obj_id"] = $a_target;
00431 $_GET["ref_id"] = $ref_id;
00432 include_once("ilias.php");
00433 exit;
00434 }
00435 }
00436
00437 if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
00438 {
00439 $_GET["cmd"] = "frameset";
00440 $_GET["target"] = "";
00441 $_GET["ref_id"] = ROOT_FOLDER_ID;
00442 sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
00443 ilObject::_lookupTitle($lm_id)), true);
00444 include("repository.php");
00445 exit;
00446 }
00447
00448 $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
00449 }
00450
00451 }
00452 ?>