4 require_once(
"./Services/COPage/classes/class.ilPageContent.php");
34 return array(
"ed_insert_amd_page_list",
"pc_amdpl");
42 parent::setNode($a_node);
43 $this->amdpl_node = $a_node->first_child();
52 function create(&$a_pg_obj, $a_hier_id, $a_pc_id =
"")
56 $this->amdpl_node = $this->dom->create_element(
"AMDPageList");
57 $this->amdpl_node = $this->node->append_child($this->amdpl_node);
67 $data_id = $this->amdpl_node->get_attribute(
"Id");
70 $ilDB->manipulate(
"DELETE FROM pg_amd_page_list".
71 " WHERE id = ".$ilDB->quote($data_id,
"integer"));
75 $data_id = $ilDB->nextId(
"pg_amd_page_list");
76 $this->amdpl_node->set_attribute(
"Id", $data_id);
79 $this->amdpl_node->set_attribute(
"Mode", (
int)$a_mode);
81 foreach($a_fields_data as $field_id => $field_data)
84 "id" =>
array(
"integer", $data_id)
85 ,
"field_id" =>
array(
"integer", $field_id)
86 ,
"data" =>
array(
"text", serialize($field_data))
88 $ilDB->insert(
"pg_amd_page_list", $fields);
94 if (is_object($this->amdpl_node))
96 return (
int)$this->amdpl_node->get_attribute(
"Mode");
114 if (is_object($this->amdpl_node))
116 $a_data_id = $this->amdpl_node->get_attribute(
"Id");
122 $set = $ilDB->query(
"SELECT * FROM pg_amd_page_list".
123 " WHERE id = ".$ilDB->quote($a_data_id,
"integer"));
124 while(
$row = $ilDB->fetchAssoc($set))
126 $res[
$row[
"field_id"]] = unserialize($row[
"data"]);
139 $xpath =
new DOMXPath($a_domdoc);
140 $nodes = $xpath->query(
"//AMDPageList");
141 foreach($nodes as
$node)
143 $old_id = $node->getAttribute(
"Id");
149 $new_id = $ilDB->nextId(
"pg_amd_page_list");
151 $set = $ilDB->query(
"SELECT * FROM pg_amd_page_list".
152 " WHERE id = ".$ilDB->quote($old_id,
"integer"));
153 while(
$row = $ilDB->fetchAssoc($set))
156 "id" =>
array(
"integer", $new_id)
157 ,
"field_id" =>
array(
"integer",
$row[
"field_id"])
160 $ilDB->insert(
"pg_amd_page_list", $fields);
163 $node->setAttribute(
"Id", $new_id);
177 $wiki_id = $this->
getPage()->getWikiId();
179 $found_result =
array();
184 foreach($recs as $record)
188 if(isset($list_values[$field->getFieldId()]))
190 $field_form =
ilADTFactory::getInstance()->getSearchBridgeForDefinitionInstance($field->getADTDefinition(),
true,
false);
191 $field->setSearchValueSerialized($field_form, $list_values[$field->getFieldId()]);
192 $found_pages = $field->searchSubObjects($field_form, $wiki_id,
"wpg");
193 if(is_array($found_ids))
195 $found_ids = array_intersect($found_ids, $found_pages);
199 $found_ids = $found_pages;
205 if(
sizeof($found_ids))
207 $sql =
"SELECT id,title FROM il_wiki_page".
208 " WHERE ".$ilDB->in(
"id", $found_ids,
"",
"integer").
210 $set = $ilDB->query($sql);
211 while(
$row = $ilDB->fetchAssoc($set))
213 $found_result[
$row[
"id"]] = $row[
"title"];
217 return $found_result;
224 if($this->
getPage()->getParentType() !=
"wpg")
229 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php');
230 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
231 include_once(
'Modules/Wiki/classes/class.ilWikiUtil.php');
233 $wiki_id = $this->
getPage()->getWikiId();
236 $start = strpos($a_html,
"[[[[[AMDPageList;");
239 $end = strpos($a_html,
"]]]]]",
$start);
244 $parts = explode(
";", substr($a_html,
$start + 17, $end -
$start - 17));
246 $list_id = (int)$parts[0];
247 $list_mode = (
sizeof($parts) == 2)
251 $ltpl =
new ilTemplate(
"tpl.wiki_amd_page_list.html",
true,
true,
"Modules/Wiki");
256 $ltpl->setCurrentBlock(
"page_bl");
257 foreach($pages as $page_id => $page_title)
260 $frag =
new stdClass;
261 $frag->mFragment = null;
262 $frag->mTextform = $page_title;
265 $ltpl->parseCurrentBlock();
270 $ltpl->touchBlock(
"no_hits_bl");
273 $ltpl->setVariable(
"LIST_MODE", $list_mode ?
"ol" :
"ul");
275 $a_html = substr($a_html, 0,
$start).
277 substr($a_html, $end + 5);
279 $start = strpos($a_html,
"[[[[[AMDPageList;",
$start + 5);
283 $end = strpos($a_html,
"]]]]]",
$start);
299 public static function migrateField($a_obj_id, $a_field_id, $old_option, $new_option, $a_is_multi =
false)
305 $set = $ilDB->query(
"SELECT * FROM pg_amd_page_list".
306 " WHERE field_id = ".$ilDB->quote($a_field_id,
"integer"));
307 while(
$row = $ilDB->fetchAssoc($set))
309 $data = unserialize(unserialize(
$row[
"data"]));
310 if(is_array(
$data) &&
311 in_array($old_option,
$data))
313 $idx = array_search($old_option,
$data);
316 $data[$idx] = $new_option;
324 "data" =>
array(
"text", serialize(serialize(
$data)))
328 "field_id" =>
array(
"integer",
$row[
"field_id"])
330 $ilDB->update(
"pg_amd_page_list", $fields, $primary);
static handleCopiedContent(DOMDocument $a_domdoc, $a_self_ass=true, $a_clone_mobs=false)
init()
Init page content component.
modifyPageContentPostXsl($a_html, $a_mode)
setData(array $a_fields_data, $a_mode=null)
Set list settings.
static makeLink(&$nt, $a_wiki_id, $text='', $query='', $trail='', $prefix='', $a_offline=false)
Make a wiki link, the following formats are supported:
setType($a_type)
Set Type.
static getInstance()
Get singleton.
static getInstancesByRecordId($a_record_id, $a_only_searchable=false)
Get definitions by record id.
setNode($a_node)
Set node.
static migrateField($a_obj_id, $a_field_id, $old_option, $new_option, $a_is_multi=false)
Migrate search/filter values on advmd change.
special template class to simplify handling of ITX/PEAR
static _getSelectedRecordsByObject($a_obj_type, $a_obj_id, $a_sub_type="")
Get selected records by object.
getFieldValues($a_data_id=null)
Get filter field values.
Create styles array
The data for the language used.
create(&$a_pg_obj, $a_hier_id, $a_pc_id="")
Create list node in xml.
static getLangVars()
Get lang vars needed for editing.
createPageContentNode($a_set_this_node=true)
Create page content node (always use this method first when adding a new element) ...