ILIAS  release_8 Revision v8.24
ilPCFileList Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilPCFileList:
+ Collaboration diagram for ilPCFileList:

Public Member Functions

 init ()
 Init object. More...
 
 setNode (php4DOMElement $a_node)
 Set xml node of page content. More...
 
 create (ilPageObject $a_pg_obj, string $a_hier_id, string $a_pc_id="")
 
 appendItem (int $a_id, string $a_location, string $a_format)
 
 setListTitle (string $a_title, string $a_language)
 
 getListTitle ()
 
 getLanguage ()
 
 getFileList ()
 Get list of files. More...
 
 deleteFileItems (array $a_ids)
 Delete file items. More...
 
 savePositions (array $a_pos)
 Save positions of file items. More...
 
 getAllClasses ()
 Get all style classes. More...
 
 saveStyleClasses (array $a_class)
 Save style classes of file items. More...
 
- Public Member Functions inherited from ilPageContent
 __construct (ilPageObject $a_pg_obj)
 
 setPage (ilPageObject $a_val)
 
 getPage ()
 
 init ()
 Init object. More...
 
 getType ()
 
 setNode (php4DOMElement $a_node)
 Set xml node of page content. More...
 
 getNode ()
 
 getJavascriptFiles (string $a_mode)
 
 getCssFiles (string $a_mode)
 
 getOnloadCode (string $a_mode)
 
 setHierId (string $a_hier_id)
 
 getHierId ()
 
 lookupHierId ()
 
 readHierId ()
 
 setPcId (string $a_pcid)
 
 getPCId ()
 
 setFileDownloadLink (string $a_download_link)
 
 getFileDownloadLink ()
 
 setProfileBackUrl (string $url)
 
 getProfileBackUrl ()
 
 setFullscreenLink (string $a_fullscreen_link)
 
 getFullscreenLink ()
 
 setSourcecodeDownloadScript (string $script_name)
 
 getSourcecodeDownloadScript ()
 
 readPCId ()
 
 writePCId (string $a_pc_id)
 
 setEnabled (string $value)
 Set Enabled value for page content component. More...
 
 enable ()
 
 disable ()
 
 isEnabled ()
 
 createPageContentNode (bool $a_set_this_node=true)
 Create page content node (always use this method first when adding a new element) More...
 
 modifyPageContentPostXsl (string $a_output, string $a_mode, bool $a_abstract_only=false)
 Modify page content after xsl. More...
 
 getModel ()
 Get model as needed for the front-end editor. More...
 

Static Public Member Functions

static getLangVars ()
 Get lang vars needed for editing. More...
 
static afterPageUpdate (ilPageObject $a_page, DOMDocument $a_domdoc, string $a_xml, bool $a_creation)
 After page has been updated (or created) More...
 
static beforePageDelete (ilPageObject $a_page)
 Before page is being deleted. More...
 
static afterPageHistoryEntry (ilPageObject $a_page, DOMDocument $a_old_domdoc, string $a_old_xml, int $a_old_nr)
 After page history entry has been created. More...
 
static saveFileUsage (ilPageObject $a_page, DOMDocument $a_domdoc, int $a_old_nr=0)
 Save file usages. More...
 
static collectFileItems (ilPageObject $a_page, DOMDocument $a_domdoc)
 Get all file items that are used within the page. More...
 
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. More...
 
- Static Public Member Functions inherited from ilPageContent
static incEdId (string $ed_id)
 Increases an hierarchical editing id at lowest level (last number) More...
 
static decEdId (string $ed_id)
 Decreases an hierarchical editing id at lowest level (last number) More...
 
static sortHierIds (array $a_array)
 Sort an array of Hier IDS in ascending order. More...
 
static isGreaterHierId (string $a, string $b)
 Check whether Hier ID $a is greater than Hier ID $b. More...
 
static getLangVars ()
 Get lang vars needed for editing. More...
 
static handleCopiedContent (DOMDocument $a_domdoc, bool $a_self_ass=true, bool $a_clone_mobs=false, int $new_parent_id=0, int $obj_copy_id=0)
 Handle copied content. More...
 
static afterPageUpdate (ilPageObject $a_page, DOMDocument $a_domdoc, string $a_xml, bool $a_creation)
 After page has been updated (or created) More...
 
static beforePageDelete (ilPageObject $a_page)
 Before page is being deleted. More...
 
