ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilPCFileList Class Reference

Class ilPCFileList. More...

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

Public Member Functions

 init ()
 Init page content component.
 setNode (&$a_node)
 Set xml node of page content.
 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.
 deleteFileItems ($a_ids)
 Delete file items.
 savePositions ($a_pos)
 Save positions of file items.
 getAllClasses ()
 Get all style classes.
 saveStyleClasses ($a_class)
 Save style classes of file items.
- Public Member Functions inherited from ilPageContent
 __construct ($a_pg_obj)
 Constructor.
 setPage ($a_val)
 Set page.
 getPage ()
 Get page.
 getType ()
 Get type of page content.
getNode ()
 Get xml node of page content.
 getJavascriptFiles ()
 Get Javascript files.
 getCssFiles ()
 Get css files.
 setHierId ($a_hier_id)
 Set hierarchical ID in xml structure.
 getHierId ()
 Get hierarchical id.
 lookupHierId ()
 Get hierarchical id from dom.
 readHierId ()
 Read PC Id.
 setPcId ($a_pcid)
 Set PC Id.
 getPCId ()
 Get PC Id.
 readPCId ()
 Read PC Id.
 writePCId ($a_pc_id)
 Write pc id.
 isGreaterHierId ($a, $b)
 Check whether Hier ID $a is greater than Hier ID $b.
 setEnabled ($value)
 Set Enabled value for page content component.
 enable ()
 Enable page content.
 disable ()
 Disable page content.
 isEnabled ()
 Check whether page content is enabled.
 createPageContentNode ($a_set_this_node=true)
 Create page content node (always use this method first when adding a new element)
 modifyPageContentPostXsl ($a_output, $a_mode)
 Modify page content after xsl.

Static Public Member Functions

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

Data Fields

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

Additional Inherited Members

- Protected Member Functions inherited from ilPageContent
 setType ($a_type)
 Set Type.

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:
class.ilPCFileList.php 60665 2015-09-10 09:11:11Z gitmgr

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

Member Function Documentation

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

Reimplemented from ilPageContent.

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

References saveFileUsage().

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

+ Here is the call graph for this function:

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

Reimplemented from ilPageContent.

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

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

{
// pc filelist
include_once("./Modules/File/classes/class.ilObjFile.php");
$a_page->getParentType().":pg", $a_page->getId(), 0, $a_page->getLanguage());
self::saveFileUsage($a_page, $a_domdoc);
foreach($file_ids as $file) // check, whether file object can be deleted
{
if (ilObject::_exists($file))
{
$file_obj = new ilObjFile($file, false);
$usages = $file_obj->getUsages();
if (count($usages) == 0) // delete, if no usage exists
{
if ($file_obj->getMode() == "filelist") // non-repository object
{
$file_obj->delete();
}
}
}
}
}

+ Here is the call graph for this function:

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

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

{
// File Item
$new_item =& $this->dom->create_element("FileItem");
$new_item =& $this->list_node->append_child($new_item);
// Identifier
$id_node =& $this->dom->create_element("Identifier");
$id_node =& $new_item->append_child($id_node);
$id_node->set_attribute("Catalog", "ILIAS");
$id_node->set_attribute("Entry", "il__file_".$a_id);
// Location
$loc_node =& $this->dom->create_element("Location");
$loc_node =& $new_item->append_child($loc_node);
$loc_node->set_attribute("Type", "LocalFile");
$loc_node->set_content($a_location);
// Format
$form_node =& $this->dom->create_element("Format");
$form_node =& $new_item->append_child($form_node);
$form_node->set_content($a_format);
}
static ilPCFileList::beforePageDelete (   $a_page)
static

Before page is being deleted.

Parameters
object$a_pagepage object

Reimplemented from ilPageContent.

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

References ilObjFile\_deleteAllUsages(), ilObject\_exists(), and collectFileItems().

{
$files = self::collectFileItems($a_page, $a_page->getDomDoc());
// delete all file usages
include_once("./Modules/File/classes/class.ilObjFile.php");
ilObjFile::_deleteAllUsages($a_page->getParentType().":pg", $a_page->getId(), false,
$a_page->getLanguage());
include_once("./Modules/File/classes/class.ilObjFile.php");
foreach ($files as $file_id)
{
if (ilObject::_exists($file_id))
{
$file_obj = new ilObjFile($file_id, false);
$file_obj->delete();
}
}
}

+ Here is the call graph for this function:

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

Get all file items that are used within the page.

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

References ilPageContent\$node, and $t.

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

{
$xpath = new DOMXPath($a_domdoc);
$nodes = $xpath->query('//FileItem/Identifier');
$file_ids = array();
foreach($nodes as $node)
{
$id_arr = explode("_", $node->getAttribute("Entry"));
$file_id = $id_arr[count($id_arr) - 1];
if ($file_id > 0 && ($id_arr[1] == "" || $id_arr[1] == IL_INST_ID || $id_arr[1] == 0))
{
$file_ids[$file_id] = $file_id;
}
}
// file items in download links
$xpath = new DOMXPath($a_domdoc);
$nodes = $xpath->query("//IntLink[@Type='File']");
foreach($nodes as $node)
{
$t = $node->getAttribute("Target");
if (substr($t, 0, 9) == "il__dfile")
{
$id_arr = explode("_", $t);
$file_id = $id_arr[count($id_arr) - 1];
$file_ids[$file_id] = $file_id;
}
}
return $file_ids;
}

+ Here is the caller graph for this function:

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.

