ILIAS  release_8 Revision v8.24
ilPCAMDPageList Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilPCAMDPageList:
+ Collaboration diagram for ilPCAMDPageList:

Public Member Functions

 init ()
 Init object. More...
 
 setNode (php4DOMElement $a_node)
 Set xml node of page content. More...
 
 create (ilPageObject $a_pg_obj, string $a_hier_id, string $a_pc_id="")
 
 setData (array $a_fields_data, int $a_mode=null)
 
 getMode ()
 
 getFieldValues (int $a_data_id=null)
 Get filter field values. More...
 
 modifyPageContentPostXsl (string $a_output, string $a_mode, bool $a_abstract_only=false)
 Modify page content after xsl. More...
 
- Public Member Functions inherited from ilPageContent
 __construct (ilPageObject $a_pg_obj)
 
 setPage (ilPageObject $a_val)
 
 getPage ()
 
 init ()
 Init object. More...
 
 getType ()
 
 setNode (php4DOMElement $a_node)
 Set xml node of page content. More...
 
 getNode ()
 
 getJavascriptFiles (string $a_mode)
 
 getCssFiles (string $a_mode)
 
 getOnloadCode (string $a_mode)
 
 setHierId (string $a_hier_id)
 
 getHierId ()
 
 lookupHierId ()
 
 readHierId ()
 
 setPcId (string $a_pcid)
 
 getPCId ()
 
 setFileDownloadLink (string $a_download_link)
 
 getFileDownloadLink ()
 
 setProfileBackUrl (string $url)
 
 getProfileBackUrl ()
 
 setFullscreenLink (string $a_fullscreen_link)
 
 getFullscreenLink ()
 
 setSourcecodeDownloadScript (string $script_name)
 
 getSourcecodeDownloadScript ()
 
 readPCId ()
 
 writePCId (string $a_pc_id)
 
 setEnabled (string $value)
 Set Enabled value for page content component. More...
 
 enable ()
 
 disable ()
 
 isEnabled ()
 
 createPageContentNode (bool $a_set_this_node=true)
 Create page content node (always use this method first when adding a new element) More...
 
 modifyPageContentPostXsl (string $a_output, string $a_mode, bool $a_abstract_only=false)
 Modify page content after xsl. More...
 
 getModel ()
 Get model as needed for the front-end editor. More...
 

Static Public Member Functions

static getLangVars ()
 Get lang vars needed for editing. More...
 
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)
 Handle copied content. More...
 
static migrateField (int $a_field_id, array $mapping)
 Migrate search/filter values on advmd change. More...
 
- Static Public Member Functions inherited from ilPageContent
static incEdId (string $ed_id)
 Increases an hierarchical editing id at lowest level (last number) More...
 
static decEdId (string $ed_id)
 Decreases an hierarchical editing id at lowest level (last number) More...
 
static sortHierIds (array $a_array)
 Sort an array of Hier IDS in ascending order. More...
 
static isGreaterHierId (string $a, string $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, bool $a_self_ass=true, bool $a_clone_mobs=false, int $new_parent_id=0, int $obj_copy_id=0)
 Handle copied content. More...
 
static afterPageUpdate (ilPageObject $a_page, DOMDocument $a_domdoc, string $a_xml, bool $a_creation)
 After page has been updated (or created) More...
 
static beforePageDelete (ilPageObject $a_page)
 Before page is being deleted. More...
 
static afterRepositoryCopy (ilPageObject $page, array $mapping, int $source_ref_id)
 After repository (container) copy action. More...
 
static afterPageHistoryEntry (ilPageObject $a_page, DOMDocument $a_old_domdoc, string $a_old_xml, int $a_old_nr)
 After page history entry has been created. More...
 
static deleteHistoryLowerEqualThan (string $parent_type, int $page_id, string $lang, int $delete_lower_than_nr)
 Overwrite in derived classes, if old history entries are being deleted. More...
 

Protected Attributes

php4DOMElement $amdpl_node
 
ilDBInterface $db
 
ilLanguage $lng
 
- Protected Attributes inherited from ilPageContent
string $pcid
 
string $type = ""
 
ilPageObject $pg_obj
 
string $file_download_link
 
string $fullscreen_link
 
string $sourcecode_download_script
 
ilLogger $log
 
string $profile_back_url = ""
 

Additional Inherited Members

- Data Fields inherited from ilPageContent
string $hier_id = ""
 
php4DOMElement $node = null
 
php4DOMDocument $dom = null
 
string $page_lang = ""
 
- Protected Member Functions inherited from ilPageContent
 setType (string $a_type)
 Set Type. More...
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilPCAMDPageList

Advanced MD page list content object (see ILIAS DTD)

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 26 of file class.ilPCAMDPageList.php.

Member Function Documentation

◆ create()

