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

Modules/LearningModule/classes/class.ilObjContentObject.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 
00025 require_once "classes/class.ilObject.php";
00026 require_once "Services/MetaData/classes/class.ilMDLanguageItem.php";
00027 require_once("classes/class.ilNestedSetXML.php");
00028 
00042 class ilObjContentObject extends ilObject
00043 {
00044         var $lm_tree;
00045         var $meta_data;
00046         var $layout;
00047         var $style_id;
00048         var $pg_header;
00049         var $online;
00050 
00057         function ilObjContentObject($a_id = 0,$a_call_by_reference = true)
00058         {
00059                 // this also calls read() method! (if $a_id is set)
00060                 $this->ilObject($a_id,$a_call_by_reference);
00061 
00062                 $this->mob_ids = array();
00063                 $this->file_ids = array();
00064         }
00065 
00069         function create($a_upload = false)
00070         {
00071                 global $ilUser;
00072 
00073                 parent::create();
00074                 
00075                 // meta data will be created by
00076                 // import parser
00077                 if (!$a_upload)
00078                 {
00079                         $this->createMetaData();
00080                 }
00081 
00082                 $this->createProperties();
00083                 if (!$a_upload)
00084                 {
00085                         if (is_object($ilUser))
00086                         {
00087                                 //$this->meta_data->setLanguage($ilUser->getLanguage());
00088                         }
00089                 }
00090         }
00091 
00098         function initDefaultRoles()
00099         {
00100                 return array();
00101 
00102                 global $rbacadmin, $rbacreview;
00103 
00104                 // create a local role folder
00105                 $rfoldObj = $this->createRoleFolder("Local roles","Role Folder of content object ".$this->getId());
00106 
00107                 // note: we don't need any roles here, local "author" roles must
00108                 // be created manually. subscription roles have been abandoned.
00109                 /*
00110                 // create author role and assign role to rolefolder...
00111                 $roleObj = $rfoldObj->createRole("author object ".$this->getRefId(),"author of content object ref id ".$this->getRefId());
00112                 $roles[] = $roleObj->getId();
00113 
00114                 // copy permissions from author template to new role
00115                 $rbacadmin->copyRolePermissions($this->getAuthorRoleTemplateId(), 8, $rfoldObj->getRefId(), $roleObj->getId());
00116 
00117                 // grant all allowed operations of role to current learning module
00118                 $rbacadmin->grantPermission($roleObj->getId(),
00119                         $rbacreview->getOperationsOfRole($roleObj->getId(), "lm", $rfoldObj->getRefId()),
00120                         $this->getRefId());*/
00121 
00122                 unset($rfoldObj);
00123                 //unset($roleObj);
00124 
00125                 return $roles ? $roles : array();
00126         }
00127 
00128 
00132         function read()
00133         {
00134                 parent::read();
00135 #               echo "Content<br>\n";
00136 
00137                 $this->lm_tree = new ilTree($this->getId());
00138                 $this->lm_tree->setTableNames('lm_tree','lm_data');
00139                 $this->lm_tree->setTreeTablePK("lm_id");
00140 
00141                 $this->readProperties();
00142                 //parent::read();
00143         }
00144 
00150         function getTitle()
00151         {
00152                 return parent::getTitle();
00153         }
00154 
00158         function setTitle($a_title)
00159         {
00160                 parent::setTitle($a_title);
00161 //              $this->meta_data->setTitle($a_title);
00162         }
00163 
00169         function getDescription()
00170         {
00171                 return parent::getDescription();
00172         }
00173 
00177         function setDescription($a_description)
00178         {
00179                 parent::setDescription($a_description);
00180 //              $this->meta_data->setDescription($a_description);
00181         }
00182 
00183 
00184         function getImportId()
00185         {
00186                 return $this->import_id;
00187         }
00188 
00189         function setImportId($a_id)
00190         {
00191                 $this->import_id = $a_id;
00192         }
00193 
00194         function &getTree()
00195         {
00196                 return $this->lm_tree;
00197         }
00198 
00202         function update()
00203         {
00204                 $this->updateMetaData();
00205                 parent::update();
00206                 $this->updateProperties();
00207         }
00208 
00209 
00213         function import()
00214         {
00215                 // nothing to do. just display the dialogue in Out
00216                 return;
00217         }
00218 
00219 
00224         function putInTree($a_parent)
00225         {
00226                 global $tree;
00227 
00228                 // put this object in tree under $a_parent
00229                 parent::putInTree($a_parent);
00230 
00231                 // make new tree for this object
00232                 //$tree->addTree($this->getId());
00233         }
00234 
00235 
00241         function createLMTree()
00242         {
00243                 $this->lm_tree =& new ilTree($this->getId());
00244                 $this->lm_tree->setTreeTablePK("lm_id");
00245                 $this->lm_tree->setTableNames('lm_tree','lm_data');
00246                 $this->lm_tree->addTree($this->getId(), 1);
00247         }
00248 
00249 
00253         function &getLMTree()
00254         {
00255                 return $this->lm_tree;
00256         }
00257 
00258 
00264         function createImportDirectory()
00265         {
00266                 $lm_data_dir = ilUtil::getDataDir()."/lm_data";
00267                 if(!is_writable($lm_data_dir))
00268                 {
00269                         $this->ilias->raiseError("Content object Data Directory (".$lm_data_dir
00270                                 .") not writeable.",$this->ilias->error_obj->FATAL);
00271                 }
00272 
00273                 // create learning module directory (data_dir/lm_data/lm_<id>)
00274                 $lm_dir = $lm_data_dir."/lm_".$this->getId();
00275                 ilUtil::makeDir($lm_dir);
00276                 if(!@is_dir($lm_dir))
00277                 {
00278                         $this->ilias->raiseError("Creation of Learning Module Directory failed.",$this->ilias->error_obj->FATAL);
00279                 }
00280 
00281                 // create import subdirectory (data_dir/lm_data/lm_<id>/import)
00282                 $import_dir = $lm_dir."/import";
00283                 ilUtil::makeDir($import_dir);
00284                 if(!@is_dir($import_dir))
00285                 {
00286                         $this->ilias->raiseError("Creation of Import Directory failed.",$this->ilias->error_obj->FATAL);
00287                 }
00288         }
00289 
00293         function getDataDirectory()
00294         {
00295                 return ilUtil::getDataDir()."/lm_data".
00296                         "/lm_".$this->getId();
00297         }
00298 
00302         function getImportDirectory()
00303         {
00304                 $import_dir = ilUtil::getDataDir()."/lm_data".
00305                         "/lm_".$this->getId()."/import";
00306                 if(@is_dir($import_dir))
00307                 {
00308                         return $import_dir;
00309                 }
00310                 else
00311                 {
00312                         return false;
00313                 }
00314         }
00315 
00316 
00322         function createExportDirectory($a_type = "xml")
00323         {
00324                 $lm_data_dir = ilUtil::getDataDir()."/lm_data";
00325                 if(!is_writable($lm_data_dir))
00326                 {
00327                         $this->ilias->raiseError("Content object Data Directory (".$lm_data_dir
00328                                 .") not writeable.",$this->ilias->error_obj->FATAL);
00329                 }
00330                 // create learning module directory (data_dir/lm_data/lm_<id>)
00331                 $lm_dir = $lm_data_dir."/lm_".$this->getId();
00332                 ilUtil::makeDir($lm_dir);
00333                 if(!@is_dir($lm_dir))
00334                 {
00335                         $this->ilias->raiseError("Creation of Learning Module Directory failed.",$this->ilias->error_obj->FATAL);
00336                 }
00337                 // create Export subdirectory (data_dir/lm_data/lm_<id>/Export)
00338                 switch ($a_type)
00339                 {
00340                         // html
00341                         case "html":
00342                                 $export_dir = $lm_dir."/export_html";
00343                                 break;
00344 
00345                         // scorm
00346                         case "scorm":
00347                                 $export_dir = $lm_dir."/export_scorm";
00348                                 break;
00349 
00350                         default:                // = xml
00351                                 $export_dir = $lm_dir."/export";
00352                                 break;
00353                 }
00354                 ilUtil::makeDir($export_dir);
00355 
00356                 if(!@is_dir($export_dir))
00357                 {
00358                         $this->ilias->raiseError("Creation of Export Directory failed.",$this->ilias->error_obj->FATAL);
00359                 }
00360         }
00361 
00365         function getExportDirectory($a_type = "xml")
00366         {
00367                 switch  ($a_type)
00368                 {
00369                         case "html":
00370                                 $export_dir = ilUtil::getDataDir()."/lm_data"."/lm_".$this->getId()."/export_html";
00371                                 break;
00372 
00373                         case "scorm":
00374                                 $export_dir = ilUtil::getDataDir()."/lm_data"."/lm_".$this->getId()."/export_scorm";
00375                                 break;
00376                                 
00377                         default:                        // = xml
00378                                 $export_dir = ilUtil::getDataDir()."/lm_data"."/lm_".$this->getId()."/export";
00379                                 break;
00380                 }
00381                 return $export_dir;
00382         }
00383 
00384 
00395         function delete()
00396         {
00397                 global $ilDB;
00398 
00399                 global $ilBench;
00400 
00401                 // always call parent delete function first!!
00402                 if (!parent::delete())
00403                 {
00404                         return false;
00405                 }
00406 
00407                 // delete lm object data
00408                 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
00409                 ilLMObject::_deleteAllObjectData($this);
00410 
00411                 // delete meta data of content object
00412                 $this->deleteMetaData();
00413 
00414                 // delete bibitem data
00415                 $nested = new ilNestedSetXML();
00416                 $nested->init($this->getId(), "bib");
00417                 $nested->deleteAllDBData();
00418 
00419 
00420                 // delete learning module tree
00421                 $this->lm_tree->removeTree($this->lm_tree->getTreeId());
00422 
00423                 // delete data directory
00424                 ilUtil::delDir($this->getDataDirectory());
00425 
00426                 // delete content object record
00427                 $q = "DELETE FROM content_object WHERE id = ".$ilDB->quote($this->getId());
00428                 $this->ilias->db->query($q);
00429 
00430                 // delete lm menu entries
00431                 $q = "DELETE FROM lm_menu WHERE lm_id = ".$ilDB->quote($this->getId());
00432                 $this->ilias->db->query($q);
00433 
00434                 return true;
00435         }
00436 
00437 
00443         function getLayout()
00444         {
00445                 return $this->layout;
00446         }
00447 
00453         function setLayout($a_layout)
00454         {
00455                 $this->layout = $a_layout;
00456         }
00457 
00461         function getStyleSheetId()
00462         {
00463                 return $this->style_id;
00464         }
00465 
00469         function setStyleSheetId($a_style_id)
00470         {
00471                 $this->style_id = $a_style_id;
00472         }
00473 
00477         function writeStyleSheetId($a_style_id)
00478         {
00479                 global $ilDB;
00480 
00481                 $q = "UPDATE content_object SET ".
00482                         " stylesheet = ".$ilDB->quote($a_style_id).
00483                         " WHERE id = ".$ilDB->quote($this->getId());
00484                 $ilDB->query($q);
00485 
00486                 $this->style_id = $a_style_id;
00487         }
00488         
00492         function _moveLMStyles($a_from_style, $a_to_style)
00493         {
00494                 global $ilDB, $ilias;
00495 
00496                 if ($a_from_style < 0)  // change / delete all individual styles
00497                 {
00498                         $q = "SELECT stylesheet FROM content_object, style_data ".
00499                                 " WHERE content_object.stylesheet = style_data.id ".
00500                                 " AND style_data.standard = 0 ".
00501                                 " AND content_object.stylesheet > 0";
00502                         $style_set = $ilDB->query($q);
00503                         while($style_rec = $style_set->fetchRow(DB_FETCHMODE_ASSOC))
00504                         {
00505                                 // assign learning modules to new style
00506                                 $q = "UPDATE content_object SET ".
00507                                         " stylesheet = ".$ilDB->quote($a_to_style).
00508                                         " WHERE stylesheet = ".$ilDB->quote($style_rec["stylesheet"]);
00509                                 $ilDB->query($q);
00510                                 
00511                                 // delete style
00512                                 $style_obj =& $ilias->obj_factory->getInstanceByObjId($style_rec["stylesheet"]);
00513                                 $style_obj->delete();
00514                         }
00515                 }
00516                 else
00517                 {
00518                         $q = "UPDATE content_object SET ".
00519                                 " stylesheet = ".$ilDB->quote($a_to_style).
00520                                 " WHERE stylesheet = ".$ilDB->quote($a_from_style);
00521                         $ilDB->query($q);
00522                 }
00523         }
00524 
00528         function _lookupStyleSheetId($a_cont_obj_id)
00529         {
00530                 global $ilDB;
00531 
00532                 $q = "SELECT stylesheet FROM content_object ".
00533                         " WHERE id = ".$ilDB->quote($a_cont_obj_id);
00534                 $res = $ilDB->query($q);
00535                 $sheet = $res->fetchRow(DB_FETCHMODE_ASSOC);
00536 
00537                 return $sheet["stylesheet"];
00538         }
00539         
00543         function _lookupContObjIdByStyleId($a_style_id)
00544         {
00545                 global $ilDB;
00546 
00547                 $q = "SELECT id FROM content_object ".
00548                         " WHERE stylesheet = ".$ilDB->quote($a_style_id);
00549                 $res = $ilDB->query($q);
00550                 $obj_ids = array();
00551                 while($cont = $res->fetchRow(DB_FETCHMODE_ASSOC))
00552                 {
00553                         $obj_ids[] = $cont["id"];
00554                 }
00555                 return $obj_ids;
00556         }
00557         
00563         function _getNrOfAssignedLMs($a_style_id)
00564         {
00565                 global $ilDB;
00566                 
00567                 $q = "SELECT count(*) as cnt FROM content_object ".
00568                         " WHERE stylesheet = ".$ilDB->quote($a_style_id);
00569                 $cset = $ilDB->query($q);
00570                 $crow = $cset->fetchRow(DB_FETCHMODE_ASSOC);
00571 
00572                 return (int) $crow["cnt"];
00573         }
00574         
00575         
00579         function _getNrLMsIndividualStyles()
00580         {
00581                 global $ilDB;
00582                 
00583                 // joining with style table (not perfectly nice)
00584                 $q = "SELECT count(*) as cnt FROM content_object, style_data ".
00585                         " WHERE stylesheet = style_data.id ".
00586                         " AND standard = 0";
00587                 $cset = $ilDB->query($q);
00588                 $crow = $cset->fetchRow(DB_FETCHMODE_ASSOC);
00589 
00590                 return (int) $crow["cnt"];
00591         }
00592 
00596         function _getNrLMsNoStyle()
00597         {
00598                 global $ilDB;
00599                 
00600                 $q = "SELECT count(*) as cnt FROM content_object ".
00601                         " WHERE stylesheet = 0";
00602                 $cset = $ilDB->query($q);
00603                 $crow = $cset->fetchRow(DB_FETCHMODE_ASSOC);
00604 
00605                 return (int) $crow["cnt"];
00606         }
00607 
00613         function _deleteStyleAssignments($a_style_id)
00614         {
00615                 global $ilDB;
00616                 
00617                 $q = "UPDATE content_object SET ".
00618                         " stylesheet = ".$ilDB->quote("0").
00619                         " WHERE stylesheet = ".$ilDB->quote($this->getId($a_style_id));
00620 
00621                 $ilDB->query($q);
00622         }
00623 
00627         function getPageHeader()
00628         {
00629                 return $this->pg_header;
00630         }
00631 
00637         function setPageHeader($a_pg_header = IL_CHAPTER_TITLE)
00638         {
00639                 $this->pg_header = $a_pg_header;
00640         }
00641 
00645         function getTOCMode()
00646         {
00647                 return $this->toc_mode;
00648         }
00649         
00653         function getPublicAccessMode()
00654         {
00655                 return $this->public_access_mode;
00656         }
00657 
00663         function setTOCMode($a_toc_mode = "chapters")
00664         {
00665                 $this->toc_mode = $a_toc_mode;
00666         }
00667 
00668         function setOnline($a_online)
00669         {
00670                 $this->online = $a_online;
00671         }
00672 
00673         function getOnline()
00674         {
00675                 return $this->online;
00676         }
00677 
00678         function setActiveLMMenu($a_act_lm_menu)
00679         {
00680                 $this->lm_menu_active = $a_act_lm_menu;
00681         }
00682 
00683         function isActiveLMMenu()
00684         {
00685                 return $this->lm_menu_active;
00686         }
00687 
00688         function setActiveTOC($a_toc)
00689         {
00690                 $this->toc_active = $a_toc;
00691         }
00692 
00693         function isActiveTOC()
00694         {
00695                 return $this->toc_active;
00696         }
00697 
00698         function setActiveNumbering($a_num)
00699         {
00700                 $this->numbering = $a_num;
00701         }
00702 
00703         function isActiveNumbering()
00704         {
00705                 return $this->numbering;
00706         }
00707 
00708         function setActivePrintView($a_print)
00709         {
00710                 $this->print_view_active = $a_print;
00711         }
00712 
00713         function isActivePrintView()
00714         {
00715                 return $this->print_view_active;
00716         }
00717 
00718         function setActiveDownloads($a_down)
00719         {
00720                 $this->downloads_active = $a_down;
00721         }
00722         
00723         function isActiveDownloads()
00724         {
00725                 return $this->downloads_active;
00726         }
00727         
00728         function setActiveDownloadsPublic($a_down)
00729         {
00730                 $this->downloads_public_active = $a_down;
00731         }
00732         
00733         function isActiveDownloadsPublic()
00734         {
00735                 return $this->downloads_public_active;
00736         }
00737 
00738         function setPublicNotes($a_pub_notes)
00739         {
00740                 $this->pub_notes = $a_pub_notes;
00741         }
00742 
00743         function publicNotes()
00744         {
00745                 return $this->pub_notes;
00746         }
00747         
00748         function setCleanFrames($a_clean)
00749         {
00750                 $this->clean_frames = $a_clean;
00751         }
00752 
00753         function cleanFrames()
00754         {
00755                 return $this->clean_frames;
00756         }
00757         
00758         function setHistoryUserComments($a_comm)
00759         {
00760                 $this->user_comments = $a_comm;
00761         }
00762 
00763         function setPublicAccessMode($a_mode)
00764         {
00765                 $this->public_access_mode = $a_mode;
00766         }
00767 
00768         function isActiveHistoryUserComments()
00769         {
00770                 return $this->user_comments;
00771         }
00772 
00773         function setHeaderPage($a_pg)
00774         {
00775                 $this->header_page = $a_pg;
00776         }
00777         
00778         function getHeaderPage()
00779         {
00780                 return $this->header_page;
00781         }
00782         
00783         function setFooterPage($a_pg)
00784         {
00785                 $this->footer_page = $a_pg;
00786         }
00787         
00788         function getFooterPage()
00789         {
00790                 return $this->footer_page;
00791         }
00792 
00796         function readProperties()
00797         {
00798                 global $ilDB;
00799                 
00800                 $q = "SELECT * FROM content_object WHERE id = ".$ilDB->quote($this->getId());
00801                 $lm_set = $this->ilias->db->query($q);
00802                 $lm_rec = $lm_set->fetchRow(DB_FETCHMODE_ASSOC);
00803                 $this->setLayout($lm_rec["default_layout"]);
00804                 $this->setStyleSheetId($lm_rec["stylesheet"]);
00805                 $this->setPageHeader($lm_rec["page_header"]);
00806                 $this->setTOCMode($lm_rec["toc_mode"]);
00807                 $this->setOnline(ilUtil::yn2tf($lm_rec["online"]));
00808                 $this->setActiveTOC(ilUtil::yn2tf($lm_rec["toc_active"]));
00809                 $this->setActiveNumbering(ilUtil::yn2tf($lm_rec["numbering"]));
00810                 $this->setActivePrintView(ilUtil::yn2tf($lm_rec["print_view_active"]));
00811                 $this->setActiveDownloads(ilUtil::yn2tf($lm_rec["downloads_active"]));
00812                 $this->setActiveDownloadsPublic(ilUtil::yn2tf($lm_rec["downloads_public_active"]));
00813                 $this->setActiveLMMenu(ilUtil::yn2tf($lm_rec["lm_menu_active"]));
00814                 $this->setCleanFrames(ilUtil::yn2tf($lm_rec["clean_frames"]));
00815                 $this->setPublicNotes(ilUtil::yn2tf($lm_rec["pub_notes"]));
00816                 $this->setHeaderPage($lm_rec["header_page"]);
00817                 $this->setFooterPage($lm_rec["footer_page"]);
00818                 $this->setHistoryUserComments(ilUtil::yn2tf($lm_rec["hist_user_comments"]));
00819                 $this->setPublicAccessMode($lm_rec["public_access_mode"]);
00820                 $this->setPublicExportFile("xml", $lm_rec["public_xml_file"]);
00821                 $this->setPublicExportFile("html", $lm_rec["public_html_file"]);
00822         }
00823 
00827         function updateProperties()
00828         {
00829                 global $ilDB;
00830                 
00831                 $q = "UPDATE content_object SET ".
00832                         " default_layout = ".$ilDB->quote($this->getLayout()).", ".
00833                         " stylesheet = ".$ilDB->quote($this->getStyleSheetId()).",".
00834                         " page_header = ".$ilDB->quote($this->getPageHeader()).",".
00835                         " toc_mode = ".$ilDB->quote($this->getTOCMode()).",".
00836                         " online = ".$ilDB->quote(ilUtil::tf2yn($this->getOnline())).",".
00837                         " toc_active = ".$ilDB->quote(ilUtil::tf2yn($this->isActiveTOC())).",".
00838                         " numbering = ".$ilDB->quote(ilUtil::tf2yn($this->isActiveNumbering())).",".
00839                         " print_view_active = ".$ilDB->quote(ilUtil::tf2yn($this->isActivePrintView())).",".
00840                         " downloads_active = ".$ilDB->quote(ilUtil::tf2yn($this->isActiveDownloads())).",".
00841                         " downloads_public_active = ".$ilDB->quote(ilUtil::tf2yn($this->isActiveDownloadsPublic())).",".
00842                         " clean_frames = ".$ilDB->quote(ilUtil::tf2yn($this->cleanFrames())).",".
00843                         " pub_notes = ".$ilDB->quote(ilUtil::tf2yn($this->publicNotes())).",".
00844                         " hist_user_comments = ".$ilDB->quote(ilUtil::tf2yn($this->isActiveHistoryUserComments())).",".
00845                         " public_access_mode = ".$ilDB->quote($this->getPublicAccessMode()).",".
00846                         " public_xml_file = ".$ilDB->quote($this->getPublicExportFile("xml")).",".
00847                         " public_html_file = ".$ilDB->quote($this->getPublicExportFile("html")).",".
00848                         " header_page = ".$ilDB->quote($this->getHeaderPage()).",".
00849                         " footer_page = ".$ilDB->quote($this->getFooterPage()).",".
00850                         " lm_menu_active = ".$ilDB->quote(ilUtil::tf2yn($this->isActiveLMMenu()))." ".
00851                         " WHERE id = ".$ilDB->quote($this->getId());
00852                 $this->ilias->db->query($q);
00853         }
00854 
00858         function createProperties()
00859         {
00860                 global $ilDB;
00861                 
00862                 $q = "INSERT INTO content_object (id) VALUES (".$ilDB->quote($this->getId()).")";
00863                 $this->ilias->db->query($q);
00864                 $this->readProperties();                // to get db default values
00865         }
00866 
00870         function _lookupOnline($a_id)
00871         {
00872                 global $ilDB;
00873                 
00874 //echo "class ilObjContentObject::_lookupOnline($a_id) called. Use Access class instead.";
00875 
00876                 $q = "SELECT * FROM content_object WHERE id = ".$ilDB->quote($a_id);
00877                 $lm_set = $this->ilias->db->query($q);
00878                 $lm_rec = $lm_set->fetchRow(DB_FETCHMODE_ASSOC);
00879 
00880                 return ilUtil::yn2tf($lm_rec["online"]);
00881         }
00882 
00888         function getAvailableLayouts()
00889         {
00890                 // read sdir, copy files and copy directories recursively
00891                 $dir = opendir("./Modules/LearningModule/layouts/lm");
00892 
00893                 $layouts = array();
00894 
00895                 while($file = readdir($dir))
00896                 {
00897                         if ($file != "." && $file != ".." && $file != "CVS" && $file != ".svn")
00898                         {
00899                                 // directories
00900                                 if (@is_dir("./Modules/LearningModule/layouts/lm/".$file))
00901                                 {
00902                                         $layouts[$file] = $file;
00903                                 }
00904                         }
00905                 }
00906                 asort($layouts);
00907                 return $layouts;
00908         }
00909 
00913         function _checkPreconditionsOfPage($cont_ref_id,$cont_obj_id, $page_id)
00914         {
00915                 global $ilias,$ilUser,$ilErr;
00916 
00917                 $lm_tree = new ilTree($cont_obj_id);
00918                 $lm_tree->setTableNames('lm_tree','lm_data');
00919                 $lm_tree->setTreeTablePK("lm_id");
00920 
00921                 if ($lm_tree->isInTree($page_id))
00922                 {
00923                         $path = $lm_tree->getPathFull($page_id, $lm_tree->readRootId());
00924                         foreach ($path as $node)
00925                         {
00926                                 if ($node["type"] == "st")
00927                                 {
00928                                         if (!ilConditionHandler::_checkAllConditionsOfTarget($cont_ref_id,$node["child"], "st"))
00929                                         {
00930                                                 return false;
00931                                         }
00932                                 }
00933                         }
00934                 }
00935                 
00936                 return true;
00937         }
00938 
00942         function _getMissingPreconditionsOfPage($cont_ref_id,$cont_obj_id, $page_id)
00943         {
00944                 $lm_tree = new ilTree($cont_obj_id);
00945                 $lm_tree->setTableNames('lm_tree','lm_data');
00946                 $lm_tree->setTreeTablePK("lm_id");
00947 
00948                 $conds = array();
00949                 if ($lm_tree->isInTree($page_id))
00950                 {
00951                         // get full path of page
00952                         $path = $lm_tree->getPathFull($page_id, $lm_tree->readRootId());
00953                         foreach ($path as $node)
00954                         {
00955                                 if ($node["type"] == "st")
00956                                 {
00957                                         // get all preconditions of upper chapters
00958                                         $tconds = ilConditionHandler::_getConditionsOfTarget($cont_ref_id,$node["child"], "st");
00959                                         foreach ($tconds as $tcond)
00960                                         {
00961                                                 // store all missing preconditions
00962                                                 if (!ilConditionHandler::_checkCondition($tcond["id"]))
00963                                                 {
00964                                                         $conds[] = $tcond;
00965                                                 }
00966                                         }
00967                                 }
00968                         }
00969                 }
00970                 
00971                 return $conds;
00972         }
00973 
00977         function _getMissingPreconditionsTopChapter($cont_obj_ref_id,$cont_obj_id, $page_id)
00978         {
00979                 $lm_tree = new ilTree($cont_obj_id);
00980                 $lm_tree->setTableNames('lm_tree','lm_data');
00981                 $lm_tree->setTreeTablePK("lm_id");
00982 
00983                 $conds = array();
00984                 if ($lm_tree->isInTree($page_id))
00985                 {
00986                         // get full path of page
00987                         $path = $lm_tree->getPathFull($page_id, $lm_tree->readRootId());
00988                         foreach ($path as $node)
00989                         {
00990                                 if ($node["type"] == "st")
00991                                 {
00992                                         // get all preconditions of upper chapters
00993                                         $tconds = ilConditionHandler::_getConditionsOfTarget($cont_obj_ref_id,$node["child"], "st");
00994                                         foreach ($tconds as $tcond)
00995                                         {
00996                                                 // look for missing precondition
00997                                                 if (!ilConditionHandler::_checkCondition($tcond["id"]))
00998                                                 {
00999                                                         return $node["child"];
01000                                                 }
01001                                         }
01002                                 }
01003                         }
01004                 }
01005                 
01006                 return "";
01007         }
01008 
01019         function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
01020         {
01021                 global $tree;
01022                 
01023                 switch ($a_event)
01024                 {
01025                         case "link":
01026 
01027                                 //var_dump("<pre>",$a_params,"</pre>");
01028                                 //echo "Content Object ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
01029                                 //exit;
01030                                 break;
01031                         
01032                         case "cut":
01033                                 
01034                                 //echo "Content Object ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
01035                                 //exit;
01036                                 break;
01037                                 
01038                         case "copy":
01039                         
01040                                 //var_dump("<pre>",$a_params,"</pre>");
01041                                 //echo "Content Object ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
01042                                 //exit;
01043                                 break;
01044 
01045                         case "paste":
01046                                 
01047                                 //echo "Content Object ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
01048                                 //exit;
01049                                 break;
01050                         
01051                         case "new":
01052                                 
01053                                 //echo "Content Object ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
01054                                 //exit;
01055                                 break;
01056                 }
01057 
01058                 // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
01059                 if ($a_node_id==$_GET["ref_id"])
01060                 {       
01061                         $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
01062                         $parent_type = $parent_obj->getType();
01063                         if($parent_type == $this->getType())
01064                         {
01065                                 $a_node_id = (int) $tree->getParentId($a_node_id);
01066                         }
01067                 }
01068                 
01069                 parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
01070         }
01071 
01079         function _search(&$search_obj,$a_search_in)
01080         {
01081                 global $ilBench;
01082 
01083                 switch($a_search_in)
01084                 {
01085                         case 'meta':
01086                                 // FILTER ALL DBK OBJECTS
01087                                 $in             = $search_obj->getInStatement("r.ref_id");
01088                                 $where  = $search_obj->getWhereCondition("fulltext",array("xv.tag_value"));
01089 
01090                                 /* very slow on mysql < 4.0.18 (? or everytime ?)
01091                                 $query = "SELECT DISTINCT(r.ref_id) FROM object_reference AS r,object_data AS o, ".
01092                                         "lm_data AS l,xmlnestedset AS xm,xmlvalue AS xv ".
01093                                         $where.
01094                                         $in.
01095                                         "AND r.obj_id=o.obj_id AND ((o.obj_id=l.lm_id AND xm.ns_book_fk=l.obj_id) OR ".
01096                                         "(o.obj_id=xm.ns_book_fk AND xm.ns_type IN ('lm','bib'))) ".
01097                                         "AND xm.ns_tag_fk=xv.tag_fk ".
01098                                         "AND o.type= 'lm'";*/
01099 
01100                                 $query1 = "SELECT DISTINCT(r.ref_id) FROM object_reference AS r,object_data AS o, ".
01101                                         "xmlnestedset AS xm,xmlvalue AS xv ".
01102                                         $where.
01103                                         $in.
01104                                         "AND r.obj_id=o.obj_id AND ( ".
01105                                         "(o.obj_id=xm.ns_book_fk AND xm.ns_type IN ('lm','bib'))) ".
01106                                         "AND xm.ns_tag_fk=xv.tag_fk ".
01107                                         "AND o.type= 'lm'";
01108 
01109                                 // BEGINNING SELECT WITH SEARCH RESULTS IS MUCH FASTER
01110                                 $query1 = "SELECT DISTINCT(r.ref_id) as ref_id FROM xmlvalue AS xv ".
01111                                         "LEFT JOIN xmlnestedset AS xm ON xm.ns_tag_fk=xv.tag_fk ".
01112                                         "LEFT JOIN object_data AS o ON o.obj_id = xm.ns_book_fk ".
01113                                         "LEFT JOIN object_reference AS r ON o.obj_id = r.obj_id ".
01114                                         $where.
01115                                         $in.
01116                                         " AND o.type = 'lm' AND xm.ns_type IN ('lm','bib')";
01117 
01118                                 $query2 = "SELECT DISTINCT(r.ref_id) FROM object_reference AS r,object_data AS o, ".
01119                                         "lm_data AS l,xmlnestedset AS xm,xmlvalue AS xv ".
01120                                         $where.
01121                                         $in.
01122                                         "AND r.obj_id=o.obj_id AND ((o.obj_id=l.lm_id AND xm.ns_book_fk=l.obj_id)".
01123                                         ") ".
01124                                         "AND xm.ns_tag_fk=xv.tag_fk ".
01125                                         "AND o.type= 'lm'";
01126 
01127                                 $query2 = "SELECT DISTINCT(r.ref_id) as ref_id FROM xmlvalue AS xv ".
01128                                         "LEFT JOIN xmlnestedset AS xm ON xm.ns_tag_fk = xv.tag_fk ".
01129                                         "LEFT JOIN lm_data AS l ON l.obj_id = xm.ns_book_fk ".
01130                                         "LEFT JOIN object_data AS o ON o.obj_id = l.lm_id ".
01131                                         "LEFT JOIN object_reference AS r ON r.obj_id = o.obj_id ".
01132                                         $where.
01133                                         $in.
01134                                         "AND o.type = 'lm'";
01135 
01136                                 $ilBench->start("Search", "ilObjContentObject_search_meta");
01137                                 $res1 = $search_obj->ilias->db->query($query1);
01138                                 $res2 = $search_obj->ilias->db->query($query2);
01139                                 $ilBench->stop("Search", "ilObjContentObject_search_meta");
01140 
01141                                 $counter = 0;
01142                                 $ids = array();
01143                                 while($row = $res1->fetchRow(DB_FETCHMODE_OBJECT))
01144                                 {
01145                                         $ids[] = $row->ref_id;
01146                                         $result[$counter]["id"]         =  $row->ref_id;
01147                                         ++$counter;
01148                                 }
01149                                 while($row = $res2->fetchRow(DB_FETCHMODE_OBJECT))
01150                                 {
01151                                         if(in_array($row->ref_id,$ids))
01152                                         {
01153                                                 continue;
01154                                         }
01155                                         $result[$counter]["id"]         =  $row->ref_id;
01156                                         ++$counter;
01157                                 }
01158                                 break;
01159 
01160                         case 'content':
01161                                 $in             = $search_obj->getInStatement("r.ref_id");
01162                                 $where  = $search_obj->getWhereCondition("fulltext",array("pg.content"));
01163 
01164                                 // slow on mysql < 4.0.18 (join bug)
01165                                 /*
01166                                 $query = "SELECT DISTINCT(r.ref_id) AS ref_id ,pg.page_id AS page_id FROM page_object AS pg ".
01167                                         "INNER JOIN object_reference AS r ON pg.parent_id = r.obj_id ".
01168                                         $where.
01169                                         $in.
01170                                         "AND pg.parent_type = 'lm' ";*/
01171 
01172                                 $query = "SELECT DISTINCT(r.ref_id) AS ref_id ,pg.page_id AS page_id FROM page_object AS pg ".
01173                                         ", object_reference AS r ".
01174                                         $where.
01175                                         " AND pg.parent_id = r.obj_id ".
01176                                         $in.
01177                                         " AND pg.parent_type = 'lm' ";
01178 
01179                                 $query = "SELECT DISTINCT(r.ref_id) AS ref_id ,pg.page_id AS page_id FROM page_object AS pg ".
01180                                         "LEFT JOIN object_data AS o ON o.obj_id = pg.parent_id ".
01181                                         "LEFT JOIN object_reference AS r ON o.obj_id = r.obj_id ".
01182                                         $where.
01183                                         $in.
01184                                         " AND pg.parent_type = 'lm'";
01185 
01186                                 $ilBench->start("Search", "ilObjContentObject_search_content");
01187                                 $res = $search_obj->ilias->db->query($query);
01188                                 $ilBench->stop("Search", "ilObjContentObject_search_content");
01189 
01190                                 $counter = 0;
01191                                 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
01192                                 {
01193                                         $result[$counter]["id"] = $row->ref_id;
01194                                         $result[$counter]["page_id"] = $row->page_id;
01195                                         ++$counter;
01196                                 }
01197                                 break;
01198                 }
01199                 return $result ? $result : array();
01200         }
01201         
01205         function hasSuccessorPage($a_cont_obj_id, $a_page_id)
01206         {
01207                 $tree = new ilTree($a_cont_obj_id);
01208                 $tree->setTableNames('lm_tree','lm_data');
01209                 $tree->setTreeTablePK("lm_id");
01210                 if ($tree->isInTree($a_page_id))
01211                 {
01212                         $succ = $tree->fetchSuccessorNode($a_page_id, "pg");
01213                         if ($succ > 0)
01214                         {
01215                                 return true;
01216                         }
01217                 }
01218                 return false;
01219         }
01220 
01221         
01222         function checkTree()
01223         {
01224                 $tree = new ilTree($this->getId());
01225                 $tree->setTableNames('lm_tree','lm_data');
01226                 $tree->setTreeTablePK("lm_id");
01227                 $tree->checkTree();
01228                 $tree->checkTreeChilds();
01229 //echo "checked";
01230         }
01231 
01235         function fixTree()
01236         {
01237                 global $ilDB;
01238 
01239                 $tree =& $this->getLMTree();
01240 
01241                 // delete subtrees that have no lm_data records
01242                 $nodes = $tree->getSubtree($tree->getNodeData($tree->getRootId()));
01243                 foreach ($nodes as $node)
01244                 {
01245                         $q = "SELECT * FROM lm_data WHERE obj_id = ".$ilDB->quote($node["child"]);
01246                         $obj_set = $ilDB->query($q);
01247                         $obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC);
01248                         if (!$obj_rec)
01249                         {
01250                                 $node_data = $tree->getNodeData($node["child"]);
01251                                 $tree->deleteTree($node_data);
01252                         }
01253                 }
01254 
01255                 // delete subtrees that have pages as parent
01256                 $nodes = $tree->getSubtree($tree->getNodeData($tree->getRootId()));
01257                 foreach ($nodes as $node)
01258                 {
01259                         $q = "SELECT * FROM lm_data WHERE obj_id = ".$ilDB->quote($node["parent"]);
01260                         $obj_set = $ilDB->query($q);
01261                         $obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC);
01262                         if ($obj_rec["type"] == "pg")
01263                         {
01264                                 $node_data = $tree->getNodeData($node["child"]);
01265                                 if ($tree->isInTree($node["child"]))
01266                                 {
01267                                         $tree->deleteTree($node_data);
01268                                 }
01269                         }
01270                 }
01271 
01272         }
01273 
01274 
01281         function exportXML(&$a_xml_writer, $a_inst, $a_target_dir, &$expLog)
01282         {
01283                 global $ilBench;
01284 
01285                 $attrs = array();
01286                 switch($this->getType())
01287                 {
01288                         case "lm":
01289                                 $attrs["Type"] = "LearningModule";
01290                                 break;
01291 
01292                         case "dbk":
01293                                 $attrs["Type"] = "LibObject";
01294                                 break;
01295                 }
01296                 $a_xml_writer->xmlStartTag("ContentObject", $attrs);
01297 
01298                 // MetaData
01299                 $this->exportXMLMetaData($a_xml_writer);
01300 
01301                 // StructureObjects
01302 //echo "ContObj:".$a_inst.":<br>";
01303                 $expLog->write(date("[y-m-d H:i:s] ")."Start Export Structure Objects");
01304                 $ilBench->start("ContentObjectExport", "exportStructureObjects");
01305                 $this->exportXMLStructureObjects($a_xml_writer, $a_inst, $expLog);
01306                 $ilBench->stop("ContentObjectExport", "exportStructureObjects");
01307                 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export Structure Objects");
01308 
01309                 // PageObjects
01310                 $expLog->write(date("[y-m-d H:i:s] ")."Start Export Page Objects");
01311                 $ilBench->start("ContentObjectExport", "exportPageObjects");
01312                 $this->exportXMLPageObjects($a_xml_writer, $a_inst, $expLog);
01313                 $ilBench->stop("ContentObjectExport", "exportPageObjects");
01314                 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export Page Objects");
01315 
01316                 // MediaObjects
01317                 $expLog->write(date("[y-m-d H:i:s] ")."Start Export Media Objects");
01318                 $ilBench->start("ContentObjectExport", "exportMediaObjects");
01319                 $this->exportXMLMediaObjects($a_xml_writer, $a_inst, $a_target_dir, $expLog);
01320                 $ilBench->stop("ContentObjectExport", "exportMediaObjects");
01321                 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export Media Objects");
01322 
01323                 // FileItems
01324                 $expLog->write(date("[y-m-d H:i:s] ")."Start Export File Items");
01325                 $ilBench->start("ContentObjectExport", "exportFileItems");
01326                 $this->exportFileItems($a_target_dir, $expLog);
01327                 $ilBench->stop("ContentObjectExport", "exportFileItems");
01328                 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export File Items");
01329                 
01330                 // To do: implement version selection/detection
01331                 // Properties
01332                 $expLog->write(date("[y-m-d H:i:s] ")."Start Export Properties");
01333                 $this->exportXMLProperties($a_xml_writer, $expLog);
01334                 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export Properties");
01335 
01336                 // Glossary
01337                 // not implemented
01338 
01339                 // Bibliography
01340                 // not implemented
01341 
01342                 // Layout
01343                 // not implemented
01344 
01345                 $a_xml_writer->xmlEndTag("ContentObject");
01346         }
01347 
01354         function exportXMLMetaData(&$a_xml_writer)
01355         {
01356                 include_once("Services/MetaData/classes/class.ilMD2XML.php");
01357                 $md2xml = new ilMD2XML($this->getId(), 0, $this->getType());
01358                 $md2xml->setExportMode(true);
01359                 $md2xml->startExport();
01360                 $a_xml_writer->appendXML($md2xml->getXML());
01361         }
01362 
01369         function exportXMLStructureObjects(&$a_xml_writer, $a_inst, &$expLog)
01370         {
01371                 include_once './Modules/LearningModule/classes/class.ilStructureObject.php';
01372 
01373                 $childs = $this->lm_tree->getChilds($this->lm_tree->getRootId());
01374                 foreach ($childs as $child)
01375                 {
01376                         if($child["type"] != "st")
01377                         {
01378                                 continue;
01379                         }
01380 
01381                         $structure_obj = new ilStructureObject($this, $child["obj_id"]);
01382                         $structure_obj->exportXML($a_xml_writer, $a_inst, $expLog);
01383                         unset($structure_obj);
01384                 }
01385         }
01386 
01387 
01394         function exportXMLPageObjects(&$a_xml_writer, $a_inst, &$expLog)
01395         {
01396                 global $ilBench;
01397 
01398                 include_once "./Modules/LearningModule/classes/class.ilLMPageObject.php";
01399 
01400                 $pages = ilLMPageObject::getPageList($this->getId());
01401                 foreach ($pages as $page)
01402                 {
01403                         $ilBench->start("ContentObjectExport", "exportPageObject");
01404                         $expLog->write(date("[y-m-d H:i:s] ")."Page Object ".$page["obj_id"]);
01405 
01406                         // export xml to writer object
01407                         $ilBench->start("ContentObjectExport", "exportPageObject_getLMPageObject");
01408                         $page_obj = new ilLMPageObject($this, $page["obj_id"]);
01409                         $ilBench->stop("ContentObjectExport", "exportPageObject_getLMPageObject");
01410                         $ilBench->start("ContentObjectExport", "exportPageObject_XML");
01411                         $page_obj->exportXML($a_xml_writer, "normal", $a_inst);
01412                         $ilBench->stop("ContentObjectExport", "exportPageObject_XML");
01413 
01414                         // collect media objects
01415                         $ilBench->start("ContentObjectExport", "exportPageObject_CollectMedia");
01416                         $mob_ids = $page_obj->getMediaObjectIDs();
01417                         foreach($mob_ids as $mob_id)
01418                         {
01419                                 $this->mob_ids[$mob_id] = $mob_id;
01420                         }
01421                         $ilBench->stop("ContentObjectExport", "exportPageObject_CollectMedia");
01422 
01423                         // collect all file items
01424                         $ilBench->start("ContentObjectExport", "exportPageObject_CollectFileItems");
01425                         $file_ids = $page_obj->getFileItemIds();
01426                         foreach($file_ids as $file_id)
01427                         {
01428                                 $this->file_ids[$file_id] = $file_id;
01429                         }
01430                         $ilBench->stop("ContentObjectExport", "exportPageObject_CollectFileItems");
01431 
01432                         unset($page_obj);
01433 
01434                         $ilBench->stop("ContentObjectExport", "exportPageObject");
01435                 }
01436         }
01437 
01444         function exportXMLMediaObjects(&$a_xml_writer, $a_inst, $a_target_dir, &$expLog)
01445         {
01446                 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
01447 
01448                 $linked_mobs = array();
01449                 
01450                 // mobs directly embedded into pages
01451                 foreach ($this->mob_ids as $mob_id)
01452                 {
01453                         if ($mob_id > 0)
01454                         {
01455                                 $expLog->write(date("[y-m-d H:i:s] ")."Media Object ".$mob_id);
01456                                 $media_obj = new ilObjMediaObject($mob_id);
01457                                 $media_obj->exportXML($a_xml_writer, $a_inst);
01458                                 $media_obj->exportFiles($a_target_dir);
01459                                 
01460                                 $lmobs = $media_obj->getLinkedMediaObjects($this->mob_ids);
01461                                 $linked_mobs = array_merge($linked_mobs, $lmobs);
01462                                 
01463                                 unset($media_obj);
01464                         }
01465                 }
01466 
01467                 // linked mobs (in map areas)
01468                 foreach ($linked_mobs as $mob_id)
01469                 {
01470                         if ($mob_id > 0)
01471                         {
01472                                 $expLog->write(date("[y-m-d H:i:s] ")."Media Object ".$mob_id);
01473                                 $media_obj = new ilObjMediaObject($mob_id);
01474                                 $media_obj->exportXML($a_xml_writer, $a_inst);
01475                                 $media_obj->exportFiles($a_target_dir);
01476                                 unset($media_obj);
01477                         }
01478                 }
01479 
01480         }
01481 
01486         function exportFileItems($a_target_dir, &$expLog)
01487         {
01488                 include_once("./Modules/File/classes/class.ilObjFile.php");
01489 
01490                 foreach ($this->file_ids as $file_id)
01491                 {
01492                         $expLog->write(date("[y-m-d H:i:s] ")."File Item ".$file_id);
01493                         $file_obj = new ilObjFile($file_id, false);
01494                         $file_obj->export($a_target_dir);
01495                         unset($file_obj);
01496                 }
01497         }
01498 
01503         function exportXMLProperties($a_xml_writer, &$expLog)
01504         {
01505                 $attrs = array();
01506                 $a_xml_writer->xmlStartTag("Properties", $attrs);
01507 
01508                 // Layout
01509                 $attrs = array("Name" => "Layout", "Value" => $this->getLayout());
01510                 $a_xml_writer->xmlElement("Property", $attrs);
01511                 
01512                 // Page Header
01513                 $attrs = array("Name" => "PageHeader", "Value" => $this->getPageHeader());
01514                 $a_xml_writer->xmlElement("Property", $attrs);
01515                 
01516                 // TOC Mode
01517                 $attrs = array("Name" => "TOCMode", "Value" => $this->getTOCMode());
01518                 $a_xml_writer->xmlElement("Property", $attrs);
01519                 
01520                 // LM Menu Activation
01521                 $attrs = array("Name" => "ActiveLMMenu", "Value" =>
01522                         ilUtil::tf2yn($this->isActiveLMMenu()));
01523                 $a_xml_writer->xmlElement("Property", $attrs);
01524 
01525                 // Numbering Activation
01526                 $attrs = array("Name" => "ActiveNumbering", "Value" =>
01527                         ilUtil::tf2yn($this->isActiveNumbering()));
01528                 $a_xml_writer->xmlElement("Property", $attrs);
01529 
01530                 // Table of contents button activation
01531                 $attrs = array("Name" => "ActiveTOC", "Value" =>
01532                         ilUtil::tf2yn($this->isActiveTOC()));
01533                 $a_xml_writer->xmlElement("Property", $attrs);
01534                 
01535                 // Print view button activation
01536                 $attrs = array("Name" => "ActivePrintView", "Value" =>
01537                         ilUtil::tf2yn($this->isActivePrintView()));
01538                 $a_xml_writer->xmlElement("Property", $attrs);
01539                 
01540                 // Note that download button is not saved, because
01541                 // download files do not exist after import
01542 
01543                 // Clean frames
01544                 $attrs = array("Name" => "CleanFrames", "Value" =>
01545                         ilUtil::tf2yn($this->cleanFrames()));
01546                 $a_xml_writer->xmlElement("Property", $attrs);
01547                 
01548                 // Public notes activation
01549                 $attrs = array("Name" => "PublicNotes", "Value" =>
01550                         ilUtil::tf2yn($this->publicNotes()));
01551                 $a_xml_writer->xmlElement("Property", $attrs);
01552                 
01553                 // History comments for authors activation
01554                 $attrs = array("Name" => "HistoryUserComments", "Value" =>
01555                         ilUtil::tf2yn($this->isActiveHistoryUserComments()));
01556                 $a_xml_writer->xmlElement("Property", $attrs);
01557 
01558                 // Header Page
01559                 if ($this->getHeaderPage() > 0)
01560                 {
01561                         $attrs = array("Name" => "HeaderPage", "Value" =>
01562                                 "il_".IL_INST_ID."_pg_".$this->getHeaderPage());
01563                         $a_xml_writer->xmlElement("Property", $attrs);
01564                 }
01565 
01566                 // Footer Page
01567                 if ($this->getFooterPage() > 0)
01568                 {
01569                         $attrs = array("Name" => "FooterPage", "Value" =>
01570                                 "il_".IL_INST_ID."_pg_".$this->getFooterPage());
01571                         $a_xml_writer->xmlElement("Property", $attrs);
01572                 }
01573 
01574                 $a_xml_writer->xmlEndTag("Properties");
01575         }
01576 
01580         function getExportFiles()
01581         {
01582                 $file = array();
01583                 
01584                 $types = array("xml", "html", "scorm");
01585                 
01586                 foreach ($types as $type)
01587                 {
01588                         $dir = $this->getExportDirectory($type);
01589                         // quit if import dir not available
01590                         if (!@is_dir($dir) or
01591                                 !is_writeable($dir))
01592                         {
01593                                 continue;
01594                         }
01595         
01596                         // open directory
01597                         $cdir = dir($dir);
01598         
01599                         // initialize array
01600         
01601                         // get files and save the in the array
01602                         while ($entry = $cdir->read())
01603                         {
01604                                 if ($entry != "." and
01605                                         $entry != ".." and
01606                                         substr($entry, -4) == ".zip" and
01607                                         ereg("^[0-9]{10}_{2}[0-9]+_{2}(lm_)*[0-9]+\.zip\$", $entry))
01608                                 {
01609                                         $file[$entry.$type] = array("type" => $type, "file" => $entry,
01610                                                 "size" => filesize($dir."/".$entry));
01611                                 }
01612                         }
01613         
01614                         // close import directory
01615                         $cdir->close();
01616                 }
01617 
01618                 // sort files
01619                 ksort ($file);
01620                 reset ($file);
01621                 return $file;
01622         }
01623         
01630         function setPublicExportFile($a_type, $a_file)
01631         {
01632                 $this->public_export_file[$a_type] = $a_file;
01633         }
01634 
01642         function getPublicExportFile($a_type)
01643         {
01644                 return $this->public_export_file[$a_type];
01645         }
01646 
01650         function getOfflineFiles($dir)
01651         {
01652                 // quit if offline dir not available
01653                 if (!@is_dir($dir) or
01654                         !is_writeable($dir))
01655                 {
01656                         return array();
01657                 }
01658 
01659                 // open directory
01660                 $dir = dir($dir);
01661 
01662                 // initialize array
01663                 $file = array();
01664 
01665                 // get files and save the in the array
01666                 while ($entry = $dir->read())
01667                 {
01668                         if ($entry != "." and
01669                                 $entry != ".." and
01670                                 substr($entry, -4) == ".pdf" and
01671                                 ereg("^[0-9]{10}_{2}[0-9]+_{2}(lm_)*[0-9]+\.pdf\$", $entry))
01672                         {
01673                                 $file[] = $entry;
01674                         }
01675                 }
01676 
01677                 // close import directory
01678                 $dir->close();
01679 
01680                 // sort files
01681                 sort ($file);
01682                 reset ($file);
01683 
01684                 return $file;
01685         }
01686         
01690         function exportSCORM($a_target_dir, $log)
01691         {
01692                 ilUtil::delDir($a_target_dir);
01693                 ilUtil::makeDir($a_target_dir);
01694                 //ilUtil::makeDir($a_target_dir."/res");
01695                 
01696                 // export everything to html
01697                 $this->exportHTML($a_target_dir."/res", $log, false, "scorm");
01698                 
01699                 // build manifest file
01700                 include("./Modules/LearningModule/classes/class.ilContObjectManifestBuilder.php");
01701                 $man_builder = new ilContObjectManifestBuilder($this);
01702                 $man_builder->buildManifest();
01703                 $man_builder->dump($a_target_dir);
01704                 
01705                 // copy scorm 1.2 schema definitions
01706                 copy("Modules/LearningModule/scorm_xsd/adlcp_rootv1p2.xsd", $a_target_dir."/adlcp_rootv1p2.xsd");
01707                 copy("Modules/LearningModule/scorm_xsd/imscp_rootv1p1p2.xsd", $a_target_dir."/imscp_rootv1p1p2.xsd");
01708                 copy("Modules/LearningModule/scorm_xsd/imsmd_rootv1p2p1.xsd", $a_target_dir."/imsmd_rootv1p2p1.xsd");
01709                 copy("Modules/LearningModule/scorm_xsd/ims_xml.xsd", $a_target_dir."/ims_xml.xsd");
01710 
01711                 // zip it all
01712                 $date = time();
01713                 $zip_file = $a_target_dir."/".$date."__".IL_INST_ID."__".
01714                         $this->getType()."_".$this->getId().".zip";
01715         //echo "zip-".$a_target_dir."-to-".$zip_file;
01716                 ilUtil::zip(array($a_target_dir."/res",
01717                         $a_target_dir."/imsmanifest.xml",
01718                         $a_target_dir."/adlcp_rootv1p2.xsd",
01719                         $a_target_dir."/imscp_rootv1p1p2.xsd",
01720                         $a_target_dir."/ims_xml.xsd",
01721                         $a_target_dir."/imsmd_rootv1p2p1.xsd")
01722                         , $zip_file);
01723 
01724                 $dest_file = $this->getExportDirectory("scorm")."/".$date."__".IL_INST_ID."__".
01725                         $this->getType()."_".$this->getId().".zip";
01726                 
01727                 rename($zip_file, $dest_file);
01728                 ilUtil::delDir($a_target_dir);
01729 
01730         }
01731 
01732         
01736         function exportHTML($a_target_dir, $log, $a_zip_file = true, $a_export_format = "html")
01737         {
01738                 global $ilias, $tpl, $ilBench, $ilLocator;
01739 
01740                 // initialize temporary target directory
01741                 ilUtil::delDir($a_target_dir);
01742                 ilUtil::makeDir($a_target_dir);
01743                 $mob_dir = $a_target_dir."/mobs";
01744                 ilUtil::makeDir($mob_dir);
01745                 $file_dir = $a_target_dir."/files";
01746                 ilUtil::makeDir($file_dir);
01747                 $teximg_dir = $a_target_dir."/teximg";
01748                 ilUtil::makeDir($teximg_dir);
01749                 $GLOBALS["teximgcnt"] = 0;
01750 
01751                 // export system style sheet
01752                 $location_stylesheet = ilUtil::getStyleSheetLocation("filesystem");
01753                 $style_name = $ilias->account->prefs["style"].".css";
01754                 copy($location_stylesheet, $a_target_dir."/".$style_name);
01755                 $location_stylesheet = ilUtil::getStyleSheetLocation();
01756                 
01757                 // export content style sheet
01758                 $ilBench->start("ExportHTML", "exportContentStyle");
01759                 if ($this->getStyleSheetId() < 1)
01760                 {
01761                         $cont_stylesheet = "./Services/COPage/css/content.css";
01762                         copy($cont_stylesheet, $a_target_dir."/content.css");
01763                 }
01764                 else
01765                 {
01766                         $style = new ilObjStyleSheet($this->getStyleSheetId());
01767                         $style->writeCSSFile($a_target_dir."/content.css");
01768                 }
01769                 $ilBench->stop("ExportHTML", "exportContentStyle");
01770                 
01771                 // export syntax highlighting style
01772                 $syn_stylesheet = ilObjStyleSheet::getSyntaxStylePath();
01773                 copy($syn_stylesheet, $a_target_dir."/syntaxhighlight.css");
01774 
01775                 // get learning module presentation gui class
01776                 include_once("./Modules/LearningModule/classes/class.ilLMPresentationGUI.php");
01777                 $_GET["cmd"] = "nop";
01778                 $lm_gui =& new ilLMPresentationGUI();
01779                 $lm_gui->setOfflineMode(true);
01780                 $lm_gui->setOfflineDirectory($a_target_dir);
01781                 $lm_gui->setExportFormat($a_export_format);
01782 
01783                 // export pages
01784                 $ilBench->start("ExportHTML", "exportHTMLPages");
01785                 $this->exportHTMLPages($lm_gui, $a_target_dir);
01786                 $ilBench->stop("ExportHTML", "exportHTMLPages");
01787 
01788                 // export glossary terms
01789                 $ilBench->start("ExportHTML", "exportHTMLGlossaryTerms");
01790                 $this->exportHTMLGlossaryTerms($lm_gui, $a_target_dir);
01791                 $ilBench->stop("ExportHTML", "exportHTMLGlossaryTerms");
01792 
01793                 // export all media objects
01794                 $ilBench->start("ExportHTML", "exportHTMLMediaObjects");
01795                 $linked_mobs = array();
01796                 foreach ($this->offline_mobs as $mob)
01797                 {
01798                         if (ilObject::_exists($mob))
01799                         {
01800                                 $this->exportHTMLMOB($a_target_dir, $lm_gui, $mob, "_blank", $linked_mobs);
01801                         }
01802                 }
01803                 $linked_mobs2 = array();                                // mobs linked in link areas
01804                 foreach ($linked_mobs as $mob)
01805                 {
01806                         if (ilObject::_exists($mob))
01807                         {
01808                                 $this->exportHTMLMOB($a_target_dir, $lm_gui, $mob, "_blank", $linked_mobs2);
01809                         }
01810                 }
01811                 $_GET["obj_type"]  = "MediaObject";
01812                 $_GET["obj_id"]  = $a_mob_id;
01813                 $_GET["cmd"] = "";
01814                 $ilBench->stop("ExportHTML", "exportHTMLMediaObjects");
01815 
01816                 // export all file objects
01817                 $ilBench->start("ExportHTML", "exportHTMLFileObjects");
01818                 foreach ($this->offline_files as $file)
01819                 {
01820                         $this->exportHTMLFile($a_target_dir, $file);
01821                 }
01822                 $ilBench->stop("ExportHTML", "exportHTMLFileObjects");
01823 
01824                 // export table of contents
01825                 $ilBench->start("ExportHTML", "exportHTMLTOC");
01826                 $ilLocator->clearItems();
01827                 if ($this->isActiveTOC())
01828                 {
01829                         $tpl = new ilTemplate("tpl.main.html", true, true);
01830                         //$tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
01831                         $content =& $lm_gui->showTableOfContents();
01832                         $file = $a_target_dir."/table_of_contents.html";
01833                                 
01834                         // open file
01835                         if (!($fp = @fopen($file,"w+")))
01836                         {
01837                                 die ("<b>Error</b>: Could not open \"".$file."\" for writing".
01838                                         " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
01839                         }
01840                         chmod($file, 0770);
01841                         fwrite($fp, $content);
01842                         fclose($fp);
01843                 }
01844                 $ilBench->stop("ExportHTML", "exportHTMLTOC");
01845 
01846                 // export images
01847                 $ilBench->start("ExportHTML", "exportHTMLImages");
01848                 $image_dir = $a_target_dir."/images";
01849                 ilUtil::makeDir($image_dir);
01850                 ilUtil::makeDir($image_dir."/browser");
01851                 copy(ilUtil::getImagePath("enlarge.gif", false, "filesystem"),
01852                         $image_dir."/enlarge.gif");
01853                 copy(ilUtil::getImagePath("browser/blank.gif", false, "filesystem"),
01854                         $image_dir."/browser/plus.gif");
01855                 copy(ilUtil::getImagePath("browser/blank.gif", false, "filesystem"),
01856                         $image_dir."/browser/minus.gif");
01857                 copy(ilUtil::getImagePath("browser/blank.gif", false, "filesystem"),
01858                         $image_dir."/browser/blank.gif");
01859                 copy(ilUtil::getImagePath("icon_st.gif", false, "filesystem"),
01860                         $image_dir."/icon_st.gif");
01861                 copy(ilUtil::getImagePath("icon_pg.gif", false, "filesystem"),
01862                         $image_dir."/icon_pg.gif");
01863                 copy(ilUtil::getImagePath("icon_st_s.gif", false, "filesystem"),
01864                         $image_dir."/icon_st_s.gif");
01865                 copy(ilUtil::getImagePath("icon_pg_s.gif", false, "filesystem"),
01866                         $image_dir."/icon_pg_s.gif");
01867                 copy(ilUtil::getImagePath("icon_lm.gif", false, "filesystem"),
01868                         $image_dir."/icon_lm.gif");
01869                 copy(ilUtil::getImagePath("icon_lm_s.gif", false, "filesystem"),
01870                         $image_dir."/icon_lm_s.gif");
01871                 copy(ilUtil::getImagePath("nav_arr_L.gif", false, "filesystem"),
01872                         $image_dir."/nav_arr_L.gif");
01873                 copy(ilUtil::getImagePath("nav_arr_R.gif", false, "filesystem"),
01874                         $image_dir."/nav_arr_R.gif");
01875                         
01876                 copy(ilUtil::getImagePath("download.gif", false, "filesystem"),
01877                         $image_dir."/download.gif");
01878                 $ilBench->stop("ExportHTML", "exportHTMLImages");
01879                         
01880                 // template workaround: reset of template 
01881                 $tpl = new ilTemplate("tpl.main.html", true, true);
01882                 $tpl->setVariable("LOCATION_STYLESHEET",$location_stylesheet);
01883                 $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
01884 
01885                 // zip everything
01886                 $ilBench->start("ExportHTML", "zip");
01887                 if (true)
01888                 {
01889                         if ($a_zip_file)
01890                         {
01891                                 // zip it all
01892                                 $date = time();
01893                                 $zip_file = $this->getExportDirectory("html")."/".$date."__".IL_INST_ID."__".
01894                                         $this->getType()."_".$this->getId().".zip";
01895                                 ilUtil::zip($a_target_dir, $zip_file);
01896                                 ilUtil::delDir($a_target_dir);
01897                         }
01898                 }
01899                 $ilBench->stop("ExportHTML", "zip");
01900 
01901         }
01902         
01906         function exportHTMLFile($a_target_dir, $a_file_id)
01907         {
01908                 $file_dir = $a_target_dir."/files/file_".$a_file_id;
01909                 ilUtil::makeDir($file_dir);
01910                 include_once("./Modules/File/classes/class.ilObjFile.php");
01911                 $file_obj = new ilObjFile($a_file_id, false);
01912                 $source_file = $file_obj->getDirectory($file_obj->getVersion())."/".$file_obj->getFileName();
01913                 if (!is_file($source_file))
01914                 {
01915                         $source_file = $file_obj->getDirectory()."/".$file_obj->getFileName();
01916                 }
01917                 if (is_file($source_file))
01918                 {
01919                         copy($source_file, $file_dir."/".$file_obj->getFileName());
01920                 }
01921         }
01922 
01926         function exportHTMLMOB($a_target_dir, &$a_lm_gui, $a_mob_id, $a_frame, &$a_linked_mobs)
01927         {
01928                 global $tpl;
01929 
01930                 $mob_dir = $a_target_dir."/mobs";
01931 
01932                 $source_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$a_mob_id;
01933                 if (@is_dir($source_dir))
01934                 {
01935                         ilUtil::makeDir($mob_dir."/mm_".$a_mob_id);
01936                         ilUtil::rCopy($source_dir, $mob_dir."/mm_".$a_mob_id);
01937                 }
01938                 
01939                 $tpl = new ilTemplate("tpl.main.html", true, true);
01940                 $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
01941                 $_GET["obj_type"]  = "MediaObject";
01942                 $_GET["mob_id"]  = $a_mob_id;
01943                 $_GET["frame"] = $a_frame;
01944                 $_GET["cmd"] = "";
01945                 $content =& $a_lm_gui->media();
01946                 $file = $a_target_dir."/media_".$a_mob_id.".html";
01947 
01948                 // open file
01949                 if (!($fp = @fopen($file,"w+")))
01950                 {
01951                         die ("<b>Error</b>: Could not open \"".$file."\" for writing".
01952                                 " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
01953                 }
01954                 chmod($file, 0770);
01955                 fwrite($fp, $content);
01956                 fclose($fp);
01957                 
01958                 // fullscreen
01959                 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
01960                 $mob_obj = new ilObjMediaObject($a_mob_id);
01961                 if ($mob_obj->hasFullscreenItem())
01962                 {
01963                         $tpl = new ilTemplate("tpl.main.html", true, true);
01964                         $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
01965                         $_GET["obj_type"]  = "";
01966                         $_GET["frame"]  = "";
01967                         $_GET["mob_id"]  = $a_mob_id;
01968                         $_GET["cmd"] = "fullscreen";
01969                         $content =& $a_lm_gui->fullscreen();
01970                         $file = $a_target_dir."/fullscreen_".$a_mob_id.".html";
01971         
01972                         // open file
01973                         if (!($fp = @fopen($file,"w+")))
01974                         {
01975                                 die ("<b>Error</b>: Could not open \"".$file."\" for writing".
01976                                         " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
01977                         }
01978                         chmod($file, 0770);
01979                         fwrite($fp, $content);
01980                         fclose($fp);
01981                 }
01982                 $linked_mobs = $mob_obj->getLinkedMediaObjects();
01983                 $a_linked_mobs = array_merge($a_linked_mobs, $linked_mobs);
01984         }
01985         
01989         function exportHTMLGlossaryTerms(&$a_lm_gui, $a_target_dir)
01990         {
01991                 global $ilLocator;
01992                 
01993                 foreach($this->offline_int_links as $int_link)
01994                 {
01995                         $ilLocator->clearItems();
01996                         if ($int_link["type"] == "git")
01997                         {
01998                                 $tpl = new ilTemplate("tpl.main.html", true, true);
01999                                 $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
02000 
02001                                 $_GET["obj_id"] = $int_link["id"];
02002                                 $_GET["frame"] = "_blank";
02003                                 $content =& $a_lm_gui->glossary();
02004                                 $file = $a_target_dir."/term_".$int_link["id"].".html";
02005                                         
02006                                 // open file
02007                                 if (!($fp = @fopen($file,"w+")))
02008                                 {
02009                                         die ("<b>Error</b>: Could not open \"".$file."\" for writing".
02010                                                         " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
02011                                 }
02012                                 chmod($file, 0770);
02013                                 fwrite($fp, $content);
02014                                 fclose($fp);
02015 
02016                                 // store linked/embedded media objects of glosssary term
02017                                 include_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
02018                                 $defs = ilGlossaryDefinition::getDefinitionList($int_link["id"]);
02019                                 foreach($defs as $def)
02020                                 {
02021                                         $def_mobs = ilObjMediaObject::_getMobsOfObject("gdf:pg", $def["id"]);
02022                                         foreach($def_mobs as $def_mob)
02023                                         {
02024                                                 $this->offline_mobs[$def_mob] = $def_mob;
02025                                         }
02026                                         
02027                                         // get all files of page
02028                                         $def_files = ilObjFile::_getFilesOfObject("gdf:pg", $page["obj_id"]);
02029                                         $this->offline_files = array_merge($this->offline_files, $def_files);
02030 
02031                                 }
02032                                 
02033                         }
02034                 }
02035         }
02036         
02040         function exportHTMLPages(&$a_lm_gui, $a_target_dir)
02041         {
02042                 global $tpl, $ilBench, $ilLocator;
02043                                 
02044                 $pages = ilLMPageObject::getPageList($this->getId());
02045                 
02046                 $lm_tree =& $this->getLMTree();
02047                 $first_page = $lm_tree->fetchSuccessorNode($lm_tree->getRootId(), "pg");
02048                 $this->first_page_id = $first_page["child"];
02049 
02050                 // iterate all learning module pages
02051                 $mobs = array();
02052                 $int_links = array();
02053                 $this->offline_files = array();
02054                 
02055                 foreach ($pages as $page)
02056                 {
02057                         $ilLocator->clearItems();
02058                         $ilBench->start("ExportHTML", "exportHTMLPage");
02059                         $ilBench->start("ExportHTML", "exportPageHTML");
02060                         $this->exportPageHTML($a_lm_gui, $a_target_dir, $page["obj_id"]);
02061                         $ilBench->stop("ExportHTML", "exportPageHTML");
02062                         
02063                         // get all media objects of page
02064                         include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
02065                         $pg_mobs = ilObjMediaObject::_getMobsOfObject($this->getType().":pg", $page["obj_id"]);
02066                         foreach($pg_mobs as $pg_mob)
02067                         {
02068                                 $mobs[$pg_mob] = $pg_mob;
02069                         }
02070                         
02071                         // get all internal links of page
02072                         $pg_links = ilInternalLink::_getTargetsOfSource($this->getType().":pg", $page["obj_id"]);
02073                         $int_links = array_merge($int_links, $pg_links);
02074                         
02075                         // get all files of page
02076                         include_once("./Modules/File/classes/class.ilObjFile.php");
02077                         $pg_files = ilObjFile::_getFilesOfObject($this->getType().":pg", $page["obj_id"]);
02078                         $this->offline_files = array_merge($this->offline_files, $pg_files);
02079                         
02080                         $ilBench->stop("ExportHTML", "exportHTMLPage");
02081                 }
02082                 $this->offline_mobs = $mobs;
02083                 $this->offline_int_links = $int_links;
02084                 
02085                 
02086         }
02087 
02091         function exportPageHTML(&$a_lm_gui, $a_target_dir, $a_lm_page_id, $a_frame = "")
02092         {
02093                 global $ilias, $tpl, $ilBench;
02094                 
02095 //echo "<br>B: export Page HTML ($a_lm_page_id)"; flush();
02096                 // template workaround: reset of template 
02097                 $tpl = new ilTemplate("tpl.main.html", true, true);
02098                 $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
02099 
02100                 $_GET["obj_id"] = $a_lm_page_id;
02101                 $_GET["frame"] = $a_frame;
02102 
02103                 if ($a_frame == "")
02104                 {
02105                         if ($nid = ilLMObject::_lookupNID($a_lm_gui->lm->getId(), $a_lm_page_id, "pg"))
02106                         {
02107                                 $file = $a_target_dir."/lm_pg_".$nid.".html";
02108                         }
02109                         else
02110                         {
02111                                 $file = $a_target_dir."/lm_pg_".$a_lm_page_id.".html";
02112                         }
02113                 }
02114                 else
02115                 {
02116                         if ($a_frame != "toc")
02117                         {
02118                                 $file = $a_target_dir."/frame_".$a_lm_page_id."_".$a_frame.".html";
02119                         }
02120                         else
02121                         {
02122                                 $file = $a_target_dir."/frame_".$a_frame.".html";
02123                         }
02124                 }
02125                 
02126                 // return if file is already existing
02127                 if (@is_file($file))
02128                 {
02129                         return;
02130                 }
02131 
02132                 $ilBench->start("ExportHTML", "layout");
02133                 $ilBench->start("ExportHTML", "layout_".$a_frame);
02134                 $content =& $a_lm_gui->layout("main.xml", false);
02135                 $ilBench->stop("ExportHTML", "layout_".$a_frame);
02136                 $ilBench->stop("ExportHTML", "layout");
02137 
02138                 // open file
02139                 if (!($fp = @fopen($file,"w+")))
02140                 {
02141                         die ("<b>Error</b>: Could not open \"".$file."\" for writing".
02142                                         " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
02143                 }
02144         
02145                 // set file permissions
02146                 chmod($file, 0770);
02147                         
02148                 // write xml data into the file
02149                 fwrite($fp, $content);
02150                 
02151                 // close file
02152                 fclose($fp);
02153 
02154                 if ($this->first_page_id == $a_lm_page_id && $a_frame == "")
02155                 {
02156                         copy($file, $a_target_dir."/index.html");
02157                 }
02158 
02159                 // write frames of frameset
02160                 $ilBench->start("ExportHTML", "getCurrentFrameSet");
02161                 $frameset = $a_lm_gui->getCurrentFrameSet();
02162                 $ilBench->stop("ExportHTML", "getCurrentFrameSet");
02163                 
02164                 foreach ($frameset as $frame)
02165                 {                               
02166                         $this->exportPageHTML($a_lm_gui, $a_target_dir, $a_lm_page_id, $frame);
02167                 }
02168 
02169         }
02170 
02177         function exportFO(&$a_xml_writer, $a_target_dir)
02178         {
02179                 global $ilBench;
02180 
02181                 // fo:root (start)
02182                 $attrs = array();
02183                 $attrs["xmlns:fo"] = "http://www.w3.org/1999/XSL/Format";
02184                 $a_xml_writer->xmlStartTag("fo:root", $attrs);
02185 
02186                 // fo:layout-master-set (start)
02187                 $attrs = array();
02188                 $a_xml_writer->xmlStartTag("fo:layout-master-set", $attrs);
02189 
02190                 // fo:simple-page-master (start)
02191                 $attrs = array();
02192                 $attrs["master-name"] = "DinA4";
02193                 $attrs["page-height"] = "29.7cm";
02194                 $attrs["page-width"] = "21cm";
02195                 $attrs["margin-top"] = "4cm";
02196                 $attrs["margin-bottom"] = "1cm";
02197                 $attrs["margin-left"] = "2.8cm";
02198                 $attrs["margin-right"] = "7.3cm";
02199                 $a_xml_writer->xmlStartTag("fo:simple-page-master", $attrs);
02200 
02201                 // fo:region-body (complete)
02202                 $attrs = array();
02203                 $attrs["margin-top"] = "0cm";
02204                 $attrs["margin-bottom"] = "1.25cm";
02205                 $a_xml_writer->xmlElement("fo:region-body", $attrs);
02206 
02207                 // fo:region-before (complete)
02208                 $attrs = array();
02209                 $attrs["extent"] = "1cm";
02210                 $a_xml_writer->xmlElement("fo:region-before", $attrs);
02211 
02212                 // fo:region-after (complete)
02213                 $attrs = array();
02214                 $attrs["extent"] = "1cm";
02215                 $a_xml_writer->xmlElement("fo:region-after", $attrs);
02216 
02217                 // fo:simple-page-master (end)
02218                 $a_xml_writer->xmlEndTag("fo:simple-page-master");
02219 
02220                 // fo:layout-master-set (end)
02221                 $a_xml_writer->xmlEndTag("fo:layout-master-set");
02222 
02223                 // fo:page-sequence (start)
02224                 $attrs = array();
02225                 $attrs["master-reference"] = "DinA4";
02226                 $a_xml_writer->xmlStartTag("fo:page-sequence", $attrs);
02227 
02228                 // fo:flow (start)
02229                 $attrs = array();
02230                 $attrs["flow-name"] = "xsl-region-body";
02231                 $a_xml_writer->xmlStartTag("fo:flow", $attrs);
02232 
02233 
02234                 // StructureObjects
02235                 //$expLog->write(date("[y-m-d H:i:s] ")."Start Export Structure Objects");
02236                 $ilBench->start("ContentObjectExport", "exportFOStructureObjects");
02237                 $this->exportFOStructureObjects($a_xml_writer, $expLog);
02238                 $ilBench->stop("ContentObjectExport", "exportFOStructureObjects");
02239                 //$expLog->write(date("[y-m-d H:i:s] ")."Finished Export Structure Objects");*/
02240 
02241                 // fo:flow (end)
02242                 $a_xml_writer->xmlEndTag("fo:flow");
02243 
02244                 // fo:page-sequence (end)
02245                 $a_xml_writer->xmlEndTag("fo:page-sequence");
02246 
02247                 // fo:root (end)
02248                 $a_xml_writer->xmlEndTag("fo:root");
02249         }
02250 
02257         function exportFOStructureObjects(&$a_xml_writer)
02258         {
02259                 $childs = $this->lm_tree->getChilds($this->lm_tree->getRootId());
02260                 foreach ($childs as $child)
02261                 {
02262                         if($child["type"] != "st")
02263                         {
02264                                 continue;
02265                         }
02266 
02267                         $structure_obj = new ilStructureObject($this, $child["obj_id"]);
02268                         $structure_obj->exportFO($a_xml_writer, $expLog);
02269                         unset($structure_obj);
02270                 }
02271         }
02272 
02273         function getXMLZip()
02274         {
02275                 include_once("./Modules/LearningModule/classes/class.ilContObjectExport.php");
02276 
02277                 $cont_exp = new ilContObjectExport($this,'xml');
02278 
02279                 $export_file = $cont_exp->buildExportFile();
02280                 return $export_file;
02281         }               
02282 
02283 
02284 }
02285 ?>

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