ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ilLMObject Class Reference

Class ilLMObject. More...

+ Inheritance diagram for ilLMObject:
+ Collaboration diagram for ilLMObject:

Public Member Functions

 __construct (ilObjLearningModule $a_content_obj, int $a_id=0)
 
 MDUpdateListener (string $a_element)
 Meta data update listener Important note: Do never call create() or update() method of ilObject here. More...
 
 createMetaData ()
 create meta data entry More...
 
 updateMetaData ()
 update meta data entry More...
 
 deleteMetaData ()
 delete meta data entry More...
 
 setDataRecord (array $a_record)
 this method should only be called by class ilLMObjectFactory More...
 
 read ()
 
 setTitle (string $a_title)
 
 getTitle ()
 
 setShortTitle (string $a_title)
 
 getShortTitle ()
 
 setDescription (string $a_description)
 
 getDescription ()
 
 setType (string $a_type)
 
 getType ()
 
 setLMId (int $a_lm_id)
 
 getLMId ()
 
 setContentObject (ilObjLearningModule $a_content_obj)
 
 getContentObject ()
 
 setId (int $a_id)
 
 getId ()
 
 getImportId ()
 
 setImportId (string $a_id)
 
 setLayout (string $a_val)
 
 getLayout ()
 
 create (bool $a_upload=false)
 
 update ()
 
 delete (bool $a_delete_meta_data=true)
 
 existsExportID (int $a_lm_id, int $a_exp_id, string $a_type="pg")
 Does export ID exist in lm? More...
 

Static Public Member Functions

static preloadDataByLM (int $a_lm_id)
 Preload data records by lm. More...
 
static _lookupTitle (int $a_obj_id)
 
static _lookupShortTitle (int $a_obj_id)
 
static _lookupType (int $a_obj_id, int $a_lm_id=0)
 
static _writeTitle (int $a_obj_id, string $a_title)
 
static _writeImportId (int $a_id, string $a_import_id)
 
static _getIdForImportId (string $a_import_id)
 get current object id for import id (static) More...
 
static _getAllObjectsForImportId (string $a_import_id, int $a_in_lm=0)
 Get all items for an import ID. More...
 
static _exists (int $a_id)
 checks wether a lm content object with specified id exists or not More...
 
static getObjectList (int $lm_id, string $type="")
 
static _deleteAllObjectData (ilObjLearningModule $a_cobj)
 delete all objects of content object (digi book / learning module) More...
 
static _lookupContObjID (int $a_id)
 get learning module id for lm object More...
 
static putInTree (ilLMObject $a_obj, int $a_parent_id=0, int $a_target_node_id=0)
 put this object into content object tree More...
 
static getTree (int $a_cont_obj_id)
 Get learning module tree. More...
 
static clipboardCut (int $a_cont_obj_id, array $a_ids)
 Copy a set of chapters/pages into the clipboard. More...
 
static clipboardCopy (int $a_cont_obj_id, array $a_ids)
 Copy a set of chapters/pages into the clipboard. More...
 
static saveTitles (ilObjLearningModule $a_lm, array $a_titles, string $a_lang="-")
 Save titles for lm objects. More...
 
static saveTitle (int $id, string $title, string $lang="-")
 
static updateInternalLinks (array $a_copied_nodes, string $a_parent_type="lm")
 Update internal links, after multiple pages have been copied. More...
 
static uniqueTypesCheck (array $a_items)
 Check for unique types (all pages or all chapters) More...
 
static writeLayout (int $a_obj_id, string $a_layout, ?ilObjLearningModule $a_lm=null)
 Write layout setting. More...
 
static lookupLayout (int $a_obj_id)
 Lookup type. More...
 
static getPagesOfChapter (int $a_lm_id, int $a_chap_id)
 Get pages of chapter. More...
 
static _getAllLMObjectsOfLM (int $a_lm_id, string $a_type="")
 Get all objects of learning module. More...
 
static saveExportId (int $a_lm_id, int $a_lmobj_id, string $a_exp_id, string $a_type="pg")
 
static getExportId (int $a_lm_id, int $a_lmobj_id, string $a_type="pg")
 
static getDuplicateExportIDs (int $a_lm_id, string $a_type="pg")
 Get duplicate export IDs (count export ID usages) More...
 
static _getNodePresentationTitle (array $a_node, string $a_mode=self::PAGE_TITLE, bool $a_include_numbers=false, bool $a_time_scheduled_activation=false, bool $a_force_content=false, int $a_lm_id=0, string $a_lang="-")
 
static getShortTitles (int $a_lm_id, string $a_lang="-")
 
static writeShortTitle (int $a_id, string $a_short_title, string $a_lang="-")
 

Data Fields

const CHAPTER_TITLE = "st_title"
 
const PAGE_TITLE = "pg_title"
 
const NO_HEADER = "none"
 
int $lm_id = 0
 
string $type = ""
 
int $id = 0
 
array $data_record
 
ilObjLearningModule $content_object
 
string $title = ""
 
string $short_title = ""
 
string $description = ""
 
bool $active = true
 

Static Protected Member Functions

static _lookup (int $a_obj_id, string $a_field)
 
static getPathToExportIDInLOM ()
 

Protected Attributes

string $layout = ""
 
string $import_id = ""
 
ilObjUser $user
 
ilDBInterface $db
 
LOMServices $lom_services
 

Static Protected Attributes

static array $data_records = []
 

Detailed Description

Class ilLMObject.

Base class for ilStructureObjects and ilPageObjects (see ILIAS DTD)

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 32 of file class.ilLMObject.php.

Constructor & Destructor Documentation

◆ __construct()

ilLMObject::__construct ( ilObjLearningModule  $a_content_obj,
int  $a_id = 0 
)

Reimplemented in ilStructureObject.

Definition at line 54 of file class.ilLMObject.php.

57 {
58 global $DIC;
59 $this->user = $DIC->user();
60
61 $this->db = $DIC->database();
62 $this->lom_services = $DIC->learningObjectMetadata();
63
64 $this->id = $a_id;
65 $this->setContentObject($a_content_obj);
66 $this->setLMId($a_content_obj->getId());
67 if ($a_id != 0) {
68 $this->read();
69 }
70 }
setContentObject(ilObjLearningModule $a_content_obj)
setLMId(int $a_lm_id)
global $DIC
Definition: shib_login.php:26

