ILIAS  release_7 Revision v7.30-3-g800a261c036
ilPCAMDPageList Class Reference

Class ilPCAMDPageLisdatat. More...

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

Public Member Functions

 init ()
 Init page content component. More...
 
 setNode ($a_node)
 Set node. More...
 
 create (&$a_pg_obj, $a_hier_id, $a_pc_id="")
 Create list node in xml. More...
 
 setData (array $a_fields_data, $a_mode=null)
 Set list settings. More...
 
 getMode ()
 
 getFieldValues ($a_data_id=null)
 Get filter field values. More...
 
 modifyPageContentPostXsl ($a_html, $a_mode, $a_abstract_only=false)
 
- Public Member Functions inherited from ilPageContent
 __construct ($a_pg_obj)
 Constructor. More...
 
 setPage ($a_val)
 Set page. More...
 
 getPage ()
 Get page. More...
 
 init ()
 Init object. More...
 
 getType ()
 Get type of page content. More...
 
 setNode ($a_node)
 Set xml node of page content. More...
 
getNode ()
 Get xml node of page content. More...
 
 getJavascriptFiles ($a_mode)
 Get Javascript files. More...
 
 getCssFiles ($a_mode)
 Get css files. More...
 
 getOnloadCode ($a_mode)
 Get on load code. More...
 
 setHierId ($a_hier_id)
 Set hierarchical ID in xml structure. More...
 
 getHierId ()
 Get hierarchical id. More...
 
 lookupHierId ()
 Get hierarchical id from dom. More...
 
 readHierId ()
 Read PC Id. More...
 
 setPcId ($a_pcid)
 Set PC Id. More...
 
 getPCId ()
 Get PC Id. More...
 
 setFileDownloadLink ($a_download_link)
 Set file download link. More...
 
 getFileDownloadLink ()
 Get file download link. More...
 
 setProfileBackUrl ($url)
 
 getProfileBackUrl ()
 
 setFullscreenLink ($a_fullscreen_link)
 Set fullscreen link. More...
 
 getFullscreenLink ()
 Get fullscreen link. More...
 
 setSourcecodeDownloadScript ($script_name)
 Set sourcecode download script. More...
 
 getSourcecodeDownloadScript ()
 Get sourcecode download script. More...
 
 readPCId ()
 Read PC Id. More...
 
 writePCId ($a_pc_id)
 Write pc id. More...
 
 setEnabled ($value)
 Set Enabled value for page content component. More...
 
 enable ()
 Enable page content. More...
 
 disable ()
 Disable page content. More...
 
 isEnabled ()
 Check whether page content is enabled. More...
 
 createPageContentNode ($a_set_this_node=true)
 Create page content node (always use this method first when adding a new element) More...
 
 modifyPageContentPostXsl ($a_output, $a_mode, $a_abstract_only=false)
 Modify page content after xsl. More...
 
 getModel ()
 Get model. More...
 

Static Public Member Functions

static getLangVars ()
 Get lang vars needed for editing. More...
 
static handleCopiedContent (DOMDocument $a_domdoc, $a_self_ass=true, $a_clone_mobs=false)
 
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 ($ed_id)
 Increases an hierarchical editing id at lowest level (last number) More...
 
static decEdId ($ed_id)
 Decreases an hierarchical editing id at lowest level (last number) More...
 
static haveSameContainer ($ed_id1, $ed_id2)
 Check, if two ids are in same container. More...
 
static sortHierIds ($a_array)
 Sort an array of Hier IDS in ascending order. More...
 
static isGreaterHierId ($a, $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, $a_self_ass=true, $a_clone_mobs=false)
 Handle copied content. More...
 
static afterPageUpdate ($a_page, DOMDocument $a_domdoc, $a_xml, $a_creation)
 After page has been updated (or created) More...
 
static beforePageDelete ($a_page)
 Before page is being deleted. More...
 
static afterPageHistoryEntry ($a_page, DOMDocument $a_old_domdoc, $a_old_xml, $a_old_nr)
 After page history entry has been created. More...
 

Data Fields

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

Protected Member Functions

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

Protected Attributes

 $db
 
 $lng
 
