ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
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 544 of file class.ilLMObject.php.

546 : void {
547 global $DIC;
548
549 $ilDB = $DIC->database();
550
551 $query = "SELECT * FROM lm_data " .
552 "WHERE lm_id= " . $ilDB->quote($a_cobj->getId(), "integer");
553 $obj_set = $ilDB->query($query);
554
555 while ($obj_rec = $ilDB->fetchAssoc($obj_set)) {
556 $lm_obj = ilLMObjectFactory::getInstance($a_cobj, $obj_rec["obj_id"], false);
557
558 if (is_object($lm_obj)) {
559 $lm_obj->delete(true);
560 }
561 }
562 }
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 493 of file class.ilLMObject.php.

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

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

Referenced by ilCourseObjectiveMaterials\__read(), ilInternalLink\_exists(), ILIAS\LearningModule\Links\Retrieval\getLMObjectTitle(), 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 1136 of file class.ilLMObject.php.

1139 : array {
1140 global $DIC;
1141
1142 $ilDB = $DIC->database();
1143
1144 $and = ($a_type != "")
1145 ? " AND type = " . $ilDB->quote($a_type, "text")
1146 : "";
1147
1148 $set = $ilDB->query("SELECT obj_id FROM lm_data " .
1149 " WHERE lm_id = " . $ilDB->quote($a_lm_id, "integer") . $and);
1150 $obj_ids = array();
1151 while ($rec = $ilDB->fetchAssoc($set)) {
1152 $obj_ids[] = $rec["obj_id"];
1153 }
1154
1155 return $obj_ids;
1156 }

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 461 of file class.ilLMObject.php.

464 : array {
465 global $DIC;
466
467 $ilDB = $DIC->database();
468
469 $where = ($a_in_lm > 0)
470 ? " AND lm_id = " . $ilDB->quote($a_in_lm, "integer") . " "
471 : "";
472
473 $q = "SELECT * FROM lm_data WHERE import_id = " .
474 $ilDB->quote($a_import_id, "text") . " " .
475 $where .
476 " ORDER BY create_date DESC";
477 $obj_set = $ilDB->query($q);
478
479 $items = array();
480 while ($obj_rec = $ilDB->fetchAssoc($obj_set)) {
481 // check, whether lm is not trashed
482 if (ilObject::_hasUntrashedReference($obj_rec["lm_id"])) {
483 $items[] = $obj_rec;
484 }
485 }
486
487 return $items;
488 }
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 431 of file class.ilLMObject.php.

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

1291 : string {
1292 if ($a_lang == "") {
1293 $a_lang = "-";
1294 }
1295
1296 if ($a_node["type"] == "st") {
1298 $a_node["child"],
1299 self::CHAPTER_TITLE,
1300 $a_include_numbers,
1301 $a_time_scheduled_activation,
1302 $a_force_content,
1303 $a_lm_id,
1304 $a_lang
1305 );
1306 } else {
1308 $a_node["child"],
1309 $a_mode,
1310 $a_include_numbers,
1311 $a_time_scheduled_activation,
1312 $a_force_content,
1313 $a_lm_id,
1314 $a_lang
1315 );
1316 }
1317 }
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 567 of file class.ilLMObject.php.

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

References $DIC, and $ilDB.

Referenced by ilObjContentObjectAccess\_checkGoto(), _getIdForImportId(), ilStructureObject\_getPresentationTitle(), ilLMPageObjectGUI\_goto(), ilLMEditorGUI\checkRequestParameters(), ilLMNavigationStatus\determineStatus(), ilObjContentObjectGUI\editHelpMapping(), ilLearningModuleImporter\finalProcessing(), ilLMPageObjectGUI\getLinkXML(), ilPageLinker\getLinkXML(), ILIAS\LearningModule\Links\Retrieval\getLMObjectTitle(), ilLearningModuleDataSet\importRecord(), ilObjContentObjectGUI\saveHelpMapping(), ilLMEditShortTitlesGUI\saveShortTitle(), 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(), ilObjContentObjectGUI\getExportIdForm(), ilLMTOCExplorerGUI\getRootNode(), ilLMNavigationStatus\getSuccessorPageId(), ilObjContentObjectGUI\saveExportId(), 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, and $ilDB.

◆ _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 }
static subStr(string $a_str, int $a_start, ?int $a_length=null)
Definition: class.ilStr.php:21

References $DIC, $ilDB, and ilStr\subStr().

Referenced by MDUpdateListener().

+ Here is the call graph for this function:
+ 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 688 of file class.ilLMObject.php.

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

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 647 of file class.ilLMObject.php.

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

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

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

+ 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 413 of file class.ilLMObject.php.

413 : void
414 {
416
417 $query = "DELETE FROM lm_data WHERE obj_id = " .
418 $ilDB->quote($this->getId(), "integer");
419 $ilDB->manipulate($query);
420
421 $this->deleteMetaData();
422 }
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 1216 of file class.ilLMObject.php.

1220 : bool {
1221 $searcher = $this->lom_services->search();
1222
1223 $search_clause = $searcher->getClauseFactory()->getBasicClause(
1224 self::getPathToExportIDInLOM(),
1225 Mode::EQUALS,
1226 $a_exp_id
1227 );
1228 $results = $searcher->execute(
1229 $search_clause,
1230 1,
1231 null,
1232 $searcher->getFilter($a_lm_id, Placeholder::ANY, $a_type)
1233 );
1234 return count(iterator_to_array($results)) > 0;
1235 }
$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 1240 of file class.ilLMObject.php.

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

Referenced by ILIAS\LearningModule\Editing\ExportIds\Retrieval\getExportIds().

+ 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 1196 of file class.ilLMObject.php.

1200 : string {
1201 global $DIC;
1202
1203 // look for export id
1204 $export_id_path = self::getPathToExportIDInLOM();
1205 return $DIC->learningObjectMetadata()->read(
1206 $a_lm_id,
1207 $a_lmobj_id,
1208 $a_type,
1209 $export_id_path
1210 )->firstData($export_id_path)->value();
1211 }

Referenced by ilLMTOCExplorerGUI\build(), ILIAS\LearningModule\Export\LMHtmlExport\exportHTMLPages(), ilObjContentObjectGUI\getExportIdForm(), and ILIAS\LearningModule\Editing\ExportIds\Retrieval\getExportIds().

+ 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 513 of file class.ilLMObject.php.

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

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 1118 of file class.ilLMObject.php.

1121 : array {
1122 // update structure entries: if at least one page of a chapter is public set chapter to public too
1123 $lm_tree = new ilTree($a_lm_id);
1124 $lm_tree->setTableNames('lm_tree', 'lm_data');
1125 $lm_tree->setTreeTablePK("lm_id");
1126 $lm_tree->readRootId();
1127
1128 $childs = $lm_tree->getChildsByType($a_chap_id, "pg");
1129
1130 return $childs;
1131 }
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 1180 of file class.ilLMObject.php.

1180 : LOMPath
1181 {
1182 global $DIC;
1183
1184 return $DIC->learningObjectMetadata()
1185 ->paths()
1186 ->custom()
1187 ->withNextStep('general')
1188 ->withNextStep('identifier')
1189 ->withNextStep('catalog')
1190 ->withAdditionalFilterAtCurrentStep(FilterType::DATA, 'ILIAS_NID')
1191 ->withNextStepToSuperElement()
1192 ->withNextStep('entry')
1193 ->get();
1194 }

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 1319 of file class.ilLMObject.php.

1322 : array {
1323 global $DIC;
1324
1325 $db = $DIC->database();
1326
1327 $title_data = array();
1328 if ($a_lang == "-") {
1329 $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 = " .
1330 $db->quote($a_lm_id, "integer") . " ORDER BY t.lft, d.title");
1331 } else {
1332 $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 " .
1333 " LEFT JOIN lm_tree t ON (d.obj_id = t.child) " .
1334 " LEFT JOIN lm_data_transl tr ON (tr.id = d.obj_id AND tr.lang=" . $db->quote($a_lang, "text") . ") WHERE d.lm_id = " .
1335 $db->quote($a_lm_id, "integer") . " ORDER BY t.lft, d.title");
1336 }
1337 while ($rec = $db->fetchAssoc($set)) {
1338 $title_data[] = $rec;
1339 }
1340 return $title_data;
1341 }
quote($value, string $type)
query(string $query)
Run a (read-only) Query on the database.
fetchAssoc(ilDBStatement $statement)

