2007-07-19 12:40:28 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* 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.
|
2008-01-09 05:18:36 +01:00
|
|
|
* @package forms
|
|
|
|
* @subpackage fields-structural
|
2007-07-19 12:40:28 +02:00
|
|
|
*/
|
|
|
|
class TabSet extends CompositeField {
|
|
|
|
public function __construct($id) {
|
|
|
|
$tabs = func_get_args();
|
|
|
|
$this->id = array_shift($tabs);
|
2008-09-12 06:42:24 +02:00
|
|
|
$this->name = $this->id;
|
2007-07-19 12:40:28 +02:00
|
|
|
$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() {
|
ENHANCEMENT Introduced constants for system paths like /sapphire in preparation for a more flexible directory reorganisation. Instead of hardcoding your path, please use the following constants: BASE_PATH, BASE_URL, SAPPHIRE_DIR, SAPPHIRE_PATH, CMS_DIR, CMS_PATH, THIRDPARTY_DIR, THIRDPARTY_PATH, ASSETS_DIR, ASSETS_PATH, THEMES_DIR, THEMES_PATH
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@63175 467b73ca-7a2a-4603-9d3b-597d59a354a9
2008-09-28 15:12:20 +02:00
|
|
|
Requirements::javascript(THIRDPARTY_DIR . "/loader.js");
|
|
|
|
Requirements::javascript(THIRDPARTY_DIR . "/prototype.js");
|
|
|
|
Requirements::javascript(THIRDPARTY_DIR . "/behaviour.js");
|
|
|
|
Requirements::javascript(THIRDPARTY_DIR . "/prototype_improvements.js");
|
|
|
|
Requirements::javascript(THIRDPARTY_DIR . "/tabstrip/tabstrip.js");
|
|
|
|
Requirements::css(THIRDPARTY_DIR . "/tabstrip/tabstrip.css");
|
2007-07-19 12:40:28 +02:00
|
|
|
|
|
|
|
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() {
|
2008-04-01 03:50:34 +02:00
|
|
|
if(isset($this->tabSet)) return $this->tabSet;
|
2007-07-19 12:40:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
}
|
|
|
|
|
2008-09-12 06:42:24 +02:00
|
|
|
public function removeByName( $tabName, $dataFieldOnly = false ) {
|
|
|
|
parent::removeByName( $tabName, $dataFieldOnly );
|
2007-07-19 12:40:28 +02:00
|
|
|
}
|
|
|
|
}
|
2008-04-01 03:50:34 +02:00
|
|
|
?>
|