ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 312 of file class.ilPCFileList.php.

313  {
314  self::saveFileUsage($a_page, $a_old_domdoc, $a_old_nr);
315  }

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

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

251  {
252  if (!$a_page->getImportMode()) {
253  // pc filelist
254  include_once("./Modules/File/classes/class.ilObjFile.php");
255  $file_ids = ilObjFile::_getFilesOfObject(
256  $a_page->getParentType() . ":pg",
257  $a_page->getId(),
258  0,
259  $a_page->getLanguage()
260  );
261  self::saveFileUsage($a_page, $a_domdoc);
262 
263  foreach ($file_ids as $file) { // check, whether file object can be deleted
264  if (ilObject::_exists($file) && ilObject::_lookupType($file) == "file") {
265  $file_obj = new ilObjFile($file, false);
266  $usages = $file_obj->getUsages();
267  if (count($usages) == 0) { // delete, if no usage exists
268  if ($file_obj->getMode() == "filelist") { // non-repository object
269  $file_obj->delete();
270  }
271  }
272  }
273  }
274  }
275  }
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
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 282 of file class.ilPCFileList.php.

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

283  {
284  $files = self::collectFileItems($a_page, $a_page->getDomDoc());
285 
286  // delete all file usages
287  include_once("./Modules/File/classes/class.ilObjFile.php");
289  $a_page->getParentType() . ":pg",
290  $a_page->getId(),
291  false,
292  $a_page->getLanguage()
293  );
294 
295  include_once("./Modules/File/classes/class.ilObjFile.php");
296  foreach ($files as $file_id) {
297  if (ilObject::_exists($file_id)) {
298  $file_obj = new ilObjFile($file_id, false);
299  $file_obj->delete();
300  }
301  }
302  }
$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
+ 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 339 of file class.ilPCFileList.php.

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

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

340  {
341  $xpath = new DOMXPath($a_domdoc);
342  $nodes = $xpath->query('//FileItem/Identifier');
343  $file_ids = array();
344  foreach ($nodes as $node) {
345  $id_arr = explode("_", $node->getAttribute("Entry"));
346  $file_id = $id_arr[count($id_arr) - 1];
347  if ($file_id > 0 && ($id_arr[1] == "" || $id_arr[1] == IL_INST_ID || $id_arr[1] == 0)) {
348  $file_ids[$file_id] = $file_id;
349  }
350  }
351  // file items in download links
352  $xpath = new DOMXPath($a_domdoc);
353  $nodes = $xpath->query("//IntLink[@Type='File']");
354  foreach ($nodes as $node) {
355  $t = $node->getAttribute("Target");
356  if (substr($t, 0, 9) == "il__dfile") {
357  $id_arr = explode("_", $t);
358  $file_id = $id_arr[count($id_arr) - 1];
359  $file_ids[$file_id] = $file_id;
360  }
361  }
362  return $file_ids;
363  }
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 148 of file class.ilPCFileList.php.

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

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

◆ getAllClasses()

ilPCFileList::getAllClasses ( )

Get all style classes.

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

References $i, and array.

199  {
200  $classes = array();
201 
202  // File Item
203  $childs = $this->list_node->child_nodes();
204 
205  for ($i=0; $i<count($childs); $i++) {
206  if ($childs[$i]->node_name() == "FileItem") {
207  $classes[$childs[$i]->get_attribute("HierId") . ":" .
208  $childs[$i]->get_attribute("PCID")] = $childs[$i]->get_attribute("Class");
209  }
210  }
211 
212  return $classes;
213  }
Create styles array
The data for the language used.
$i
Definition: disco.tpl.php:19

◆ getFileList()

ilPCFileList::getFileList ( )

Get list of files.

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

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

116  {
117  $files = array();
118 
119  // File Item
120  $childs = $this->list_node->child_nodes();
121  for ($i=0; $i<count($childs); $i++) {
122  if ($childs[$i]->node_name() == "FileItem") {
123  $id = $entry = "";
124  $pc_id = $childs[$i]->get_attribute("PCID");
125  $hier_id = $childs[$i]->get_attribute("HierId");
126  $class = $childs[$i]->get_attribute("Class");
127 
128  // Identifier
129  $id_node = $childs[$i]->first_child();
130  if ($id_node->node_name() == "Identifier") {
131  $entry = $id_node->get_attribute("Entry");
132  if (substr($entry, 0, 9) == "il__file_") {
133  $id = substr($entry, 9);
134  }
135  }
136  $files[] = array("entry" => $entry, "id" => $id,
137  "pc_id" => $pc_id, "hier_id" => $hier_id,
138  "class" => $class);
139  }
140  }
141 
142  return $files;
143  }
$files
Definition: add-vimline.php:18
if(!array_key_exists('StateId', $_REQUEST)) $id
Create styles array
The data for the language used.
$i
Definition: disco.tpl.php:19

◆ getLanguage()

ilPCFileList::getLanguage ( )

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

References $i.

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

◆ getLangVars()

static ilPCFileList::getLangVars ( )
static

Get lang vars needed for editing.

Returns
array array of lang var keys

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

References array.

238  {
239  return array("ed_edit_files", "ed_insert_filelist", "pc_flist");
240  }
Create styles array
The data for the language used.

◆ getListTitle()

ilPCFileList::getListTitle ( )

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

References $i.

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

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

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

321  {
322  $file_ids = self::collectFileItems($a_page, $a_domdoc);
323  include_once("./Modules/File/classes/class.ilObjFile.php");
324  ilObjFile::_deleteAllUsages($a_page->getParentType() . ":pg", $a_page->getId(), $a_old_nr, $a_page->getLanguage());
325  foreach ($file_ids as $file_id) {
327  $file_id,
328  $a_page->getParentType() . ":pg",
329  $a_page->getId(),
330  $a_old_nr,
331  $a_page->getLanguage()
332  );
333  }
334  }
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 171 of file class.ilPCFileList.php.

References ilPageContent\$hier_id, $i, $id, and array.

172  {
173  asort($a_pos);
174 
175  // File Item
176  $childs = $this->list_node->child_nodes();
177  $nodes = array();
178  for ($i=0; $i<count($childs); $i++) {
179  if ($childs[$i]->node_name() == "FileItem") {
180  $id = $entry = "";
181  $pc_id = $childs[$i]->get_attribute("PCID");
182  $hier_id = $childs[$i]->get_attribute("HierId");
183  $nodes[$hier_id . ":" . $pc_id] = $childs[$i];
184  $childs[$i]->unlink($childs[$i]);
185  }
186  }
187 
188  foreach ($a_pos as $k => $v) {
189  if (is_object($nodes[$k])) {
190  $nodes[$k] = $this->list_node->append_child($nodes[$k]);
191  }
192  }
193  }
if(!array_key_exists('StateId', $_REQUEST)) $id
Create styles array
The data for the language used.
$i
Definition: disco.tpl.php:19

◆ saveStyleClasses()

ilPCFileList::saveStyleClasses (   $a_class)

Save style classes of file items.

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

References $i.

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

◆ setListTitle()

ilPCFileList::setListTitle (   $a_title,
  $a_language 
)

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

References array, and ilDOMUtil\setFirstOptionalElement().

79  {
81  $this->dom,
82  $this->list_node,
83  "Title",
84  array("FileItem"),
85  $a_title,
86  array("Language" => $a_language)
87  );
88  }
Create styles array
The data for the language used.
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...
+ 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: