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

Class ilPCTabs. More...

+ Inheritance diagram for ilPCTabs:
+ Collaboration diagram for ilPCTabs:

Public Member Functions

 init ()
 Init page content component. More...
 
 setNode (&$a_node)
 Set content node. More...
 
 create (&$a_pg_obj, $a_hier_id, $a_pc_id="")
 Create new Tabs node. More...
 
 setTabType ($a_type="HorizontalTabs")
 Set type of tabs. More...
 
 getTabType ()
 Get type of tabs. More...
 
 setContentWidth ($a_val)
 Set content width. More...
 
 getContentWidth ()
 Get content width. More...
 
 setContentHeight ($a_val)
 Set content height. More...
 
 getContentHeight ()
 Get content height. More...
 
 setHorizontalAlign ($a_val)
 Set horizontal align. More...
 
 getHorizontalAlign ()
 Get horizontal align. More...
 
 setBehavior ($a_val)
 Set behavior. More...
 
 getBehavior ()
 Get behavior. More...
 
 getCaptions ()
 Get captions. More...
 
 getCaption ($a_hier_id, $a_pc_id)
 Get caption. More...
 
 savePositions ($a_pos)
 Save positions of tabs. More...
 
 saveCaptions ($a_captions)
 Add Tab items. More...
 
 deleteTab ($a_hier_id, $a_pc_id)
 Save positions of tabs. More...
 
 addTab ($a_caption)
 Add a tab. More...
 
 setTemplate ($a_template)
 Set template. More...
 
 getTemplate ()
 Get template. More...
 
- 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 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

 $tabs_node
 
const ACCORDION_HOR = "HorizontalAccordion"
 
const ACCORDION_VER = "VerticalAccordion"
 
- Data Fields inherited from ilPageContent
 $hier_id
 
 $node
 
 $dom
 

Protected Member Functions

 setTabsAttribute ($a_attr, $a_value)
 Set attribute of tabs tag. More...
 
- Protected Member Functions inherited from ilPageContent
 setType ($a_type)
 Set Type. More...
 

Detailed Description

Class ilPCTabs.

Tabbed contents (see ILIAS DTD)

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 36 of file class.ilPCTabs.php.

Member Function Documentation

◆ addTab()

ilPCTabs::addTab (   $a_caption)

Add a tab.

Definition at line 340 of file class.ilPCTabs.php.

References ilDOMUtil\setFirstOptionalElement().

341  {
342  $new_item = $this->dom->create_element("Tab");
343  $new_item = $this->tabs_node->append_child($new_item);
344  ilDOMUtil::setFirstOptionalElement($this->dom, $new_item, "TabCaption",
345  array(), $a_caption, array());
346  }
setFirstOptionalElement(&$doc, &$parent_node, $a_node_name, $a_successors, $a_content, $a_attributes, $a_remove_childs=true)
searches for an element $a_node_name within the childs of $parent_node if no node is found...
+ Here is the call graph for this function:

◆ create()

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

Create new Tabs node.

Definition at line 62 of file class.ilPCTabs.php.

References ilPageContent\createPageContentNode(), and IL_INSERT_AFTER.

63  {
64  $this->node = $this->createPageContentNode();
65  $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
66  $this->tabs_node =& $this->dom->create_element("Tabs");
67  $this->tabs_node =& $this->node->append_child($this->tabs_node);
68  }
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:

◆ deleteTab()

ilPCTabs::deleteTab (   $a_hier_id,
  $a_pc_id 
)

Save positions of tabs.

Definition at line 319 of file class.ilPCTabs.php.

320  {
321  // File Item
322  $childs = $this->tabs_node->child_nodes();
323  $nodes = array();
324  for ($i=0; $i<count($childs); $i++)
325  {
326  if ($childs[$i]->node_name() == "Tab")
327  {
328  if ($a_pc_id == $childs[$i]->get_attribute("PCID") &&
329  $a_hier_id == $childs[$i]->get_attribute("HierId"))
330  {
331  $childs[$i]->unlink($childs[$i]);
332  }
333  }
334  }
335  }

◆ getBehavior()

ilPCTabs::getBehavior ( )

Get behavior.

Returns
string behavior

Definition at line 190 of file class.ilPCTabs.php.

191  {
192  return $this->tabs_node->get_attribute("Behavior");
193  }

◆ getCaption()

ilPCTabs::getCaption (   $a_hier_id,
  $a_pc_id 
)

Get caption.

Definition at line 231 of file class.ilPCTabs.php.

232  {
233  $captions = array();
234  $tab_nodes = $this->tabs_node->child_nodes();
235  $k = 0;
236  for($i = 0; $i < count($tab_nodes); $i++)
237  {
238  if ($tab_nodes[$i]->node_name() == "Tab")
239  {
240  if ($a_pc_id == $tab_nodes[$i]->get_attribute("PCID") &&
241  ($a_hier_id == $tab_nodes[$i]->get_attribute("HierId")))
242  {
243  $tab_node_childs = $tab_nodes[$i]->child_nodes();
244  for($j = 0; $j < count($tab_node_childs); $j++)
245  {
246  if ($tab_node_childs[$j]->node_name() == "TabCaption")
247  {
248  return $tab_node_childs[$j]->get_content();
249  }
250  }
251  }
252  }
253  }
254 
255  return "";
256  }