static afterRepositoryCopy (ilPageObject $page, array $mapping, int $source_ref_id)
 After repository (container) copy action. More...
 
static afterPageHistoryEntry (ilPageObject $a_page, DOMDocument $a_old_domdoc, string $a_old_xml, int $a_old_nr)
 After page history entry has been created. More...
 
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. More...
 

Data Fields

php4DOMElement $list_node
 
- Data Fields inherited from ilPageContent
string $hier_id = ""
 
php4DOMElement $node = null
 
php4DOMDocument $dom = null
 
string $page_lang = ""
 

Static Protected Member Functions

static _deleteHistoryUsagesLowerEqualThan (string $parent_type, int $a_id, int $a_usage_hist_nr, string $a_lang="-")
 

Additional Inherited Members

- Protected Member Functions inherited from ilPageContent
 setType (string $a_type)
 Set Type. More...
 
- Protected Attributes inherited from ilPageContent
string $pcid
 
string $type = ""
 
ilPageObject $pg_obj
 
string $file_download_link
 
string $fullscreen_link
 
string $sourcecode_download_script
 
ilLogger $log
 
string $profile_back_url = ""
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilPCFileList File List content object (see ILIAS DTD)

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

Definition at line 24 of file class.ilPCFileList.php.

Member Function Documentation

◆ _deleteHistoryUsagesLowerEqualThan()

static ilPCFileList::_deleteHistoryUsagesLowerEqualThan ( string  $parent_type,
int  $a_id,
int  $a_usage_hist_nr,
string  $a_lang = "-" 
)
staticprotected

Definition at line 385 of file class.ilPCFileList.php.

390 : array {
391 global $DIC;
392
393 $hist_repo = $DIC->copage()->internal()->repo()->history();
394
395 $file_ids = [];
396 foreach ($hist_repo->getHistoryNumbersOlderEqualThanNr(
397 $a_usage_hist_nr,
398 $parent_type,
399 $a_id,
400 $a_lang
401 ) as $old_nr) {
402 foreach (ilObjFile::_getFilesOfObject($parent_type . ":pg", $a_id, $old_nr, $a_lang) as $file_id) {
403 $file_ids[$file_id] = $file_id;
404 }
405 ilObjFile::_deleteAllUsages($parent_type . ":pg", $a_id, $old_nr, $a_lang);
406 }
407 return $file_ids;
408 }
global $DIC
Definition: feed.php:28

◆ afterPageHistoryEntry()

static ilPCFileList::afterPageHistoryEntry ( ilPageObject  $a_page,
DOMDocument  $a_old_domdoc,
string  $a_old_xml,
int  $a_old_nr 
)
static

After page history entry has been created.

Reimplemented from ilPageContent.

Definition at line 300 of file class.ilPCFileList.php.

305 : void {
306 self::saveFileUsage($a_page, $a_old_domdoc, $a_old_nr);
307 }
static saveFileUsage(ilPageObject $a_page, DOMDocument $a_domdoc, int $a_old_nr=0)
Save file usages.

◆ afterPageUpdate()

static ilPCFileList::afterPageUpdate ( ilPageObject  $a_page,
DOMDocument  $a_domdoc,
string  $a_xml,
bool  $a_creation 
)
static

After page has been updated (or created)

Reimplemented from ilPageContent.

Definition at line 243 of file class.ilPCFileList.php.

248 : void {
249 if (!$a_page->getImportMode()) {
250 // pc filelist
251 $file_ids = ilObjFile::_getFilesOfObject(
252 $a_page->getParentType() . ":pg",
253 $a_page->getId(),
254 0,
255 $a_page->getLanguage()
256 );
257 self::saveFileUsage($a_page, $a_domdoc);
258
259 foreach ($file_ids as $file) { // check, whether file object can be deleted
260 if (ilObject::_exists($file) && ilObject::_lookupType($file) == "file") {
261 $file_obj = new ilObjFile($file, false);
262 $usages = $file_obj->getUsages();
263 if (count($usages) == 0) { // delete, if no usage exists
264 if ($file_obj->getMode() == "filelist") { // non-repository object
265 $file_obj->delete();
266 }
267 }
268 }
269 }
270 }
271 }
Class ilObjFile.
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

References ilObject\_exists(), ilObject\_lookupType(), ilPageObject\getId(), ilPageObject\getLanguage(), and ilPageObject\getParentType().

+ Here is the call graph for this function:

◆ appendItem()

ilPCFileList::appendItem ( int  $a_id,
string  $a_location,
string  $a_format 
)

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

54 : void {
55 // File Item
56 $new_item = $this->dom->create_element("FileItem");
57 $new_item = $this->list_node->append_child($new_item);
58
59 // Identifier
60 $id_node = $this->dom->create_element("Identifier");
61 $id_node = $new_item->append_child($id_node);
62 $id_node->set_attribute("Catalog", "ILIAS");
63 $id_node->set_attribute("Entry", "il__file_" . $a_id);
64
65 // Location
66 $loc_node = $this->dom->create_element("Location");
67 $loc_node = $new_item->append_child($loc_node);
68 $loc_node->set_attribute("Type", "LocalFile");
69 $loc_node->set_content($a_location);
70
71 // Format
72 $form_node = $this->dom->create_element("Format");
73 $form_node = $new_item->append_child($form_node);
74 $form_node->set_content($a_format);
75 }

◆ beforePageDelete()

static ilPCFileList::beforePageDelete ( ilPageObject  $a_page)
static

Before page is being deleted.

Reimplemented from ilPageContent.

Definition at line 276 of file class.ilPCFileList.php.

278 : void {
279 $files = self::collectFileItems($a_page, $a_page->getDomDoc());
280
281 // delete all file usages
282 ilObjFile::_deleteAllUsages(
283 $a_page->getParentType() . ":pg",
284 $a_page->getId(),
285 false,
286 $a_page->getLanguage()
287 );
288
289 foreach ($files as $file_id) {
290 if (ilObject::_exists($file_id)) {
291 $file_obj = new ilObjFile($file_id, false);
292 $file_obj->delete();
293 }
294 }
295 }
static collectFileItems(ilPageObject $a_page, DOMDocument $a_domdoc)
Get all file items that are used within the page.

◆ collectFileItems()

static ilPCFileList::collectFileItems ( ilPageObject  $a_page,
DOMDocument  $a_domdoc 
)
static

Get all file items that are used within the page.

Definition at line 333 of file class.ilPCFileList.php.

336 : array {
337 $xpath = new DOMXPath($a_domdoc);
338 $nodes = $xpath->query('//FileItem/Identifier');
339 $file_ids = array();
340 foreach ($nodes as $node) {
341 $id_arr = explode("_", $node->getAttribute("Entry"));
342 $file_id = $id_arr[count($id_arr) - 1];
343 if ($file_id > 0 && ($id_arr[1] == "" || $id_arr[1] == IL_INST_ID || $id_arr[1] == 0)) {
344 $file_ids[$file_id] = $file_id;
345 }
346 }
347 // file items in download links
348 $xpath = new DOMXPath($a_domdoc);
349 $nodes = $xpath->query("//IntLink[@Type='File']");
350 foreach ($nodes as $node) {
351 $t = $node->getAttribute("Target");
352 if (substr($t, 0, 9) == "il__dfile") {
353 $id_arr = explode("_", $t);
354 $file_id = $id_arr[count($id_arr) - 1];
355 $file_ids[$file_id] = $file_id;
356 }
357 }
358 return $file_ids;
359 }
php4DOMElement $node
const IL_INST_ID
Definition: constants.php:40

Referenced by ilObjTest\exportXMLPageObjects(), and ilObjQuestionPool\exportXMLPageObjects().

+ Here is the caller graph for this function:

◆ create()

ilPCFileList::create ( ilPageObject  $a_pg_obj,
string  $a_hier_id,
string  $a_pc_id = "" 
)

Definition at line 39 of file class.ilPCFileList.php.

43 : void {
44 $this->node = $this->createPageContentNode();
45 $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
46 $this->list_node = $this->dom->create_element("FileList");
47 $this->list_node = $this->node->append_child($this->list_node);
48 }
const IL_INSERT_AFTER
createPageContentNode(bool $a_set_this_node=true)
Create page content node (always use this method first when adding a new element)
insertContent(ilPageContent $a_cont_obj, string $a_pos, int $a_mode=IL_INSERT_AFTER, string $a_pcid="", bool $remove_placeholder=true)
insert a content node before/after a sibling or as first child of a parent

◆ deleteFileItems()

ilPCFileList::deleteFileItems ( array  $a_ids)

Delete file items.

Definition at line 149 of file class.ilPCFileList.php.

149 : void
150 {
151 // File Item
152 $childs = $this->list_node->child_nodes();
153
154 for ($i = 0; $i < count($childs); $i++) {
155 if ($childs[$i]->node_name() == "FileItem") {
156 $id = $entry = "";
157 $pc_id = $childs[$i]->get_attribute("PCID");
158 $hier_id = $childs[$i]->get_attribute("HierId");
159
160 if (in_array($hier_id . ":" . $pc_id, $a_ids)) {
161 $childs[$i]->unlink($childs[$i]);
162 }
163 }
164 }
165 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
$i
Definition: metadata.php:41

References $i, and $id.

◆ deleteHistoryLowerEqualThan()

static ilPCFileList::deleteHistoryLowerEqualThan ( string  $parent_type,
int  $page_id,
string  $lang,
int  $delete_lower_than_nr 
)
static

Overwrite in derived classes, if old history entries are being deleted.

Reimplemented from ilPageContent.

Definition at line 361 of file class.ilPCFileList.php.

366 : void {
368 $parent_type,
369 $page_id,
370 $delete_lower_than_nr,
371 $lang
372 );
373
374 foreach ($file_ids as $file_id) {
375 if (ilObject::_lookupType($file_id) === "file") {
376 $file = new ilObjFile($file_id, false);
377 $usages = $file->getUsages();
378 if (count($usages) == 0) {
379 $file->delete();
380 }
381 }
382 }
383 }
static _deleteHistoryUsagesLowerEqualThan(string $parent_type, int $a_id, int $a_usage_hist_nr, string $a_lang="-")
$lang
Definition: xapiexit.php:26

References ilObject\_lookupType().

+ Here is the call graph for this function:

◆ getAllClasses()

ilPCFileList::getAllClasses ( )

Get all style classes.

Definition at line 196 of file class.ilPCFileList.php.

196 : array
197 {
198 $classes = array();
199
200 // File Item
201 $childs = $this->list_node->child_nodes();
202
203 for ($i = 0; $i < count($childs); $i++) {
204 if ($childs[$i]->node_name() == "FileItem") {
205 $classes[$childs[$i]->get_attribute("HierId") . ":" .
206 $childs[$i]->get_attribute("PCID")] = $childs[$i]->get_attribute("Class");
207 }
208 }
209
210 return $classes;
211 }

References $i.

◆ getFileList()

ilPCFileList::getFileList ( )

Get list of files.

Definition at line 116 of file class.ilPCFileList.php.

116 : array
117 {
118 $files = array();
119
120 // File Item
121 $childs = $this->list_node->child_nodes();
122 for ($i = 0; $i < count($childs); $i++) {
123 if ($childs[$i]->node_name() == "FileItem") {
124 $id = $entry = "";
125 $pc_id = $childs[$i]->get_attribute("PCID");
126 $hier_id = $childs[$i]->get_attribute("HierId");
127 $class = $childs[$i]->get_attribute("Class");
128
129 // Identifier
130 $id_node = $childs[$i]->first_child();
131 if ($id_node->node_name() == "Identifier") {
132 $entry = $id_node->get_attribute("Entry");
133 if (substr($entry, 0, 9) == "il__file_") {
134 $id = substr($entry, 9);
135 }
136 }
137 $files[] = array("entry" => $entry, "id" => $id,
138 "pc_id" => $pc_id, "hier_id" => $hier_id,
139 "class" => $class);
140 }
141 }
142
143 return $files;
144 }

References $i, and $id.

◆ getLanguage()

ilPCFileList::getLanguage ( )

Definition at line 102 of file class.ilPCFileList.php.

102 : string
103 {
104 $chlds = $this->list_node->child_nodes();
105 for ($i = 0; $i < count($chlds); $i++) {
106 if ($chlds[$i]->node_name() == "Title") {
107 return $chlds[$i]->get_attribute("Language");
108 }
109 }
110 return "";
111 }

References $i.

◆ getLangVars()

static ilPCFileList::getLangVars ( )
static

Get lang vars needed for editing.

Returns
array array of lang var keys

Reimplemented from ilPageContent.

Definition at line 235 of file class.ilPCFileList.php.

235 : array
236 {
237 return array("ed_edit_files", "ed_insert_filelist", "pc_flist");
238 }

◆ getListTitle()

