ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilPCAMDPageList Class Reference

Class ilPCAMDPageList. More...

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

Public Member Functions

 init ()
 Init page content component.
 setNode (&$a_node)
 Set node.
 create (&$a_pg_obj, $a_hier_id, $a_pc_id="")
 Create list node in xml.
 setData (array $a_fields_data)
 Set list settings.
 getFieldValues ($a_data_id=null)
 Get filter field values.
 modifyPageContentPostXsl ($a_html, $a_mode)
 Modify page content after xsl.
- Public Member Functions inherited from ilPageContent
 __construct ($a_pg_obj)
 Constructor.
 setPage ($a_val)
 Set page.
 getPage ()
 Get page.
 getType ()
 Get type of page content.
getNode ()
 Get xml node of page content.
 getJavascriptFiles ()
 Get Javascript files.
 getCssFiles ()
 Get css files.
 getOnloadCode ()
 Get on load code.
 setHierId ($a_hier_id)
 Set hierarchical ID in xml structure.
 getHierId ()
 Get hierarchical id.
 lookupHierId ()
 Get hierarchical id from dom.
 readHierId ()
 Read PC Id.
 setPcId ($a_pcid)
 Set PC Id.
 getPCId ()
 Get PC Id.
 readPCId ()
 Read PC Id.
 writePCId ($a_pc_id)
 Write pc id.
 isGreaterHierId ($a, $b)
 Check whether Hier ID $a is greater than Hier ID $b.
 setEnabled ($value)
 Set Enabled value for page content component.
 enable ()
 Enable page content.
 disable ()
 Disable page content.
 isEnabled ()
 Check whether page content is enabled.
 createPageContentNode ($a_set_this_node=true)
 Create page content node (always use this method first when adding a new element)

Static Public Member Functions

static getLangVars ()
 Get lang vars needed for editing.
static handleCopiedContent (DOMDocument $a_domdoc, $a_self_ass=true, $a_clone_mobs=false)
 Handle copied content.
static migrateField ($a_obj_id, $a_field_id, $old_option, $new_option, $a_is_multi=false)
 Migrate search/filter values on advmd change.
- Static Public Member Functions inherited from ilPageContent
static incEdId ($ed_id)
 Increases an hierarchical editing id at lowest level (last number)
static decEdId ($ed_id)
 Decreases an hierarchical editing id at lowest level (last number)
static haveSameContainer ($ed_id1, $ed_id2)
 Check, if two ids are in same container.
static sortHierIds ($a_array)
 Sort an array of Hier IDS in ascending order.
static afterPageUpdate ($a_page, DOMDocument $a_domdoc, $a_xml, $a_creation)
 After page has been updated (or created)
static beforePageDelete ($a_page)
 Before page is being deleted.
static afterPageHistoryEntry ($a_page, DOMDocument $a_old_domdoc, $a_old_xml, $a_old_nr)
 After page history entry has been created.

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.

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

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.

{
$this->node = $this->createPageContentNode();
$a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
$this->amdpl_node = $this->dom->create_element("AMDPageList");
$this->amdpl_node = $this->node->append_child($this->amdpl_node);
}

+ Here is the call graph for this function:

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().

