6 require_once(
"./Services/COPage/classes/class.ilPageContent.php");
32 parent::setNode($a_node);
33 $this->list_node = $a_node->first_child();
36 function create(&$a_pg_obj, $a_hier_id, $a_pc_id =
"")
40 $this->list_node = $this->dom->create_element(
"FileList");
41 $this->list_node = $this->node->append_child($this->list_node);
57 $new_item = $this->dom->create_element(
"FileItem");
58 $new_item = $this->list_node->append_child($new_item);
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);
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);
73 $form_node = $this->dom->create_element(
"Format");
74 $form_node = $new_item->append_child($form_node);
75 $form_node->set_content($a_format);
81 $this->list_node,
"Title",
array(
"FileItem"),
82 $a_title,
array(
"Language" => $a_language));
87 $chlds = $this->list_node->child_nodes();
88 for($i=0; $i<count($chlds); $i++)
90 if ($chlds[$i]->node_name() ==
"Title")
92 return $chlds[$i]->get_content();
100 $chlds = $this->list_node->child_nodes();
101 for($i=0; $i<count($chlds); $i++)
103 if ($chlds[$i]->node_name() ==
"Title")
105 return $chlds[$i]->get_attribute(
"Language");
119 $childs = $this->list_node->child_nodes();
120 for ($i=0; $i<count($childs); $i++)
122 if ($childs[$i]->node_name() ==
"FileItem")
125 $pc_id = $childs[$i]->get_attribute(
"PCID");
126 $hier_id = $childs[$i]->get_attribute(
"HierId");
127 $class = $childs[$i]->get_attribute(
"Class");
130 $id_node = $childs[$i]->first_child();
131 if ($id_node->node_name() ==
"Identifier")
133 $entry = $id_node->get_attribute(
"Entry");
134 if (substr($entry, 0, 9) ==
"il__file_")
136 $id = substr($entry, 9);
140 "pc_id" => $pc_id,
"hier_id" =>
$hier_id,
156 $childs = $this->list_node->child_nodes();
158 for ($i=0; $i<count($childs); $i++)
160 if ($childs[$i]->node_name() ==
"FileItem")
163 $pc_id = $childs[$i]->get_attribute(
"PCID");
164 $hier_id = $childs[$i]->get_attribute(
"HierId");
166 if (in_array(
$hier_id.
":".$pc_id, $a_ids))
168 $childs[$i]->unlink($childs[$i]);
182 $childs = $this->list_node->child_nodes();
184 for ($i=0; $i<count($childs); $i++)
186 if ($childs[$i]->node_name() ==
"FileItem")
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]);
196 foreach($a_pos as $k => $v)
198 if (is_object($nodes[$k]))
200 $nodes[$k] = $this->list_node->append_child($nodes[$k]);
213 $childs = $this->list_node->child_nodes();
215 for ($i=0; $i<count($childs); $i++)
217 if ($childs[$i]->node_name() ==
"FileItem")
219 $classes[$childs[$i]->get_attribute(
"HierId").
":".
220 $childs[$i]->get_attribute(
"PCID")] = $childs[$i]->get_attribute(
"Class");
233 $childs = $this->list_node->child_nodes();
234 for ($i=0; $i<count($childs); $i++)
236 if ($childs[$i]->node_name() ==
"FileItem")
238 $childs[$i]->set_attribute(
"Class",
239 $a_class[$childs[$i]->get_attribute(
"HierId").
":".
240 $childs[$i]->get_attribute(
"PCID")]);
251 return array(
"ed_edit_files",
"ed_insert_filelist",
"pc_flist");
264 if (!$a_page->getImportMode())
267 include_once(
"./Modules/File/classes/class.ilObjFile.php");
269 $a_page->getParentType().
":pg", $a_page->getId(), 0, $a_page->getLanguage());
270 self::saveFileUsage($a_page, $a_domdoc);
272 foreach($file_ids as
$file)
277 $usages = $file_obj->getUsages();
278 if (count($usages) == 0)
280 if ($file_obj->getMode() ==
"filelist")
298 $files = self::collectFileItems($a_page, $a_page->getDomDoc());
301 include_once(
"./Modules/File/classes/class.ilObjFile.php");
303 $a_page->getLanguage());
305 include_once(
"./Modules/File/classes/class.ilObjFile.php");
306 foreach (
$files as $file_id)
310 $file_obj =
new ilObjFile($file_id,
false);
326 self::saveFileUsage($a_page, $a_old_domdoc, $a_old_nr);
334 $file_ids = self::collectFileItems($a_page, $a_domdoc);
335 include_once(
"./Modules/File/classes/class.ilObjFile.php");
337 foreach($file_ids as $file_id)
340 $a_page->getLanguage());
349 $xpath =
new DOMXPath($a_domdoc);
350 $nodes = $xpath->query(
'//FileItem/Identifier');
352 foreach($nodes as
$node)
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))
358 $file_ids[$file_id] = $file_id;
362 $xpath =
new DOMXPath($a_domdoc);
363 $nodes = $xpath->query(
"//IntLink[@Type='File']");
364 foreach($nodes as $node)
366 $t = $node->getAttribute(
"Target");
367 if (substr(
$t, 0, 9) ==
"il__dfile")
369 $id_arr = explode(
"_",
$t);
370 $file_id = $id_arr[count($id_arr) - 1];
371 $file_ids[$file_id] = $file_id;
getAllClasses()
Get all style classes.
static saveFileUsage($a_page, $a_domdoc, $a_old_nr=0)
Save file usages.
static getLangVars()
Get lang vars needed for editing.
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
init()
Init page content component.
static _deleteAllUsages($a_type, $a_id, $a_usage_hist_nr=0, $a_usage_lang="-")
static delete all usages of
setType($a_type)
Set Type.
getFileList()
Get list of files.
static beforePageDelete($a_page)
Before page is being deleted.
deleteFileItems($a_ids)
Delete file items.
setListTitle($a_title, $a_language)
static afterPageUpdate($a_page, DOMDocument $a_domdoc, $a_xml, $a_creation)
After page has been updated (or created)
create(&$a_pg_obj, $a_hier_id, $a_pc_id="")
static afterPageHistoryEntry($a_page, DOMDocument $a_old_domdoc, $a_old_xml, $a_old_nr)
After page history entry has been created.
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...
static collectFileItems($a_page, $a_domdoc)
Get all file items that are used within the page.
static _saveUsage($a_file_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_usage_lang="-")
save usage
static _getFilesOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_usage_lang="-")
get all files of an object
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
saveStyleClasses($a_class)
Save style classes of file items.
createPageContentNode($a_set_this_node=true)
Create page content node (always use this method first when adding a new element) ...
appendItem($a_id, $a_location, $a_format)
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
savePositions($a_pos)
Save positions of file items.