/**
  * @param string $name
  * @param string $title
  * @param array|FieldList $children
  */
 public function __construct($name, $title, $children = null)
 {
     $this->name = $name;
     $this->title = $title;
     $this->children = $children ? $children : new FieldList();
     parent::__construct($children);
 }
 /**
  * @param string $name Identifier
  * @param string $title (Optional) Natural language title of the tabset
  * @param Tab|TabSet $unknown All further parameters are inserted as children into the TabSet
  */
 public function __construct($name)
 {
     $args = func_get_args();
     $name = array_shift($args);
     if (!is_string($name)) {
         user_error('TabSet::__construct(): $name parameter to a valid string', E_USER_ERROR);
     }
     $this->name = $name;
     $this->id = $name;
     // Legacy handling: only assume second parameter as title if its a string,
     // otherwise it might be a formfield instance
     if (isset($args[0]) && is_string($args[0])) {
         $title = array_shift($args);
     }
     $this->title = isset($title) ? $title : FormField::name_to_label($name);
     if ($args) {
         foreach ($args as $tab) {
             $isValidArg = is_object($tab) && (!$tab instanceof Tab || !$tab instanceof TabSet);
             if (!$isValidArg) {
                 user_error('TabSet::__construct(): Parameter not a valid Tab instance', E_USER_ERROR);
             }
             $tab->setTabSet($this);
         }
     }
     parent::__construct($args);
 }
 /**
  * Constructor
  *
  * @param string    $name     Name
  * @param string    $title    Title
  * @param FieldList $fields   CMS fields
  * @param mixed     $children Children
  * 
  * @return void
  */
 public function __construct($name, $title = '', $fields = null, $children = array())
 {
     parent::__construct($children);
     $this->setName($name);
     $this->setTitle($title);
     $this->setFields($fields);
 }
Exemplo n.º 4
0
 /**
  * @param string $name Identifier
  * @param string|Tab|TabSet $titleOrTab Natural language title of the tabset, or first tab.
  * If its left out, the class uses {@link FormField::name_to_label()} to produce a title
  * from the {@link $name} parameter.
  * @param Tab|TabSet ...$tabs All further parameters are inserted as children into the TabSet
  */
 public function __construct($name, $titleOrTab = null, $tabs = null)
 {
     if (!is_string($name)) {
         throw new InvalidArgumentException('Invalid string parameter for $name');
     }
     // Get following arguments
     $tabs = func_get_args();
     array_shift($tabs);
     // Detect title from second argument, if it is a string
     if ($titleOrTab && is_string($titleOrTab)) {
         $title = $titleOrTab;
         array_shift($tabs);
     } else {
         $title = static::name_to_label($name);
     }
     // Normalise children list
     if (count($tabs) === 1 && (is_array($tabs[0]) || $tabs[0] instanceof FieldList)) {
         $tabs = $tabs[0];
     }
     // Ensure tabs are assigned to this tabset
     if ($tabs) {
         foreach ($tabs as $tab) {
             if ($tab instanceof Tab || $tab instanceof TabSet) {
                 $tab->setTabSet($this);
             } else {
                 throw new InvalidArgumentException("TabSet can only contain instances of other Tab or Tabsets");
             }
         }
     }
     parent::__construct($tabs);
     // Assign name and title (not assigned by parent constructor)
     $this->setName($name);
     $this->setTitle($title);
     $this->setID(Convert::raw2htmlid($name));
 }
Exemplo n.º 5
0
	/**
	 * Create a new selection group.
	 * @param name The field name of the selection group.
	 * @param items The list of items to show.  This should be a map.  The keys will be the radio
	 * button option names, and the values should be the associated field to display.  If you want,
	 * you can make this field a composite field.
	 * 
	 * If you want to a have a title that is different from the value of the key, you can express it
	 * as "InternalVal//This is the Title"
	 */
	function __construct($name, $items) {
		$this->name = $name;
		
		parent::__construct($items);
		
		Requirements::css(FRAMEWORK_DIR . '/css/SelectionGroup.css');
	}
Exemplo n.º 6
0
 function __construct($name, $title, $children)
 {
     $this->name = $name;
     $this->title = $title;
     $this->startClosed(true);
     parent::__construct($children);
 }
Exemplo n.º 7
0
 public function __construct($title)
 {
     $args = func_get_args();
     $this->title = array_shift($args);
     $this->id = ereg_replace('[^0-9A-Za-z]+', '', $this->title);
     parent::__construct($args);
 }
 public function __construct($name, $title = null, $value = null)
 {
     $this->labelField = LabelField::create($name . "Label", self::name_to_label($name))->addExtraClass("left");
     $this->checkboxField = CheckboxField::create($name, "", $value);
     $this->labelField->setTemplate("LabeledCheckboxLabelField");
     $this->addExtraClass("field");
     parent::__construct(array($this->labelField, $this->checkboxField));
 }
 public function __construct($name, $children = null)
 {
     $this->setName($name);
     if (!$children) {
         $children = array();
     }
     parent::__construct($children);
 }
 /**
  * @param String $value Form field identifier
  * @param FormField|array $fields Contents of the option
  * @param String $title Title to show for the radio button option
  */
 function __construct($value, $fields = null, $title = null)
 {
     $this->setValue($value);
     if ($fields && !is_array($fields)) {
         $fields = array($fields);
     }
     parent::__construct($fields);
     $this->setTitle($title ?: $value);
 }
 public function __construct($name, $inlineForm, $actionToExecuteOnSaveInto = null)
 {
     $this->name = $name;
     $this->inlineForm = $inlineForm;
     $this->actionToExecuteOnSaveInto = $actionToExecuteOnSaveInto;
     $this->inlineForm->setName($name);
     $this->inlineForm->disableSecurityToken();
     parent::__construct($inlineForm->Fields());
 }
 public function __construct($name, $title = null, $value = null)
 {
     $this->name = $name;
     $this->setTitle($title);
     parent::__construct(array($this->from = new DateSelectorField($this->name, $title, null, 'From'), $this->to = new DateSelectorField($this->name, $title, null, 'To')));
     $this->from->addExtraClass('rangeselectedfrom');
     $this->to->addExtraClass('rangeselectedto');
     $this->setValue($value);
 }
 /**
  * Builds the button
  * @param string $title    The text for the button
  * @param array  $children Child buttons (FormActions)
  */
 public function __construct($title = null, $children = array())
 {
     $this->Title = $title;
     foreach ($children as $c) {
         $c->setUseButtonTag(true);
     }
     parent::__construct($children);
     self::$instance_count++;
     $this->identifier = self::$instance_count;
 }
Exemplo n.º 14
0
 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);
 }
 function __construct($checkName, $childField, $value = "", $readonly = false)
 {
     $this->name = $checkName;
     $this->checkbox = new CheckboxField($checkName, "", $value);
     if ($readonly) {
         $this->checkbox->setDisabled(true);
     }
     $this->childField = $childField;
     $children = new FieldList($this->childField, $this->checkbox);
     parent::__construct($children);
 }
 public function __construct($name)
 {
     Requirements::css(RIGHTSIDEBAR_DIR . '/css/cms.css');
     Requirements::javascript(RIGHTSIDEBAR_DIR . '/js/cms.js');
     $args = func_get_args();
     $name = array_shift($args);
     if (!is_string($name)) {
         user_error('RightSidebar::__construct(): $name parameter to a valid string', E_USER_ERROR);
     }
     $this->name = $name;
     $this->id = preg_replace('/[^0-9A-Za-z]+/', '', $name);
     $this->title = isset($title) ? $title : FormField::name_to_label($name);
     parent::__construct($args);
 }
 public function __construct($name, $children = null)
 {
     $this->name = $name;
     if ($children && ($type = $this->subItemType)) {
         $sub = [];
         foreach ($children as $child) {
             if ($child instanceof $type) {
                 $sub[] = $child;
             }
         }
     } else {
         $sub = $children ? $children : FieldList::create();
     }
     CompositeField::__construct($sub);
 }
 public function __construct($name, $record, FieldList $fields = null)
 {
     $this->name = $name;
     $this->record = $record;
     if (!$fields) {
         if ($this->record->hasMethod('getHasOneCMSFields')) {
             $fields = $this->record->getHasOneCMSFields($name);
         } else {
             $fields = $this->record->getCMSFields();
         }
         if ($fields) {
             $fields = $fields->dataFields();
         }
     }
     parent::__construct($fields);
 }
Exemplo n.º 19
0
 /**
  * @uses FormField::name_to_label()
  * 
  * @param string $name Identifier of the tab, without characters like dots or spaces
  * @param string $title Natural language title of the tab. If its left out,
  *  the class uses {@link FormField::name_to_label()} to produce a title from the {@link $name} parameter.
  * @param FormField All following parameters are inserted as children to this tab
  */
 public function __construct($name)
 {
     $args = func_get_args();
     $name = array_shift($args);
     if (!is_string($name)) {
         user_error('TabSet::__construct(): $name parameter to a valid string', E_USER_ERROR);
     }
     $this->name = $name;
     $this->id = preg_replace('/[^0-9A-Za-z]+/', '', $name);
     // Legacy handling: only assume second parameter as title if its a string,
     // otherwise it might be a formfield instance
     if (isset($args[0]) && is_string($args[0])) {
         $title = array_shift($args);
     }
     $this->title = isset($title) ? $title : FormField::name_to_label($name);
     parent::__construct($args);
 }
