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

Modules/LearningModule/classes/class.ilLMPageObjectGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2006 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("./Modules/LearningModule/classes/class.ilLMObjectGUI.php");
00025 require_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
00026 require_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
00027 require_once ("./Modules/LearningModule/classes/class.ilInternalLinkGUI.php");
00028 
00041 class ilLMPageObjectGUI extends ilLMObjectGUI
00042 {
00043         var $obj;
00044 
00051         function ilLMPageObjectGUI(&$a_content_obj)
00052         {
00053                 global $ilias, $tpl, $lng;
00054 
00055                 parent::ilLMObjectGUI($a_content_obj);
00056 
00057         }
00058 
00059 
00063         function setLMPageObject(&$a_pg_obj)
00064         {
00065                 $this->obj =& $a_pg_obj;
00066                 $this->obj->setLMId($this->content_object->getId());
00067                 $this->actions = $this->objDefinition->getActions($this->obj->getType());
00068         }
00069 
00073         function &executeCommand()
00074         {
00075 #echo "<br>:cmd:".$this->ctrl->getCmd().":cmdClass:".$this->ctrl->getCmdClass().":"; flush();
00076                 $next_class = $this->ctrl->getNextClass($this);
00077                 $cmd = $this->ctrl->getCmd();
00078 
00079                 switch($next_class)
00080                 {
00081                         case 'ilmdeditorgui':
00082 
00083                                 $this->setTabs();
00084                                 include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
00085 
00086                                 $md_gui =& new ilMDEditorGUI($this->content_object->getID(),
00087                                         $this->obj->getId(), $this->obj->getType());
00088                                 $md_gui->addObserver($this->obj,'MDUpdateListener','General');
00089 
00090                                 $this->ctrl->forwardCommand($md_gui);
00091                                 break;
00092 
00093                         case "ilpageobjectgui":
00094 
00095                                 // Determine whether the view of a learning resource should
00096                                 // be shown in the frameset of ilias, or in a separate window.
00097                                 //$showViewInFrameset = $this->ilias->ini->readVariable("layout","view_target") == "frame";
00098                                 $showViewInFrameset = true;
00099 
00100                                 $this->ctrl->setReturn($this, "view");
00101                                 $page_object =& $this->obj->getPageObject();
00102                                 $page_object->buildDom();
00103                                 $page_object->addUpdateListener($this, "updateHistory");
00104                                 $int_links = $page_object->getInternalLinks();
00105                                 $link_xml = $this->getLinkXML($int_links);
00106                                 $page_gui =& new ilPageObjectGUI($page_object);
00107 
00108                                 // set page view link
00109                                 if ($showViewInFrameset)
00110                                 {
00111                                         $view_frame = ilFrameTargetInfo::_getFrame("MainContent");
00112                                 }
00113                                 else
00114                                 {
00115                                         $view_frame = "ilContObj".$this->content_object->getID();
00116                                 }
00117                                 $page_gui->setViewPageLink(ILIAS_HTTP_PATH."/goto.php?target=pg_".$this->obj->getId().
00118                                         "_".$_GET["ref_id"],
00119                                         $view_frame);
00120 
00121                                 $page_gui->setIntLinkHelpDefault("StructureObject", $_GET["ref_id"]);
00122                                 $page_gui->setTemplateTargetVar("ADM_CONTENT");
00123                                 $page_gui->setLinkXML($link_xml);
00124                                 $page_gui->enableChangeComments($this->content_object->isActiveHistoryUserComments());
00125                                 $page_gui->setFileDownloadLink("ilias.php?cmd=downloadFile&ref_id=".$_GET["ref_id"]."&baseClass=ilLMPresentationGUI");
00126                                 $page_gui->setFullscreenLink("ilias.php?cmd=fullscreen&ref_id=".$_GET["ref_id"]."&baseClass=ilLMPresentationGUI");
00127                                 $page_gui->setLinkParams("ref_id=".$this->content_object->getRefId());
00128                                 $page_gui->setSourcecodeDownloadScript("ilias.php?ref_id=".$_GET["ref_id"]."&baseClass=ilLMPresentationGUI");
00129                                 $page_gui->setPresentationTitle(
00130                                         ilLMPageObject::_getPresentationTitle($this->obj->getId(),
00131                                         $this->content_object->getPageHeader(), $this->content_object->isActiveNumbering()));
00132                                 $page_gui->setLocator($contObjLocator);
00133                                 $page_gui->setHeader($this->lng->txt("page").": ".$this->obj->getTitle());
00134                                 $page_gui->setEnabledActivation(true);
00135                                 $page_gui->setActivationListener($this, "activatePage");
00136                                 $page_gui->setActivated($this->obj->getActive());
00137                                 $ret =& $this->ctrl->forwardCommand($page_gui);
00138                                 //$ret =& $page_gui->executeCommand();
00139                                 break;
00140 
00141                         default:
00142                                 $ret =& $this->$cmd();
00143                                 break;
00144                 }
00145         }
00146 
00147 
00148         /*
00149         * display content of page (edit view)
00150         */
00151         function view()
00152         {
00153 //echo "<br>umschuss";
00154                 $this->ctrl->setCmdClass("ilpageobjectgui");
00155                 $this->ctrl->setCmd("view");
00156                 $this->executeCommand();
00157                 $this->setTabs();
00158         }
00159 
00160         /*
00161         * display content of page (edit view)
00162         */
00163         function preview()
00164         {
00165                 $this->ctrl->setCmdClass("ilpageobjectgui");
00166                 $this->ctrl->setCmd("preview");
00167                 $this->executeCommand();
00168                 $this->setTabs();
00169         }
00170 
00174         function save()
00175         {
00176 
00177                 $this->obj =& new ilLMPageObject($this->content_object);
00178                 $this->obj->setType("pg");
00179                 $this->obj->setTitle(ilUtil::stripSlashes($_POST["Fobject"]["title"]));
00180                 $this->obj->setDescription(ilUtil::stripSlashes($_POST["Fobject"]["desc"]));
00181                 $this->obj->setLMId($this->content_object->getId());
00182                 $this->obj->create();
00183 
00184                 // obj_id is empty, if page is created from "all pages" screen
00185                 // -> a free page is created (not in the tree)
00186 //echo "<br>savePage:".$_GET["obj_id"].":";
00187                 if ($_GET["obj_id"] != 0)
00188                 {
00189                         $this->putInTree();
00190 
00191                         // check the tree
00192                         $this->checkTree();
00193 
00194                         ilUtil::redirect($this->ctrl->getLinkTargetByClass("ilStructureObjectGUI",
00195                                 "view", "", true));
00196                 }
00197         }
00198 
00202         function cancel()
00203         {
00204                 ilUtil::sendInfo($this->lng->txt("msg_cancel"), true);
00205                 if ($_GET["obj_id"] != 0)
00206                 {
00207                         ilUtil::redirect($this->ctrl->getLinkTargetByClass("ilStructureObjectGUI",
00208                                 "view", "", true));
00209                 }
00210                 //$this->ctrl->returnToParent($this);
00211         }
00212 
00216         function getLinkXML($a_int_links)
00217         {
00218                 if ($a_layoutframes == "")
00219                 {
00220                         $a_layoutframes = array();
00221                 }
00222                 $link_info = "<IntLinkInfos>";
00223                 foreach ($a_int_links as $int_link)
00224                 {
00225                         $target = $int_link["Target"];
00226                         if (substr($target, 0, 4) == "il__")
00227                         {
00228                                 $target_arr = explode("_", $target);
00229                                 $target_id = $target_arr[count($target_arr) - 1];
00230                                 $type = $int_link["Type"];
00231                                 $targetframe = ($int_link["TargetFrame"] != "")
00232                                         ? $int_link["TargetFrame"]
00233                                         : "None";
00234                                         
00235                                 switch($type)
00236                                 {
00237                                         case "PageObject":
00238                                         case "StructureObject":
00239                                                 $lm_id = ilLMObject::_lookupContObjID($target_id);
00240                                                 $cont_obj =& $this->content_object;
00241                                                 if ($lm_id == $cont_obj->getId())
00242                                                 {
00243                                                         $ltarget = "";
00244                                                         if ($type == "PageObject")
00245                                                         {
00246                                                                 $this->ctrl->setParameter($this, "obj_id", $target_id);
00247                                                                 $href = $this->ctrl->getLinkTargetByClass(get_class($this), "view", "", true);
00248                                                         }
00249                                                         else
00250                                                         {
00251                                                                 $this->ctrl->setParameterByClass("ilstructureobjectgui", "obj_id", $target_id);
00252                                                                 $href = $this->ctrl->getLinkTargetByClass("ilstructureobjectgui", "view", "", true);
00253                                                         }
00254                                                         $href = str_replace("&", "&amp;", $href);
00255                                                         $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
00256                                                 }
00257                                                 else
00258                                                 {
00259                                                         if ($type == "PageObject")
00260                                                         {
00261                                                                 $href = "../goto.php?target=pg_".$target_id;
00262                                                         }
00263                                                         else
00264                                                         {
00265                                                                 $href = "../goto.php?target=st_".$target_id;
00266                                                         }
00267                                                         $ltarget = "ilContObj".$lm_id;
00268                                                 }
00269                                                 break;
00270 
00271                                         case "GlossaryItem":
00272                                                 $ltarget = $nframe = "_blank";
00273                                                 $href = "ilias.php?cmdClass=illmpresentationgui&amp;baseClass=ilLMPresentationGUI&amp;".
00274                                                         "obj_type=$type&amp;cmd=glossary&amp;ref_id=".$_GET["ref_id"].
00275                                                         "&amp;obj_id=".$target_id."&amp;frame=$nframe";
00276                                                 break;
00277 
00278                                         case "MediaObject":
00279                                                 $ltarget = $nframe = "_blank";
00280                                                 $href = "ilias.php?cmdClass=illmpresentationgui&amp;baseClass=ilLMPresentationGUI&amp;obj_type=$type&amp;cmd=media&amp;ref_id=".$_GET["ref_id"].
00281                                                         "&amp;mob_id=".$target_id."&amp;frame=$nframe";
00282                                                 break;
00283                                                 
00284                                         case "RepositoryItem":
00285                                                 $obj_type = ilObject::_lookupType($target_id, true);
00286                                                 $obj_id = ilObject::_lookupObjId($target_id);
00287                                                 $href = "./goto.php?target=".$obj_type."_".$target_id;
00288                                                 $t_frame = ilFrameTargetInfo::_getFrame("MainContent", $obj_type);
00289                                                 $ltarget = $t_frame;
00290                                                 break;
00291                                 }
00292                                 $link_info.="<IntLinkInfo Target=\"$target\" Type=\"$type\" ".
00293                                         "TargetFrame=\"$targetframe\" LinkHref=\"$href\" LinkTarget=\"$ltarget\" />";
00294                         }
00295                 }
00296                 $link_info.= "</IntLinkInfos>";
00297 //echo ":".htmlentities($link_info).":";
00298                 return $link_info;
00299         }
00300         
00301         
00307         function history()
00308         {
00309                 $this->setTabs();
00310                 
00311                 require_once("classes/class.ilHistoryGUI.php");
00312                 $hist_gui =& new ilHistoryGUI($this->obj->getId() ,
00313                         $this->content_object->getType().":pg");
00314                 $hist_html = $hist_gui->getHistoryTable(
00315                         $this->ctrl->getParameterArray($this, "history"),
00316                         $this->content_object->isActiveHistoryUserComments()
00317                         );
00318                 
00319                 $this->tpl->setVariable("ADM_CONTENT", $hist_html);
00320         }
00321 
00325         function updateHistory()
00326         {
00327                 require_once("classes/class.ilHistory.php");
00328                 ilHistory::_createEntry($this->obj->getId(), "update",
00329                         "", $this->content_object->getType().":pg",
00330                         "", true);
00331         }
00332 
00333 
00337         function setTabs()
00338         {
00339                 global $ilTabs;
00340 //echo "setTabs";
00341                 // catch feedback message
00342                 #include_once("classes/class.ilTabsGUI.php");
00343                 #$tabs_gui =& new ilTabsGUI();
00344                 $this->getTabs($ilTabs);
00345                 
00346                 $this->tpl->setCurrentBlock("header_image");
00347                 $this->tpl->setVariable("IMG_HEADER", ilUtil::getImagePath("icon_pg_b.gif"));
00348                 $this->tpl->parseCurrentBlock();
00349                 $this->tpl->setCurrentBlock("content");
00350 
00351                 #$this->tpl->setVariable("TABS", $tabs_gui->getHTML());
00352                 $this->tpl->setVariable("HEADER",
00353                         $this->lng->txt($this->obj->getType()).": ".$this->obj->getTitle());
00354         }
00355 
00361         function getTabs(&$tabs_gui)
00362         {
00363                 // back to upper context
00364                 $tabs_gui->addTarget("edit", $this->ctrl->getLinkTarget($this, "view")
00365                         , array("", "view"), "ilpageobjectgui");
00366 
00367                 $tabs_gui->addTarget("cont_preview", $this->ctrl->getLinkTarget($this, "preview")
00368                         , "preview", "ilpageobjectgui");
00369                         
00370                 //$tabs_gui->addTarget("properties", $this->ctrl->getLinkTarget($this, "properties")
00371                 //      , "properties", get_class($this));
00372 
00373                 $tabs_gui->addTarget("meta_data",
00374                          $this->ctrl->getLinkTargetByClass('ilmdeditorgui',''),
00375                          "", "ilmdeditorgui");
00376 
00377                 $tabs_gui->addTarget("history", $this->ctrl->getLinkTarget($this, "history")
00378                         , "history", get_class($this));
00379 
00380                 $tabs = $this->ctrl->getTabs();
00381                 foreach ($tabs as $tab)
00382                 {
00383                         $tabs_gui->addTarget($tab["lang_var"], $tab["link"]
00384                                 , $tab["cmd"], $tab["class"]);
00385                 }
00386 
00387                 //$tabs_gui->addTarget("clipboard", $this->ctrl->getLinkTargetByClass("ilEditClipboardGUI", "view")
00388                 //      , "view", "ilEditClipboardGUI");
00389 
00390         }
00391 
00397         function _goto($a_target, $a_target_ref_id = "")
00398         {
00399                 global $rbacsystem, $ilErr, $lng, $ilAccess;
00400 
00401                 // determine learning object
00402                 $lm_id = ilLMObject::_lookupContObjID($a_target);
00403 
00404                 // get all references
00405                 $ref_ids = ilObject::_getAllReferences($lm_id);
00406 
00407                 // always try passed ref id first
00408                 if (in_array($a_target_ref_id, $ref_ids))
00409                 {
00410                         $ref_ids = array_merge(array($a_target_ref_id), $ref_ids);
00411                 }
00412 
00413                 // check read permissions
00414                 foreach ($ref_ids as $ref_id)
00415                 {
00416                         // check read permissions
00417                         if ($ilAccess->checkAccess("read", "", $ref_id))
00418                         {
00419                                 // don't redirect anymore, just set parameters
00420                                 // (goto.php includes  "ilias.php")
00421                                 $_GET["baseClass"] = "ilLMPresentationGUI";
00422                                 $_GET["obj_id"] = $a_target;
00423                                 $_GET["ref_id"] = $ref_id;
00424                                 include_once("ilias.php");
00425                                 exit;
00426                         }
00427                 }
00428 
00429                 if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
00430                 {
00431                         $_GET["cmd"] = "frameset";
00432                         $_GET["target"] = "";
00433                         $_GET["ref_id"] = ROOT_FOLDER_ID;
00434                         ilUtil::sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
00435                                 ilObject::_lookupTitle($lm_id)), true);
00436                         include("repository.php");
00437                         exit;
00438                 }
00439 
00440                 $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
00441         }
00442 
00443 }
00444 ?>

Generated on Fri Dec 13 2013 17:56:51 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1