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

Generated on Fri Dec 13 2013 10:18:29 for ILIAS Release_3_5_x_branch .rev 46805 by  doxygen 1.7.1