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;
    }
 public function UpdateCMSFields(FieldList $fields)
 {
     if ($this->IsInSocialMedia()) {
         $fields->addFieldToTab('Root.Main', $text = new CompositeField(), 'Content');
         $text->setDescription('Tämä blogiartikkeli on julkaistu sosiaalisessa mediassa. Muutokset blogiin eivät enää päivity sosiaaliseen mediaan. Jos poistat blogin, se ei poistu somesta automaattisesti.');
     } else {
         $fields->addFieldToTab('Root.Main', $checkbox = new CheckboxField('PublishInSocialMedia', 'Julkaise sosiaalisessa mediassa'), 'Content');
         $checkbox->setDescription('Julkaisu tapahtuu kun klikkaat "Tallenna ja julkaise". Jos teet muutoksia sisältöön ensimmäisen some-julkaisun jälkeen, muutokset päivittyvät ainoastaan blogiin, eivätkä mene someen. Jos poistat artikkelin, se täytyy käydä erikseen poistamassa somessa.');
     }
 }
 public function testLegend()
 {
     $composite = new CompositeField(new TextField('A'), new TextField('B'));
     $composite->setTag('fieldset');
     $composite->setLegend('My legend');
     $parser = new CSSContentParser($composite->Field());
     $root = $parser->getBySelector('fieldset.composite');
     $legend = $parser->getBySelector('fieldset.composite legend');
     $this->assertNotNull($legend);
     $this->assertEquals('My legend', (string) $legend[0]);
 }
Exemplo n.º 4
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;
 }
Exemplo n.º 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;
 }
 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;
 }
 function testFieldPosition()
 {
     $compositeOuter = new CompositeField(new TextField('A'), new TextField('B'), $compositeInner = new CompositeField(new TextField('C1'), new TextField('C2')), new TextField('D'));
     $this->assertEquals(0, $compositeOuter->fieldPosition('A'));
     $this->assertEquals(1, $compositeOuter->fieldPosition('B'));
     $this->assertEquals(3, $compositeOuter->fieldPosition('D'));
     $this->assertEquals(0, $compositeInner->fieldPosition('C1'));
     $this->assertEquals(1, $compositeInner->fieldPosition('C2'));
     $compositeOuter->insertBefore(new TextField('AB'), 'B');
     $this->assertEquals(0, $compositeOuter->fieldPosition('A'));
     $this->assertEquals(1, $compositeOuter->fieldPosition('AB'));
     $this->assertEquals(2, $compositeOuter->fieldPosition('B'));
 }
 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);
 }
 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 getColumnContent($gridField, $record, $columnName)
 {
     if (!$record->canEdit()) {
         return;
     }
     $field = new CompositeField();
     if (!$record instanceof ElementVirtualLinked) {
         $field->push(GridField_FormAction::create($gridField, 'UnlinkRelation' . $record->ID, false, "unlinkrelation", array('RecordID' => $record->ID))->addExtraClass('gridfield-button-unlink')->setAttribute('title', _t('GridAction.UnlinkRelation', "Unlink"))->setAttribute('data-icon', 'chain--minus'));
     }
     if ($record->canDelete() && $record->VirtualClones()->count() == 0) {
         $field->push(GridField_FormAction::create($gridField, 'DeleteRecord' . $record->ID, false, "deleterecord", array('RecordID' => $record->ID))->addExtraClass('gridfield-button-delete')->setAttribute('title', _t('GridAction.Delete', "Delete"))->setAttribute('data-icon', 'cross-circle')->setDescription(_t('GridAction.DELETE_DESCRIPTION', 'Delete')));
     }
     return $field->Field();
 }
Exemplo n.º 11
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;
    }
Exemplo n.º 13
0
 /**
  * getCMSFields
  * Construct the FieldList used in the CMS. To provide a
  * smarter UI we don't use the scaffolding provided by
  * parent::getCMSFields.
  * 
  * @return FieldList
  */
 public function getCMSFields()
 {
     Requirements::css('torindul-silverstripe-shop/css/LeftAndMain.css');
     //Create the FieldList and push the Root TabSet on to it.
     $fields = FieldList::create($root = TabSet::create('Root', Tab::create("Main", HeaderField::create($this->SystemName), CompositeField::create(TextField::create("Title", "Friendly Name")->setRightTitle("This is the name your customers would see against this courier."), DropdownField::create("Enabled", "Enable this courier?", array("0" => "No", "1" => "Yes"))->setEmptyString("(Select one)")->setRightTitle("Can customers use this courier?")))));
     return $fields;
 }
 public function getCMSFields()
 {
     $fields = new FieldList();
     $fields->push(new TabSet("Root", new Tab("Main", TextField::create("Title", "Title"), GridField::create("Slides", "Nivo Slide", $this->Slides(), GridFieldConfig_RecordEditor::create())), new Tab("Advanced", DropdownField::create("Theme", "Theme", self::get_all_themes()), DropdownField::create("Effect", "Effect", $this->dbObject("Effect")->enumValues()), NumericField::create("AnimationSpeed", "Animation Speed")->setDescription("Animation speed in milliseconds."), NumericField::create("PauseTime", "Pause Time")->setDescription("Pause time on each frame in milliseconds."), TextField::create("PrevText", "Previous Text"), TextField::create("NextText", "Next Text"), NumericField::create("Slices", "Slices")->setDescription("Number of slices for slice animation effects."), NumericField::create("BoxCols", "Box Columns")->setDescription("Number of box columns for box animation effects."), NumericField::create("BoxRows", "Box Rows")->setDescription("Number of box rows for box animation effects."), NumericField::create("StartSlide", "Start Slide")->setDescription("Slide to start on (0 being the first)."), HeaderField::create("ControlHeading", "Control Options", 4), CompositeField::create(array(CheckboxField::create("DirectionNav", "Display Direction Navigation?"), CheckboxField::create("ControlNav", "Display Control Navigation?"), CheckboxField::create("ControlNavThumbs", "Use thumbnails for control nav?"), CheckboxField::create("PauseOnHover", "Stop the animation whilst hovering?"), CheckboxField::create("ManualAdvance", "Force manual transition?"), CheckboxField::create("RandomStart", "Random Start?"))))));
     $fields->extend("updateCMSFields", $fields);
     return $fields;
 }
 /**
  * getCMSFields
  * Construct the FieldList used in the CMS. To provide a
  * smarter UI we don't use the scaffolding provided by
  * parent::getCMSFields.
  * 
  * @return FieldList
  */
 public function getCMSFields()
 {
     Requirements::css('torindul-silverstripe-shop/css/LeftAndMain.css');
     //Create the FieldList and push the Root TabSet on to it.
     $fields = FieldList::create($root = TabSet::create('Root', Tab::create("Main", HeaderField::create("Add/Edit Order Status"), CompositeField::create(TextField::create("Title", "Friendly Name")->setRightTitle("The name of your custom order status. i.e. Pending, Awaiting Stock."), TextareaField::create("Content", "Friendly Description")->setRightTitle("This will be shown to your customers. What do you wish to tell them about this status?")))));
     return $fields;
 }
 public function __construct($controller, $name = "PostagePaymentForm")
 {
     // Get delivery data and postage areas from session
     $delivery_data = Session::get("Commerce.DeliveryDetailsForm.data");
     $country = $delivery_data['DeliveryCountry'];
     $postcode = $delivery_data['DeliveryPostCode'];
     $postage_areas = $controller->getPostageAreas($country, $postcode);
     // Loop through all postage areas and generate a new list
     $postage_array = array();
     foreach ($postage_areas as $area) {
         $area_currency = new Currency("Cost");
         $area_currency->setValue($area->Cost);
         $postage_array[$area->ID] = $area->Title . " (" . $area_currency->Nice() . ")";
     }
     $postage_id = Session::get('Commerce.PostageID') ? Session::get('Commerce.PostageID') : 0;
     // Setup postage fields
     $postage_field = CompositeField::create(HeaderField::create("PostageHeader", _t('Commerce.Postage', "Postage")), OptionsetField::create("PostageID", _t('Commerce.PostageSelection', 'Please select your prefered postage'), $postage_array)->setValue($postage_id))->setName("PostageFields")->addExtraClass("unit")->addExtraClass("size1of2")->addExtraClass("unit-50");
     // Get available payment methods and setup payment
     $payment_methods = SiteConfig::current_site_config()->PaymentMethods();
     // Deal with payment methods
     if ($payment_methods->exists()) {
         $payment_map = $payment_methods->map('ID', 'Label');
         $payment_value = $payment_methods->filter('Default', 1)->first()->ID;
     } else {
         $payment_map = array();
         $payment_value = 0;
     }
     $payment_field = CompositeField::create(HeaderField::create('PaymentHeading', _t('Commerce.Payment', 'Payment'), 2), OptionsetField::create('PaymentMethodID', _t('Commerce.PaymentSelection', 'Please choose how you would like to pay'), $payment_map, $payment_value))->setName("PaymentFields")->addExtraClass("unit")->addExtraClass("size1of2")->addExtraClass("unit-50");
     $fields = FieldList::create(CompositeField::create($postage_field, $payment_field)->setName("PostagePaymentFields")->addExtraClass("units-row")->addExtraClass("line"));
     $back_url = $controller->Link("billing");
     $actions = FieldList::create(LiteralField::create('BackButton', '<a href="' . $back_url . '" class="btn btn-red commerce-action-back">' . _t('Commerce.Back', 'Back') . '</a>'), FormAction::create('doContinue', _t('Commerce.PaymentDetails', 'Enter Payment Details'))->addExtraClass('btn')->addExtraClass('commerce-action-next')->addExtraClass('btn-green'));
     $validator = RequiredFields::create(array("PostageID", "PaymentMethod"));
     parent::__construct($controller, $name, $fields, $actions, $validator);
 }
	function fieldByName($name) {
		if ($name == $this->Name()) {
			return $this;
		} else {
			return parent::fieldByName($name);
		}
	}
Exemplo n.º 18
0
 /**
  * getCMSFields
  * Construct the FieldList used in the CMS. To provide a
  * smarter UI we don't use the scaffolding provided by
  * parent::getCMSFields.
  * 
  * @return FieldList
  */
 public function getCMSFields()
 {
     Requirements::css('torindul-silverstripe-shop/css/LeftAndMain.css');
     //Create the FieldList and push the Root TabSet on to it.
     $fields = FieldList::create($root = TabSet::create('Root', Tab::create("Main", HeaderField::create("Add/Edit Tax Zone"), CompositeField::create(DropdownField::create("Enabled", "Enable this zone?", array("1" => "Yes", "2" => "No"))->setRightTitle($this->SystemCreated == 1 && $this->exists() ? "DISABLED: You can not disable the default tax zone." : "If enabled your store will use the rates defined in this zone for customers in the selected country.")->setDisabled($this->SystemCreated == 1 && $this->exists() ? true : false), !$this->exists() ? CountryDropdownField::create("Title", "Country")->setRightTitle($this->SystemCreated == 1 && $this->exists() ? "DISABLED: You can not select a country as this zone applies to all countries." : "Select the country this zone applies to.")->setDisabled($this->SystemCreated == 1 && $this->exists() ? true : false) : "", $this->exists() ? GridField::create("TaxZones_TaxRates", "Tax Rates within the '" . $this->Title . "' Tax Zone", $this->TaxRates(), GridFieldConfig_RecordEditor::create()) : ""))));
     return $fields;
 }
 /**
  * getCMSFields
  * Construct the FieldList used in the CMS. To provide a
  * smarter UI we don't use the scaffolding provided by
  * parent::getCMSFields.
  * 
  * @return FieldList
  */
 public function getCMSFields()
 {
     Requirements::css('torindul-silverstripe-shop/css/LeftAndMain.css');
     //Create the FieldList and push the Root TabSet on to it.
     $fields = FieldList::create($root = TabSet::create('Root', Tab::create("Main", HeaderField::create("Add/Edit Tax Class"), CompositeField::create(TextField::create("Title", "Class Name")->setRightTitle("i.e. Zero Rate, Standard Rate.")))));
     return $fields;
 }
 public function __construct($controller, $name, $show_actions = true)
 {
     $TempBasketID = Store_BasketController::get_temp_basket_id();
     $order_id = DB::Query("SELECT id FROM `order` WHERE (`TempBasketID`='" . $TempBasketID . "')")->value();
     /* Basket GridField */
     $config = new GridFieldConfig();
     $dataColumns = new GridFieldDataColumns();
     $dataColumns->setDisplayFields(array('getPhoto' => "Photo", 'Title' => 'Product', 'Price' => 'Item Price', 'Quantity' => 'Quantity', 'productPrice' => 'Total Price', 'getfriendlyTaxCalculation' => 'Tax Inc/Exc', 'TaxClassName' => 'Tax'));
     $config->addComponent($dataColumns);
     $config->addComponent(new GridFieldTitleHeader());
     $basket = GridField::create("BasketItems", "", DataObject::get("Order_Items", "(OrderID='" . $order_id . "')"), $config);
     /* Basket Subtotal */
     $subtotal = new Order();
     $subtotal = $subtotal->calculateSubTotal($order_id);
     $subtotal = ReadonlyField::create("SubTotal", "Basket Total (" . Product::getDefaultCurrency() . ")", $subtotal);
     /* Fields */
     $fields = FieldList::create($basket, $subtotal, ReadonlyField::create("Tax", "Tax", "Calculated on the Order Summary page."));
     /* Actions */
     $actions = FieldList::create(CompositeField::create(FormAction::create('continueshopping', 'Continue Shopping'), FormAction::create('placeorder', 'Place Order')));
     /* Required Fields */
     $required = new RequiredFields(array());
     /*
      * Now we create the actual form with our fields and actions defined 
      * within this class.
      */
     return parent::__construct($controller, $name, $fields, $show_actions ? $actions : FieldList::create(), $required);
 }
 /**
  * Form used for defining the conversion form
  * @return {Form} Form to be used for configuring the conversion
  */
 public function ConvertObjectForm()
 {
     //Reset the reading stage
     Versioned::reset();
     $fields = new FieldList(CompositeField::create($convertModeField = new OptionsetField('ConvertMode', '', array('ReplacePage' => _t('KapostAdmin.REPLACES_AN_EXISTING_PAGE', '_This replaces an existing page'), 'NewPage' => _t('KapostAdmin.IS_NEW_PAGE', '_This is a new page')), 'NewPage'))->addExtraClass('kapostConvertLeftSide'), CompositeField::create($replacePageField = TreeDropdownField::create('ReplacePageID', _t('KapostAdmin.REPLACE_PAGE', '_Replace this page'), 'SiteTree')->addExtraClass('replace-page-id'), TreeDropdownField::create('ParentPageID', _t('KapostAdmin.USE_AS_PARENT', '_Use this page as the parent for the new page, leave empty for a top level page'), 'SiteTree')->addExtraClass('parent-page-id'))->addExtraClass('kapostConvertRightSide'));
     $actions = new FieldList(FormAction::create('doConvertObject', _t('KapostAdmin.CONTINUE_CONVERT', '_Continue'))->setUseButtonTag(true)->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'kapost-convert'));
     $validator = new RequiredFields('ConvertMode');
     $form = new Form($this, 'ConvertObjectForm', $fields, $actions, $validator);
     $form->addExtraClass('KapostAdmin center')->setAttribute('data-layout-type', 'border')->setTemplate('KapostAdmin_ConvertForm');
     //Handle pages to see if the page exists
     $convertToClass = $this->getDestinationClass();
     if ($convertToClass !== false && ($convertToClass == 'SiteTree' || is_subclass_of($convertToClass, 'SiteTree'))) {
         $obj = SiteTree::get()->filter('KapostRefID', Convert::raw2sql($this->record->KapostRefID))->first();
         if (!empty($obj) && $obj !== false && $obj->ID > 0) {
             $convertModeField->setValue('ReplacePage');
             $replacePageField->setValue($obj->ID);
             $recordTitle = $this->record->Title;
             if (!empty($recordTitle) && $recordTitle != $obj->Title) {
                 $urlFieldLabel = _t('KapostAdmin.TITLE_CHANGE_DETECT', '_The title differs from the page being replaced, it was "{wastitle}" and will be changed to "{newtitle}". Do you want to update the URL Segment?', array('wastitle' => $obj->Title, 'newtitle' => $recordTitle));
                 $fields->push(CheckboxField::create('UpdateURLSegment', $urlFieldLabel)->addExtraClass('urlsegmentcheck')->setAttribute('data-replace-id', $obj->ID)->setForm($form)->setDescription(_t('KapostAdmin.NEW_URL_SEGMENT', '_The new URL Segment will be or will be close to "{newsegment}"', array('newsegment' => $obj->generateURLSegment($recordTitle)))));
             }
         }
     }
     Requirements::css(KAPOST_DIR . '/css/KapostAdmin.css');
     Requirements::add_i18n_javascript(KAPOST_DIR . '/javascript/lang/');
     Requirements::javascript(KAPOST_DIR . '/javascript/KapostAdmin_convertPopup.js');
     //Allow extensions to adjust the form
     $this->extend('updateConvertObjectForm', $form, $this->record);
     return $form;
 }