{
global $ilDB;
$list_values = $this->getFieldValues($a_list_id);
$wiki_id = $this->getPage()->getWikiId();
$found_result = array();
// only search in active fields
$found_ids = null;
$recs = ilAdvancedMDRecord::_getSelectedRecordsByObject("wiki", $wiki_id, "wpg");
foreach($recs as $record)
{
foreach(ilAdvancedMDFieldDefinition::getInstancesByRecordId($record->getRecordId(), true) as $field)
{
if(isset($list_values[$field->getFieldId()]))
{
$field_form = ilADTFactory::getInstance()->getSearchBridgeForDefinitionInstance($field->getADTDefinition(), true, false);
$field->setSearchValueSerialized($field_form, $list_values[$field->getFieldId()]);
$found_pages = $field->searchSubObjects($field_form, $wiki_id, "wpg");
if(is_array($found_ids))
{
$found_ids = array_intersect($found_ids, $found_pages);
}
else
{
$found_ids = $found_pages;
}
}
}
}
if(sizeof($found_ids))
{
$sql = "SELECT id,title FROM il_wiki_page".
" WHERE ".$ilDB->in("id", $found_ids, "", "integer").
" ORDER BY title";
$set = $ilDB->query($sql);
while($row = $ilDB->fetchAssoc($set))
{
$found_result[$row["id"]] = $row["title"];
}
}
return $found_result;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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().

{
global $ilDB;
$res = array();
if(!$a_data_id)
{
if (is_object($this->amdpl_node))
{
$a_data_id = $this->amdpl_node->get_attribute("Id");
}
}
if($a_data_id)
{
$set = $ilDB->query("SELECT * FROM pg_amd_page_list".
" WHERE id = ".$ilDB->quote($a_data_id, "integer"));
while($row = $ilDB->fetchAssoc($set))
{
$res[$row["field_id"]] = unserialize($row["data"]);
}
}
return $res;
}

+ Here is the caller graph for this function:

static ilPCAMDPageList::getLangVars ( )
static

Get lang vars needed for editing.

Returns
array array of lang var keys

Reimplemented from ilPageContent.

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

{
return array("ed_insert_amd_page_list", "pc_amdpl");
}
static ilPCAMDPageList::handleCopiedContent ( DOMDocument  $a_domdoc,
  $a_self_ass = true,
  $a_clone_mobs = false 
)
static

Handle copied content.

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

Parameters
DOMDocument$a_domdocdom document

Reimplemented from ilPageContent.

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

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

{
global $ilDB;
// #15688
$xpath = new DOMXPath($a_domdoc);
$nodes = $xpath->query("//AMDPageList");
foreach($nodes as $node)
{
$old_id = $node->getAttribute("Id");
break;
}
if($old_id)
{
$new_id = $ilDB->nextId("pg_amd_page_list");
$set = $ilDB->query("SELECT * FROM pg_amd_page_list".
" WHERE id = ".$ilDB->quote($old_id, "integer"));
while($row = $ilDB->fetchAssoc($set))
{
$fields = array(
"id" => array("integer", $new_id)
,"field_id" => array("integer", $row["field_id"])
,"data" => array("text", $row["data"])
);
$ilDB->insert("pg_amd_page_list", $fields);
}
$node->setAttribute("Id", $new_id);
}
}
ilPCAMDPageList::init ( )

Init page content component.

Reimplemented from ilPageContent.

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

References ilPageContent\setType().

{
$this->setType("amdpl");
}

+ Here is the call graph for this function:

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 $ilDB, and $row.

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

{
global $ilDB;
// this does only work for select and select multi
$set = $ilDB->query("SELECT * FROM pg_amd_page_list".
" WHERE field_id = ".$ilDB->quote($a_field_id, "integer"));
while($row = $ilDB->fetchAssoc($set))
{
$data = unserialize(unserialize($row["data"]));
if(is_array($data) &&
in_array($old_option, $data))
{
$idx = array_search($old_option, $data);
if($new_option)
{
$data[$idx] = $new_option;
}
else
{
unset($data[$idx]);
}
$fields = array(
"data" => array("text", serialize(serialize($data)))
);
$primary = array(
"id" => array("integer", $row["id"]),
"field_id" => array("integer", $row["field_id"])
);
$ilDB->update("pg_amd_page_list", $fields, $primary);
}
}
}

+ Here is the caller graph for this function:

ilPCAMDPageList::modifyPageContentPostXsl (   $a_output,
  $a_mode 
)

Modify page content after xsl.

Parameters
string$a_output
Returns
string

Reimplemented from ilPageContent.

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

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

{
global $lng;
if($this->getPage()->getParentType() != "wpg")
{
return $a_html;
}
include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php');
include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
include_once('Modules/Wiki/classes/class.ilWikiUtil.php');
$wiki_id = $this->getPage()->getWikiId();
$c_pos = 0;
$start = strpos($a_html, "[[[[[AMDPageList;");
if (is_int($start))
{
$end = strpos($a_html, "]]]]]", $start);
}
$i = 1;
while ($end > 0)
{
$list_id = (int)substr($a_html, $start + 17, $end - $start - 17);
$ltpl = new ilTemplate("tpl.wiki_amd_page_list.html", true, true, "Modules/Wiki");
$pages = $this->findPages($list_id);
if(sizeof($pages))
{
$ltpl->setCurrentBlock("page_bl");
foreach($pages as $page_id => $page_title)
{
// see ilWikiUtil::makeLink()
$frag = new stdClass;
$frag->mFragment = null;
$frag->mTextform = $page_title;
$ltpl->setVariable("PAGE", ilWikiUtil::makeLink($frag, $wiki_id, $page_title));
$ltpl->parseCurrentBlock();
}
}
else
{
$ltpl->touchBlock("no_hits_bl");
}
$a_html = substr($a_html, 0, $start).
$ltpl->get().
substr($a_html, $end + 5);
$start = strpos($a_html, "[[[[[AMDPageList;", $start + 5);
$end = 0;
if (is_int($start))
{
$end = strpos($a_html, "]]]]]", $start);
}
}
return $a_html;
}

+ Here is the call graph for this function:

ilPCAMDPageList::setData ( array  $a_fields_data)

Set list settings.

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

References $ilDB.

{
global $ilDB;
$data_id = $this->amdpl_node->get_attribute("Id");
if($data_id)
{
$ilDB->manipulate("DELETE FROM pg_amd_page_list".
" WHERE id = ".$ilDB->quote($data_id, "integer"));
}
else
{
$data_id = $ilDB->nextId("pg_amd_page_list");
$this->amdpl_node->set_attribute("Id", $data_id);
};
foreach($a_fields_data as $field_id => $field_data)
{
$fields = array(
"id" => array("integer", $data_id)
,"field_id" => array("integer", $field_id)
,"data" => array("text", serialize($field_data))
);
$ilDB->insert("pg_amd_page_list", $fields);
}
}
ilPCAMDPageList::setNode ( $a_node)

Set node.

Reimplemented from ilPageContent.

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

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

Field Documentation

ilPCAMDPageList::$dom

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


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