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 $this->ctrl->setReturn($this, "view");
00094
00095
00096
00097
00098 $page_object =& $this->obj->getPageObject();
00099 $page_object->buildDom();
00100 $page_object->addUpdateListener($this, "updateHistory");
00101 $int_links = $page_object->getInternalLinks();
00102 $link_xml = $this->getLinkXML($int_links);
00103 $page_gui =& new ilPageObjectGUI($page_object);
00104 $page_gui->setIntLinkHelpDefault("StructureObject", $_GET["ref_id"]);
00105 $page_gui->setTemplateTargetVar("ADM_CONTENT");
00106 $page_gui->setLinkXML($link_xml);
00107 $page_gui->enableChangeComments($this->content_object->isActiveHistoryUserComments());
00108 $page_gui->setFileDownloadLink("lm_presentation.php?cmd=downloadFile".
00109 "&ref_id=".$this->content_object->getRefId());
00110 $page_gui->setFullscreenLink("lm_presentation.php?cmd=fullscreen".
00111 "&ref_id=".$this->content_object->getRefId());
00112 $page_gui->setLinkParams("ref_id=".$this->content_object->getRefId());
00113 $page_gui->setSourcecodeDownloadScript("lm_presentation.php?ref_id=".$this->content_object->getRefId());
00114 $page_gui->setPresentationTitle(
00115 ilLMPageObject::_getPresentationTitle($this->obj->getId(),
00116 $this->content_object->getPageHeader(), $this->content_object->isActiveNumbering()));
00117 $page_gui->setLocator($contObjLocator);
00118 $page_gui->setHeader($this->lng->txt("page").": ".$this->obj->getTitle());
00119 $ret =& $this->ctrl->forwardCommand($page_gui);
00120
00121 break;
00122
00123 default:
00124 $ret =& $this->$cmd();
00125 break;
00126 }
00127 }
00128
00129
00130
00131
00132
00133 function view()
00134 {
00135
00136 $this->ctrl->setCmdClass("ilpageobjectgui");
00137 $this->ctrl->setCmd("view");
00138 $this->executeCommand();
00139 $this->setTabs();
00140 }
00141
00142
00143
00144
00145 function preview()
00146 {
00147 $this->ctrl->setCmdClass("ilpageobjectgui");
00148 $this->ctrl->setCmd("preview");
00149 $this->executeCommand();
00150 $this->setTabs();
00151 }
00152
00153
00157 function save()
00158 {
00159
00160 $meta_data =& new ilMetaData($_GET["new_type"], $this->content_object->getId());
00161
00162 $this->obj =& new ilLMPageObject($this->content_object);
00163 $this->obj->assignMetaData($meta_data);
00164 $this->obj->setType("pg");
00165 $this->obj->setTitle(ilUtil::stripSlashes($_POST["Fobject"]["title"]));
00166 $this->obj->setDescription(ilUtil::stripSlashes($_POST["Fobject"]["desc"]));
00167 $this->obj->setLMId($this->content_object->getId());
00168 $this->obj->create();
00169
00170
00171
00172
00173 if ($_GET["obj_id"] != 0)
00174 {
00175 $this->putInTree();
00176
00177
00178 $this->checkTree();
00179
00180 ilUtil::redirect($this->ctrl->getLinkTargetByClass("ilStructureObjectGUI",
00181 "view", "", true));
00182 }
00183 }
00184
00188 function cancel()
00189 {
00190 sendInfo($this->lng->txt("msg_cancel"), true);
00191 if ($_GET["obj_id"] != 0)
00192 {
00193 ilUtil::redirect($this->ctrl->getLinkTargetByClass("ilStructureObjectGUI",
00194 "view", "", true));
00195 }
00196
00197 }
00198
00202 function getLinkXML($a_int_links)
00203 {
00204 if ($a_layoutframes == "")
00205 {
00206 $a_layoutframes = array();
00207 }
00208 $link_info = "<IntLinkInfos>";
00209 foreach ($a_int_links as $int_link)
00210 {
00211 $target = $int_link["Target"];
00212 if (substr($target, 0, 4) == "il__")
00213 {
00214 $target_arr = explode("_", $target);
00215 $target_id = $target_arr[count($target_arr) - 1];
00216 $type = $int_link["Type"];
00217 $targetframe = ($int_link["TargetFrame"] != "")
00218 ? $int_link["TargetFrame"]
00219 : "None";
00220
00221 switch($type)
00222 {
00223 case "PageObject":
00224 case "StructureObject":
00225 $lm_id = ilLMObject::_lookupContObjID($target_id);
00226 $cont_obj =& $this->content_object;
00227 if ($lm_id == $cont_obj->getId())
00228 {
00229 if ($type == "PageObject")
00230 {
00231 $this->ctrl->setParameter($this, "obj_id", $target_id);
00232 $href = $this->ctrl->getLinkTargetByClass(get_class($this), "view", "", true);
00233 }
00234 else
00235 {
00236 $this->ctrl->setParameterByClass("ilstructureobjectgui", "obj_id", $target_id);
00237 $href = $this->ctrl->getLinkTargetByClass("ilstructureobjectgui", "view", "", true);
00238 }
00239 $href = str_replace("&", "&", $href);
00240 $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
00241 }
00242 else
00243 {
00244 if ($type == "PageObject")
00245 {
00246 $href = "../goto.php?target=pg_".$target_id;
00247 }
00248 else
00249 {
00250 $href = "../goto.php?target=st_".$target_id;
00251 }
00252 $ltarget = "ilContObj".$lm_id;
00253 }
00254 break;
00255
00256 case "GlossaryItem":
00257 $ltarget = $nframe = "_new";
00258 $href = "lm_presentation.php?obj_type=$type&cmd=glossary&ref_id=".$_GET["ref_id"].
00259 "&obj_id=".$target_id."&frame=$nframe";
00260 break;
00261
00262 case "MediaObject":
00263 $ltarget = $nframe = "_new";
00264 $href = "lm_presentation.php?obj_type=$type&cmd=media&ref_id=".$_GET["ref_id"].
00265 "&mob_id=".$target_id."&frame=$nframe";
00266 break;
00267 }
00268 $link_info.="<IntLinkInfo Target=\"$target\" Type=\"$type\" ".
00269 "TargetFrame=\"$targetframe\" LinkHref=\"$href\" LinkTarget=\"$ltarget\" />";
00270 }
00271 }
00272 $link_info.= "</IntLinkInfos>";
00273
00274 return $link_info;
00275 }
00276
00277
00283 function history()
00284 {
00285 $this->setTabs();
00286
00287 require_once("classes/class.ilHistoryGUI.php");
00288 $hist_gui =& new ilHistoryGUI($this->obj->getId() ,
00289 $this->content_object->getType().":pg");
00290 $hist_html = $hist_gui->getHistoryTable(
00291 $this->ctrl->getParameterArray($this, "history"),
00292 $this->content_object->isActiveHistoryUserComments()
00293 );
00294
00295 $this->tpl->setVariable("ADM_CONTENT", $hist_html);
00296 }
00297
00301 function updateHistory()
00302 {
00303 require_once("classes/class.ilHistory.php");
00304 ilHistory::_createEntry($this->obj->getId(), "update",
00305 "", $this->content_object->getType().":pg",
00306 "", true);
00307 }
00308
00309
00313 function setTabs()
00314 {
00315
00316 include_once("classes/class.ilTabsGUI.php");
00317 $tabs_gui =& new ilTabsGUI();
00318 $this->getTabs($tabs_gui);
00319 $this->tpl->setVariable("TABS", $tabs_gui->getHTML());
00320 $this->tpl->setVariable("HEADER",
00321 $this->lng->txt($this->obj->getType()).": ".$this->obj->getTitle());
00322 }
00323
00329 function getTabs(&$tabs_gui)
00330 {
00331
00332 $tabs_gui->addTarget("edit", $this->ctrl->getLinkTarget($this, "view")
00333 , "view", get_class($this));
00334
00335 $tabs_gui->addTarget("cont_preview", $this->ctrl->getLinkTarget($this, "preview")
00336 , "preview", get_class($this));
00337
00338 $tabs_gui->addTarget("meta_data", $this->ctrl->getLinkTarget($this, "editMeta")
00339 , "editMeta", get_class($this));
00340
00341 $tabs_gui->addTarget("history", $this->ctrl->getLinkTarget($this, "history")
00342 , "history", get_class($this));
00343
00344 $tabs = $this->ctrl->getTabs();
00345 foreach ($tabs as $tab)
00346 {
00347 $tabs_gui->addTarget($tab["lang_var"], $tab["link"]
00348 , $tab["cmd"], $tab["class"]);
00349 }
00350
00351
00352
00353
00354 }
00355
00356
00357 }
00358 ?>