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
00043 class ilLMPageObjectGUI extends ilLMObjectGUI
00044 {
00045 var $obj;
00046
00053 function ilLMPageObjectGUI(&$a_content_obj)
00054 {
00055 global $ilias, $tpl, $lng;
00056
00057 parent::ilLMObjectGUI($a_content_obj);
00058
00059 }
00060
00066 function _forwards()
00067 {
00068 return (array("ilPageObjectGUI", "ilInternalLinkGUI"));
00069 }
00070
00074 function setLMPageObject(&$a_pg_obj)
00075 {
00076 $this->obj =& $a_pg_obj;
00077 $this->obj->setLMId($this->content_object->getId());
00078 $this->actions = $this->objDefinition->getActions($this->obj->getType());
00079 }
00080
00084 function &executeCommand()
00085 {
00086
00087 $next_class = $this->ctrl->getNextClass($this);
00088 $cmd = $this->ctrl->getCmd();
00089
00090 switch($next_class)
00091 {
00092 case "ilpageobjectgui":
00093
00094
00095
00096 $showViewInFrameset = $this->ilias->ini->readVariable("layout","view_target") == "frame";
00097
00098 $this->ctrl->setReturn($this, "view");
00099
00100
00101
00102
00103 $page_object =& $this->obj->getPageObject();
00104 $page_object->buildDom();
00105 $page_object->addUpdateListener($this, "updateHistory");
00106 $int_links = $page_object->getInternalLinks();
00107 $link_xml = $this->getLinkXML($int_links);
00108 $page_gui =& new ilPageObjectGUI($page_object);
00109
00110
00111 if ($showViewInFrameset)
00112 {
00113 $view_frame = "bottom";
00114 }
00115 else
00116 {
00117 $view_frame = "ilContObj".$this->content_object->getID();
00118 }
00119 $page_gui->setViewPageLink("../goto.php?target=pg_".$this->obj->getId(),
00120 $view_frame);
00121
00122 $page_gui->setIntLinkHelpDefault("StructureObject", $_GET["ref_id"]);
00123 $page_gui->setTemplateTargetVar("ADM_CONTENT");
00124 $page_gui->setLinkXML($link_xml);
00125 $page_gui->enableChangeComments($this->content_object->isActiveHistoryUserComments());
00126 $page_gui->setFileDownloadLink("lm_presentation.php?cmd=downloadFile".
00127 "&ref_id=".$this->content_object->getRefId());
00128 $page_gui->setFullscreenLink("lm_presentation.php?cmd=fullscreen".
00129 "&ref_id=".$this->content_object->getRefId());
00130 $page_gui->setLinkParams("ref_id=".$this->content_object->getRefId());
00131 $page_gui->setSourcecodeDownloadScript("lm_presentation.php?ref_id=".$this->content_object->getRefId());
00132 $page_gui->setPresentationTitle(
00133 ilLMPageObject::_getPresentationTitle($this->obj->getId(),
00134 $this->content_object->getPageHeader(), $this->content_object->isActiveNumbering()));
00135 $page_gui->setLocator($contObjLocator);
00136 $page_gui->setHeader($this->lng->txt("page").": ".$this->obj->getTitle());
00137 $ret =& $this->ctrl->forwardCommand($page_gui);
00138
00139 break;
00140
00141 default:
00142 $ret =& $this->$cmd();
00143 break;
00144 }
00145 }
00146
00147
00148
00149
00150
00151 function view()
00152 {
00153
00154 $this->ctrl->setCmdClass("ilpageobjectgui");
00155 $this->ctrl->setCmd("view");
00156 $this->executeCommand();
00157 $this->setTabs();
00158 }
00159
00160
00161
00162
00163 function preview()
00164 {
00165 $this->ctrl->setCmdClass("ilpageobjectgui");
00166 $this->ctrl->setCmd("preview");
00167 $this->executeCommand();
00168 $this->setTabs();
00169 }
00170
00171
00175 function save()
00176 {
00177
00178 $meta_data =& new ilMetaData($_GET["new_type"], $this->content_object->getId());
00179
00180 $this->obj =& new ilLMPageObject($this->content_object);
00181 $this->obj->assignMetaData($meta_data);
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 if ($type == "PageObject")
00248 {
00249 $this->ctrl->setParameter($this, "obj_id", $target_id);
00250 $href = $this->ctrl->getLinkTargetByClass(get_class($this), "view", "", true);
00251 }
00252 else
00253 {
00254 $this->ctrl->setParameterByClass("ilstructureobjectgui", "obj_id", $target_id);
00255 $href = $this->ctrl->getLinkTargetByClass("ilstructureobjectgui", "view", "", true);
00256 }
00257 $href = str_replace("&", "&", $href);
00258 $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
00259 }
00260 else
00261 {
00262 if ($type == "PageObject")
00263 {
00264 $href = "../goto.php?target=pg_".$target_id;
00265 }
00266 else
00267 {
00268 $href = "../goto.php?target=st_".$target_id;
00269 }
00270 $ltarget = "ilContObj".$lm_id;
00271 }
00272 break;
00273
00274 case "GlossaryItem":
00275 $ltarget = $nframe = "_new";
00276 $href = "lm_presentation.php?obj_type=$type&cmd=glossary&ref_id=".$_GET["ref_id"].
00277 "&obj_id=".$target_id."&frame=$nframe";
00278 break;
00279
00280 case "MediaObject":
00281 $ltarget = $nframe = "_new";
00282 $href = "lm_presentation.php?obj_type=$type&cmd=media&ref_id=".$_GET["ref_id"].
00283 "&mob_id=".$target_id."&frame=$nframe";
00284 break;
00285
00286 case "RepositoryItem":
00287 $obj_type = ilObject::_lookupType($target_id, true);
00288 $obj_id = ilObject::_lookupObjId($target_id);
00289 $href = "../goto.php?target=".$obj_type."_".$target_id;
00290 $t_frame = ilFrameTargetInfo::_getFrame("MainContent", $obj_type);
00291 $ltarget = $t_frame;
00292 break;
00293 }
00294 $link_info.="<IntLinkInfo Target=\"$target\" Type=\"$type\" ".
00295 "TargetFrame=\"$targetframe\" LinkHref=\"$href\" LinkTarget=\"$ltarget\" />";
00296 }
00297 }
00298 $link_info.= "</IntLinkInfos>";
00299
00300 return $link_info;
00301 }
00302
00303
00309 function history()
00310 {
00311 $this->setTabs();
00312
00313 require_once("classes/class.ilHistoryGUI.php");
00314 $hist_gui =& new ilHistoryGUI($this->obj->getId() ,
00315 $this->content_object->getType().":pg");
00316 $hist_html = $hist_gui->getHistoryTable(
00317 $this->ctrl->getParameterArray($this, "history"),
00318 $this->content_object->isActiveHistoryUserComments()
00319 );
00320
00321 $this->tpl->setVariable("ADM_CONTENT", $hist_html);
00322 }
00323
00327 function updateHistory()
00328 {
00329 require_once("classes/class.ilHistory.php");
00330 ilHistory::_createEntry($this->obj->getId(), "update",
00331 "", $this->content_object->getType().":pg",
00332 "", true);
00333 }
00334
00335
00339 function setTabs()
00340 {
00341
00342 include_once("classes/class.ilTabsGUI.php");
00343 $tabs_gui =& new ilTabsGUI();
00344 $this->getTabs($tabs_gui);
00345 $this->tpl->setVariable("TABS", $tabs_gui->getHTML());
00346 $this->tpl->setVariable("HEADER",
00347 $this->lng->txt($this->obj->getType()).": ".$this->obj->getTitle());
00348 }
00349
00355 function getTabs(&$tabs_gui)
00356 {
00357
00358 $tabs_gui->addTarget("edit", $this->ctrl->getLinkTarget($this, "view")
00359 , "view", get_class($this));
00360
00361 $tabs_gui->addTarget("cont_preview", $this->ctrl->getLinkTarget($this, "preview")
00362 , "preview", get_class($this));
00363
00364 $tabs_gui->addTarget("meta_data", $this->ctrl->getLinkTarget($this, "editMeta")
00365 , "editMeta", get_class($this));
00366
00367 $tabs_gui->addTarget("history", $this->ctrl->getLinkTarget($this, "history")
00368 , "history", get_class($this));
00369
00370 $tabs = $this->ctrl->getTabs();
00371 foreach ($tabs as $tab)
00372 {
00373 $tabs_gui->addTarget($tab["lang_var"], $tab["link"]
00374 , $tab["cmd"], $tab["class"]);
00375 }
00376
00377
00378
00379
00380 }
00381
00382
00383 }
00384 ?>