ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilPCFileList Class Reference

Class ilPCFileList. More...

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

Public Member Functions

 init ()
 Init page content component. More...
 
 setNode ($a_node)
 
 create (&$a_pg_obj, $a_hier_id, $a_pc_id="")
 
 appendItem ($a_id, $a_location, $a_format)
 
 setListTitle ($a_title, $a_language)
 
 getListTitle ()
 
 getLanguage ()
 
 getFileList ()
 Get list of files. More...
 
 deleteFileItems ($a_ids)
 Delete file items. More...
 
 savePositions ($a_pos)
 Save positions of file items. More...
 
 getAllClasses ()
 Get all style classes. More...
 
 saveStyleClasses ($a_class)
 Save style classes of file items. More...
 
- Public Member Functions inherited from ilPageContent
 __construct ($a_pg_obj)
 Constructor. More...
 
 setPage ($a_val)
 Set page. More...
 
 getPage ()
 Get page. More...
 
 init ()
 Init object. More...
 
 getType ()
 Get type of page content. More...
 
 setNode ($a_node)
 Set xml node of page content. More...
 
getNode ()
 Get xml node of page content. More...
 
 getJavascriptFiles ($a_mode)
 Get Javascript files. More...
 
 getCssFiles ($a_mode)
 Get css files. More...
 
 getOnloadCode ($a_mode)
 Get on load code. More...
 
 setHierId ($a_hier_id)
 Set hierarchical ID in xml structure. More...
 
 getHierId ()
 Get hierarchical id. More...
 
 lookupHierId ()
 Get hierarchical id from dom. More...
 
 readHierId ()
 Read PC Id. More...
 
 setPcId ($a_pcid)
 Set PC Id. More...
 
 getPCId ()
 Get PC Id. More...
 
 setFileDownloadLink ($a_download_link)
 Set file download link. More...
 
 getFileDownloadLink ()
 Get file download link. More...
 
 setFullscreenLink ($a_fullscreen_link)
 Set fullscreen link. More...
 
 getFullscreenLink ()
 Get fullscreen link. More...
 
 setSourcecodeDownloadScript ($script_name)
 Set sourcecode download script. More...
 
 getSourcecodeDownloadScript ()
 Get sourcecode download script. More...
 
 readPCId ()
 Read PC Id. More...
 
 writePCId ($a_pc_id)
 Write pc id. More...
 
 setEnabled ($value)
 Set Enabled value for page content component. More...
 
 enable ()
 Enable page content. More...
 
 disable ()
 Disable page content. More...
 
 isEnabled ()
 Check whether page content is enabled. More...
 
 createPageContentNode ($a_set_this_node=true)
 Create page content node (always use this method first when adding a new element) More...
 
 modifyPageContentPostXsl ($a_output, $a_mode)
 Modify page content after xsl. More...
 

Static Public Member Functions

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

Data Fields

 $list_node
 
- Data Fields inherited from ilPageContent
 $hier_id
 
 $node
 
 $dom
 
 $page_lang
 

Additional Inherited Members

- Protected Member Functions inherited from ilPageContent
 setType ($a_type)
 Set Type. More...
 
- Protected Attributes inherited from ilPageContent
 $file_download_link
 
 $fullscreen_link
 
 $sourcecode_download_script
 
 $log
 

Detailed Description

Class ilPCFileList.

File List content object (see ILIAS DTD)

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

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

Member Function Documentation

◆ afterPageHistoryEntry()

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

After page history entry has been created.

Parameters
object$a_pagepage object
DOMDocument$a_old_domdocold dom document
string$a_old_xmlold xml
integer$a_old_nrhistory number

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

325  {
326  self::saveFileUsage($a_page, $a_old_domdoc, $a_old_nr);
327  }

◆ afterPageUpdate()

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

After page has been updated (or created)

Parameters
object$a_pagepage object
DOMDocument$a_domdocdom document
string$a_xmlxml
bool$a_creationtrue on creation, otherwise false

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

References $file, ilObject\_exists(), ilObjFile\_getFilesOfObject(), and ilObject\_lookupType().

263  {
264  if (!$a_page->getImportMode())
265  {
266  // pc filelist
267  include_once("./Modules/File/classes/class.ilObjFile.php");
268  $file_ids = ilObjFile::_getFilesOfObject(
269  $a_page->getParentType().":pg", $a_page->getId(), 0, $a_page->getLanguage());
270  self::saveFileUsage($a_page, $a_domdoc);
271 
272  foreach($file_ids as $file) // check, whether file object can be deleted
273  {
274  if (ilObject::_exists($file) && ilObject::_lookupType($file) == "file")
275  {
276  $file_obj = new ilObjFile($file, false);
277  $usages = $file_obj->getUsages();
278  if (count($usages) == 0) // delete, if no usage exists
279  {
280  if ($file_obj->getMode() == "filelist") // non-repository object
281  {
282  $file_obj->delete();
283  }
284  }
285  }
286  }
287  }
288 
289  }
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
Class ilObjFile.
static _getFilesOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_usage_lang="-")
get all files of an object
static _lookupType($a_id, $a_reference=false)
lookup object type
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
+ Here is the call graph for this function:

