ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 ()
 
 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, ?PageManagerInterface $page_manager=null, ?ObjectAdapterInterface $object_adapter=null)
 
 setPage (ilPageObject $a_val)
 
 getPage ()
 
 init ()
 Init object. More...
 
 getType ()
 
 getDomNode ()
 
 getDomDoc ()
 
 setDomNode (DOMNode $node)
 
 getChildNode ()
 
 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...
 
 getNewPageContentNode ()
 
 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)
 
- Static Public Member Functions inherited from ilPageContent
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...
 

Static Protected Member Functions

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

Additional Inherited Members

- Data Fields inherited from ilPageContent
string $hier_id = ""
 
DOMNode $dom_node = null
 
string $page_lang = ""
 
- Protected Member Functions inherited from ilPageContent
 getPageManager ()
 
 setType (string $a_type)
 Set Type. More...
 
 hasNode ()
 
 createInitialChildNode (string $hier_id, string $pc_id, string $child, array $child_attributes=[])
 
- Protected Attributes inherited from ilPageContent
DOMDocument $dom_doc
 
ILIAS COPage InternalDomainService $domain
 
string $pcid
 
string $type = ""
 
ilPageObject $pg_obj
 
string $file_download_link
 
string $fullscreen_link
 
string $sourcecode_download_script
 
ilLogger $log
 
string $profile_back_url = ""
 
ILIAS COPage Dom DomUtil $dom_util
 
PageManagerInterface $page_manager = null
 
ObjectAdapterInterface $object = null
 

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 363 of file class.ilPCFileList.php.

References $DIC.

368  : array {
369  global $DIC;
370 
371  $hist_repo = $DIC->copage()->internal()->repo()->history();
372 
373  $file_ids = [];
374  foreach ($hist_repo->getHistoryNumbersOlderEqualThanNr(
375  $a_usage_hist_nr,
376  $parent_type,
377  $a_id,
378  $a_lang
379  ) as $old_nr) {
380  foreach (ilObjFile::_getFilesOfObject($parent_type . ":pg", $a_id, $old_nr, $a_lang) as $file_id) {
381  $file_ids[$file_id] = $file_id;
382  }
383  ilObjFile::_deleteAllUsages($parent_type . ":pg", $a_id, $old_nr, $a_lang);
384  }
385  return $file_ids;
386  }
global $DIC
Definition: shib_login.php:22

◆ 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.

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

283  : void {
284  self::saveFileUsage($a_page, $a_old_domdoc, $a_old_nr);
285  }

◆ afterPageUpdate()

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

After page has been updated (or created)

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

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

226  : void {
227  if (!$a_page->getImportMode()) {
228  // pc filelist
229  $file_ids = ilObjFile::_getFilesOfObject(
230  $a_page->getParentType() . ":pg",
231  $a_page->getId(),
232  0,
233  $a_page->getLanguage()
234  );
235  self::saveFileUsage($a_page, $a_domdoc);
236 
237  foreach ($file_ids as $file) { // check, whether file object can be deleted
238  if (ilObject::_exists($file) && ilObject::_lookupType($file) == "file") {
239  $file_obj = new ilObjFile($file, false);
240  $usages = $file_obj->getUsages();
241  if (count($usages) == 0) { // delete, if no usage exists
242  if ($file_obj->getMode() == "filelist") { // non-repository object
243  $file_obj->delete();
244  }
245  }
246  }
247  }
248  }
249  }
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
Class ilObjFile.
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:

◆ appendItem()

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

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

References ilPageContent\getChildNode().

43  : void {
44  // File Item
45  $new_item = $this->dom_doc->createElement("FileItem");
46  $new_item = $this->getChildNode()->appendChild($new_item);
47 
48  // Identifier
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);
53 
54  // Location
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);
59 
60  // Format
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);
64  }
+ Here is the call graph for this function:

◆ beforePageDelete()

static ilPCFileList::beforePageDelete ( ilPageObject  $a_page)
static

Before page is being deleted.

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

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

256  : void {
257  $files = self::collectFileItems($a_page, $a_page->getDomDoc());
258 
259  // delete all file usages
260  ilObjFile::_deleteAllUsages(
261  $a_page->getParentType() . ":pg",
262  $a_page->getId(),
263  false,
264  $a_page->getLanguage()
265  );
266 
267  foreach ($files as $file_id) {
268  if (ilObject::_exists($file_id)) {
269  $file_obj = new ilObjFile($file_id, false);
270  $file_obj->delete();
271  }
272  }
273  }
getDomDoc()
Get dom doc (DOMDocument)
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
Class ilObjFile.
+ Here is the call graph for this function:

◆ collectFileItems()

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

Get all file items that are used within the page.

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

References IL_INST_ID.

Referenced by ilObjTest\addQTIMaterial(), ilLMPageObject\exportXMLPageContent(), ilObjQuestionPool\exportXMLPageObjects(), and ilObjTest\exportXMLPageObjects().

314  : array {
315  $xpath = new DOMXPath($a_domdoc);
316  $nodes = $xpath->query('//FileItem/Identifier');
317  $file_ids = array();
318  foreach ($nodes as $node) {
319  $id_arr = explode("_", $node->getAttribute("Entry"));
320  $file_id = $id_arr[count($id_arr) - 1];
321  if ($file_id > 0 && ($id_arr[1] == "" || $id_arr[1] == IL_INST_ID || $id_arr[1] == 0)) {
322  $file_ids[$file_id] = $file_id;
323  }
324  }
325  // file items in download links
326  $xpath = new DOMXPath($a_domdoc);
327  $nodes = $xpath->query("//IntLink[@Type='File']");
328  foreach ($nodes as $node) {
329  $t = $node->getAttribute("Target");
330  if (substr($t, 0, 9) == "il__dfile") {
331  $id_arr = explode("_", $t);
332  $file_id = $id_arr[count($id_arr) - 1];
333  $file_ids[$file_id] = $file_id;
334  }
335  }
336  return $file_ids;
337  }
const IL_INST_ID
Definition: constants.php:40
+ 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 31 of file class.ilPCFileList.php.

References ilPageContent\createInitialChildNode().

35  : void {
36  $this->createInitialChildNode($a_hier_id, $a_pc_id, "FileList");
37  }
createInitialChildNode(string $hier_id, string $pc_id, string $child, array $child_attributes=[])
+ Here is the call graph for this function:

◆ deleteFileItems()

ilPCFileList::deleteFileItems ( array  $a_ids)

Delete file items.

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

References $c, ilPageContent\$hier_id, $id, and ilPageContent\getChildNode().

134  : void
135  {
136  // File Item
137  foreach ($this->getChildNode()->childNodes as $c) {
138  if ($c->nodeName === "FileItem") {
139  $id = $entry = "";
140  $pc_id = $c->getAttribute("PCID");
141  $hier_id = $c->getAttribute("HierId");
142 
143  if (in_array($hier_id . ":" . $pc_id, $a_ids)) {
144  $c->parentNode->removeChild($c);
145  }
146  }
147  }
148  }
$c
Definition: deliver.php:25
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ deleteHistoryLowerEqualThan()

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

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

References ilObject\_lookupType().

344  : void {
345  $file_ids = self::_deleteHistoryUsagesLowerEqualThan(
346  $parent_type,
347  $page_id,
348  $delete_lower_than_nr,
349  $lang
350  );
351 
352  foreach ($file_ids as $file_id) {
353  if (ilObject::_lookupType($file_id) === "file") {
354  $file = new ilObjFile($file_id, false);
355  $usages = $file->getUsages();
356  if (count($usages) == 0) {
357  $file->delete();
358  }
359  }
360  }
361  }
Class ilObjFile.
$lang
Definition: xapiexit.php:25
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:

◆ getAllClasses()

ilPCFileList::getAllClasses ( )

Get all style classes.

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

References $c, and ilPageContent\getChildNode().

177  : array
178  {
179  $classes = array();
180 
181  // File Item
182  foreach ($this->getChildNode()->childNodes as $c) {
183  if ($c->nodeName === "FileItem") {
184  $classes[$c->getAttribute("HierId") . ":" .
185  $c->getAttribute("PCID")] = $c->getAttribute("Class");
186  }
187  }
188 
189  return $classes;
190  }
$c
Definition: deliver.php:25
+ Here is the call graph for this function:

◆ getFileList()

ilPCFileList::getFileList ( )

Get list of files.

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

References $c, ilPageContent\$hier_id, $id, and ilPageContent\getChildNode().