References $DIC, ilObject\getId(), read(), setContentObject(), setLMId(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ _deleteAllObjectData()

static ilLMObject::_deleteAllObjectData ( ilObjLearningModule  $a_cobj)
static

delete all objects of content object (digi book / learning module)

Definition at line 542 of file class.ilLMObject.php.

544 : void {
545 global $DIC;
546
547 $ilDB = $DIC->database();
548
549 $query = "SELECT * FROM lm_data " .
550 "WHERE lm_id= " . $ilDB->quote($a_cobj->getId(), "integer");
551 $obj_set = $ilDB->query($query);
552
553 while ($obj_rec = $ilDB->fetchAssoc($obj_set)) {
554 $lm_obj = ilLMObjectFactory::getInstance($a_cobj, $obj_rec["obj_id"], false);
555
556 if (is_object($lm_obj)) {
557 $lm_obj->delete(true);
558 }
559 }
560 }
static getInstance(ilObjLearningModule $a_content_obj, int $a_id=0, bool $a_halt=true)

References ilLMObjectFactory\getInstance().

+ Here is the call graph for this function:

◆ _exists()

static ilLMObject::_exists ( int  $a_id)
static

checks wether a lm content object with specified id exists or not

Definition at line 491 of file class.ilLMObject.php.

491 : bool
492 {
493 global $DIC;
494
495 $ilDB = $DIC->database();
496
497 if (is_int(strpos($a_id, "_"))) {
499 }
500
501 $q = "SELECT * FROM lm_data WHERE obj_id = " .
502 $ilDB->quote($a_id, "integer");
503 $obj_set = $ilDB->query($q);
504 if ($obj_rec = $ilDB->fetchAssoc($obj_set)) {
505 return true;
506 } else {
507 return false;
508 }
509 }
$q
Definition: shib_logout.php:25

References $DIC, $ilDB, $q, and ilInternalLink\_extractObjIdOfTarget().

Referenced by ilCourseObjectiveMaterials\__read(), ilInternalLink\_exists(), ilLinksTableGUI\fillRow(), ilHelpGUI\showHelp(), and ilLMPresentationGUI\showPrintView().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getAllLMObjectsOfLM()

static ilLMObject::_getAllLMObjectsOfLM ( int  $a_lm_id,
string  $a_type = "" 
)
static

Get all objects of learning module.

Definition at line 1129 of file class.ilLMObject.php.

1132 : array {
1133 global $DIC;
1134
1135 $ilDB = $DIC->database();
1136
1137 $and = ($a_type != "")
1138 ? " AND type = " . $ilDB->quote($a_type, "text")
1139 : "";
1140
1141 $set = $ilDB->query("SELECT obj_id FROM lm_data " .
1142 " WHERE lm_id = " . $ilDB->quote($a_lm_id, "integer") . $and);
1143 $obj_ids = array();
1144 while ($rec = $ilDB->fetchAssoc($set)) {
1145 $obj_ids[] = $rec["obj_id"];
1146 }
1147
1148 return $obj_ids;
1149 }

Referenced by ilLMTracker\loadLMTrackingData().

+ Here is the caller graph for this function:

◆ _getAllObjectsForImportId()

static ilLMObject::_getAllObjectsForImportId ( string  $a_import_id,
int  $a_in_lm = 0 
)
static

Get all items for an import ID.

(only for items notnot in trash)

Definition at line 459 of file class.ilLMObject.php.

462 : array {
463 global $DIC;
464
465 $ilDB = $DIC->database();
466
467 $where = ($a_in_lm > 0)
468 ? " AND lm_id = " . $ilDB->quote($a_in_lm, "integer") . " "
469 : "";
470
471 $q = "SELECT * FROM lm_data WHERE import_id = " .
472 $ilDB->quote($a_import_id, "text") . " " .
473 $where .
474 " ORDER BY create_date DESC";
475 $obj_set = $ilDB->query($q);
476
477 $items = array();
478 while ($obj_rec = $ilDB->fetchAssoc($obj_set)) {
479 // check, whether lm is not trashed
480 if (ilObject::_hasUntrashedReference($obj_rec["lm_id"])) {
481 $items[] = $obj_rec;
482 }
483 }
484
485 return $items;
486 }
static _hasUntrashedReference(int $obj_id)
checks whether an object has at least one reference that is not in trash

Referenced by updateInternalLinks().

+ Here is the caller graph for this function:

◆ _getIdForImportId()

static ilLMObject::_getIdForImportId ( string  $a_import_id)
static

get current object id for import id (static)

import ids can exist multiple times (if the same learning module has been imported multiple times). we get the object id of the last imported object, that is not in trash

Definition at line 429 of file class.ilLMObject.php.

429 : int
430 {
431 global $DIC;
432
433 $ilDB = $DIC->database();
434 $help_module = $DIC->help()->internal()->domain()->module();
435
436 $q = "SELECT obj_id FROM lm_data WHERE import_id = " .
437 $ilDB->quote($a_import_id, "text") . " " .
438 " ORDER BY create_date DESC";
439 $obj_set = $ilDB->query($q);
440 while ($obj_rec = $ilDB->fetchAssoc($obj_set)) {
441 $lm_id = ilLMObject::_lookupContObjID($obj_rec["obj_id"]);
442
443 // link only in learning module, that is not trashed
444 $ref_ids = ilObject::_getAllReferences($lm_id); // will be 0 if import of lm is in progress (new import)
445 if (count($ref_ids) == 0 || ilObject::_hasUntrashedReference($lm_id) ||
446 $help_module->isHelpLM($lm_id)) {
447 return $obj_rec["obj_id"];
448 }
449 }
450
451 return 0;
452 }
static _lookupContObjID(int $a_id)
get learning module id for lm object
static _getAllReferences(int $id)
get all reference ids for object ID

References $DIC, $ilDB, $lm_id, $q, ilObject\_getAllReferences(), ilObject\_hasUntrashedReference(), and _lookupContObjID().

Referenced by ilInternalLink\_getIdForImportId(), SurveyQuestion\_resolveInternalLink(), and assQuestion\resolveInternalLink().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getNodePresentationTitle()

static ilLMObject::_getNodePresentationTitle ( array  $a_node,
string  $a_mode = self::PAGE_TITLE,
bool  $a_include_numbers = false,
bool  $a_time_scheduled_activation = false,
bool  $a_force_content = false,
int  $a_lm_id = 0,
string  $a_lang = "-" 
)
static

Definition at line 1276 of file class.ilLMObject.php.

1284 : string {
1285 if ($a_lang == "") {
1286 $a_lang = "-";
1287 }
1288
1289 if ($a_node["type"] == "st") {
1291 $a_node["child"],
1292 self::CHAPTER_TITLE,
1293 $a_include_numbers,
1294 $a_time_scheduled_activation,
1295 $a_force_content,
1296 $a_lm_id,
1297 $a_lang
1298 );
1299 } else {
1301 $a_node["child"],
1302 $a_mode,
1303 $a_include_numbers,
1304 $a_time_scheduled_activation,
1305 $a_force_content,
1306 $a_lm_id,
1307 $a_lang
1308 );
1309 }
1310 }
static _getPresentationTitle(int $a_pg_id, string $a_mode=self::CHAPTER_TITLE, bool $a_include_numbers=false, bool $a_time_scheduled_activation=false, bool $a_force_content=false, int $a_lm_id=0, string $a_lang="-", bool $a_include_short=false)
presentation title doesn't have to be page title, it may be chapter title + page title or chapter tit...
static _getPresentationTitle(int $a_st_id, string $a_mode=self::CHAPTER_TITLE, bool $a_include_numbers=false, bool $a_time_scheduled_activation=false, bool $a_force_content=false, int $a_lm_id=0, string $a_lang="-", bool $a_include_short=false)

Referenced by ilLMExplorerGUI\getNodeContent().

+ Here is the caller graph for this function:

◆ _lookup()

static ilLMObject::_lookup ( int  $a_obj_id,
string  $a_field 
)
staticprotected

Definition at line 219 of file class.ilLMObject.php.

219 : string
220 {
221 global $DIC;
222
223 $ilDB = $DIC->database();
224
225 if (isset(self::$data_records[$a_obj_id])) {
226 return self::$data_records[$a_obj_id][$a_field] ?? "";
227 }
228
229 $query = "SELECT " . $a_field . " FROM lm_data WHERE obj_id = " .
230 $ilDB->quote($a_obj_id, "integer");
231 $obj_set = $ilDB->query($query);
232 $obj_rec = $ilDB->fetchAssoc($obj_set);
233
234 return $obj_rec[$a_field] ?? "";
235 }

References $DIC, and $ilDB.

Referenced by _lookupShortTitle(), and _lookupTitle().

+ Here is the caller graph for this function:

◆ _lookupContObjID()

static ilLMObject::_lookupContObjID ( int  $a_id)
static

get learning module id for lm object

Definition at line 565 of file class.ilLMObject.php.