Exemplo n.º 20
0
 public function __construct($arg1 = null, $arg2 = null)
 {
     if (is_array($arg1) || is_a($arg1, 'FieldSet')) {
         $fields = $arg1;
     } else {
         if (is_array($arg2) || is_a($arg2, 'FieldList')) {
             $this->title = $arg1;
             $fields = $arg2;
         } else {
             $fields = func_get_args();
             if (!is_object(reset($fields))) {
                 $this->title = array_shift($fields);
             }
         }
     }
     parent::__construct($fields);
 }
 /**
  * Construct the field with correct ID names and values
  * 
  * @param String $name
  * @param Product $product
  */
 function __construct($name, $product)
 {
     $this->name = $name;
     $this->product = $product;
     //Set an extra class for the wrapper
     $this->addExtraClass('OptionGroupField');
     //Set an ID
     $this->setID('ProductOptions_' . $product->ID);
     //Use the product to get the attributes and options and set them to the class
     $items = new FieldSet();
     $attributes = $this->product->Attributes()->map('ID', 'Label');
     if ($attributes) {
         foreach ($attributes as $id => $title) {
             $options = $this->product->getOptionsForAttribute($id);
             if ($options->exists()) {
                 $optionsField = new OptionField($id, $title, $options);
                 $items->push($optionsField);
             }
         }
     }
     parent::__construct($items);
 }
 public function __construct(ISingleValueTemplateQuestion $question, $value = null)
 {
     $children = new FieldList();
     $this->question = $question;
     $current_user = Member::currentUser();
     $current_affiliations = $current_user->getCurrentAffiliations();
     if (!$current_affiliations) {
         $children->add($txt = new TextField($question->name(), $question->label()));
         $txt->addExtraClass('input-organization-name');
     } else {
         if (intval($current_affiliations->count()) > 1) {
             $source = array();
             foreach ($current_affiliations as $a) {
                 $org = $a->Organization();
                 $source[$org->ID] = $org->Name;
             }
             $source['0'] = "-- New One --";
             $children->add($ddl = new DropdownField($question->name() . 'ID', $question->label(), $source));
             $ddl->setEmptyString('-- Select Your Organization --');
             $ddl->addExtraClass('select-organization-name');
             if (!is_null($value)) {
                 $org = Org::get()->filter('Name', $value)->first();
                 if ($org) {
                     $ddl->setValue($org->ID);
                 }
             }
             $children->add($txt = new TextField($question->name(), ''));
             $txt->addExtraClass('input-organization-name');
         } else {
             $children->add($txt = new TextField($question->name(), $question->label(), $current_user->getOrgName()));
             $txt->addExtraClass('input-organization-name');
         }
     }
     parent::__construct($children);
     $control_css_class = strtolower($this->question->name() . '-composite');
     $this->addExtraClass($control_css_class);
     Requirements::javascript('survey_builder/js/survey.organization.field.js');
     Requirements::customScript("\n        jQuery(document).ready(function(\$) {\n            \$('.'+'{$control_css_class}').survey_organization_field();\n        });");
 }
Exemplo n.º 23
0
 /**
  * @uses FormField::name_to_label()
  *
  * @param string $name Identifier of the tab, without characters like dots or spaces
  * @param string|FormField $titleOrField Natural language title of the tabset, or first tab.
  * If its left out, the class uses {@link FormField::name_to_label()} to produce a title
  * from the {@link $name} parameter.
  * @param FormField ...$fields All following parameters are inserted as children to this tab
  */
 public function __construct($name, $titleOrField = null, $fields = null)
 {
     if (!is_string($name)) {
         throw new InvalidArgumentException('Invalid string parameter for $name');
     }
     // Get following arguments
     $fields = func_get_args();
     array_shift($fields);
     // Detect title from second argument, if it is a string
     if ($titleOrField && is_string($titleOrField)) {
         $title = $titleOrField;
         array_shift($fields);
     } else {
         $title = static::name_to_label($name);
     }
     // Remaining arguments are child fields
     parent::__construct($fields);
     // Assign name and title (not assigned by parent constructor)
     $this->setName($name);
     $this->setTitle($title);
     $this->setID(Convert::raw2htmlid($name));
 }
 public function __construct(DataObject $parent, $name, $fullName)
 {
     $this->parent = $parent;
     $this->name = $name;
     $this->fullName = $fullName;
     $entities = array();
     //		foreach (Alchemisable::entity_fields() as $field => $name) {
     //			if (!in_array($field, array('AlcPerson', 'AlcCompany', 'AlcOrganization'))) {
     //				$entities[] = new MultiValueTextField($field, $name);
     //			}
     //		}
     $fields = array(new HeaderField('ExtactedMetadataHeader', 'Extracted Metadata'));
     $alcFields = $parent->getDefaultAlchemyFields();
     $data = $parent->getAlchemyData();
     foreach ($alcFields as $fname => $default) {
         $type = is_array($default) ? 'MultiValueTextField' : 'TextField';
         $field = new $type($name . '-' . $fname, $fname, $data[$fname]);
         $field->addExtraClass('alchemy-populated');
         $fields[] = $field;
     }
     $fields[] = new LiteralField('AlchemyLogo', '<a href="http://www.alchemyapi.com/" target="_blank" style="float: right"><img src="http://www.alchemyapi.com/images/alchemyAPI.jpg" /></a>');
     parent::__construct($fields);
 }
 public function __construct($name, $title = null, $value = null, $modifier = null)
 {
     $this->name = $name . '[' . $modifier . ']';
     $this->setTitle($title);
     $this->modifier = $modifier;
     $dayArray = array(0 => 'Day');
     for ($i = 1; $i < 32; $i++) {
         if ($i < 10) {
             $dayArray['0' . $i] = $i;
         } else {
             $dayArray[$i] = $i;
         }
     }
     $monthArray = array('0' => 'Month', '01' => 'Jan', '02' => 'Feb', '03' => 'March', '04' => 'Apr', '05' => 'May', '06' => 'June', '07' => 'July', '08' => 'Aug', '09' => 'Sept', '10' => 'Oct', '11' => 'Nov', '12' => 'Dec');
     $now = new DateTime();
     $startYear = $now->format('Y');
     $endYear = $startYear - 105;
     $yearArray = array(0 => 'Year');
     for ($i = $startYear; $i >= $endYear; $i--) {
         $yearArray[$i] = $i;
     }
     $fields = array($this->day = new DropdownField($this->name . '[Day]', '', $dayArray), $this->month = new DropdownField($this->name . '[Month]', '', $monthArray), $this->year = new DropdownField($this->name . '[Year]', '', $yearArray));
     foreach ($fields as $field) {
         $field->addExtraClass('dateselectorfield');
     }
     if ($title) {
         if ($this->useHeading) {
             array_unshift($fields, $header = new HeaderField($this->name . $this->modifier . 'Title', trim($title . ' ' . $this->modifier), 4));
             $header->setAllowHTML(true);
         } else {
             array_unshift($fields, new LiteralField($this->name . $this->modifier . 'Title', '<label class="left" for="' . $this->name . '">' . trim($title . ' ' . $this->modifier) . '</label>'));
         }
     }
     Requirements::css('datedropdownselectorfield/css/admin.css');
     parent::__construct($fields);
     $this->setValue($value);
 }
Exemplo n.º 26
0
 public function __construct($name, $title, $value = null)
 {
     $this->name = $name;
     $this->title = $title;
     $children = new FieldList();
     $source = Company::get()->sort('Name')->map('ID', 'Name')->toArray();
     $source['0'] = "-- New Company --";
     $children->add($ddl = new DropdownField($name . '_id', $title, $source));
     $ddl->setEmptyString('-- Select Your Company --');
     $ddl->addExtraClass('select-company-name');
     if (!is_null($value)) {
         $c = Company::get()->filter('Name', $value)->first();
         if ($c) {
             $ddl->setValue($c->ID);
         }
     }
     $children->add($txt = new TextField($name, ''));
     $txt->addExtraClass('input-company-name');
     parent::__construct($children);
     $control_css_class = strtolower('company-composite');
     $this->addExtraClass($control_css_class);
     Requirements::javascript('openstack/code/utils/CustomHTMLFields/js/company.field.js');
     Requirements::customScript("\n        jQuery(document).ready(function(\$) {\n            \$('.'+'{$control_css_class}').company_field();\n        });");
 }
 public function __construct($children = null)
 {
     parent::__construct($children);
 }
 public function __construct($folder)
 {
     $this->folder = $folder;
     parent::__construct(new FieldList());
 }
 public function __construct($position, $children = null)
 {
     parent::__construct($children);
     $this->addExtraClass(self::$prefix . $position);
 }
 public function __construct($name, $title, $children)
 {
     $this->name = $name;
     $this->title = $title;
     parent::__construct($children);
 }