102  : array
103  {
104  $files = array();
105 
106  // File Item
107  foreach ($this->getChildNode()->childNodes as $c) {
108  if ($c->nodeName === "FileItem") {
109  $id = $entry = "";
110  $pc_id = $c->getAttribute("PCID");
111  $hier_id = $c->getAttribute("HierId");
112  $class = $c->getAttribute("Class");
113 
114  // Identifier
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);
120  }
121  }
122  $files[] = array("entry" => $entry, "id" => $id,
123  "pc_id" => $pc_id, "hier_id" => $hier_id,
124  "class" => $class);
125  }
126  }
127 
128  return $files;
129  }
$c
Definition: deliver.php:25
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ getLanguage()

ilPCFileList::getLanguage ( )

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

References $c, and ilPageContent\getChildNode().

89  : string
90  {
91  foreach ($this->getChildNode()->childNodes as $c) {
92  if ($c->nodeName === "Title") {
93  return $c->getAttribute("Language");
94  }
95  }
96  return "";
97  }
$c
Definition: deliver.php:25
+ Here is the call graph for this function:

◆ getLangVars()

static ilPCFileList::getLangVars ( )
static

Get lang vars needed for editing.

Returns
array array of lang var keys

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

213  : array
214  {
215  return array("ed_edit_files", "ed_insert_filelist", "pc_flist");
216  }

◆ getListTitle()

ilPCFileList::getListTitle ( )

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

References $c, and ilPageContent\getChildNode().

79  : string
80  {
81  foreach ($this->getChildNode()->childNodes as $c) {
82  if ($c->nodeName === "Title") {
83  return $c->nodeValue;
84  }
85  }
86  return "";
87  }
$c
Definition: deliver.php:25
+ Here is the call graph for this function:

◆ init()

ilPCFileList::init ( )

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

References ilPageContent\setType().

26  : void
27  {
28  $this->setType("flst");
29  }
setType(string $a_type)
Set Type.
+ 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 290 of file class.ilPCFileList.php.

References ilPageObject\getId(), ilPageObject\getLanguage(), and ilPageObject\getParentType().

294  : void {
295  $file_ids = self::collectFileItems($a_page, $a_domdoc);
296  ilObjFile::_deleteAllUsages($a_page->getParentType() . ":pg", $a_page->getId(), $a_old_nr, $a_page->getLanguage());
297  foreach ($file_ids as $file_id) {
298  ilObjFile::_saveUsage(
299  (int) $file_id,
300  $a_page->getParentType() . ":pg",
301  $a_page->getId(),
302  $a_old_nr,
303  $a_page->getLanguage()
304  );
305  }
306  }
+ Here is the call graph for this function:

◆ savePositions()

ilPCFileList::savePositions ( array  $a_pos)

Save positions of file items.

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

References $c, ilPageContent\$hier_id, and ilPageContent\getChildNode().

153  : void
154  {
155  asort($a_pos);
156 
157  // File Item
158  $nodes = array();
159  foreach ($this->getChildNode()->childNodes as $c) {
160  if ($c->nodeName === "FileItem") {
161  $pc_id = $c->getAttribute("PCID");
162  $hier_id = $c->getAttribute("HierId");
163  $nodes[$hier_id . ":" . $pc_id] = $c;
164  }
165  }
166  $this->dom_util->deleteAllChildsByName($this->getChildNode(), ["FileItem"]);
167  foreach ($a_pos as $k => $v) {
168  if (is_object($nodes[$k])) {
169  $nodes[$k] = $this->getChildNode()->appendChild($nodes[$k]);
170  }
171  }
172  }
$c
Definition: deliver.php:25
+ Here is the call graph for this function:

◆ saveStyleClasses()

ilPCFileList::saveStyleClasses ( array  $a_class)

Save style classes of file items.

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

References $c, and ilPageContent\getChildNode().

195  : void
196  {
197  // File Item
198  foreach ($this->getChildNode()->childNodes as $c) {
199  if ($c->nodeName == "FileItem") {
200  $c->setAttribute(
201  "Class",
202  $a_class[$c->getAttribute("HierId") . ":" .
203  $c->getAttribute("PCID")]
204  );
205  }
206  }
207  }
$c
Definition: deliver.php:25
+ Here is the call graph for this function:

◆ setListTitle()

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

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

References ilPageContent\getChildNode().

69  : void {
70  $this->dom_util->setFirstOptionalElement(
71  $this->getChildNode(),
72  "Title",
73  array("FileItem"),
74  $a_title,
75  array("Language" => $a_language)
76  );
77  }
+ Here is the call graph for this function:

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