mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
7fa0a96c71
svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.2.2 ........ r51938 | aoneil | 2008-04-01 14:34:26 +1300 (Tue, 01 Apr 2008) | 2 lines fix php notice ........ git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@51932 467b73ca-7a2a-4603-9d3b-597d59a354a9
94 lines
2.3 KiB
PHP
94 lines
2.3 KiB
PHP
<?php
|
|
/**
|
|
* @package forms
|
|
* @subpackage fields-structural
|
|
*/
|
|
|
|
/**
|
|
* 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.
|
|
* @package forms
|
|
* @subpackage fields-structural
|
|
*/
|
|
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() {
|
|
if(isset($this->tabSet)) 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.
|
|
*/
|
|
public function push($field) {
|
|
parent::push($field);
|
|
$field->setTabSet($this);
|
|
}
|
|
public function insertBefore($field, $insertBefore) {
|
|
parent::insertBefore($field, $insertBefore);
|
|
$field->setTabSet($this);
|
|
}
|
|
|
|
public function insertBeforeRecursive($field, $insertBefore, $level) {
|
|
$level = parent::insertBeforeRecursive($field, $insertBefore, $level+1);
|
|
if ($level === 0) $field->setTabSet($this);
|
|
return $level;
|
|
}
|
|
|
|
public function removeByName( $tabName ) {
|
|
parent::removeByName( $tabName );
|
|
}
|
|
}
|
|
?>
|