{
$this->node = $this->createPageContentNode();
$a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
$this->list_node =& $this->dom->create_element("FileList");
$this->list_node =& $this->node->append_child($this->list_node);
}

+ Here is the call graph for this function:

ilPCFileList::deleteFileItems (   $a_ids)

Delete file items.

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

References ilPageContent\$hier_id.

{
$files = array();
// File Item
$childs = $this->list_node->child_nodes();
for ($i=0; $i<count($childs); $i++)
{
if ($childs[$i]->node_name() == "FileItem")
{
$id = $entry = "";
$pc_id = $childs[$i]->get_attribute("PCID");
$hier_id = $childs[$i]->get_attribute("HierId");
if (in_array($hier_id.":".$pc_id, $a_ids))
{
$childs[$i]->unlink($childs[$i]);
}
}
}
}
ilPCFileList::getAllClasses ( )

Get all style classes.

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

{
$classes = array();
// File Item
$childs = $this->list_node->child_nodes();
for ($i=0; $i<count($childs); $i++)
{
if ($childs[$i]->node_name() == "FileItem")
{
$classes[$childs[$i]->get_attribute("HierId").":".
$childs[$i]->get_attribute("PCID")] = $childs[$i]->get_attribute("Class");
}
}
return $classes;
}
ilPCFileList::getFileList ( )

Get list of files.

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

References ilPageContent\$hier_id.

{
$files = array();
// File Item
$childs = $this->list_node->child_nodes();
for ($i=0; $i<count($childs); $i++)
{
if ($childs[$i]->node_name() == "FileItem")
{
$id = $entry = "";
$pc_id = $childs[$i]->get_attribute("PCID");
$hier_id = $childs[$i]->get_attribute("HierId");
$class = $childs[$i]->get_attribute("Class");
// Identifier
$id_node = $childs[$i]->first_child();
if ($id_node->node_name() == "Identifier")
{
$entry = $id_node->get_attribute("Entry");
if (substr($entry, 0, 9) == "il__file_")
{
$id = substr($entry, 9);
}
}
$files[] = array("entry" => $entry, "id" => $id,
"pc_id" => $pc_id, "hier_id" => $hier_id,
"class" => $class);
}
}
return $files;
}
ilPCFileList::getLanguage ( )

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

{
$chlds =& $this->list_node->child_nodes();
for($i=0; $i<count($chlds); $i++)
{
if ($chlds[$i]->node_name() == "Title")
{
return $chlds[$i]->get_attribute("Language");
}
}
return "";
}
static ilPCFileList::getLangVars ( )
static

Get lang vars needed for editing.

Returns
array array of lang var keys

Reimplemented from ilPageContent.

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

{
return array("ed_edit_files", "ed_insert_filelist", "pc_flist");
}
ilPCFileList::getListTitle ( )

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

{
$chlds =& $this->list_node->child_nodes();
for($i=0; $i<count($chlds); $i++)
{
if ($chlds[$i]->node_name() == "Title")
{
return $chlds[$i]->get_content();
}
}
return "";
}
ilPCFileList::init ( )

Init page content component.

Reimplemented from ilPageContent.

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

References ilPageContent\setType().

{
$this->setType("flst");
}

+ Here is the call graph for this function:

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

Save file usages.

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

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

Referenced by afterPageHistoryEntry(), and afterPageUpdate().

{
$file_ids = self::collectFileItems($a_page, $a_domdoc);
include_once("./Modules/File/classes/class.ilObjFile.php");
ilObjFile::_deleteAllUsages($a_page->getParentType().":pg", $a_page->getId(), $a_old_nr, $a_page->getLanguage());
foreach($file_ids as $file_id)
{
ilObjFile::_saveUsage($file_id, $a_page->getParentType().":pg", $a_page->getId(), $a_old_nr,
$a_page->getLanguage());
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilPCFileList::savePositions (   $a_pos)

Save positions of file items.

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

References ilPageContent\$hier_id.

{
asort($a_pos);
// File Item
$childs = $this->list_node->child_nodes();
$nodes = array();
for ($i=0; $i<count($childs); $i++)
{
if ($childs[$i]->node_name() == "FileItem")
{
$id = $entry = "";
$pc_id = $childs[$i]->get_attribute("PCID");
$hier_id = $childs[$i]->get_attribute("HierId");
$nodes[$hier_id.":".$pc_id] = $childs[$i];
$childs[$i]->unlink($childs[$i]);
}
}
foreach($a_pos as $k => $v)
{
if (is_object($nodes[$k]))
{
$nodes[$k] = $this->list_node->append_child($nodes[$k]);
}
}
}
ilPCFileList::saveStyleClasses (   $a_class)

Save style classes of file items.

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

{
// File Item
$childs = $this->list_node->child_nodes();
for ($i=0; $i<count($childs); $i++)
{
if ($childs[$i]->node_name() == "FileItem")
{
$childs[$i]->set_attribute("Class",
$a_class[$childs[$i]->get_attribute("HierId").":".
$childs[$i]->get_attribute("PCID")]);
}
}
}
ilPCFileList::setListTitle (   $a_title,
  $a_language 
)

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

References ilDOMUtil\setFirstOptionalElement().

{
$this->list_node, "Title", array("FileItem"),
$a_title, array("Language" => $a_language));
}

+ Here is the call graph for this function:

ilPCFileList::setNode ( $a_node)

Set xml node of page content.

Parameters
object$a_nodenode object

Reimplemented from ilPageContent.

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

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

Field Documentation

ilPCFileList::$list_node

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


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