◆ appendItem()

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

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

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

◆ beforePageDelete()

static ilPCFileList::beforePageDelete (   $a_page)
static

Before page is being deleted.

Parameters
object$a_pagepage object

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

References $files, ilObjFile\_deleteAllUsages(), and ilObject\_exists().

297  {
298  $files = self::collectFileItems($a_page, $a_page->getDomDoc());
299 
300  // delete all file usages
301  include_once("./Modules/File/classes/class.ilObjFile.php");
302  ilObjFile::_deleteAllUsages($a_page->getParentType().":pg", $a_page->getId(), false,
303  $a_page->getLanguage());
304 
305  include_once("./Modules/File/classes/class.ilObjFile.php");
306  foreach ($files as $file_id)
307  {
308  if (ilObject::_exists($file_id))
309  {
310  $file_obj = new ilObjFile($file_id, false);
311  $file_obj->delete();
312  }
313  }
314  }
$files
Definition: add-vimline.php:18
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
static _deleteAllUsages($a_type, $a_id, $a_usage_hist_nr=0, $a_usage_lang="-")
static delete all usages of
Class ilObjFile.
+ Here is the call graph for this function:

◆ collectFileItems()

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

Get all file items that are used within the page.

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

References ilPageContent\$node, $t, and array.

Referenced by ilPageObjectGUI\downloadFile(), ilSCORM2004Asset\exportHTMLPageObjects(), ilObjGlossary\exportXML(), ilGlossaryDefinition\exportXMLDefinition(), ilSCORM2004Page\exportXMLPageContent(), ilLMPageObject\exportXMLPageContent(), ilObjQuestionPool\exportXMLPageObjects(), ilObjTest\exportXMLPageObjects(), ilSCORM2004ScoGUI\getExportResources(), and ilContObjectManifestBuilder\writeResources().

348  {
349  $xpath = new DOMXPath($a_domdoc);
350  $nodes = $xpath->query('//FileItem/Identifier');
351  $file_ids = array();
352  foreach($nodes as $node)
353  {
354  $id_arr = explode("_", $node->getAttribute("Entry"));
355  $file_id = $id_arr[count($id_arr) - 1];
356  if ($file_id > 0 && ($id_arr[1] == "" || $id_arr[1] == IL_INST_ID || $id_arr[1] == 0))
357  {
358  $file_ids[$file_id] = $file_id;
359  }
360  }
361  // file items in download links
362  $xpath = new DOMXPath($a_domdoc);
363  $nodes = $xpath->query("//IntLink[@Type='File']");
364  foreach($nodes as $node)
365  {
366  $t = $node->getAttribute("Target");
367  if (substr($t, 0, 9) == "il__dfile")
368  {
369  $id_arr = explode("_", $t);
370  $file_id = $id_arr[count($id_arr) - 1];
371  $file_ids[$file_id] = $file_id;
372  }
373  }
374  return $file_ids;
375  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ create()

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

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

References ilPageContent\createPageContentNode(), and IL_INSERT_AFTER.

37  {
38  $this->node = $this->createPageContentNode();
39  $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
40  $this->list_node = $this->dom->create_element("FileList");
41  $this->list_node = $this->node->append_child($this->list_node);
42  }
const IL_INSERT_AFTER
createPageContentNode($a_set_this_node=true)
Create page content node (always use this method first when adding a new element) ...
+ Here is the call graph for this function:

◆ deleteFileItems()

ilPCFileList::deleteFileItems (   $a_ids)

Delete file items.

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

References $files, ilPageContent\$hier_id, and array.

152  {
153  $files = array();
154 
155  // File Item
156  $childs = $this->list_node->child_nodes();
157 
158  for ($i=0; $i<count($childs); $i++)
159  {
160  if ($childs[$i]->node_name() == "FileItem")
161  {
162  $id = $entry = "";
163  $pc_id = $childs[$i]->get_attribute("PCID");
164  $hier_id = $childs[$i]->get_attribute("HierId");
165 
166  if (in_array($hier_id.":".$pc_id, $a_ids))
167  {
168  $childs[$i]->unlink($childs[$i]);
169  }
170  }
171  }
172  }
$files
Definition: add-vimline.php:18
Create styles array
The data for the language used.

◆ getAllClasses()

ilPCFileList::getAllClasses ( )

Get all style classes.

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

References array.

209  {
210  $classes = array();
211 
212  // File Item
213  $childs = $this->list_node->child_nodes();
214 
215  for ($i=0; $i<count($childs); $i++)
216  {
217  if ($childs[$i]->node_name() == "FileItem")
218  {
219  $classes[$childs[$i]->get_attribute("HierId").":".
220  $childs[$i]->get_attribute("PCID")] = $childs[$i]->get_attribute("Class");
221  }
222  }
223 
224  return $classes;
225  }
Create styles array
The data for the language used.

◆ getFileList()

ilPCFileList::getFileList ( )

Get list of files.

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

References $files, ilPageContent\$hier_id, and array.

115  {
116  $files = array();
117 
118  // File Item
119  $childs = $this->list_node->child_nodes();
120  for ($i=0; $i<count($childs); $i++)
121  {
122  if ($childs[$i]->node_name() == "FileItem")
123  {
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  {
133  $entry = $id_node->get_attribute("Entry");
134  if (substr($entry, 0, 9) == "il__file_")
135  {
136  $id = substr($entry, 9);
137  }
138  }
139  $files[] = array("entry" => $entry, "id" => $id,
140  "pc_id" => $pc_id, "hier_id" => $hier_id,
141  "class" => $class);
142  }
143  }
144 
145  return $files;
146  }
$files
Definition: add-vimline.php:18
Create styles array
The data for the language used.

◆ getLanguage()

ilPCFileList::getLanguage ( )

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

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

◆ getLangVars()

static ilPCFileList::getLangVars ( )
static

Get lang vars needed for editing.

Returns
array array of lang var keys

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

References array.

250  {
251  return array("ed_edit_files", "ed_insert_filelist", "pc_flist");
252  }
Create styles array
The data for the language used.

◆ getListTitle()

ilPCFileList::getListTitle ( )

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

86  {
87  $chlds = $this->list_node->child_nodes();
88  for($i=0; $i<count($chlds); $i++)
89  {
90  if ($chlds[$i]->node_name() == "Title")
91  {
92  return $chlds[$i]->get_content();
93  }
94  }
95  return "";
96  }

◆ init()

ilPCFileList::init ( )

Init page content component.

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

References ilPageContent\setType().

26  {
27  $this->setType("flst");
28  }
setType($a_type)
Set Type.
+ Here is the call graph for this function:

◆ saveFileUsage()

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

Save file usages.

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

References ilObjFile\_deleteAllUsages(), and ilObjFile\_saveUsage().

333  {
334  $file_ids = self::collectFileItems($a_page, $a_domdoc);
335  include_once("./Modules/File/classes/class.ilObjFile.php");
336  ilObjFile::_deleteAllUsages($a_page->getParentType().":pg", $a_page->getId(), $a_old_nr, $a_page->getLanguage());
337  foreach($file_ids as $file_id)
338  {
339  ilObjFile::_saveUsage($file_id, $a_page->getParentType().":pg", $a_page->getId(), $a_old_nr,
340  $a_page->getLanguage());
341  }
342  }
static _deleteAllUsages($a_type, $a_id, $a_usage_hist_nr=0, $a_usage_lang="-")
static delete all usages of
static _saveUsage($a_file_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_usage_lang="-")
save usage
+ Here is the call graph for this function:

◆ savePositions()

ilPCFileList::savePositions (   $a_pos)

Save positions of file items.

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

References ilPageContent\$hier_id, and array.

178  {
179  asort($a_pos);
180 
181  // File Item
182  $childs = $this->list_node->child_nodes();
183  $nodes = array();
184  for ($i=0; $i<count($childs); $i++)
185  {
186  if ($childs[$i]->node_name() == "FileItem")
187  {
188  $id = $entry = "";
189  $pc_id = $childs[$i]->get_attribute("PCID");
190  $hier_id = $childs[$i]->get_attribute("HierId");
191  $nodes[$hier_id.":".$pc_id] = $childs[$i];
192  $childs[$i]->unlink($childs[$i]);
193  }
194  }
195 
196  foreach($a_pos as $k => $v)
197  {
198  if (is_object($nodes[$k]))
199  {
200  $nodes[$k] = $this->list_node->append_child($nodes[$k]);
201  }
202  }
203  }
Create styles array
The data for the language used.

◆ saveStyleClasses()

ilPCFileList::saveStyleClasses (   $a_class)

Save style classes of file items.

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

231  {
232  // File Item
233  $childs = $this->list_node->child_nodes();
234  for ($i=0; $i<count($childs); $i++)
235  {
236  if ($childs[$i]->node_name() == "FileItem")
237  {
238  $childs[$i]->set_attribute("Class",
239  $a_class[$childs[$i]->get_attribute("HierId").":".
240  $childs[$i]->get_attribute("PCID")]);
241  }
242  }
243  }

◆ setListTitle()

ilPCFileList::setListTitle (   $a_title,
  $a_language 
)

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

References array, and ilDOMUtil\setFirstOptionalElement().

79  {
81  $this->list_node, "Title", array("FileItem"),
82  $a_title, array("Language" => $a_language));
83  }
static setFirstOptionalElement($doc, $parent_node, $a_node_name, $a_successors, $a_content, $a_attributes, $a_remove_childs=true)
searches for an element $a_node_name within the childs of $parent_node if no node is found...
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ setNode()

ilPCFileList::setNode (   $a_node)

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

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

Field Documentation

◆ $list_node

ilPCFileList::$list_node

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


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