ilPCFileList::getListTitle ( )

Definition at line 91 of file class.ilPCFileList.php.

91 : string
92 {
93 $chlds = $this->list_node->child_nodes();
94 for ($i = 0; $i < count($chlds); $i++) {
95 if ($chlds[$i]->node_name() == "Title") {
96 return $chlds[$i]->get_content();
97 }
98 }
99 return "";
100 }

References $i.

◆ init()

ilPCFileList::init ( )

Init object.

This function must be overwritten and at least set the content type.

Reimplemented from ilPageContent.

Definition at line 28 of file class.ilPCFileList.php.

28 : void
29 {
30 $this->setType("flst");
31 }
setType(string $a_type)
Set Type.

References ilPageContent\setType().

+ Here is the call graph for this function:

◆ saveFileUsage()

static ilPCFileList::saveFileUsage ( ilPageObject  $a_page,
DOMDocument  $a_domdoc,
int  $a_old_nr = 0 
)
static

Save file usages.

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

316 : void {
317 $file_ids = self::collectFileItems($a_page, $a_domdoc);
318 ilObjFile::_deleteAllUsages($a_page->getParentType() . ":pg", $a_page->getId(), $a_old_nr, $a_page->getLanguage());
319 foreach ($file_ids as $file_id) {
320 ilObjFile::_saveUsage(
321 (int) $file_id,
322 $a_page->getParentType() . ":pg",
323 $a_page->getId(),
324 $a_old_nr,
325 $a_page->getLanguage()
326 );
327 }
328 }

◆ savePositions()

ilPCFileList::savePositions ( array  $a_pos)

Save positions of file items.

Definition at line 170 of file class.ilPCFileList.php.

170 : void
171 {
172 asort($a_pos);
173
174 // File Item
175 $childs = $this->list_node->child_nodes();
176 $nodes = array();
177 for ($i = 0; $i < count($childs); $i++) {
178 if ($childs[$i]->node_name() == "FileItem") {
179 $pc_id = $childs[$i]->get_attribute("PCID");
180 $hier_id = $childs[$i]->get_attribute("HierId");
181 $nodes[$hier_id . ":" . $pc_id] = $childs[$i];
182 $childs[$i]->unlink($childs[$i]);
183 }
184 }
185
186 foreach ($a_pos as $k => $v) {
187 if (is_object($nodes[$k])) {
188 $nodes[$k] = $this->list_node->append_child($nodes[$k]);
189 }
190 }
191 }

References $i.

◆ saveStyleClasses()

ilPCFileList::saveStyleClasses ( array  $a_class)

Save style classes of file items.

Definition at line 216 of file class.ilPCFileList.php.

216 : void
217 {
218 // File Item
219 $childs = $this->list_node->child_nodes();
220 for ($i = 0; $i < count($childs); $i++) {
221 if ($childs[$i]->node_name() == "FileItem") {
222 $childs[$i]->set_attribute(
223 "Class",
224 $a_class[$childs[$i]->get_attribute("HierId") . ":" .
225 $childs[$i]->get_attribute("PCID")]
226 );
227 }
228 }
229 }

References $i.

◆ setListTitle()

ilPCFileList::setListTitle ( string  $a_title,
string  $a_language 
)

Definition at line 77 of file class.ilPCFileList.php.

80 : void {
82 $this->dom,
83 $this->list_node,
84 "Title",
85 array("FileItem"),
86 $a_title,
87 array("Language" => $a_language)
88 );
89 }
static setFirstOptionalElement(php4DOMDocument $doc, php4DOMElement $parent_node, string $a_node_name, array $a_successors, string $a_content, array $a_attributes, bool $a_remove_childs=true)
searches for an element $a_node_name within the childs of $parent_node if no node is found,...

◆ setNode()

ilPCFileList::setNode ( php4DOMElement  $a_node)

Set xml node of page content.

Parameters
php4DOMElement$a_nodenode object

Reimplemented from ilPageContent.

Definition at line 33 of file class.ilPCFileList.php.

33 : void
34 {
35 parent::setNode($a_node); // this is the PageContent node
36 $this->list_node = $a_node->first_child(); // this is the Table node
37 }

References php4DOMNode\first_child().

+ Here is the call graph for this function:

Field Documentation

◆ $list_node

php4DOMElement ilPCFileList::$list_node

Definition at line 26 of file class.ilPCFileList.php.


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