32 public function init(): void
36 $this->db = $DIC->database();
37 $this->
lng = $DIC->language();
43 return array(
"ed_insert_amd_page_list",
"pc_amdpl");
48 parent::setNode($a_node);
59 $this->amdpl_node = $this->dom->create_element(
"AMDPageList");
60 $this->amdpl_node = $this->node->append_child($this->amdpl_node);
69 $data_id = $this->amdpl_node->get_attribute(
"Id");
71 $ilDB->manipulate(
"DELETE FROM pg_amd_page_list" .
72 " WHERE id = " .
$ilDB->quote($data_id,
"integer"));
74 $data_id =
$ilDB->nextId(
"pg_amd_page_list");
75 $this->amdpl_node->set_attribute(
"Id", $data_id);
78 $this->amdpl_node->set_attribute(
"Mode", (
int) $a_mode);
80 foreach ($a_fields_data as $field_id => $field_data) {
82 "id" => array(
"integer", $data_id)
83 ,
"field_id" => array(
"integer", $field_id)
84 ,
"sdata" => array(
"text", serialize($field_data))
86 $ilDB->insert(
"pg_amd_page_list", $fields);
92 if (is_object($this->amdpl_node)) {
93 return (
int) $this->amdpl_node->get_attribute(
"Mode");
102 int $a_data_id = null
109 if (is_object($this->amdpl_node)) {
110 $a_data_id = $this->amdpl_node->get_attribute(
"Id");
115 $set =
$ilDB->query(
"SELECT * FROM pg_amd_page_list" .
116 " WHERE id = " .
$ilDB->quote($a_data_id,
"integer"));
117 while ($row =
$ilDB->fetchAssoc($set)) {
118 $res[$row[
"field_id"]] = unserialize($row[
"sdata"], [
"allowed_classes" =>
false]);
125 bool $a_self_ass =
true,
126 bool $a_clone_mobs =
false,
127 int $new_parent_id = 0,
132 $ilDB = $DIC->database();
139 $nodes = $xpath->query(
"//AMDPageList");
140 foreach ($nodes as
$node) {
141 $old_id = $node->getAttribute(
"Id");
146 $new_id =
$ilDB->nextId(
"pg_amd_page_list");
148 $set =
$ilDB->query(
"SELECT * FROM pg_amd_page_list" .
149 " WHERE id = " .
$ilDB->quote($old_id,
"integer"));
150 while ($row =
$ilDB->fetchAssoc($set)) {
152 "id" => array(
"integer", $new_id)
153 ,
"field_id" => array(
"integer", $row[
"field_id"])
154 ,
"sdata" => array(
"text", $row[
"sdata"])
156 $ilDB->insert(
"pg_amd_page_list", $fields);
159 $node->setAttribute(
"Id", $new_id);
168 protected function findPages(
177 $wiki_id = $wpage->getWikiId();
178 $wiki_ref_id = $wpage->getWikiRefId();
180 $found_result = array();
185 foreach ($recs as $record) {
187 if (isset($list_values[$field->getFieldId()]) && $list_values[$field->getFieldId()] !==
"") {
188 $field_form =
ilADTFactory::getInstance()->getSearchBridgeForDefinitionInstance($field->getADTDefinition(),
true,
false);
189 $field->setSearchValueSerialized($field_form, $list_values[$field->getFieldId()]);
190 $found_pages = $field->searchSubObjects($field_form, $wiki_id,
"wpg");
191 if (is_array($found_ids)) {
192 $found_ids = array_intersect($found_ids, $found_pages);
194 $found_ids = $found_pages;
200 if (is_array($found_ids) && count($found_ids) > 0) {
201 $sql =
"SELECT id,title FROM il_wiki_page" .
202 " WHERE " .
$ilDB->in(
"id", $found_ids,
"",
"integer") .
204 $set =
$ilDB->query($sql);
205 while ($row =
$ilDB->fetchAssoc($set)) {
206 $found_result[$row[
"id"]] = $row[
"title"];
210 return $found_result;
216 bool $a_abstract_only =
false 218 if ($this->
getPage()->getParentType() !==
"wpg") {
222 $wiki_id = $this->
getPage()->getWikiId();
224 $start = strpos($a_output,
"[[[[[AMDPageList;");
225 if (is_int($start)) {
226 $end = strpos($a_output,
"]]]]]", $start);
229 $parts = explode(
";", substr($a_output, $start + 17, $end - $start - 17));
232 $list_mode = (count(
$parts) === 2)
236 $ltpl =
new ilTemplate(
"tpl.wiki_amd_page_list.html",
true,
true,
"Modules/Wiki");
238 $pages = $this->findPages($list_id);
240 $ltpl->setCurrentBlock(
"page_bl");
241 foreach ($pages as $page_id => $page_title) {
244 $frag->mFragment = null;
245 $frag->mTextform = $page_title;
248 $ltpl->parseCurrentBlock();
251 $ltpl->touchBlock(
"no_hits_bl");
254 $ltpl->setVariable(
"LIST_MODE", $list_mode ?
"ol" :
"ul");
256 $a_output = substr($a_output, 0, $start) .
258 substr($a_output, $end + 5);
260 $start = strpos($a_output,
"[[[[[AMDPageList;", $start + 5);
262 if (is_int($start)) {
263 $end = strpos($a_output,
"]]]]]", $start);
282 $ilDB = $DIC->database();
286 $set =
$ilDB->query(
"SELECT * FROM pg_amd_page_list" .
287 " WHERE field_id = " .
$ilDB->quote($a_field_id,
"integer"));
288 while ($row =
$ilDB->fetchAssoc($set)) {
289 $data = unserialize(unserialize($row[
"sdata"], [
"allowed_classes" =>
false]), [
"allowed_classes" =>
false]);
290 if (!is_array(
$data)) {
293 $updated_data =
$data;
294 foreach ($mapping as $old_option => $new_option) {
295 if (!in_array($old_option,
$data)) {
298 $idx = array_search($old_option,
$data);
299 if ($new_option !==
'') {
300 $updated_data[$idx] = $new_option;
302 unset($updated_data[$idx]);
306 "sdata" => array(
"text", serialize(empty($updated_data) ?
'' : serialize($updated_data)))
309 "id" => array(
"integer", $row[
"id"]),
310 "field_id" => array(
"integer", $row[
"field_id"])
312 $ilDB->update(
"pg_amd_page_list", $fields, $primary);
setType(string $a_type)
Set Type.
static makeLink(object $nt, int $a_wiki_id, string $text='', string $query='', string $trail='', string $prefix='', bool $a_offline=false)
Make a wiki link, the following formats are supported:
create(ilPageObject $a_pg_obj, string $a_hier_id, string $a_pc_id="")
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
modifyPageContentPostXsl(string $a_output, string $a_mode, bool $a_abstract_only=false)
static _getSelectedRecordsByObject(string $a_obj_type, int $a_id, string $a_sub_type="", bool $is_ref_id=true)
static getInstancesByRecordId( $a_record_id, $a_only_searchable=false, string $language='')
Get definitions by record id.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static migrateField(int $a_field_id, array $mapping)
Migrate search/filter values on advmd change.
insertContent(ilPageContent $a_cont_obj, string $a_pos, int $a_mode=IL_INSERT_AFTER, string $a_pcid="", bool $remove_placeholder=true)
insert a content node before/after a sibling or as first child of a parent
setData(array $a_fields_data, int $a_mode=null)
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
createPageContentNode(bool $a_set_this_node=true)
Create page content node (always use this method first when adding a new element) ...
static handleCopiedContent(DOMDocument $a_domdoc, bool $a_self_ass=true, bool $a_clone_mobs=false, int $new_parent_id=0, int $obj_copy_id=0)
php4DOMElement $amdpl_node
getFieldValues(int $a_data_id=null)
Get filter field values.
setNode(php4DOMElement $a_node)