26 public function init(): void
45 $new_item = $this->dom_doc->createElement(
"FileItem");
46 $new_item = $this->getChildNode()->appendChild($new_item);
49 $id_node = $this->dom_doc->createElement(
"Identifier");
50 $id_node = $new_item->appendChild($id_node);
51 $id_node->setAttribute(
"Catalog",
"ILIAS");
52 $id_node->setAttribute(
"Entry",
"il__file_" . $a_id);
55 $loc_node = $this->dom_doc->createElement(
"Location");
56 $loc_node = $new_item->appendChild($loc_node);
57 $loc_node->setAttribute(
"Type",
"LocalFile");
58 $this->dom_util->setContent($loc_node, $a_location);
61 $form_node = $this->dom_doc->createElement(
"Format");
62 $form_node = $new_item->appendChild($form_node);
63 $this->dom_util->setContent($form_node, $a_format);
70 $this->dom_util->setFirstOptionalElement(
71 $this->getChildNode(),
75 array(
"Language" => $a_language)
81 foreach ($this->getChildNode()->childNodes as
$c) {
82 if (
$c->nodeName ===
"Title") {
91 foreach ($this->getChildNode()->childNodes as
$c) {
92 if (
$c->nodeName ===
"Title") {
93 return $c->getAttribute(
"Language");
107 foreach ($this->getChildNode()->childNodes as
$c) {
108 if (
$c->nodeName ===
"FileItem") {
110 $pc_id =
$c->getAttribute(
"PCID");
111 $hier_id =
$c->getAttribute(
"HierId");
112 $class =
$c->getAttribute(
"Class");
115 $id_node =
$c->firstChild;
116 if ($id_node->nodeName ===
"Identifier") {
117 $entry = $id_node->getAttribute(
"Entry");
118 if (substr($entry, 0, 9) ==
"il__file_") {
119 $id = substr($entry, 9);
122 $files[] = array(
"entry" => $entry,
"id" =>
$id,
123 "pc_id" => $pc_id,
"hier_id" => $hier_id,
137 $childs = iterator_to_array($this->getChildNode()->childNodes);
138 foreach ($childs as
$c) {
139 if (
$c->nodeName ===
"FileItem") {
141 $pc_id =
$c->getAttribute(
"PCID");
142 $hier_id =
$c->getAttribute(
"HierId");
144 if (in_array($hier_id .
":" . $pc_id, $a_ids)) {
145 $c->parentNode->removeChild(
$c);
160 foreach ($this->getChildNode()->childNodes as
$c) {
161 if (
$c->nodeName ===
"FileItem") {
162 $pc_id =
$c->getAttribute(
"PCID");
163 $hier_id =
$c->getAttribute(
"HierId");
164 $nodes[$hier_id .
":" . $pc_id] =
$c;
167 $this->dom_util->deleteAllChildsByName($this->getChildNode(), [
"FileItem"]);
168 foreach ($a_pos as $k => $v) {
169 if (is_object($nodes[$k])) {
170 $nodes[$k] = $this->getChildNode()->appendChild($nodes[$k]);
183 foreach ($this->getChildNode()->childNodes as
$c) {
184 if (
$c->nodeName ===
"FileItem") {
185 $classes[
$c->getAttribute(
"HierId") .
":" .
186 $c->getAttribute(
"PCID")] =
$c->getAttribute(
"Class");
199 foreach ($this->getChildNode()->childNodes as
$c) {
200 if (
$c->nodeName ==
"FileItem") {
203 $a_class[
$c->getAttribute(
"HierId") .
":" .
204 $c->getAttribute(
"PCID")]
216 return array(
"ed_edit_files",
"ed_insert_filelist",
"pc_flist");
224 DOMDocument $a_domdoc,
228 if (!$a_page->getImportMode()) {
230 $file_ids = ilObjFile::_getFilesOfObject(
236 self::saveFileUsage($a_page, $a_domdoc);
238 foreach ($file_ids as $file) {
241 $usages = $file_obj->getUsages();
242 if (count($usages) == 0) {
243 if ($file_obj->getMode() ==
"filelist") {
258 $files = self::collectFileItems($a_page, $a_page->getDomDoc());
261 ilObjFile::_deleteAllUsages(
268 foreach ($files as $file_id) {
270 $file_obj =
new ilObjFile($file_id,
false);
281 DOMDocument $a_old_domdoc,
285 self::saveFileUsage($a_page, $a_old_domdoc, $a_old_nr);
293 DOMDocument $a_domdoc,
296 $file_ids = self::collectFileItems($a_page, $a_domdoc);
298 foreach ($file_ids as $file_id) {
299 ilObjFile::_saveUsage(
314 DOMDocument $a_domdoc
316 $xpath = new DOMXPath($a_domdoc);
317 $nodes = $xpath->query(
'//FileItem/Identifier');
319 foreach ($nodes as $node) {
320 $id_arr = explode(
"_", $node->getAttribute(
"Entry"));
321 $file_id = $id_arr[count($id_arr) - 1];
322 if ($file_id > 0 && ($id_arr[1] ==
"" || $id_arr[1] ==
IL_INST_ID || $id_arr[1] == 0)) {
323 $file_ids[$file_id] = $file_id;
327 $xpath =
new DOMXPath($a_domdoc);
328 $nodes = $xpath->query(
"//IntLink[@Type='File']");
329 foreach ($nodes as $node) {
330 $t = $node->getAttribute(
"Target");
331 if (substr($t, 0, 9) ==
"il__dfile") {
332 $id_arr = explode(
"_", $t);
333 $file_id = $id_arr[count($id_arr) - 1];
334 $file_ids[$file_id] = $file_id;
344 int $delete_lower_than_nr
346 $file_ids = self::_deleteHistoryUsagesLowerEqualThan(
349 $delete_lower_than_nr,
353 foreach ($file_ids as $file_id) {
356 $usages = $file->getUsages();
357 if (count($usages) == 0) {
367 int $a_usage_hist_nr,
372 $hist_repo =
$DIC->copage()->internal()->repo()->history();
375 foreach ($hist_repo->getHistoryNumbersOlderEqualThanNr(
381 foreach (ilObjFile::_getFilesOfObject($parent_type .
":pg", $a_id, $old_nr, $a_lang) as $file_id) {
382 $file_ids[$file_id] = $file_id;
384 ilObjFile::_deleteAllUsages($parent_type .
":pg", $a_id, $old_nr, $a_lang);
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
static _lookupType(int $id, bool $reference=false)
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static beforePageDelete(ilPageObject $a_page)
Before page is being deleted.
static getLangVars()
Get lang vars needed for editing.
static afterPageUpdate(ilPageObject $a_page, DOMDocument $a_domdoc, string $a_xml, bool $a_creation)
After page has been updated (or created)
static collectFileItems(ilPageObject $a_page, DOMDocument $a_domdoc)
Get all file items that are used within the page.
getAllClasses()
Get all style classes.
static saveFileUsage(ilPageObject $a_page, DOMDocument $a_domdoc, int $a_old_nr=0)
Save file usages.
static deleteHistoryLowerEqualThan(string $parent_type, int $page_id, string $lang, int $delete_lower_than_nr)
Overwrite in derived classes, if old history entries are being deleted.
static _deleteHistoryUsagesLowerEqualThan(string $parent_type, int $a_id, int $a_usage_hist_nr, string $a_lang="-")
saveStyleClasses(array $a_class)
Save style classes of file items.
setListTitle(string $a_title, string $a_language)
savePositions(array $a_pos)
Save positions of file items.
create(ilPageObject $a_pg_obj, string $a_hier_id, string $a_pc_id="")
static afterPageHistoryEntry(ilPageObject $a_page, DOMDocument $a_old_domdoc, string $a_old_xml, int $a_old_nr)
After page history entry has been created.
deleteFileItems(array $a_ids)
Delete file items.
appendItem(int $a_id, string $a_location, string $a_format)
getFileList()
Get list of files.
Content object of ilPageObject (see ILIAS DTD).
createInitialChildNode(string $hier_id, string $pc_id, string $child, array $child_attributes=[])
setType(string $a_type)
Set Type.
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
if(!file_exists('../ilias.ini.php'))