• 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 
00061 
00065         function setLMPageObject(&$a_pg_obj)
00066         {
00067                 $this->obj =& $a_pg_obj;
00068                 $this->obj->setLMId($this->content_object->getId());
00069                 $this->actions = $this->objDefinition->getActions($this->obj->getType());
00070         }
00071 
00075         function &executeCommand()
00076         {
00077 #echo "<br>:cmd:".$this->ctrl->getCmd().":cmdClass:".$this->ctrl->getCmdClass().":"; flush();
00078                 $next_class = $this->ctrl->getNextClass($this);
00079                 $cmd = $this->ctrl->getCmd();
00080 
00081                 switch($next_class)
00082                 {
00083                         case 'ilmdeditorgui':
00084 
00085                                 $this->setTabs();
00086                                 include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
00087 
00088                                 $md_gui =& new ilMDEditorGUI($this->content_object->getID(),
00089                                         $this->obj->getId(), $this->obj->getType());
00090                                 $md_gui->addObserver($this->obj,'MDUpdateListener','General');
00091 
00092                                 $this->ctrl->forwardCommand($md_gui);
00093                                 break;
00094 
00095                         case "ilpageobjectgui":
00096 
00097                                 // Determine whether the view of a learning resource should
00098                                 // be shown in the frameset of ilias, or in a separate window.
00099                                 //$showViewInFrameset = $this->ilias->ini->readVariable("layout","view_target") == "frame";
00100                                 $showViewInFrameset = true;
00101 
00102                                 $this->ctrl->setReturn($this, "view");
00103                                 //require_once("content/classes/class.ilContObjLocatorGUI.php");
00104                                 //$contObjLocator =& new ilContObjLocatorGUI($this->content_object->getTree());
00105                                 //$contObjLocator->setObject($this->obj);
00106                                 //$contObjLocator->setContentObject($this->content_object);
00107                                 $page_object =& $this->obj->getPageObject();
00108                                 $page_object->buildDom();
00109                                 $page_object->addUpdateListener($this, "updateHistory");
00110                                 $int_links = $page_object->getInternalLinks();
00111                                 $link_xml = $this->getLinkXML($int_links);
00112                                 $page_gui =& new ilPageObjectGUI($page_object);
00113 
00114                                 // set page view link
00115                                 if ($showViewInFrameset)
00116                                 {
00117                                         $view_frame = "bottom";
00118                                 }
00119                                 else
00120                                 {
00121                                         $view_frame = "ilContObj".$this->content_object->getID();
00122                                 }
00123                                 $page_gui->setViewPageLink(ILIAS_HTTP_PATH."/goto.php?target=pg_".$this->obj->getId(),
00124                                         $view_frame);
00125 
00126                                 $page_gui->setIntLinkHelpDefault("StructureObject", $_GET["ref_id"]);
00127                                 $page_gui->setTemplateTargetVar("ADM_CONTENT");
00128                                 $page_gui->setLinkXML($link_xml);
00129                                 $page_gui->enableChangeComments($this->content_object->isActiveHistoryUserComments());
00130                                 $page_gui->setFileDownloadLink("ilias.php?cmd=downloadFile&ref_id=".$_GET["ref_id"]."&baseClass=ilLMPresentationGUI");
00131                                 $page_gui->setFullscreenLink("ilias.php?cmd=fullscreen&ref_id=".$_GET["ref_id"]."&baseClass=ilLMPresentationGUI");
00132                                 $page_gui->setLinkParams("ref_id=".$this->content_object->getRefId());
00133                                 $page_gui->setSourcecodeDownloadScript("ilias.php?ref_id=".$_GET["ref_id"]."&baseClass=ilLMPresentationGUI");
00134                                 $page_gui->setPresentationTitle(
00135                                         ilLMPageObject::_getPresentationTitle($this->obj->getId(),
00136                                         $this->content_object->getPageHeader(), $this->content_object->isActiveNumbering()));
00137                                 $page_gui->setLocator($contObjLocator);
00138                                 $page_gui->setHeader($this->lng->txt("page").": ".$this->obj->getTitle());
00139                                 $ret =& $this->ctrl->forwardCommand($page_gui);
00140                                 //$ret =& $page_gui->executeCommand();
00141                                 break;
00142 
00143                         default:
00144                                 $ret =& $this->$cmd();
00145                                 break;
00146                 }
00147         }
00148 
00149 
00150         /*
00151         * display content of page (edit view)
00152         */
00153         function view()
00154         {
00155 //echo "<br>umschuss";
00156                 $this->ctrl->setCmdClass("ilpageobjectgui");
00157                 $this->ctrl->setCmd("view");
00158                 $this->executeCommand();
00159                 $this->setTabs();
00160         }
00161 
00162         /*
00163         * display content of page (edit view)
00164         */
00165         function preview()
00166         {
00167                 $this->ctrl->setCmdClass("ilpageobjectgui");
00168                 $this->ctrl->setCmd("preview");
00169                 $this->executeCommand();
00170                 $this->setTabs();
00171         }
00172 
00176         function save()
00177         {
00178 
00179                 $this->obj =& new ilLMPageObject($this->content_object);
00180                 $this->obj->setType("pg");
00181                 $this->obj->setTitle(ilUtil::stripSlashes($_POST["Fobject"]["title"]));
00182                 $this->obj->setDescription(ilUtil::stripSlashes($_POST["Fobject"]["desc"]));
00183                 $this->obj->setLMId($this->content_object->getId());
00184                 $this->obj->create();
00185 
00186                 // obj_id is empty, if page is created from "all pages" screen
00187                 // -> a free page is created (not in the tree)
00188 //echo "<br>savePage:".$_GET["obj_id"].":";
00189                 if ($_GET["obj_id"] != 0)
00190                 {
00191                         $this->putInTree();
00192 
00193                         // check the tree
00194                         $this->checkTree();
00195 
00196                         ilUtil::redirect($this->ctrl->getLinkTargetByClass("ilStructureObjectGUI",
00197                                 "view", "", true));
00198                 }
00199         }
00200 
00204         function cancel()
00205         {
00206                 sendInfo($this->lng->txt("msg_cancel"), true);
00207                 if ($_GET["obj_id"] != 0)
00208                 {
00209                         ilUtil::redirect($this->ctrl->getLinkTargetByClass("ilStructureObjectGUI",
00210                                 "view", "", true));
00211                 }
00212                 //$this->ctrl->returnToParent($this);
00213         }
00214 
00218         function getLinkXML($a_int_links)
00219         {
00220                 if ($a_layoutframes == "")
00221                 {
00222                         $a_layoutframes = array();
00223                 }
00224                 $link_info = "<IntLinkInfos>";
00225                 foreach ($a_int_links as $int_link)
00226                 {
00227                         $target = $int_link["Target"];
00228                         if (substr($target, 0, 4) == "il__")
00229                         {
00230                                 $target_arr = explode("_", $target);
00231                                 $target_id = $target_arr[count($target_arr) - 1];
00232                                 $type = $int_link["Type"];
00233                                 $targetframe = ($int_link["TargetFrame"] != "")
00234                                         ? $int_link["TargetFrame"]
00235                                         : "None";
00236                                         
00237                                 switch($type)
00238                                 {
00239                                         case "PageObject":
00240                                         case "StructureObject":
00241                                                 $lm_id = ilLMObject::_lookupContObjID($target_id);
00242                                                 $cont_obj =& $this->content_object;
00243                                                 if ($lm_id == $cont_obj->getId())
00244                                                 {
00245                                                         $ltarget = "";
00246                                                         if ($type == "PageObject")
00247                                                         {
00248                                                                 $this->ctrl->setParameter($this, "obj_id", $target_id);
00249                                                                 $href = $this->ctrl->getLinkTargetByClass(get_class($this), "view", "", true);
00250                                                         }
00251                                                         else
00252                                                         {
00253                                                                 $this->ctrl->setParameterByClass("ilstructureobjectgui", "obj_id", $target_id);
00254                                                                 $href = $this->ctrl->getLinkTargetByClass("ilstructureobjectgui", "view", "", true);
00255                                                         }
00256                                                         $href = str_replace("&", "&amp;", $href);
00257                                                         $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
00258                                                 }
00259                                                 else
00260                                                 {
00261                                                         if ($type == "PageObject")
00262                                                         {
00263                                                                 $href = "../goto.php?target=pg_".$target_id;
00264                                                         }
00265                                                         else
00266                                                         {
00267                                                                 $href = "../goto.php?target=st_".$target_id;
00268                                                         }
00269                                                         $ltarget = "ilContObj".$lm_id;
00270                                                 }
00271                                                 break;
00272 
00273                                         case "GlossaryItem":
00274                                                 $ltarget = $nframe = "_new";
00275                                                 $href = "ilias.php?cmdClass=illmpresentationgui&amp;baseClass=ilLMPresentationGUI&amp;".
00276                                                         "obj_type=$type&amp;cmd=glossary&amp;ref_id=".$_GET["ref_id"].
00277                                                         "&amp;obj_id=".$target_id."&amp;frame=$nframe";
00278                                                 //$href = "content/lm_presentation.php?obj_type=$type&amp;cmd=glossary&amp;ref_id=".$_GET["ref_id"].
00279                                                 //      "&amp;obj_id=".$target_id."&amp;frame=$nframe";
00280                                                 break;
00281 
00282                                         case "MediaObject":
00283                                                 $ltarget = $nframe = "_new";
00284                                                 $href = "ilias.php?cmdClass=illmpresentationgui&amp;baseClass=ilLMPresentationGUI&amp;obj_type=$type&amp;cmd=media&amp;ref_id=".$_GET["ref_id"].
00285                                                         "&amp;mob_id=".$target_id."&amp;frame=$nframe";
00286                                                 //$href = "content/lm_presentation.php?obj_type=$type&amp;cmd=media&amp;ref_id=".$_GET["ref_id"].
00287                                                 //      "&amp;mob_id=".$target_id."&amp;frame=$nframe";
00288                                                 break;
00289                                                 
00290                                         case "RepositoryItem":
00291                                                 $obj_type = ilObject::_lookupType($target_id, true);
00292                                                 $obj_id = ilObject::_lookupObjId($target_id);
00293                                                 $href = "./goto.php?target=".$obj_type."_".$target_id;
00294                                                 $t_frame = ilFrameTargetInfo::_getFrame("MainContent", $obj_type);
00295                                                 $ltarget = $t_frame;
00296                                                 break;
00297                                 }
00298                                 $link_info.="<IntLinkInfo Target=\"$target\" Type=\"$type\" ".
00299                                         "TargetFrame=\"$targetframe\" LinkHref=\"$href\" LinkTarget=\"$ltarget\" />";
00300                         }
00301                 }
00302                 $link_info.= "</IntLinkInfos>";
00303 //echo ":".htmlentities($link_info).":";
00304                 return $link_info;
00305         }
00306         
00307         
00313         function history()
00314         {
00315                 $this->setTabs();
00316                 
00317                 require_once("classes/class.ilHistoryGUI.php");
00318                 $hist_gui =& new ilHistoryGUI($this->obj->getId() ,
00319                         $this->content_object->getType().":pg");
00320                 $hist_html = $hist_gui->getHistoryTable(
00321                         $this->ctrl->getParameterArray($this, "history"),
00322                         $this->content_object->isActiveHistoryUserComments()
00323                         );
00324                 
00325                 $this->tpl->setVariable("ADM_CONTENT", $hist_html);
00326         }
00327 
00331         function updateHistory()
00332         {
00333                 require_once("classes/class.ilHistory.php");
00334                 ilHistory::_createEntry($this->obj->getId(), "update",
00335                         "", $this->content_object->getType().":pg",
00336                         "", true);
00337         }
00338 
00339 
00343         function setTabs()
00344         {
00345                 global $ilTabs;
00346 //echo "setTabs";
00347                 // catch feedback message
00348                 #include_once("classes/class.ilTabsGUI.php");
00349                 #$tabs_gui =& new ilTabsGUI();
00350                 $this->getTabs($ilTabs);
00351                 
00352                 $this->tpl->setCurrentBlock("header_image");
00353                 $this->tpl->setVariable("IMG_HEADER", ilUtil::getImagePath("icon_pg.gif"));
00354                 $this->tpl->parseCurrentBlock();
00355                 $this->tpl->setCurrentBlock("content");
00356 
00357                 #$this->tpl->setVariable("TABS", $tabs_gui->getHTML());
00358                 $this->tpl->setVariable("HEADER",
00359                         $this->lng->txt($this->obj->getType()).": ".$this->obj->getTitle());
00360         }
00361 
00367         function getTabs(&$tabs_gui)
00368         {
00369                 // back to upper context
00370                 $tabs_gui->addTarget("edit", $this->ctrl->getLinkTarget($this, "view")
00371                         , array("", "view"), "ilpageobjectgui");
00372 
00373                 $tabs_gui->addTarget("cont_preview", $this->ctrl->getLinkTarget($this, "preview")
00374                         , "preview", "ilpageobjectgui");
00375                         
00376                 //$tabs_gui->addTarget("properties", $this->ctrl->getLinkTarget($this, "properties")
00377                 //      , "properties", get_class($this));
00378 
00379                 $tabs_gui->addTarget("meta_data",
00380                          $this->ctrl->getLinkTargetByClass('ilmdeditorgui',''),
00381                          "", "ilmdeditorgui");
00382 
00383                 $tabs_gui->addTarget("history", $this->ctrl->getLinkTarget($this, "history")
00384                         , "history", get_class($this));
00385 
00386                 $tabs = $this->ctrl->getTabs();
00387                 foreach ($tabs as $tab)
00388                 {
00389                         $tabs_gui->addTarget($tab["lang_var"], $tab["link"]
00390                                 , $tab["cmd"], $tab["class"]);
00391                 }
00392 
00393                 //$tabs_gui->addTarget("clipboard", $this->ctrl->getLinkTargetByClass("ilEditClipboardGUI", "view")
00394                 //      , "view", "ilEditClipboardGUI");
00395 
00396         }
00397 
00398 
00399 }
00400 ?>

Generated on Fri Dec 13 2013 11:57:56 for ILIAS Release_3_6_x_branch .rev 46809 by  doxygen 1.7.1