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

content/classes/class.ilLMPageObjectGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 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("./content/classes/class.ilLMObjectGUI.php");
00025 require_once("./content/classes/class.ilLMPageObject.php");
00026 require_once("./content/classes/Pages/class.ilPageObjectGUI.php");
00027 //require_once ("content/classes/class.ilEditClipboardGUI.php");
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 //echo "<br>:cmd:".$this->ctrl->getCmd().":cmdClass:".$this->ctrl->getCmdClass().":"; flush();
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                                 //require_once("content/classes/class.ilContObjLocatorGUI.php");
00095                                 //$contObjLocator =& new ilContObjLocatorGUI($this->content_object->getTree());
00096                                 //$contObjLocator->setObject($this->obj);
00097                                 //$contObjLocator->setContentObject($this->content_object);
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                                         "&amp;ref_id=".$this->content_object->getRefId());
00110                                 $page_gui->setFullscreenLink("lm_presentation.php?cmd=fullscreen".
00111                                         "&amp;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                                 //$ret =& $page_gui->executeCommand();
00121                                 break;
00122 
00123                         default:
00124                                 $ret =& $this->$cmd();
00125                                 break;
00126                 }
00127         }
00128 
00129 
00130         /*
00131         * display content of page (edit view)
00132         */
00133         function view()
00134         {
00135 //echo "<br>umschuss";
00136                 $this->ctrl->setCmdClass("ilpageobjectgui");
00137                 $this->ctrl->setCmd("view");
00138                 $this->executeCommand();
00139                 $this->setTabs();
00140         }
00141 
00142         /*
00143         * display content of page (edit view)
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                 // create new object
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                 // obj_id is empty, if page is created from "all pages" screen
00171                 // -> a free page is created (not in the tree)
00172 //echo "<br>savePage:".$_GET["obj_id"].":";
00173                 if ($_GET["obj_id"] != 0)
00174                 {
00175                         $this->putInTree();
00176 
00177                         // check the tree
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                 //$this->ctrl->returnToParent($this);
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("&", "&amp;", $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&amp;cmd=glossary&amp;ref_id=".$_GET["ref_id"].
00259                                                         "&amp;obj_id=".$target_id."&amp;frame=$nframe";
00260                                                 break;
00261 
00262                                         case "MediaObject":
00263                                                 $ltarget = $nframe = "_new";
00264                                                 $href = "lm_presentation.php?obj_type=$type&amp;cmd=media&amp;ref_id=".$_GET["ref_id"].
00265                                                         "&amp;mob_id=".$target_id."&amp;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                 // catch feedback message
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                 // back to upper context
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                 //$tabs_gui->addTarget("clipboard", $this->ctrl->getLinkTargetByClass("ilEditClipboardGUI", "view")
00352                 //      , "view", "ilEditClipboardGUI");
00353 
00354         }
00355 
00356 
00357 }
00358 ?>

Generated on Fri Dec 13 2013 08:00:16 for ILIAS Release_3_3_x_branch .rev 46803 by  doxygen 1.7.1