2007-07-19 12:40:28 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* TabSet.php contains all of the classes used to build tabbed forms
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Defines a set of tabs in a form.
|
|
|
|
* The tabs are build with our standard tabstrip javascript library. By default, the HTML is
|
|
|
|
* generated using FieldHolder.
|
|
|
|
*/
|
|
|
|
class TabSet extends CompositeField {
|
|
|
|
public function __construct($id) {
|
|
|
|
$tabs = func_get_args();
|
|
|
|
$this->id = array_shift($tabs);
|
|
|
|
$this->title = $this->id;
|
|
|
|
|
|
|
|
foreach($tabs as $tab) $tab->setTabSet($this);
|
|
|
|
|
|
|
|
parent::__construct($tabs);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function id() {
|
|
|
|
if($this->tabSet) return $this->tabSet->id() . '_' . $this->id . '_set';
|
|
|
|
else return $this->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a tab-strip and the associated tabs.
|
|
|
|
* The HTML is a standardised format, containing a <ul;
|
|
|
|
*/
|
|
|
|
public function FieldHolder() {
|
|
|
|
Requirements::javascript("jsparty/loader.js");
|
|
|
|
Requirements::javascript("jsparty/prototype.js");
|
|
|
|
Requirements::javascript("jsparty/behaviour.js");
|
|
|
|
Requirements::javascript("jsparty/prototype_improvements.js");
|
|
|
|
Requirements::javascript("jsparty/tabstrip/tabstrip.js");
|
|
|
|
Requirements::css("jsparty/tabstrip/tabstrip.css");
|
|
|
|
|
|
|
|
return $this->renderWith("TabSetFieldHolder");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a dataobject set of all this classes tabs
|
|
|
|
*/
|
|
|
|
public function Tabs() {
|
|
|
|
return $this->children;
|
|
|
|
}
|
|
|
|
public function setTabs($children){
|
|
|
|
$this->children = $children;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setTabSet($val) {
|
|
|
|
$this->tabSet = $val;
|
|
|
|
}
|
|
|
|
public function getTabSet() {
|
|
|
|
return $this->tabSet;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the named tab
|
|
|
|
*/
|
|
|
|
public function fieldByName($name) {
|
|
|
|
foreach($this->children as $child) {
|
|
|
|
if($name == $child->Name || $name == $child->id) return $child;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a new child field to the end of the set.
|
|
|
|
*/
|
2007-11-04 22:35:51 +01:00
|
|
|
public function push($field) {
|
2007-07-19 12:40:28 +02:00
|
|
|
parent::push($field);
|
|
|
|
$field->setTabSet($this);
|
|
|
|
}
|
|
|
|
public function insertBefore($field, $insertBefore) {
|
|
|
|
parent::insertBefore($field, $insertBefore);
|
|
|
|
$field->setTabSet($this);
|
|
|
|
}
|
|
|
|
|
2007-09-16 18:05:59 +02:00
|
|
|
public function insertBeforeRecursive($field, $insertBefore, $level) {
|
|
|
|
$level = parent::insertBeforeRecursive($field, $insertBefore, $level+1);
|
|
|
|
if ($level === 0) $field->setTabSet($this);
|
|
|
|
return $level;
|
|
|
|
}
|
|
|
|
|
2007-07-19 12:40:28 +02:00
|
|
|
public function removeByName( $tabName ) {
|
|
|
|
parent::removeByName( $tabName );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|