565 : int
566 {
567 global $DIC;
568
569 $ilDB = $DIC->database();
570
571 if (isset(self::$data_records[$a_id])) {
572 return self::$data_records[$a_id]["lm_id"];
573 }
574
575 $query = "SELECT lm_id FROM lm_data WHERE obj_id = " .
576 $ilDB->quote($a_id, "integer");
577 $obj_set = $ilDB->query($query);
578 $obj_rec = $ilDB->fetchAssoc($obj_set);
579
580 return (int) ($obj_rec["lm_id"] ?? 0);
581 }

References $DIC, and $ilDB.

Referenced by ilObjContentObjectAccess\_checkGoto(), _getIdForImportId(), ilStructureObject\_getPresentationTitle(), ilLMPageObjectGUI\_goto(), ilLMEditorGUI\checkRequestParameters(), ilLMNavigationStatus\determineStatus(), ilLinksTableGUI\fillRow(), ilLearningModuleImporter\finalProcessing(), ilLMPageObjectGUI\getLinkXML(), ilPageLinker\getLinkXML(), ilLearningModuleDataSet\importRecord(), ilLMEditShortTitlesGUI\save(), ilHelpGUI\showHelp(), and updateInternalLinks().

+ Here is the caller graph for this function:

◆ _lookupShortTitle()

static ilLMObject::_lookupShortTitle ( int  $a_obj_id)
static

Definition at line 242 of file class.ilLMObject.php.

242 : string
243 {
244 return self::_lookup($a_obj_id, "short_title");
245 }
static _lookup(int $a_obj_id, string $a_field)

References _lookup().

+ Here is the call graph for this function:

◆ _lookupTitle()

◆ _lookupType()

static ilLMObject::_lookupType ( int  $a_obj_id,
int  $a_lm_id = 0 
)
static

Definition at line 247 of file class.ilLMObject.php.

247 : string
248 {
249 global $DIC;
250
251 $ilDB = $DIC->database();
252
253 if (isset(self::$data_records[$a_obj_id])) {
254 if ($a_lm_id == 0 || self::$data_records[$a_obj_id]["lm_id"] == $a_lm_id) {
255 return self::$data_records[$a_obj_id]["type"];
256 }
257 }
258
259 $and = "";
260 if ($a_lm_id) {
261 $and = ' AND lm_id = ' . $ilDB->quote($a_lm_id, 'integer');
262 }
263
264 $query = "SELECT type FROM lm_data WHERE obj_id = " . $ilDB->quote($a_obj_id, "integer") . $and;
265 $obj_set = $ilDB->query($query);
266 $obj_rec = $ilDB->fetchAssoc($obj_set);
267
268 return $obj_rec["type"] ?? "";
269 }

References $DIC, and $ilDB.

Referenced by ILIAS\LearningModule\Editing\EditSubObjectsGUI\activatePages(), ilLMContentRendererGUI\determineStatus(), ilLMNavigationStatus\determineStatus(), ILIAS\COPage\Link\LinkManager\getDefaultLMTypeLookuper(), ilLMTOCExplorerGUI\getRootNode(), ilLMNavigationStatus\getSuccessorPageId(), ilObjContentObjectGUI\saveExportIds(), ilLMPresentationGUI\showPrintView(), uniqueTypesCheck(), updateInternalLinks(), and ilCourseObjectivesGUI\updateMaterialAssignment().

+ Here is the caller graph for this function:

◆ _writeImportId()

static ilLMObject::_writeImportId ( int  $a_id,
string  $a_import_id 
)
static

Definition at line 357 of file class.ilLMObject.php.

357 : void
358 {
359 global $DIC;
360
361 $ilDB = $DIC->database();
362
363 $q = "UPDATE lm_data " .
364 "SET " .
365 "import_id = " . $ilDB->quote($a_import_id, "text") . "," .
366 "last_update = " . $ilDB->now() . " " .
367 "WHERE obj_id = " . $ilDB->quote($a_id, "integer");
368
369 $ilDB->manipulate($q);
370 }

References $DIC, $ilDB, and $q.

◆ _writeTitle()

static ilLMObject::_writeTitle ( int  $a_obj_id,
string  $a_title 
)
static

Definition at line 272 of file class.ilLMObject.php.

272 : void
273 {
274 global $DIC;
275
276 $ilDB = $DIC->database();
277
278 $a_title = ilStr::substr($a_title, 0, 200);
279
280 $query = "UPDATE lm_data SET " .
281 " title = " . $ilDB->quote($a_title, "text") .
282 " WHERE obj_id = " . $ilDB->quote($a_obj_id, "integer");
283 $ilDB->manipulate($query);
284 }

References $DIC, and $ilDB.

Referenced by MDUpdateListener().

+ Here is the caller graph for this function:

◆ clipboardCopy()

static ilLMObject::clipboardCopy ( int  $a_cont_obj_id,
array  $a_ids 
)
static

Copy a set of chapters/pages into the clipboard.

Definition at line 686 of file class.ilLMObject.php.

689 : void {
690 global $DIC;
691
692 $ilUser = $DIC->user();
693
694 $tree = ilLMObject::getTree($a_cont_obj_id);
695
696 $ilUser->clipboardDeleteObjectsOfType("pg");
697 $ilUser->clipboardDeleteObjectsOfType("st");
698
699 // put them into the clipboard
700 $time = date("Y-m-d H:i:s", time());
701 $order = 0;
702 foreach ($a_ids as $id) {
703 $curnode = array();
704 if ($tree->isInTree($id)) {
705 $curnode = $tree->getNodeData($id);
706 $subnodes = $tree->getSubTree($curnode);
707 foreach ($subnodes as $subnode) {
708 if ($subnode["child"] != $id) {
709 $ilUser->addObjectToClipboard(
710 $subnode["child"],
711 $subnode["type"],
712 ilStr::subStr($subnode["title"], 0, 70),
713 $subnode["parent"],
714 $time,
715 $subnode["lft"]
716 );
717 }
718 }
719 }
720 $order = (($curnode["lft"] ?? 0) > 0)
721 ? $curnode["lft"]
722 : (int) ($order + 1);
723 $ilUser->addObjectToClipboard(
724 $id,
725 self::_lookupType($id),
726 ilStr::subStr(self::_lookupTitle($id), 0, 70),
727 0,
728 $time,
729 $order
730 );
731 }
732 }
static getTree(int $a_cont_obj_id)
Get learning module tree.
static subStr(string $a_str, int $a_start, ?int $a_length=null)
Definition: class.ilStr.php:21

Referenced by ILIAS\LearningModule\Editing\EditSubObjectsGUI\copyItems(), ilObjContentObjectGUI\copyItems(), and ilObjContentObjectGUI\copyPage().

+ Here is the caller graph for this function:

◆ clipboardCut()

static ilLMObject::clipboardCut ( int  $a_cont_obj_id,
array  $a_ids 
)
static

Copy a set of chapters/pages into the clipboard.

Definition at line 645 of file class.ilLMObject.php.

648 : void {
649 $tree = ilLMObject::getTree($a_cont_obj_id);
650 $cut_ids = [];
651
652 if (!is_array($a_ids)) {
653 return;
654 } else {
655 // get all "top" ids, i.e. remove ids, that have a selected parent
656 foreach ($a_ids as $id) {
657 $path = $tree->getPathId($id);
658 $take = true;
659 foreach ($path as $path_id) {
660 if ($path_id != $id && in_array($path_id, $a_ids)) {
661 $take = false;
662 }
663 }
664 if ($take) {
665 $cut_ids[] = $id;
666 }
667 }
668 }
669
670 ilLMObject::clipboardCopy($a_cont_obj_id, $cut_ids);
671
672 // remove the objects from the tree
673 // note: we are getting chapters which are *not* in the tree
674 // we do not delete any pages/chapters here
675 foreach ($cut_ids as $id) {
676 $curnode = $tree->getNodeData($id);
677 if ($tree->isInTree($id)) {
678 $tree->deleteTree($curnode);
679 }
680 }
681 }
static clipboardCopy(int $a_cont_obj_id, array $a_ids)
Copy a set of chapters/pages into the clipboard.
$path
Definition: ltiservices.php:30