ilPCAMDPageList::create ( ilPageObject  $a_pg_obj,
string  $a_hier_id,
string  $a_pc_id = "" 
)

Definition at line 52 of file class.ilPCAMDPageList.php.

56 : void {
57 $this->node = $this->createPageContentNode();
58 $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
59 $this->amdpl_node = $this->dom->create_element("AMDPageList");
60 $this->amdpl_node = $this->node->append_child($this->amdpl_node);
61 }
const IL_INSERT_AFTER
createPageContentNode(bool $a_set_this_node=true)
Create page content node (always use this method first when adding a new element)
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

◆ getFieldValues()

ilPCAMDPageList::getFieldValues ( int  $a_data_id = null)

Get filter field values.

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

103 : array {
105
106 $res = array();
107
108 if (!$a_data_id) {
109 if (is_object($this->amdpl_node)) {
110 $a_data_id = $this->amdpl_node->get_attribute("Id");
111 }
112 }
113
114 if ($a_data_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]);
119 }
120 }
121 return $res;
122 }
$res
Definition: ltiservices.php:69

◆ getLangVars()

static ilPCAMDPageList::getLangVars ( )
static

Get lang vars needed for editing.

Returns
string[] array of lang var keys

Reimplemented from ilPageContent.

Definition at line 41 of file class.ilPCAMDPageList.php.

41 : array
42 {
43 return array("ed_insert_amd_page_list", "pc_amdpl");
44 }

◆ getMode()

ilPCAMDPageList::getMode ( )

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

90 : int
91 {
92 if (is_object($this->amdpl_node)) {
93 return (int) $this->amdpl_node->get_attribute("Mode");
94 }
95 return 0;
96 }

◆ handleCopiedContent()

static ilPCAMDPageList::handleCopiedContent ( DOMDocument  $a_domdoc,
bool  $a_self_ass = true,
bool  $a_clone_mobs = false,
int  $new_parent_id = 0,
int  $obj_copy_id = 0 
)
static

Handle copied content.

This function must, e.g. create copies of objects referenced within the content (e.g. question objects)

Parameters
DOMDocument$a_domdoc
bool$a_self_ass
bool$a_clone_mobs
int$new_parent_id
int$obj_copy_id

Reimplemented from ilPageContent.

Definition at line 123 of file class.ilPCAMDPageList.php.

129 : void {
130 global $DIC;
131
132 $ilDB = $DIC->database();
133 $old_id = 0;
134 $node = null;
135
136 // #15688
137
138 $xpath = new DOMXPath($a_domdoc);
139 $nodes = $xpath->query("//AMDPageList");
140 foreach ($nodes as $node) {
141 $old_id = $node->getAttribute("Id");
142 break;
143 }
144
145 if ($old_id) {
146 $new_id = $ilDB->nextId("pg_amd_page_list");
147
148 $set = $ilDB->query("SELECT * FROM pg_amd_page_list" .
149 " WHERE id = " . $ilDB->quote($old_id, "integer"));
150 while ($row = $ilDB->fetchAssoc($set)) {
151 $fields = array(
152 "id" => array("integer", $new_id)
153 ,"field_id" => array("integer", $row["field_id"])
154 ,"sdata" => array("text", $row["sdata"])
155 );
156 $ilDB->insert("pg_amd_page_list", $fields);
157 }
158
159 $node->setAttribute("Id", $new_id);
160 }
161 }
php4DOMElement $node
global $DIC
Definition: feed.php:28

◆ init()

ilPCAMDPageList::init ( )

Init object.

This function must be overwritten and at least set the content type.

Reimplemented from ilPageContent.

Definition at line 32 of file class.ilPCAMDPageList.php.

32 : void
33 {
34 global $DIC;
35
36 $this->db = $DIC->database();
37 $this->lng = $DIC->language();
38 $this->setType("amdpl");
39 }
setType(string $a_type)
Set Type.

References $DIC, ILIAS\Repository\lng(), and ilPageContent\setType().

+ Here is the call graph for this function:

◆ migrateField()

static ilPCAMDPageList::migrateField ( int  $a_field_id,
array  $mapping 
)
static

Migrate search/filter values on advmd change.

In the mapping, keys are indices of old options, and values indices of associated new options.

Parameters
int$a_field_id
string[]$mapping

Definition at line 276 of file class.ilPCAMDPageList.php.

279 : void {
280 global $DIC;
281
282 $ilDB = $DIC->database();
283
284 // this does only work for select and select multi
285
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)) {
291 continue;
292 }
293 $updated_data = $data;
294 foreach ($mapping as $old_option => $new_option) {
295 if (!in_array($old_option, $data)) {
296 continue;
297 }
298 $idx = array_search($old_option, $data);
299 if ($new_option !== '') {
300 $updated_data[$idx] = $new_option;
301 } else {
302 unset($updated_data[$idx]);
303 }
304 }
305 $fields = array(
306 "sdata" => array("text", serialize(empty($updated_data) ? '' : serialize($updated_data)))
307 );
308 $primary = array(
309 "id" => array("integer", $row["id"]),
310 "field_id" => array("integer", $row["field_id"])
311 );
312 $ilDB->update("pg_amd_page_list", $fields, $primary);
313 }
314 }

