public function getSearchContext()
 {
     $context = parent::getSearchContext();
     $categories = EmailTemplate::get()->column('Category');
     $context->getFields()->replaceField('q[Category]', new DropdownField('q[Category]', 'Category', ArrayLib::valuekey($categories)));
     return $context;
 }
 /**
  * @covers ClassInfo::ancestry()
  */
 public function testAncestry()
 {
     $ancestry = ClassInfo::ancestry('ClassInfoTest_ChildClass');
     $expect = ArrayLib::valuekey(array('Object', 'ViewableData', 'DataObject', 'ClassInfoTest_BaseClass', 'ClassInfoTest_ChildClass'));
     $this->assertEquals($expect, $ancestry);
     $ancestry = ClassInfo::ancestry('ClassInfoTest_ChildClass', true);
     $this->assertEquals(array('ClassInfoTest_BaseClass' => 'ClassInfoTest_BaseClass'), $ancestry, '$tablesOnly option excludes memory-only inheritance classes');
 }
 public function getCMSFields()
 {
     $fields = FieldList::create(TabSet::create('Root'));
     $fields->addFieldsToTab('Root.Main', array(TextField::create('Title'), TextareaField::create('Description'), CurrencyField::create('PricePerNight', 'Price (per night)'), DropdownField::create('Bedrooms')->setSource(ArrayLib::valuekey(range(1, 10))), DropdownField::create('Bathrooms')->setSource(ArrayLib::valuekey(range(1, 10))), DropdownField::create('RegionID', 'Region')->setSource(Region::get()->map('ID', 'Title'))->setEmptyString('-- Select a region --'), CheckboxField::create('FeaturedOnHomepage', 'Feature on homepage')));
     $fields->addFieldToTab('Root.Photos', $upload = UploadField::create('PrimaryPhoto', 'Primary photo'));
     $upload->getValidator()->setAllowedExtensions(array('png', 'jpeg', 'jpg', 'gif'));
     $upload->setFolderName('property-photos');
     return $fields;
 }
 protected function generateColorPalette($fieldName, $paletteSetting)
 {
     $palette = $this->owner->config()->get($paletteSetting) ? $this->owner->config()->get($paletteSetting) : Config::inst()->get($this->class, $paletteSetting);
     $field = ColorPaletteField::create($fieldName, $this->owner->fieldLabel($fieldName), ArrayLib::valuekey($palette));
     if (Config::inst()->get($this->class, 'colors_can_be_empty')) {
         $field = $field->setEmptyString('none');
     }
     return $field;
 }
 /**
  * Update the SearchForm to use dropdown fields for MessageType/Status filters
  * @return Form
  **/
 public function SearchForm()
 {
     $form = parent::SearchForm();
     $fields = $form->Fields();
     $q = $this->getRequest()->requestVar('q');
     $fields->removeByName('q[MessageType]');
     $fields->push(DropdownField::create('q[MessageType]', 'Message Type', ArrayLib::valuekey(Config::inst()->get('TimedNotice', 'message_types')), isset($q['MessageType']) ? $q['MessageType'] : null)->setEmptyString(' '));
     $fields->push(DropdownField::create('q[Status]', 'Status', ArrayLib::valuekey(Config::inst()->get('TimedNotice', 'status_options')), isset($q['Status']) ? $q['Status'] : null)->setEmptyString(' '));
     return $form;
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->addFieldToTab('Root.Main', TreeDropdownField::create('SourceFolderID', 'Source folder', 'Folder'), 'Content');
     $fields->addFieldToTab('Root.Main', NumericField::create('ItemsPerPage', 'Items per page'), 'Content');
     $fileFields = singleton('File')->inheritedDatabaseFields();
     $fileFields = array_merge($fileFields, array('Created' => null, 'LastEdited' => null));
     $fileFields = ArrayLib::valuekey(array_keys($fileFields));
     $fields->addFieldToTab('Root.Main', DropdownField::create('FileSortBy', 'Sort files by', $fileFields), 'Content');
     $fields->addFieldToTab('Root.Main', DropdownField::create('FileSortDir', 'Sort direction', self::$sort_dirs_map), 'Content');
     return $fields;
 }
 public function updateCMSFields(FieldList $fields)
 {
     // if there are Models set in the Product Category then use a dropdown to select
     if ($this->owner->Parent && $this->owner->Parent->ProductModels()->count()) {
         $fields->replaceField('Model', DropdownField::create('Model', _t("Product.MODELREQUIRED", "Model (required)"), ArrayLib::valuekey($this->owner->Parent->ProductModels()->column('Title')))->setEmptyString(_t("Product.MODELSELECT", "Select..."))->setAttribute('Required', true));
     } else {
         // Update Model for extended length
         // see config.yml for updated db settings
         $model = $fields->dataFieldByName('Model');
         $model->setMaxLength(100);
     }
 }
Exemple #8
0
	function testValuekey() {
		$this->assertEquals(
			ArrayLib::valuekey(
				array(
					'testkey1' => 'testvalue1',
					'testkey2' => 'testvalue2'
				)
			),
			array(
				'testvalue1' => 'testvalue1',
				'testvalue2' => 'testvalue2'
			)
		);
	}
    /**
     * @return FieldSet
     */
    public function getCMSFields()
    {
        Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
        Requirements::javascript('inlinehelp/javascript/InlineHelpAdmin.js');
        return new FieldList(new TabSet('Root', new Tab('Main', new HeaderField('HelpHeader', 'Help Topic'), new TextField('Title', 'Title'), new OptionSetField('DisplayType', 'Display type', array('Tooltip' => 'Display help text and/or link in tooltip', 'Link' => 'Click the icon to go to the help link')), new HtmlEditorField('Text', 'Short help text'), new TextField('Link', 'Help link')), new Tab('Subject', new HeaderField('SubjectHeader', 'Help Subject(s)'), new TextField('DOMPattern', 'DOM pattern'), new LiteralField('DOMPatternNote', '<p>This is a jQuery (CSS)
				selector which specifies which elements to attach this help
				topic to. The same topic can be attached to multiple elements.
				</p>'), new DropdownField('DOMMethod', 'DOM attachment method', self::$attachment_method_map)), new Tab('AttachTo', new HeaderField('AttachToHeader', 'Attach Help To'), new OptionSetField('AttachType', '', array('All' => 'All pages', 'Pages' => 'Specific pages', 'Children' => 'Children of the selected page', 'Type' => 'Instances of a specific page type')), new TreeMultiSelectField('Pages', 'Pages', 'SiteTree'), new TreeDropdownField('ParentFilterID', 'Parent page', 'SiteTree'), new DropdownField('AttachPageType', 'Page type', ArrayLib::valuekey(ClassInfo::subclassesFor('Page')))), new Tab('Advanced', new HeaderField('AdvancedHeader', 'Advanced Inline Help Options'), new DropdownField('ShowTooltip', 'Show tooltip on', array('Hover' => 'On mouse hover', 'Click' => 'On mouse click')), new TextField('IconHTML', 'Icon HTML code'), new FieldGroup('Help icon position (relative to subject)', new TextField('IconMy', 'my'), new TextField('IconAt', 'at')), new FieldGroup('Help icon offset (relative to position)', new TextField('IconOffset', ''), new LiteralField('IconOffsetNote', 'format "horizontal vertical" (e.g. "15 -5")')), new FieldGroup('Tooltip position (relative to icon)', new TextField('TooltipMy', 'my'), new TextField('TooltipAt', 'at')), new LiteralField('HelpPositionNote', '<p>These allow you to
				specify the position of the elements relative to each other.
				Each position is in the format "horizontal vertical", where
				horizontal can be one of left, center or right (default
				center), and vertical can be top, center or bottom (default
				center)</p>'), new FieldGroup('Tooltip size', new TextField('TooltipWidth', ''), new LiteralField('SizeSeparator', 'x'), new TextField('TooltipHeight', ''), new LiteralField('DefaultSizeNote', '(default: 300 x "auto")')))));
    }
 public function PropertySearchForm()
 {
     $nights = array();
     foreach (range(1, 14) as $i) {
         $nights[$i] = "{$i} night" . ($i > 1 ? 's' : '');
     }
     $prices = array();
     foreach (range(100, 1000, 50) as $i) {
         $prices[$i] = '$' . $i;
     }
     $form = Form::create($this, 'PropertySearchForm', FieldList::create(TextField::create('Keywords')->setAttribute('placeholder', 'City, State, Country, etc...')->addExtraClass('form-control'), TextField::create('ArrivalDate', 'Arrive on...')->setAttribute('data-datepicker', true)->setAttribute('data-date-format', 'DD-MM-YYYY')->addExtraClass('form-control'), DropdownField::create('Nights', 'Stay for...')->setSource($nights)->addExtraClass('form-control'), DropdownField::create('Bedrooms')->setSource(ArrayLib::valuekey(range(1, 5)))->addExtraClass('form-control'), DropdownField::create('Bathrooms')->setSource(ArrayLib::valuekey(range(1, 5)))->addExtraClass('form-control'), DropdownField::create('MinPrice', 'Min. price')->setEmptyString('-- any --')->setSource($prices)->addExtraClass('form-control'), DropdownField::create('MaxPrice', 'Max. price')->setEmptyString('-- any --')->setSource($prices)->addExtraClass('form-control')), FieldList::create(FormAction::create('doPropertySearch', 'Search')->addExtraClass('btn-lg btn-fullcolor')));
     $form->setFormMethod('GET')->setFormAction($this->Link())->disableSecurityToken()->loadDataFrom($this->request->getVars());
     return $form;
 }
 /**
  * @return FieldSet
  */
 public function getCmsExtraFields($time)
 {
     switch ($this->Type) {
         case 'Single':
             $quantity = new ReadonlyField('OneAvailable', 'Quantity', '(One available)');
             break;
         case 'Limited':
             $quantity = new DropdownField('BookingQuantity', 'Quantity', ArrayLib::valuekey(range(1, $this->getAvailableForEvent($time))), null, null, true);
             break;
         case 'Unlimited':
             $quantity = new NumericField('BookingQuantity', 'Quantity');
             break;
     }
     return new FieldSet(new ReadonlyField('Title', 'Resource title', $this->Title), $quantity);
 }
 /**
  * Return the themes that can be used with this subsite, as an array of themecode => description
  */
 function allowedThemes()
 {
     if ($themes = $this->stat('allowed_themes')) {
         return ArrayLib::valuekey($themes);
     } else {
         $themes = array();
         if (is_dir('../themes/')) {
             foreach (scandir('../themes/') as $theme) {
                 if ($theme[0] == '.') {
                     continue;
                 }
                 $theme = strtok($theme, '_');
                 $themes[$theme] = $theme;
             }
             ksort($themes);
         }
         return $themes;
     }
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeFieldFromTab('Root', 'ViewerGroups');
     $viewersOptionsSource['LoggedInUsers'] = _t('TimedNotice.ACCESSLOGGEDIN', 'Logged-in users');
     $viewersOptionsSource['OnlyTheseUsers'] = _t('TimedNotice.ACCESSONLYTHESE', 'Only these people (choose from list)');
     $fields->addFieldToTab('Root.Main', $canViewTypeField = OptionsetField::create("CanViewType", _t('TimedNotice.ACCESSHEADER', "Who should see this notice?"), $viewersOptionsSource));
     $groupsMap = Group::get()->map('ID', 'Breadcrumbs')->toArray();
     asort($groupsMap);
     $fields->addFieldToTab('Root.Main', $viewerGroupsField = ListboxField::create("ViewerGroups", _t('TimedNotice.VIEWERGROUPS', "Only people in these groups"))->setMultiple(true)->setSource($groupsMap)->setAttribute('data-placeholder', _t('TimedNotice.GroupPlaceholder', 'Click to select group')));
     $viewerGroupsField->displayIf("CanViewType")->isEqualTo("OnlyTheseUsers");
     $fields->addFieldToTab('Root.Main', DropdownField::create('MessageType', 'Message Type', ArrayLib::valuekey($this->config()->get('message_types'))), 'Message');
     $fields->addFieldToTab('Root.Main', ReadonlyField::create('TZNote', 'Note', sprintf(_t('TimedNotice.TZNote', 'Your dates and times should be based on the server timezone: %s'), date_default_timezone_get())), 'StartTime');
     $start = $fields->dataFieldByName('StartTime');
     $end = $fields->dataFieldByName('EndTime');
     $start->getDateField()->setConfig('showcalendar', true);
     $end->getDateField()->setConfig('showcalendar', true);
     $start->setTimeField(TimePickerField::create('StartTime[time]', '')->addExtraClass('fieldgroup-field'));
     $end->setTimeField(TimePickerField::create('EndTime[time]', '')->addExtraClass('fieldgroup-field'));
     return $fields;
 }
 public function getCMSFields()
 {
     if ($this->List) {
         $opts = array('random' => 'A random list of objects', 'query' => 'A specific list of objects');
     } else {
         $opts = array('static' => 'A static value', 'random' => 'A random object', 'query' => 'A specific object');
     }
     $map = ArrayLib::valuekey(ClassInfo::subclassesFor('DataObject'));
     unset($map['DataObject']);
     foreach ($map as $k => $class) {
         if (ClassInfo::classImplements($class, 'TestOnly')) {
             unset($map[$class]);
         }
     }
     ksort($map);
     $f = FieldList::create(TabSet::create('Root'));
     $f->addFieldToTab('Root.Main', ReadonlyField::create('Variable', 'Variable name'));
     $f->addFieldToTab('Root.Main', OptionsetField::create('ValueType', 'Value type', $opts));
     $f->addFieldToTab('Root.Main', DropdownField::create('RecordClass', 'Object type', $map)->displayIf('ValueType')->isEqualTo('random')->orIf('ValueType')->isEqualTo('query')->end());
     $f->addFieldToTab('Root.Main', TextField::create('Value')->displayIf('ValueType')->isEqualTo('static')->end());
     $f->addFieldToTab('Root.Main', TextField::create('Query', 'Query string')->displayIf('ValueType')->isEqualTo('query')->end()->setDescription('E.g. Name:StartsWith=Uncle&Status=Awesome'));
     return $f;
 }
 public function getCMSFields()
 {
     Requirements::javascript(USERSUBMISSIONPAGES_DIR . '/javascript/userformpages.js');
     Requirements::css(USERSUBMISSIONPAGES_DIR . '/css/userformpages.css');
     $self = $this;
     $this->beforeUpdateCMSFields(function ($fields) use($self) {
         //
         // WARNING: Some of the fields here are moved with 'insertAfter' after
         //			$this->extend('updateCMSFields') is called, so their location is immutable.
         //			However, any other data to do with the field can be modified.
         //
         // Add dropdown that defines what page type gets created.
         $pageTypes = array();
         foreach (UserSubmissionExtension::get_classes_extending() as $class) {
             $pageTypes[$class] = singleton($class)->singular_name();
         }
         $field = null;
         if ($pageTypes && count($pageTypes) > 1) {
             $fields->push($field = DropdownField::create('SubmissionPageClassName', null, $pageTypes));
         } else {
             if ($pageTypes) {
                 // Seperated into *_Readonly so the value can look nice and use the 'singular_name'.
                 $fields->push($field = ReadonlyField::create('SubmissionPageClassName_Readonly', null, reset($pageTypes)));
             }
         }
         if ($field) {
             $field->setTitle('Submission Page Type');
             $field->setRightTitle('The page type to create underneath this page when a submission is approved.');
         }
         // Add dropdown that defines what field is used for the Page title of the published
         // submission listing items
         $userFields = $self->InputFields()->map('Name', 'Title');
         if (!$userFields instanceof ArrayList) {
             $userFields = $userFields->toArray();
         }
         if ($self->SubmissionPageTitleField && !isset($userFields[$self->SubmissionPageTitleField])) {
             // If set value isn't in dropdown, make it appear in there.
             $userFields[$self->SubmissionPageTitleField] = '<Field Deleted>';
         } else {
             if (!$self->SubmissionPageTitleField) {
                 $userFields = array_merge(array('' => '(Select Field)'), $userFields);
             }
         }
         $fields->push($field = DropdownField::create('SubmissionPageTitleField', 'Submission Page Title Field', $userFields));
         $field->setRightTitle('Be careful when modifying this value as it will change the "Title" and "Menu Title" of all your child pages.');
         // Update 'Submissions' gridfield to show the current state of a submission
         $submissionsGridField = $fields->dataFieldByName('Submissions');
         if ($submissionsGridField) {
             $class = $submissionsGridField->getList()->dataClass();
             $displayFields = ArrayLib::valuekey($class::config()->summary_fields);
             $displayFields['CMSState'] = 'State';
             $submissionsGridField->getConfig()->getComponentByType('GridFieldDataColumns')->setDisplayFields($displayFields);
         }
         // Add content
         $instructions = '';
         foreach ($self->ContentVariables() as $varname => $data) {
             $value = isset($data['Help']) ? $data['Help'] : $data['Value'];
             $instructions .= $varname . ' = ' . Convert::raw2xml($value) . '<br/>';
         }
         $field = $fields->dataFieldByName('Content');
         if ($field) {
             $field->setTitle($field->Title() . ' (Listing)');
             $field->setRightTitle($instructions);
         }
         $fields->addFieldToTab('Root.Submissions', NumericField::create('ItemsPerPage')->setRightTitle('If set to 0, then show all items.'));
         $fields->addFieldToTab('Root.Submissions', $field = HtmlEditorField::create('ContentAdd', 'Content (Form)'));
         $field->setRightTitle($instructions);
         // Add templating
         $fields->addFieldToTab('Root.Main', $field = TextareaField::create('TemplateHolderMarkup', 'Template Holder')->setRows(10));
         $fields->addFieldToTab('Root.Main', $field = TextareaField::create('TemplatePageMarkup', 'Template Page')->setRows(10));
         // Add search info
         if ($self->config()->enable_search_form) {
             $fields->addFieldToTab('Root.Main', $field = ReadonlyField::create('Search_EnableOnSearchForm_Readonly', 'Search Form Fields'));
             $field->setValue(implode(', ', $self->Fields()->filter('EnableOnSearchForm', true)->map('ID', 'Title')->toArray()));
             $field->setRightTitle('Fields that currently have "Show field on search form?" checked in their options.');
             $fields->addFieldToTab('Root.Main', $field = ReadonlyField::create('Search_UseInKeywordSearch_Readonly', 'Search Form Fields in Keyword Search'));
             $field->setValue(implode(', ', $self->Fields()->filter('UseInKeywordSearch', true)->map('ID', 'Title')->toArray()));
             $field->setRightTitle('Fields that currently have "Use for "Keywords" field search?" checked in their options.');
         }
         // Update Email Recipients gridfield to use custom email recipient class
         $gridField = $fields->dataFieldByName('EmailRecipients');
         if ($gridField) {
             $gridField->setModelClass('UserSubmissionHolder_EmailRecipient');
         }
     });
     $fields = parent::getCMSFields();
     if ($field = $fields->dataFieldByName('Search_UseInKeywordSearch_Readonly')) {
         $fields->insertAfter($field, 'Fields');
     }
     if ($field = $fields->dataFieldByName('Search_EnableOnSearchForm_Readonly')) {
         $fields->insertAfter($field, 'Fields');
     }
     if ($field = $fields->dataFieldByName('TemplatePageMarkup')) {
         $fields->insertAfter($field, 'Fields');
         $this->insertCMSTemplateAddFieldButtons($fields, 'TemplatePageMarkup');
     }
     if ($field = $fields->dataFieldByName('TemplateHolderMarkup')) {
         $fields->insertAfter($field, 'Fields');
         $this->insertCMSTemplateAddFieldButtons($fields, 'TemplateHolderMarkup');
     }
     if ($field = $fields->dataFieldByName('SubmissionPageTitleField')) {
         $fields->insertAfter($field, 'Fields');
     }
     if ($field = $fields->dataFieldByName('SubmissionPageClassName')) {
         $fields->insertAfter($field, 'Fields');
     }
     if ($field = $fields->dataFieldByName('SubmissionPageClassName_Readonly')) {
         $fields->insertAfter($field, 'Fields');
     }
     return $fields;
 }
 public function Tickets()
 {
     $result = new ArrayList();
     $tickets = $this->datetime->Tickets('', '"RegistrableDateTime_Tickets"."Sort"');
     foreach ($tickets as $ticket) {
         $available = $ticket->getAvailableForDateTime($this->datetime, $this->excludedRegistrationId);
         $endTime = $ticket->getSaleEndForDateTime($this->datetime);
         if ($avail = $available['available']) {
             $name = "{$this->name}[{$ticket->ID}]";
             $min = $ticket->MinTickets;
             $max = $ticket->MaxTickets;
             $val = array_key_exists($ticket->ID, $this->value) ? $this->value[$ticket->ID] : null;
             if (!$val && !$this->showUnselectedTickets) {
                 continue;
             }
             if ($this->readonly) {
                 $field = $val ? $val : '0';
             } elseif ($max) {
                 $field = new DropdownField($name, '', ArrayLib::valuekey(range($min, min($available, $max))), $val, null);
                 $field->setHasEmptyDefault(true);
             } else {
                 $field = new NumericField($name, '', $val);
             }
             $result->push(new ArrayData(array('Title' => $ticket->Title, 'Description' => $ticket->Description, 'Available' => $avail === true ? 'Unlimited' : $avail, 'Price' => $ticket->PriceSummary(), 'End' => DBField::create_field('SS_Datetime', $endTime), 'Quantity' => $field)));
         } elseif ($this->showUnavailableTickets) {
             $availableAt = null;
             if (array_key_exists('available_at', $available)) {
                 $availableAt = DBField::create_field('SS_Datetime', $available['available_at']);
             }
             $result->push(new ArrayData(array('Title' => $ticket->Title, 'Description' => $ticket->Description, 'Available' => false, 'Reason' => $available['reason'], 'AvailableAt' => $availableAt)));
         }
     }
     return $result;
 }
 public function getBlockClasses()
 {
     $classes = ArrayLib::valuekey(ClassInfo::subclassesFor('Block'));
     array_shift($classes);
     foreach ($classes as $k => $v) {
         $classes[$k] = singleton($k)->singular_name();
     }
     if (!Config::inst()->get('BlockManager', 'use_default_blocks')) {
         unset($classes['ContentBlock']);
     }
     if ($disabledArr = Config::inst()->get('BlockManager', 'disabled_blocks')) {
         foreach ($disabledArr as $k => $v) {
             unset($classes[$v]);
         }
     }
     return $classes;
 }
 /**
  * Checks to see if this site has a feature as defined in Muiltisites.site_features config
  * @return Boolean
  **/
 public function hasFeature($feature)
 {
     if (!$this->DevID) {
         return false;
     }
     $sites = Config::inst()->get('Multisites', 'site_features');
     if (!isset($sites[$this->DevID])) {
         return false;
     }
     $features = ArrayLib::valuekey($sites[$this->DevID]);
     if (!isset($features[$feature])) {
         return false;
     }
     return true;
 }
Exemple #19
0
	/**
	 * Return the values of this enum, suitable for insertion into a dropdown field.
	 */
	function enumValues($hasEmpty = false) {
		return ($hasEmpty) ? array_merge(array('' => ''), ArrayLib::valuekey($this->enum)) : ArrayLib::valuekey($this->enum);
	}
Exemple #20
0
 /**
  * Returns the values of this enum as an array, suitable for insertion into
  * a {@link DropdownField}
  *
  * @param boolean
  *
  * @return array
  */
 public function enumValues($hasEmpty = false)
 {
     return $hasEmpty ? array_merge(array('' => ''), ArrayLib::valuekey($this->getEnum())) : ArrayLib::valuekey($this->getEnum());
 }
 private function createFieldRange($fieldName)
 {
     $rangeMax = $this->config['max_dropdown_values'][$fieldName];
     $rangeMin = $this->config['min_dropdown_values'][$fieldName];
     if ($fieldName == 'Hour' && !$this->config['24_hr']) {
         if ($rangeMax > 12) {
             $rangeMax = 12;
         }
         if ($rangeMin < 1) {
             $rangeMin = 1;
         }
     }
     $range = range($rangeMin, $rangeMax, $this->config[strtolower($fieldName) . '_interval']);
     foreach ($range as &$val) {
         if ($val > 9) {
             break;
         }
         $val = '0' . $val;
     }
     return ArrayLib::valuekey($range);
 }
 /**
  * Returns the values of this enum as an array, suitable for insertion into
  * a {@link DropdownField}
  *
  * @param boolean
  *
  * @return array
  */
 public function enumValues($hasEmpty = true)
 {
     $this->enum = array();
     return $hasEmpty ? array_merge(array('' => ''), ArrayLib::valuekey($this->enum)) : ArrayLib::valuekey($this->enum);
 }
 /**
  * Add {@link RequiredField} objects together
  *
  * @param RequiredFields
  *
  * @return RequiredFields
  */
 public function appendRequiredFields($requiredFields)
 {
     $this->required = $this->required + ArrayLib::valuekey($requiredFields->getRequired());
     return $this;
 }
 public function getSettingsFields()
 {
     $badges = array('auto' => 'Auto', 'inc' => 'Increment');
     foreach (range(1, 5) as $val) {
         $badges[$val] = $val;
     }
     $applications = array_keys(self::$applications);
     if ($applications) {
         $applications = ArrayLib::valuekey($applications);
     }
     $fields = new FieldList($app = new DropdownField($this->getSettingFieldName('App'), _t('Push.UA_APP', 'Urban Airship Application'), $applications, $this->getSetting('App')), new CheckboxSetField($this->getSettingFieldName('Devices'), _t('Push.DEVICES', 'Devices'), array(self::ANDROID => 'Android', self::BLACKBERRY => 'Blackberry', self::IOS => 'iOS', self::MPNS => 'Windows Phone', self::WNS => 'Windows 8'), $this->getSetting('Devices')), new LiteralField('', sprintf('<p>%s</p>', _t('Push.UARECIPIENTSUPPORT', 'The Urban Airship provider does ' . 'not support selecting recipients - the push notification ' . 'will be sent to all devices using the broadcast API.'))), new HeaderField('IosOptionsHeader', _t('Push.IOSOPTIONS', 'iOS Options')), new DropdownField($this->getSettingFieldName('Sound'), _t('Push.UA_SOUND', 'Trigger sound when alert is received?'), array('No', 'Yes'), $this->getSetting('Sound')), new DropdownField($this->getSettingFieldName('Badge'), _t('Push.UA_BADGE', 'Badge'), $badges, $this->getSetting('Badge')));
     $app->setHasEmptyDefault(true);
     return $fields;
 }
 /**
  * Returns a list of classes that inherit from the given class.
  * The resulting array includes the base class passed
  * through the $class parameter as the first array value.
  *
  * Example usage:
  * <code>
  * ClassInfo::subclassesFor('BaseClass');
  * 	array(
  * 	'BaseClass' => 'BaseClass',
  * 	'ChildClass' => 'ChildClass',
  * 	'GrandChildClass' => 'GrandChildClass'
  * )
  * </code>
  *
  * @param mixed $class string of the classname or instance of the class
  * @return array Names of all subclasses as an associative array.
  */
 public static function subclassesFor($class)
 {
     if (is_string($class) && !class_exists($class)) {
         return [];
     }
     //normalise class case
     $className = self::class_name($class);
     $descendants = SS_ClassLoader::instance()->getManifest()->getDescendantsOf($class);
     $result = array($className => $className);
     if ($descendants) {
         return $result + ArrayLib::valuekey($descendants);
     } else {
         return $result;
     }
 }
 /**
  * @return FieldList
  */
 public function getCMSFields()
 {
     $fields = FieldList::create(TabSet::create('Root'));
     $fields->addFieldsToTab('Root.Main', [AutoCompleteField::create('FoundationMemberID', 'Member')->setSourceClass('Member')->setSourceFields(['FirstName', 'Surname', 'Email', 'SecondEmail', 'ThirdEmail'])->setLabelField('Name')->setLimit(10), DropdownField::create('Identifier', 'Metric', ArrayLib::valuekey(self::get_metric_identifiers())), ReadonlyField::create('Value', $this->ValueDescription)]);
     return $fields;
 }
    public function testEnumParsing()
    {
        $enum = new DBEnum('testField', "\n\t\t\t,\n\t\t\t0,\n\t\t\tItem1,\n\t\t\tItem2,\n\t\t\tItem 3,\n\t\t\tItem-4,\n\t\t\titem 5\n\t\t\tstill 5,\n\t\t\ttrailing comma,\n\t\t");
        $this->assertEquals(ArrayLib::valuekey(array('', '0', 'Item1', 'Item2', 'Item 3', 'Item-4', 'item 5
			still 5', 'trailing comma')), $enum->enumValues());
    }
 public function updateCMSFields(FieldList $fields)
 {
     $userFields = Config::inst()->get('Intercom', 'lead_fields');
     $companyFields = Config::inst()->get('Intercom', 'company_fields');
     $fields->addFieldsToTab('Root.Intercom', array(CheckboxField::create('MapToIntercom', 'Store this field in Intercom'), DisplayLogicWrapper::create(DropdownField::create('IntercomFieldType', 'Where will this field be stored?', array('USER' => 'On the person', 'COMPANY' => 'On the company', 'NOTE' => 'In notes'))->setEmptyString('--- Please select ---'), DropdownField::create('IntercomUserField', 'Which user field in Intercom does it map to?')->setSource(ArrayLib::valuekey($userFields))->displayIf('IntercomFieldType')->isEqualTo('USER')->end(), DropdownField::create('IntercomCompanyField', 'Which company field in Intercom does it map to?')->setSource(ArrayLib::valuekey($companyFields))->displayIf('IntercomFieldType')->isEqualTo('COMPANY')->end(), TextField::create('CustomAttributeName', 'Custom attribute name')->setDescription('No spaces, ideally lowercase_with_underscores')->displayIf('IntercomCompanyField')->isEqualTo('custom_attributes')->orIf('IntercomUserField')->isEqualTo('custom_attributes')->end(), TextField::create('NoteLabel', 'Label for this field in the note')->setDescription('Note: this should probably be the same as the "Title" field on the Main tab')->displayIf('IntercomFieldType')->isEqualTo('NOTE')->end())->displayIf('MapToIntercom')->isChecked()->end()));
 }
Exemple #29
0
 /**
  * Returns a list of classes that inherit from the given class.
  * The resulting array includes the base class passed
  * through the $class parameter as the first array value.
  * 
  * Example usage:
  * <code>
  * ClassInfo::subclassesFor('BaseClass');
  * 	array(
  * 	0 => 'BaseClass',
  * 	'ChildClass' => 'ChildClass',
  * 	'GrandChildClass' => 'GrandChildClass'
  * )
  * </code>
  * 
  * @param mixed $class string of the classname or instance of the class
  * @return array Names of all subclasses as an associative array.
  */
 public static function subclassesFor($class)
 {
     $descendants = SS_ClassLoader::instance()->getManifest()->getDescendantsOf($class);
     $result = array($class => $class);
     if ($descendants) {
         return $result + ArrayLib::valuekey($descendants);
     } else {
         return $result;
     }
 }
 public function getBlockClasses()
 {
     $classes = ArrayLib::valuekey(ClassInfo::subclassesFor('Block'));
     array_shift($classes);
     foreach ($classes as $k => $v) {
         $classes[$k] = singleton($k)->singular_name();
     }
     $themeConfig = $this->getThemeConfig();
     if (isset($themeConfig['use_default_blocks']) && !$themeConfig['use_default_blocks']) {
         unset($classes['ContentBlock']);
     } else {
         if (!$this->config()->use_default_blocks) {
             unset($classes['ContentBlock']);
         }
     }
     $disabledArr = Config::inst()->get('BlockManager', 'disabled_blocks') ? Config::inst()->get('BlockManager', 'disabled_blocks') : array();
     if (isset($themeConfig['disabled_blocks'])) {
         $disabledArr = array_merge($disabledArr, $themeConfig['disabled_blocks']);
     }
     if (count($disabledArr)) {
         foreach ($disabledArr as $k => $v) {
             unset($classes[$v]);
         }
     }
     return $classes;
 }