ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
ilPCAMDPageList Class Reference

Class ilPCAMDPageList. 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)
 Set list settings. More...
 
 getFieldValues ($a_data_id=null)
 Get filter field values. More...
 
 modifyPageContentPostXsl ($a_html, $a_mode)
 
- 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 ()
 Get Javascript files. More...
 
 getCssFiles ()
 Get css files. More...
 
 getOnloadCode ()
 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...
 
 readPCId ()
 Read PC Id. More...
 
 writePCId ($a_pc_id)
 Write pc id. More...
 
 isGreaterHierId ($a, $b)
 Check whether Hier ID $a is greater than Hier ID $b. 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)
 Modify page content after xsl. 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 ($a_obj_id, $a_field_id, $old_option, $new_option, $a_is_multi=false)
 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 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
 

Protected Member Functions

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

Detailed Description

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
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 52 of file class.ilPCAMDPageList.php.

References ilPageContent\createPageContentNode(), and IL_INSERT_AFTER.

53  {
54  $this->node = $this->createPageContentNode();
55  $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
56  $this->amdpl_node = $this->dom->create_element("AMDPageList");
57  $this->amdpl_node = $this->node->append_child($this->amdpl_node);
58  }
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 162 of file class.ilPCAMDPageList.php.

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

Referenced by modifyPageContentPostXsl().

163  {
164  global $ilDB;
165 
166  $list_values = $this->getFieldValues($a_list_id);
167  $wiki_id = $this->getPage()->getWikiId();
168 
169  $found_result = array();
170 
171  // only search in active fields
172  $found_ids = null;
173  $recs = ilAdvancedMDRecord::_getSelectedRecordsByObject("wiki", $wiki_id, "wpg");
174  foreach($recs as $record)
175  {
176  foreach(ilAdvancedMDFieldDefinition::getInstancesByRecordId($record->getRecordId(), true) as $field)
177  {
178  if(isset($list_values[$field->getFieldId()]))
179  {
180  $field_form = ilADTFactory::getInstance()->getSearchBridgeForDefinitionInstance($field->getADTDefinition(), true, false);
181  $field->setSearchValueSerialized($field_form, $list_values[$field->getFieldId()]);
182  $found_pages = $field->searchSubObjects($field_form, $wiki_id, "wpg");
183  if(is_array($found_ids))
184  {
185  $found_ids = array_intersect($found_ids, $found_pages);
186  }
187  else
188  {
189  $found_ids = $found_pages;
190  }
191  }
192  }
193  }
194 
195  if(sizeof($found_ids))
196  {
197  $sql = "SELECT id,title FROM il_wiki_page".
198  " WHERE ".$ilDB->in("id", $found_ids, "", "integer").
199  " ORDER BY title";
200  $set = $ilDB->query($sql);
201  while($row = $ilDB->fetchAssoc($set))
202  {
203  $found_result[$row["id"]] = $row["title"];
204  }
205  }
206 
207  return $found_result;
208  }
static getInstance()
Get singleton.
static getInstancesByRecordId($a_record_id, $a_only_searchable=false)
Get definitions by record id.
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.
global $ilDB
+ 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 96 of file class.ilPCAMDPageList.php.

References $ilDB, $res, and $row.

Referenced by findPages().

97  {
98  global $ilDB;
99 
100  $res = array();
101 
102  if(!$a_data_id)
103  {
104  if (is_object($this->amdpl_node))
105  {
106  $a_data_id = $this->amdpl_node->get_attribute("Id");
107  }
108  }
109 
110  if($a_data_id)
111  {
112  $set = $ilDB->query("SELECT * FROM pg_amd_page_list".
113  " WHERE id = ".$ilDB->quote($a_data_id, "integer"));
114  while($row = $ilDB->fetchAssoc($set))
115  {
116  $res[$row["field_id"]] = unserialize($row["data"]);
117  }
118  }
119 
120  return $res;
121  }
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 32 of file class.ilPCAMDPageList.php.

33  {
34  return array("ed_insert_amd_page_list", "pc_amdpl");
35  }

◆ handleCopiedContent()

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

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

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

124  {
125  global $ilDB;
126 
127  // #15688
128 
129  $xpath = new DOMXPath($a_domdoc);
130  $nodes = $xpath->query("//AMDPageList");
131  foreach($nodes as $node)
132  {
133  $old_id = $node->getAttribute("Id");
134  break;
135  }
136 
137  if($old_id)
138  {
139  $new_id = $ilDB->nextId("pg_amd_page_list");
140 
141  $set = $ilDB->query("SELECT * FROM pg_amd_page_list".
142  " WHERE id = ".$ilDB->quote($old_id, "integer"));
143  while($row = $ilDB->fetchAssoc($set))
144  {
145  $fields = array(
146  "id" => array("integer", $new_id)
147  ,"field_id" => array("integer", $row["field_id"])
148  ,"data" => array("text", $row["data"])
149  );
150  $ilDB->insert("pg_amd_page_list", $fields);
151  }
152 
153  $node->setAttribute("Id", $new_id);
154  }
155  }
global $ilDB