References $data, and $ilDB.

Referenced by ilAdvancedMDFieldDefinitionSelect\update().

+ Here is the caller graph for this function:

◆ modifyPageContentPostXsl()

ilPCAMDPageList::modifyPageContentPostXsl ( string  $a_output,
string  $a_mode,
bool  $a_abstract_only = false 
)

Modify page content after xsl.

Reimplemented from ilPageContent.

Definition at line 213 of file class.ilPCAMDPageList.php.

217 : string {
218 if ($this->getPage()->getParentType() !== "wpg") {
219 return $a_output;
220 }
221 $end = 0;
222 $wiki_id = $this->getPage()->getWikiId();
223
224 $start = strpos($a_output, "[[[[[AMDPageList;");
225 if (is_int($start)) {
226 $end = strpos($a_output, "]]]]]", $start);
227 }
228 while ($end > 0) {
229 $parts = explode(";", substr($a_output, $start + 17, $end - $start - 17));
230
231 $list_id = (int) $parts[0];
232 $list_mode = (count($parts) === 2)
233 ? (int) $parts[1]
234 : 0;
235
236 $ltpl = new ilTemplate("tpl.wiki_amd_page_list.html", true, true, "Modules/Wiki");
237
238 $pages = $this->findPages($list_id);
239 if (count($pages)) {
240 $ltpl->setCurrentBlock("page_bl");
241 foreach ($pages as $page_id => $page_title) {
242 // see ilWikiUtil::makeLink()
243 $frag = new stdClass();
244 $frag->mFragment = null;
245 $frag->mTextform = $page_title;
246
247 $ltpl->setVariable("PAGE", ilWikiUtil::makeLink($frag, $wiki_id, $page_title));
248 $ltpl->parseCurrentBlock();
249 }
250 } else {
251 $ltpl->touchBlock("no_hits_bl");
252 }
253
254 $ltpl->setVariable("LIST_MODE", $list_mode ? "ol" : "ul");
255
256 $a_output = substr($a_output, 0, $start) .
257 $ltpl->get() .
258 substr($a_output, $end + 5);
259
260 $start = strpos($a_output, "[[[[[AMDPageList;", $start + 5);
261 $end = 0;
262 if (is_int($start)) {
263 $end = strpos($a_output, "]]]]]", $start);
264 }
265 }
266
267 return $a_output;
268 }
special template class to simplify handling of ITX/PEAR
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:
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:64

◆ setData()

ilPCAMDPageList::setData ( array  $a_fields_data,
int  $a_mode = null 
)

Definition at line 63 of file class.ilPCAMDPageList.php.

66 : void {
68
69 $data_id = $this->amdpl_node->get_attribute("Id");
70 if ($data_id) {
71 $ilDB->manipulate("DELETE FROM pg_amd_page_list" .
72 " WHERE id = " . $ilDB->quote($data_id, "integer"));
73 } else {
74 $data_id = $ilDB->nextId("pg_amd_page_list");
75 $this->amdpl_node->set_attribute("Id", $data_id);
76 }
77
78 $this->amdpl_node->set_attribute("Mode", (int) $a_mode);
79
80 foreach ($a_fields_data as $field_id => $field_data) {
81 $fields = array(
82 "id" => array("integer", $data_id)
83 ,"field_id" => array("integer", $field_id)
84 ,"sdata" => array("text", serialize($field_data))
85 );
86 $ilDB->insert("pg_amd_page_list", $fields);
87 }
88 }

References $ilDB.

◆ setNode()

ilPCAMDPageList::setNode ( php4DOMElement  $a_node)

Set xml node of page content.

Parameters
php4DOMElement$a_nodenode object

Reimplemented from ilPageContent.

Definition at line 46 of file class.ilPCAMDPageList.php.

46 : void
47 {
48 parent::setNode($a_node); // this is the PageContent node
49 $this->amdpl_node = $a_node->first_child(); // this is the courses node
50 }

References php4DOMNode\first_child().

+ Here is the call graph for this function:

Field Documentation

◆ $amdpl_node

php4DOMElement ilPCAMDPageList::$amdpl_node
protected

Definition at line 28 of file class.ilPCAMDPageList.php.

◆ $db

ilDBInterface ilPCAMDPageList::$db
protected

Definition at line 29 of file class.ilPCAMDPageList.php.

◆ $lng

ilLanguage ilPCAMDPageList::$lng
protected

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


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