Referenced by ilLMEditShortTitlesGUI\getShortTitleForm(), and ILIAS\LearningModule\Editing\ShortTitles\Retrieval\getShortTitles().

+ 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 635 of file class.ilLMObject.php.

637 : ilLMTree {
638 $tree = new ilLMTree($a_cont_obj_id);
639 $tree->readRootId();
640
641 return $tree;
642 }
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 1101 of file class.ilLMObject.php.

1101 : string
1102 {
1103 global $DIC;
1104
1105 $ilDB = $DIC->database();
1106
1107 $query = "SELECT layout FROM lm_data WHERE obj_id = " .
1108 $ilDB->quote($a_obj_id, "integer");
1109 $obj_set = $ilDB->query($query);
1110 $obj_rec = $ilDB->fetchAssoc($obj_set);
1111
1112 return $obj_rec["layout"];
1113 }

References $DIC, and $ilDB.

Referenced by ILIAS\LearningModule\Editing\PagesRetrieval\getPages().

+ 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)
const int LP_MODE_COLLECTION_TLT
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 588 of file class.ilLMObject.php.

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

1168 : void {
1169 global $DIC;
1170
1171 $manipulator = $DIC->learningObjectMetadata()->manipulate($a_lm_id, $a_lmobj_id, $a_type);
1172 if (trim($a_exp_id) == "") {
1173 $manipulator = $manipulator->prepareDelete(self::getPathToExportIDInLOM());
1174 } else {
1175 $manipulator = $manipulator->prepareCreateOrUpdate(self::getPathToExportIDInLOM(), $a_exp_id);
1176 }
1177 $manipulator->execute();
1178 }

Referenced by ilObjContentObjectGUI\saveExportId().

+ Here is the caller graph for this function:

◆ saveTitle()

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

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

854 : void
855 {
856 global $DIC;
857
858 $lom_services = $DIC->learningObjectMetadata();
860 if (in_array($lang, ["-", ""])) {
863 if ($type !== "" && $lm_id > 0) {
864 try {
865 $lom_services->manipulate($lm_id, $id, $type)
866 ->prepareCreateOrUpdate(
867 $lom_services->paths()->title(),
868 $title
869 )->execute();
870 } catch (Exception $e) {
871 }
873 }
874 } else {
875 $lmobjtrans = new ilLMObjTranslation($id, $lang);
876 $lmobjtrans->setTitle($title);
877 $lmobjtrans->save();
878 }
879 }
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 835 of file class.ilLMObject.php.

839 : void {
840 global $DIC;
841
842 $lom_services = $DIC->learningObjectMetadata();
843
844 if ($a_lang == "") {
845 $a_lang = "-";
846 }
847 if (is_array($a_titles)) {
848 foreach ($a_titles as $id => $title) {
849 self::saveTitle($id, $title, $a_lang);
850 }
851 }
852 }
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 1047 of file class.ilLMObject.php.

1047 : bool
1048 {
1049 $types = array();
1050 if (is_array($a_items)) {
1051 foreach ($a_items as $item) {
1053 $types[$type] = $type;
1054 }
1055 }
1056
1057 if (count($types) > 1) {
1058 return false;
1059 }
1060 return true;
1061 }

References _lookupType().

+ Here is the call graph for this function:

◆ update()

ilLMObject::update ( )

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

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

References $db, $ilDB, $title, getId(), getLayout(), getLMId(), getShortTitle(), getTitle(), ilStr\subStr(), 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 884 of file class.ilLMObject.php.

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

References ILIAS\Scripts\PHPStan\$target, $usage, 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 1066 of file class.ilLMObject.php.

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

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 1343 of file class.ilLMObject.php.

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

Referenced by ilLMEditShortTitlesGUI\saveShortTitle().

+ 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 create(), getTitle(), MDUpdateListener(), and update().

◆ $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: