00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 require_once("content/classes/class.ilLMObject.php");
00025 require_once("content/classes/Pages/class.ilPageObject.php");
00026
00027 define ("IL_CHAPTER_TITLE", "st_title");
00028 define ("IL_PAGE_TITLE", "pg_title");
00029 define ("IL_NO_HEADER", "none");
00030
00048 class ilLMPageObject extends ilLMObject
00049 {
00050 var $is_alias;
00051 var $origin_id;
00052 var $id;
00053 var $ilias;
00054 var $dom;
00055 var $page_object;
00056
00061 function ilLMPageObject(&$a_content_obj, $a_id = 0, $a_halt = true)
00062 {
00063 global $ilias, $ilBench;
00064
00065 $ilBench->start("ContentPresentation", "ilLMPageObject_Constructor");
00066
00067 parent::ilLMObject($a_content_obj, $a_id);
00068 $this->setType("pg");
00069 $this->id = $a_id;
00070 $this->ilias =& $ilias;
00071
00072 $this->is_alias = false;
00073 $this->contains_int_link = false;
00074 $this->mobs_contained = array();
00075 $this->files_contained = array();
00076 $this->halt_on_error = $a_halt;
00077
00078 if($a_id != 0)
00079 {
00080 $this->read();
00081 }
00082
00083 $ilBench->stop("ContentPresentation", "ilLMPageObject_Constructor");
00084 }
00085
00086 function _ilLMPageObject()
00087 {
00088 if(is_object($this->page_object))
00089 {
00090 unset($this->page_object);
00091 }
00092 }
00093
00097 function read()
00098 {
00099 global $ilBench;
00100
00101 $ilBench->start("ContentPresentation", "ilLMPageObject_read");
00102 parent::read();
00103
00104 $this->page_object =& new ilPageObject($this->content_object->getType(),
00105 $this->id, $this->halt_on_error);
00106
00107 $ilBench->stop("ContentPresentation", "ilLMPageObject_read");
00108 }
00109
00110 function create($a_upload = false)
00111 {
00112 parent::create($a_upload);
00113 if(!is_object($this->page_object))
00114 {
00115 $this->page_object =& new ilPageObject($this->content_object->getType());
00116 }
00117 $this->page_object->setId($this->getId());
00118 $this->page_object->setParentId($this->getLMId());
00119 $this->page_object->create($a_upload);
00120 }
00121
00122 function delete($a_delete_meta_data = true)
00123 {
00124 parent::delete($a_delete_meta_data);
00125 $this->page_object->delete();
00126 }
00127
00128
00132 function ©()
00133 {
00134
00135
00136 $lm_page =& new ilLMPageObject($this->getContentObject());
00137 $lm_page->setTitle($this->getTitle());
00138 $lm_page->setLMId($this->getLMId());
00139 $lm_page->setType($this->getType());
00140 $lm_page->setDescription($this->getDescription());
00141 $lm_page->create(true);
00142
00143
00144 include_once("Services/MetaData/classes/class.ilMD.php");
00145 $md = new ilMD($this->getLMId(), $this->getId(), $this->getType());
00146 $new_md =& $md->cloneMD($this->getLMId(), $lm_page->getId(), $this->getType());
00147
00148
00149 $page =& $lm_page->getPageObject();
00150 $page->setXMLContent($this->page_object->getXMLContent());
00151 $page->buildDom();
00152 $page->update();
00153
00154 return $lm_page;
00155 }
00156
00160 function ©ToOtherContObject(&$a_cont_obj)
00161 {
00162
00163 $lm_page =& new ilLMPageObject($a_cont_obj);
00164 $lm_page->setTitle($this->getTitle());
00165 $lm_page->setLMId($a_cont_obj->getId());
00166 $lm_page->setType($this->getType());
00167 $lm_page->setDescription($this->getDescription());
00168 $lm_page->create(true);
00169
00170
00171 include_once("Services/MetaData/classes/class.ilMD.php");
00172 $md = new ilMD($this->getLMId(), $this->getId(), $this->getType());
00173 $new_md =& $md->cloneMD($a_cont_obj->getId(), $lm_page->getId(), $this->getType());
00174
00175
00176 $page =& $lm_page->getPageObject();
00177 $page->setXMLContent($this->page_object->getXMLContent());
00178 $page->buildDom();
00179 $page->update();
00180
00181 return $lm_page;
00182 }
00183
00191 function _splitPage($a_page_id, $a_pg_parent_type, $a_hier_id)
00192 {
00193
00194 $lm_id = ilLMObject::_lookupContObjID($a_page_id);
00195 $type = ilObject::_lookupType($lm_id, false);
00196 switch ($type)
00197 {
00198 case "lm":
00199 include_once ("content/classes/class.ilObjLearningModule.php");
00200 $cont_obj = new ilObjLearningModule($lm_id, false);
00201 break;
00202
00203 case "dbk":
00204 include_once ("content/classes/class.ilObjDlBook.php");
00205 $cont_obj = new ilObjDlBook($lm_id, false);
00206 break;
00207 }
00208
00209 $source_lm_page =& new ilLMPageObject($cont_obj, $a_page_id);
00210
00211
00212 $lm_page =& new ilLMPageObject($cont_obj);
00213 $lm_page->setTitle($source_lm_page->getTitle());
00214 $lm_page->setLMId($source_lm_page->getLMId());
00215 $lm_page->setType($source_lm_page->getType());
00216 $lm_page->setDescription($source_lm_page->getDescription());
00217 $lm_page->create(true);
00218
00219
00220 include_once("Services/MetaData/classes/class.ilMD.php");
00221 $md = new ilMD($source_lm_page->getLMId(), $a_page_id, $source_lm_page->getType());
00222 $new_md =& $md->cloneMD($source_lm_page->getLMId(), $lm_page->getId(), $source_lm_page->getType());
00223
00224
00225 $source_page =& $source_lm_page->getPageObject();
00226 $page =& $lm_page->getPageObject();
00227 $page->setXMLContent($source_page->getXMLContent());
00228 $page->buildDom();
00229
00230
00231 $tree = new ilTree($cont_obj->getId());
00232 $tree->setTableNames('lm_tree','lm_data');
00233 $tree->setTreeTablePK("lm_id");
00234 if ($tree->isInTree($source_lm_page->getId()))
00235 {
00236 $parent_node = $tree->getParentNodeData($source_lm_page->getId());
00237 $tree->insertNode($lm_page->getId(), $parent_node["child"], $source_lm_page->getId());
00238 }
00239
00240
00241 $source_page->buildDom();
00242 $source_page->addHierIds();
00243 $source_page->deleteContentFromHierId($a_hier_id);
00244
00245
00246 $page->addHierIds();
00247 $page->deleteContentBeforeHierId($a_hier_id);
00248
00249 return $lm_page;
00250
00251 }
00252
00260 function _splitPageNext($a_page_id, $a_pg_parent_type, $a_hier_id)
00261 {
00262
00263 $lm_id = ilLMObject::_lookupContObjID($a_page_id);
00264 $type = ilObject::_lookupType($lm_id, false);
00265 switch ($type)
00266 {
00267 case "lm":
00268 include_once ("content/classes/class.ilObjLearningModule.php");
00269 $cont_obj = new ilObjLearningModule($lm_id, false);
00270 break;
00271
00272 case "dbk":
00273 include_once ("content/classes/class.ilObjDlBook.php");
00274 $cont_obj = new ilObjDlBook($lm_id, false);
00275 break;
00276 }
00277 $tree = new ilTree($cont_obj->getId());
00278 $tree->setTableNames('lm_tree','lm_data');
00279 $tree->setTreeTablePK("lm_id");
00280
00281 $source_lm_page =& new ilLMPageObject($cont_obj, $a_page_id);
00282 $source_page =& $source_lm_page->getPageObject();
00283
00284
00285 $succ = $tree->fetchSuccessorNode($a_page_id, "pg");
00286 if ($succ["child"] > 0)
00287 {
00288 $target_lm_page =& new ilLMPageObject($cont_obj, $succ["child"]);
00289 $target_page =& $target_lm_page->getPageObject();
00290 $target_page->buildDom();
00291 $target_page->addHierIds();
00292
00293
00294 $source_page->buildDom();
00295 $source_page->addHierIds();
00296 ilPageObject::_moveContentAfterHierId($source_page, $target_page, $a_hier_id);
00297
00298
00299 return $succ["child"];
00300 }
00301
00302 }
00303
00304
00310 function assignPageObject(&$a_page_obj)
00311 {
00312 $this->page_object =& $a_page_obj;
00313 }
00314
00315
00321 function &getPageObject()
00322 {
00323 return $this->page_object;
00324 }
00325
00326
00330 function setId($a_id)
00331 {
00332 $this->id = $a_id;
00333 }
00334
00335 function getId()
00336 {
00337 return $this->id;
00338 }
00339
00343 function setAlias($a_is_alias)
00344 {
00345 $this->is_alias = $a_is_alias;
00346 }
00347
00348 function isAlias()
00349 {
00350 return $this->is_alias;
00351 }
00352
00353
00354 function setOriginID($a_id)
00355 {
00356 return $this->origin_id = $a_id;
00357 }
00358
00359
00360 function getOriginID()
00361 {
00362 return $this->origin_id;
00363 }
00364
00368 function getPageList($lm_id)
00369 {
00370 return ilLMObject::getObjectList($lm_id, "pg");
00371 }
00372
00373
00380 function _getPresentationTitle($a_pg_id, $a_mode = IL_CHAPTER_TITLE,
00381 $a_include_numbers = false)
00382 {
00383 global $ilDB;
00384
00385
00386 $query = "SELECT * FROM lm_data WHERE obj_id = '".$a_pg_id."'";
00387 $pg_set = $ilDB->query($query);
00388 $pg_rec = $pg_set->fetchRow(DB_FETCHMODE_ASSOC);
00389
00390 if($a_mode == IL_NO_HEADER)
00391 {
00392 return "";
00393 }
00394
00395 $tree = new ilTree($pg_rec["lm_id"]);
00396 $tree->setTableNames('lm_tree','lm_data');
00397 $tree->setTreeTablePK("lm_id");
00398
00399 if($a_mode == IL_PAGE_TITLE)
00400 {
00401 $nr = "";
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435 return $nr.$pg_rec["title"];
00436 }
00437
00438 if ($tree->isInTree($pg_rec["obj_id"]))
00439 {
00440 $pred_node = $tree->fetchPredecessorNode($pg_rec["obj_id"], "st");
00441 $childs = $tree->getChildsByType($pred_node["obj_id"], "pg");
00442 $cnt_str = "";
00443 if(count($childs) > 1)
00444 {
00445 $cur_cnt = 0;
00446 foreach($childs as $child)
00447 {
00448 $cur_cnt++;
00449 if($child["obj_id"] == $pg_rec["obj_id"])
00450 {
00451 break;
00452 }
00453 }
00454 $cnt_str = " (".$cur_cnt."/".count($childs).")";
00455 }
00456
00457
00458
00459
00460 return $pred_node["title"].$cnt_str;
00461 }
00462 else
00463 {
00464 return $pg_rec["title"];
00465 }
00466 }
00467
00474 function exportXML(&$a_xml_writer, $a_mode = "normal", $a_inst = 0)
00475 {
00476 global $ilBench;
00477
00478 $attrs = array();
00479 $a_xml_writer->xmlStartTag("PageObject", $attrs);
00480
00481 switch ($a_mode)
00482 {
00483 case "normal":
00484
00485 $ilBench->start("ContentObjectExport", "exportPageObject_XML_Meta");
00486 $this->exportXMLMetaData($a_xml_writer);
00487 $ilBench->stop("ContentObjectExport", "exportPageObject_XML_Meta");
00488
00489
00490 $ilBench->start("ContentObjectExport", "exportPageObject_XML_PageContent");
00491 $this->exportXMLPageContent($a_xml_writer, $a_inst);
00492 $ilBench->stop("ContentObjectExport", "exportPageObject_XML_PageContent");
00493 break;
00494
00495 case "alias":
00496 $attrs = array();
00497 $attrs["OriginId"] = "il_".$a_inst.
00498 "_pg_".$this->getId();
00499 $a_xml_writer->xmlElement("PageAlias", $attrs);
00500 break;
00501 }
00502
00503
00504
00505
00506 $a_xml_writer->xmlEndTag("PageObject");
00507 }
00508
00512 function _exportXMLAlias(&$a_xml_writer, $a_id, $a_inst = 0)
00513 {
00514 $attrs = array();
00515 $a_xml_writer->xmlStartTag("PageObject", $attrs);
00516
00517 $attrs = array();
00518 $attrs["OriginId"] = "il_".$a_inst.
00519 "_pg_".$a_id;
00520 $a_xml_writer->xmlElement("PageAlias", $attrs);
00521
00522 $a_xml_writer->xmlEndTag("PageObject");
00523 }
00524
00525
00532 function exportXMLMetaData(&$a_xml_writer)
00533 {
00534 include_once("Services/MetaData/classes/class.ilMD2XML.php");
00535 $md2xml = new ilMD2XML($this->getLMId(), $this->getId(), $this->getType());
00536 $md2xml->setExportMode(true);
00537 $md2xml->startExport();
00538 $a_xml_writer->appendXML($md2xml->getXML());
00539 }
00540
00541 function modifyExportIdentifier($a_tag, $a_param, $a_value)
00542 {
00543 if ($a_tag == "Identifier" && $a_param == "Entry")
00544 {
00545 $a_value = "il_".IL_INST_ID."_pg_".$this->getId();
00546
00547 }
00548
00549 return $a_value;
00550 }
00551
00552
00559 function exportXMLPageContent(&$a_xml_writer, $a_inst = 0)
00560 {
00561
00562 $cont_obj =& $this->getContentObject();
00563
00564
00565 $this->page_object->buildDom();
00566 $this->page_object->insertInstIntoIDs($a_inst);
00567 $this->mobs_contained = $this->page_object->collectMediaObjects(false);
00568 $this->files_contained = $this->page_object->collectFileItems();
00569 $xml = $this->page_object->getXMLFromDom(false, false, false, "", true);
00570 $xml = str_replace("&","&", $xml);
00571 $a_xml_writer->appendXML($xml);
00572
00573 $this->page_object->freeDom();
00574 }
00575
00581 function getMediaObjectIds()
00582 {
00583 return $this->mobs_contained;
00584 }
00585
00591 function getFileItemIds()
00592 {
00593 return $this->files_contained;
00594 }
00595
00602 function exportFO(&$a_xml_writer)
00603 {
00604 global $ilBench;
00605
00606
00607
00608 $title = ilLMPageObject::_getPresentationTitle($this->getId());
00609 if ($title != "")
00610 {
00611 $attrs = array();
00612 $attrs["font-family"] = "Times";
00613 $attrs["font-size"] = "14pt";
00614 $a_xml_writer->xmlElement("fo:block", $attrs, $title);
00615 }
00616
00617
00618 $this->page_object->buildDom();
00619 $fo = $this->page_object->getFO();
00620 $a_xml_writer->appendXML($fo);
00621
00622
00623 }
00624
00625
00631 function _goto($a_target)
00632 {
00633 global $rbacsystem, $ilErr, $lng;
00634
00635
00636 $lm_id = ilLMObject::_lookupContObjID($a_target);
00637
00638
00639 $ref_ids = ilObject::_getAllReferences($lm_id);
00640
00641
00642 foreach ($ref_ids as $ref_id)
00643 {
00644 include_once 'classes/class.ilSearch.php';
00645
00646
00647
00648 if ($rbacsystem->checkAccess("read", $ref_id) and ilSearch::_checkParentConditions($ref_id))
00649 {
00650 ilUtil::redirect("content/lm_presentation.php?ref_id=$ref_id".
00651 "&obj_id=$a_target");
00652 }
00653 $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
00654 }
00655 }
00656 }
00657 ?>