Referenced by ilObjContentObjectGUI\cutItems(), ILIAS\LearningModule\Editing\EditSubObjectsGUI\cutItems(), and ilObjContentObjectGUI\movePage().

+ Here is the caller graph for this function:

◆ create()

ilLMObject::create ( bool  $a_upload = false)

Definition at line 372 of file class.ilLMObject.php.

372 : void
373 {
375
376 // insert object data
377 $this->setId($ilDB->nextId("lm_data"));
378 $query = "INSERT INTO lm_data (obj_id, title, type, layout, lm_id, import_id, short_title, create_date) " .
379 "VALUES (" .
380 $ilDB->quote($this->getId(), "integer") . "," .
381 $ilDB->quote($this->getTitle(), "text") . "," .
382 $ilDB->quote($this->getType(), "text") . ", " .
383 $ilDB->quote($this->getLayout(), "text") . ", " .
384 $ilDB->quote($this->getLMId(), "integer") . "," .
385 $ilDB->quote($this->getImportId(), "text") . "," .
386 $ilDB->quote($this->getShortTitle(), "text") .
387 ", " . $ilDB->now() . ")";
388 $ilDB->manipulate($query);
389
390 if (!$a_upload) {
391 $this->createMetaData();
392 }
393 }
setId(int $a_id)
ilDBInterface $db
createMetaData()
create meta data entry

References $db, $ilDB, createMetaData(), getId(), getImportId(), getLayout(), getLMId(), getShortTitle(), getTitle(), getType(), and setId().

+ Here is the call graph for this function:

◆ createMetaData()

ilLMObject::createMetaData ( )

create meta data entry

Definition at line 117 of file class.ilLMObject.php.

117 : void
118 {
119 $ilUser = $this->user;
120
121 $this->lom_services->derive()
122 ->fromBasicProperties(
123 $this->getTitle(),
124 $this->getDescription(),
125 $ilUser->getPref('language')
126 )->forObject($this->getLMId(), $this->getId(), $this->getType());
127 }
ilObjUser $user

References $user, getDescription(), getId(), getLMId(), getTitle(), and getType().

Referenced by create().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ilLMObject::delete ( bool  $a_delete_meta_data = true)

Reimplemented in ilLMPageObject, and ilStructureObject.

Definition at line 411 of file class.ilLMObject.php.

411 : void
412 {
414
415 $query = "DELETE FROM lm_data WHERE obj_id = " .
416 $ilDB->quote($this->getId(), "integer");
417 $ilDB->manipulate($query);
418
419 $this->deleteMetaData();
420 }
deleteMetaData()
delete meta data entry

References $db, $ilDB, deleteMetaData(), and getId().

+ Here is the call graph for this function:

◆ deleteMetaData()

ilLMObject::deleteMetaData ( )

delete meta data entry

Definition at line 145 of file class.ilLMObject.php.

145 : void
146 {
147 $this->lom_services->deleteAll($this->getLMId(), $this->getId(), $this->getType());
148 }

References getId(), getLMId(), and getType().

Referenced by delete().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ existsExportID()

ilLMObject::existsExportID ( int  $a_lm_id,
int  $a_exp_id,
string  $a_type = "pg" 
)

Does export ID exist in lm?

Definition at line 1209 of file class.ilLMObject.php.

1213 : bool {
1214 $searcher = $this->lom_services->search();
1215
1216 $search_clause = $searcher->getClauseFactory()->getBasicClause(
1217 self::getPathToExportIDInLOM(),
1218 Mode::EQUALS,
1219 $a_exp_id
1220 );
1221 $results = $searcher->execute(
1222 $search_clause,
1223 1,
1224 null,
1225 $searcher->getFilter($a_lm_id, Placeholder::ANY, $a_type)
1226 );
1227 return count(iterator_to_array($results)) > 0;
1228 }
$results

◆ getContentObject()

ilLMObject::getContentObject ( )

Definition at line 322 of file class.ilLMObject.php.

323 {
325 }
ilObjLearningModule $content_object
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References $content_object.

◆ getDescription()

ilLMObject::getDescription ( )

Definition at line 292 of file class.ilLMObject.php.

292 : string
293 {
294 return $this->description;
295 }
string $description

References $description.

Referenced by createMetaData().

+ Here is the caller graph for this function:

◆ getDuplicateExportIDs()

static ilLMObject::getDuplicateExportIDs ( int  $a_lm_id,
string  $a_type = "pg" 
)
static

Get duplicate export IDs (count export ID usages)

Definition at line 1233 of file class.ilLMObject.php.

1236 : array {
1237 global $DIC;
1238
1239 $lom_services = $DIC->learningObjectMetadata();
1240 $export_id_path = self::getPathToExportIDInLOM();
1241
1242 $searcher = $lom_services->search();
1243 $search_clause = $searcher->getClauseFactory()->getBasicClause(
1244 $export_id_path,
1245 Mode::EQUALS,
1246 '',
1247 true
1248 );
1249 $search_results = $searcher->execute(
1250 $search_clause,
1251 1,
1252 null,
1253 $searcher->getFilter($a_lm_id, Placeholder::ANY, $a_type)
1254 );
1255
1256 $res = [];
1257 foreach ($search_results as $search_result) {
1258 if (!ilLMObject::_exists($search_result->subID())) {
1259 continue;
1260 }
1261 $reader = $lom_services->read(
1262 $search_result->objID(),
1263 $search_result->subID(),
1264 $search_result->type(),
1265 $export_id_path
1266 );
1267 foreach ($reader->allData($export_id_path) as $export_id_datum) {
1268 $export_id = trim($export_id_datum->value());
1269 $res[$export_id] = ($res[$export_id] ?? 0) + 1;
1270 }
1271 }
1272 return $res;
1273 }
static getPathToExportIDInLOM()
LOMServices $lom_services
static _exists(int $a_id)
checks wether a lm content object with specified id exists or not
$res
Definition: ltiservices.php:69

Referenced by ilExportIDTableGUI\__construct().

+ Here is the caller graph for this function:

◆ getExportId()

static ilLMObject::getExportId ( int  $a_lm_id,
int  $a_lmobj_id,
string  $a_type = "pg" 
)
static

Definition at line 1189 of file class.ilLMObject.php.

1193 : string {
1194 global $DIC;
1195
1196 // look for export id
1197 $export_id_path = self::getPathToExportIDInLOM();
1198 return $DIC->learningObjectMetadata()->read(
1199 $a_lm_id,
1200 $a_lmobj_id,
1201 $a_type,
1202 $export_id_path
1203 )->firstData($export_id_path)->value();
1204 }

Referenced by ILIAS\LearningModule\Export\LMHtmlExport\exportHTMLPages(), ilExportIDTableGUI\fillRow(), and ilLMTOCExplorerGUI\getNodeHref().

+ Here is the caller graph for this function:

◆ getId()

ilLMObject::getId ( )

Reimplemented in ilLMPageObject.

Definition at line 332 of file class.ilLMObject.php.

332 : int
333 {
334 return $this->id;
335 }

References $id.

Referenced by create(), createMetaData(), delete(), ilStructureObject\delete(), deleteMetaData(), MDUpdateListener(), update(), and updateMetaData().

+ Here is the caller graph for this function:

◆ getImportId()

ilLMObject::getImportId ( )

Definition at line 337 of file class.ilLMObject.php.

337 : string
338 {
339 return $this->import_id;
340 }

References $import_id.

Referenced by create().

+ Here is the caller graph for this function:

◆ getLayout()

ilLMObject::getLayout ( )

Definition at line 352 of file class.ilLMObject.php.

352 : string
353 {
354 return $this->layout;
355 }