- Protected Attributes inherited from ilPageContent
 $profile_back_url
 
 $file_download_link
 
 $fullscreen_link
 
 $sourcecode_download_script
 
 $log
 

Detailed Description

Class ilPCAMDPageLisdatat.

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
Version
Id
class.ilPCListItem.php 22210 2009-10-26 09:46:06Z akill

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

Member Function Documentation

◆ create()

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

Create list node in xml.

Parameters
object$a_pg_objPage Object
string$a_hier_idHierarchical ID

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

References ilPageContent\createPageContentNode(), and IL_INSERT_AFTER.

69  {
70  $this->node = $this->createPageContentNode();
71  $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
72  $this->amdpl_node = $this->dom->create_element("AMDPageList");
73  $this->amdpl_node = $this->node->append_child($this->amdpl_node);
74  }
const IL_INSERT_AFTER
createPageContentNode($a_set_this_node=true)
Create page content node (always use this method first when adding a new element) ...
+ Here is the call graph for this function:

◆ findPages()

ilPCAMDPageList::findPages (   $a_list_id)
protected

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

References $db, $ilDB, ilAdvancedMDRecord\_getSelectedRecordsByObject(), getFieldValues(), ilADTFactory\getInstance(), ilAdvancedMDFieldDefinition\getInstancesByRecordId(), and ilPageContent\getPage().

Referenced by modifyPageContentPostXsl().

179  {
180  $ilDB = $this->db;
181 
182  $list_values = $this->getFieldValues($a_list_id);
183  $wiki_id = $this->getPage()->getWikiId();
184 
185  $found_result = array();
186 
187  // only search in active fields
188  $found_ids = null;
189  $recs = ilAdvancedMDRecord::_getSelectedRecordsByObject("wiki", $this->ref_id, "wpg");
190  foreach ($recs as $record) {
191  foreach (ilAdvancedMDFieldDefinition::getInstancesByRecordId($record->getRecordId(), true) as $field) {
192  if (isset($list_values[$field->getFieldId()])) {
193  $field_form = ilADTFactory::getInstance()->getSearchBridgeForDefinitionInstance($field->getADTDefinition(), true, false);
194  $field->setSearchValueSerialized($field_form, $list_values[$field->getFieldId()]);
195  $found_pages = $field->searchSubObjects($field_form, $wiki_id, "wpg");
196  if (is_array($found_ids)) {
197  $found_ids = array_intersect($found_ids, $found_pages);
198  } else {
199  $found_ids = $found_pages;
200  }
201  }
202  }
203  }
204 
205  if (is_array($found_ids) && count($found_ids) > 0) {
206  $sql = "SELECT id,title FROM il_wiki_page" .
207  " WHERE " . $ilDB->in("id", $found_ids, "", "integer") .
208  " ORDER BY title";
209  $set = $ilDB->query($sql);
210  while ($row = $ilDB->fetchAssoc($set)) {
211  $found_result[$row["id"]] = $row["title"];
212  }
213  }
214 
215  return $found_result;
216  }
static getInstance()
Get singleton.
static _getSelectedRecordsByObject($a_obj_type, $a_ref_id, $a_sub_type="")
Get selected records by object.
getFieldValues($a_data_id=null)
Get filter field values.
global $ilDB
static getInstancesByRecordId($a_record_id, $a_only_searchable=false, string $language='')
Get definitions by record id.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFieldValues()

ilPCAMDPageList::getFieldValues (   $a_data_id = null)

Get filter field values.

Parameters
int$a_data_id
Returns
string

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

References $db, $ilDB, and $res.

Referenced by findPages().

118  {
119  $ilDB = $this->db;
120 
121  $res = array();
122 
123  if (!$a_data_id) {
124  if (is_object($this->amdpl_node)) {
125  $a_data_id = $this->amdpl_node->get_attribute("Id");
126  }
127  }
128 
129  if ($a_data_id) {
130  $set = $ilDB->query("SELECT * FROM pg_amd_page_list" .
131  " WHERE id = " . $ilDB->quote($a_data_id, "integer"));
132  while ($row = $ilDB->fetchAssoc($set)) {
133  $res[$row["field_id"]] = unserialize($row["sdata"]);
134  }
135  }
136 
137  return $res;
138  }
foreach($_POST as $key=> $value) $res
global $ilDB
+ Here is the caller graph for this function:

◆ getLangVars()

static ilPCAMDPageList::getLangVars ( )
static

Get lang vars needed for editing.

Returns
array array of lang var keys

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

49  {
50  return array("ed_insert_amd_page_list", "pc_amdpl");
51  }

◆ getMode()

ilPCAMDPageList::getMode ( )

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

105  {
106  if (is_object($this->amdpl_node)) {
107  return (int) $this->amdpl_node->get_attribute("Mode");
108  }
109  }

◆ handleCopiedContent()

static ilPCAMDPageList::handleCopiedContent ( DOMDocument  $a_domdoc,
  $a_self_ass = true,
  $a_clone_mobs = false 
)
static

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

References $DIC, $ilDB, and ilPageContent\$node.

141  {
142  global $DIC;
143 
144  $ilDB = $DIC->database();
145 
146  // #15688
147 
148  $xpath = new DOMXPath($a_domdoc);
149  $nodes = $xpath->query("//AMDPageList");
150  foreach ($nodes as $node) {
151  $old_id = $node->getAttribute("Id");
152  break;
153  }
154 
155  if ($old_id) {
156  $new_id = $ilDB->nextId("pg_amd_page_list");
157 
158  $set = $ilDB->query("SELECT * FROM pg_amd_page_list" .
159  " WHERE id = " . $ilDB->quote($old_id, "integer"));
160  while ($row = $ilDB->fetchAssoc($set)) {
161  $fields = array(
162  "id" => array("integer", $new_id)
163  ,"field_id" => array("integer", $row["field_id"])
164  ,"sdata" => array("text", $row["sdata"])
165  );
166  $ilDB->insert("pg_amd_page_list", $fields);
167  }
168 
169  $node->setAttribute("Id", $new_id);
170  }
171  }
global $DIC
Definition: goto.php:24
global $ilDB

◆ init()

ilPCAMDPageList::init ( )

Init page content component.

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

References $_GET, $DIC, and ilPageContent\setType().

34  {
35  global $DIC;
36 
37  $this->db = $DIC->database();
38  $this->lng = $DIC->language();
39  $this->setType("amdpl");
40 
41  $this->ref_id = (int) $_GET["ref_id"];
42  }
$_GET["client_id"]
setType($a_type)
Set Type.
global $DIC
Definition: goto.php:24
+ 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 289 of file class.ilPCAMDPageList.php.

References $data, $DIC, and $ilDB.

Referenced by ilAdvancedMDFieldDefinitionSelect\update().

292  : void {
293  global $DIC;
294 
295  $ilDB = $DIC->database();
296 
297  // this does only work for select and select multi
298 
299  $set = $ilDB->query("SELECT * FROM pg_amd_page_list" .
300  " WHERE field_id = " . $ilDB->quote($a_field_id, "integer"));
301  while ($row = $ilDB->fetchAssoc($set)) {
302  $data = unserialize(unserialize($row["sdata"], ["allowed_classes" => false]), ["allowed_classes" => false]);
303  if (!is_array($data)) {
304  continue;
305  }
306  $updated_data = $data;
307  foreach ($mapping as $old_option => $new_option) {
308  if (!in_array($old_option, $data)) {
309  continue;
310  }
311  $idx = array_search($old_option, $data);
312  if ($new_option !== '') {
313  $updated_data[$idx] = $new_option;
314  } else {
315  unset($updated_data[$idx]);
316  }
317  }
318  $fields = array(
319  "sdata" => array("text", serialize(serialize($updated_data)))
320  );
321  $primary = array(
322  "id" => array("integer", $row["id"]),
323  "field_id" => array("integer", $row["field_id"])
324  );
325  $ilDB->update("pg_amd_page_list", $fields, $primary);
326  }
327  }
$data
Definition: storeScorm.php:23
global $DIC
Definition: goto.php:24
global $ilDB
+ Here is the caller graph for this function:

◆ modifyPageContentPostXsl()

ilPCAMDPageList::modifyPageContentPostXsl (   $a_html,
  $a_mode,
  $a_abstract_only = false 
)

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

References $i, $lng, findPages(), ilPageContent\getPage(), and ilWikiUtil\makeLink().

222  {
223  $lng = $this->lng;
224 
225  if ($this->getPage()->getParentType() != "wpg") {
226  return $a_html;
227  }
228 
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');
232 
233  $wiki_id = $this->getPage()->getWikiId();
234 
235  $c_pos = 0;
236  $start = strpos($a_html, "[[[[[AMDPageList;");
237  if (is_int($start)) {
238  $end = strpos($a_html, "]]]]]", $start);
239  }
240  $i = 1;
241  while ($end > 0) {
242  $parts = explode(";", substr($a_html, $start + 17, $end - $start - 17));
243 
244  $list_id = (int) $parts[0];
245  $list_mode = (sizeof($parts) == 2)
246  ? (int) $parts[1]
247  : 0;
248 
249  $ltpl = new ilTemplate("tpl.wiki_amd_page_list.html", true, true, "Modules/Wiki");
250 
251  $pages = $this->findPages($list_id);
252  if (sizeof($pages)) {
253  $ltpl->setCurrentBlock("page_bl");
254  foreach ($pages as $page_id => $page_title) {
255  // see ilWikiUtil::makeLink()
256  $frag = new stdClass;
257  $frag->mFragment = null;
258  $frag->mTextform = $page_title;
259 
260  $ltpl->setVariable("PAGE", ilWikiUtil::makeLink($frag, $wiki_id, $page_title));
261  $ltpl->parseCurrentBlock();
262  }
263  } else {
264  $ltpl->touchBlock("no_hits_bl");
265  }
266 
267  $ltpl->setVariable("LIST_MODE", $list_mode ? "ol" : "ul");
268 
269  $a_html = substr($a_html, 0, $start) .
270  $ltpl->get() .
271  substr($a_html, $end + 5);
272 
273  $start = strpos($a_html, "[[[[[AMDPageList;", $start + 5);
274  $end = 0;
275  if (is_int($start)) {
276  $end = strpos($a_html, "]]]]]", $start);
277  }
278  }
279 
280  return $a_html;
281  }
static makeLink(&$nt, $a_wiki_id, $text='', $query='', $trail='', $prefix='', $a_offline=false)
Make a wiki link, the following formats are supported:
$i
Definition: metadata.php:24
+ Here is the call graph for this function:

◆ setData()

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

Set list settings.

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

References $db, and $ilDB.

80  {
81  $ilDB = $this->db;
82 
83  $data_id = $this->amdpl_node->get_attribute("Id");
84  if ($data_id) {
85  $ilDB->manipulate("DELETE FROM pg_amd_page_list" .
86  " WHERE id = " . $ilDB->quote($data_id, "integer"));
87  } else {
88  $data_id = $ilDB->nextId("pg_amd_page_list");
89  $this->amdpl_node->set_attribute("Id", $data_id);
90  };
91 
92  $this->amdpl_node->set_attribute("Mode", (int) $a_mode);
93 
94  foreach ($a_fields_data as $field_id => $field_data) {
95  $fields = array(
96  "id" => array("integer", $data_id)
97  ,"field_id" => array("integer", $field_id)
98  ,"sdata" => array("text", serialize($field_data))
99  );
100  $ilDB->insert("pg_amd_page_list", $fields);
101  }
102  }
global $ilDB

◆ setNode()

ilPCAMDPageList::setNode (   $a_node)

Set node.

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

57  {
58  parent::setNode($a_node); // this is the PageContent node
59  $this->amdpl_node = $a_node->first_child(); // this is the courses node
60  }

Field Documentation

◆ $db

ilPCAMDPageList::$db
protected

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

Referenced by findPages(), getFieldValues(), and setData().

◆ $dom

ilPCAMDPageList::$dom

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

◆ $lng

ilPCAMDPageList::$lng
protected

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

Referenced by modifyPageContentPostXsl().


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