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

content/classes/class.ilLMPresentationGUI.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("./content/classes/class.ilObjLearningModule.php");
00025 require_once("./classes/class.ilMainMenuGUI.php");
00026 require_once("./classes/class.ilObjStyleSheet.php");
00027 
00040 class ilLMPresentationGUI
00041 {
00042         var $ilias;
00043         var $lm;
00044         var $tpl;
00045         var $lng;
00046         var $layout_doc;
00047         var $offline;
00048         var $offline_directory;
00049 
00050         function ilLMPresentationGUI()
00051         {
00052                 global $ilias, $lng, $tpl, $rbacsystem, $ilCtrl, $ilAccess;
00053 
00054                 // load language vars
00055                 $lng->loadLanguageModule("content");
00056 
00057                 $this->ilias =& $ilias;
00058                 $this->lng =& $lng;
00059                 $this->tpl =& $tpl;
00060                 $this->offline = false;
00061                 $this->frames = array();
00062                 $this->ctrl =& $ilCtrl;
00063                 $this->ctrl->saveParameter($this, array("ref_id"));
00064 
00065                 // check read permission, payment and parent conditions
00066                 // todo: replace all this by ilAccess call
00067                 if (!$ilAccess->checkAccess("read", "", $_GET["ref_id"]) &&
00068                         (!(($this->ctrl->getCmd() == "infoScreen" || $this->ctrl->getNextClass() == "ilinfoscreengui")
00069                         && $ilAccess->checkAccess("visible", "", $_GET["ref_id"]))))
00070                 {
00071                         $ilias->raiseError($lng->txt("permission_denied"), $ilias->error_obj->WARNING);
00072                 }
00073 #               include_once './classes/class.ilSearch.php';
00074 
00075 #               if(!ilSearch::_checkParentConditions($_GET['ref_id']))
00076 #               {
00077 #                       $ilias->error_obj->raiseError($lng->txt('access_denied'),$ilias->error_obj->WARNING);
00078 #               }
00079                 // Todo: check lm id
00080                 $type = $this->ilias->obj_factory->getTypeByRefId($_GET["ref_id"]);
00081 
00082                 // TODO: WE NEED AN OBJECT FACTORY FOR GUI CLASSES
00083                 switch($type)
00084                 {
00085                         case "dbk":
00086                                 include_once("./content/classes/class.ilObjDlBookGUI.php");
00087 
00088                                 $this->lm_gui = new ilObjDlBookGUI($data,$_GET["ref_id"],true,false);
00089                                 break;
00090                         case "lm":
00091                                 include_once("./content/classes/class.ilObjLearningModuleGUI.php");
00092 
00093                                 $this->lm_gui = new ilObjLearningModuleGUI($data,$_GET["ref_id"],true,false);
00094 
00095                                 break;
00096                 }
00097                 $this->lm =& $this->lm_gui->object;
00098 
00099                 // check, if learning module is online
00100                 if (!$rbacsystem->checkAccess("write", $_GET["ref_id"]))
00101                 {
00102                         if (!$this->lm->getOnline())
00103                         {
00104                                 $ilias->raiseError($lng->txt("permission_denied"), $ilias->error_obj->WARNING);
00105                         }
00106                 }
00107                 
00108                 $this->lm_tree = new ilTree($this->lm->getId());
00109                 $this->lm_tree->setTableNames('lm_tree','lm_data');
00110                 $this->lm_tree->setTreeTablePK("lm_id");
00111 
00112                 // do digilib book initialisation stuff
00113                 if ($type == "dbk")
00114                 {
00115                         $this->abstract = true;
00116                         $this->setSessionVars();
00117                         if((count($_POST["tr_id"]) > 1) or
00118                            (!$_POST["target"] and ($_POST["action"] == "show" or $_POST["action"] == "show_citation")))
00119                         {
00120                                 $this->abstract = true;
00121                         }
00122                         else if($_GET["obj_id"] or ($_POST["action"] == "show") or ($_POST["action"] == "show_citation"))
00123                         {
00124                                 $this->abstract = false;
00125                         }
00126                 }
00127 
00128         }
00129 
00130 
00134         function &executeCommand()
00135         {
00136 
00137                 $next_class = $this->ctrl->getNextClass($this);
00138                 $cmd = $this->ctrl->getCmd("layout");
00139 
00140                 $cmd = (isset($_POST['cmd']['citation']))
00141                         ? "ilCitation"
00142                         : $cmd;
00143 
00144                 // ### AA 03.09.01 added page access logger ###
00145                 $this->lmAccess($this->ilias->account->getId(),$_GET["ref_id"],$_GET["obj_id"]);
00146 
00147                 switch($next_class)
00148                 {
00149                         case "ilnotegui":
00150                                 $ret =& $this->layout();
00151                                 break;
00152                                 
00153                         case "ilinfoscreengui":
00154                                 $ret =& $this->outputInfoScreen();
00155                                 break;
00156                                 
00157                         case 'ilpaymentpurchasegui':
00158                                 $this->tpl->getStandardTemplate();
00159                                 $this->ilLocator();
00160                                         
00161                                 include_once("./payment/classes/class.ilPaymentPurchaseGUI.php");
00162                                 $pa =& new ilPaymentPurchaseGUI((int) $_GET['ref_id']);
00163                                 $ret =& $this->ctrl->forwardCommand($pa);
00164                                 $this->tpl->show();
00165                                 break;
00166 
00167                         default:
00168                                 include_once './payment/classes/class.ilPaymentObject.php';
00169                                 
00170                                 if(!ilPaymentObject::_hasAccess($_GET['ref_id']))
00171                                 {
00172                                         $this->tpl->getStandardTemplate();
00173                                         $this->ilLocator();
00174                 
00175                                         // payment
00176                                         include_once("./payment/classes/class.ilPaymentPurchaseGUI.php");
00177                                         $pa =& new ilPaymentPurchaseGUI((int) $_GET['ref_id']);
00178                                         $this->ctrl->setCmd("showDetails");
00179                                         $ret =& $this->ctrl->forwardCommand($pa);
00180                                         $this->tpl->show();
00181                                         return true;
00182                                 }
00183                          
00184                                 $ret =& $this->$cmd();
00185                                 break;
00186                 }
00187         }
00188 
00189 
00193         function setOfflineMode($a_offline = true)
00194         {
00195                 $this->offline = $a_offline;
00196         }
00197         
00198         
00202         function offlineMode()
00203         {
00204                 return $this->offline;
00205         }
00206         
00212         function setExportFormat($a_format)
00213         {
00214                 $this->export_format = $a_format;
00215         }
00216 
00222         function getExportFormat()
00223         {
00224                 return $this->export_format;
00225         }
00226 
00230         function nop()
00231         {
00232         }
00233 
00234         // ### AA 03.09.01 added page access logger ###
00241         function lmAccess($usr_id,$lm_id,$obj_id)
00242         {
00243                 global $ilDB;
00244                 
00245                 // first check if an entry for this user and this lm already exist, when so, delete
00246                 $q = "DELETE FROM lo_access ".
00247                         "WHERE usr_id='".$usr_id."' ".
00248                         "AND lm_id='".$lm_id."'";
00249                 $this->ilias->db->query($q);
00250                 $title = (is_object($this->lm))?$this->lm->getTitle():"- no title -";
00251                 // insert new entry
00252                 $pg_title = "";
00253                 $q = "INSERT INTO lo_access ".
00254                         "(timestamp,usr_id,lm_id,obj_id,lm_title) ".
00255                         "VALUES ".
00256                         "(now(),'".$usr_id."','".$lm_id."',".$ilDB->quote($obj_id).",'".ilUtil::prepareDBString($title)."')";
00257                 $this->ilias->db->query($q);
00258         }
00259 
00268         function export()
00269         {
00270                 switch($this->lm->getType())
00271                 {
00272                         case "dbk":
00273                                 $this->lm_gui->export();
00274                                 break;
00275                 }
00276         }
00277 
00285         function offlineexport() {
00286 
00287                 if ($_POST["cmd"]["cancel"] != "")
00288                 {
00289                         $this->ctrl->setParameter($this, "frame", "maincontent");
00290                         $this->ctrl->redirect($this, "layout");
00291                 }
00292 
00293                 switch($this->lm->getType())
00294                 {
00295                         case "dbk":
00296                                 //$this->lm_gui->offlineexport();
00297                                 $_GET["frame"] = "maincontent";
00298 
00299                                 $query = "SELECT * FROM object_reference,object_data WHERE object_reference.ref_id='".
00300                                         $_GET["ref_id"]."' AND object_reference.obj_id=object_data.obj_id ";
00301                                 $result = $this->ilias->db->query($query);
00302                                 $objRow = $result->fetchRow(DB_FETCHMODE_ASSOC);
00303                                 $_GET["obj_id"] = $objRow["obj_id"];
00304 
00305                                 $query = "SELECT * FROM lm_data WHERE lm_id='".$objRow["obj_id"]."' AND type='pg' ";
00306                                 $result = $this->ilias->db->query($query);
00307 
00308                                 $page = 0;
00309                                 $showpage = 0;
00310                                 while (is_array($row = $result->fetchRow(DB_FETCHMODE_ASSOC)) )
00311                                 {
00312 
00313                                         $page++;
00314 
00315                                         if ($_POST["pages"]=="all" || ($_POST["pages"]=="fromto" && $page>=$_POST["pagefrom"] && $page<=$_POST["pageto"] ))
00316                     {
00317 
00318                                                 if ($showpage>0)
00319                                                 {
00320                                                         if($_POST["type"] == "pdf") $output .= "<hr BREAK >\n";
00321                                                         if($_POST["type"] == "print") $output .= "<p style=\"page-break-after:always\" />";
00322                                                         if($_POST["type"] == "html") $output .= "<br><br><br><br>";
00323                                                 }
00324                                                 $showpage++;
00325 
00326                                                 $_GET["obj_id"] = $row["obj_id"];
00327                                                 $o = $this->layout("main.xml",false);
00328 
00329                         $output .= "<div xmlns:xhtml=\"http://www.w3.org/1999/xhtml\" class=\"ilc_PageTitle\">".$this->lm->title."</div><p>";
00330                                                 $output .= $o;
00331 
00332                                                 $output .= "\n<table cellpadding=0 cellspacing=0 border=0 width=100%><tr><td valign=top align=center>- ".$page." -</td></tr></table>\n";
00333 
00334                                         }
00335                                 }
00336 
00337                                 $printTpl = new ilTemplate("tpl.print.html", true, true, true);
00338 
00339                                 if($_POST["type"] == "print")
00340                                 {
00341                                         $printTpl->touchBlock("printreq");
00342                                         $css1 = ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId());
00343                                         $css2 = ilUtil::getStyleSheetLocation();
00344                                 }
00345                                 else
00346                                 {
00347                                         $css1 = "./css/delos.css";
00348                                         $css2 = "./css/content.css";
00349                                 }
00350                                 $printTpl->setVariable("LOCATION_CONTENT_STYLESHEET", $css1 );
00351 
00352                                 $printTpl->setVariable("LOCATION_STYLESHEET", $css2);
00353                                 $printTpl->setVariable("CONTENT",$output);
00354 
00355                                 // syntax style
00356                                 $printTpl->setCurrentBlock("SyntaxStyle");
00357                                 $printTpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
00358                                         ilObjStyleSheet::getSyntaxStylePath());
00359                                 $printTpl->parseCurrentBlock();
00360 
00361 
00362                                 $html = $printTpl->get();
00363 
00367                                 $this->lm->createExportDirectory();
00368                                 $export_dir = $this->lm->getExportDirectory();
00369 
00373                                 $fileName = "offline";
00374                                 $fileName = str_replace(" ","_",$fileName);
00375 
00376                                 if (!file_exists($export_dir."/".$fileName))
00377                                 {
00378                                         @mkdir($export_dir."/".$fileName);
00379                                         @chmod($export_dir."/".$fileName, 0755);
00380 
00381                                         @mkdir($export_dir."/".$fileName."/css");
00382                                         @chmod($export_dir."/".$fileName."/css", 0755);
00383 
00384                                 }
00385 
00386                                 if($_POST["type"] == "xml")
00387                                 {
00388                                         //vd($_GET["ref_id"]);
00389                                         $tmp_obj =& $this->ilias->obj_factory->getInstanceByRefId($_GET["ref_id"]);
00390 
00391                                         if ($tmp_obj->getType() == "dbk" )
00392                                         {
00393                                                 require_once "content/classes/class.ilObjDlBook.php";
00394                                                 $dbk =& new ilObjDlBook($_GET["ref_id"]);
00395                                                 $dbk->export();
00396                                         }
00397 
00398                                 }
00399                                 else if($_POST["type"] == "print")
00400                                 {
00401                                         echo $html;
00402                                 }
00403                                 else if ($_POST["type"]=="html")
00404                                 {
00405 
00411                                         $css1 = file("./templates/default/delos.css");
00412                                         $css1 = implode($css1,"");
00413 
00414                                         $fp = fopen($export_dir."/".$fileName."/css/delos.css","wb");
00415                                         fwrite($fp,$css1);
00416                                         fclose($fp);
00417 
00418                                         $css2 = file("./content/content.css");
00419                                         $css2 = implode($css2,"");
00420 
00421                                         $fp = fopen($export_dir."/".$fileName."/css/content.css","wb");
00422                                         fwrite($fp,$css2);
00423                                         fclose($fp);
00424 
00425 
00426                                         $fp = fopen($export_dir."/".$fileName."/".$fileName.".html","wb");
00427                                         fwrite($fp,$html);
00428                                         fclose($fp);
00429 
00430                                         ilUtil::zip($export_dir."/".$fileName, $export_dir."/".$fileName.".zip");
00431 
00432                     ilUtil::deliverFile($export_dir."/".$fileName.".zip", $fileName.".zip");
00433 
00434                                 }
00435                 else if ($_POST["type"]=="pdf")
00436                                 {
00437 
00438                     ilUtil::html2pdf($html, $export_dir."/".$fileName.".pdf");
00439 
00440                     ilUtil::deliverFile($export_dir."/".$fileName.".pdf", $fileName.".pdf");
00441 
00442                                 }
00443 
00444                                 exit;
00445                 }
00446 
00447         }
00448 
00456         function offlineexportform()
00457     {
00458 
00459                 switch($this->lm->getType())
00460                 {
00461                         case "dbk":
00462                                 $this->lm_gui->offlineexportform();
00463                                 break;
00464                 }
00465 
00466         }
00467 
00468 
00476         function exportbibinfo()
00477         {
00478                 $query = "SELECT * FROM object_reference,object_data WHERE object_reference.ref_id='".$_GET["ref_id"]."' AND object_reference.obj_id=object_data.obj_id ";
00479                 $result = $this->ilias->db->query($query);
00480 
00481                 $objRow = $result->fetchRow(DB_FETCHMODE_ASSOC);
00482 
00483                 $filename = preg_replace('/[^a-z0-9_]/i', '_', $objRow["title"]);
00484 
00485                 $C = $this->lm_gui->showAbstract(array(1));
00486 
00487                 if ($_GET["print"]==1)
00488                 {
00489                         $printTpl = new ilTemplate("tpl.print.html", true, true, true);
00490                         $printTpl->touchBlock("printreq");
00491                         $css1 = ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId());
00492                         $css2 = ilUtil::getStyleSheetLocation();
00493                         $printTpl->setVariable("LOCATION_CONTENT_STYLESHEET", $css1 );
00494 
00495                         $printTpl->setVariable("LOCATION_STYLESHEET", $css2);
00496 
00497                         // syntax style
00498                         $printTpl->setCurrentBlock("SyntaxStyle");
00499                         $printTpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
00500                                 ilObjStyleSheet::getSyntaxStylePath());
00501                         $printTpl->parseCurrentBlock();
00502 
00503                         $printTpl->setVariable("CONTENT",$C);
00504 
00505                         echo $printTpl->get();
00506                         exit;
00507                 }
00508                 else
00509                 {
00510                         ilUtil::deliverData($C, $filename.".html");
00511                         exit;
00512                 }
00513 
00514         }
00515 
00516 
00517 
00518 
00519         function attrib2arr($a_attributes)
00520         {
00521                 $attr = array();
00522                 if(!is_array($a_attributes))
00523                 {
00524                         return $attr;
00525                 }
00526                 foreach ($a_attributes as $attribute)
00527                 {
00528                         $attr[$attribute->name()] = $attribute->value();
00529                 }
00530                 return $attr;
00531         }
00532 
00536         function getCurrentFrameSet()
00537         {
00538                 return $this->frames;
00539         }
00540         
00544         function layout($a_xml = "main.xml", $doShow = true)
00545         {
00546                 global $tpl, $ilBench;
00547 
00548                 $ilBench->start("ContentPresentation", "layout");
00549 
00550                 // export scorm always to 1window
00551                 if ($this->getExportFormat() == "scorm")
00552                 {
00553                         $layout = "1window";
00554                 }
00555                 else
00556                 {
00557                         $layout = $this->lm->getLayout();
00558                 }
00559 
00560                 //$doc = xmldocfile("./layouts/lm/".$layout."/".$a_xml);
00561 
00562                 // xmldocfile is deprecated! Use domxml_open_file instead.
00563                 // But since using relative pathes with domxml under windows don't work,
00564                 // we need another solution:
00565                 $xmlfile = file_get_contents("./layouts/lm/".$layout."/".$a_xml);
00566 
00567                 if (!$doc = domxml_open_mem($xmlfile)) { echo "ilLMPresentation: XML File invalid"; exit; }
00568                 $this->layout_doc =& $doc;
00569 //echo ":".htmlentities($xmlfile).":$layout:$a_xml:";
00570 
00571                 // get current frame node
00572                 $ilBench->start("ContentPresentation", "layout_getFrameNode");
00573                 $xpc = xpath_new_context($doc);
00574                 $path = (empty($_GET["frame"]) || ($_GET["frame"] == "_blank"))
00575                         ? "/ilLayout/ilFrame[1]"
00576                         : "//ilFrame[@name='".$_GET["frame"]."']";
00577                 $result = xpath_eval($xpc, $path);
00578                 $found = $result->nodeset;
00579                 if (count($found) != 1) { echo "ilLMPresentation: XML File invalid"; exit; }
00580                 $node = $found[0];
00581 
00582                 $ilBench->stop("ContentPresentation", "layout_getFrameNode");
00583 //echo "<br>layout 2";
00584                 // ProcessFrameset
00585                 // node is frameset, if it has cols or rows attribute
00586                 $attributes = $this->attrib2arr($node->attributes());
00587                 $this->frames = array();
00588                 if((!empty($attributes["rows"])) || (!empty($attributes["cols"])))
00589                 {
00590                         $ilBench->start("ContentPresentation", "layout_processFrameset");
00591                         $content .= $this->buildTag("start", "frameset", $attributes);
00592 //echo "<br>A: reset frames"; flush();
00593                         //$this->frames = array();
00594                         $this->processNodes($content, $node);
00595                         $content .= $this->buildTag("end", "frameset");
00596                         $this->tpl = new ilTemplate("tpl.frameset.html", true, true, true);
00597                         $this->tpl->setVariable("PAGETITLE", "- ".$this->lm->getTitle());
00598                         $this->tpl->setVariable("FS_CONTENT", $content);
00599                         $ilBench->stop("ContentPresentation", "layout_processFrameset");
00600                         if (!$doshow)
00601                         {
00602                                 $content = $this->tpl->get();
00603                         }
00604                 }
00605                 else    // node is frame -> process the content tags
00606                 {
00607                         // ProcessContentTag
00608                         $ilBench->start("ContentPresentation", "layout_processContentTag");
00609                         //if ((empty($attributes["template"]) || !empty($_GET["obj_type"])))
00610                         if ((empty($attributes["template"]) || !empty($_GET["obj_type"]))
00611                                 && ($_GET["frame"] != "_blank" || $_GET["obj_type"] != "MediaObject"))
00612                         {
00613                                 // we got a variable content frame (can display different
00614                                 // object types (PageObject, MediaObject, GlossarItem)
00615                                 // and contains elements for them)
00616 
00617                                 // determine object type
00618                                 if(empty($_GET["obj_type"]))
00619                                 {
00620                                         $obj_type = "PageObject";
00621                                 }
00622                                 else
00623                                 {
00624                                         $obj_type = $_GET["obj_type"];
00625                                 }
00626 
00627                                 // get object specific node
00628                                 $childs = $node->child_nodes();
00629                                 $found = false;
00630                                 foreach($childs as $child)
00631                                 {
00632                                         if ($child->node_name() == $obj_type)
00633                                         {
00634                                                 $found = true;
00635                                                 $attributes = $this->attrib2arr($child->attributes());
00636                                                 $node =& $child;
00637 //echo "<br>2node:".$node->node_name();
00638                                                 break;
00639                                         }
00640                                 }
00641                                 if (!$found) { echo "ilLMPresentation: No template specified for frame '".
00642                                         $_GET["frame"]."' and object type '".$obj_type."'."; exit; }
00643                         }
00644 
00645                         // get template
00646                         $in_module = ($attributes["template_location"] == "module")
00647                                 ? true
00648                                 : false;
00649                         if ($in_module)
00650                         {
00651                                 $this->tpl = new ilTemplate($attributes["template"], true, true, $in_module);
00652                         }
00653                         else
00654                         {
00655                                 $this->tpl =& $tpl;
00656                         }
00657 
00658                         // set style sheets
00659                         if (!$this->offlineMode())
00660                         {
00661                                 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
00662                         }
00663                         else
00664                         {
00665                                 $style_name = $this->ilias->account->prefs["style"].".css";;
00666                                 $this->tpl->setVariable("LOCATION_STYLESHEET","./".$style_name);
00667                         }
00668 
00669                         $childs = $node->child_nodes();
00670                         
00671                         $ilBench->start("ContentPresentation", "layout_processContentNodes");
00672                         foreach($childs as $child)
00673                         {
00674 
00675                                 $child_attr = $this->attrib2arr($child->attributes());
00676 //echo "-".$child->node_name()."-";
00677                                 switch ($child->node_name())
00678                                 {
00679                                         case "ilMainMenu":
00680                                                 $ilBench->start("ContentPresentation", "layout_mainmenu");
00681                                                 $this->ilMainMenu();
00682                                                 $ilBench->stop("ContentPresentation", "layout_mainmenu");
00683                                                 break;
00684 
00685                                         case "ilTOC":
00686                                                 $this->ilTOC($child_attr["target_frame"]);
00687                                                 break;
00688 
00689                                         case "ilPage":
00690                                                 switch($this->lm->getType())
00691                                                 {
00692                                                         case "lm":
00693                                                                 unset($_SESSION["tr_id"]);
00694                                                                 unset($_SESSION["bib_id"]);
00695                                                                 unset($_SESSION["citation"]);
00696                                                                 $content = $this->ilPage($child);
00697                                                                 break;
00698 
00699                                                         case "dbk":
00700                                                                 $this->setSessionVars();
00701                                                                 if($this->abstract)
00702                                                                 {
00703                                                                         $content = $this->lm_gui->showAbstract($_POST["target"]);
00704                                                                 }
00705                                                                 else
00706                                                                 {
00707                                                                         // SHOW PAGE IF PAGE WAS SELECTED
00708                                                                         $content = $this->ilPage($child);
00709 
00710                                                                         if($_SESSION["tr_id"])
00711                                                                         {
00712                                                                                 $translation_content = $this->ilTranslation($child);
00713                                                                         }
00714                                                                 }
00715                                                                 break;
00716                                                 }
00717                                                                                                 break;
00718 
00719                                         case "ilGlossary":
00720                                                 $content = $this->ilGlossary($child);
00721                                                 break;
00722 
00723                                         case "ilLMNavigation":
00724 
00725                                                 // NOT FOR ABSTRACT
00726                                                 if($_GET["obj_id"] or
00727                                                    ((count($_POST["tr_id"]) < 2) and $_POST["target"] and
00728                                                         ($_POST["action"] == "show" or $_POST["action"] == "show_citation")) or
00729                                                    $this->lm->getType() == 'lm')
00730                                                 {
00731                                                         $ilBench->start("ContentPresentation", "layout_lmnavigation");
00732                                                         $this->ilLMNavigation();
00733                                                         $ilBench->stop("ContentPresentation", "layout_lmnavigation");
00734                                                 }
00735                                                 break;
00736 
00737                                         case "ilMedia":
00738                                                 $this->ilMedia();
00739                                                 break;
00740 
00741                                         case "ilLocator":
00742                                                 $ilBench->start("ContentPresentation", "layout_locator");
00743                                                 $this->ilLocator();
00744                                                 $ilBench->stop("ContentPresentation", "layout_locator");
00745                                                 break;
00746 
00747                                         case "ilLMMenu":
00748                                                 $ilBench->start("ContentPresentation", "layout_lmmenu");
00749                                                 $this->ilLMMenu();
00750                                                 $ilBench->stop("ContentPresentation", "layout_lmmenu");
00751                                                 break;
00752 
00753                                         case "ilLMSubMenu":
00754                                                 $ilBench->start("ContentPresentation", "layout_lmsubmenu");
00755                                                 $this->ilLMSubMenu();
00756                                                 $ilBench->stop("ContentPresentation", "layout_lmsubmenu");
00757                                                 break;
00758                                                 
00759                                         case "ilLMNotes":
00760                                                 $ilBench->start("ContentPresentation", "layout_lmnotes");
00761                                                 $this->ilLMNotes();
00762                                                 $ilBench->stop("ContentPresentation", "layout_lmnotes");
00763                                                 break;
00764                                 }
00765                         }
00766                         $ilBench->stop("ContentPresentation", "layout_processContentNodes");
00767                         
00768                         $ilBench->stop("ContentPresentation", "layout_processContentTag");
00769                 }
00770                 $content =  $this->tpl->get();
00771 
00772                 if ($doShow)
00773                 {
00774                         // (horrible) workaround for preventing template engine
00775                         // from hiding paragraph text that is enclosed
00776                         // in curly brackets (e.g. "{a}", see ilPageObjectGUI::showPage())
00777                         
00778                         $this->tpl->fillTabs();
00779                         $content =  $this->tpl->get();
00780                         $content = str_replace("&#123;", "{", $content);
00781                         $content = str_replace("&#125;", "}", $content);
00782 
00783                         header('Content-type: text/html; charset=UTF-8');
00784                         echo $content;
00785                 }
00786 
00787                 $ilBench->stop("ContentPresentation", "layout");
00788 
00789                 return($content);
00790         }
00791 
00792         function fullscreen()
00793         {
00794                 return $this->layout("fullscreen.xml", !$this->offlineMode());
00795         }
00796 
00797         function media()
00798         {
00799                 if ($_GET["frame"] != "_blank")
00800                 {
00801                         return $this->layout("main.xml", !$this->offlineMode());
00802                 }
00803                 else
00804                 {
00805                         return $this->layout("fullscreen.xml", !$this->offlineMode());
00806                 }
00807         }
00808 
00809         function glossary()
00810         {
00811                 if ($_GET["frame"] != "_blank")
00812                 {
00813                         $this->layout();
00814                 }
00815                 else
00816                 {
00817                         $this->tpl = new ilTemplate("tpl.glossary_term_output.html", true, true, true);
00818                         $this->tpl->setVariable("PAGETITLE", " - ".$this->lm->getTitle());
00819 
00820                         // set style sheets
00821                         if (!$this->offlineMode())
00822                         {
00823                                 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
00824                         }
00825                         else
00826                         {
00827                                 $style_name = $this->ilias->account->prefs["style"].".css";;
00828                                 $this->tpl->setVariable("LOCATION_STYLESHEET","./".$style_name);
00829                         }
00830 
00831                         $this->ilGlossary($child);
00832                         if (!$this->offlineMode())
00833                         {
00834                                 $this->tpl->show();
00835                         }
00836                         else
00837                         {
00838                                 return $this->tpl->get();
00839                         }
00840                 }
00841         }
00842 
00846         function ilMainMenu()
00847         {
00848                 global $ilBench, $ilMainMenu;
00849 
00850                 if ($this->offlineMode())
00851                 {
00852                         return;
00853                 }
00854 
00855                 $ilBench->start("ContentPresentation", "ilMainMenu");
00856 
00857                 /*
00858                 $menu = new ilMainMenuGUI(ilFrameTargetInfo::_getFrame("MainContent"));
00859                 $menu->setTemplate($this->tpl);
00860                 $menu->addMenuBlock("MAINMENU", "mainmenu");
00861                 $menu->setTemplateVars();*/
00862                 if ($this->lm->getLayout() == "2window" || 
00863                         $this->lm->getLayout() == "3window")
00864                 {
00865                         $ilMainMenu->setSmallMode(true);
00866                 }
00867                 else
00868                 {
00869                         $ilMainMenu->setSmallMode(false);
00870                 }
00871                 
00872                 $this->tpl->setVariable("MAINMENU", $ilMainMenu->getHTML());
00873                 
00874                 $ilBench->stop("ContentPresentation", "ilMainMenu");
00875         }
00876 
00880         function ilTOC($a_target)
00881         {
00882                 global $ilBench;
00883 
00884                 $ilBench->start("ContentPresentation", "ilTOC");
00885                 require_once("./content/classes/class.ilLMTOCExplorer.php");
00886                 if ($this->lm->cleanFrames())
00887                 {
00888                         $a_target = "";
00889                 }
00890                 $exp = new ilLMTOCExplorer($this->getLink($this->lm->getRefId(), "layout", "", $a_target),$this->lm);
00891                 $exp->setExpandTarget($this->getLink($this->lm->getRefId(), $_GET["cmd"], $_GET["obj_id"], $_GET["frame"]));
00892                 $exp->setTargetGet("obj_id");
00893                 if ($this->lm->cleanFrames())
00894                 {
00895                         if ($this->offlineMode())
00896                         {
00897                                 $exp->setFrameTarget("_top");
00898                         }
00899                         else
00900                         {
00901                                 $exp->setFrameTarget(ilFrameTargetInfo::_getFrame("MainContent"));
00902                         }
00903                 }
00904                 else
00905                 {
00906                         $exp->setFrameTarget($a_target);
00907                 }
00908                 $exp->addFilter("du");
00909                 $exp->addFilter("st");
00910                 
00911                 // force expansion
00912                 if ($this->lm->cleanFrames())
00913                 {
00914                         $page_id = $this->getCurrentPageId();
00915                         if ($page_id > 0)
00916                         {
00917                                 $path = $this->lm_tree->getPathId($page_id);
00918                                 $exp->setForceOpenPath($path);
00919                         }
00920                         if (!$this->offlineMode())
00921                         {
00922                                 $exp->highlightNode($page_id);
00923                         }
00924                 }
00925                 
00926                 $exp->setOfflineMode($this->offlineMode());
00927                 if ($this->lm->getTOCMode() == "pages")
00928                 {
00929                         $exp->addFilter("pg");
00930                 }
00931                 $exp->setFiltered(true);
00932                 $exp->setFilterMode(IL_FM_POSITIVE);
00933 
00934                 if ($_GET["lmexpand"] == "")
00935                 {
00936                         $expanded = $this->lm_tree->readRootId();
00937                 }
00938                 else
00939                 {
00940                         $expanded = $_GET["lmexpand"];
00941                 }
00942                 $exp->setExpand($expanded);
00943 
00944                 // build html-output
00945                 $exp->setOutput(0);
00946                 $output = $exp->getOutput();
00947 
00948                 $this->tpl->setVariable("PAGETITLE", " - ".$this->lm->getTitle());
00949 
00950                 // set style sheets
00951                 if (!$this->offlineMode())
00952                 {
00953                         $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
00954                 }
00955                 else
00956                 {
00957                         $style_name = $this->ilias->account->prefs["style"].".css";;
00958                         $this->tpl->setVariable("LOCATION_STYLESHEET","./".$style_name);
00959                 }
00960 
00961                 if (!$this->offlineMode())
00962                 {
00963                         $this->tpl->addBlockFile("EXPL_TOP", "exp_top", "tpl.explorer_top.html");
00964                         //$this->tpl->setVariable("DUMMY", "&nbsp;");
00965                         $this->tpl->setVariable("IMG_SPACE", ilUtil::getImagePath("spacer.gif", false));
00966                 }
00967                 $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_toc"));
00968                 $this->tpl->setVariable("EXPLORER",$output);
00969                 $this->tpl->setVariable("ACTION",
00970                         $this->getLink($this->lm->getRefId(), $_GET["cmd"], "", $_GET["frame"]).
00971                         "&lmexpand=".$_GET["lmexpand"]);
00972                 $this->tpl->parseCurrentBlock();
00973                 $ilBench->stop("ContentPresentation", "ilTOC");
00974         }
00975 
00979         function ilLMMenu()
00980         {
00981                 $this->tpl->setVariable("MENU", $this->lm_gui->setilLMMenu($this->offlineMode()
00982                         ,$this->getExportFormat()));
00983         }
00984 
00988         function ilLMSubMenu()
00989         {
00990                 global $rbacsystem;
00991                 
00992                 // no sub menu for abstract of digilib book
00993                 if ($this->lm->getType() == "dbk" && $this->abstract)
00994                 {
00995                         return;
00996                 }
00997 
00998                 //$showViewInFrameset = $this->ilias->ini->readVariable("layout","view_target") == "frame";
00999                 $showViewInFrameset = true;
01000                 
01001                 if ($showViewInFrameset)
01002                 {
01003                         $buttonTarget = ilFrameTargetInfo::_getFrame("MainContent");
01004                 }
01005                 else
01006                 {
01007                         $buttonTarget = "_top";
01008                 }
01009 
01010 
01011                 include_once("./classes/class.ilTemplate.php");
01012                 $tpl_menu =& new ilTemplate("tpl.lm_sub_menu.html", true, true, true);
01013 
01014                 // edit learning module
01015                 if (!$this->offlineMode())
01016                 {
01017                         if ($rbacsystem->checkAccess("write", $_GET["ref_id"]))
01018                         {
01019                                 $tpl_menu->setCurrentBlock("edit_page");
01020                                 $page_id = $this->getCurrentPageId();
01021                                 $tpl_menu->setVariable("EDIT_LINK", ILIAS_HTTP_PATH."/ilias.php?baseClass=ilLMEditorGUI&ref_id=".$_GET["ref_id"].
01022                                         "&obj_id=".$page_id."&to_page=1");
01023                                 $tpl_menu->setVariable("EDIT_TXT", $this->lng->txt("edit_page"));
01024                                 $tpl_menu->setVariable("EDIT_TARGET", $buttonTarget);
01025                                 $tpl_menu->parseCurrentBlock();
01026                         }
01027 
01028                         $tpl_menu->setCurrentBlock("perma_link");
01029                         $page_id = $this->getCurrentPageId();
01030                         $tpl_menu->setVariable("PERMA_LINK", ILIAS_HTTP_PATH.
01031                                 "/goto.php?target=pg_".$page_id."_".$this->lm->getRefId()."&client_id=".CLIENT_ID);
01032                         $tpl_menu->setVariable("TXT_PERMA_LINK", $this->lng->txt("perma_link"));
01033                         $tpl_menu->setVariable("PERMA_TARGET", "_top");
01034                         $tpl_menu->parseCurrentBlock();
01035 
01036                 }
01037 
01038                 $this->tpl->setVariable("SUBMENU", $tpl_menu->get());
01039         }
01040 
01041 
01045         function ilLMNotes()
01046         {
01047                 global $ilAccess;
01048                 
01049                 // no notes for abstract of digilib book
01050                 if ($this->lm->getType() == "dbk" && $this->abstract)
01051                 {
01052                         return;
01053                 }
01054 
01055 
01056                 // no notes in offline (export) mode
01057                 if ($this->offlineMode())
01058                 {
01059                         return;
01060                 }
01061                 
01062                 
01063                 $next_class = $this->ctrl->getNextClass($this);
01064 
01065                 include_once("Services/Notes/classes/class.ilNoteGUI.php");
01066                 $notes_gui = new ilNoteGUI($this->lm->getId(), $this->getCurrentPageId(), "pg");
01067                 if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
01068                 {
01069                         $notes_gui->enablePublicNotesDeletion(true);
01070                 }
01071                 
01072                 $this->ctrl->setParameter($this, "frame", $_GET["frame"]);
01073                 $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
01074                 
01075                 $notes_gui->enablePrivateNotes();
01076                 if ($this->lm->publicNotes())
01077                 {
01078                         $notes_gui->enablePublicNotes();
01079                 }
01080 
01081                 if ($next_class == "ilnotegui")
01082                 {
01083                         $html = $this->ctrl->forwardCommand($notes_gui);
01084                 }
01085                 else
01086                 {       
01087                         $html = $notes_gui->getNotesHTML();
01088                 }
01089                 $this->tpl->setVariable("NOTES", $html);
01090         }
01091 
01092 
01096         function ilLocator()
01097         {
01098                 global $ilLocator, $tree;
01099 
01100                 require_once("content/classes/class.ilStructureObject.php");
01101 
01102                 if (empty($_GET["obj_id"]))
01103                 {
01104                         $a_id = $this->lm_tree->getRootId();
01105                 }
01106                 else
01107                 {
01108                         $a_id = $_GET["obj_id"];
01109                 }
01110 
01111                 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
01112                 
01113                 if (!$this->lm->cleanFrames())
01114                 {
01115                         $frame_param = $_GET["frame"];
01116                         $frame_target = "";
01117                 }
01118                 else if (!$this->offlineMode())
01119                 {
01120                         $frame_param = "";
01121                         $frame_target = ilFrameTargetInfo::_getFrame("MainContent");
01122                 }
01123                 else
01124                 {
01125                         $frame_param = "";
01126                         $frame_target = "_top";
01127                 }
01128 
01129                 if (!$this->offlineMode())
01130                 {
01131                         $ilLocator->addItem("...", "");
01132 
01133                         $par_id = $tree->getParentId($_GET["ref_id"]);
01134                         $ilLocator->addItem(
01135                                 ilObject::_lookupTitle(ilObject::_lookupObjId($par_id)),
01136                                 "repository.php?cmd=frameset&amp;ref_id=".$par_id,
01137                                 ilFrameTargetInfo::_getFrame("MainContent"));
01138                 }
01139 
01140                 if($this->lm_tree->isInTree($a_id))
01141                 {                       
01142                         $path = $this->lm_tree->getPathFull($a_id);
01143 
01144                         foreach ($path as $key => $row)
01145                         {
01146                                 if ($row["type"] != "pg")
01147                                 {
01148                                         if($row["child"] != $this->lm_tree->getRootId())
01149                                         {
01150                                                 $ilLocator->addItem(
01151                                                         ilUtil::shortenText(
01152                                                                 ilStructureObject::_getPresentationTitle($row["child"],
01153                                                                 $this->lm->isActiveNumbering()),50,true),
01154                                                         $this->getLink($_GET["ref_id"], "layout", $row["child"], $frame_param, "StructureObject"),
01155                                                         $frame_target);
01156                                         }
01157                                         else
01158                                         {
01159                                                 $ilLocator->addItem(
01160                                                         ilUtil::shortenText($this->lm->getTitle(),50,true),
01161                                                         $this->getLink($_GET["ref_id"], "layout", "", $frame_param),
01162                                                         $frame_target);
01163                                         }
01164                                 }
01165                         }
01166                 }
01167                 else            // lonely page
01168                 {
01169         
01170                         $ilLocator->addItem(
01171                                 $this->lm->getTitle(),
01172                                 $this->getLink($_GET["ref_id"], "layout", "", $_GET["frame"]));
01173 
01174                         require_once("content/classes/class.ilLMObjectFactory.php");
01175                         $lm_obj =& ilLMObjectFactory::getInstance($this->lm, $a_id);
01176 
01177                         $ilLocator->addItem(
01178                                 $lm_obj->getTitle(),
01179                                 $this->getLink($_GET["ref_id"], "layout", $a_id, $frame_param),
01180                                 $frame_target);
01181                 }
01182 
01183                 if (DEBUG)
01184                 {
01185                         $debug = "DEBUG: <font color=\"red\">".$this->type."::".$this->id."::".$_GET["cmd"]."</font><br/>";
01186                 }
01187 
01188                 //$prop_name = $this->objDefinition->getPropertyName($_GET["cmd"],$this->type);
01189 
01190 
01191                 $this->tpl->setLocator();
01192         }
01193         
01194         function getCurrentPageId()
01195         {
01196                 global $ilUser;
01197 
01198                 // determine object id
01199                 if(empty($_GET["obj_id"]))
01200                 {
01201                         $obj_id = $this->lm_tree->getRootId();
01202                 }
01203                 else
01204                 {
01205                         $obj_id = $_GET["obj_id"];
01206                 }
01207 
01208                 // obj_id not in tree -> it is a unassigned page -> return page id
01209                 if (!$this->lm_tree->isInTree($obj_id))
01210                 {
01211                         return $obj_id;
01212                 }
01213 
01214                 $curr_node = $this->lm_tree->getNodeData($obj_id);
01215                 
01216                 if ($curr_node["type"] == "pg" &&
01217                         ilLMPageObject::_lookupActive($obj_id))         // page in tree -> return page id
01218                 {
01219                         $page_id = $curr_node["obj_id"];
01220                 }
01221                 else            // no page -> search for next page and return its id
01222                 {
01223                         $succ_node = true;
01224                         $active = false;
01225                         $page_id = $obj_id;
01226                         while($succ_node && !$active)
01227                         {
01228                                 $succ_node = $this->lm_tree->fetchSuccessorNode($page_id, "pg");
01229                                 $page_id = $succ_node["obj_id"];
01230                                 $active = ilLMPageObject::_lookupActive($page_id);
01231                         }
01232 
01233                         if ($succ_node["type"] != "pg")
01234                         {
01235                                 $this->tpl = new ilTemplate("tpl.main.html", true, true);
01236                                 $this->ilias->raiseError($this->lng->txt("cont_no_page"),$this->ilias->error_obj->FATAL);
01237                                 $this->tpl->show();
01238                                 exit;
01239                         }
01240 
01241                         // if public access get first public page in chapter
01242                         if ($ilUser->getId() == ANONYMOUS_USER_ID and $this->lm_gui->object->getPublicAccessMode() == "selected")
01243                         {
01244                                 $public = ilLMObject::_isPagePublic($page_id);
01245 
01246                                 while ($public === false)
01247                                 {
01248                                         $succ_node = $this->lm_tree->fetchSuccessorNode($page_id, "pg");
01249                                         $page_id = $succ_node["obj_id"];
01250                                         $public = ilLMObject::_isPagePublic($page_id);
01251                                 }
01252                         }
01253                 }
01254 
01255                 return $page_id;
01256         }
01257 
01258         function mapCurrentPageId($current_page_id)
01259         {
01260                 $subtree = $this->lm_tree->getSubTree($this->lm_tree->getNodeData(1));
01261                 $node = $this->lm_tree->getNodeData($current_page_id);
01262                 $pos = array_search($node,$subtree);
01263 
01264                 $this->tr_obj =& $this->ilias->obj_factory->getInstanceByRefId($_SESSION["tr_id"]);
01265 
01266                 $lmtree = new ilTree($this->tr_obj->getId());
01267                 $lmtree->setTableNames('lm_tree','lm_data');
01268                 $lmtree->setTreeTablePK("lm_id");
01269 
01270                 $subtree = $lmtree->getSubTree($lmtree->getNodeData(1));
01271 
01272                 return $subtree[$pos]["child"];
01273         }
01274 
01275         function ilTranslation(&$a_page_node)
01276         {
01277                 global $ilUser;
01278 
01279                 require_once("content/classes/Pages/class.ilPageObjectGUI.php");
01280                 require_once("content/classes/class.ilLMPageObject.php");
01281 
01282                 $page_id = $this->mapCurrentPageId($this->getCurrentPageId());
01283 
01284                 if(!$page_id)
01285                 {
01286                         $this->tpl->setVariable("TRANSLATION_CONTENT","NO TRNSLATION FOUND");
01287                         return false;
01288                 }
01289 
01290                 $page_object =& new ilPageObject($this->lm->getType(), $page_id);
01291                 $page_object_gui =& new ilPageObjectGUI($page_object);
01292 
01293                 // Update personal desktop items
01294                 $this->ilias->account->setDesktopItemParameters($_SESSION["tr_id"], $this->lm->getType(),$page_id);
01295 
01296                 // Update course items
01297                 include_once './course/classes/class.ilCourseLMHistory.php';
01298 
01299                 ilCourseLMHistory::_updateLastAccess($ilUser->getId(),$this->lm->getRefId(),$page_id);
01300 
01301                 // read link targets
01302                 $targets = $this->getLayoutLinkTargets();
01303 
01304                 $lm_pg_obj =& new ilLMPageObject($this->lm, $page_id);
01305                 $lm_pg_obj->setLMId($_SESSION["tr_id"]);
01306                 //$pg_obj->setParentId($this->lm->getId());
01307                 #$page_object_gui->setLayoutLinkTargets($targets);
01308 
01309                 // USED FOR DBK PAGE TURNS
01310                 $page_object_gui->setBibId($_SESSION["bib_id"]);
01311 
01312                 // determine target frames for internal links
01313                 //$pg_frame = $_GET["frame"];
01314                 $page_object_gui->setLinkFrame($_GET["frame"]);
01315                 $page_object_gui->setOutputMode("presentation");
01316                 $page_object_gui->setOutputSubmode("translation");
01317 
01318                 $page_object_gui->setPresentationTitle(
01319                         ilLMPageObject::_getPresentationTitle($lm_pg_obj->getId(),
01320                         $this->lm->getPageHeader(), $this->lm->isActiveNumbering()));
01321 #               $page_object_gui->setLinkParams("ref_id=".$this->lm->getRefId());
01322                 $page_object_gui->setLinkParams("ref_id=".$_SESSION["tr_id"]);
01323                 $page_object_gui->setTemplateTargetVar("PAGE_CONTENT");
01324                 $page_object_gui->setTemplateOutputVar("TRANSLATION_CONTENT");
01325 
01326 
01327                 return $page_object_gui->presentation();
01328 
01329         }
01330 
01331         function ilCitation()
01332         {
01333                 $page_id = $this->getCurrentPageId();
01334                 $this->tpl = new ilTemplate("tpl.page.html",true,true,true);
01335                 $this->ilLocator();
01336                 $this->tpl->setVariable("MENU",$this->lm_gui->setilCitationMenu());
01337 
01338                 include_once("content/classes/Pages/class.ilPageObject.php");
01339 
01340                 $this->pg_obj =& new ilPageObject($this->lm->getType(),$page_id);
01341                 $xml = $this->pg_obj->getXMLContent();
01342                 $this->lm_gui->showCitation($xml);
01343                 $this->tpl->show();
01344         }
01345 
01346 
01347         function getLayoutLinkTargets()
01348         {
01349 
01350                 if (!is_object($this->layout_doc))
01351                         return array ();
01352 
01353                 $xpc = xpath_new_context($this->layout_doc);
01354 
01355                 $path = "/ilLayout/ilLinkTargets/LinkTarget";
01356                 $res = xpath_eval($xpc, $path);
01357                 $targets = array();
01358                 for ($i = 0; $i < count($res->nodeset); $i++)
01359                 {
01360                         $type = $res->nodeset[$i]->get_attribute("Type");
01361                         $frame = $res->nodeset[$i]->get_attribute("Frame");
01362                         $targets[$type] = array("Type" => $type, "Frame" => $frame);
01363                 }
01364                 return $targets;
01365         }
01366 
01370         function ilPage(&$a_page_node, $a_page_id = 0)
01371         {
01372                 global $ilBench,$ilUser;
01373 
01374                 if ($ilUser->getId() == ANONYMOUS_USER_ID and $this->lm_gui->object->getPublicAccessMode() == "selected")
01375                 {
01376                         $public = ilLMObject::_isPagePublic($this->getCurrentPageId());
01377 
01378                         if (!$public)
01379                                 return $this->showNoPublicAccess($this->getCurrentPageId());
01380                 }
01381 
01382                 if (!ilObjContentObject::_checkPreconditionsOfPage($this->lm->getId(), $this->getCurrentPageId()))
01383                 {
01384                         return $this->showPreconditionsOfPage($this->getCurrentPageId());
01385                 }
01386 
01387                 $ilBench->start("ContentPresentation", "ilPage");
01388 
01389                 require_once("content/classes/Pages/class.ilPageObjectGUI.php");
01390                 require_once("content/classes/class.ilLMPageObject.php");
01391                 
01392                 // page id is e.g. > 0 when footer or header page is processed
01393                 if ($a_page_id == 0)
01394                 {
01395                         $ilBench->start("ContentPresentation", "ilPage_getCurrentPageId");
01396                         $page_id = $this->getCurrentPageId();
01397                         $ilBench->stop("ContentPresentation", "ilPage_getCurrentPageId");
01398                 }
01399                 else
01400                 {
01401                         $page_id = $a_page_id;
01402                 }
01403                 
01404                 $ilBench->start("ContentPresentation", "ilPage_getPageObject");
01405                 $page_object =& new ilPageObject($this->lm->getType(), $page_id);
01406                 $page_object->buildDom();
01407                 $page_object->registerOfflineHandler($this);
01408                 $ilBench->stop("ContentPresentation", "ilPage_getPageObject");
01409                 
01410                 $ilBench->start("ContentPresentation", "ilPage_getInternalLinks");
01411                 $int_links = $page_object->getInternalLinks();
01412                 $ilBench->stop("ContentPresentation", "ilPage_getInternalLinks");
01413                 
01414                 $ilBench->start("ContentPresentation", "ilPage_getPageObjectGUI");
01415                 $page_object_gui =& new ilPageObjectGUI($page_object);
01416                 $page_object_gui->setTemplateOutput(false);
01417                 $ilBench->stop("ContentPresentation", "ilPage_getPageObjectGUI");
01418                 
01419                 // Update personal desktop items
01420                 $this->ilias->account->setDesktopItemParameters($this->lm->getRefId(), $this->lm->getType(), $page_id);
01421 
01422                 // Update course items
01423                 $ilBench->start("ContentPresentation", "ilPage_updateCourseItems");
01424                 include_once './course/classes/class.ilCourseLMHistory.php';
01425                 ilCourseLMHistory::_updateLastAccess($ilUser->getId(),$this->lm->getRefId(),$page_id);
01426                 $ilBench->stop("ContentPresentation", "ilPage_updateCourseItems");
01427 
01428                 // read link targets
01429                 $link_xml = $this->getLinkXML($int_links, $this->getLayoutLinkTargets());
01430 //echo "<br>+".htmlentities($link_xml)."+";
01431                 
01432                 // get lm page object
01433                 $ilBench->start("ContentPresentation", "ilPage_getLMPageObject");
01434                 $lm_pg_obj =& new ilLMPageObject($this->lm, $page_id);
01435                 $lm_pg_obj->setLMId($this->lm->getId());
01436                 $page_object_gui->setLinkXML($link_xml);
01437                 $ilBench->stop("ContentPresentation", "ilPage_getLMPageObject");
01438 
01439                 $ilBench->start("ContentPresentation", "ilPage_preparePage");
01440                 
01441                 // USED FOR DBK PAGE TURNS
01442                 $page_object_gui->setBibId($_SESSION["bib_id"]);
01443                 $page_object_gui->enableCitation((bool) $_SESSION["citation"]);
01444 
01445                 // determine target frames for internal links
01446                 //$pg_frame = $_GET["frame"];
01447                 $page_object_gui->setLinkFrame($_GET["frame"]);
01448                 if (!$this->offlineMode())
01449                 {
01450                         $page_object_gui->setOutputMode("presentation");
01451                 }
01452                 else
01453                 {
01454                         $page_object_gui->setOutputMode("offline");
01455                         $page_object_gui->setOfflineDirectory($this->getOfflineDirectory());
01456                 }               
01457                 $page_object_gui->setFileDownloadLink($this->getLink($_GET["ref_id"], "downloadFile"));
01458                 $page_object_gui->setFullscreenLink($this->getLink($_GET["ref_id"], "fullscreen"));
01459                 
01460                 
01461                 // page title (not for header or footer page)
01462                 if ($page_id == 0 || ($page_id != $this->lm->getHeaderPage() &&
01463                         $page_id != $this->lm->getFooterPage()))
01464                 {
01465                         $page_object_gui->setPresentationTitle(
01466                                 ilLMPageObject::_getPresentationTitle($lm_pg_obj->getId(),
01467                                 $this->lm->getPageHeader(), $this->lm->isActiveNumbering()));
01468                 }
01469 
01470                 // ADDED FOR CITATION
01471                 $page_object_gui->setLinkParams("ref_id=".$this->lm->getRefId());
01472                 $page_object_gui->setTemplateTargetVar("PAGE_CONTENT");
01473                 $page_object_gui->setSourcecodeDownloadScript($this->getSourcecodeDownloadLink());
01474 
01475                 if($_SESSION["tr_id"])
01476                 {
01477                         $page_object_gui->setOutputSubmode("translation");
01478                 }
01479 
01480                 // content style
01481                 $this->tpl->setCurrentBlock("ContentStyle");
01482                 if (!$this->offlineMode())
01483                 {
01484                         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
01485                                 ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
01486                 }
01487                 else
01488                 {
01489                         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content.css");
01490                 }
01491                 $this->tpl->parseCurrentBlock();
01492 
01493                 // syntax style
01494                 $this->tpl->setCurrentBlock("SyntaxStyle");
01495                 if (!$this->offlineMode())
01496                 {
01497                         $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
01498                                 ilObjStyleSheet::getSyntaxStylePath());
01499                 }
01500                 else
01501                 {
01502                         $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
01503                                 "syntaxhighlight.css");
01504                 }
01505                 $this->tpl->parseCurrentBlock();
01506                 
01507                 $ilBench->stop("ContentPresentation", "ilPage_preparePage");
01508 
01509                 // track user access to page
01510                 $ilBench->start("ContentPresentation", "ilPage_trackUserAccess");
01511                 include_once "Services/Tracking/classes/class.ilTracking.php";
01512                 ilTracking::_trackAccess($this->lm->getId(), $this->lm->getType(),
01513                         $page_id, "pg", "read");
01514                 $ilBench->stop("ContentPresentation", "ilPage_trackUserAccess");
01515 
01516                 $ilBench->start("ContentPresentation", "ilPage_getPageContent");
01517                 $ret = $page_object_gui->presentation($page_object_gui->getOutputMode());
01518                 $ilBench->stop("ContentPresentation", "ilPage_getPageContent");
01519                 
01520                 $ilBench->stop("ContentPresentation", "ilPage");
01521                 
01522                 // process header
01523                 if ($this->lm->getHeaderPage() > 0 && 
01524                         $page_id != $this->lm->getHeaderPage() &&
01525                         ($page_id == 0 || $page_id != $this->lm->getFooterPage()))
01526                 {
01527                         if (ilLMObject::_exists($this->lm->getHeaderPage()))
01528                         {
01529                                 $head = $this->ilPage($a_page_node, $this->lm->getHeaderPage());
01530                         }
01531                 }
01532 
01533                 // process footer
01534                 if ($this->lm->getFooterPage() > 0 && 
01535                         $page_id != $this->lm->getFooterPage() &&
01536                         ($page_id == 0 || $page_id != $this->lm->getHeaderPage()))
01537                 {
01538                         if (ilLMObject::_exists($this->lm->getFooterPage()))
01539                         {
01540                                 $foot = $this->ilPage($a_page_node, $this->lm->getFooterPage());
01541                         }
01542                 }
01543                 
01544                 $this->tpl->setVariable("PAGE_CONTENT", $head.$ret.$foot); 
01545 //echo htmlentities("-".$ret."-");
01546                 return $head.$ret.$foot;
01547 
01548         }
01549 
01553         function showPreconditionsOfPage()
01554         {
01555                 global $ilBench;
01556 
01557                 $ilBench->start("ContentPresentation", "showPagePreconditions");
01558                 $conds = ilObjContentObject::_getMissingPreconditionsOfPage($this->lm->getId(), $this->getCurrentPageId());
01559                 $topchap = ilObjContentObject::_getMissingPreconditionsTopChapter($this->lm->getId(), $this->getCurrentPageId());
01560 
01561                 $page_id = $this->getCurrentPageId();
01562 
01563                 // content style
01564                 $this->tpl->setCurrentBlock("ContentStyle");
01565                 if (!$this->offlineMode())
01566                 {
01567                         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
01568                                 ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
01569                 }
01570                 else
01571                 {
01572                         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content.css");
01573                 }
01574                 $this->tpl->parseCurrentBlock();
01575 
01576                 $this->tpl->addBlockFile("PAGE_CONTENT", "pg_content", "tpl.page_preconditions.html", true);
01577                 
01578                 // list all missing preconditions
01579                 include_once("classes/class.ilRepositoryExplorer.php");
01580                 foreach($conds as $cond)
01581                 {
01582                         $obj_link = ilRepositoryExplorer::buildLinkTarget($cond["trigger_ref_id"],$cond["trigger_type"]);
01583                         $obj_frame = ilRepositoryExplorer::buildFrameTarget($cond["trigger_type"],$cond["trigger_ref_id"],$cond["trigger_obj_id"]);
01584                         $this->tpl->setCurrentBlock("condition");
01585                         $this->tpl->setVariable("ROWCOL", $rc = ($rc != "tblrow2") ? "tblrow2" : "tblrow1");
01586                         $this->tpl->setVariable("VAL_ITEM", ilObject::_lookupTitle($cond["trigger_obj_id"]));
01587                         $this->tpl->setVariable("LINK_ITEM", $obj_link);
01588                         $this->tpl->setVariable("FRAME_ITEM", $obj_frame);
01589                         if ($cond["operator"] == "passed")
01590                         {
01591                                 $cond_str = $this->lng->txt("passed");
01592                         }
01593                         else
01594                         {
01595                                 $cond_str = $cond["operator"];
01596                         }
01597                         $this->tpl->setVariable("VAL_CONDITION", $cond_str." ".$cond["value"]);
01598                         $this->tpl->parseCurrentBlock();
01599                 }
01600                 $this->tpl->setCurrentBlock("pg_content");
01601                 
01602                 //include_once("content/classes/class.ilLMObject.php");
01603                 $this->tpl->setVariable("TXT_MISSING_PRECONDITIONS", 
01604                         sprintf($this->lng->txt("cont_missing_preconditions"),
01605                         ilLMObject::_lookupTitle($topchap)));
01606                 $this->tpl->setVariable("TXT_ITEM", $this->lng->txt("item"));
01607                 $this->tpl->setVariable("TXT_CONDITION", $this->lng->txt("condition"));
01608                 
01609                 // output skip chapter link
01610                 $parent = $this->lm_tree->getParentId($topchap);
01611                 $childs = $this->lm_tree->getChildsByType($parent, "st");
01612                 $next = "";
01613                 $j=-2; $i=1; 
01614                 foreach($childs as $child)
01615                 {
01616                         if ($child["child"] == $topchap)
01617                         {
01618                                 $j = $i;
01619                         }
01620                         if ($i++ == ($j+1))
01621                         {
01622                                 $succ_node = $this->lm_tree->fetchSuccessorNode($child["child"], "pg");
01623                         }
01624                 }
01625                 if($succ_node != "")
01626                 {
01627                         $framestr = (!empty($_GET["frame"]))
01628                                 ? "frame=".$_GET["frame"]."&"
01629                                 : "";
01630                         //$showViewInFrameset = $this->ilias->ini->readVariable("layout","view_target") == "frame";
01631                         $showViewInFrameset = true;
01632                         $link = "<br /><a href=\"".
01633                                 $this->getLink($this->lm->getRefId(), "layout", $succ_node["obj_id"], $_GET["frame"]).
01634                                 "\">".$this->lng->txt("cont_skip_chapter")."</a>";
01635                         $this->tpl->setVariable("LINK_SKIP_CHAPTER", $link);
01636                 }
01637                 
01638                 $this->tpl->parseCurrentBlock();
01639                 
01640                 $ilBench->stop("ContentPresentation", "showPagePreconditions");
01641         }
01642         
01646         function getLinkXML($a_int_links, $a_layoutframes)
01647         {
01648                 // Determine whether the view of a learning resource should
01649                 // be shown in the frameset of ilias, or in a separate window.
01650                 //$showViewInFrameset = $this->ilias->ini->readVariable("layout","view_target") == "frame";
01651                 $showViewInFrameset = true;
01652 
01653                 if ($a_layoutframes == "")
01654                 {
01655                         $a_layoutframes = array();
01656                 }
01657                 $link_info = "<IntLinkInfos>";
01658                 foreach ($a_int_links as $int_link)
01659                 {
01660                         $target = $int_link["Target"];
01661                         if (substr($target, 0, 4) == "il__")
01662                         {
01663                                 $target_arr = explode("_", $target);
01664                                 $target_id = $target_arr[count($target_arr) - 1];
01665                                 $type = $int_link["Type"];
01666                                 $targetframe = ($int_link["TargetFrame"] != "")
01667                                         ? $int_link["TargetFrame"]
01668                                         : "None";
01669 
01670                                 switch($type)
01671                                 {
01672                                         case "PageObject":
01673                                         case "StructureObject":
01674                                                 $lm_id = ilLMObject::_lookupContObjID($target_id);
01675                                                 if ($lm_id == $this->lm->getId() ||
01676                                                         ($targetframe != "None" && $targetframe != "New"))
01677                                                 {
01678                                                         $ltarget = $a_layoutframes[$targetframe]["Frame"];
01679                                                         //$nframe = ($ltarget == "")
01680                                                         //      ? $_GET["frame"]
01681                                                         //      : $ltarget;
01682                                                         $nframe = ($ltarget == "")
01683                                                                 ? ""
01684                                                                 : $ltarget;
01685                                                         if ($ltarget == "")
01686                                                         {
01687                                                                 if ($showViewInFrameset) {
01688                                                                         $ltarget="_parent";
01689                                                                 } else {
01690                                                                         $ltarget="_top";
01691                                                                 }
01692                                                         }
01693                                                         // scorm always in 1window view and link target
01694                                                         // is always same frame
01695                                                         if ($this->getExportFormat() == "scorm" &&
01696                                                                 $this->offlineMode())
01697                                                         {
01698                                                                 $ltarget = "";
01699                                                         }
01700                                                         $href =
01701                                                                 $this->getLink($_GET["ref_id"], "layout", $target_id, $nframe, $type);
01702                                                 }
01703                                                 else
01704                                                 {
01705                                                         if (!$this->offlineMode())
01706                                                         {
01707                                                                 if ($type == "PageObject")
01708                                                                 {
01709                                                                         $href = "./goto.php?target=pg_".$target_id;
01710                                                                 }
01711                                                                 else
01712                                                                 {
01713                                                                         $href = "./goto.php?target=st_".$target_id;
01714                                                                 }
01715                                                         }
01716                                                         else
01717                                                         {
01718                                                                 if ($type == "PageObject")
01719                                                                 {
01720                                                                         $href = ILIAS_HTTP_PATH."/goto.php?target=pg_".$target_id."&amp;client_id=".CLIENT_ID;
01721                                                                 }
01722                                                                 else
01723                                                                 {
01724                                                                         $href = ILIAS_HTTP_PATH."/goto.php?target=st_".$target_id."&amp;client_id=".CLIENT_ID;
01725                                                                 }
01726                                                         }
01727                                                         $ltarget = ilFrameTargetInfo::_getFrame("MainContent");
01728                                                 }
01729                                                 break;
01730 
01731                                         case "GlossaryItem":
01732                                                 if ($targetframe == "None")
01733                                                 {
01734                                                         $targetframe = "Glossary";
01735                                                 }
01736                                                 $ltarget = $a_layoutframes[$targetframe]["Frame"];
01737                                                 $nframe = ($ltarget == "")
01738                                                         ? $_GET["frame"]
01739                                                         : $ltarget;
01740                                                 $href =
01741                                                         $this->getLink($_GET["ref_id"], $a_cmd = "glossary", $target_id, $nframe, $type);
01742                                                 break;
01743 
01744                                         case "MediaObject":
01745                                                 $ltarget = $a_layoutframes[$targetframe]["Frame"];
01746                                                 $nframe = ($ltarget == "")
01747                                                         ? $_GET["frame"]
01748                                                         : $ltarget;
01749                                                 $href =
01750                                                         $this->getLink($_GET["ref_id"], $a_cmd = "media", $target_id, $nframe, $type);
01751                                                 break;
01752 
01753                                         case "RepositoryItem":
01754                                                 $obj_type = ilObject::_lookupType($target_id, true);
01755                                                 $obj_id = ilObject::_lookupObjId($target_id);
01756                                                 if (!$this->offlineMode())
01757                                                 {
01758                                                         $href = "./goto.php?target=".$obj_type."_".$target_id;
01759                                                 }
01760                                                 else
01761                                                 {
01762                                                         $href = ILIAS_HTTP_PATH."/goto.php?target=".$obj_type."_".$target_id."&amp;client_id=".CLIENT_ID;
01763                                                 }
01764                                                 $ltarget = ilFrameTargetInfo::_getFrame("MainContent");
01765                                                 break;
01766 
01767                                 }
01768                                 $link_info.="<IntLinkInfo Target=\"$target\" Type=\"$type\" ".
01769                                         "TargetFrame=\"$targetframe\" LinkHref=\"$href\" LinkTarget=\"$ltarget\" />";
01770 
01771                                 // set equal link info for glossary links of target "None" and "Glossary"
01772                                 /*
01773                                 if ($targetframe=="None" && $type=="GlossaryItem")
01774                                 {
01775                                         $link_info.="<IntLinkInfo Target=\"$target\" Type=\"$type\" ".
01776                                                 "TargetFrame=\"Glossary\" LinkHref=\"$href\" LinkTarget=\"$ltarget\" />";
01777                                 }*/
01778                         }
01779                 }
01780                 $link_info.= "</IntLinkInfos>";
01781 
01782                 return $link_info;
01783         }
01784 
01785 
01789         function ilGlossary()
01790         {
01791                 global $ilBench;
01792 
01793                 $ilBench->start("ContentPresentation", "ilGlossary");
01794 
01795                 //require_once("content/classes/Pages/class.ilPageObjectGUI.php");
01796                 //require_once("content/classes/class.ilLMPageObject.php");
01797 
01798                 require_once("content/classes/class.ilGlossaryTermGUI.php");
01799                 $term_gui =& new ilGlossaryTermGUI($_GET["obj_id"]);
01800 
01801                 // content style
01802                 $this->tpl->setCurrentBlock("ContentStyle");
01803                 if (!$this->offlineMode())
01804                 {
01805                         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
01806                                 ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
01807                 }
01808                 else
01809                 {
01810                         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content.css");
01811                 }
01812                 $this->tpl->parseCurrentBlock();
01813 
01814                 // syntax style
01815                 $this->tpl->setCurrentBlock("SyntaxStyle");
01816 
01817                 if (!$this->offlineMode())
01818                 {
01819                         $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
01820                                 ilObjStyleSheet::getSyntaxStylePath());
01821                 }
01822                 else
01823                 {
01824                         $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
01825                                 "syntaxhighlight.css");
01826                 }
01827                 $this->tpl->parseCurrentBlock();
01828 
01829                 $int_links = $term_gui->getInternalLinks();
01830                 $link_xml = $this->getLinkXML($int_links, $this->getLayoutLinkTargets());
01831                 $term_gui->setLinkXML($link_xml);
01832 
01833                 $term_gui->output($this->offlineMode(), "content/");
01834                 //$term_gui->listDefinitions($this->offlineMode());
01835 
01836                 $ilBench->stop("ContentPresentation", "ilGlossary");
01837         }
01838 
01842         function ilMedia()
01843         {
01844                 global $ilBench;
01845 
01846                 $ilBench->start("ContentPresentation", "ilMedia");
01847 
01848                 $this->tpl->setCurrentBlock("ContentStyle");
01849                 if (!$this->offlineMode())
01850                 {
01851                         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
01852                                 ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
01853                 }
01854                 else
01855                 {
01856                         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content.css");
01857                 }
01858                 $this->tpl->parseCurrentBlock();
01859 
01860                 $this->tpl->setVariable("PAGETITLE", " - ".$this->lm->getTitle());
01861                 
01862                 // set style sheets
01863                 if (!$this->offlineMode())
01864                 {
01865                         $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
01866                 }
01867                 else
01868                 {
01869                         $style_name = $this->ilias->account->prefs["style"].".css";;
01870                         $this->tpl->setVariable("LOCATION_STYLESHEET","./".$style_name);
01871                 }
01872 
01873                 $this->tpl->setCurrentBlock("ilMedia");
01874 
01875                 //$int_links = $page_object->getInternalLinks();
01876                 $med_links = ilMediaItem::_getMapAreasIntLinks($_GET["mob_id"]);
01877                 $link_xml = $this->getLinkXML($med_links, $this->getLayoutLinkTargets());
01878 //echo "<br><br>".htmlentities($link_xml);
01879                 require_once("content/classes/Media/class.ilObjMediaObject.php");
01880                 $media_obj =& new ilObjMediaObject($_GET["mob_id"]);
01881                 if (!empty ($_GET["pg_id"]))
01882                 {
01883                         require_once("content/classes/Pages/class.ilPageObject.php");
01884                         $pg_obj =& new ilPageObject($this->lm->getType(), $_GET["pg_id"]);
01885                         $pg_obj->buildDom();
01886 
01887                         $xml = "<dummy>";
01888                         // todo: we get always the first alias now (problem if mob is used multiple
01889                         // times in page)
01890                         $xml.= $pg_obj->getMediaAliasElement($_GET["mob_id"]);
01891                         $xml.= $media_obj->getXML(IL_MODE_OUTPUT);
01892                         $xml.= $link_xml;
01893                         $xml.="</dummy>";
01894                 }
01895                 else
01896                 {
01897                         $xml = "<dummy>";
01898                         // todo: we get always the first alias now (problem if mob is used multiple
01899                         // times in page)
01900                         $xml.= $media_obj->getXML(IL_MODE_ALIAS);
01901                         $xml.= $media_obj->getXML(IL_MODE_OUTPUT);
01902                         $xml.= $link_xml;
01903                         $xml.="</dummy>";
01904                 }
01905 
01906 //echo htmlentities($xml); exit;
01907 
01908                 // todo: utf-header should be set globally
01909                 //header('Content-type: text/html; charset=UTF-8');
01910 
01911                 $xsl = file_get_contents("./content/page.xsl");
01912                 $args = array( '/_xml' => $xml, '/_xsl' => $xsl );
01913                 $xh = xslt_create();
01914 
01915 //echo "<b>XML:</b>".htmlentities($xml);
01916                 // determine target frames for internal links
01917                 //$pg_frame = $_GET["frame"];
01918                 if (!$this->offlineMode())
01919                 {
01920                         $wb_path = ilUtil::getWebspaceDir("output");
01921                 }
01922                 else
01923                 {
01924                         $wb_path = ".";
01925                 }
01926 //              $wb_path = "../".$this->ilias->ini->readVariable("server","webspace_dir");
01927                 $mode = ($_GET["cmd"] == "fullscreen")
01928                         ? "fullscreen"
01929                         : "media";
01930                 $enlarge_path = ilUtil::getImagePath("enlarge.gif", false, "output", $this->offlineMode());
01931                 $fullscreen_link =
01932                         $this->getLink($this->lm->getRefId(), "fullscreen");
01933                 $params = array ('mode' => $mode, 'enlarge_path' => $enlarge_path,
01934                         'link_params' => "ref_id=".$this->lm->getRefId(),'fullscreen_link' => $fullscreen_link,
01935                         'ref_id' => $this->lm->getRefId(), 'pg_frame' => $pg_frame, 'webspace_path' => $wb_path);
01936                 $output = xslt_process($xh,"arg:/_xml","arg:/_xsl",NULL,$args, $params);
01937                 echo xslt_error($xh);
01938                 xslt_free($xh);
01939 
01940                 // unmask user html
01941                 $this->tpl->setVariable("MEDIA_CONTENT", $output);
01942 
01943                 $ilBench->stop("ContentPresentation", "ilMedia");
01944         }
01945 
01946 
01951         function ilLMNavigation()
01952         {
01953                 global $ilBench,$ilUser;
01954 
01955                 $ilBench->start("ContentPresentation", "ilLMNavigation");
01956 
01957                 $page_id = $this->getCurrentPageId();
01958 
01959                 if(empty($page_id))
01960                 {
01961                         return;
01962                 }
01963 
01964                 // process navigation for free page
01965                 if(!$this->lm_tree->isInTree($page_id))
01966                 {
01967                         if ($this->offlineMode() || $_GET["back_pg"] == "")
01968                         {
01969                                 return;
01970                         }
01971                         $limpos = strpos($_GET["back_pg"], ":");
01972                         if ($limpos > 0)
01973                         {
01974                                 $back_pg = substr($_GET["back_pg"], 0, $limpos);
01975                         }
01976                         else
01977                         {
01978                                 $back_pg = $_GET["back_pg"];
01979                         }
01980                         if (!$this->lm->cleanFrames())
01981                         {
01982                                 $back_href =
01983                                         $this->getLink($this->lm->getRefId(), "layout", $back_pg, $_GET["frame"],
01984                                                 "", "reduce");
01985                                 $back_target = "";
01986                         }
01987                         else
01988                         {
01989                                 $back_href =
01990                                         $this->getLink($this->lm->getRefId(), "layout", $back_pg, "",
01991                                                 "", "reduce");
01992                                 $back_target = 'target="'.ilFrameTargetInfo::_getFrame("MainContent").'" ';
01993                         }
01994                         $back_img =
01995                                 ilUtil::getImagePath("nav_arr2_L.gif", false, "output", $this->offlineMode());
01996                         $this->tpl->setCurrentBlock("ilLMNavigation_Prev");
01997                         $this->tpl->setVariable("IMG_PREV", $back_img);
01998                         $this->tpl->setVariable("HREF_PREV", $back_href);
01999                         $this->tpl->setVariable("FRAME_PREV", $back_target);
02000                         $this->tpl->setVariable("TXT_PREV", $this->lng->txt("back"));
02001                         $this->tpl->setVariable("ALT_PREV", $this->lng->txt("back"));
02002                         $this->tpl->parseCurrentBlock();
02003                         $this->tpl->setCurrentBlock("ilLMNavigation_Prev2");
02004                         $this->tpl->setVariable("IMG_PREV2", $back_img);
02005                         $this->tpl->setVariable("HREF_PREV2", $back_href);
02006                         $this->tpl->setVariable("FRAME_PREV2", $back_target);
02007                         $this->tpl->setVariable("TXT_PREV2", $this->lng->txt("back"));
02008                         $this->tpl->setVariable("ALT_PREV2", $this->lng->txt("back"));
02009                         $this->tpl->parseCurrentBlock();
02010                         return;
02011                 }
02012 
02013                 // determine successor page_id
02014                 $ilBench->start("ContentPresentation", "ilLMNavigation_fetchSuccessor");
02015                 $found = false;
02016                 $c_id = $page_id;
02017                 while (!$found)
02018                 {
02019                         $succ_node = $this->lm_tree->fetchSuccessorNode($c_id, "pg");
02020                         $c_id = $succ_node["obj_id"];
02021                         if ($succ_node["obj_id"] > 0 &&
02022                                 $ilUser->getId() == ANONYMOUS_USER_ID &&
02023                                 ( $this->lm->getPublicAccessMode() == "selected" &&
02024                                 !ilLMObject::_isPagePublic($succ_node["obj_id"])))
02025                         {
02026                                 $found = false;
02027                         }
02028                         else if ($succ_node["obj_id"] > 0 &&
02029                                 !ilLMObject::_lookupActive($succ_node["obj_id"]))
02030                         {
02031                                 $found = false;
02032                         }
02033                         else
02034                         {
02035                                 $found = true;
02036                         }
02037                 }
02038                 $ilBench->stop("ContentPresentation", "ilLMNavigation_fetchSuccessor");
02039 
02040                 $succ_str = ($succ_node !== false)
02041                         ? " -> ".$succ_node["obj_id"]."_".$succ_node["type"]
02042                         : "";
02043 
02044                 // determine predecessor page id
02045                 $ilBench->start("ContentPresentation", "ilLMNavigation_fetchPredecessor");
02046                 $found = false;
02047                 $c_id = $page_id;
02048                 while (!$found)
02049                 {
02050                         $pre_node = $this->lm_tree->fetchPredecessorNode($c_id, "pg");
02051                         $c_id = $pre_node["obj_id"];
02052                         if ($pre_node["obj_id"] > 0 &&
02053                                 $ilUser->getId() == ANONYMOUS_USER_ID &&
02054                                 ($this->lm->getPublicAccessMode() == "selected" &&
02055                                 !ilLMObject::_isPagePublic($pre_node["obj_id"])))
02056                         {
02057                                 $found = false;
02058                         }
02059                         else if ($pre_node["obj_id"] > 0 &&
02060                                 !ilLMObject::_lookupActive($pre_node["obj_id"]))
02061                         {
02062                                 $found = false;
02063                         }
02064                         else
02065                         {
02066                                 $found = true;
02067                         }
02068                 }
02069                 $ilBench->stop("ContentPresentation", "ilLMNavigation_fetchPredecessor");
02070 
02071                 $pre_str = ($pre_node !== false)
02072                         ? $pre_node["obj_id"]."_".$pre_node["type"]." -> "
02073                         : "";
02074 
02075                 // determine target frame
02076                 $framestr = (!empty($_GET["frame"]))
02077                         ? "frame=".$_GET["frame"]."&"
02078                         : "";
02079 
02080 
02081                 // Determine whether the view of a learning resource should
02082                 // be shown in the frameset of ilias, or in a separate window.
02083                 //$showViewInFrameset = $this->ilias->ini->readVariable("layout","view_target") == "frame";
02084                 $showViewInFrameset = true;
02085 
02086                 if($pre_node != "")
02087                 {
02088                         $ilBench->start("ContentPresentation", "ilLMNavigation_outputPredecessor");
02089 
02090                         // get page object
02091                         //$ilBench->start("ContentPresentation", "ilLMNavigation_getPageObject");
02092                         //$pre_page =& new ilLMPageObject($this->lm, $pre_node["obj_id"]);
02093                         //$pre_page->setLMId($this->lm->getId());
02094                         //$ilBench->stop("ContentPresentation", "ilLMNavigation_getPageObject");
02095 
02096                         // get presentation title
02097                         $ilBench->start("ContentPresentation", "ilLMNavigation_getPresentationTitle");
02098                         $prev_title = ilLMPageObject::_getPresentationTitle($pre_node["obj_id"],
02099                                 $this->lm->getPageHeader(), $this->lm->isActiveNumbering());
02100                         $prev_title = ilUtil::shortenText($prev_title, 50, true);
02101                         $prev_img = 
02102                                 ilUtil::getImagePath("nav_arr_L.gif", false, "output", $this->offlineMode());
02103 
02104                         if (!$this->lm->cleanFrames())
02105                         {
02106                                 $prev_href =
02107                                         $this->getLink($this->lm->getRefId(), "layout", $pre_node["obj_id"], $_GET["frame"]);
02108                                 $prev_target = "";
02109                         }
02110                         else if ($showViewInFrameset && !$this->offlineMode())
02111                         {
02112                                 $prev_href =
02113                                         $this->getLink($this->lm->getRefId(), "layout", $pre_node["obj_id"]);
02114                                 $prev_target = 'target="'.ilFrameTargetInfo::_getFrame("MainContent").'" ';
02115                         }
02116                         else
02117                         {
02118                                 $prev_href =
02119                                         $this->getLink($this->lm->getRefId(), "layout", $pre_node["obj_id"]);
02120                                 $prev_target = 'target="_top" ';
02121                         }
02122                         
02123                         if ($ilUser->getId() == ANONYMOUS_USER_ID and ($this->lm->getPublicAccessMode() == "selected" and !ilLMObject::_isPagePublic($pre_node["obj_id"])))
02124                         {
02125                                 $output = $this->lng->txt("msg_page_not_public");
02126                         }
02127                         
02128                         $ilBench->stop("ContentPresentation", "ilLMNavigation_getPresentationTitle");
02129                         
02130                         $this->tpl->setCurrentBlock("ilLMNavigation_Prev");
02131                         $this->tpl->setVariable("IMG_PREV", $prev_img);
02132                         $this->tpl->setVariable("HREF_PREV", $prev_href);
02133                         $this->tpl->setVariable("FRAME_PREV", $prev_target);
02134                         $this->tpl->setVariable("TXT_PREV", $prev_title);
02135                         $this->tpl->setVariable("ALT_PREV", $this->lng->txt("previous"));
02136                         $this->tpl->parseCurrentBlock();
02137                         $this->tpl->setCurrentBlock("ilLMNavigation_Prev2");
02138                         $this->tpl->setVariable("IMG_PREV2", $prev_img);
02139                         $this->tpl->setVariable("HREF_PREV2", $prev_href);
02140                         $this->tpl->setVariable("FRAME_PREV2", $prev_target);
02141                         $this->tpl->setVariable("TXT_PREV2", $prev_title);
02142                         $this->tpl->setVariable("ALT_PREV2", $this->lng->txt("previous"));
02143                         $this->tpl->parseCurrentBlock();
02144                         $ilBench->stop("ContentPresentation", "ilLMNavigation_outputPredecessor");
02145                 }
02146                 if($succ_node != "")
02147                 {
02148                         $ilBench->start("ContentPresentation", "ilLMNavigation_outputSuccessor");
02149 
02150                         // get presentation title
02151                         $ilBench->start("ContentPresentation", "ilLMNavigation_getPresentationTitle");
02152                         $succ_title = ilLMPageObject::_getPresentationTitle($succ_node["obj_id"],
02153                                 $this->lm->getPageHeader(), $this->lm->isActiveNumbering());
02154                         $succ_title = ilUtil::shortenText($succ_title,50,true);
02155                         $succ_img =
02156                                 ilUtil::getImagePath("nav_arr_R.gif", false, "output", $this->offlineMode());
02157                         if (!$this->lm->cleanFrames())
02158                         {
02159                                 $succ_href =
02160                                         $this->getLink($this->lm->getRefId(), "layout", $succ_node["obj_id"], $_GET["frame"]);
02161                                 $succ_target = "";
02162                         }
02163                         else if ($showViewInFrameset && !$this->offlineMode())
02164                         {
02165                                 $succ_href =
02166                                         $this->getLink($this->lm->getRefId(), "layout", $succ_node["obj_id"]);
02167                                 $succ_target = ' target="'.ilFrameTargetInfo::_getFrame("MainContent").'" ';
02168                         }
02169                         else
02170                         {
02171                                 $succ_href =
02172                                         $this->getLink($this->lm->getRefId(), "layout", $succ_node["obj_id"]);
02173                                 $succ_target = ' target="_top" ';
02174                         }
02175                         
02176                         if ($ilUser->getId() == ANONYMOUS_USER_ID and ($this->lm->getPublicAccessMode() == "selected" and !ilLMObject::_isPagePublic($succ_node["obj_id"])))
02177                         {
02178                                 $output = $this->lng->txt("msg_page_not_public");
02179                         }
02180 
02181                         $ilBench->stop("ContentPresentation", "ilLMNavigation_getPresentationTitle");
02182                         
02183                         $this->tpl->setCurrentBlock("ilLMNavigation_Next");
02184                         $this->tpl->setVariable("IMG_SUCC", $succ_img);
02185                         $this->tpl->setVariable("HREF_SUCC", $succ_href);
02186                         $this->tpl->setVariable("FRAME_SUCC", $succ_target);
02187                         $this->tpl->setVariable("TXT_SUCC", $succ_title);
02188                         $this->tpl->setVariable("ALT_SUCC", $this->lng->txt("next"));
02189                         $this->tpl->parseCurrentBlock();
02190                         $this->tpl->setCurrentBlock("ilLMNavigation_Next2");
02191                         $this->tpl->setVariable("IMG_SUCC2", $succ_img);
02192                         $this->tpl->setVariable("HREF_SUCC2", $succ_href);
02193                         $this->tpl->setVariable("FRAME_SUCC2", $succ_target);
02194                         $this->tpl->setVariable("TXT_SUCC2", $succ_title);
02195                         $this->tpl->setVariable("ALT_SUCC2", $this->lng->txt("next"));
02196                         $this->tpl->parseCurrentBlock();
02197                         $ilBench->stop("ContentPresentation", "ilLMNavigation_outputSuccessor");
02198                 }
02199 
02200                 $ilBench->stop("ContentPresentation", "ilLMNavigation");
02201         }
02202 
02203 
02204         function processNodes(&$a_content, &$a_node)
02205         {
02206                 $child_nodes = $a_node->child_nodes();
02207                 foreach ($child_nodes as $child)
02208                 {
02209                         if($child->node_name() == "ilFrame")
02210                         {
02211                                 $attributes = $this->attrib2arr($child->attributes());
02212                                 // node is frameset, if it has cols or rows attribute
02213                                 if ((!empty($attributes["rows"])) || (!empty($attrubtes["cols"])))
02214                                 {
02215                                         // if framset has name, another http request is necessary
02216                                         // (html framesets don't have names, so we need a wrapper frame)
02217                                         if(!empty($attributes["name"]))
02218                                         {
02219                                                 unset($attributes["template"]);
02220                                                 unset($attributes["template_location"]);
02221                                                 $attributes["src"] =
02222                                                         $this->getLink($this->lm->getRefId(), "layout", $_GET["obj_id"], $attributes["name"],
02223                                                                 "", "keep");
02224                                                 $attributes["title"] = $this->lng->txt("cont_frame_".$attributes["name"]);
02225                                                 $a_content .= $this->buildTag("", "frame", $attributes);
02226                                                 $this->frames[$attributes["name"]] = $attributes["name"];
02227 //echo "<br>processNodes:add1 ".$attributes["name"];
02228                                         }
02229                                         else    // ok, no name means that we can easily output the frameset tag
02230                                         {
02231                                                 $a_content .= $this->buildTag("start", "frameset", $attributes);
02232                                                 $this->processNodes($a_content, $child);
02233                                                 $a_content .= $this->buildTag("end", "frameset");
02234                                         }
02235                                 }
02236                                 else    // frame with
02237                                 {
02238                                         unset($attributes["template"]);
02239                                         unset($attributes["template_location"]);
02240                                         $attributes["src"] =
02241                                                 $this->getLink($this->lm->getRefId(), "layout", $_GET["obj_id"], $attributes["name"],
02242                                                         "", "keep");
02243                                         $attributes["title"] = $this->lng->txt("cont_frame_".$attributes["name"]);
02244                                         if ($attributes["name"] == "toc")
02245                                         {
02246                                                 $attributes["src"].= "#".$_GET["obj_id"];
02247                                         }
02248                                         $a_content .= $this->buildTag("", "frame", $attributes);
02249                                         $this->frames[$attributes["name"]] = $attributes["name"];
02250 //echo "<br>processNodes:add2 ".$attributes["name"];
02251                                         //$a_content .= "<frame name=\"".$attributes["name"]."\" ".
02252                                         //      "src=\"lm_presentation.php?ref_id=".$this->lm->getRefId()."&cmd=layout&frame=".$attributes["name"]."&obj_id=".$_GET["obj_id"]."\" />\n";
02253                                 }
02254                         }
02255                 }
02256         }
02257 
02265         function buildTag ($type, $name, $attr="")
02266         {
02267                 $tag = "<";
02268 
02269                 if ($type == "end")
02270                         $tag.= "/";
02271 
02272                 $tag.= $name;
02273 
02274                 if (is_array($attr))
02275                 {
02276                         while (list($k,$v) = each($attr))
02277                                 $tag.= " ".$k."=\"$v\"";
02278                 }
02279 
02280                 if ($type == "")
02281                         $tag.= "/";
02282 
02283                 $tag.= ">\n";
02284 
02285                 return $tag;
02286         }
02287 
02288 
02292         function showTableOfContents()
02293         {
02294                 global $ilBench;
02295 
02296                 $ilBench->start("ContentPresentation", "TableOfContents");
02297 
02298                 //$this->tpl = new ilTemplate("tpl.lm_toc.html", true, true, true);
02299                 $this->tpl->setCurrentBlock("ContentStyle");
02300                 if (!$this->offlineMode())
02301                 {
02302                         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
02303                                 ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
02304                 }
02305                 else
02306                 {
02307                         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content.css");
02308                 }
02309                 $this->tpl->parseCurrentBlock();
02310 
02311                 $this->tpl->setVariable("PAGETITLE", " - ".$this->lm->getTitle());
02312 
02313                 // set style sheets
02314                 if (!$this->offlineMode())
02315                 {
02316                         $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
02317                 }
02318                 else
02319                 {
02320                         $style_name = $this->ilias->account->prefs["style"].".css";;
02321                         $this->tpl->setVariable("LOCATION_STYLESHEET","./".$style_name);
02322                 }
02323 
02324                 //$this->tpl->addBlockFile("CONTENT", "content", "tpl.lm_toc.html", true);
02325                 $this->tpl->getStandardTemplate();
02326                 $this->ilLocator();
02327                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lm_toc.html", true);
02328 
02329                 // set title header
02330                 $this->tpl->setVariable("TXT_TOC", $this->lng->txt("cont_toc"));
02331                 $this->tpl->setTitle($this->lm->getTitle());
02332                 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_lm_b.gif"));
02333 
02334                 if (!$this->offlineMode())
02335                 {
02336                         $this->tpl->setCurrentBlock("back_to_lm");
02337                         $this->tpl->setVariable("TXT_BACK", $this->lng->txt("back"));
02338                         $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
02339                         $this->tpl->setVariable("LINK_BACK",
02340                                 $this->ctrl->getLinkTarget($this, ""));
02341                         $this->tpl->parseCurrentBlock();
02342                 }
02343 
02344                 include_once ("content/classes/class.ilLMTableOfContentsExplorer.php");
02345                 $exp = new ilTableOfContentsExplorer(
02346                         $this->getLink($this->lm->getRefId(), ""),
02347                         $this->lm, $this->getExportFormat());
02348                 $exp->setExpandTarget($this->getLink($this->lm->getRefId(), $_GET["cmd"], "", $_GET["frame"]));
02349                 $exp->setTargetGet("obj_id");
02350                 $exp->setOfflineMode($this->offlineMode());
02351                 $exp->forceExpandAll(true, false);
02352 
02353                 $tree =& $this->lm->getTree();
02354                 if ($_GET["lmtocexpand"] == "")
02355                 {
02356                         $expanded = $tree->readRootId();
02357                 }
02358                 else
02359                 {
02360                         $expanded = $_GET["lmtocexpand"];
02361                 }
02362 
02363                 $exp->setExpand($expanded);
02364 
02365                 // build html-output
02366                 $exp->setOutput(0);
02367                 $output = $exp->getOutput();
02368 
02369                 $this->tpl->setVariable("EXPLORER", $output);
02370                 $this->tpl->parseCurrentBlock();
02371 
02372                 if ($this->offlineMode())
02373                 {
02374                         return $this->tpl->get();
02375                 }
02376                 else
02377                 {
02378                         $this->tpl->show();
02379                 }
02380 
02381                 $ilBench->stop("ContentPresentation", "TableOfContents");
02382         }
02383         
02384         
02390         function infoScreen()
02391         {
02392                 $this->ctrl->setCmd("showSummary");
02393                 $this->ctrl->setCmdClass("ilinfoscreengui");
02394                 $this->outputInfoScreen();
02395         }
02396 
02400         function showInfoScreen()
02401         {
02402                 $this->outputInfoScreen(true);
02403         }
02404 
02408         function outputInfoScreen($a_standard_locator = false)
02409         {
02410                 global $ilBench, $ilLocator, $ilAccess;
02411 
02412                 $this->tpl->setHeaderPageTitle("PAGETITLE", " - ".$this->lm->getTitle());
02413 
02414                 // set style sheets
02415                 if (!$this->offlineMode())
02416                 {
02417                         $this->tpl->setStyleSheetLocation(ilUtil::getStyleSheetLocation());
02418                 }
02419                 else
02420                 {
02421                         $style_name = $this->ilias->account->prefs["style"].".css";;
02422                         $this->tpl->setStyleSheetLocation("./".$style_name);
02423                 }
02424 
02425                 $this->tpl->getStandardTemplate();
02426                 $this->tpl->setTitle($this->lm->getTitle());
02427                 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_lm_b.gif"));
02428                 
02429                 // Full locator, if read permission is given
02430                 if ($ilAccess->checkAccess("read", "", $_GET["ref_id"]))
02431                 {
02432                         $this->ilLocator();
02433                 }
02434                 else
02435                 {
02436                         $ilLocator->addRepositoryItems();
02437                         $this->tpl->setLocator();
02438                 }
02439                 
02440                 $this->lng->loadLanguageModule("meta");
02441 
02442                 include_once("classes/class.ilInfoScreenGUI.php");
02443 
02444                 $info = new ilInfoScreenGUI($this->lm_gui);
02445                 $info->enablePrivateNotes();
02446                 $info->enableLearningProgress();
02447 
02448                 // add read / back button
02449                 if ($ilAccess->checkAccess("read", "", $_GET["ref_id"]))
02450                 {
02451                         if ($_GET["obj_id"] > 0)
02452                         {
02453                                 $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
02454                                 $info->addButton($this->lng->txt("back"),
02455                                         $this->ctrl->getLinkTarget($this, "layout"));
02456                         }
02457                         else
02458                         {
02459                                 $info->addButton($this->lng->txt("view"),
02460                                         $this->ctrl->getLinkTarget($this, "layout"));
02461                         }
02462                 }
02463                 
02464                 // show standard meta data section
02465                 $info->addMetaDataSections($this->lm->getId(),0, $this->lm->getType());
02466 
02467                 if ($this->offlineMode())
02468                 {
02469                         $this->tpl->setContent($info->getHTML());
02470                         return $this->tpl->get();
02471                 }
02472                 else
02473                 {
02474                         // forward the command
02475                         $this->ctrl->forwardCommand($info);
02476                         //$this->tpl->setContent("aa");
02477                         $this->tpl->show();
02478                 }
02479         }
02480 
02484         function showPrintViewSelection()
02485         {
02486                 global $ilBench,$ilUser;
02487                 
02488                 if (!$this->lm->isActivePrintView())
02489                 {
02490                         return;
02491                 }
02492 
02493                 include_once("content/classes/class.ilStructureObject.php");
02494 
02495                 $ilBench->start("ContentPresentation", "PrintViewSelection");
02496 
02497                 //$this->tpl = new ilTemplate("tpl.lm_toc.html", true, true, true);
02498                 $this->tpl->setCurrentBlock("ContentStyle");
02499                 if (!$this->offlineMode())
02500                 {
02501                         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
02502                                 ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
02503                 }
02504                 else
02505                 {
02506                         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content.css");
02507                 }
02508                 $this->tpl->parseCurrentBlock();
02509 
02510                 $this->tpl->setVariable("PAGETITLE", " - ".$this->lm->getTitle());
02511                 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
02512                 $this->tpl->getStandardTemplate();
02513                 $this->ilLocator();
02514                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content",
02515                         "tpl.lm_print_selection.html", true);
02516 
02517                 // set title header
02518                 $this->tpl->setTitle($this->lm->getTitle());
02519                 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_lm_b.gif"));
02520                 $this->tpl->setVariable("TXT_SHOW_PRINT", $this->lng->txt("cont_show_print_view"));
02521                 $this->tpl->setVariable("TXT_BACK", $this->lng->txt("back"));
02522                 $this->ctrl->setParameterByClass("illmpresentationgui", "obj_id", $_GET["obj_id"]);
02523                 $this->tpl->setVariable("LINK_BACK",
02524                         $this->ctrl->getLinkTargetByClass("illmpresentationgui", ""));
02525 
02526                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormaction($this));
02527 
02528                 $nodes = $this->lm_tree->getSubtree($this->lm_tree->getNodeData($this->lm_tree->getRootId()));
02529 
02530                 if (!is_array($_POST["item"]))
02531                 {
02532                         if ($_GET["obj_id"] != "")
02533                         {
02534                                 $_POST["item"][$_GET["obj_id"]] = "y";
02535                         }
02536                         else
02537                         {
02538                                 $_POST["item"][1] = "y";
02539                         }
02540                 }
02541 
02542                 foreach ($nodes as $node)
02543                 {
02544 
02545                         // indentation
02546                         for ($i=0; $i<$node["depth"]; $i++)
02547                         {
02548                                 $this->tpl->setCurrentBlock("indent");
02549                                 $this->tpl->setVariable("IMG_BLANK", ilUtil::getImagePath("browser/blank.gif"));
02550                                 $this->tpl->parseCurrentBlock();
02551                         }
02552 
02553                         // output title
02554                         $this->tpl->setCurrentBlock("lm_item");
02555 
02556                         switch ($node["type"])
02557                         {
02558                                 // page
02559                                 case "pg":
02560                                         $this->tpl->setVariable("TXT_TITLE",
02561                                         ilLMPageObject::_getPresentationTitle($node["obj_id"],
02562                                         $this->lm->getPageHeader(), $this->lm->isActiveNumbering()));
02563                                         
02564                                         if ($ilUser->getId() == ANONYMOUS_USER_ID and $this->lm_gui->object->getPublicAccessMode() == "selected")
02565                                         {
02566                                                 if (!ilLMObject::_isPagePublic($node["obj_id"]))
02567                                                 {
02568                                                         $this->tpl->setVariable("DISABLED", "disabled=\"disabled\"");
02569                                                         $this->tpl->setVariable("TXT_NO_ACCESS", "(".$this->lng->txt("cont_no_access").")");
02570                                                 }
02571                                         }
02572                                         $this->tpl->setVariable("IMG_TYPE", ilUtil::getImagePath("icon_pg.gif"));
02573                                         break;
02574 
02575                                 // learning module
02576                                 case "du":
02577                                         $this->tpl->setVariable("TXT_TITLE", "<b>".$this->lm->getTitle()."</b>");
02578                                         $this->tpl->setVariable("IMG_TYPE", ilUtil::getImagePath("icon_lm.gif"));
02579                                         break;
02580 
02581                                 // chapter
02582                                 case "st":
02583                                         /*
02584                                         $this->tpl->setVariable("TXT_TITLE", "<b>".
02585                                                 ilStructureObject::_getPresentationTitle($node["obj_id"],
02586                                                 $this->lm->getPageHeader(), $this->lm->isActiveNumbering())
02587                                                 ."</b>");*/
02588                                         $this->tpl->setVariable("TXT_TITLE", "<b>".
02589                                                 ilStructureObject::_getPresentationTitle($node["obj_id"],
02590                                                 $this->lm->isActiveNumbering())
02591                                                 ."</b>");
02592                                         if ($ilUser->getId() == ANONYMOUS_USER_ID and $this->lm_gui->object->getPublicAccessMode() == "selected")
02593                                         {
02594                                                 if (!ilLMObject::_isPagePublic($node["obj_id"]))
02595                                                 {
02596                                                         $this->tpl->setVariable("DISABLED", "disabled=\"disabled\"");
02597                                                         $this->tpl->setVariable("TXT_NO_ACCESS", "(".$this->lng->txt("cont_no_access").")");
02598                                                 }
02599                                         }
02600                                         $this->tpl->setVariable("IMG_TYPE", ilUtil::getImagePath("icon_st.gif"));
02601 
02602                                         break;
02603                         }
02604                         
02605                         if (!ilObjContentObject::_checkPreconditionsOfPage($this->lm->getId(), $node["obj_id"]))
02606                         {
02607                                 $this->tpl->setVariable("TXT_NO_ACCESS", "(".$this->lng->txt("cont_no_access").")");
02608                         }
02609 
02610                         $this->tpl->setVariable("ITEM_ID", $node["obj_id"]);
02611 
02612                         if ($_POST["item"][$node["obj_id"]] == "y")
02613                         {
02614                                 $this->tpl->setVariable("CHECKED", "checked=\"checked\"");
02615                         }
02616 
02617                         $this->tpl->parseCurrentBlock();
02618                 }
02619 
02620                 $this->tpl->show();
02621 
02622                 $ilBench->stop("ContentPresentation", "PrintViewSelection");
02623         }
02624 
02628         function showPrintView()
02629         {
02630                 global $ilBench,$ilUser;
02631 
02632                 if (!$this->lm->isActivePrintView())
02633                 {
02634                         return;
02635                 }
02636 
02637                 $ilBench->start("ContentPresentation", "PrintView");
02638 
02639                 $this->tpl->setVariable("PAGETITLE", " - ".$this->lm->getTitle());
02640                 
02641                 // set style sheets
02642                 if (!$this->offlineMode())
02643                 {
02644                         $this->tpl->setVariable("LOCATION_STYLESHEET", ilObjStyleSheet::getContentPrintStyle());
02645                 }
02646                 else
02647                 {
02648                         $style_name = $this->ilias->account->prefs["style"].".css";;
02649                         $this->tpl->setVariable("LOCATION_STYLESHEET","./".$style_name);
02650                 }
02651 
02652                 // content style
02653                 $this->tpl->setCurrentBlock("ContentStyle");
02654                 if (!$this->offlineMode())
02655                 {
02656                         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
02657                                 ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
02658                 }
02659                 else
02660                 {
02661                         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content.css");
02662                 }
02663                 $this->tpl->parseCurrentBlock();
02664 
02665                 // syntax style
02666                 $this->tpl->setCurrentBlock("SyntaxStyle");
02667                 $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
02668                         ilObjStyleSheet::getSyntaxStylePath());
02669                 $this->tpl->parseCurrentBlock();
02670 
02671                 //$this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
02672                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.lm_print_view.html", true);
02673 
02674                 // set title header
02675                 $this->tpl->setVariable("HEADER", $this->lm->getTitle());
02676 
02677                 $nodes = $this->lm_tree->getSubtree($this->lm_tree->getNodeData($this->lm_tree->getRootId()));
02678 
02679                 include_once("content/classes/Pages/class.ilPageObjectGUI.php");
02680                 include_once("content/classes/class.ilLMPageObject.php");
02681                 include_once("content/classes/class.ilStructureObject.php");
02682 
02683                 $act_level = 99999;
02684                 $activated = false;
02685 
02686                 $glossary_links = array();
02687                 $output_header = false;
02688                 $media_links = array();
02689 
02690                 // get header and footer
02691                 if ($this->lm->getFooterPage() > 0)
02692                 {
02693                         $page_object =& new ilPageObject($this->lm->getType(), $this->lm->getFooterPage());
02694                         $page_object_gui =& new ilPageObjectGUI($page_object);
02695 
02696                         // determine target frames for internal links
02697                         $page_object_gui->setLinkFrame($_GET["frame"]);
02698                         $page_object_gui->setOutputMode("print");
02699                         $page_object_gui->setPresentationTitle("");
02700                         $footer_page_content = $page_object_gui->showPage();
02701                 }
02702                 if ($this->lm->getHeaderPage() > 0)
02703                 {
02704                         $page_object =& new ilPageObject($this->lm->getType(), $this->lm->getHeaderPage());
02705                         $page_object_gui =& new ilPageObjectGUI($page_object);
02706 
02707                         // determine target frames for internal links
02708                         $page_object_gui->setLinkFrame($_GET["frame"]);
02709                         $page_object_gui->setOutputMode("print");
02710                         $page_object_gui->setPresentationTitle("");
02711                         $header_page_content = $page_object_gui->showPage();
02712                 }
02713 
02714                 foreach ($nodes as $node_key => $node)
02715                 {
02716 
02717                         // print all subchapters/subpages if higher chapter
02718                         // has been selected
02719                         if ($node["depth"] <= $act_level)
02720                         {
02721                                 if ($_POST["item"][$node["obj_id"]] == "y")
02722                                 {
02723                                         $act_level = $node["depth"];
02724                                         $activated = true;
02725                                 }
02726                                 else
02727                                 {
02728                                         $act_level = 99999;
02729                                         $activated = false;
02730                                 }
02731                         }
02732                         
02733                         if ($activated &&
02734                                 ilObjContentObject::_checkPreconditionsOfPage($this->lm->getId(), $node["obj_id"]))
02735                         {
02736                                 // output learning module header
02737                                 if ($node["type"] == "du")
02738                                 {
02739                                         $output_header = true;
02740                                 }
02741 
02742                                 // output chapter title
02743                                 if ($node["type"] == "st")
02744                                 {
02745                                         if ($ilUser->getId() == ANONYMOUS_USER_ID and $this->lm_gui->object->getPublicAccessMode() == "selected")
02746                                         {
02747                                                 if (!ilLMObject::_isPagePublic($node["obj_id"]))
02748                                                 {
02749                                                         continue;
02750                                                 }
02751                                         }
02752                                         
02753                                         $chap =& new ilStructureObject($this->lm, $node["obj_id"]);
02754                                         $this->tpl->setCurrentBlock("print_chapter");
02755 
02756                                         $chapter_title = $chap->_getPresentationTitle($node["obj_id"],
02757                                                 $this->lm->isActiveNumbering());
02758                                         $this->tpl->setVariable("CHAP_TITLE",
02759                                                 $chapter_title);
02760                                                 
02761                                         if ($this->lm->getPageHeader() == IL_CHAPTER_TITLE)
02762                                         {
02763                                                 if ($nodes[$node_key + 1]["type"] == "pg")
02764                                                 {
02765                                                         $this->tpl->setVariable("CHAP_HEADER",
02766                                                                 $header_page_content);
02767                                                         $did_chap_page_header = true;
02768                                                 }
02769                                         }
02770 
02771                                         $this->tpl->parseCurrentBlock();
02772                                         $this->tpl->setCurrentBlock("print_block");
02773                                         $this->tpl->parseCurrentBlock();
02774                                 }
02775 
02776                                 // output page
02777                                 if ($node["type"] == "pg")
02778                                 {
02779                                         if ($ilUser->getId() == ANONYMOUS_USER_ID and $this->lm_gui->object->getPublicAccessMode() == "selected")
02780                                         {
02781                                                 if (!ilLMObject::_isPagePublic($node["obj_id"]))
02782                                                 {
02783                                                         continue;
02784                                                 }
02785                                         }
02786 
02787                                         $this->tpl->setCurrentBlock("print_item");
02788                                         
02789                                         // get page
02790                                         $page_id = $node["obj_id"];
02791                                         $page_object =& new ilPageObject($this->lm->getType(), $page_id);
02792                                         $page_object_gui =& new ilPageObjectGUI($page_object);
02793 
02794                                         // get lm page
02795                                         $lm_pg_obj =& new ilLMPageObject($this->lm, $page_id);
02796                                         $lm_pg_obj->setLMId($this->lm->getId());
02797 
02798                                         // determine target frames for internal links
02799                                         $page_object_gui->setLinkFrame($_GET["frame"]);
02800                                         $page_object_gui->setOutputMode("print");
02801                                         $page_object_gui->setPresentationTitle("");
02802                                         
02803                                         if ($this->lm->getPageHeader() == IL_PAGE_TITLE)
02804                                         {
02805                                                 $page_title = ilLMPageObject::_getPresentationTitle($lm_pg_obj->getId(),
02806                                                                 $this->lm->getPageHeader(), $this->lm->isActiveNumbering());
02807 
02808                                                 // prevent page title after chapter title
02809                                                 // that have the same content
02810                                                 if ($this->lm->isActiveNumbering())
02811                                                 {
02812                                                         $chapter_title = trim(substr($chapter_title,
02813                                                                 strpos($chapter_title, " ")));
02814                                                 }
02815 
02816                                                 if ($page_title != $chapter_title)
02817                                                 {
02818                                                         $page_object_gui->setPresentationTitle($page_title);
02819                                                 }
02820                                         }
02821 
02822                                         // handle header / footer
02823                                         $hcont = $header_page_content;
02824                                         $fcont = $footer_page_content;
02825 
02826                                         if ($this->lm->getPageHeader() == IL_CHAPTER_TITLE)
02827                                         {
02828                                                 if ($did_chap_page_header)
02829                                                 {
02830                                                         $hcont = "";
02831                                                 }
02832                                                 if ($nodes[$node_key + 1]["type"] == "pg" &&
02833                                                         !($nodes[$node_key + 1]["depth"] <= $act_level
02834                                                          && $_POST["item"][$nodes[$node_key + 1]["obj_id"]] != "y"))
02835                                                 {
02836                                                         $fcont = "";
02837                                                 }
02838                                         }
02839                                         
02840                                         $page_content = $page_object_gui->showPage();
02841                                         if ($this->lm->getPageHeader() != IL_PAGE_TITLE)
02842                                         {
02843                                                 $this->tpl->setVariable("CONTENT",
02844                                                         $hcont.$page_content.$fcont);
02845                                         }
02846                                         else
02847                                         {
02848                                                 $this->tpl->setVariable("CONTENT", 
02849                                                         $hcont.$page_content.$fcont."<br />");
02850                                         }
02851                                         $chapter_title = "";
02852                                         $this->tpl->parseCurrentBlock();
02853                                         $this->tpl->setCurrentBlock("print_block");
02854                                         $this->tpl->parseCurrentBlock();
02855 
02856                                         // get internal links
02857                                         $int_links = ilInternalLink::_getTargetsOfSource($this->lm->getType().":pg", $node["obj_id"]);
02858 
02859                                         $got_mobs = false;
02860 
02861                                         foreach ($int_links as $key => $link)
02862                                         {
02863                                                 if ($link["type"] == "git" &&
02864                                                         ($link["inst"] == IL_INST_ID || $link["inst"] == 0))
02865                                                 {
02866                                                         $glossary_links[$key] = $link;
02867                                                 }
02868                                                 if ($link["type"] == "mob" &&
02869                                                         ($link["inst"] == IL_INST_ID || $link["inst"] == 0))
02870                                                 {
02871                                                         $got_mobs = true;
02872                                                         $mob_links[$key] = $link;
02873                                                 }
02874                                         }
02875 
02876                                         // this is not cool because of performance reasons
02877                                         // unfortunately the int link table does not
02878                                         // store the target frame (we want to append all linked
02879                                         // images but not inline images (i.e. mobs with no target
02880                                         // frame))
02881                                         if ($got_mobs)
02882                                         {
02883                                                 $page_object->buildDom();
02884                                                 $links = $page_object->getInternalLinks();
02885                                                 foreach($links as $link)
02886                                                 {
02887                                                         if ($link["Type"] == "MediaObject"
02888                                                                 && $link["TargetFrame"] != ""
02889                                                                 && $link["TargetFrame"] != "None")
02890                                                         {
02891                                                                 $media_links[] = $link;
02892                                                         }
02893                                                 }
02894                                         }
02895                                 }
02896                         }
02897                 }
02898 
02899                 $annex_cnt = 0;
02900                 $annexes = array();
02901 
02902                 // glossary
02903                 if (count($glossary_links) > 0)
02904                 {
02905                         include_once("content/classes/class.ilGlossaryTerm.php");
02906                         include_once("content/classes/class.ilGlossaryDefinition.php");
02907 
02908                         // sort terms
02909                         $terms = array();
02910                         
02911                         foreach($glossary_links as $key => $link)
02912                         {
02913                                 $term = ilGlossaryTerm::_lookGlossaryTerm($link["id"]);
02914                                 $terms[$term.":".$key] = $link;
02915                         }
02916                         ksort($terms);
02917 
02918                         foreach($terms as $key => $link)
02919                         {
02920                                 $defs = ilGlossaryDefinition::getDefinitionList($link["id"]);
02921                                 $def_cnt = 1;
02922 
02923                                 // output all definitions of term
02924                                 foreach($defs as $def)
02925                                 {
02926                                         // definition + number, if more than 1 definition
02927                                         if (count($defs) > 1)
02928                                         {
02929                                                 $this->tpl->setCurrentBlock("def_title");
02930                                                 $this->tpl->setVariable("TXT_DEFINITION",
02931                                                         $this->lng->txt("cont_definition")." ".($def_cnt++));
02932                                                 $this->tpl->parseCurrentBlock();
02933                                         }
02934                                         $page =& new ilPageObject("gdf", $def["id"]);
02935                                         $page_gui =& new ilPageObjectGUI($page);
02936                                         $page_gui->setTemplateOutput(false);
02937                                         $page_gui->setOutputMode("print");
02938 
02939                                         $this->tpl->setCurrentBlock("definition");
02940                                         $output = $page_gui->showPage();
02941                                         $this->tpl->setVariable("VAL_DEFINITION", $output);
02942                                         $this->tpl->parseCurrentBlock();
02943                                 }
02944 
02945                                 // output term
02946                                 $this->tpl->setCurrentBlock("term");
02947                                 $this->tpl->setVariable("VAL_TERM",
02948                                         $term = ilGlossaryTerm::_lookGlossaryTerm($link["id"]));
02949                                 $this->tpl->parseCurrentBlock();
02950                         }
02951 
02952                         // output glossary header
02953                         $annex_cnt++;
02954                         $this->tpl->setCurrentBlock("glossary");
02955                         $annex_title = $this->lng->txt("cont_annex")." ".
02956                                 chr(64+$annex_cnt).": ".$this->lng->txt("glo");
02957                         $this->tpl->setVariable("TXT_GLOSSARY", $annex_title);
02958                         $this->tpl->parseCurrentBlock();
02959 
02960                         $annexes[] = $annex_title;
02961                 }
02962 
02963                 // referenced images
02964                 if (count($media_links) > 0)
02965                 {
02966                         include_once("content/classes/Media/class.ilObjMediaObject.php");
02967                         include_once("content/classes/Media/class.ilMediaItem.php");
02968 
02969                         foreach($media_links as $media)
02970                         {
02971                                 if (substr($media["Target"],0,4) == "il__")
02972                                 {
02973                                         $arr = explode("_",$media["Target"]);
02974                                         $id = $arr[count($arr) - 1];
02975                                         
02976                                         $med_obj = new ilObjMediaObject($id);
02977                                         $med_item =& $med_obj->getMediaItem("Standard");
02978                                         if (is_object($med_item))
02979                                         {
02980                                                 if (is_int(strpos($med_item->getFormat(), "image")))
02981                                                 {
02982                                                         $this->tpl->setCurrentBlock("ref_image");
02983                                                         
02984                                                         // image source
02985                                                         if ($med_item->getLocationType() == "LocalFile")
02986                                                         {
02987                                                                 $this->tpl->setVariable("IMG_SOURCE",
02988                                                                         ilUtil::getWebspaceDir("output")."/mobs/mm_".$id.
02989                                                                         "/".$med_item->getLocation());
02990                                                         }
02991                                                         else
02992                                                         {
02993                                                                 $this->tpl->setVariable("IMG_SOURCE",
02994                                                                         $med_item->getLocation());                                                              
02995                                                         }
02996                                                         
02997                                                         if ($med_item->getCaption() != "")
02998                                                         {
02999                                                                 $this->tpl->setVariable("IMG_TITLE", $med_item->getCaption());
03000                                                         }
03001                                                         else
03002                                                         {
03003                                                                 $this->tpl->setVariable("IMG_TITLE", $med_obj->getTitle());
03004                                                         }
03005                                                         $this->tpl->parseCurrentBlock();
03006                                                 }
03007                                         }
03008                                 }
03009                         }
03010                         
03011                         // output glossary header
03012                         $annex_cnt++;
03013                         $this->tpl->setCurrentBlock("ref_images");
03014                         $annex_title = $this->lng->txt("cont_annex")." ".
03015                                 chr(64+$annex_cnt).": ".$this->lng->txt("cont_ref_images");
03016                         $this->tpl->setVariable("TXT_REF_IMAGES", $annex_title);
03017                         $this->tpl->parseCurrentBlock();
03018 
03019                         $annexes[] = $annex_title;
03020                 }
03021 
03022                 // output learning module title and toc
03023                 if ($output_header)
03024                 {
03025                         $this->tpl->setCurrentBlock("print_header");
03026                         $this->tpl->setVariable("LM_TITLE", $this->lm->getTitle());
03027                         if ($this->lm->getDescription() != "none")
03028                         {
03029                                 include_once("Services/MetaData/classes/class.ilMD.php");
03030                                 $md = new ilMD($this->lm->getId(), 0, $this->lm->getType());
03031                                 $md_gen = $md->getGeneral();
03032                                 foreach($md_gen->getDescriptionIds() as $id)
03033                                 {
03034                                         $md_des = $md_gen->getDescription($id);
03035                                         $description = $md_des->getDescription();
03036                                 }
03037 
03038                                 $this->tpl->setVariable("LM_DESCRIPTION",
03039                                         $description);
03040                         }
03041                         $this->tpl->parseCurrentBlock();
03042 
03043                         // output toc
03044                         $nodes2 = $nodes;
03045                         foreach ($nodes2 as $node2)
03046                         {
03047                                 if ($node2["type"] == "st"
03048                                         && ilObjContentObject::_checkPreconditionsOfPage($this->lm->getId(), $node2["obj_id"]))
03049                                 {
03050                                         for ($j=1; $j < $node2["depth"]; $j++)
03051                                         {
03052                                                 $this->tpl->setCurrentBlock("indent");
03053                                                 $this->tpl->setVariable("IMG_BLANK", ilUtil::getImagePath("browser/blank.gif"));
03054                                                 $this->tpl->parseCurrentBlock();
03055                                         }
03056                                         $this->tpl->setCurrentBlock("toc_entry");
03057                                         $this->tpl->setVariable("TXT_TOC_TITLE",
03058                                                 ilStructureObject::_getPresentationTitle($node2["obj_id"],
03059                                                 $this->lm->isActiveNumbering()));
03060                                         $this->tpl->parseCurrentBlock();
03061                                 }
03062                         }
03063 
03064                         // annexes
03065                         foreach ($annexes as $annex)
03066                         {
03067                                 $this->tpl->setCurrentBlock("indent");
03068                                 $this->tpl->setVariable("IMG_BLANK", ilUtil::getImagePath("browser/blank.gif"));
03069                                 $this->tpl->parseCurrentBlock();
03070                                 $this->tpl->setCurrentBlock("toc_entry");
03071                                 $this->tpl->setVariable("TXT_TOC_TITLE", $annex);
03072                                 $this->tpl->parseCurrentBlock();
03073                         }
03074 
03075                         $this->tpl->setCurrentBlock("toc");
03076                         $this->tpl->setVariable("TXT_TOC", $this->lng->txt("cont_toc"));
03077                         $this->tpl->parseCurrentBlock();
03078 
03079                         $this->tpl->setCurrentBlock("print_start_block");
03080                         $this->tpl->parseCurrentBlock();
03081                 }
03082                 
03083                 // output copyright information
03084                 include_once 'Services/MetaData/classes/class.ilMD.php';
03085                 $md = new ilMD($this->lm->getId(),0, $this->lm->getType());
03086                 if (is_object($md_rights = $md->getRights()))
03087                 {
03088                         $copyright = $md_rights->getDescription();
03089                         if ($copyright != "")
03090                         {
03091                                 $this->lng->loadLanguageModule("meta");
03092                                 $this->tpl->setCurrentBlock("copyright");
03093                                 $this->tpl->setVariable("TXT_COPYRIGHT", $this->lng->txt("meta_copyright"));
03094                                 $this->tpl->setVariable("LM_COPYRIGHT", $copyright);
03095                                 $this->tpl->parseCurrentBlock();
03096                         }
03097                 }
03098 
03099                 $this->tpl->show(false);
03100 
03101                 $ilBench->stop("ContentPresentation", "PrintView");
03102         }
03103 
03104         // PRIVATE METHODS
03105         function setSessionVars()
03106         {
03107                 if($_POST["action"] == "show" or $_POST["action"] == "show_citation")
03108                 {
03109                         if($_POST["action"] == "show_citation")
03110                         {
03111                                 // ONLY ONE EDITION
03112                                 if(count($_POST["target"]) != 1)
03113                                 {
03114                                         sendInfo($this->lng->txt("cont_citation_err_one"));
03115                                         $_POST["action"] = "";
03116                                         $_POST["target"] = 0;
03117                                         return false;
03118                                 }
03119                                 $_SESSION["citation"] = 1;
03120                         }
03121                         else
03122                         {
03123                                 unset($_SESSION["citation"]);
03124                         }
03125                         if(isset($_POST["tr_id"]))
03126                         {
03127                                 $_SESSION["tr_id"] = $_POST["tr_id"][0];
03128                         }
03129                         else
03130                         {
03131                                 unset($_SESSION["tr_id"]);
03132                         }
03133                         if(is_array($_POST["target"]))
03134                         {
03135                                 $_SESSION["bib_id"] = ",".implode(',',$_POST["target"]).",";
03136                         }
03137                         else
03138                         {
03139                                 $_SESSION["bib_id"] = ",0,";
03140                         }
03141                 }
03142                 return true;
03143         }
03144 
03148         function downloadFile()
03149         {
03150                 $file = explode("_", $_GET["file_id"]);
03151                 require_once("classes/class.ilObjFile.php");
03152                 $fileObj =& new ilObjFile($file[count($file) - 1], false);
03153                 $fileObj->sendFile();
03154                 exit;
03155         }
03156 
03160         function download_paragraph ()
03161         {
03162                 require_once("content/classes/Pages/class.ilPageObject.php");
03163                 $pg_obj =& new ilPageObject($this->lm->getType(), $_GET["pg_id"]);
03164                 $pg_obj->send_paragraph ($_GET["par_id"], $_GET["downloadtitle"]);
03165         }
03166         
03170         function showDownloadList()
03171         {
03172                 global $ilBench;
03173 
03174                 //$this->tpl = new ilTemplate("tpl.lm_toc.html", true, true, true);
03175                 $this->tpl->setCurrentBlock("ContentStyle");
03176                 if (!$this->offlineMode())
03177                 {
03178                         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
03179                                 ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
03180                 }
03181                 else
03182                 {
03183                         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content.css");
03184                 }
03185                 $this->tpl->parseCurrentBlock();
03186 
03187                 $this->tpl->setVariable("PAGETITLE", " - ".$this->lm->getTitle());
03188                 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
03189                 $this->tpl->getStandardTemplate();
03190                 $this->ilLocator();
03191                 $this->tpl->stopTitleFloating();
03192                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lm_download_list.html", true);
03193 
03194                 // set title header
03195                 $this->tpl->setTitle($this->lm->getTitle());
03196                 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_lm_b.gif"));
03197                 $this->tpl->setVariable("TXT_BACK", $this->lng->txt("back"));
03198                 $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
03199                 $this->tpl->setVariable("LINK_BACK",
03200                         $this->ctrl->getLinkTarget($this, ""));
03201 
03202                 // output copyright information
03203                 include_once 'Services/MetaData/classes/class.ilMD.php';
03204                 $md = new ilMD($this->lm->getId(),0, $this->lm->getType());
03205                 if (is_object($md_rights = $md->getRights()))
03206                 {
03207                         $copyright = $md_rights->getDescription();
03208                         if ($copyright != "")
03209                         {
03210                                 $this->lng->loadLanguageModule("meta");
03211                                 $this->tpl->setCurrentBlock("copyright");
03212                                 $this->tpl->setVariable("TXT_COPYRIGHT", $this->lng->txt("meta_copyright"));
03213                                 $this->tpl->setVariable("LM_COPYRIGHT", $copyright);
03214                                 $this->tpl->parseCurrentBlock();
03215                         }
03216                 }
03217 
03218                 // create table
03219                 require_once("classes/class.ilTableGUI.php");
03220                 $tbl = new ilTableGUI();
03221 
03222                 // load files templates
03223                 $this->tpl->addBlockfile("DOWNLOAD_TABLE", "download_table", "tpl.table.html");
03224 
03225                 // load template for table content data
03226                 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.download_file_row.html", true);
03227 
03228                 $export_files = array();
03229                 $types = array("xml", "html");
03230                 foreach($types as $type)
03231                 {
03232                         if ($this->lm->getPublicExportFile($type) != "")
03233                         {
03234                                 if (is_file($this->lm->getExportDirectory($type)."/".
03235                                         $this->lm->getPublicExportFile($type)))
03236                                 {
03237                                         $dir = $this->lm->getExportDirectory($type);
03238                                         $size = filesize($this->lm->getExportDirectory($type)."/".
03239                                                 $this->lm->getPublicExportFile($type));
03240                                         $export_files[] = array("type" => $type,
03241                                                 "file" => $this->lm->getPublicExportFile($type),
03242                                                 "size" => $size);
03243                                 }
03244                         }
03245                 }
03246                 
03247                 $num = 0;
03248                 
03249                 $tbl->setTitle($this->lng->txt("download"));
03250 
03251                 $tbl->setHeaderNames(array($this->lng->txt("cont_format"),
03252                         $this->lng->txt("cont_file"),
03253                         $this->lng->txt("size"), $this->lng->txt("date"),
03254                         ""));
03255 
03256                 $cols = array("format", "file", "size", "date", "download");
03257                 $header_params = array("ref_id" => $_GET["ref_id"], "obj_id" => $_GET["obj_id"],
03258                         "cmd" => "showDownloadList", "cmdClass" => strtolower(get_class($this)));
03259                 $tbl->setHeaderVars($cols, $header_params);
03260                 $tbl->setColumnWidth(array("10%", "30%", "20%", "20%","20%"));
03261                 $tbl->disable("sort");
03262 
03263                 // control
03264                 $tbl->setOrderColumn($_GET["sort_by"]);
03265                 $tbl->setOrderDirection($_GET["sort_order"]);
03266                 $tbl->setLimit($_GET["limit"]);
03267                 $tbl->setOffset($_GET["offset"]);
03268                 $tbl->setMaxCount($this->maxcount);             // ???
03269 
03270                 //$this->tpl->setVariable("COLUMN_COUNTS", 5);
03271 
03272                 // footer
03273                 //$tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
03274                 $tbl->disable("footer");
03275 
03276                 $tbl->setMaxCount(count($export_files));
03277                 $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
03278 
03279                 $tbl->render();
03280                 if(count($export_files) > 0)
03281                 {
03282                         $i=0;
03283                         foreach($export_files as $exp_file)
03284                         {
03285                                 if (!$exp_file["size"] > 0)
03286                                 {
03287                                         continue;
03288                                 }
03289                                 
03290                                 $this->tpl->setCurrentBlock("tbl_content");
03291                                 $this->tpl->setVariable("TXT_FILENAME", $exp_file["file"]);
03292 
03293                                 $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
03294                                 $this->tpl->setVariable("CSS_ROW", $css_row);
03295 
03296                                 $this->tpl->setVariable("TXT_SIZE", $exp_file["size"]);
03297                                 $this->tpl->setVariable("TXT_FORMAT", strtoupper($exp_file["type"]));
03298                                 $this->tpl->setVariable("CHECKBOX_ID", $exp_file["type"].":".$exp_file["file"]);
03299 
03300                                 $file_arr = explode("__", $exp_file["file"]);
03301                                 $this->tpl->setVariable("TXT_DATE", date("Y-m-d H:i:s",$file_arr[0]));
03302 
03303                                 $this->tpl->setVariable("TXT_DOWNLOAD", $this->lng->txt("download"));
03304                                 $this->ctrl->setParameter($this, "type", $exp_file["type"]);
03305                                 $this->tpl->setVariable("LINK_DOWNLOAD",
03306                                         $this->ctrl->getLinkTarget($this, "downloadExportFile"));
03307 
03308                                 $this->tpl->parseCurrentBlock();
03309                         }
03310                 } //if is_array
03311                 else
03312                 {
03313                         $this->tpl->setCurrentBlock("notfound");
03314                         $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
03315                         $this->tpl->setVariable("NUM_COLS", 5);
03316                         $this->tpl->parseCurrentBlock();
03317                 }
03318 
03319                 $this->tpl->show();
03320         }
03321 
03322         
03326         function downloadExportFile()
03327         {
03328                 $file = $this->lm->getPublicExportFile($_GET["type"]);
03329                 if ($this->lm->getPublicExportFile($_GET["type"]) != "")
03330                 {
03331                         $dir = $this->lm->getExportDirectory($_GET["type"]);
03332                         if (is_file($dir."/".$file))
03333                         {
03334                                 ilUtil::deliverFile($dir."/".$file, $file);
03335                                 exit;
03336                         }
03337                 }
03338                 $this->ilias->raiseError($this->lng->txt("file_not_found"),$this->ilias->error_obj->MESSAGE);
03339         }
03340         
03344         function getLink($a_ref_id, $a_cmd = "", $a_obj_id = "", $a_frame = "", $a_type = "",
03345                 $a_back_link = "append")
03346         {
03347                 global $ilCtrl;
03348                 
03349                 if ($a_cmd == "")
03350                 {
03351                         $a_cmd = "layout";
03352                 }
03353                 
03354                 // handling of free pages
03355                 $cur_page_id = $this->getCurrentPageId();
03356                 $back_pg = $_GET["back_pg"];
03357                 if ($a_obj_id != "" && !$this->lm_tree->isInTree($a_obj_id) && $cur_page_id != "" &&
03358                         $a_back_link == "append")
03359                 {
03360                         if ($back_pg != "")
03361                         {
03362                                 $back_pg = $cur_page_id.":".$back_pg;
03363                         }
03364                         else
03365                         {
03366                                 $back_pg = $cur_page_id;
03367                         }
03368                 }
03369                 else
03370                 {
03371                         if ($a_back_link == "reduce")
03372                         {
03373                                 $limpos = strpos($_GET["back_pg"], ":");
03374 
03375                                 if ($limpos > 0)
03376                                 {
03377                                         $back_pg = substr($back_pg, strpos($back_pg, ":") + 1);
03378                                 }
03379                                 else
03380                                 {
03381                                         $back_pg = "";
03382                                 }
03383                         }
03384                         else if ($a_back_link != "keep")
03385                         {
03386                                 $back_pg = "";
03387                         }
03388                 }
03389                 
03390                 // handle online links
03391                 if (!$this->offlineMode())
03392                 {
03393                         switch ($a_cmd)
03394                         {
03395                                 case "fullscreen":
03396                                         $link = $this->ctrl->getLinkTarget($this, "fullscreen");
03397                                         break;
03398                                 
03399                                 default:
03400                                         
03401                                         if ($back_pg != "")
03402                                         {
03403                                                 $this->ctrl->setParameter($this, "back_pg", $back_pg);
03404                                         }
03405                                         if ($a_frame != "")
03406                                         {
03407                                                 $this->ctrl->setParameter($this, "frame", $a_frame);
03408                                         }
03409                                         if ($a_obj_id != "")
03410                                         {
03411                                                 switch ($a_type)
03412                                                 {
03413                                                         case "MediaObject":
03414                                                                 $this->ctrl->setParameter($this, "mob_id", $a_obj_id);
03415                                                                 break;
03416                                                                 
03417                                                         default:
03418                                                                 $this->ctrl->setParameter($this, "obj_id", $a_obj_id);
03419                                                                 $link.= "&amp;obj_id=".$a_obj_id;
03420                                                                 break;
03421                                                 }
03422                                         }
03423                                         if ($a_type != "")
03424                                         {
03425                                                 $this->ctrl->setParameter($this, "obj_type", $a_type);
03426                                         }
03427                                         $link = $this->ctrl->getLinkTarget($this, $a_cmd);
03428                                         $link = str_replace("&", "&amp;", $link);
03429                                         
03430                                         $this->ctrl->setParameter($this, "frame", "");
03431                                         $this->ctrl->setParameter($this, "obj_id", "");
03432                                         $this->ctrl->setParameter($this, "mob_id", "");
03433                                         break;
03434                         }
03435                 }
03436                 else    // handle offline links
03437                 {
03438                         switch ($a_cmd)
03439                         {
03440                                 case "downloadFile":
03441                                         break;
03442                                         
03443                                 case "fullscreen":
03444                                         $link = "fullscreen.html";              // id is handled by xslt
03445                                         break;
03446                                         
03447                                 case "layout":
03448                                 
03449                                         if ($a_obj_id == "")
03450                                         {
03451                                                 $a_obj_id = $this->lm_tree->getRootId();
03452                                                 $pg_node = $this->lm_tree->fetchSuccessorNode($a_obj_id, "pg");
03453                                                 $a_obj_id = $pg_node["obj_id"];
03454                                         }
03455                                         if ($a_type == "StructureObject")
03456                                         {
03457                                                 $pg_node = $this->lm_tree->fetchSuccessorNode($a_obj_id, "pg");
03458                                                 $a_obj_id = $pg_node["obj_id"];
03459                                         }
03460                                         if ($a_frame != "")
03461                                         {
03462                                                 if ($a_frame != "toc")
03463                                                 {
03464                                                         $link = "frame_".$a_obj_id."_".$a_frame.".html";
03465                                                 }
03466                                                 else    // don't save multiple toc frames (all the same)
03467                                                 {
03468                                                         $link = "frame_".$a_frame.".html";
03469                                                 }                                               
03470                                         }
03471                                         else
03472                                         {
03473                                                 if ($nid = ilLMObject::_lookupNID($this->lm->getId(), $a_obj_id, "pg"))
03474                                                 {
03475                                                         $link = "lm_pg_".$nid.".html";
03476                                                 }
03477                                                 else
03478                                                 {
03479                                                         $link = "lm_pg_".$a_obj_id.".html";
03480                                                 }
03481                                         }
03482                                         break;
03483                                         
03484                                 case "glossary":
03485                                         $link = "term_".$a_obj_id.".html";
03486                                         break;
03487                                 
03488                                 case "media":
03489                                         $link = "media_".$a_obj_id.".html";
03490                                         break;
03491                                         
03492                                 default:
03493                                         break;
03494                         }
03495                 }
03496                 
03497                 $this->ctrl->clearParameters($this);
03498                 
03499                 return $link;
03500         }
03501         
03502         
03503         
03504         function showNoPublicAccess()
03505         {
03506                 $page_id = $this->getCurrentPageId();
03507 
03508                 // content style
03509                 $this->tpl->setCurrentBlock("ContentStyle");
03510                 
03511                 if (!$this->offlineMode())
03512                 {
03513                         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
03514                                 ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
03515                 }
03516                 else
03517                 {
03518                         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content.css");
03519                 }
03520                 
03521                 $this->tpl->parseCurrentBlock();
03522                 $this->tpl->addBlockFile("PAGE_CONTENT", "pg_content", "tpl.page_nopublicaccess.html", true);
03523                 $this->tpl->setCurrentBlock("pg_content");
03524                 $this->tpl->setVariable("TXT_PAGE_NO_PUBLIC_ACCESS",$this->lng->txt("msg_page_no_public_access"));
03525                 $this->tpl->parseCurrentBlock();
03526         }
03527         
03528         function getSourcecodeDownloadLink() {
03529                 if (!$this->offlineMode())
03530                 {
03531                         //$this->ctrl->setParameter($this, session_name(), session_id());
03532                         $target = $this->ctrl->getLinkTarget($this, "");
03533                         $target = ilUtil::appendUrlParameterString($target, session_name()."=".session_id());
03534                         return $this->ctrl->getLinkTarget($this, "");
03535                 }
03536                 else
03537                 {
03538                         return "";
03539                 }
03540         }
03541 
03549         function setOfflineDirectory ($offdir) {
03550                 $this->offline_directory = $offdir;
03551         }
03552         
03553         
03560         function getOfflineDirectory () {
03561                 return $this->offline_directory;
03562         }
03563         
03568         function handleCodeParagraph ($page_id, $paragraph_id, $title, $text) {
03569                 $directory = $this->getOfflineDirectory()."/codefiles/".$page_id."/".$paragraph_id;
03570                 ilUtil::makeDirParents ($directory);
03571                 $file = $directory."/".$title;
03572                 if (!($fp = @fopen($file,"w+")))
03573                 {
03574                         die ("<b>Error</b>: Could not open \"".$file."\" for writing".
03575                                 " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
03576                 }               
03577                 chmod($file, 0770);
03578                 fwrite($fp, $text);
03579                 fclose($fp);
03580         }
03581 }
03582 ?>

Generated on Fri Dec 13 2013 13:52:09 for ILIAS Release_3_7_x_branch .rev 46817 by  doxygen 1.7.1