Exemplo n.º 22
0
 public function __construct($title)
 {
     $args = func_get_args();
     $this->title = array_shift($args);
     $this->id = ereg_replace('[^0-9A-Za-z]+', '', $this->title);
     parent::__construct($args);
 }
 /**
  * getCMSFields
  * Construct the FieldList used in the CMS. To provide a
  * smarter UI we don't use the scaffolding provided by
  * parent::getCMSFields.
  * 
  * @return FieldList
  */
 public function getCMSFields()
 {
     Requirements::css('torindul-silverstripe-shop/css/LeftAndMain.css');
     //Create the FieldList and push the Root TabSet on to it.
     $fields = FieldList::create($root = TabSet::create('Root', Tab::create("Main", HeaderField::create("Add/Edit Currency"), CompositeField::create(DropdownField::create("Enabled", "Enable Currency?", array("1" => "Yes", "2" => "No"))->setRightTitle($this->SystemCreated == 1 ? "DISABLED: You can not disable the default currency." : "Select the country this zone applies to.")->setDisabled($this->SystemCreated == 1 ? true : false), TextField::create("Title", "Currency Name")->setRightTitle("i.e. Great British Pound."), TextField::create("Code", "Currency Code")->setRightTitle("i.e. GBP, USD, EUR."), TextField::create("ExchangeRate", "Exchange Rate")->setRightTitle("i.e. Your new currency is USD, a conversion rate of 1.53 may apply against the local currency."), TextField::create("Symbol", "Currency Symbol")->setRightTitle("i.e. &pound;, \$, &euro;."), DropdownField::create("SymbolLocation", "Symbol Location", array("1" => "On the left, i.e. \$1.00", "2" => "On the right, i.e. 1.00\$", "3" => "Display the currency code instead, i.e. 1 USD."))->setRightTitle("Where should the currency symbol be placed?"), TextField::create("DecimalSeperator", "Decimal Separator")->setRightTitle("What decimal separator does this currency use?"), TextField::create("ThousandsSeparator", "Thousands Separator")->setRightTitle("What thousands separator does this currency use?"), NumericField::create("DecimalPlaces", "Decimal Places")->setRightTitle("How many decimal places does this currency use?")))));
     return $fields;
 }
Exemplo n.º 24
0
 function __construct($name, $title, $children)
 {
     $this->name = $name;
     $this->title = $title;
     $this->startClosed(true);
     parent::__construct($children);
 }
Exemplo n.º 25
0
 public function updateCMSFields(FieldList $fields)
 {
     $fields->removeByName(array('Lat', 'Lng'));
     // Adds Lat/Lng fields for viewing in the CMS
     $compositeField = CompositeField::create();
     $compositeField->push($overrideField = CheckboxField::create('LatLngOverride', 'Override Latitude and Longitude?'));
     $overrideField->setDescription('Check this box and save to be able to edit the latitude and longitude manually.');
     if ($this->owner->Lng && $this->owner->Lat) {
         $googleMapURL = 'http://maps.google.com/?q=' . $this->owner->Lat . ',' . $this->owner->Lng;
         $googleMapDiv = '<div class="field"><label class="left" for="Form_EditForm_MapURL_Readonly">Google Map</label><div class="middleColumn"><a href="' . $googleMapURL . '" target="_blank">' . $googleMapURL . '</a></div></div>';
         $compositeField->push(LiteralField::create('MapURL_Readonly', $googleMapDiv));
     }
     if ($this->owner->LatLngOverride) {
         $compositeField->push(TextField::create('Lat', 'Lat'));
         $compositeField->push(TextField::create('Lng', 'Lng'));
     } else {
         $compositeField->push(ReadonlyField::create('Lat_Readonly', 'Lat', $this->owner->Lat));
         $compositeField->push(ReadonlyField::create('Lng_Readonly', 'Lng', $this->owner->Lng));
     }
     if ($this->owner->hasExtension('Addressable')) {
         // If using addressable, put the fields with it
         $fields->addFieldToTab('Root.Address', ToggleCompositeField::create('Coordinates', 'Coordinates', $compositeField));
     } else {
         if ($this->owner instanceof SiteTree) {
             // If SIteTree but not using Addressable, put after 'Metadata' toggle composite field
             $fields->insertAfter($compositeField, 'ExtraMeta');
         } else {
             $fields->addFieldToTab('Root.Main', ToggleCompositeField::create('Coordinates', 'Coordinates', $compositeField));
         }
     }
 }
 function FieldSet()
 {
     $items = parent::FieldSet()->toArray();
     $count = 0;
     $firstSelected = $checked = "";
     foreach ($items as $key => $item) {
         if (strpos($key, '//') !== false) {
             list($key, $title) = explode('//', $key, 2);
         } else {
             $title = $key;
         }
         if ($this->value == $key) {
             $firstSelected = " class=\"selected\"";
             $checked = " checked=\"checked\"";
         }
         $itemID = $this->ID() . '_' . ++$count;
         $extra = array("RadioButton" => "<input class=\"selector\" type=\"radio\" id=\"{$itemID}\" name=\"{$this->name}\" value=\"{$key}\"{$checked} />", "RadioLabel" => "<label for=\"{$itemID}\">{$title}</label>", "Selected" => $firstSelected);
         if (is_object($item)) {
             $newItems[] = $item->customise($extra);
         } else {
             $newItems[] = new ArrayData($extra);
         }
         $firstSelected = $checked = "";
     }
     return new DataObjectSet($newItems);
 }
 /**
  * Renders the button, includes the JS and CSS
  * @param array $properties
  */
 public function Field($properties = array())
 {
     Requirements::css(BETTER_BUTTONS_DIR . '/css/dropdown_form_action.css');
     Requirements::javascript(BETTER_BUTTONS_DIR . '/javascript/dropdown_form_action.js');
     $this->setAttribute('data-form-action-dropdown', '#' . $this->DropdownID());
     return parent::Field();
 }
 /**
  * Provides a GUI for the insert/edit shortcode popup
  * @return Form
  **/
 public function ShortcodeForm()
 {
     if (!Permission::check('CMS_ACCESS_CMSMain')) {
         return;
     }
     Config::inst()->update('SSViewer', 'theme_enabled', false);
     // create a list of shortcodable classes for the ShortcodeType dropdown
     $classList = ClassInfo::implementorsOf('Shortcodable');
     $classes = array();
     foreach ($classList as $class) {
         $classes[$class] = singleton($class)->singular_name();
     }
     // load from the currently selected ShortcodeType or Shortcode data
     $classname = false;
     $shortcodeData = false;
     if ($shortcode = $this->request->requestVar('Shortcode')) {
         $shortcode = str_replace("", '', $shortcode);
         //remove BOM inside string on cursor position...
         $shortcodeData = singleton('ShortcodableParser')->the_shortcodes(array(), $shortcode);
         if (isset($shortcodeData[0])) {
             $shortcodeData = $shortcodeData[0];
             $classname = $shortcodeData['name'];
         }
     } else {
         $classname = $this->request->requestVar('ShortcodeType');
     }
     if ($shortcodeData) {
         $headingText = _t('Shortcodable.EDITSHORTCODE', 'Edit Shortcode');
     } else {
         $headingText = _t('Shortcodable.INSERTSHORTCODE', 'Insert Shortcode');
     }
     // essential fields
     $fields = FieldList::create(array(CompositeField::create(LiteralField::create('Heading', sprintf('<h3 class="htmleditorfield-shortcodeform-heading insert">%s</h3>', $headingText)))->addExtraClass('CompositeField composite cms-content-header nolabel'), LiteralField::create('shortcodablefields', '<div class="ss-shortcodable content">'), DropdownField::create('ShortcodeType', 'ShortcodeType', $classes, $classname)->setHasEmptyDefault(true)->addExtraClass('shortcode-type')));
     // attribute and object id fields
     if ($classname) {
         if (class_exists($classname)) {
             $class = singleton($classname);
             if (is_subclass_of($class, 'DataObject')) {
                 if (singleton($classname)->hasMethod('get_shortcodable_records')) {
                     $dataObjectSource = $classname::get_shortcodable_records();
                 } else {
                     $dataObjectSource = $classname::get()->map()->toArray();
                 }
                 $fields->push(DropdownField::create('id', $class->singular_name(), $dataObjectSource)->setHasEmptyDefault(true));
             }
             if ($attrFields = $classname::shortcode_attribute_fields()) {
                 $fields->push(CompositeField::create($attrFields)->addExtraClass('attributes-composite'));
             }
         }
     }
     // actions
     $actions = FieldList::create(array(FormAction::create('insert', _t('Shortcodable.BUTTONINSERTSHORTCODE', 'Insert shortcode'))->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')->setUseButtonTag(true)));
     // form
     $form = Form::create($this, "ShortcodeForm", $fields, $actions)->loadDataFrom($this)->addExtraClass('htmleditorfield-form htmleditorfield-shortcodable cms-dialog-content');
     if ($shortcodeData) {
         $form->loadDataFrom($shortcodeData['atts']);
     }
     $this->extend('updateShortcodeForm', $form);
     return $form;
 }
 function ItemEditForm()
 {
     $form = parent::ItemEditForm();
     $actions = $form->Actions();
     $majorActions = CompositeField::create()->setName('MajorActions')->setTag('fieldset')->addExtraClass('ss-ui-buttonset');
     $rootTabSet = new TabSet('ActionMenus');
     $moreOptions = new Tab('MoreOptions', _t('SiteTree.MoreOptions', 'More options', 'Expands a view for more buttons'));
     $rootTabSet->push($moreOptions);
     $rootTabSet->addExtraClass('ss-ui-action-tabset action-menus');
     // Render page information into the "more-options" drop-up, on the top.
     $baseClass = ClassInfo::baseDataClass($this->record->class);
     $live = Versioned::get_one_by_stage($this->record->class, 'Live', "\"{$baseClass}\".\"ID\"='{$this->record->ID}'");
     $existsOnLive = $this->record->getExistsOnLive();
     $published = $this->record->isPublished();
     $moreOptions->push(new LiteralField('Information', $this->record->customise(array('Live' => $live, 'ExistsOnLive' => $existsOnLive))->renderWith('SiteTree_Information')));
     $actions->removeByName('action_doSave');
     $actions->removeByName('action_doDelete');
     if ($this->record->canEdit()) {
         if ($this->record->IsDeletedFromStage) {
             if ($existsOnLive) {
                 $majorActions->push(FormAction::create('revert', _t('CMSMain.RESTORE', 'Restore')));
                 if ($this->record->canDelete() && $this->record->canDeleteFromLive()) {
                     $majorActions->push(FormAction::create('unpublish', _t('CMSMain.DELETEFP', 'Delete'))->addExtraClass('ss-ui-action-destructive'));
                 }
             } else {
                 if (!$this->record->isNew()) {
                     $majorActions->push(FormAction::create('restore', _t('CMSMain.RESTORE', 'Restore'))->setAttribute('data-icon', 'decline'));
                 } else {
                     $majorActions->push(FormAction::create('save', _t('SiteTree.BUTTONSAVED', 'Saved'))->addExtraClass('ss-ui-alternate ss-ui-action-constructive')->setAttribute('data-icon', 'accept')->setAttribute('data-icon-alternate', 'addpage')->setAttribute('data-text-alternate', _t('CMSMain.SAVEDRAFT', 'Save draft'))->setUseButtonTag(true));
                     $majorActions->push(FormAction::create('publish', _t('SiteTree.BUTTONPUBLISHED', 'Published'))->addExtraClass('ss-ui-alternate ss-ui-action-constructive')->setAttribute('data-icon', 'accept')->setAttribute('data-icon-alternate', 'disk')->setAttribute('data-text-alternate', _t('SiteTree.BUTTONSAVEPUBLISH', 'Save & publish'))->setUseButtonTag(true));
                 }
             }
         } else {
             if ($this->record->canDelete() && !$published) {
                 $moreOptions->push(FormAction::create('delete', _t('SiteTree.BUTTONDELETE', 'Delete draft'))->addExtraClass('ss-ui-action-destructive')->setUseButtonTag(true));
             }
             $majorActions->push(FormAction::create('save', _t('SiteTree.BUTTONSAVED', 'Saved'))->setAttribute('data-icon', 'accept')->setAttribute('data-icon-alternate', 'addpage')->setAttribute('data-text-alternate', _t('CMSMain.SAVEDRAFT', 'Save draft'))->setUseButtonTag(true));
         }
     }
     $publish = FormAction::create('publish', $published ? _t('SiteTree.BUTTONPUBLISHED', 'Published') : _t('SiteTree.BUTTONSAVEPUBLISH', 'Save & publish'))->setAttribute('data-icon', 'accept')->setAttribute('data-icon-alternate', 'disk')->setAttribute('data-text-alternate', _t('SiteTree.BUTTONSAVEPUBLISH', 'Save & publish'))->setUseButtonTag(true);
     if (!$published || $this->record->stagesDiffer('Stage', 'Live') && $published) {
         $publish->addExtraClass('ss-ui-alternate');
     }
     if ($this->record->canPublish() && !$this->record->IsDeletedFromStage) {
         $majorActions->push($publish);
     }
     if ($published && $this->record->canPublish() && !$this->record->IsDeletedFromStage && $this->record->canDeleteFromLive()) {
         $moreOptions->push(FormAction::create('unpublish', _t('SiteTree.BUTTONUNPUBLISH', 'Unpublish'), 'delete')->addExtraClass('ss-ui-action-destructive')->setUseButtonTag(true));
     }
     if ($this->record->stagesDiffer('Stage', 'Live') && !$this->record->IsDeletedFromStage && $this->record->isPublished() && $this->record->canEdit()) {
         $moreOptions->push(FormAction::create('rollback', _t('SiteTree.BUTTONCANCELDRAFT', 'Cancel draft changes'))->setDescription(_t('SiteTree.BUTTONCANCELDRAFTDESC', 'Delete your draft and revert to the currently published page'))->setUseButtonTag(true));
     }
     $actions->push($majorActions);
     $actions->push($rootTabSet);
     if ($this->record->hasMethod('getCMSValidator')) {
         $form->setValidator($this->record->getCMSValidator());
     }
     return $form;
 }
 /**
  * Add fields to the CMS for this gateway.
  */
 public function getCMSFields()
 {
     //Fetch the fields from the Courier DataObject
     $fields = parent::getCMSFields();
     //Add new fields
     $fields->addFieldsToTab("Root.Main", array(HeaderField::create("PayPal Transaction Information"), CompositeField::create(ReadonlyField::create("custom", "Order Number"), ReadonlyField::create("payment_date", "Payment Date"), ReadonlyField::create("payment_status", "Payment Status")->setRightTitle("\n\t\t\t\t\tIf this status is pending, see Pending Reason below. \n\t\t\t\t"), ReadonlyField::create("payment_type", "Payment Type")->setRightTitle("\n\t\t\t\t\tFor a explanation of the different payment types please see 'payment_type' at \n\t\t\t\t\t<a href=\"https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNandPDTVariables/\">paypal.com</a>\n\t\t\t\t"), ReadonlyField::create("pending_reason", "Pending Reason")->setRightTitle("\n\t\t\t\t\tFor a explanation of pending reasons please see 'pending_reason' at \n\t\t\t\t\t<a href=\"https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNandPDTVariables/\">paypal.com</a>\n\t\t\t\t"), ReadonlyField::create("reason_code", "Reason Code")->setRightTitle("\n\t\t\t\t\tThis is set if Payment Status is Reversed, Refunded, Canceled_Reversal, or Denied. For an explanation of its\n\t\t\t\t\tmeaning see 'reason_code' at \n\t\t\t\t\t<a href=\"https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNandPDTVariables/\">paypal.com</a>\n\t\t\t\t"), FieldGroup::create("Transaction Identifiers", ReadonlyField::create("txn_id", "<strong>Transaction ID</strong>"), ReadonlyField::create("parent_txn_id", "<strong>Parent Transaction ID</strong>"))->setRightTitle("\n\t\t\t\t\t<strong>Transaction ID</strong><br />\n\t\t\t\t\tThe identifier for this specific transaction entry.\n\t\t\t\t\t\n\t\t\t\t\t<br /><br />\n\t\t\t\t\t\n\t\t\t\t\t<strong>Parent Transaction ID</strong><br />\n\t\t\t\t\tIf provided, this value is the transaction identifier of the\n\t\t\t\t\tparent transaction. i.e. If this transaction is a refund, the\n\t\t\t\t\tvalue will be the transaction ID of the original purchase.\n\t\t\t\t\t<br />\n\t\t\t\t"), FieldGroup::create("Funds", ReadonlyField::create("mc_gross", "<strong>Gross Payment</strong>"), ReadonlyField::create("mc_fee", "<strong>PayPal Fee</strong>"))->setRightTitle("\n\t\t\t\t\t<strong>Gross Payment</strong><br />\n\t\t\t\t\tFull amount of the customer's payment, before transaction fee is subtracted.\n\t\t\t\t\t\n\t\t\t\t\t<br /><br />\n\t\t\t\t\t\n\t\t\t\t\t<strong>PayPal Fee</strong><br />\n\t\t\t\t\tTransaction fee associated with the payment.\n\t\t\t\t"))));
     return $fields;
 }