function updateCMSFields(&$fields) { if ($brands = DataObject::get('ProductBrand')) { $fields->addFieldToTab('Root.Content.Main', $ddf = new DropDownField('BrandID', 'Brand', $brands->toDropDownMap()), 'FeaturedProduct'); $ddf->setHasEmptyDefault(true); } }
function getCMSFields() { $_REQUEST["CompanyId"] = $this->ID; $large_logo = new UploadField('BigLogo', 'Large Company Logo'); $large_logo->setFolderName('companies/main_logo'); $large_logo->setAllowedFileCategories('image'); $small_logo = new UploadField('Logo', 'Small Company Logo'); $small_logo->setAllowedFileCategories('image'); //logo validation rules $large_logo_validator = new Upload_Image_Validator(); $large_logo_validator->setAllowedExtensions(array('jpg', 'png', 'jpeg')); $large_logo_validator->setAllowedMaxImageWidth(500); $large_logo->setValidator($large_logo_validator); $small_logo_validator = new Upload_Image_Validator(); $small_logo_validator->setAllowedExtensions(array('jpg', 'png', 'jpeg')); $small_logo_validator->setAllowedMaxImageWidth(200); $small_logo->setValidator($small_logo_validator); $fields = new FieldList(new TabSet($name = "Root", new Tab($title = 'Company', new HeaderField("Company Data"), new TextField('Name', 'Company Name'), new TextField('URLSegment', 'Unique page name for this company profile (ie: company-name)'), new TextField('URL', 'Company Web Address (URL)'), $level = new DropDownField('MemberLevel', 'OpenStack Foundation Member Level', $this->dbObject('MemberLevel')->enumValues()), new ColorField("Color", "Company Color"), new CheckboxField('DisplayOnSite', 'List this company on openstack.org'), new CheckboxField('Featured', 'Include this company in featured companies area'), new LiteralField('Break', '<hr/>'), $this->canEditLogo() ? $large_logo : new LiteralField('Space', '<br/>'), $this->canEditLogo() ? $small_logo : new LiteralField('Space', '<br/>'), new TextField('Industry', 'Industry (<4 Words)'), new HtmlEditorField('Description', 'Company Description'), new HtmlEditorField('Contributions', 'How you are contributing to OpenStack (<150 words)'), new HtmlEditorField('Products', 'Products/Services Related to OpenStack (<100 words)'), new HtmlEditorField('Overview', 'Company Overview'), new TextField('CommitmentAuthor', 'Commitment Author (Optional)'), new HtmlEditorField('Commitment', "OpenStack Commitment"), new LiteralField('Break', '<hr/>'), new TextField('ContactEmail', 'Best Contact email address (optional)')))); $level->setEmptyString('-- Choose One --'); if ($this->ID > 0) { $admin_list = $this->Administrators()->sort('ID'); $query = $admin_list->dataQuery(); $query->groupby('MemberID'); $admin_list = $admin_list->setDataQuery($query); $config = GridFieldConfig_RelationEditor::create(); $config->removeComponentsByType('GridFieldEditButton'); $config->removeComponentsByType('GridFieldAddNewButton'); $config->getComponentByType('GridFieldDataColumns')->setDisplayFields(array('FirstName' => 'First Name', 'Surname' => 'Last Name', 'Email' => 'Email', 'DDLAdminSecurityGroup' => 'Security Group')); $admins = new GridField('Administrators', 'Company Administrators', $admin_list, $config); $contracts = new GridField("Contracts", "Contracts", $this->Contracts(), GridFieldConfig_RecordEditor::create(10)); $fields->addFieldsToTab('Root.Administrators', array(new HeaderField("Companies Administrators"), $admins)); $fields->addFieldsToTab('Root.Contracts', array(new HeaderField("Companies Contracts"), $contracts)); } return $fields; }
public function Field($properties = array()) { Requirements::javascript(BOLTTOOLS_DIR . '/javascript/addnewlistboxfield.js'); $this->setTemplate('AddNewListboxField'); $this->addExtraClass('has-chzn'); return parent::Field($properties); }
public function updateSettingsFields(FieldList $fields) { $changeFreq = Singleton('Page')->dbObject('ChangeFreq')->enumValues(); $fields->addFieldToTab('Root.Settings', DropDownField::create('ChangeFreq', 'Change Frequency', $changeFreq)); $priority = Singleton('Page')->dbObject('Priority')->enumValues(); $fields->addFieldToTab('Root.Settings', DropDownField::create('Priority', 'Priority', $priority)); }
public function getCMSFields() { $fields = FieldList::create(new TabSet($name = 'Root', new Tab($title = 'Main', HeaderField::create('ContactHD', 'Contact Information'), TextField::create('Title', 'Name'), TextField::create('Phone'), EmailField::create('Email', 'Email'), TextField::create('Website')->setAttribute('placeholder', 'http://'), DropDownField::create('CategoryID', 'Category', LocationCategory::get()->map('ID', 'Title'))->setEmptyString('-- select --'), CheckboxField::create('ShowInLocator', 'Show in results')->setDescription('Location will be included in results list'), CheckboxField::create('Featured')->setDescription('Location will show at/near the top of the results list')))); // allow to be extended via DataExtension $this->extend('updateCMSFields', $fields); // override Suburb field name $fields->dataFieldByName('Suburb')->setTitle('City'); return $fields; }
public function getCMSFields() { $fields = parent::getCMSFields(); $display_types = array('Categories' => 'All Root Categories', 'Category' => 'One Categories Children', 'Products' => 'All Products'); $fields->addFieldToTab('Root.Main', DropDownField::create('Display', 'What will this catalog display?', $display_types), 'Content'); if ($this->Display == 'Category') { $fields->addFieldToTab('Root.Main', TreeDropdownField::create("CategoryID", "Choose a category:", "ProductCategory")->setLabelField("Title"), 'Content'); } $fields->removeByName('Content'); return $fields; }
public function createFields() { $order = $this->order; $member = $this->customer; //Payment fields $supported_methods = PaymentProcessor::get_supported_methods(); $source = array(); foreach ($supported_methods as $methodName) { $methodConfig = PaymentFactory::get_factory_config($methodName); $source[$methodName] = $methodConfig['title']; } $outstanding = $order->TotalOutstanding()->Nice(); $paymentFields = CompositeField::create(new HeaderField(_t('CheckoutPage.PAYMENT', "Payment"), 3), LiteralField::create('RepayLit', "<p>Process a payment for the oustanding amount: {$outstanding}</p>"), DropDownField::create('PaymentMethod', 'Select Payment Method', $source)->setCustomValidationMessage(_t('CheckoutPage.SELECT_PAYMENT_METHOD', "Please select a payment method.")))->setName('PaymentFields'); $fields = FieldList::create($paymentFields); $this->extend('updateFields', $fields); $fields->setForm($this); return $fields; }
public function getCMSFields() { $fields = parent::getCMSFields(); // remove Main tab $fields->removeByName('Main'); // create and populate Info tab $fields->addFieldsToTab('Root.Info', array(HeaderField::create('InfoHeader', 'Contact Information'), TextField::create('Website'), TextField::create('EmailAddress'), TextField::create('Phone'))); // change label of Suburb from Addressable to City $fields->removeByName('Suburb'); $fields->insertBefore(TextField::create('Suburb', 'City'), 'State'); // If categories have been created, show category drop down if (LocationCategory::get()->Count() > 0) { $fields->insertAfter(DropDownField::create('CategoryID', 'Category', LocationCategory::get()->map('ID', 'Title'))->setEmptyString('-- select --'), 'Phone'); } // move Title and ShowInLocator fields to Address tab from Addressable $fields->insertAfter(TextField::create('Title'), 'AddressHeader'); $fields->insertAfter(CheckboxField::create('Featured', 'Featured'), 'Title'); $fields->insertAfter(CheckboxField::create('ShowInLocator', 'Show on Map'), 'Country'); // allow to be extended via DataExtension $this->extend('updateCMSFields', $fields); return $fields; }
public function FieldHolder() { $html = "<div class=\"display_anything_field upload_anything_field\">"; $id = $this->controller->{$this->name}()->getField('ID'); $migrated_value = $this->controller->{$this->name}()->getField('Migrated'); $migrator = FALSE; if ($this->detect_image_gallery_module && $migrated_value == 0) { //display only if we want to detect imagegallery albums and it's not already migrated $list = $this->ImageGalleryAlbums(); if (!empty($list)) { $migrator = TRUE; $html .= "<div class=\"field_content migrate\">"; $html .= "<fieldset><h5>Display Anything has detected an ImageGallery album associated with this page</h5>"; $html .= "<p>Do you wish to migrate it to your new gallery?<p>"; $html .= "<p>Migration notes:</p><ul>"; $html .= "<li>The original ImageGallery album will remain untouched.</li>"; $html .= "<li>Files will be copied alongside current files, this will allow you to remove the old gallery as and when required.</li>"; $html .= "</ul>"; $migrate = new DropDownField("{$this->name}[{$id}][MigrateImageGalleryAlbumID]", "Choose an album to migrate images from", $list, '', NULL, '[Do not migrate]'); $html .= $migrate->FieldHolder(); $html .= "</fieldset>"; $html .= "</div>"; } } else { if ($migrated_value == 1) { $migrator = TRUE; } } $html .= "<div class=\"field_content\">"; $html .= "<fieldset><h5>Gallery settings and options</h5>"; $title = new TextField("{$this->name}[{$id}][Title]", "Title", $this->controller->{$this->name}()->getField('Title')); $html .= $title->FieldHolder(); $description = new TextareaField("{$this->name}[{$id}][Description]", "Description", 3, NULL, $this->controller->{$this->name}()->getField('Description')); $html .= $description->FieldHolder(); $visible = new CheckboxField("{$this->name}[{$id}][Visible]", "Publicly Visible", $this->controller->{$this->name}()->getField('Visible') == 1 ? TRUE : FALSE); $html .= $visible->FieldHolder(); if ($migrator && $migrated_value == 1) { //only need to show this post migration $migrated = new CheckboxField("{$this->name}[{$id}][Migrated]", "Image Gallery migration complete (uncheck and save to display migration options)", TRUE); $html .= $migrated->FieldHolder(); } $html .= "</fieldset></div>"; $html .= "<div class=\"field_content\">"; $html .= "<fieldset><h5>Gallery Items</h5>"; if (!empty($id)) { $html .= parent::FieldHolder(); } else { $html .= "<div class=\"message\"><p>Gallery items can be uploaded after the gallery is saved for the first time</p></div>"; } $html .= "</fieldset></div>"; $html .= "</div>"; return $html; }
function getInput() { return parent::getInput($this->name, null); }
public function Form() { $genres = $this->__getGenres(); $clean = parent::__convertAndCleanList($genres, $pipe = '|'); $genres != null ? $genresJson = json_encode($clean) : json_encode(array("Comedy", "Drama", "Horror", "Science Fiction", "Comic/Super Heroes", "Action", "Thriller", "Crime", "Documentary", "Family", "Animated", "Romance", "Adventure", "War", "Sitcom")); Requirements::customScript(' $("#Form_Form_Seasons").tagit({ singleFieldDelimiter: " | ", allowSpaces: true, availableTags: ["Season 1", "Season 2", "Season 3", "Season 4", "Season 5", "Season 6", "Season 7", "Season 8", "Season 9" , "Season 10", "Season 11", "Season 12", "Season 13", "Season 14", "Season 15", "Season 16"] }); $("#Form_Form_Genre").tagit({ singleFieldDelimiter: " | ", availableTags: ' . $genresJson . ' }); '); //create source arrays to swap out on form load $filmarr = array('Bluray' => 'BD/BRRip', 'DVD' => 'DVD-R', 'screener' => 'SCR/SCREENER/DVDSCR/DVDSCREENER/BDSCR', 'cam' => 'CAMRip/CAM/TS/TELESYNC', 'vod' => 'VODRip/VODR', 'web' => 'WEB-Rip/WEBRIP/WEB Rip/WEB-DL'); $tvarr = array('Bluray' => 'BD/BRRip', 'DVD' => 'DVD-R', 'HDTV' => 'HD TV', 'SDTV' => 'SD TV', 'web' => 'WEB-Rip/WEBRIP/WEB Rip/WEB-DL'); //include js $keywords = $this->__getKeywords(); if ($keywords != null) { $clean = parent::__convertAndCleanList($keywords, $pipe = ','); $json = json_encode($clean); // turn into json array for jquery library Requirements::customScript(' $("#Form_Form_keywords").tagit({ singleFieldDelimiter: " , ", allowSpaces: true, fieldName: "keywordsField", availableTags: ' . $json . ' }); '); } else { Requirements::customScript(' $("#Form_Form_keywords").tagit({ singleFieldDelimiter: " , ", allowSpaces: true, }); '); } $action = Controller::curr()->getRequest()->param('Action'); $id = (int) Controller::curr()->getRequest()->param('ID'); $automap = $id ? $automap = Catalogue::get()->byID($id) : false; $submitCaption = $automap ? 'Edit' : 'Add'; $sourceArr = $filmarr; if (isset($automap->Video_type)) { $automap->Video_type == 'film' ? $sourceArr = $filmarr : ($sourceArr = $tvarr); } // Create fields $fields = FieldList::create(TextField::create('Video_title', 'Video Title'), DropDownField::create('Video_type', 'Type of Video', array('series' => 'Series (TV)', 'film' => 'Film'))->setEmptyString('Select type of media'), TextField::create('Genre', 'Genre')->setDescription('Select a genre by typing a keyword e.g. Comedy'), TextField::create('keywords', 'Keywords')->setDescription('Add a keyword/tag to the title e.g. Marvel'), TextField::create('trilogy', 'Is this a Trilogy?')->setDescription('Add a trilogy name e.g. "X-Men" or "Wolverine"'), TextField::create('Seasons', 'Seasons')->setDescription('Select a Season or type Seasons owned e.g. Season 1'), DropDownField::create('Status', 'Current Status of download', array('Downloaded' => 'Downloaded - file complete', 'Downloading' => 'Dowloading - in progress', 'Wanted' => 'Wanted - need a copy of', 'No Torrents' => 'No Torrents - cannot find video'))->setEmptyString('Select status'), DropDownField::create('Source', 'Source of download', $sourceArr)->setEmptyString('Select source'), DropDownField::create('Quality', 'Resolution of download (quality)', array('4k' => '4k', '1440p' => '1440p', '1080p' => '1080p', '720p' => '720p', '420p' => '420p', '320p' => '320p'))->setEmptyString('Select quality'), HiddenField::create('Owner', '', Member::currentUserID()), HiddenField::create('Comments'), HiddenField::create('imdbID'), HiddenField::create('Year'), TextareaField::create('CommentsEnter', 'Enter new comments on new line'), HiddenField::create('Poster'), HiddenField::create('ID', 'ID')->setValue($id)); $actions = FieldList::create(FormAction::create('submit', $submitCaption)); $validator = RequiredFields::create('Video_title'); $form = Form::create($this, 'Form', $fields, $actions, $validator); $form->type = $submitCaption; //are we in edit or add mode, pass it to view if ($automap) { $form->loadDataFrom($automap); } return $form; }
function __construct($params = array()) { $params['fromDb'] = true; parent::__construct(array(), $params); }
/** * {@inheritdoc} */ public function getCMSFields() { Requirements::css(BLOGGER_DIR . '/css/cms.css'); Requirements::javascript(BLOGGER_DIR . '/js/cms.js'); $self =& $this; $this->beforeUpdateCMSFields(function ($fields) use($self) { $uploadField = UploadField::create('FeaturedImage', _t('BlogPost.FeaturedImage', 'Featured Image')); $uploadField->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif')); /** * @var FieldList $fields */ $fields->insertAfter($uploadField, 'Content'); $summary = HtmlEditorField::create('Summary', false); $summary->setRows(5); $summary->setDescription(_t('BlogPost.SUMMARY_DESCRIPTION', 'If no summary is specified the first 30 words will be used.')); $summaryHolder = ToggleCompositeField::create('CustomSummary', _t('BlogPost.CUSTOMSUMMARY', 'Add A Custom Summary'), array($summary)); $summaryHolder->setHeadingLevel(4); $summaryHolder->addExtraClass('custom-summary'); $fields->insertAfter($summaryHolder, 'FeaturedImage'); $fields->push(HiddenField::create('MenuTitle')); $urlSegment = $fields->dataFieldByName('URLSegment'); $urlSegment->setURLPrefix($self->Parent()->RelativeLink()); $fields->removeFieldsFromTab('Root.Main', array('MenuTitle', 'URLSegment')); $authorField = ListboxField::create('Authors', _t('BlogPost.Authors', 'Authors'), Member::get()->map()->toArray())->setMultiple(true); $authorNames = TextField::create('AuthorNames', _t('BlogPost.AdditionalCredits', 'Additional Credits'), null, 1024); $authorNames->setDescription('If some authors of this post don\'t have CMS access, enter their name(s) here. You can separate multiple names with a comma.'); if (!$self->canEditAuthors()) { $authorField = $authorField->performDisabledTransformation(); $authorNames = $authorNames->performDisabledTransformation(); } $publishDate = DatetimeField::create('PublishDate', _t('BlogPost.PublishDate', 'Publish Date')); $publishDate->getDateField()->setConfig('showcalendar', true); // Get categories and tags $parent = $self->Parent(); $categories = $parent instanceof Blog ? $parent->Categories()->exclude('CatID', 0) : BlogCategory::get()->exclude('CatID', 0); $list = array(); foreach ($categories->sort('CatID, Title ASC') as $cat) { $list[$cat->ID] = sprintf('%s/%s', $cat->Cat()->Title, $cat->Title); } $val = ''; if ($this->Categories()->count() > 0) { $val = $this->Categories()->first()->ID; } $options = BlogAdminSidebar::create($publishDate, $urlSegment, $catField = DropDownField::create('Category', 'Category', $list, $value = $val)->setEmptyString('(select one)'), $authorField, $authorNames)->setTitle('Post Options'); $fields->insertBefore($options, 'Root'); }); $fields = parent::getCMSFields(); $fields->fieldByName('Root')->setTemplate('TabSet_holder'); return $fields; }
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeByName('ModuleAreaID'); $fields->removeByName('SortOrder'); $fields->removeByName('URLSegment'); if ($this->ClassName == 'ContentModule') { $fields->addFieldToTab('Root.Main', DropDownField::create('ClassName', 'Choose Module Type', $this->getClassesForDropdown())); $fields->addFieldToTab('Root.Main', LiteralField::create('ClassNameMessage', '<div class="message">You can add content after saving for the first time.</div>')); Config::inst()->update('ContentModule', 'better_buttons_enabled', false); } else { $fields->addFieldToTab('Root.Settings', DropDownField::create('ClassName', 'Module Type', $this->getClassesForDropdown())); } return $fields; }
public function __construct($name, $title = "", $source = array(), $value = "", $form = null, $emptyString = null) { $source = array('KY' => 'Kentucky', 'CA' => 'California'); parent::__construct($name, $title, $source, $value, $form, $emptyString); }
public function createFields() { $order = $this->order; $member = $this->customer; //Personal details fields if (!$member->ID || $member->Password == '') { $link = $this->controller->Link(); $note = _t('CheckoutPage.NOTE', 'NOTE:'); $passwd = _t('CheckoutPage.PLEASE_CHOOSE_PASSWORD', 'Please choose a password, so you can login and check your order history in the future.'); $mber = sprintf(_t('CheckoutPage.ALREADY_MEMBER', 'If you are already a member please %s log in. %s'), "<a href=\"Security/login?BackURL={$link}\">", '</a>'); $personalFields = CompositeField::create(new HeaderField(_t('CheckoutPage.ACCOUNT', "Account"), 3), new CompositeField(EmailField::create('Email', _t('CheckoutPage.EMAIL', 'Email'))->setCustomValidationMessage(_t('CheckoutPage.PLEASE_ENTER_EMAIL_ADDRESS', "Please enter your email address."))), new CompositeField(new FieldGroup(new ConfirmedPasswordField('Password', _t('CheckoutPage.PASSWORD', "Password")))), new CompositeField(new LiteralField('AccountInfo', "\r\n\t\t\t\t\t\t<p class=\"alert alert-info\">\r\n\t\t\t\t\t\t\t<strong class=\"alert-heading\">{$note}</strong>\r\n\t\t\t\t\t\t\t{$passwd} <br /><br />\r\n\t\t\t\t\t\t\t{$mber}\r\n\t\t\t\t\t\t</p>\r\n\t\t\t\t\t\t")))->setID('PersonalDetails')->setName('PersonaDetails'); } //Order item fields $items = $order->Items(); $itemFields = CompositeField::create()->setName('ItemsFields'); if ($items) { foreach ($items as $item) { $itemFields->push(new OrderForm_ItemField($item)); } } //Order modifications fields $subTotalModsFields = CompositeField::create()->setName('SubTotalModificationsFields'); $subTotalMods = $order->SubTotalModifications(); if ($subTotalMods && $subTotalMods->exists()) { foreach ($subTotalMods as $modification) { $modFields = $modification->getFormFields(); foreach ($modFields as $field) { $subTotalModsFields->push($field); } } } $totalModsFields = CompositeField::create()->setName('TotalModificationsFields'); $totalMods = $order->TotalModifications(); if ($totalMods && $totalMods->exists()) { foreach ($totalMods as $modification) { $modFields = $modification->getFormFields(); foreach ($modFields as $field) { $totalModsFields->push($field); } } } //Payment fields $supported_methods = PaymentProcessor::get_supported_methods(); $source = array(); foreach ($supported_methods as $methodName) { $methodConfig = PaymentFactory::get_factory_config($methodName); $source[$methodName] = $methodConfig['title']; } $paymentFields = CompositeField::create(new HeaderField(_t('CheckoutPage.PAYMENT', "Payment"), 3), DropDownField::create('PaymentMethod', 'Select Payment Method', $source)->setCustomValidationMessage(_t('CheckoutPage.SELECT_PAYMENT_METHOD', "Please select a payment method.")))->setName('PaymentFields'); $fields = FieldList::create($itemFields, $subTotalModsFields, $totalModsFields, $notesFields = CompositeField::create(TextareaField::create('Notes', _t('CheckoutPage.NOTES_ABOUT_ORDER', "Notes about this order")))->setName('NotesFields'), $paymentFields); if (isset($personalFields)) { $fields->push($personalFields); } $this->extend('updateFields', $fields); $fields->setForm($this); return $fields; }