References $layout.

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getLMId()

ilLMObject::getLMId ( )

Definition at line 312 of file class.ilLMObject.php.

312 : int
313 {
314 return $this->lm_id;
315 }

References $lm_id.

Referenced by ilStructureObject\__construct(), create(), createMetaData(), deleteMetaData(), MDUpdateListener(), update(), and updateMetaData().

+ Here is the caller graph for this function:

◆ getObjectList()

static ilLMObject::getObjectList ( int  $lm_id,
string  $type = "" 
)
static

Definition at line 511 of file class.ilLMObject.php.

514 : array {
515 global $DIC;
516
517 $ilDB = $DIC->database();
518
519 $type_str = ($type != "")
520 ? "AND type = " . $ilDB->quote($type, "text") . " "
521 : "";
522
523 $query = "SELECT * FROM lm_data " .
524 "WHERE lm_id= " . $ilDB->quote($lm_id, "integer") . " " .
525 $type_str . " " .
526 "ORDER BY title";
527 $obj_set = $ilDB->query($query);
528 $obj_list = array();
529 while ($obj_rec = $ilDB->fetchAssoc($obj_set)) {
530 $obj_list[] = array("obj_id" => $obj_rec["obj_id"],
531 "title" => $obj_rec["title"],
532 "import_id" => $obj_rec["import_id"],
533 "type" => $obj_rec["type"]);
534 }
535 return $obj_list;
536 }

Referenced by ilLMPageObject\getPageList(), ilHelpExporter\getXmlExportTailDependencies(), and ilLearningModuleExporter\getXmlExportTailDependencies().

+ Here is the caller graph for this function:

◆ getPagesOfChapter()

static ilLMObject::getPagesOfChapter ( int  $a_lm_id,
int  $a_chap_id 
)
static

Get pages of chapter.

Definition at line 1111 of file class.ilLMObject.php.

1114 : array {
1115 // update structure entries: if at least one page of a chapter is public set chapter to public too
1116 $lm_tree = new ilTree($a_lm_id);
1117 $lm_tree->setTableNames('lm_tree', 'lm_data');
1118 $lm_tree->setTreeTablePK("lm_id");
1119 $lm_tree->readRootId();
1120
1121 $childs = $lm_tree->getChildsByType($a_chap_id, "pg");
1122
1123 return $childs;
1124 }
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...

Referenced by ilHelpGUI\showHelp().

+ Here is the caller graph for this function:

◆ getPathToExportIDInLOM()

static ilLMObject::getPathToExportIDInLOM ( )
staticprotected

Definition at line 1173 of file class.ilLMObject.php.

1173 : LOMPath
1174 {
1175 global $DIC;
1176
1177 return $DIC->learningObjectMetadata()
1178 ->paths()
1179 ->custom()
1180 ->withNextStep('general')
1181 ->withNextStep('identifier')
1182 ->withNextStep('catalog')
1183 ->withAdditionalFilterAtCurrentStep(FilterType::DATA, 'ILIAS_NID')
1184 ->withNextStepToSuperElement()
1185 ->withNextStep('entry')
1186 ->get();
1187 }

References $DIC, and ILIAS\MetaData\Paths\Filters\DATA.

◆ getShortTitle()

ilLMObject::getShortTitle ( )

Definition at line 214 of file class.ilLMObject.php.

214 : string
215 {
216 return $this->short_title;
217 }
string $short_title

References $short_title.

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getShortTitles()

static ilLMObject::getShortTitles ( int  $a_lm_id,
string  $a_lang = "-" 
)
static

Definition at line 1312 of file class.ilLMObject.php.

1315 : array {
1316 global $DIC;
1317
1318 $db = $DIC->database();
1319
1320 $title_data = array();
1321 if ($a_lang == "-") {
1322 $set = $db->query("SELECT t.child, d.obj_id, d.title, d.short_title FROM lm_data d LEFT JOIN lm_tree t ON (d.obj_id = t.child) WHERE d.lm_id = " .
1323 $db->quote($a_lm_id, "integer") . " ORDER BY t.lft, d.title");
1324 } else {
1325 $set = $db->query("SELECT t.child, d.obj_id, tr.title, tr.short_title, d.title default_title, d.short_title default_short_title FROM lm_data d " .
1326 " LEFT JOIN lm_tree t ON (d.obj_id = t.child) " .
1327 " LEFT JOIN lm_data_transl tr ON (tr.id = d.obj_id AND tr.lang=" . $db->quote($a_lang, "text") . ") WHERE d.lm_id = " .
1328 $db->quote($a_lm_id, "integer") . " ORDER BY t.lft, d.title");
1329 }
1330 while ($rec = $db->fetchAssoc($set)) {
1331 $title_data[] = $rec;
1332 }
1333 return $title_data;
1334 }
quote($value, string $type)
query(string $query)
Run a (read-only) Query on the database.
fetchAssoc(ilDBStatement $statement)

Referenced by ilLMEditShortTitlesTableGUI\__construct().

+ Here is the caller graph for this function:

◆ getTitle()

ilLMObject::getTitle ( )

Definition at line 204 of file class.ilLMObject.php.

204 : string
205 {
206 return $this->title;
207 }

References $title.

Referenced by create(), createMetaData(), and update().

+ Here is the caller graph for this function:

◆ getTree()

static ilLMObject::getTree ( int  $a_cont_obj_id)
static

Get learning module tree.

Definition at line 633 of file class.ilLMObject.php.