◆ init()

ilPCAMDPageList::init ( )

Init page content component.

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

References ilPageContent\setType().

24  {
25  $this->setType("amdpl");
26  }
setType($a_type)
Set Type.
+ Here is the call graph for this function:

◆ migrateField()

static ilPCAMDPageList::migrateField (   $a_obj_id,
  $a_field_id,
  $old_option,
  $new_option,
  $a_is_multi = false 
)
static

Migrate search/filter values on advmd change.

Parameters
int$a_obj_id
int$a_field_id
string$old_option
string$new_option
bool$a_is_multi

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

References $data, $ilDB, and $row.

Referenced by ilAdvancedMDFieldDefinitionSelectMulti\update(), and ilAdvancedMDFieldDefinitionSelect\update().

283  {
284  global $ilDB;
285 
286  // this does only work for select and select multi
287 
288  $set = $ilDB->query("SELECT * FROM pg_amd_page_list".
289  " WHERE field_id = ".$ilDB->quote($a_field_id, "integer"));
290  while($row = $ilDB->fetchAssoc($set))
291  {
292  $data = unserialize(unserialize($row["data"]));
293  if(is_array($data) &&
294  in_array($old_option, $data))
295  {
296  $idx = array_search($old_option, $data);
297  if($new_option)
298  {
299  $data[$idx] = $new_option;
300  }
301  else
302  {
303  unset($data[$idx]);
304  }
305 
306  $fields = array(
307  "data" => array("text", serialize(serialize($data)))
308  );
309  $primary = array(
310  "id" => array("integer", $row["id"]),
311  "field_id" => array("integer", $row["field_id"])
312  );
313  $ilDB->update("pg_amd_page_list", $fields, $primary);
314  }
315  }
316  }
global $ilDB
+ Here is the caller graph for this function:

◆ modifyPageContentPostXsl()

ilPCAMDPageList::modifyPageContentPostXsl (   $a_html,
  $a_mode 
)

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

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

211  {
212  global $lng;
213 
214  if($this->getPage()->getParentType() != "wpg")
215  {
216  return $a_html;
217  }
218 
219  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php');
220  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
221  include_once('Modules/Wiki/classes/class.ilWikiUtil.php');
222 
223  $wiki_id = $this->getPage()->getWikiId();
224 
225  $c_pos = 0;
226  $start = strpos($a_html, "[[[[[AMDPageList;");
227  if (is_int($start))
228  {
229  $end = strpos($a_html, "]]]]]", $start);
230  }
231  $i = 1;
232  while ($end > 0)
233  {
234  $list_id = (int)substr($a_html, $start + 17, $end - $start - 17);
235 
236  $ltpl = new ilTemplate("tpl.wiki_amd_page_list.html", true, true, "Modules/Wiki");
237 
238  $pages = $this->findPages($list_id);
239  if(sizeof($pages))
240  {
241  $ltpl->setCurrentBlock("page_bl");
242  foreach($pages as $page_id => $page_title)
243  {
244  // see ilWikiUtil::makeLink()
245  $frag = new stdClass;
246  $frag->mFragment = null;
247  $frag->mTextform = $page_title;
248 
249  $ltpl->setVariable("PAGE", ilWikiUtil::makeLink($frag, $wiki_id, $page_title));
250  $ltpl->parseCurrentBlock();
251  }
252  }
253  else
254  {
255  $ltpl->touchBlock("no_hits_bl");
256  }
257 
258  $a_html = substr($a_html, 0, $start).
259  $ltpl->get().
260  substr($a_html, $end + 5);
261 
262  $start = strpos($a_html, "[[[[[AMDPageList;", $start + 5);
263  $end = 0;
264  if (is_int($start))
265  {
266  $end = strpos($a_html, "]]]]]", $start);
267  }
268  }
269 
270  return $a_html;
271  }
static makeLink(&$nt, $a_wiki_id, $text='', $query='', $trail='', $prefix='', $a_offline=false)
Make a wiki link, the following formats are supported:
special template class to simplify handling of ITX/PEAR
global $lng
Definition: privfeed.php:40
+ Here is the call graph for this function:

◆ setData()

ilPCAMDPageList::setData ( array  $a_fields_data)

Set list settings.

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

References $ilDB.

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

◆ setNode()

ilPCAMDPageList::setNode ( $a_node)

Set node.

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

41  {
42  parent::setNode($a_node); // this is the PageContent node
43  $this->amdpl_node =& $a_node->first_child(); // this is the courses node
44  }

Field Documentation

◆ $dom

ilPCAMDPageList::$dom

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


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