function testLegacyItemsFieldHolderWithTitle() { $items = array('one//one title' => new LiteralField('one', 'one view'), 'two//two title' => new LiteralField('two', 'two view')); $field = new SelectionGroup('MyGroup', $items); $parser = new CSSContentParser($field->FieldHolder()); $listEls = $parser->getBySelector('li'); $listElOne = $listEls[0]; $listElTwo = $listEls[1]; $this->assertEquals('one', (string) $listElOne->input[0]['value']); $this->assertEquals('two', (string) $listElTwo->input[0]['value']); $this->assertEquals('one title', (string) $listElOne->label[0]); $this->assertEquals('two title', (string) $listElTwo->label[0]); }
public function updateCMSFields(\FieldList $fields) { if (!$this->owner->exists()) { return; } $fields->addFieldsToTab('Root.Recommended', [\TextField::create('Recommended_Title', _t('Product.Recommended_Title', 'Title'))->setAttribute('placeholder', $this->owner->config()->recommended_title ?: _t('Product.Default-Recommended_Title', 'Recommended Products')), \CheckboxField::create('Recommended_AlsoBought', _t('Product.Recommended_AlsoBought', 'Prioritise products that were bought with this product?'))->setDescription(_t('Product.Desc-Recommended_AlsoBought', 'This will use products that previous customers have bought with this product, otherwise it will select from your choice below.')), \SelectionGroup::create('Recommended_FindBy', $this->getMethodFormFields())]); }
public function getCMSFields($params = null) { //fields that shouldn't be changed once coupon is used $fields = new FieldList(array($tabset = new TabSet("Root", $maintab = new Tab("Main", TextField::create("Title"), CheckboxField::create("Active", "Active")->setDescription("Enable/disable all use of this discount."), HeaderField::create("ActionTitle", "Action", 3), $typefield = SelectionGroup::create("Type", array(new SelectionGroup_Item("Percent", $percentgroup = FieldGroup::create($percentfield = NumericField::create("Percent", "Percentage", "0.00")->setDescription("e.g. 0.05 = 5%, 0.5 = 50%, and 5 = 500%"), $maxamountfield = CurrencyField::create("MaxAmount", _t("MaxAmount", "Maximum Amount"))->setDescription("The total allowable discount. 0 means unlimited.")), "Discount by percentage"), new SelectionGroup_Item("Amount", $amountfield = CurrencyField::create("Amount", "Amount", "\$0.00"), "Discount by fixed amount")))->setTitle("Type"), OptionSetField::create("For", "Applies to", array("Order" => "Entire Order", "Cart" => "Cart Subtotal", "Shipping" => "Shipping Subtotal", "Items" => "Each Individual Item")), new Tab("Main", HeaderField::create("ConstraintsTitle", "Constraints", 3), LabelField::create("ConstraintsDescription", "Configure the requirements an order must meet for this discount to be valid:")), new TabSet("Constraints"))))); if (!$this->isInDB()) { $fields->addFieldToTab("Root.Main", LiteralField::create("SaveNote", "<p class=\"message good\">More constraints will show up after you save for the first time.</p>"), "Constraints"); } $this->extend("updateCMSFields", $fields, $params); if ($count = $this->getUseCount()) { $fields->addFieldsToTab("Root.Usage", array(HeaderField::create("UseCount", sprintf("This discount has been used {$count} time%s.", $count > 1 ? "s" : "")), HeaderField::create("TotalSavings", sprintf("A total of %s has been saved by customers using this discount.", $this->SavingsTotal), "3"), GridField::create("Orders", "Orders", $this->getAppliedOrders(), GridFieldConfig_RecordViewer::create()->removeComponentsByType("GridFieldViewButton")))); } if ($params && isset($params['forcetype'])) { $valuefield = $params['forcetype'] == "Percent" ? $percentfield : $amountfield; $fields->insertAfter($valuefield, "Type"); $fields->removeByName("Type"); } elseif ($this->Type && (double) $this->{$this->Type}) { $valuefield = $this->Type == "Percent" ? $percentfield : $amountfield; $fields->removeByName("Type"); $fields->insertAfter($valuefield, "ActionTitle"); $fields->replaceField($this->Type, $valuefield->performReadonlyTransformation()); if ($this->Type == "Percent") { $fields->insertAfter($maxamountfield, "Percent"); } } return $fields; }
/** * @return Form */ public function AddForm() { $pageTypes = array(); foreach ($this->PageTypes() as $type) { $html = sprintf('<span class="page-icon class-%s"></span><strong class="title">%s</strong><span class="description">%s</span>', $type->getField('ClassName'), $type->getField('AddAction'), $type->getField('Description')); $pageTypes[$type->getField('ClassName')] = DBField::create_field('HTMLText', $html); } // Ensure generic page type shows on top if (isset($pageTypes['Page'])) { $pageTitle = $pageTypes['Page']; $pageTypes = array_merge(array('Page' => $pageTitle), $pageTypes); } $numericLabelTmpl = '<span class="step-label"><span class="flyout">%d</span><span class="arrow"></span><span class="title">%s</span></span>'; $topTitle = _t('CMSPageAddController.ParentMode_top', 'Top level'); $childTitle = _t('CMSPageAddController.ParentMode_child', 'Under another page'); $fields = new FieldList(new LiteralField('PageModeHeader', sprintf($numericLabelTmpl, 1, _t('CMSMain.ChoosePageParentMode', 'Choose where to create this page'))), $parentModeField = new SelectionGroup("ParentModeField", array(new SelectionGroup_Item("top", null, $topTitle), new SelectionGroup_Item('child', $parentField = new TreeDropdownField("ParentID", "", 'SiteTree', 'ID', 'TreeTitle'), $childTitle))), $typeField = new OptionsetField("PageType", sprintf($numericLabelTmpl, 2, _t('CMSMain.ChoosePageType', 'Choose page type')), $pageTypes, 'Page'), new LiteralField('RestrictedNote', sprintf('<p class="message notice message-restricted">%s</p>', _t('CMSMain.AddPageRestriction', 'Note: Some page types are not allowed for this selection')))); $parentField->setSearchFunction(function ($sourceObject, $labelField, $search) { return DataObject::get($sourceObject, sprintf("\"MenuTitle\" LIKE '%%%s%%' OR \"Title\" LIKE '%%%s%%'", Convert::raw2sql($search), Convert::raw2sql($search))); }); // TODO Re-enable search once it allows for HTML title display, // see http://open.silverstripe.org/ticket/7455 // $parentField->setShowSearch(true); $parentModeField->addExtraClass('parent-mode'); // CMSMain->currentPageID() automatically sets the homepage, // which we need to counteract in the default selection (which should default to root, ID=0) if ($parentID = $this->getRequest()->getVar('ParentID')) { $parentModeField->setValue('child'); $parentField->setValue((int) $parentID); } else { $parentModeField->setValue('top'); } $actions = new FieldList(FormAction::create("doAdd", _t('CMSMain.Create', "Create"))->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')->setUseButtonTag(true), FormAction::create("doCancel", _t('CMSMain.Cancel', "Cancel"))->addExtraClass('ss-ui-action-destructive ss-ui-action-cancel')->setUseButtonTag(true)); $this->extend('updatePageOptions', $fields); $form = CMSForm::create($this, "AddForm", $fields, $actions)->setHTMLID('Form_AddForm'); $form->setAttribute('data-hints', $this->SiteTreeHints()); $form->setAttribute('data-childfilter', $this->Link('childfilter')); $form->setResponseNegotiator($this->getResponseNegotiator()); $form->addExtraClass('cms-add-form stacked cms-content center cms-edit-form ' . $this->BaseCSSClasses()); $form->setTemplate($this->getTemplatesWithSuffix('_EditForm')); return $form; }
/** * @return Form */ function AddForm() { $record = $this->currentPage(); $pageTypes = array(); foreach ($this->PageTypes() as $type) { $html = sprintf('<span class="page-icon class-%s"></span><strong class="title">%s</strong><span class="description">%s</span>', $type->getField('ClassName'), $type->getField('AddAction'), $type->getField('Description')); $pageTypes[$type->getField('ClassName')] = $html; } // Ensure generic page type shows on top if (isset($pageTypes['Page'])) { $pageTitle = $pageTypes['Page']; $pageTypes = array_merge(array('Page' => $pageTitle), $pageTypes); } $numericLabelTmpl = '<span class="step-label"><span class="flyout">%d</span><span class="arrow"></span><span class="title">%s</span></span>'; $topTitle = _t('CMSPageAddController.ParentMode_top', 'Top level'); $childTitle = _t('CMSPageAddController.ParentMode_child', 'Under another page'); $fields = new FieldList($hintsField = new LiteralField('Hints', sprintf('<span class="hints" data-hints="%s"></span>', $this->SiteTreeHints())), new LiteralField('PageModeHeader', sprintf($numericLabelTmpl, 1, _t('CMSMain.ChoosePageParentMode', 'Choose where to create this page'))), $parentModeField = new SelectionGroup("ParentModeField", array("top//{$topTitle}" => null, "child//{$childTitle}" => $parentField = new TreeDropdownField("ParentID", "", 'SiteTree', 'ID', 'TreeTitle'))), $typeField = new OptionsetField("PageType", sprintf($numericLabelTmpl, 2, _t('CMSMain.ChoosePageType', 'Choose page type')), $pageTypes, 'Page')); // TODO Re-enable search once it allows for HTML title display, // see http://open.silverstripe.org/ticket/7455 // $parentField->setShowSearch(true); $parentModeField->setValue($this->request->getVar('ParentID') ? 'child' : 'top'); $parentModeField->addExtraClass('parent-mode'); // CMSMain->currentPageID() automatically sets the homepage, // which we need to counteract in the default selection (which should default to root, ID=0) $homepageSegment = RootURLController::get_homepage_link(); if ($record && $record->URLSegment != $homepageSegment) { $parentField->setValue($record->ID); } $actions = new FieldList(FormAction::create("doAdd", _t('CMSMain.Create', "Create"))->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')->setUseButtonTag(true)); $this->extend('updatePageOptions', $fields); $form = new Form($this, "AddForm", $fields, $actions); $form->addExtraClass('cms-add-form stacked cms-content center cms-edit-form ' . $this->BaseCSSClasses()); $form->setTemplate($this->getTemplatesWithSuffix('_EditForm')); if ($parentID = $this->request->getVar('ParentID')) { $form->Fields()->dataFieldByName('ParentID')->setValue((int) $parentID); } return $form; }
public function Field($properties = []) { if (!$this->config()->exclude_js) { if (!$this->config()->exclude_js_libraries) { Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js'); Requirements::javascript(SS_MWM_FORMFIELDS_DIR . '/thirdparty/js/tab.js'); } Requirements::javascript(SS_MWM_FORMFIELDS_DIR . '/js/tabbedselectiongroup.init.js'); } if (!$this->config()->exclude_css) { Requirements::css(SS_MWM_FORMFIELDS_DIR . '/css/tabbedselectiongroup.css'); } return parent::Field($properties); }
/** * Display CMS link mapping configuration. */ public function getCMSFields() { $fields = parent::getCMSFields(); Requirements::css(MISDIRECTION_PATH . '/css/misdirection.css'); // Remove any fields that are not required in their default state. $fields->removeByName('MappedLink'); $fields->removeByName('IncludesHostname'); $fields->removeByName('Priority'); $fields->removeByName('RedirectType'); $fields->removeByName('RedirectLink'); $fields->removeByName('RedirectPageID'); $fields->removeByName('ResponseCode'); $fields->removeByName('ForwardPOSTRequest'); $fields->removeByName('HostnameRestriction'); // Update any fields that are displayed. $fields->dataFieldByName('LinkType')->addExtraClass('link-type')->setTitle('Type'); // Instantiate the required fields. $fields->insertBefore(HeaderField::create('MappedLinkHeader', 'Mapping', 3), 'LinkType'); // Retrieve the mapped link configuration as a single grouping. $URL = FieldGroup::create(TextField::create('MappedLink', '')->setRightTitle('This should <strong>not</strong> include the <strong>HTTP/S</strong> scheme'), CheckboxField::create('IncludesHostname', 'Includes Hostname?'))->addExtraClass('mapped-link')->setTitle('URL'); $fields->addFieldToTab('Root.Main', $URL); // Generate the 1 - 10 priority selection. $range = array(); for ($iteration = 1; $iteration <= 10; $iteration++) { $range[$iteration] = $iteration; } $fields->addFieldToTab('Root.Main', DropdownField::create('Priority', null, $range)); // Retrieve the redirection configuration as a single grouping. $fields->addFieldToTab('Root.Main', HeaderField::create('RedirectionHeader', 'Redirection', 3)); $redirect = FieldGroup::create()->addExtraClass('redirect-link'); $redirect->push(TextField::create('RedirectLink', '')->setRightTitle('This requires the <strong>HTTP/S</strong> scheme for an external URL')); // Allow redirect page configuration when the CMS module is present. if (ClassInfo::exists('SiteTree')) { // Allow redirect type configuration. if (!$this->RedirectType) { // Initialise the default redirect type. $this->RedirectType = 'Link'; } $fields->addFieldToTab('Root.Main', SelectionGroup::create('RedirectType', array('Link//To URL' => $redirect, 'Page//To Page' => TreeDropdownField::create('RedirectPageID', '', 'SiteTree')))->addExtraClass('field redirect')); } else { $redirect->setTitle('To URL'); $fields->addFieldToTab('Root.Main', $redirect); } // Use third party validation against an external URL. if ($this->canEdit()) { Requirements::javascript(MISDIRECTION_PATH . '/javascript/misdirection-link-mapping.js'); $redirect->push(CheckboxField::create('ValidateExternal', 'Validate External URL?')->addExtraClass('validate-external')); } // Retrieve the response code selection. $responses = Config::inst()->get('SS_HTTPResponse', 'status_codes'); $selection = array(); foreach ($responses as $code => $description) { if ($code >= 300 && $code < 400) { $selection[$code] = "{$code}: {$description}"; } } // Retrieve the response code configuration as a single grouping. $response = FieldGroup::create(DropdownField::create('ResponseCode', '', $selection), CheckboxField::create('ForwardPOSTRequest', 'Forward POST Request?'))->addExtraClass('response')->setTitle('Response Code'); $fields->addFieldToTab('Root.Main', $response); // The optional hostname restriction is now deprecated. if ($this->HostnameRestriction) { $fields->addFieldToTab('Root.Optional', TextField::create('HostnameRestriction')); } // Allow extension customisation. $this->extend('updateLinkMappingCMSFields', $fields); return $fields; }
/** * @return Form */ function AddForm() { // If request send from rightclick-submenu, directly add Page if(($pageType = $this->request->getVar('Type')) && ($parentID = $this->request->getVar('ParentID'))) { $data = array( "PageType" => (string)$pageType, "ParentID" => $parentID, "ParentModeField" => "child" ); $this->doAdd($data, null); return; } $record = $this->currentPage(); $pageTypes = array(); foreach($this->PageTypes() as $type) { $html = sprintf('<span class="icon class-%s"></span><strong class="title">%s</strong><span class="description">%s</span>', $type->getField('ClassName'), $type->getField('AddAction'), $type->getField('Description') ); $pageTypes[$type->getField('ClassName')] = $html; } // Ensure generic page type shows on top if(isset($pageTypes['Page'])) { $pageTitle = $pageTypes['Page']; $pageTypes = array_merge(array('Page' => $pageTitle), $pageTypes); } $numericLabelTmpl = '<span class="step-label"><span class="flyout">%d</span><span class="arrow"></span><span class="title">%s</span></span>'; $topTitle = _t('CMSPageAddController.ParentMode_top', 'Top level'); $childTitle = _t('CMSPageAddController.ParentMode_child', 'Under another page'); $fields = new FieldList( // new HiddenField("ParentID", false, ($this->parentRecord) ? $this->parentRecord->ID : null), // TODO Should be part of the form attribute, but not possible in current form API $hintsField = new LiteralField('Hints', sprintf('<span class="hints" data-hints="%s"></span>', $this->SiteTreeHints())), new LiteralField('PageModeHeader', sprintf($numericLabelTmpl, 1, _t('CMSMain.ChoosePageParentMode', 'Choose where to create this page'))), $parentModeField = new SelectionGroup( "ParentModeField", array( "top//$topTitle" => null, //new LiteralField("Dummy", ''), "child//$childTitle" => $parentField = new TreeDropdownField( "ParentID", "", 'SiteTree' ) ) ), $typeField = new OptionsetField( "PageType", sprintf($numericLabelTmpl, 2, _t('CMSMain.ChoosePageType', 'Choose page type')), $pageTypes, 'Page' ) ); $parentField->setShowSearch(true); $parentModeField->setValue($this->request->getVar('ParentID') ? 'child' : 'top'); $parentModeField->addExtraClass('parent-mode'); // CMSMain->currentPageID() automatically sets the homepage, // which we need to counteract in the default selection (which should default to root, ID=0) $homepageSegment = RootURLController::get_homepage_link(); if($record && $record->URLSegment != $homepageSegment) { $parentField->setValue($record->ID); } $actions = new FieldList( // $resetAction = new ResetFormAction('doCancel', _t('CMSMain.Cancel', 'Cancel')), FormAction::create("doAdd", _t('CMSMain.Create',"Create")) ->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept') ->setUseButtonTag(true) ); $this->extend('updatePageOptions', $fields); $form = new Form($this, "AddForm", $fields, $actions); $form->addExtraClass('cms-add-form stacked cms-content center cms-edit-form ' . $this->BaseCSSClasses()); $form->setTemplate($this->getTemplatesWithSuffix('_EditForm')); if($parentID = $this->request->getVar('ParentID')) { $form->Fields()->dataFieldByName('ParentID')->setValue((int)$parentID); } return $form; }
/** * @return array */ protected function getTagFields() { $fields = new FieldList(LiteralField::create('BlockScrapeTitle', '<p>Block tag and meta keywords generation</p>'), SelectionGroup::create('BlockScrape', [new SelectionGroup_Item(true, [], 'Yes'), new SelectionGroup_Item(false, [new CheckboxField('ReGenerateTags', 'Regenerate tags on save'), new CheckboxField('ReGenerateKeywords', 'Regenerate keywords on save'), new CheckboxField('RestrictToKnownTags', 'Restrict to known terms when regenerating'), new CheckboxField('TreatHashTagsAsKnownTags', 'Treat hash tags as known tags')], 'No')])->addExtraClass('field'), new TextField('MetaKeywords', 'Meta Keywords (comma separated)'), new TextField('Tags', 'Tags (comma separated)')); return $fields; }
/** * Frontend fields * Simple list of the basic fields - how they're intended to be edited */ function getFrontEndFields($params = null) { //parent::getFrontEndFields($params); $timeFrameHeaderText = 'Time Frame'; if (!CalendarConfig::subpackage_setting('events', 'force_end')) { $timeFrameHeaderText = 'End Date / Time (optional)'; } $fields = FieldList::create(TextField::create('Title')->setAttribute('placeholder', 'Enter a title'), CheckboxField::create('AllDay', 'All-day'), $startDateTime = DatetimeField::create('StartDateTime', 'Start'), CheckboxField::create('NoEnd', 'Open End'), HeaderField::create('TimeFrameHeader', $timeFrameHeaderText, 5), SelectionGroup::create('TimeFrameType', array("Duration//Duration" => TimeField::create('Duration', '')->setRightTitle('up to 24h')->setAttribute('placeholder', 'Enter duration'), "DateTime//Date/Time" => $endDateTime = DateTimeField::create('EndDateTime', ''))), LiteralField::create('Clear', '<div class="clear"></div>')); //Date field settings $timeExpl = 'Time, e.g. 11:15am or 15:30'; //$startDateTime->setConfig('datavalueformat', 'YYYY-MM-dd HH:mm'); //$endDateTime->setConfig('datavalueformat', 'YYYY-MM-dd HH:mm'); $startDateTime->getDateField()->setConfig('showcalendar', 1)->setAttribute('placeholder', 'Enter date')->setAttribute('readonly', 'true'); //we only want input through the datepicker $startDateTime->getTimeField()->setConfig('timeformat', 'HH:mm')->setAttribute('placeholder', 'Enter time'); $endDateTime->getDateField()->setConfig('showcalendar', 1)->setAttribute('placeholder', 'Enter date')->setAttribute('readonly', 'true'); //we only want input through the datepicker $endDateTime->getTimeField()->setConfig('timeformat', 'HH:mm')->setAttribute('placeholder', 'Enter time'); //removing AllDay checkbox if allday events are disabled if (!CalendarConfig::subpackage_setting('events', 'enable_allday_events')) { $fields->removeByName('AllDay'); } //removing NoEnd checkbox if end dates are enforced if (CalendarConfig::subpackage_setting('events', 'force_end')) { $fields->removeByName('NoEnd'); } else { //we don't want the NoEnd checkbox when creating new events if (!$this->ID) { //$fields->removeByName('NoEnd'); } } $this->extend('updateFrontEndFields', $fields); return $fields; }
/** * Construct the deployment form * * @param SS_HTTPRequest $request * @return Form */ public function getDeployForm(SS_HTTPRequest $request) { // Performs canView permission check by limiting visible projects $project = $this->getCurrentProject(); if (!$project) { return new SS_HTTPResponse("Project '" . Convert::raw2xml($request->latestParam('Project')) . "' not found.", 404); } // Performs canView permission check by limiting visible projects $environment = $this->getCurrentEnvironment($project); if (!$environment) { return new SS_HTTPResponse("Environment '" . Convert::raw2xml($request->latestParam('Environment')) . "' not found.", 404); } if (!$environment->canDeploy()) { return new SS_HTTPResponse("Not allowed to deploy", 401); } if (!$project->repoExists()) { $literalField = new LiteralField('noRepoWarning', '<strong>The GIT repository is for the time being not available.</strong>'); return Form::create($this, 'DeployForm', new FieldList($literalField), new FieldList()); } $branches = array(); foreach ($project->DNBranchList() as $branch) { $sha = $branch->SHA(); $name = $branch->Name(); $branches[$sha] = $name . ' (' . substr($sha, 0, 8) . ', ' . $branch->LastUpdated()->TimeDiff() . ' old)'; } $tags = array(); foreach ($project->DNTagList()->setLimit(null) as $tag) { $sha = $tag->SHA(); $name = $tag->Name(); $tags[$sha] = $name . ' (' . substr($sha, 0, 8) . ', ' . $tag->Created()->TimeDiff() . ' old)'; } $tags = array_reverse($tags); $redeploy = array(); foreach ($project->DNEnvironmentList() as $dnEnvironment) { $envName = $dnEnvironment->Name; foreach ($dnEnvironment->DeployHistory() as $deploy) { $sha = $deploy->SHA; if (!isset($redeploy[$envName])) { $redeploy[$envName] = array(); } if (!isset($redeploy[$envName][$sha])) { $redeploy[$envName][$sha] = substr($sha, 0, 8) . ' (deployed ' . $deploy->obj('LastEdited')->Ago() . ')'; } } } $releaseMethods = array(); if ($tags) { $releaseMethods[] = new SelectionGroup_Item('Tag', new DropdownField('Tag', '', $tags), 'Deploy a tagged release'); } if ($branches) { $releaseMethods[] = new SelectionGroup_Item('Branch', new DropdownField('Branch', '', $branches), 'Deploy the latest version of a branch'); } if ($redeploy) { $releaseMethods[] = new SelectionGroup_Item('Redeploy', new GroupedDropdownField('Redeploy', '', $redeploy), 'Redeploy a release that was previously deployed (to any environment)'); } $releaseMethods[] = new SelectionGroup_Item('SHA', new Textfield('SHA', 'Please specify the full SHA'), 'Deploy a specific SHA'); $field = new SelectionGroup('SelectRelease', $releaseMethods); $field->setValue('Tag'); $form = new Form($this, 'DeployForm', new FieldList($field), new FieldList($deployAction = new FormAction('doDeploy', "Deploy to " . $environment->Name))); $deployAction->addExtraClass('btn'); $form->disableSecurityToken(); // Tweak the action so it plays well with our fake URL structure. $form->setFormAction($request->getURL() . '/DeployForm'); return $form; }
/** * Construct fields to select any commit * * @param DNProject $project * @param DataList $pipelineCommits Optional list of pipeline-filtered commits to include * @return FormField */ protected function buildCommitSelector($project, $pipelineCommits = null) { // Branches $branches = array(); foreach ($project->DNBranchList() as $branch) { $sha = $branch->SHA(); $name = $branch->Name(); $branches[$sha . '-' . $name] = $name . ' (' . substr($sha, 0, 8) . ', ' . $branch->LastUpdated()->TimeDiff() . ' old)'; } // Tags $tags = array(); foreach ($project->DNTagList()->setLimit(null) as $tag) { $sha = $tag->SHA(); $name = $tag->Name(); $tags[$sha . '-' . $tag] = $name . ' (' . substr($sha, 0, 8) . ', ' . $tag->Created()->TimeDiff() . ' old)'; } $tags = array_reverse($tags); // Past deployments $redeploy = array(); foreach ($project->DNEnvironmentList() as $dnEnvironment) { $envName = $dnEnvironment->Name; foreach ($dnEnvironment->DeployHistory() as $deploy) { $sha = $deploy->SHA; if (!isset($redeploy[$envName])) { $redeploy[$envName] = array(); } if (!isset($redeploy[$envName][$sha])) { $redeploy[$envName][$sha] = substr($sha, 0, 8) . ' (deployed ' . $deploy->obj('LastEdited')->Ago() . ')'; } } } // Merge fields $releaseMethods = array(); if ($pipelineCommits) { $releaseMethods[] = new SelectionGroup_Item('FilteredCommits', $this->buildPipelineField($pipelineCommits), 'Deploy a commit prepared for this pipeline'); } if ($branches) { $releaseMethods[] = new SelectionGroup_Item('Branch', new DropdownField('Branch', '', $branches), 'Deploy the latest version of a branch'); } if ($tags) { $releaseMethods[] = new SelectionGroup_Item('Tag', new DropdownField('Tag', '', $tags), 'Deploy a tagged release'); } if ($redeploy) { $releaseMethods[] = new SelectionGroup_Item('Redeploy', new GroupedDropdownField('Redeploy', '', $redeploy), 'Redeploy a release that was previously deployed (to any environment)'); } $releaseMethods[] = new SelectionGroup_Item('SHA', new Textfield('SHA', 'Please specify the full SHA'), 'Deploy a specific SHA'); $field = new SelectionGroup('SelectRelease', $releaseMethods); $field->setValue(reset($releaseMethods)->getValue()); return $field; }
public function getCMSFields() { Requirements::css('silverstripe-video-embed/assests/css/VideoEmbedEditor.css'); Requirements::javascript('silverstripe-video-embed/assests/javascript/urlParser.min.js'); Requirements::javascript(THIRDPARTY_DIR . '/json-js/json2.js'); Requirements::javascript('silverstripe-video-embed/assests/javascript/VideoEmbedEditor.js'); $Fields = parent::getCMSFields(); $Fields->removeByName('Type'); $Fields->removeByName('Code'); $Fields->removeByName('HTML5Video'); $Fields->removeByName('ThumbnailURL'); $Fields->removeByName('ThumbnailFile'); $types = $this->GetVideoTypes(); $typeSelection = array(); foreach ($types as $type) { if (isset($type["label"])) { $typeSelection[$type["label"]] = $type["label"]; } } $Fields->addFieldToTab('Root.Main', new DropdownField("Type", "Type", $typeSelection)); $CodeField = new TextField("Code", "Code"); $CodeField->setDescription(' Copy and paste your Video URL here<br/> eg</br> https://www.youtube.com/watch?v=cRi5Hh7RU34</br> http://vimeo.com/93104916</br> http://www.dailymotion.com/video/x1no7nq_jquery-and-ajax-tutorials-45-ajax-login-example_tech</br> '); $Fields->addFieldToTab('Root.Main', $CodeField); $TitleField = new TextField("Title", "Title"); $Fields->addFieldToTab('Root.Main', $TitleField); $HTML5VideoField = new UploadField('HTML5Video', 'Video file'); //::create("HTML5Video")->setTitle("Album Cover Photo"); $HTML5VideoField->getValidator()->allowedExtensions = array("webm", "ogg", "mp4", "flv"); $HTML5VideoField->setAllowedMaxFileNumber(1); $Fields->addFieldToTab('Root.Main', $HTML5VideoField); $ThumbnailUploadField = new UploadField('ThumbnailFile', ''); $ThumbnailUploadField->getValidator()->allowedExtensions = array('jpg', 'jpeg', 'gif', 'png'); $ThumbnailUploadField->setAllowedMaxFileNumber(1); $thumbnailField = new SelectionGroup('ThumbnailGroup', array(SelectionGroup_Item::create('URL', array(LiteralField::create('ThumbPreview', ' <div class="ss-uploadfield "> <div class="ss-uploadfield-item ss-uploadfield-addfile middleColumn"> <div class="ss-uploadfield-item-preview ss-uploadfield-dropzone ui-corner-all" style="display: block; margin: 0" id="ThumbnailURLHolder"> Enter a URL </div> <img src="" alt="Failed to load preview" style="display:none; width: 60px;" id="ThumbnailURLPreview"/> '), TextField::create('ThumbnailURL', ''), LiteralField::create('ThumbPreview', ' </div> </div>'))), SelectionGroup_Item::create('File', $ThumbnailUploadField))); $thumbnailField->setValue("URL"); if ($this->ThumbnailURL) { $thumbnailField->setValue("URL"); } else { if ($this->ThumbnailFile()->exists()) { $thumbnailField->setValue("File"); } } $fields[] = LiteralField::create("guestLabel", '<div id="Thumbnail" class="field text"> <label class="left" for="Form_ItemEditForm_Value">Thumbnail</label> <div class="middleColumn">'); $fields[] = $thumbnailField; $fields[] = LiteralField::create("guestLabel", ' <input type="text" name="Value" class="text" id="Form_ItemEditForm_Value"> </div> </div>'); $fields[] = new HiddenField("VideoTypesHolder", "VideoTypesHolder", Convert::raw2json($types)); $Fields->addFieldsToTab('Root.Main', $fields); return $Fields; }