635 : ilLMTree {
636 $tree = new ilLMTree($a_cont_obj_id);
637 $tree->readRootId();
638
639 return $tree;
640 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ getType()

ilLMObject::getType ( )

Definition at line 302 of file class.ilLMObject.php.

302 : string
303 {
304 return $this->type;
305 }

References $type.

Referenced by create(), createMetaData(), deleteMetaData(), MDUpdateListener(), and updateMetaData().

+ Here is the caller graph for this function:

◆ lookupLayout()

static ilLMObject::lookupLayout ( int  $a_obj_id)
static

Lookup type.

Definition at line 1094 of file class.ilLMObject.php.

1094 : string
1095 {
1096 global $DIC;
1097
1098 $ilDB = $DIC->database();
1099
1100 $query = "SELECT layout FROM lm_data WHERE obj_id = " .
1101 $ilDB->quote($a_obj_id, "integer");
1102 $obj_set = $ilDB->query($query);
1103 $obj_rec = $ilDB->fetchAssoc($obj_set);
1104
1105 return $obj_rec["layout"];
1106 }

References $DIC, and $ilDB.

Referenced by ilLMPagesTableGUI\fillRow().

+ Here is the caller graph for this function:

◆ MDUpdateListener()

ilLMObject::MDUpdateListener ( string  $a_element)

Meta data update listener Important note: Do never call create() or update() method of ilObject here.

It would result in an endless loop: update object -> update meta -> update object -> ... Use static _writeTitle() ... methods instead.

Parameters
string$a_elementmd element

Definition at line 81 of file class.ilLMObject.php.

81 : void
82 {
83 switch ($a_element) {
84 case 'General':
85
86 // Update Title and description
87 $paths = $this->lom_services->paths();
88 $reader = $this->lom_services->read(
89 $this->getLMId(),
90 $this->getId(),
91 $this->getType(),
92 $paths->custom()->withNextStep('general')->get()
93 );
94 $title = $reader->firstData($paths->title())->value();
95
97 break;
98
99 case 'Educational':
100 $obj_lp = ilObjectLP::getInstance($this->getLMId());
101 if (in_array(
102 $obj_lp->getCurrentMode(),
104 )) {
106 }
107 break;
108
109 default:
110 }
111 }
static _writeTitle(int $a_obj_id, string $a_title)
static _refreshStatus(int $a_obj_id, ?array $a_users=null)
static getInstance(int $obj_id)

References $title, ilLPStatusWrapper\_refreshStatus(), _writeTitle(), getId(), ilObjectLP\getInstance(), getLMId(), getType(), ilLPObjSettings\LP_MODE_COLLECTION_TLT, and ilLPObjSettings\LP_MODE_TLT.

+ Here is the call graph for this function:

◆ preloadDataByLM()

static ilLMObject::preloadDataByLM ( int  $a_lm_id)
static

Preload data records by lm.

Returns
int number of preloaded records

Definition at line 183 of file class.ilLMObject.php.

183 : int
184 {
185 global $DIC;
186
187 $ilDB = $DIC->database();
188
189 $set = $ilDB->query(
190 "SELECT * FROM lm_data " .
191 " WHERE lm_id = " . $ilDB->quote($a_lm_id, "integer")
192 );
193 while ($rec = $ilDB->fetchAssoc($set)) {
194 self::$data_records[$rec["obj_id"]] = $rec;
195 }
196 return count(self::$data_records);
197 }

References $DIC, and $ilDB.

Referenced by ilLMExplorerGUI\__construct().

+ Here is the caller graph for this function:

◆ putInTree()

static ilLMObject::putInTree ( ilLMObject  $a_obj,
int  $a_parent_id = 0,
int  $a_target_node_id = 0 
)
static

put this object into content object tree

Definition at line 586 of file class.ilLMObject.php.

590 : void {
591 global $DIC;
592
593 $ilLog = $DIC["ilLog"];
594
595 $tree = new ilLMTree($a_obj->getContentObject()->getId());
596
597 // determine parent
598 $parent_id = ($a_parent_id != 0)
599 ? $a_parent_id
600 : $tree->getRootId();
601
602 // determine target
603 if ($a_target_node_id != 0) {
604 $target = $a_target_node_id;
605 } else {
606 // determine last child that serves as predecessor
607 if ($a_obj->getType() == "st") {
608 $s_types = array("st", "pg");
609 $childs = $tree->getChildsByTypeFilter($parent_id, $s_types);
610 } else {
611 $s_types = "pg";
612 $childs = $tree->getChildsByType($parent_id, $s_types);
613 }
614
615 if (count($childs) == 0) {
616 $target = ilTree::POS_FIRST_NODE;
617 } else {
618 $target = $childs[count($childs) - 1]["obj_id"];
619 }
620 }
621
622 if ($tree->isInTree($parent_id) && !$tree->isInTree($a_obj->getId())) {
623 $ilLog->write("LMObject::putInTree: insertNode, ID: " . $a_obj->getId() .
624 "Parent ID: " . $parent_id . ", Target: " . $target);
625
626 $tree->insertNode($a_obj->getId(), $parent_id, $target);
627 }
628 }
const POS_FIRST_NODE

Referenced by ilLearningModuleDataSet\importRecord().

+ Here is the caller graph for this function:

◆ read()

ilLMObject::read ( )

Reimplemented in ilLMPageObject.

Definition at line 160 of file class.ilLMObject.php.

160 : void
161 {
163
164 if (!isset($this->data_record)) {
165 $query = "SELECT * FROM lm_data WHERE obj_id = " .
166 $ilDB->quote($this->id, "integer");
167 $obj_set = $ilDB->query($query);
168 $this->data_record = $ilDB->fetchAssoc($obj_set);
169 }
170
171 $this->type = $this->data_record["type"];
172 $this->setImportId((string) $this->data_record["import_id"]);
173 $this->setTitle((string) $this->data_record["title"]);
174 $this->setShortTitle((string) $this->data_record["short_title"]);
175 $this->setLayout((string) $this->data_record["layout"]);
176 }
setShortTitle(string $a_title)
setImportId(string $a_id)
setLayout(string $a_val)
setTitle(string $a_title)

References $db, $ilDB, setImportId(), setLayout(), setShortTitle(), and setTitle().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveExportId()

static ilLMObject::saveExportId ( int  $a_lm_id,
int  $a_lmobj_id,
string  $a_exp_id,
string  $a_type = "pg" 
)
static

Definition at line 1156 of file class.ilLMObject.php.

1161 : void {
1162 global $DIC;
1163
1164 $manipulator = $DIC->learningObjectMetadata()->manipulate($a_lm_id, $a_lmobj_id, $a_type);
1165 if (trim($a_exp_id) == "") {
1166 $manipulator = $manipulator->prepareDelete(self::getPathToExportIDInLOM());
1167 } else {
1168 $manipulator = $manipulator->prepareCreateOrUpdate(self::getPathToExportIDInLOM(), $a_exp_id);
1169 }
1170 $manipulator->execute();
1171 }

Referenced by ilObjContentObjectGUI\saveExportIds().

+ Here is the caller graph for this function:

◆ saveTitle()

static ilLMObject::saveTitle ( int  $id,
string  $title,
string  $lang = "-" 
)
static

Definition at line 847 of file class.ilLMObject.php.

847 : void
848 {
849 global $DIC;
850
851 $lom_services = $DIC->learningObjectMetadata();
853 if (in_array($lang, ["-", ""])) {
856 if ($type !== "" && $lm_id > 0) {
857 try {
858 $lom_services->manipulate($lm_id, $id, $type)
859 ->prepareCreateOrUpdate(
860 $lom_services->paths()->title(),
861 $title
862 )->execute();
863 } catch (Exception $e) {
864 }
866 }
867 } else {
868 $lmobjtrans = new ilLMObjTranslation($id, $lang);
869 $lmobjtrans->setTitle($title);
870 $lmobjtrans->save();
871 }
872 }
static removeProhibitedCharacters(string $a_text)
Remove prohibited characters see #19159.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupType(int $a_obj_id, int $a_lm_id=0)

References $DIC, Vendor\Package\$e, $id, and ilFormPropertyGUI\removeProhibitedCharacters().

Referenced by ILIAS\LearningModule\Editing\EditSubObjectsGUI\saveTitle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveTitles()

static ilLMObject::saveTitles ( ilObjLearningModule  $a_lm,
array  $a_titles,
string  $a_lang = "-" 
)
static

Save titles for lm objects.

Definition at line 828 of file class.ilLMObject.php.

832 : void {
833 global $DIC;
834
835 $lom_services = $DIC->learningObjectMetadata();
836
837 if ($a_lang == "") {
838 $a_lang = "-";
839 }
840 if (is_array($a_titles)) {
841 foreach ($a_titles as $id => $title) {
842 self::saveTitle($id, $title, $a_lang);
843 }
844 }
845 }
static saveTitle(int $id, string $title, string $lang="-")

Referenced by ilObjContentObjectGUI\saveAllTitles().

+ Here is the caller graph for this function:

◆ setContentObject()

ilLMObject::setContentObject ( ilObjLearningModule  $a_content_obj)

Definition at line 317 of file class.ilLMObject.php.

317 : void
318 {
319 $this->content_object = $a_content_obj;
320 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setDataRecord()

ilLMObject::setDataRecord ( array  $a_record)

this method should only be called by class ilLMObjectFactory

Definition at line 155 of file class.ilLMObject.php.

155 : void
156 {
157 $this->data_record = $a_record;
158 }

◆ setDescription()

ilLMObject::setDescription ( string  $a_description)

Definition at line 287 of file class.ilLMObject.php.

287 : void
288 {
289 $this->description = $a_description;
290 }

◆ setId()

ilLMObject::setId ( int  $a_id)

Reimplemented in ilLMPageObject.

Definition at line 327 of file class.ilLMObject.php.

327 : void
328 {
329 $this->id = $a_id;
330 }

Referenced by create().

+ Here is the caller graph for this function:

◆ setImportId()

ilLMObject::setImportId ( string  $a_id)

Definition at line 342 of file class.ilLMObject.php.

342 : void
343 {
344 $this->import_id = $a_id;
345 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setLayout()

ilLMObject::setLayout ( string  $a_val)

Definition at line 347 of file class.ilLMObject.php.

347 : void
348 {
349 $this->layout = $a_val;
350 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setLMId()

ilLMObject::setLMId ( int  $a_lm_id)

Definition at line 307 of file class.ilLMObject.php.

307 : void
308 {
309 $this->lm_id = $a_lm_id;
310 }

Referenced by __construct(), and ilLMPageObjectGUI\setLMPageObject().

+ Here is the caller graph for this function:

◆ setShortTitle()

ilLMObject::setShortTitle ( string  $a_title)

Definition at line 209 of file class.ilLMObject.php.

209 : void
210 {
211 $this->short_title = $a_title;
212 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setTitle()

ilLMObject::setTitle ( string  $a_title)

Definition at line 199 of file class.ilLMObject.php.

199 : void
200 {
201 $this->title = $a_title;
202 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setType()

ilLMObject::setType ( string  $a_type)

Definition at line 297 of file class.ilLMObject.php.

297 : void
298 {
299 $this->type = $a_type;
300 }

Referenced by ilStructureObject\__construct(), and ilLMPageObject\__construct().

+ Here is the caller graph for this function:

◆ uniqueTypesCheck()

static ilLMObject::uniqueTypesCheck ( array  $a_items)
static

Check for unique types (all pages or all chapters)

Definition at line 1040 of file class.ilLMObject.php.

1040 : bool
1041 {
1042 $types = array();
1043 if (is_array($a_items)) {
1044 foreach ($a_items as $item) {
1046 $types[$type] = $type;
1047 }
1048 }
1049
1050 if (count($types) > 1) {
1051 return false;
1052 }
1053 return true;
1054 }

References _lookupType().

+ Here is the call graph for this function:

◆ update()

ilLMObject::update ( )

Definition at line 395 of file class.ilLMObject.php.

395 : void
396 {
398
399 $this->updateMetaData();
400
401 $query = "UPDATE lm_data SET " .
402 " lm_id = " . $ilDB->quote($this->getLMId(), "integer") .
403 " ,title = " . $ilDB->quote($this->getTitle(), "text") .
404 " ,short_title = " . $ilDB->quote($this->getShortTitle(), "text") .
405 " ,layout = " . $ilDB->quote($this->getLayout(), "text") .
406 " WHERE obj_id = " . $ilDB->quote($this->getId(), "integer");
407
408 $ilDB->manipulate($query);
409 }
updateMetaData()
update meta data entry

References $db, $ilDB, getId(), getLayout(), getLMId(), getShortTitle(), getTitle(), and updateMetaData().

+ Here is the call graph for this function:

◆ updateInternalLinks()

static ilLMObject::updateInternalLinks ( array  $a_copied_nodes,
string  $a_parent_type = "lm" 
)
static

Update internal links, after multiple pages have been copied.

Definition at line 877 of file class.ilLMObject.php.

880 : void {
881 $all_fixes = array();
882 foreach ($a_copied_nodes as $original_id => $copied_id) {
883 $copied_type = ilLMObject::_lookupType($copied_id);
884 $copy_lm = ilLMObject::_lookupContObjID($copied_id);
885
886 if ($copied_type == "pg") {
887 foreach (ilPageObject::lookupTranslations($a_parent_type, $copied_id) as $l) {
888 //
889 // 1. Outgoing links from the copied page.
890 //
891 //$targets = ilInternalLink::_getTargetsOfSource($a_parent_type.":pg", $copied_id);
892 $tpg = new ilLMPage($copied_id, 0, $l);
893 $tpg->buildDom();
894 $il = $tpg->getInternalLinks();
895 $targets = array();
896 foreach ($il as $l2) {
897 $targets[] = array("type" => ilInternalLink::_extractTypeOfTarget($l2["Target"]),
898 "id" => (int) ilInternalLink::_extractObjIdOfTarget($l2["Target"]),
899 "inst" => (int) ilInternalLink::_extractInstOfTarget($l2["Target"]));
900 }
901 $fix = array();
902 foreach ($targets as $target) {
903 if (($target["inst"] == 0 || $target["inst"] = IL_INST_ID) &&
904 ($target["type"] == "pg" || $target["type"] == "st")) {
905 // first check, whether target is also within the copied set
906 if (($a_copied_nodes[$target["id"]] ?? 0) > 0) {
907 $fix[$target["id"]] = $a_copied_nodes[$target["id"]];
908 } else {
909 // now check, if a copy if the target is already in the same lm
910
911 // only if target is not already in the same lm!
912 $trg_lm = ilLMObject::_lookupContObjID($target["id"]);
913 if ($trg_lm != $copy_lm) {
914 $lm_data = ilLMObject::_getAllObjectsForImportId("il__" . $target["type"] . "_" . $target["id"]);
915 $found = false;
916
917 foreach ($lm_data as $item) {
918 if (!$found && ($item["lm_id"] == $copy_lm)) {
919 $fix[$target["id"]] = $item["obj_id"];
920 $found = true;
921 }
922 }
923 }
924 }
925 }
926 }
927
928 // outgoing links to be fixed
929 if (count($fix) > 0) {
930 //echo "<br>--".$copied_id;
931 //var_dump($fix);
932 $t = ilObject::_lookupType($copy_lm);
933 if (isset($all_fixes[$t . ":" . $copied_id])) {
934 $all_fixes[$t . ":" . $copied_id] += $fix;
935 } else {
936 $all_fixes[$t . ":" . $copied_id] = $fix;
937 }
938 }
939 }
940 }
941
942 if ($copied_type == "pg" ||
943 $copied_type == "st") {
944 //
945 // 2. Incoming links to the original pages
946 //
947 // A->B A2 (A+B currently copied)
948 // A->C B2
949 // B->A
950 // C->A C2->A (C already copied)
951 $original_lm = ilLMObject::_lookupContObjID($original_id);
952 $original_type = ilObject::_lookupType($original_lm);
953
954 if ($original_lm != $copy_lm) {
955 // This gets sources that link to A+B (so we have C here)
956 // (this also does already the trick when instance map areas are given in C)
957 // int_link, where target_type, target_id, target_inst -> ok
959 $copied_type,
960 $original_id,
961 0
962 );
963
964 // mobs linking to $original_id
965 // map_area, where link_type, target -> ok
966 $mobs = ilMapArea::_getMobsForTarget("int", "il__" . $copied_type .
967 "_" . $original_id);
968
969 // pages using these mobs
970 foreach ($mobs as $mob) {
971 // mob_usage, where id -> ok
972 // mep_item, where foreign_id, type -> ok
973 // mep_tree, where child -> already existed
974 // il_news_item, where mob_id -> ok
975 // map_area, where link_type, target -> aready existed
976 // media_item, where id -> already existed
977 // personal_clipboard, where item_id, type -> ok
978 $usages = ilObjMediaObject::lookupUsages($mob);
979 foreach ($usages as $usage) {
980 if ($usage["type"] == "lm:pg" | $usage["type"] == "lm:st") {
981 $sources[] = $usage;
982 }
983 }
984 }
985 $fix = array();
986 foreach ($sources as $source) {
987 $stype = explode(":", $source["type"]);
988 $source_type = $stype[1] ?? "";
989
990 if ($source_type == "pg" || $source_type == "st") {
991 // first of all: source must be in original lm
992 $src_lm = ilLMObject::_lookupContObjID($source["id"]);
993
994 if ($src_lm == $original_lm) {
995 // check, if a copy if the source is already in the same lm
996 // now we look for the latest copy of C in LM2
998 "il__" . $source_type . "_" . $source["id"],
999 $copy_lm
1000 );
1001 $found = false;
1002 foreach ($lm_data as $item) {
1003 if (!$found) {
1004 $fix[$item["obj_id"]][$original_id] = $copied_id;
1005 $found = true;
1006 }
1007 }
1008 }
1009 }
1010 }
1011 // outgoing links to be fixed
1012 if (count($fix) > 0) {
1013 foreach ($fix as $page_id => $fix_array) {
1014 $t = ilObject::_lookupType($copy_lm);
1015 if (isset($all_fixes[$t . ":" . $page_id])) {
1016 $all_fixes[$t . ":" . $page_id] += $fix_array;
1017 } else {
1018 $all_fixes[$t . ":" . $page_id] = $fix_array;
1019 }
1020 }
1021 }
1022 }
1023 }
1024 }
1025
1026 foreach ($all_fixes as $pg => $fixes) {
1027 $pg = explode(":", $pg);
1028 foreach (ilPageObject::lookupTranslations($pg[0], $pg[1]) as $l) {
1029 $page = ilPageObjectFactory::getInstance($pg[0], $pg[1], 0, $l);
1030 if ($page->moveIntLinks($fixes)) {
1031 $page->update(true, true);
1032 }
1033 }
1034 }
1035 }
static _getAllObjectsForImportId(string $a_import_id, int $a_in_lm=0)
Get all items for an import ID.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getMobsForTarget(string $a_type, string $a_target)
Get areas for a certain target.
static lookupUsages(int $a_id, bool $a_include_history=true)
Lookup usages of media object.
static _lookupType(int $id, bool $reference=false)
static getInstance(string $a_parent_type, int $a_id=0, int $a_old_nr=0, string $a_lang="-")
static lookupTranslations(string $a_parent_type, int $a_id)
Lookup translations.
const IL_INST_ID
Definition: constants.php:40

References ilInternalLink\_extractInstOfTarget(), ilInternalLink\_extractObjIdOfTarget(), ilInternalLink\_extractTypeOfTarget(), _getAllObjectsForImportId(), ilMapArea\_getMobsForTarget(), ilInternalLink\_getSourcesOfTarget(), _lookupContObjID(), _lookupType(), ilObject\_lookupType(), IL_INST_ID, ilPageObject\lookupTranslations(), and ilObjMediaObject\lookupUsages().

+ Here is the call graph for this function:

◆ updateMetaData()

ilLMObject::updateMetaData ( )

update meta data entry

Definition at line 132 of file class.ilLMObject.php.

132 : void
133 {
134 $this->lom_services->manipulate($this->getLMId(), $this->getId(), $this->getType())
135 ->prepareCreateOrUpdate(
136 $this->lom_services->paths()->title(),
137 $this->getTitle()
138 )->execute();
139 }

References getId(), getLMId(), and getType().

Referenced by update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeLayout()

static ilLMObject::writeLayout ( int  $a_obj_id,
string  $a_layout,
?ilObjLearningModule  $a_lm = null 
)
static

Write layout setting.

Definition at line 1059 of file class.ilLMObject.php.

1063 : void {
1064 global $DIC;
1065
1066 $ilDB = $DIC->database();
1067
1068 $t = ilLMObject::_lookupType($a_obj_id);
1069
1070 if ($t == "pg") {
1071 $query = "UPDATE lm_data SET " .
1072 " layout = " . $ilDB->quote($a_layout, "text") .
1073 " WHERE obj_id = " . $ilDB->quote($a_obj_id, "integer");
1074 $ilDB->manipulate($query);
1075 } elseif ($t == "st" && is_object($a_lm)) {
1076 $node = $a_lm->getLMTree()->getNodeData($a_obj_id);
1077 $child_nodes = $a_lm->getLMTree()->getSubTree($node);
1078 if (is_array($child_nodes) && count($child_nodes) > 0) {
1079 foreach ($child_nodes as $c) {
1080 if ($c["type"] == "pg") {
1081 $query = "UPDATE lm_data SET " .
1082 " layout = " . $ilDB->quote($a_layout, "text") .
1083 " WHERE obj_id = " . $ilDB->quote($c["child"], "integer");
1084 $ilDB->manipulate($query);
1085 }
1086 }
1087 }
1088 }
1089 }
$c
Definition: deliver.php:25

Referenced by ilLMPageObjectGUI\saveLayout(), ilObjContentObjectGUI\savePageLayout(), and ilStructureObjectGUI\savePageLayout().

+ Here is the caller graph for this function:

◆ writeShortTitle()

static ilLMObject::writeShortTitle ( int  $a_id,
string  $a_short_title,
string  $a_lang = "-" 
)
static

Definition at line 1336 of file class.ilLMObject.php.

1340 : void {
1341 global $DIC;
1342
1343 $db = $DIC->database();
1344
1345 if ($a_lang != "-" && $a_lang != "") {
1346 $trans = new ilLMObjTranslation($a_id, $a_lang);
1347 $trans->setShortTitle($a_short_title);
1348 $trans->save();
1349 } else {
1350 $db->manipulate(
1351 "UPDATE lm_data SET " .
1352 " short_title = " . $db->quote($a_short_title, "text") .
1353 " WHERE obj_id = " . $db->quote($a_id, "integer")
1354 );
1355 }
1356 }
manipulate(string $query)
Run a (write) Query on the database.

Referenced by ilLMEditShortTitlesGUI\save().

+ Here is the caller graph for this function:

Field Documentation

◆ $active

bool ilLMObject::$active = true

Definition at line 49 of file class.ilLMObject.php.

◆ $content_object

ilObjLearningModule ilLMObject::$content_object

Definition at line 45 of file class.ilLMObject.php.

Referenced by getContentObject().

◆ $data_record

array ilLMObject::$data_record

Definition at line 44 of file class.ilLMObject.php.

◆ $data_records

array ilLMObject::$data_records = []
staticprotected

Definition at line 50 of file class.ilLMObject.php.

◆ $db

ilDBInterface ilLMObject::$db
protected

Definition at line 51 of file class.ilLMObject.php.

Referenced by create(), delete(), read(), and update().

◆ $description

string ilLMObject::$description = ""

Definition at line 48 of file class.ilLMObject.php.

Referenced by getDescription().

◆ $id

int ilLMObject::$id = 0

Definition at line 43 of file class.ilLMObject.php.

Referenced by getId().

◆ $import_id

string ilLMObject::$import_id = ""
protected

Definition at line 38 of file class.ilLMObject.php.

Referenced by getImportId().

◆ $layout

string ilLMObject::$layout = ""
protected

Definition at line 37 of file class.ilLMObject.php.

Referenced by getLayout().

◆ $lm_id

int ilLMObject::$lm_id = 0

Definition at line 41 of file class.ilLMObject.php.

Referenced by _getIdForImportId(), and getLMId().

◆ $lom_services

LOMServices ilLMObject::$lom_services
protected

Definition at line 52 of file class.ilLMObject.php.

◆ $short_title

string ilLMObject::$short_title = ""

Definition at line 47 of file class.ilLMObject.php.

Referenced by getShortTitle().

◆ $title

string ilLMObject::$title = ""

Definition at line 46 of file class.ilLMObject.php.

Referenced by getTitle(), and MDUpdateListener().

◆ $type

string ilLMObject::$type = ""

Definition at line 42 of file class.ilLMObject.php.

Referenced by getType().

◆ $user

ilObjUser ilLMObject::$user
protected

Definition at line 40 of file class.ilLMObject.php.

Referenced by createMetaData().

◆ CHAPTER_TITLE

◆ NO_HEADER

const ilLMObject::NO_HEADER = "none"

Definition at line 36 of file class.ilLMObject.php.

◆ PAGE_TITLE

const ilLMObject::PAGE_TITLE = "pg_title"

The documentation for this class was generated from the following file: