/**
  * @return Comosite FieldSet with Categorys and Items
  */
 function getCompositeField()
 {
     //create new composite field group for each category
     $oCatFieldSet = new CompositeField();
     // Set the field group ID
     $oCatFieldSet->setID('Cat' . $this->ID);
     $oCatFieldSet->addExtraClass('category');
     //create new composite field group for each category
     $oCatField = new TextField($this->ID . '_' . $this->FieldName, $this->Title, null, null);
     $oCatField->addExtraClass('category-field');
     //Add Category Percentage Field to the Form
     $oCatFieldSet->push($oCatField);
     if ($this->Description) {
         $oCatDescField = new LiteralField($this->ID . '_Description', '<p class="category-field-desc">' . $this->Description . '</p>');
         $oCatDescField->addExtraClass('category-field');
         $oCatFieldSet->push($oCatDescField);
     }
     //Add item Composite Field to this Composite Field
     //now get all of the items matched with this category
     $oFormCategoryItems = self::FormCategoryItems();
     foreach ($oFormCategoryItems as $item) {
         $oCatFieldSet->push($item->getFormField());
     }
     return $oCatFieldSet;
 }
    public function getCMSFields()
    {
        $fields = parent::getCMSFields();
        $fields->removeByName('Order');
        $fields->removeByName('Title');
        $fields->removeByName('ProcessInfo');
        $fields->removeByName('ParentProcessID');
        $fields->addFieldToTab('Root.Main', $processSteps = new CompositeField($title = new TextField('Title', 'Title')));
        $title->addExtraClass('process-noborder');
        $processSteps->addExtraClass('process-step');
        $fields->addFieldToTab('Root.Main', $processSteps = new CompositeField(new GridField('ProcessInfo', 'Information for this case', $this->ProcessInfo(), GridFieldConfig_RecordViewer::create())));
        $processes = Process::get();
        if ($processes) {
            $fields->insertAfter($inner = new CompositeField(new LiteralField('ExplainStop', '<label class="right">This must be set after you create a process</label>'), $processesOptions = new DropdownField('ParentProcessID', 'Process', $processes->map('ID', 'Title'))), 'Title');
            $inner->addExtraClass('message special');
        }
        $processSteps->addExtraClass('process-step');
        $fields->insertBefore(new LiteralField('StageTitle', '<h3 class="process-info-header">
				<span class="step-label">
					<span class="flyout">0.1</span><span class="arrow"></span>
					<span class="title">Case details</span>
				</span>
			</h3>'), 'Title');
        $fields->insertBefore(new LiteralField('StageTitle', '<h3 class="process-info-header">
				<span class="step-label">
					<span class="flyout">0.2</span><span class="arrow"></span>
					<span class="title">Associated Information Pieces</span>
				</span>
			</h3>'), 'ProcessInfo');
        return $fields;
    }
예제 #3
0
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeByName('Archived');
     $fields->removeByName('Sort');
     $fields->addFieldToTab('Root.Main', $group = new CompositeField($label = new LabelField("LabelArchive", "Archive this news item?"), new CheckboxField('Archived', '')));
     $group->addExtraClass("field special");
     $label->addExtraClass("left");
     $fields->removeByName('ParentID');
     return $fields;
 }
 function PopupForm()
 {
     $form = new Form($this, "{$this->name}/PopupForm", new FieldList($headerWrap = new CompositeField(new LiteralField('Heading', sprintf('<h3 class="htmleditorfield-mediaform-heading insert">%s</h3>', 'Edit Source'))), $codeField = new CodeEditorField('TinyMCESource', '')), new FieldList(ResetFormAction::create('cancel', 'Cancel')->addExtraClass('ss-ui-action-destructive')->setUseButtonTag(true), FormAction::create('update', 'Update')->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')->setUseButtonTag(true)));
     $headerWrap->addExtraClass('CompositeField composite cms-content-header nolabel ');
     //	$contentComposite->addExtraClass('tinymce-codeeditor-field content');
     $codeField->addExtraClass('nolabel stacked');
     $form->unsetValidator();
     $form->loadDataFrom($this);
     $form->addExtraClass('htmleditorfield-form htmleditorfield-codeform cms-dialog-content');
     //	$this->extend('updateLinkForm', $form);
     return $form;
 }
예제 #5
0
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeByName('Archived');
     $fields->removeByName('Sort');
     $fields->addFieldToTab('Root.Main', $group = new CompositeField($label = new LabelField("LabelArchive", "Archive this news item?"), new CheckboxField('Archived', '')));
     $group->addExtraClass("field special");
     $label->addExtraClass("left");
     $fields->removeByName('ParentID');
     $fields->insertAfter(ColorPaletteField::create("Colour", "Colour", array('night' => '#333333', 'air' => '#009EE2', 'earth' => ' #79c608', 'passion' => '#b02635', 'people' => '#de347f', 'inspiration' => '#783980')), "Title");
     return $fields;
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $gateways = GatewayInfo::get_supported_gateways();
     $amountfields = $this->Fields()->map("ID", "Title");
     $fields->addFieldsToTab("Root.Payment", array(DropdownField::create("PaymentAmountFieldID", "Payment Amount Field", $amountfields)->setDescription("This must return a value like 20.00 (no dollar sign)"), new DropdownField("PaymentGateway", "Payment Gateway", $gateways), new TextField("PaymentCurrency", "Payment Currency"), new CheckboxField("PaymentFields_Card", "Show Card Fields"), new CheckboxField("PaymentFields_Billing", "Show Billing Fields"), new CheckboxField("PaymentFields_Shipping", "Show Shipping Fields"), new CheckboxField("PaymentFields_Company", "Show Company Fields"), new CheckboxField("PaymentFields_Email", "Show Email Fields")));
     // text to show on error
     $onErrorFieldSet = new CompositeField($label = new LabelField('OnErrorMessageLabel', _t('UserDefinedForm.ONERRORLABEL', 'Show on error')), $editor = new HtmlEditorField("OnErrorMessage", "", _t('UserDefinedForm.ONERRORMESSAGE', $this->OnErrorMessage)));
     $onErrorFieldSet->addExtraClass('field');
     $fields->insertAfter($onErrorFieldSet, "OnCompleteMessage");
     return $fields;
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeByName('Archived');
     $fields->addFieldToTab('Root.Main', new TreeDropdownField('LinkID', 'Link', 'SiteTree'));
     $fields->addFieldToTab('Root.Main', $group = new CompositeField($label = new LabelField("LabelArchive", "Archive this carousel item?"), new CheckboxField('Archived', '')));
     $group->addExtraClass("field special");
     $label->addExtraClass("left");
     $fields->removeByName('ParentID');
     $fields->insertBefore($wrap = new CompositeField($extraLabel = new LabelField('Note', "Note: You will need to create the carousel item before you can add an image")), 'Image');
     $wrap->addExtraClass('alignExtraLabel');
     return $fields;
 }
 public function __construct($controller, $name)
 {
     $fields = new FieldList($dataFields = new CompositeField(TextField::create("Name", _t('ContactForm.YOURNAME', 'Your name'))->setCustomValidationMessage(_t('ContactForm.YOURNAME_MESSAGE_REQUIRED', 'Please enter your name'))->setAttribute('data-message-required', _t('ContactForm.YOURNAME_MESSAGE_REQUIRED', 'Please enter your name')), EmailField::create("Email", _t('ContactController.EMAILADDRESS', "Your email address"))->setCustomValidationMessage(_t('ContactForm.EMAILADDRESS_MESSAGE_REQUIRED', 'Please enter your email address'))->setAttribute('data-message-required', _t('ContactForm.EMAILADDRESS_MESSAGE_REQUIRED', 'Please enter your email address'))->setAttribute('data-message-email', _t('ContactForm.EMAILADDRESS_MESSAGE_EMAIL', 'Please enter a valid email address')), TextareaField::create("Comment", _t('ContactController.COMMENTS', "Comments"))->setCustomValidationMessage(_t('ContactForm.COMMENT_MESSAGE_REQUIRED', 'Please enter your comment'))->setAttribute('data-message-required', _t('ContactForm.COMMENT_MESSAGE_REQUIRED', 'Please enter your comment'))), HiddenField::create("ReturnURL"));
     $dataFields->addExtraClass('data-fields');
     // save actions
     $actions = new FieldList(new FormAction("doPostContact", _t('ContactForm.POST', 'Post')));
     // required fields for server side
     $required = new RequiredFields(array('Name', 'Email', 'Comment'));
     $this->setAttribute('novalidate', 'novalidate');
     // Set it so the user gets redirected back down to the form upon form fail
     //$this->setRedirectToFormOnValidationError(true);
     parent::__construct($controller, $name, $fields, $actions, $required);
 }
예제 #9
0
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeByName('Archived');
     $fields->removeByName('Sort');
     $fields->insertAfter(LinkField::create('LinkID', 'Link'), "Title");
     $fields->insertAfter($altText = TextField::create('AltText', 'Alternative text'), "Title");
     $altText->setDescription("e.g. Sign up now!");
     $fields->addFieldToTab('Root.Main', $group = new CompositeField($label = new LabelField("LabelArchive", "Archive this promotional item?"), new CheckboxField('Archived', '')));
     $group->addExtraClass("field special");
     $label->addExtraClass("left");
     $fields->removeByName('ParentID');
     return $fields;
 }
    public function getCMSFields()
    {
        $fields = parent::getCMSFields();
        $fields->removeByName('Order');
        $fields->removeByName('ProcessInfo');
        $fields->removeByName('StopStageID');
        $fields->removeByName('StopButton');
        $fields->removeByName('ContinueButton');
        $fields->removeByName('DecisionPoint');
        $fields->removeByName('CaseFinal');
        $fields->insertBefore(new LiteralField('StageTitle', '<h3 class="process-info-header">
			<span class="step-label">
				<span class="flyout">3</span><span class="arrow"></span>
				<span class="title">Stage Settings</span>
			</span>
		</h3>'), 'Title');
        $caseFinalMap = ProcessCase::get()->filter(array('ParentProcessID' => $this->ParentID))->map("ID", "Title")->toArray();
        asort($caseFinalMap);
        $case = ListboxField::create('CaseFinal', 'Final step for these Cases')->setMultiple(true)->setSource($caseFinalMap)->setAttribute('data-placeholder', _t('ProcessAdmin.Cases', 'Cases', 'Placeholder text for a dropdown'));
        $fields->insertAfter($case, 'Title');
        $fields->insertAfter($group = new CompositeField($label = new LabelField('switchLabel', 'Act as Decision Point'), new CheckboxField('DecisionPoint', '')), 'ParentID');
        $group->addExtraClass("field special process-noborder");
        $label->addExtraClass("left");
        $fields->dataFieldByName('Content')->setRows(10);
        if ($this->ID > 0) {
            $fields->addFieldToTab('Root.Main', new LiteralField('SaveRecord', '<p></p>'));
            $fields->addFieldToTab('Root.Main', $processInfo = new CompositeField($grid = new GridField('ProcessInfo', 'Information for this stage', $this->ProcessInfo()->sort(array('TypeID' => 'ASC', 'ProcessCaseID' => 'ASC', 'LinksToAnotherStageID' => 'ASC')), $gridConfig = GridFieldConfig_RelationEditor::create())));
            $gridConfig->addComponent(new GridFieldSortableRows('Order'));
            $processInfo->addExtraClass('process-spacing');
            $grid->addExtraClass('toggle-grid');
        } else {
            $fields->addFieldToTab('Root.Main', new LiteralField('SaveRecord', '<p class="message info">Save this stage to add info</p>'));
        }
        $fields->insertBefore(new LiteralField('StageTitleInfo', '<h3 class="process-info-header">
				<span class="step-label">
					<span class="flyout">4</span><span class="arrow"></span>
					<span class="title">Information</span>
				</span>
			</h3>'), 'SaveRecord');
        $stopStage = ProcessStopStage::get();
        if ($stopStage) {
            $fields->insertBefore($inner = new CompositeField(new LiteralField('Decision', '<h3>Decision Point</h3>'), new LiteralField('ExplainStop', '<label class="right">Choose a stop stage if you would like this stage to act as a decision point</label>'), $stop = new DropdownField('StopStageID', 'Stop Stage', $stopStage->map('ID', 'Title')), $continue = new TextField('ContinueButton', 'Button: Continue (e.g. "Yes")'), new TextField('StopButton', 'Button: Stop (e.g. "No")')), 'ProcessInfo');
            $stop->setEmptyString('No stop after this stage');
            $inner->addExtraClass('message special toggle-decide');
            $continue->addExtraClass('process-noborder');
            $stop->addExtraClass('process-noborder');
        }
        return $fields;
    }
 /**
  * Don't pass $form in by reference, as doing so and adding a field creates both a div and an 
  * input with identical IDs - which is both invalid HTML and breaks the ability to click on the
  * label and focus on the input
  */
 public function updateMediaForm($form)
 {
     Requirements::javascript(HTMLEDITORIFRAME_BASE . '/javascript/HtmlEditorField_Iframe.js');
     Requirements::css(HTMLEDITORIFRAME_BASE . '/css/HtmlEditorField_Iframe.css');
     $numericLabelTmpl = '<span class="step-label"><span class="flyout">%d</span><span class="arrow"></span>' . '<strong class="title">%s</strong></span>';
     $fromIframe = new CompositeField(new LiteralField('headerIframe', '<h4>' . sprintf($numericLabelTmpl, '1', "Iframe URL") . '</h4>'), $iframeURL = new TextField('IframeURL', 'http://'), new LiteralField('addIframeImage', '<button class="action ui-action-constructive ui-button field add-iframe" data-icon="addMedia">Add url</button>'));
     $iframeURL->addExtraClass('iframeurl');
     $fromIframe->addExtraClass('content ss-uploadfield from-web');
     // $fields->dataFieldByName() doesn't appear to work
     $fields = $form->Fields();
     $tabset = $fields[1]->fieldByName("MediaFormInsertMediaTabs");
     $tabset->push($iFrameTab = new Tab('From an Iframe', $fromIframe));
     $iFrameTab->addExtraClass('htmleditorfield-from-iframe');
     return $form;
 }
예제 #12
0
파일: Region.php 프로젝트: adrexia/nzlarps
 /**
  * Returns a FieldList of cms form fields that is the main form for editing this DataObject
  *
  * @return FieldList
  */
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     // Hide these from editing
     $fields->removeByName('ParentID');
     $fields->removeByName('Sort');
     $image = $fields->dataFieldByName('SplashImage');
     $image->setFolderName('Uploads/Splash-Images');
     $fields->insertAfter(ColorPaletteField::create("Colour", "Colour", array('night' => '#333333', 'air' => '#009EE2', 'earth' => ' #79c608', 'passion' => '#b02635', 'people' => '#de347f', 'inspiration' => '#783980')), "Title");
     $fields->removeByName('HideFromRegionLists');
     // Archived
     $fields->removeByName('Archived');
     $fields->addFieldToTab('Root.Main', $group = new CompositeField($labelHide = new LabelField("LabelHideFromRegionLists", "Hide from region lists?"), new CheckboxField('HideFromRegionLists', "e.g. if you need a region for an event that isn't a branch location"), $label = new LabelField("LabelArchive", "Archive this region?"), new CheckboxField('Archived', '')));
     $labelHide->addExtraClass("left");
     $group->addExtraClass("special field");
     $label->addExtraClass("left");
     return $fields;
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->insertAfter($gameFormContent = new HTMLEditorField('GameLiveContent', 'Game selection form detail'), 'Content');
     $gameFormContent->setRows(20);
     $regOpen = new CheckboxField('OpenGameReg', '');
     $fields->insertBefore($cField = new CompositeField(array($label = new LabelField('OpenGameRegLabel', 'Open game selection (all)'), $regOpen)), 'Content');
     $cField->addExtraClass('field');
     $regOpen->addExtraClass('mts');
     $label->addExtraClass('left');
     $groupsMap = array();
     foreach (Group::get() as $group) {
         // Listboxfield values are escaped, use ASCII char instead of &raquo;
         $groupsMap[$group->ID] = $group->getBreadcrumbs(' > ');
     }
     asort($groupsMap);
     $fields->insertBefore(ListboxField::create('OpenGameRegForGroups', "Open game selection for group (limited)")->setMultiple(true)->setSource($groupsMap)->setAttribute('data-placeholder', _t('Member.ADDGROUP', 'Add group', 'Placeholder text for a dropdown')), 'Content');
     return $fields;
 }
예제 #14
0
 /**
  * Returns a FieldList of cms form fields
  *
  * @return FieldList
  */
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     // Hide these from editing
     $fields->removeByName('ParentID');
     $fields->removeByName('Sort');
     //Remove to re-add
     $fields->removeByName('Type');
     $fields->removeByName('LinkLabel');
     $content = $fields->dataFieldByName('Content');
     $numberToDisplay = $fields->dataFieldByName('NumberToDisplay');
     $projectPage = $fields->dataFieldByName('ProjectPageID');
     $html = $fields->dataFieldByName('HTML');
     $subtitle = $fields->dataFieldByName('SubTitle');
     $html->setRows(20);
     $html->addExtraClass('no-pagebreak');
     $link = $fields->dataFieldByName('LinkID');
     $image = $fields->dataFieldByName('Image');
     $image->setFolderName('Uploads/Small-Images');
     $fields->removeByName('Image');
     $fields->insertBefore($projectPage, 'Content');
     $fields->insertAfter($type = OptionSetField::create("Type", "Type", $this->dbObject('Type')->enumValues()), "Colour");
     $type->addExtraClass('inline-short-list');
     $fields->insertAfter(ColorPaletteField::create("Colour", "Colour", array('night' => '#333333', 'air' => '#009EE2', 'earth' => ' #79c608', 'passion' => '#b02635', 'people' => '#de347f', 'inspiration' => '#783980')), "Title");
     $fields->insertAfter($linkLabel = new TextField("LinkLabel", "Link Label"), "LinkID");
     $fields->insertAfter($imageLogin = DisplayLogicWrapper::create($image), 'LinkLabel');
     $imageLogin->hideUnless("Type")->isEqualTo("Content");
     $html->hideUnless("Type")->isEqualTo("HTML");
     $subtitle->hideUnless("Type")->isEqualTo("HTML");
     $link->hideUnless("Type")->isEqualTo("Content")->orIf("Type")->isEqualTo("Project");
     $linkLabel->hideUnless("LinkID")->isGreaterThan(0)->andIf("Type")->isEqualTo("Content");
     $numberToDisplay->hideIf("Type")->isEqualTo("Content")->orIf("Type")->isEqualTo("HTML");
     $projectPage->hideUnless("Type")->isEqualTo("Project");
     $content->hideUnless("Type")->isEqualTo("Content");
     // Archived
     $fields->removeByName('Archived');
     $fields->addFieldToTab('Root.Main', $group = new CompositeField($label = new LabelField("LabelArchive", "Archive this feature?"), new CheckboxField('Archived', '')));
     $group->addExtraClass("special field");
     $label->addExtraClass("left");
     return $fields;
 }
 /**
  * @return Form
  */
 public function ImageForm()
 {
     Requirements::css('framework/admin/thirdparty/jquery-notice/jquery.notice.css');
     Requirements::css('framework/thirdparty/jquery-ui-themes/smoothness/jquery-ui.css');
     Requirements::css('framework/admin/thirdparty/chosen/chosen/chosen.css');
     Requirements::css('framework/thirdparty/jstree/themes/apple/style.css');
     Requirements::css('framework/css/TreeDropdownField.css');
     Requirements::css('framework/css/GridField.css');
     Requirements::css('framework/admin/css/screen.css');
     Requirements::css('site/css/cms.css');
     Requirements::css('dashboard/css/dashboard_icon.css');
     Requirements::css('userforms/css/FieldEditor.css');
     Requirements::css('cms/css/screen.css');
     Requirements::javascript('framework/thirdparty/jquery/jquery.js');
     Requirements::javascript('framework/thirdparty/jquery-ui/jquery-ui.js');
     Requirements::javascript('framework/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js');
     Requirements::javascript('framework/thirdparty/jquery-cookie/jquery.cookie.js');
     Requirements::javascript('framework/javascript/GridField.js');
     Requirements::javascript('framework/admin/javascript/leaktools.js');
     Requirements::javascript('framework/admin/javascript/LeftAndMain.Layout.js');
     Requirements::javascript('framework/admin/javascript/LeftAndMain.js');
     Requirements::javascript('framework/admin/javascript/LeftAndMain.ActionTabSet.js');
     Requirements::javascript('framework/admin/javascript/LeftAndMain.Panel.js');
     Requirements::javascript('framework/admin/javascript/LeftAndMain.Tree.js');
     Requirements::javascript('framework/admin/javascript/LeftAndMain.Content.js');
     Requirements::javascript('framework/admin/javascript/LeftAndMain.EditForm.js');
     Requirements::javascript('framework/admin/javascript/LeftAndMain.Menu.js');
     Requirements::javascript('framework/admin/javascript/LeftAndMain.Preview.js');
     Requirements::javascript('framework/admin/javascript/LeftAndMain.BatchActions.js');
     Requirements::javascript('framework/admin/javascript/LeftAndMain.FieldHelp.js');
     Requirements::javascript('framework/admin/javascript/LeftAndMain.TreeDropdownField.js');
     Requirements::javascript('framework/javascript/lang/en.js');
     $numericLabelTmpl = '<span class="step-label"><span class="flyout">%d</span><span class="arrow"></span>' . '<strong class="title">%s</strong></span>';
     $form = new Form($this, "ImageForm", new FieldList($contentComposite = new CompositeField(new LiteralField('Step1', '<div class="step1">' . sprintf($numericLabelTmpl, '1', _t('HtmlEditorField.SELECTIMAGE', 'Select Image')) . '</div>'), CloudinaryImageField::create('Image')->addExtraClass('markdown-popup'), new LiteralField('Step2', '<div class="step2">' . sprintf($numericLabelTmpl, '2', _t('HtmlEditorField.DETAILS', 'Details')) . '</div>'), NumericField::create('Width'), NumericField::create('Height'), TextField::create('AltText')->setTitle('Alter Text'))), new FieldList(FormAction::create('insert', _t('HtmlEditorField.BUTTONINSERTIMAGE', 'Insert Image'))->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')->setUseButtonTag(true)));
     $contentComposite->addExtraClass('ss-insert-image content ss-insert-media');
     $form->unsetValidator();
     $form->loadDataFrom($this);
     $form->addExtraClass('markdownfield-form markdowneditorfield-imageform ');
     return $form;
 }
 /**
  * Presents a form to select a language to translate the pages selected with batch actions into.
  *
  * @param string $pageIDs | null
  * @return Form $form
  */
 public function TranslatePagesForm($pageIDs = null)
 {
     Versioned::reading_stage('Stage');
     // Needs this for changes to effect draft tree
     $languages = Translatable::get_allowed_locales();
     $action = FormAction::create('doTranslatePages', 'Translate')->setUseButtonTag('true')->addExtraClass('ss-ui-button ss-ui-action-constructive batch-form-actions')->setUseButtonTag(true);
     $actions = FieldList::create($action);
     $allFields = new CompositeField();
     $allFields->addExtraClass('batch-form-body');
     if ($pageIDs == null) {
         $pageIDs = $this->getRequest()->getVar('PageIDs');
     } else {
         $allFields->push(new LiteralField("ErrorParent", '<p class="message bad">Invalid parent selected, please choose another</p>'));
     }
     $allFields->push(new HiddenField("PageIDs", "PageIDs", $pageIDs));
     $allFields->push(LanguageDropdownField::create("NewTransLang", _t('Translatable.NEWLANGUAGE', 'New language'), $languages));
     $headings = new CompositeField(new LiteralField('Heading', sprintf('<h3 class="">%s</h3>', _t('HtmlEditorField.MOVE', 'Choose Language...'))));
     $headings->addExtraClass('cms-content-header batch-pages');
     $fields = new FieldList($headings, $allFields);
     $form = Form::create($this, 'TranslatePagesForm', $fields, $actions);
     return $form;
 }
 /**
  * @param Controller $controller
  * @param String $name
  * @param Order $order
  * @param String
  */
 function __construct(Controller $controller, $name, Order $order, $returnToLink = '')
 {
     $fields = new FieldList(new HiddenField('OrderID', '', $order->ID));
     if ($returnToLink) {
         $fields->push(new HiddenField("returntolink", "", convert::raw2att($returnToLink)));
     }
     $bottomFields = new CompositeField();
     $bottomFields->addExtraClass('bottomOrder');
     if ($order->Total() > 0) {
         $paymentFields = EcommercePayment::combined_form_fields($order->getTotalAsMoney()->NiceLongSymbol(false), $order);
         foreach ($paymentFields as $paymentField) {
             $bottomFields->push($paymentField);
         }
         if ($paymentRequiredFields = EcommercePayment::combined_form_requirements($order)) {
             $requiredFields = array_merge($requiredFields, $paymentRequiredFields);
         }
     } else {
         $bottomFields->push(new HiddenField("PaymentMethod", "", ""));
     }
     $fields->push($bottomFields);
     $actions = new FieldList(new FormAction('dopayment', _t('OrderForm.PAYORDER', 'Pay balance')));
     $requiredFields = array();
     $validator = OrderForm_Payment_Validator::create($requiredFields);
     $form = parent::__construct($controller, $name, $fields, $actions, $validator);
     //extension point
     $this->extend('updateFields', $fields);
     $this->setFields($fields);
     $this->extend('updateActions', $actions);
     $this->setActions($actions);
     $this->extend('updateValidator', $validator);
     $this->setValidator($validator);
     $this->setFormAction($controller->Link($name));
     $oldData = Session::get("FormInfo.{$this->FormName()}.data");
     if ($oldData && (is_array($oldData) || is_object($oldData))) {
         $this->loadDataFrom($oldData);
     }
     $this->extend('updateOrderForm_Payment', $this);
 }
    public function createTwoColumnField($id, $label, $field1, $field2)
    {
        $twoColumnField = new CompositeField(new LiteralField($id . '-wrap', '
<div id="' . $id . '-wrap" class="field fieldgroup">
    <label class="left" for="HeaderLogoOffsetLarge">' . $label . '</label>
    <div class="middleColumn">
        <div id="' . $id . '[X]" class="fieldgroup-field nolabel" style="padding-top: 0; margin-top: -7px;">
            <div class="nolabel">
                '), $field1, new LiteralField('MobileLogoOffSetField2', '
  </div>
        </div>
        <div id="' . $id . '[Y]" class="fieldgroup-field nolabel" style="padding-top: 0; margin-top: -7px;">
            <div class="nolabel">
                '), $field2, new LiteralField('MobileLogoOffSetField3', '
   </div>
        </div>
    </div>
</div>
'));
        $twoColumnField->addExtraClass('field');
        $twoColumnField->setName($id);
        return $twoColumnField;
    }
예제 #19
0
    public function getCMSFields()
    {
        $fields = parent::getCMSFields();
        $fields->removeByName('Order');
        $fields->removeByName('Title');
        $fields->removeByName('ProcessStages');
        $fields->removeByName('StopStages');
        if ($this->ID > 0) {
            $stops = new GridField('StopStages', 'Stopping Points', $this->StopStages(), GridFieldConfig_RelationEditor::create());
            $stopGroup = new ToggleCompositeField('StopStages', 'Stopping points in this process', array(LiteralField::create('StopDescription', '<p class="message info">Create all stops for this process. You can then link to these stops from within any stages you create.</p>'), $stops));
            $stopGroup->setHeadingLevel(5);
        } else {
            $stopGroup = LiteralField::create('NoStopDescription', '<p class="message info">Save this process to add stages and stop stages</p>');
        }
        $fields->addFieldToTab('Root.Main', $processSteps = new CompositeField($title = new TextField('Title', 'Title'), $stopGroup));
        $title->addExtraClass('process-noborder');
        $processSteps->addExtraClass('process-step');
        $fields->insertBefore(new LiteralField('StageTitle', '<h3 class="process-info-header">
				<span class="step-label">
					<span class="flyout">1</span><span class="arrow"></span>
					<span class="title">Process details</span>
				</span>
			</h3>'), 'Title');
        if ($this->ID > 0) {
            $fields->addFieldToTab('Root.Main', $processSteps = new CompositeField(new GridField('ProcessStages', 'Process Stages', $this->ProcessStages(), $processStages = GridFieldConfig_RelationEditor::create())));
            $processStages->addComponent(new GridFieldSortableRows('Order'));
            $processSteps->addExtraClass('process-step');
            $fields->insertBefore(new LiteralField('StageTitle', '<h3 class="process-info-header">
					<span class="step-label">
						<span class="flyout">2</span><span class="arrow"></span>
						<span class="title">Stages of this process</span>
					</span>
				</h3>'), 'ProcessStages');
        }
        return $fields;
    }
예제 #20
0
    /**
     * @return FieldList
     */
    public function getCMSFields()
    {
        // call updateCMSFields after userforms
        SiteTree::disableCMSFieldsExtensions();
        $fields = parent::getCMSFields();
        SiteTree::enableCMSFieldsExtensions();
        // define tabs
        $fields->findOrMakeTab('Root.FormContent', _t('UserDefinedForm.FORM', 'Form'));
        $fields->findOrMakeTab('Root.FormOptions', _t('UserDefinedForm.CONFIGURATION', 'Configuration'));
        $fields->findOrMakeTab('Root.Submissions', _t('UserDefinedForm.SUBMISSIONS', 'Submissions'));
        // field editor
        $fields->addFieldToTab("Root.FormContent", new FieldEditor("Fields", 'Fields', "", $this));
        // text to show on complete
        $onCompleteFieldSet = new CompositeField($label = new LabelField('OnCompleteMessageLabel', _t('UserDefinedForm.ONCOMPLETELABEL', 'Show on completion')), $editor = new HtmlEditorField("OnCompleteMessage", "", _t('UserDefinedForm.ONCOMPLETEMESSAGE', $this->OnCompleteMessage)));
        $onCompleteFieldSet->addExtraClass('field');
        $editor->setRows(3);
        $label->addExtraClass('left');
        // Set the summary fields of UserDefinedForm_EmailRecipient dynamically via config system
        Config::inst()->update('UserDefinedForm_EmailRecipient', 'summary_fields', array('EmailAddress' => _t('UserDefinedForm.EMAILADDRESS', 'Email'), 'EmailSubject' => _t('UserDefinedForm.EMAILSUBJECT', 'Subject'), 'EmailFrom' => _t('UserDefinedForm.EMAILFROM', 'From')));
        // who do we email on submission
        $emailRecipients = new GridField("EmailRecipients", _t('UserDefinedForm.EMAILRECIPIENTS', 'Email Recipients'), $this->EmailRecipients(), GridFieldConfig_RecordEditor::create(10));
        $emailRecipients->getConfig()->getComponentByType('GridFieldAddNewButton')->setButtonName(_t('UserDefinedForm.ADDEMAILRECIPIENT', 'Add Email Recipient'));
        $fields->addFieldsToTab("Root.FormOptions", $onCompleteFieldSet);
        $fields->addFieldToTab("Root.FormOptions", $emailRecipients);
        $fields->addFieldsToTab("Root.FormOptions", $this->getFormOptions());
        // view the submissions
        $submissions = new GridField("Reports", _t('UserDefinedForm.SUBMISSIONS', 'Submissions'), $this->Submissions()->sort('Created', 'DESC'));
        // make sure a numeric not a empty string is checked against this int column for SQL server
        $parentID = !empty($this->ID) ? $this->ID : 0;
        // get a list of all field names and values used for print and export CSV views of the GridField below.
        $columnSQL = <<<SQL
SELECT "Name", "Title"
FROM "SubmittedFormField"
LEFT JOIN "SubmittedForm" ON "SubmittedForm"."ID" = "SubmittedFormField"."ParentID"
WHERE "SubmittedForm"."ParentID" = '{$parentID}'
ORDER BY "Title" ASC
SQL;
        $columns = DB::query($columnSQL)->map();
        $config = new GridFieldConfig();
        $config->addComponent(new GridFieldToolbarHeader());
        $config->addComponent($sort = new GridFieldSortableHeader());
        $config->addComponent($filter = new UserFormsGridFieldFilterHeader());
        $config->addComponent(new GridFieldDataColumns());
        $config->addComponent(new GridFieldEditButton());
        $config->addComponent(new GridState_Component());
        $config->addComponent(new GridFieldDeleteAction());
        $config->addComponent(new GridFieldPageCount('toolbar-header-right'));
        $config->addComponent($pagination = new GridFieldPaginator(25));
        $config->addComponent(new GridFieldDetailForm());
        $config->addComponent($export = new GridFieldExportButton());
        $config->addComponent($print = new GridFieldPrintButton());
        $sort->setThrowExceptionOnBadDataType(false);
        $filter->setThrowExceptionOnBadDataType(false);
        $pagination->setThrowExceptionOnBadDataType(false);
        // attach every column to the print view form
        $columns['Created'] = 'Created';
        $filter->setColumns($columns);
        // print configuration
        $print->setPrintHasHeader(true);
        $print->setPrintColumns($columns);
        // export configuration
        $export->setCsvHasHeader(true);
        $export->setExportColumns($columns);
        $submissions->setConfig($config);
        $fields->addFieldToTab("Root.Submissions", $submissions);
        $fields->addFieldToTab("Root.FormOptions", new CheckboxField('DisableSaveSubmissions', _t('UserDefinedForm.SAVESUBMISSIONS', "Disable Saving Submissions to Server")));
        $this->extend('updateCMSFields', $fields);
        return $fields;
    }
 function FlashForm()
 {
     $form = new Form($this->controller, "{$this->name}/FlashForm", new FieldSet(new LiteralField('Heading', sprintf('<h3>%s</h3>', _t('HtmlEditorField.FLASH', 'Flash'))), $contentComposite = new CompositeField(new TreeDropdownField("FolderID", _t('HtmlEditorField.FOLDER'), "Folder"), new TextField('getflashSearch', _t('HtmlEditorField.SEARCHFILENAME', 'Search by file name')), new ThumbnailStripField("Flash", "FolderID", "getflash"), new FieldGroup(_t('HtmlEditorField.IMAGEDIMENSIONS', "Dimensions"), new TextField("Width", _t('HtmlEditorField.IMAGEWIDTHPX', "Width"), 100), new TextField("Height", "x " . _t('HtmlEditorField.IMAGEHEIGHTPX', "Height"), 100)))), new FieldSet(new FormAction("insertflash", _t('HtmlEditorField.BUTTONINSERTFLASH', 'Insert Flash'))));
     $contentComposite->addExtraClass('content');
     $this->extend('updateFlashForm', $form);
     $form->unsetValidator();
     $form->loadDataFrom($this);
     $form->disableSecurityToken();
     return $form;
 }
 /**
  * @param Member $member
  * @return FieldList
  **/
 public function getFields(Member $member = null)
 {
     $fields = parent::getEcommerceFields();
     $fields->push(new HeaderField('BillingDetails', _t('OrderAddress.BILLINGDETAILS', 'Billing Address'), 3));
     $fields->push(new TextField('Phone', _t('OrderAddress.PHONE', 'Phone')));
     $billingFields = new CompositeField();
     $hasPreviousAddresses = false;
     if ($member) {
         if ($member->exists() && !$member->IsShopAdmin()) {
             $this->FillWithLastAddressFromMember($member, true);
             $addresses = $member->previousOrderAddresses($this->baseClassLinkingToOrder(), $this->ID, $onlyLastRecord = false, $keepDoubles = false);
             //we want MORE than one here not just one.
             if ($addresses->count() > 1) {
                 $fields->push(SelectOrderAddressField::create('SelectBillingAddressField', _t('OrderAddress.SELECTBILLINGADDRESS', 'Select Billing Address'), $addresses));
                 $hasPreviousAddresses = true;
             }
         }
     }
     //$billingFields->push(new TextField('MobilePhone', _t('OrderAddress.MOBILEPHONE','Mobile Phone')));
     $mappingArray = $this->Config()->get("fields_to_google_geocode_conversion");
     if (is_array($mappingArray) && count($mappingArray)) {
         if (!class_exists("GoogleAddressField")) {
             user_error("You must install the Sunny Side Up google_address_field module OR remove entries from: BillingAddress.fields_to_google_geocode_conversion");
         }
         $billingFields->push($billingEcommerceGeocodingField = new GoogleAddressField('BillingEcommerceGeocodingField', _t('OrderAddress.FIND_ADDRESS', 'Find address'), Session::get("BillingEcommerceGeocodingFieldValue")));
         $billingEcommerceGeocodingField->setFieldMap($mappingArray);
         //$billingFields->push(new HiddenField('Address2', "NOT SET", "NOT SET"));
         //$billingFields->push(new HiddenField('City', "NOT SET", "NOT SET"));
     }
     //$billingFields->push(new TextField('Prefix', _t('OrderAddress.PREFIX','Title (e.g. Ms)')));
     $billingFields->push(new TextField('Address', _t('OrderAddress.ADDRESS', 'Address')));
     $billingFields->push(new TextField('Address2', _t('OrderAddress.ADDRESS2', '')));
     $billingFields->push(new TextField('City', _t('OrderAddress.CITY', 'Town')));
     $billingFields->push($this->getPostalCodeField("PostalCode"));
     $billingFields->push($this->getRegionField("RegionID", "RegionCode"));
     $billingFields->push($this->getCountryField("Country"));
     $billingFields->addExtraClass('billingFields');
     $billingFields->addExtraClass("orderAddressHolder");
     $this->makeSelectedFieldsReadOnly($billingFields->FieldList());
     $fields->push($billingFields);
     $this->extend('augmentEcommerceBillingAddressFields', $fields);
     return $fields;
 }
 /**
  *
  * @param Controller
  * @param String
  */
 function __construct(Controller $controller, $name)
 {
     //set basics
     $requiredFields = array();
     //requirements
     Requirements::javascript('ecommerce/javascript/EcomOrderFormAddress.js');
     // LEAVE HERE - NOT EASY TO INCLUDE VIA TEMPLATE
     if (EcommerceConfig::get("OrderAddress", "use_separate_shipping_address")) {
         Requirements::javascript('ecommerce/javascript/EcomOrderFormShipping.js');
         // LEAVE HERE - NOT EASY TO INCLUDE VIA TEMPLATE
     }
     //  ________________ 1) Order + Member + Address fields
     //find member
     $this->order = ShoppingCart::current_order();
     $this->orderMember = $this->order->CreateOrReturnExistingMember(false);
     $this->loggedInMember = Member::currentUser();
     //strange security situation...
     if ($this->orderMember->exists() && $this->loggedInMember) {
         if ($this->orderMember->ID != $this->loggedInMember->ID) {
             if (!$this->loggedInMember->IsShopAdmin()) {
                 $this->loggedInMember->logOut();
             }
         }
     }
     $addressFieldsBilling = new FieldList();
     //member fields
     if ($this->orderMember) {
         $memberFields = $this->orderMember->getEcommerceFields();
         $requiredFields = array_merge($requiredFields, $this->orderMember->getEcommerceRequiredFields());
         $addressFieldsBilling->merge($memberFields);
     }
     //billing address field
     $billingAddress = $this->order->CreateOrReturnExistingAddress("BillingAddress");
     $billingAddressFields = $billingAddress->getFields($this->orderMember);
     $requiredFields = array_merge($requiredFields, $billingAddress->getRequiredFields());
     $addressFieldsBilling->merge($billingAddressFields);
     //shipping address field
     $addressFieldsShipping = null;
     if (EcommerceConfig::get("OrderAddress", "use_separate_shipping_address")) {
         $addressFieldsShipping = new FieldList();
         //add the important CHECKBOX
         $useShippingAddressField = new FieldList(new CheckboxField("UseShippingAddress", _t("OrderForm.USESHIPPINGADDRESS", "Use an alternative shipping address")));
         $addressFieldsShipping->merge($useShippingAddressField);
         //now we can add the shipping fields
         $shippingAddress = $this->order->CreateOrReturnExistingAddress("ShippingAddress");
         $shippingAddressFields = $shippingAddress->getFields($this->orderMember);
         //we have left this out for now as it was giving a lot of grief...
         //$requiredFields = array_merge($requiredFields, $shippingAddress->getRequiredFields());
         //finalise left fields
         $addressFieldsShipping->merge($shippingAddressFields);
     }
     $leftFields = new CompositeField($addressFieldsBilling);
     $leftFields->addExtraClass('leftOrderBilling');
     $allLeftFields = new CompositeField($leftFields);
     $allLeftFields->addExtraClass('leftOrder');
     if ($addressFieldsShipping) {
         $leftFieldsShipping = new CompositeField($addressFieldsShipping);
         $leftFieldsShipping->addExtraClass('leftOrderShipping');
         $allLeftFields->push($leftFieldsShipping);
     }
     //  ________________  2) Log in / vs Create Account fields - RIGHT-HAND-SIDE fields
     $rightFields = new CompositeField();
     $rightFields->addExtraClass('rightOrder');
     //to do: simplify
     if (EcommerceConfig::get("EcommerceRole", "allow_customers_to_setup_accounts")) {
         if ($this->orderDoesNotHaveFullyOperationalMember()) {
             //general header
             if (!$this->loggedInMember) {
                 $rightFields->push(new LiteralField('MemberInfo', '<p class="message good">' . _t('OrderForm.MEMBERINFO', 'If you already have an account then please') . " <a href=\"Security/login/?BackURL=/" . urlencode(implode("/", $controller->getURLParams())) . "\">" . _t('OrderForm.LOGIN', 'log in') . '</a>.</p>'));
             }
         } else {
             if ($this->loggedInMember) {
                 $rightFields->push(new LiteralField('LoginNote', "<p class=\"message good\">" . _t("Account.LOGGEDIN", "You are logged in as ") . Convert::raw2xml($this->loggedInMember->FirstName) . ' ' . Convert::raw2xml($this->loggedInMember->Surname) . ' (' . Convert::raw2xml($this->loggedInMember->Email) . ').' . ' <a href="/Security/logout/">' . _t("Account.LOGOUTNOW", "Log out?") . '</a>' . '</p>'));
             }
         }
         if ($this->orderMember->exists()) {
             if ($this->loggedInMember) {
                 if ($this->loggedInMember->ID != $this->orderMember->ID) {
                     $rightFields->push(new LiteralField('OrderAddedTo', "<p class=\"message good\">" . _t("Account.ORDERADDEDTO", "Order will be added to ") . Convert::raw2xml($this->orderMember->FirstName) . ' ' . Convert::raw2xml($this->orderMember->Surname) . ' (' . Convert::raw2xml($this->orderMember->Email) . ').</p>'));
                 }
             }
         }
     }
     //  ________________  5) Put all the fields in one FieldList
     $fields = new FieldList($rightFields, $allLeftFields);
     //  ________________  6) Actions and required fields creation + Final Form construction
     $nextButton = new FormAction('saveAddress', _t('OrderForm.NEXT', 'Next'));
     $nextButton->addExtraClass("next");
     $actions = new FieldList($nextButton);
     $validator = OrderFormAddress_Validator::create($requiredFields);
     parent::__construct($controller, $name, $fields, $actions, $validator);
     $this->setAttribute("autocomplete", "off");
     //extensions need to be set after __construct
     //extension point
     $this->extend('updateFields', $fields);
     $this->setFields($fields);
     $this->extend('updateActions', $actions);
     $this->setActions($actions);
     $this->extend('updateValidator', $validator);
     $this->setValidator($validator);
     //this needs to come after the extension calls
     foreach ($validator->getRequired() as $requiredField) {
         $field = $fields->dataFieldByName($requiredField);
         if ($field) {
             $field->addExtraClass("required");
         }
     }
     //  ________________  7)  Load saved data
     //we do this first so that Billing and Shipping Address can override this...
     if ($this->orderMember) {
         $this->loadDataFrom($this->orderMember);
     }
     if ($this->order) {
         $this->loadDataFrom($this->order);
         if ($billingAddress) {
             $this->loadDataFrom($billingAddress);
         }
         if (EcommerceConfig::get("OrderAddress", "use_separate_shipping_address")) {
             if ($shippingAddress) {
                 $this->loadDataFrom($shippingAddress);
             }
         }
     }
     //allow updating via decoration
     $oldData = Session::get("FormInfo.{$this->FormName()}.data");
     if ($oldData && (is_array($oldData) || is_object($oldData))) {
         $this->loadDataFrom($oldData);
     }
     $this->extend('updateOrderFormAddress', $this);
 }
 /**
  * Builds a Form that mirrors the parent editForm, but with an extra field to collect the ChangeSet ID
  *
  * @param DataObject $object The object we're going to be adding to whichever ChangeSet is chosen
  * @return Form
  */
 public function Form($object)
 {
     $inChangeSets = array_unique(ChangeSetItem::get_for_object($object)->column('ChangeSetID'));
     $changeSets = $this->getAvailableChangeSets()->map();
     $campaignDropdown = DropdownField::create('Campaign', '', $changeSets);
     $campaignDropdown->setEmptyString(_t('Campaigns.AddToCampaign', 'Select a Campaign'));
     $campaignDropdown->addExtraClass('noborder');
     $campaignDropdown->setDisabledItems($inChangeSets);
     $fields = new FieldList([$campaignDropdown, HiddenField::create('ID', null, $this->data['ID']), HiddenField::create('ClassName', null, $this->data['ClassName'])]);
     $form = new Form($this->editForm->getController(), $this->editForm->getName(), new FieldList($header = new CompositeField(new LiteralField('Heading', sprintf('<h3>%s</h3>', _t('Campaigns.AddToCampaign', 'Add To Campaign')))), $content = new CompositeField($fields)), new FieldList($action = AddToCampaignHandler_FormAction::create()));
     $header->addExtraClass('add-to-campaign__header');
     $content->addExtraClass('add-to-campaign__content');
     $action->addExtraClass('add-to-campaign__action');
     $form->setHTMLID('Form_EditForm_AddToCampaign');
     $form->unsetValidator();
     $form->loadDataFrom($this->data);
     $form->addExtraClass('add-to-campaign__form');
     return $form;
 }
예제 #25
0
	/**
	 * Return a {@link Form} instance allowing a user to
	 * add images and flash objects to the TinyMCE content editor.
	 *  
	 * @return Form
	 */
	function MediaForm() {
		// TODO Handle through GridState within field - currently this state set too late to be useful here (during request handling)
		$parentID = $this->controller->getRequest()->requestVar('ParentID');

		$fileFieldConfig = GridFieldConfig::create();
		$fileFieldConfig->addComponent(new GridFieldSortableHeader());
		$fileFieldConfig->addComponent(new GridFieldFilterHeader());
		$fileFieldConfig->addComponent(new GridFieldDataColumns());
		$fileFieldConfig->addComponent(new GridFieldPaginator(5));
		$fileField = new GridField('Files', false, null, $fileFieldConfig);
		$fileField->setList($this->getFiles($parentID));
		$fileField->setAttribute('data-selectable', true);
		$fileField->setAttribute('data-multiselect', true);
		$columns = $fileField->getConfig()->getComponentByType('GridFieldDataColumns');
		$columns->setDisplayFields(array(
			'CMSThumbnail' => false,
			'Name' => _t('File.Name'),
		));
		
		$numericLabelTmpl = '<span class="step-label"><span class="flyout">%d</span><span class="arrow"></span><strong class="title">%s</strong></span>';

		$fromCMS = new CompositeField(
			new LiteralField('headerSelect', '<h4 class="field header-select">' . sprintf($numericLabelTmpl, '1', _t('HtmlEditorField.Find', 'Find')) . '</h4>'),
				$selectComposite = new CompositeField(
					new TreeDropdownField('ParentID', _t('HtmlEditorField.FOLDER', 'Folder'), 'Folder'),
					$fileField
				)
		);

		$fromCMS->addExtraClass('content');
		$selectComposite->addExtraClass('content-select');

		Requirements::css(FRAMEWORK_DIR . '/css/AssetUploadField.css');
		$computerUploadField = Object::create('UploadField', 'AssetUploadField', '');
		$computerUploadField->setConfig('previewMaxWidth', 40);
		$computerUploadField->setConfig('previewMaxHeight', 30);
		$computerUploadField->addExtraClass('ss-assetuploadfield');
		$computerUploadField->removeExtraClass('ss-uploadfield');
		$computerUploadField->setTemplate('HtmlEditorField_UploadField');
		$computerUploadField->setFolderName(Upload::$uploads_folder);

		$tabSet = new TabSet(
			"MediaFormInsertImageTabs",
			new Tab(
				_t('HtmlEditorField.FROMCOMPUTER','From your computer'),
				$computerUploadField
			),
			new Tab(
				_t('HtmlEditorField.FROMCMS','From the CMS'),
				$fromCMS
			)
		);

		$allFields = new CompositeField(
			$tabSet,
			new LiteralField('headerEdit', '<h4 class="field header-edit">' . sprintf($numericLabelTmpl, '2', _t('HtmlEditorField.EditDetails', 'Edit details')) . '</h4>'),
			$editComposite = new CompositeField(
				new LiteralField('contentEdit', '<div class="content-edit"></div>')
			)
		);

		$fields = new FieldList(
			new LiteralField(
				'Heading',
				sprintf('<h3 class="htmleditorfield-mediaform-heading insert">%s</h3>', _t('HtmlEditorField.INSERTIMAGE', 'Insert Image')).
				sprintf('<h3 class="htmleditorfield-mediaform-heading update">%s</h3>', _t('HtmlEditorField.UpdateIMAGE', 'Update Image'))
			),
			$allFields
		);
		
		$actions = new FieldList(
			FormAction::create('insertimage', _t('HtmlEditorField.BUTTONINSERT', 'Insert'))
				->addExtraClass('ss-ui-action-constructive image-insert')
				->setAttribute('data-icon', 'accept')
				->setUseButtonTag(true),
			FormAction::create('insertimage', _t('HtmlEditorField.BUTTONUpdate', 'Update'))
				->addExtraClass('ss-ui-action-constructive image-update')
				->setAttribute('data-icon', 'accept')
				->setUseButtonTag(true)
		);

		$form = new Form(
			$this->controller,
			"{$this->name}/MediaForm",
			$fields,
			$actions
		);
		

		$form->unsetValidator();
		$form->disableSecurityToken();
		$form->loadDataFrom($this);
		$form->addExtraClass('htmleditorfield-form htmleditorfield-mediaform cms-dialog-content');
		// TODO Re-enable once we remove $.metadata dependency which currently breaks the JS due to $.ui.widget
		// $form->setAttribute('data-urlViewfile', $this->controller->Link($this->name));

		// Allow other people to extend the fields being added to the imageform 
		$this->extend('updateMediaForm', $form);
		
		return $form;
	}
예제 #26
0
 /**
  * Return a {@link Form} instance allowing a user to
  * add images and flash objects to the TinyMCE content editor.
  *  
  * @return Form
  */
 public function MediaForm()
 {
     // TODO Handle through GridState within field - currently this state set too late to be useful here (during
     // request handling)
     $parentID = $this->getAttachParentID();
     $fileFieldConfig = GridFieldConfig::create()->addComponents(new GridFieldFilterHeader(), new GridFieldSortableHeader(), new GridFieldDataColumns(), new GridFieldPaginator(5), new GridFieldDeleteAction(), new GridFieldDetailForm());
     $fileField = new GridField('Files', false, null, $fileFieldConfig);
     $fileField->setList($this->getFiles($parentID));
     $fileField->setAttribute('data-selectable', true);
     $fileField->setAttribute('data-multiselect', true);
     $columns = $fileField->getConfig()->getComponentByType('GridFieldDataColumns');
     $columns->setDisplayFields(array('CMSThumbnail' => false, 'Name' => _t('File.Name')));
     $numericLabelTmpl = '<span class="step-label"><span class="flyout">%d</span><span class="arrow"></span>' . '<strong class="title">%s</strong></span>';
     $fromCMS = new CompositeField(new LiteralField('headerSelect', '<h4>' . sprintf($numericLabelTmpl, '1', _t('HtmlEditorField.FindInFolder', 'Find in Folder')) . '</h4>'), $select = TreeDropdownField::create('ParentID', "", 'Folder')->addExtraClass('noborder')->setValue($parentID), $fileField);
     $fromCMS->addExtraClass('content ss-uploadfield');
     $select->addExtraClass('content-select');
     $fromWeb = new CompositeField(new LiteralField('headerURL', '<h4>' . sprintf($numericLabelTmpl, '1', _t('HtmlEditorField.ADDURL', 'Add URL')) . '</h4>'), $remoteURL = new TextField('RemoteURL', 'http://'), new LiteralField('addURLImage', '<button class="action ui-action-constructive ui-button field add-url" data-icon="addMedia">' . _t('HtmlEditorField.BUTTONADDURL', 'Add url') . '</button>'));
     $remoteURL->addExtraClass('remoteurl');
     $fromWeb->addExtraClass('content ss-uploadfield');
     Requirements::css(FRAMEWORK_DIR . '/css/AssetUploadField.css');
     $computerUploadField = Object::create('UploadField', 'AssetUploadField', '');
     $computerUploadField->setConfig('previewMaxWidth', 40);
     $computerUploadField->setConfig('previewMaxHeight', 30);
     $computerUploadField->addExtraClass('ss-assetuploadfield');
     $computerUploadField->removeExtraClass('ss-uploadfield');
     $computerUploadField->setTemplate('HtmlEditorField_UploadField');
     $computerUploadField->setFolderName(Config::inst()->get('Upload', 'uploads_folder'));
     $tabSet = new TabSet("MediaFormInsertMediaTabs", Tab::create('FromComputer', _t('HtmlEditorField.FROMCOMPUTER', 'From your computer'), $computerUploadField)->addExtraClass('htmleditorfield-from-computer'), Tab::create('FromWeb', _t('HtmlEditorField.FROMWEB', 'From the web'), $fromWeb)->addExtraClass('htmleditorfield-from-web'), Tab::create('FromCms', _t('HtmlEditorField.FROMCMS', 'From the CMS'), $fromCMS)->addExtraClass('htmleditorfield-from-cms'));
     $tabSet->addExtraClass('cms-tabset-primary');
     $allFields = new CompositeField($tabSet, new LiteralField('headerEdit', '<h4 class="field noborder header-edit">' . sprintf($numericLabelTmpl, '2', _t('HtmlEditorField.ADJUSTDETAILSDIMENSIONS', 'Details &amp; dimensions')) . '</h4>'), $editComposite = new CompositeField(new LiteralField('contentEdit', '<div class="content-edit ss-uploadfield-files files"></div>')));
     $allFields->addExtraClass('ss-insert-media');
     $headings = new CompositeField(new LiteralField('Heading', sprintf('<h3 class="htmleditorfield-mediaform-heading insert">%s</h3>', _t('HtmlEditorField.INSERTMEDIA', 'Insert Media')) . sprintf('<h3 class="htmleditorfield-mediaform-heading update">%s</h3>', _t('HtmlEditorField.UpdateMEDIA', 'Update Media'))));
     $headings->addExtraClass('cms-content-header');
     $editComposite->addExtraClass('ss-assetuploadfield');
     $fields = new FieldList($headings, $allFields);
     $actions = new FieldList(FormAction::create('insertmedia', _t('HtmlEditorField.BUTTONINSERT', 'Insert'))->addExtraClass('ss-ui-action-constructive media-insert')->setAttribute('data-icon', 'accept')->setUseButtonTag(true), FormAction::create('insertmedia', _t('HtmlEditorField.BUTTONUpdate', 'Update'))->addExtraClass('ss-ui-action-constructive media-update')->setAttribute('data-icon', 'accept')->setUseButtonTag(true));
     $form = new Form($this->controller, "{$this->name}/MediaForm", $fields, $actions);
     $form->unsetValidator();
     $form->disableSecurityToken();
     $form->loadDataFrom($this);
     $form->addExtraClass('htmleditorfield-form htmleditorfield-mediaform cms-dialog-content');
     // TODO Re-enable once we remove $.metadata dependency which currently breaks the JS due to $.ui.widget
     // $form->setAttribute('data-urlViewfile', $this->controller->Link($this->name));
     // Allow other people to extend the fields being added to the imageform
     $this->extend('updateMediaForm', $form);
     return $form;
 }
 /**
  * Give the flexibilility to show variouse combination of columns in the search result table
  */
 public function ColumnSelectionField()
 {
     $model = singleton($this->modelClass);
     $source = $this->columnsAvailable();
     // select all fields by default
     $value = $this->columnsSelectedByDefault();
     // Reorder the source so that you read items down the column and then across
     $columnisedSource = array();
     $keys = array_keys($source);
     $midPoint = ceil(sizeof($source) / 2);
     for ($i = 0; $i < $midPoint; $i++) {
         $key1 = $keys[$i];
         $columnisedSource[$key1] = $model->fieldLabel($source[$key1]);
         // If there are an odd number of items, the last item will be unset
         if (isset($keys[$i + $midPoint])) {
             $key2 = $keys[$i + $midPoint];
             $columnisedSource[$key2] = $model->fieldLabel($source[$key2]);
         }
     }
     $checkboxes = new CheckboxSetField("ResultAssembly", false, $columnisedSource, $value);
     $field = new CompositeField(new LiteralField("ToggleResultAssemblyLink", sprintf("<a class=\"form_frontend_function toggle_result_assembly\" href=\"#\">%s</a>", _t('ModelAdmin.CHOOSE_COLUMNS', 'Select result columns...'))), $checkboxesBlock = new CompositeField($checkboxes, new LiteralField("ClearDiv", "<div class=\"clear\"></div>"), new LiteralField("TickAllAssemblyLink", sprintf("<a class=\"form_frontend_function tick_all_result_assembly\" href=\"#\">%s</a>", _t('ModelAdmin.SELECTALL', 'select all'))), new LiteralField("UntickAllAssemblyLink", sprintf("<a class=\"form_frontend_function untick_all_result_assembly\" href=\"#\">%s</a>", _t('ModelAdmin.SELECTNONE', 'select none')))));
     $field->addExtraClass("ResultAssemblyBlock");
     $checkboxesBlock->addExtraClass("hidden");
     return $field;
 }
예제 #28
0
 protected function duplicateOrReplaceFields(&$fields)
 {
     $tasks = array('dup' => array());
     foreach ($fields as $field) {
         if ($field->isComposite()) {
             $innertasks = $this->duplicateOrReplaceFields($field->FieldSet());
             $tasks['dup'] = array_merge($tasks['dup'], $innertasks['dup']);
         } else {
             if (($fieldname = $field->Name()) && array_key_exists($fieldname, $this->original_values)) {
                 // Get a copy of the original field to show the untranslated value
                 if (is_subclass_of($field->class, 'TextareaField')) {
                     $nonEditableField = new ToggleField($fieldname, $field->Title(), '', '+', '-');
                     $nonEditableField->labelMore = '+';
                     $nonEditableField->labelLess = '-';
                 } else {
                     $nonEditableField = $field->performDisabledTransformation();
                 }
                 $nonEditableField_holder = new CompositeField($nonEditableField);
                 $nonEditableField_holder->setName($fieldname . '_holder');
                 $nonEditableField_holder->addExtraClass('originallang_holder');
                 $nonEditableField->setValue($this->original_values[$fieldname]);
                 $nonEditableField->setName($fieldname . '_original');
                 $nonEditableField->addExtraClass('originallang');
                 if (array_search($fieldname, $this->translatableFields) !== false) {
                     // Duplicate the field
                     if ($field->Title()) {
                         $nonEditableField->setTitle('Original');
                     }
                     $nonEditableField_holder->insertBeforeRecursive($field, $fieldname . '_original');
                     $tasks['dup'][$fieldname] = $nonEditableField_holder;
                 }
             }
         }
     }
     return $tasks;
 }
 /**
  * Return a {@link Form} instance allowing a user to
  * add images and flash objects to the TinyMCE content editor.
  *
  * @return Form
  */
 public function MediaForm()
 {
     // TODO Handle through GridState within field - currently this state set too late to be useful here (during
     // request handling)
     $parentID = $this->getAttachParentID();
     $fileFieldConfig = GridFieldConfig::create()->addComponents(new GridFieldFilterHeader(), new GridFieldSortableHeader(), new GridFieldDataColumns(), new GridFieldPaginator(7), new GridFieldDeleteAction(), new GridFieldDetailForm());
     $fileField = GridField::create('Files', false, null, $fileFieldConfig);
     $fileField->setList($this->getFiles($parentID));
     $fileField->setAttribute('data-selectable', true);
     $fileField->setAttribute('data-multiselect', true);
     $columns = $fileField->getConfig()->getComponentByType('GridFieldDataColumns');
     $columns->setDisplayFields(array('StripThumbnail' => false, 'Title' => _t('File.Title'), 'Created' => singleton('File')->fieldLabel('Created')));
     $columns->setFieldCasting(array('Created' => 'SS_Datetime->Nice'));
     $fromCMS = new CompositeField($select = TreeDropdownField::create('ParentID', "", 'Folder')->addExtraClass('noborder')->setValue($parentID), $fileField);
     $fromCMS->addExtraClass('content ss-uploadfield htmleditorfield-from-cms');
     $select->addExtraClass('content-select');
     $URLDescription = _t('HtmlEditorField.URLDESCRIPTION', 'Insert videos and images from the web into your page simply by entering the URL of the file. Make sure you have the rights or permissions before sharing media directly from the web.<br /><br />Please note that files are not added to the file store of the CMS but embeds the file from its original location, if for some reason the file is no longer available in its original location it will no longer be viewable on this page.');
     $fromWeb = new CompositeField($description = new LiteralField('URLDescription', '<div class="url-description">' . $URLDescription . '</div>'), $remoteURL = new TextField('RemoteURL', 'http://'), new LiteralField('addURLImage', '<button type="button" class="action ui-action-constructive ui-button field font-icon-plus add-url">' . _t('HtmlEditorField.BUTTONADDURL', 'Add url') . '</button>'));
     $remoteURL->addExtraClass('remoteurl');
     $fromWeb->addExtraClass('content ss-uploadfield htmleditorfield-from-web');
     Requirements::css(FRAMEWORK_DIR . '/css/AssetUploadField.css');
     $computerUploadField = Object::create('UploadField', 'AssetUploadField', '');
     $computerUploadField->setConfig('previewMaxWidth', 40);
     $computerUploadField->setConfig('previewMaxHeight', 30);
     $computerUploadField->addExtraClass('ss-assetuploadfield htmleditorfield-from-computer');
     $computerUploadField->removeExtraClass('ss-uploadfield');
     $computerUploadField->setTemplate('HtmlEditorField_UploadField');
     $computerUploadField->setFolderName(Config::inst()->get('Upload', 'uploads_folder'));
     $defaultPanel = new CompositeField($computerUploadField, $fromCMS);
     $fromWebPanel = new CompositeField($fromWeb);
     $defaultPanel->addExtraClass('htmleditorfield-default-panel');
     $fromWebPanel->addExtraClass('htmleditorfield-web-panel');
     $allFields = new CompositeField($defaultPanel, $fromWebPanel, $editComposite = new CompositeField(new LiteralField('contentEdit', '<div class="content-edit ss-uploadfield-files files"></div>')));
     $allFields->addExtraClass('ss-insert-media');
     $headings = new CompositeField(new LiteralField('Heading', sprintf('<h3 class="htmleditorfield-mediaform-heading insert">%s</h3>', _t('HtmlEditorField.INSERTMEDIA', 'Insert media from')) . sprintf('<h3 class="htmleditorfield-mediaform-heading update">%s</h3>', _t('HtmlEditorField.UpdateMEDIA', 'Update media'))));
     $headings->addExtraClass('cms-content-header');
     $editComposite->addExtraClass('ss-assetuploadfield');
     $fields = new FieldList($headings, $allFields);
     $form = new Form($this->controller, "{$this->name}/MediaForm", $fields, new FieldList());
     $form->unsetValidator();
     $form->disableSecurityToken();
     $form->loadDataFrom($this);
     $form->addExtraClass('htmleditorfield-form htmleditorfield-mediaform cms-dialog-content');
     // TODO Re-enable once we remove $.metadata dependency which currently breaks the JS due to $.ui.widget
     // $form->setAttribute('data-urlViewfile', $this->controller->Link($this->name));
     // Allow other people to extend the fields being added to the imageform
     $this->extend('updateMediaForm', $form);
     return $form;
 }
    /**
     * @return FieldList
     */
    public function getCMSFields()
    {
        $self = $this;
        $this->beforeUpdateCMSFields(function ($fields) use($self) {
            // define tabs
            $fields->findOrMakeTab('Root.FormContent', _t('UserDefinedForm.FORM', 'Form'));
            $fields->findOrMakeTab('Root.FormOptions', _t('UserDefinedForm.CONFIGURATION', 'Configuration'));
            $fields->findOrMakeTab('Root.Recipients', _t('UserDefinedForm.RECIPIENTS', 'Recipients'));
            $fields->findOrMakeTab('Root.Submissions', _t('UserDefinedForm.SUBMISSIONS', 'Submissions'));
            // field editor
            $fields->addFieldToTab('Root.FormContent', new FieldEditor('Fields', 'Fields', '', $self));
            // text to show on complete
            $onCompleteFieldSet = new CompositeField($label = new LabelField('OnCompleteMessageLabel', _t('UserDefinedForm.ONCOMPLETELABEL', 'Show on completion')), $editor = new HtmlEditorField('OnCompleteMessage', '', _t('UserDefinedForm.ONCOMPLETEMESSAGE', $self->OnCompleteMessage)));
            $onCompleteFieldSet->addExtraClass('field');
            $editor->setRows(3);
            $label->addExtraClass('left');
            // Define config for email recipients
            $emailRecipientsConfig = GridFieldConfig_RecordEditor::create(10);
            $emailRecipientsConfig->getComponentByType('GridFieldAddNewButton')->setButtonName(_t('UserDefinedForm.ADDEMAILRECIPIENT', 'Add Email Recipient'));
            // who do we email on submission
            $emailRecipients = new GridField('EmailRecipients', _t('UserDefinedForm.EMAILRECIPIENTS', 'Email Recipients'), $self->EmailRecipients(), $emailRecipientsConfig);
            $emailRecipients->getConfig()->getComponentByType('GridFieldDetailForm')->setItemRequestClass('UserDefinedForm_EmailRecipient_ItemRequest');
            $fields->addFieldsToTab('Root.FormOptions', $onCompleteFieldSet);
            $fields->addFieldToTab('Root.Recipients', $emailRecipients);
            $fields->addFieldsToTab('Root.FormOptions', $self->getFormOptions());
            // view the submissions
            $submissions = new GridField('Submissions', _t('UserDefinedForm.SUBMISSIONS', 'Submissions'), $self->Submissions()->sort('Created', 'DESC'));
            // make sure a numeric not a empty string is checked against this int column for SQL server
            $parentID = !empty($self->ID) ? $self->ID : 0;
            // get a list of all field names and values used for print and export CSV views of the GridField below.
            $columnSQL = <<<SQL
SELECT "Name", "Title"
FROM "SubmittedFormField"
LEFT JOIN "SubmittedForm" ON "SubmittedForm"."ID" = "SubmittedFormField"."ParentID"
WHERE "SubmittedForm"."ParentID" = '{$parentID}'
ORDER BY "Title" ASC
SQL;
            $columns = DB::query($columnSQL)->map();
            $config = new GridFieldConfig();
            $config->addComponent(new GridFieldToolbarHeader());
            $config->addComponent($sort = new GridFieldSortableHeader());
            $config->addComponent($filter = new UserFormsGridFieldFilterHeader());
            $config->addComponent(new GridFieldDataColumns());
            $config->addComponent(new GridFieldEditButton());
            $config->addComponent(new GridState_Component());
            $config->addComponent(new GridFieldDeleteAction());
            $config->addComponent(new GridFieldPageCount('toolbar-header-right'));
            $config->addComponent($pagination = new GridFieldPaginator(25));
            $config->addComponent(new GridFieldDetailForm());
            $config->addComponent($export = new GridFieldExportButton());
            $config->addComponent($print = new GridFieldPrintButton());
            /**
             * Support for {@link https://github.com/colymba/GridFieldBulkEditingTools}
             */
            if (class_exists('GridFieldBulkManager')) {
                $config->addComponent(new GridFieldBulkManager());
            }
            $sort->setThrowExceptionOnBadDataType(false);
            $filter->setThrowExceptionOnBadDataType(false);
            $pagination->setThrowExceptionOnBadDataType(false);
            // attach every column to the print view form
            $columns['Created'] = 'Created';
            $filter->setColumns($columns);
            // print configuration
            $print->setPrintHasHeader(true);
            $print->setPrintColumns($columns);
            // export configuration
            $export->setCsvHasHeader(true);
            $export->setExportColumns($columns);
            $submissions->setConfig($config);
            $fields->addFieldToTab('Root.Submissions', $submissions);
            $fields->addFieldToTab('Root.FormOptions', new CheckboxField('DisableSaveSubmissions', _t('UserDefinedForm.SAVESUBMISSIONS', 'Disable Saving Submissions to Server')));
        });
        $fields = parent::getCMSFields();
        return $fields;
    }