◆ getCaptions()

ilPCTabs::getCaptions ( )

Get captions.

Definition at line 198 of file class.ilPCTabs.php.

References ilPageContent\$hier_id.

199  {
200  $captions = array();
201  $tab_nodes = $this->tabs_node->child_nodes();
202  $k = 0;
203  for($i = 0; $i < count($tab_nodes); $i++)
204  {
205  if ($tab_nodes[$i]->node_name() == "Tab")
206  {
207  $pc_id = $tab_nodes[$i]->get_attribute("PCID");
208  $hier_id = $tab_nodes[$i]->get_attribute("HierId");
209 
210  $tab_node_childs = $tab_nodes[$i]->child_nodes();
211  $current_caption = "";
212  for($j = 0; $j < count($tab_node_childs); $j++)
213  {
214  if ($tab_node_childs[$j]->node_name() == "TabCaption")
215  {
216  $current_caption = $tab_node_childs[$j]->get_content();
217  }
218  }
219  $captions[] = array("pos" => $k,
220  "caption" => $current_caption, "pc_id" => $pc_id, "hier_id" => $hier_id);
221  $k++;
222  }
223  }
224 
225  return $captions;
226  }

◆ getContentHeight()

ilPCTabs::getContentHeight ( )

Get content height.

Returns
int content height

Definition at line 150 of file class.ilPCTabs.php.

151  {
152  return $this->tabs_node->get_attribute("ContentHeight");
153  }

◆ getContentWidth()

ilPCTabs::getContentWidth ( )

Get content width.

Returns
int content width

Definition at line 130 of file class.ilPCTabs.php.

131  {
132  return $this->tabs_node->get_attribute("ContentWidth");
133  }

◆ getHorizontalAlign()

ilPCTabs::getHorizontalAlign ( )

Get horizontal align.

Returns
string horizontal align

Definition at line 170 of file class.ilPCTabs.php.

171  {
172  return $this->tabs_node->get_attribute("HorizontalAlign");
173  }

◆ getLangVars()

static ilPCTabs::getLangVars ( )
static

Get lang vars needed for editing.

Returns
array array of lang var keys

Definition at line 372 of file class.ilPCTabs.php.

373  {
374  return array("pc_vacc", "pc_hacc");
375  }

◆ getTabType()

ilPCTabs::getTabType ( )

Get type of tabs.

Definition at line 110 of file class.ilPCTabs.php.

111  {
112  return $this->tabs_node->get_attribute("Type");
113  }

◆ getTemplate()

ilPCTabs::getTemplate ( )

Get template.

Returns
string template

Definition at line 363 of file class.ilPCTabs.php.

364  {
365  return $this->tabs_node->get_attribute("Template");
366  }

◆ init()

ilPCTabs::init ( )

Init page content component.

Definition at line 45 of file class.ilPCTabs.php.

References ilPageContent\setType().

46  {
47  $this->setType("tabs");
48  }
setType($a_type)
Set Type.
+ Here is the call graph for this function:

◆ saveCaptions()

ilPCTabs::saveCaptions (   $a_captions)

Add Tab items.

Definition at line 291 of file class.ilPCTabs.php.

References ilPageContent\$hier_id, ilDOMUtil\deleteAllChildsByName(), and ilDOMUtil\setFirstOptionalElement().

292  {
293  // iterate all tab nodes
294  $tab_nodes = $this->tabs_node->child_nodes();
295  for($i = 0; $i < count($tab_nodes); $i++)
296  {
297  if ($tab_nodes[$i]->node_name() == "Tab")
298  {
299  $pc_id = $tab_nodes[$i]->get_attribute("PCID");
300  $hier_id = $tab_nodes[$i]->get_attribute("HierId");
301  $k = $hier_id.":".$pc_id;
302  // if caption given, set it, otherwise delete caption subitem
303  if ($a_captions[$k] != "")
304  {
305  ilDOMUtil::setFirstOptionalElement($this->dom, $tab_nodes[$i], "TabCaption",
306  array(), $a_captions[$k], array());
307  }
308  else
309  {
310  ilDOMUtil::deleteAllChildsByName($tab_nodes[$i], array("TabCaption"));
311  }
312  }
313  }
314  }
deleteAllChildsByName(&$a_parent, $a_node_names)
delete all childs of a node by names in $a_node_names
setFirstOptionalElement(&$doc, &$parent_node, $a_node_name, $a_successors, $a_content, $a_attributes, $a_remove_childs=true)
searches for an element $a_node_name within the childs of $parent_node if no node is found...
+ Here is the call graph for this function:

◆ savePositions()

ilPCTabs::savePositions (   $a_pos)

Save positions of tabs.

Definition at line 261 of file class.ilPCTabs.php.

References ilPageContent\$hier_id.

262  {
263  asort($a_pos);
264 
265  // File Item
266  $childs = $this->tabs_node->child_nodes();
267  $nodes = array();
268  for ($i=0; $i<count($childs); $i++)
269  {
270  if ($childs[$i]->node_name() == "Tab")
271  {
272  $pc_id = $childs[$i]->get_attribute("PCID");
273  $hier_id = $childs[$i]->get_attribute("HierId");
274  $nodes[$hier_id.":".$pc_id] = $childs[$i];
275  $childs[$i]->unlink($childs[$i]);
276  }
277  }
278 
279  foreach($a_pos as $k => $v)
280  {
281  if (is_object($nodes[$k]))
282  {
283  $nodes[$k] = $this->tabs_node->append_child($nodes[$k]);
284  }
285  }
286  }

◆ setBehavior()

ilPCTabs::setBehavior (   $a_val)

Set behavior.

Parameters
stringbehavior

Definition at line 180 of file class.ilPCTabs.php.

References setTabsAttribute().

181  {
182  $this->setTabsAttribute("Behavior", $a_val);
183  }
setTabsAttribute($a_attr, $a_value)
Set attribute of tabs tag.
+ Here is the call graph for this function:

◆ setContentHeight()

ilPCTabs::setContentHeight (   $a_val)

Set content height.

Parameters
intcontent height

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

References setTabsAttribute().

141  {
142  $this->setTabsAttribute("ContentHeight", $a_val);
143  }
setTabsAttribute($a_attr, $a_value)
Set attribute of tabs tag.
+ Here is the call graph for this function:

◆ setContentWidth()

ilPCTabs::setContentWidth (   $a_val)

Set content width.

Parameters
intcontent width

Definition at line 120 of file class.ilPCTabs.php.

References setTabsAttribute().

121  {
122  $this->setTabsAttribute("ContentWidth", $a_val);
123  }
setTabsAttribute($a_attr, $a_value)
Set attribute of tabs tag.
+ Here is the call graph for this function:

◆ setHorizontalAlign()

ilPCTabs::setHorizontalAlign (   $a_val)

Set horizontal align.

Parameters
stringhorizontal align

Definition at line 160 of file class.ilPCTabs.php.

References setTabsAttribute().

161  {
162  $this->setTabsAttribute("HorizontalAlign", $a_val);
163  }
setTabsAttribute($a_attr, $a_value)
Set attribute of tabs tag.
+ Here is the call graph for this function:

◆ setNode()

ilPCTabs::setNode ( $a_node)

Set content node.

Definition at line 53 of file class.ilPCTabs.php.

54  {
55  parent::setNode($a_node); // this is the PageContent node
56  $this->tabs_node =& $a_node->first_child(); // this is the Tabs node
57  }

◆ setTabsAttribute()

ilPCTabs::setTabsAttribute (   $a_attr,
  $a_value 
)
protected

Set attribute of tabs tag.

Parameters
stringattribute name
stringattribute value

Definition at line 76 of file class.ilPCTabs.php.

Referenced by setBehavior(), setContentHeight(), setContentWidth(), setHorizontalAlign(), and setTemplate().

77  {
78  if (!empty($a_value))
79  {
80  $this->tabs_node->set_attribute($a_attr, $a_value);
81  }
82  else
83  {
84  if ($this->tabs_node->has_attribute($a_attr))
85  {
86  $this->tabs_node->remove_attribute($a_attr);
87  }
88  }
89  }
+ Here is the caller graph for this function:

◆ setTabType()

ilPCTabs::setTabType (   $a_type = "HorizontalTabs")

Set type of tabs.

Parameters
string$a_type("HorizontalTabs" | "Accordion")

Definition at line 96 of file class.ilPCTabs.php.

References ACCORDION_HOR, and ACCORDION_VER.

97  {
98  switch ($a_type)
99  {
102  $this->tabs_node->set_attribute("Type", $a_type);
103  break;
104  }
105  }
const ACCORDION_HOR
const ACCORDION_VER

◆ setTemplate()

ilPCTabs::setTemplate (   $a_template)

Set template.

Parameters
string$a_templatetemplate

Definition at line 353 of file class.ilPCTabs.php.

References setTabsAttribute().

354  {
355  $this->setTabsAttribute("Template", $a_template);
356  }
setTabsAttribute($a_attr, $a_value)
Set attribute of tabs tag.
+ Here is the call graph for this function:

Field Documentation

◆ $tabs_node

ilPCTabs::$tabs_node

Definition at line 38 of file class.ilPCTabs.php.

◆ ACCORDION_HOR

const ilPCTabs::ACCORDION_HOR = "HorizontalAccordion"

◆ ACCORDION_VER

const ilPCTabs::ACCORDION_VER = "VerticalAccordion"

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