本文整理汇总了PHP中OptionsetField类的典型用法代码示例。如果您正苦于以下问题:PHP OptionsetField类的具体用法?PHP OptionsetField怎么用?PHP OptionsetField使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OptionsetField类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCMSFields
/**
* Get the fields that are sent to the CMS. In
* your decorators: updateCMSFields(&$fields)
*
* @return Fieldset
*/
function getCMSFields()
{
Requirements::javascript(CMS_DIR . "/javascript/SitetreeAccess.js");
$fields = new FieldSet(new TabSet("Root", $tabMain = new Tab('Main', $titleField = new TextField("Title", _t('SiteConfig.SITETITLE', "Site title")), $taglineField = new TextField("Tagline", _t('SiteConfig.SITETAGLINE', "Site Tagline/Slogan")), new DropdownField("Theme", _t('SiteConfig.THEME', 'Theme'), $this->getAvailableThemes(), '', null, _t('SiteConfig.DEFAULTTHEME', '(Use default theme)'))), $tabAccess = new Tab('Access', new HeaderField('WhoCanViewHeader', _t('SiteConfig.VIEWHEADER', "Who can view pages on this site?"), 2), $viewersOptionsField = new OptionsetField("CanViewType"), $viewerGroupsField = new TreeMultiselectField("ViewerGroups", _t('SiteTree.VIEWERGROUPS', "Viewer Groups")), new HeaderField('WhoCanEditHeader', _t('SiteConfig.EDITHEADER', "Who can edit pages on this site?"), 2), $editorsOptionsField = new OptionsetField("CanEditType"), $editorGroupsField = new TreeMultiselectField("EditorGroups", _t('SiteTree.EDITORGROUPS', "Editor Groups")), new HeaderField('WhoCanCreateTopLevelHeader', _t('SiteConfig.TOPLEVELCREATE', "Who can create pages in the root of the site?"), 2), $topLevelCreatorsOptionsField = new OptionsetField("CanCreateTopLevelType"), $topLevelCreatorsGroupsField = new TreeMultiselectField("CreateTopLevelGroups", _t('SiteTree.TOPLEVELCREATORGROUPS', "Top level creators")))));
$viewersOptionsSource = array();
$viewersOptionsSource["Anyone"] = _t('SiteTree.ACCESSANYONE', "Anyone");
$viewersOptionsSource["LoggedInUsers"] = _t('SiteTree.ACCESSLOGGEDIN', "Logged-in users");
$viewersOptionsSource["OnlyTheseUsers"] = _t('SiteTree.ACCESSONLYTHESE', "Only these people (choose from list)");
$viewersOptionsField->setSource($viewersOptionsSource);
$editorsOptionsSource = array();
$editorsOptionsSource["LoggedInUsers"] = _t('SiteTree.EDITANYONE', "Anyone who can log-in to the CMS");
$editorsOptionsSource["OnlyTheseUsers"] = _t('SiteTree.EDITONLYTHESE', "Only these people (choose from list)");
$editorsOptionsField->setSource($editorsOptionsSource);
$topLevelCreatorsOptionsField->setSource($editorsOptionsSource);
// Translatable doesn't handle updateCMSFields on DataObjects,
// so add it here to save the current Locale,
// because onBeforeWrite does not work.
if (Object::has_extension('SiteConfig', "Translatable")) {
$fields->push(new HiddenField("Locale"));
}
if (!Permission::check('EDIT_SITECONFIG')) {
$fields->makeFieldReadonly($viewersOptionsField);
$fields->makeFieldReadonly($viewerGroupsField);
$fields->makeFieldReadonly($editorsOptionsField);
$fields->makeFieldReadonly($editorGroupsField);
$fields->makeFieldReadonly($topLevelCreatorsOptionsField);
$fields->makeFieldReadonly($topLevelCreatorsGroupsField);
$fields->makeFieldReadonly($taglineField);
$fields->makeFieldReadonly($titleField);
}
$tabMain->setTitle(_t('SiteConfig.TABMAIN', "Main"));
$tabAccess->setTitle(_t('SiteConfig.TABACCESS', "Access"));
$this->extend('updateCMSFields', $fields);
return $fields;
}
示例2: ConvertObjectForm
/**
* 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;
}
开发者ID:helpfulrobot,项目名称:webbuilders-group-silverstripe-kapost-bridge,代码行数:34,代码来源:KapostGridFieldDetailForm_ItemRequest.php
示例3: getCMSFields
public function getCMSFields()
{
Requirements::add_i18n_javascript(BLOCKS_DIR . '/javascript/lang');
// this line is a temporary patch until I can work out why this dependency isn't being
// loaded in some cases...
if (!$this->blockManager) {
$this->blockManager = singleton('BlockManager');
}
$fields = parent::getCMSFields();
// ClassNmae - block type/class field
$classes = $this->blockManager->getBlockClasses();
$fields->addFieldToTab('Root.Main', DropdownField::create('ClassName', 'Block Type', $classes)->addExtraClass('block-type'), 'Title');
// BlockArea - display areas field if on page edit controller
if (Controller::curr()->class == 'CMSPageEditController') {
$currentPage = Controller::curr()->currentPage();
$fields->addFieldToTab('Root.Main', DropdownField::create('ManyMany[BlockArea]', 'BlockArea', $this->blockManager->getAreasForPageType($currentPage->ClassName))->setHasEmptyDefault(true)->setRightTitle($currentPage->areasPreviewButton()), 'ClassName');
}
$fields->removeFieldFromTab('Root', 'BlockSets');
$fields->removeFieldFromTab('Root', 'Pages');
// legacy fields, will be removed in later release
$fields->removeByName('Weight');
$fields->removeByName('Area');
$fields->removeByName('Published');
if ($this->blockManager->getUseExtraCSSClasses()) {
$fields->addFieldToTab('Root.Main', $fields->dataFieldByName('ExtraCSSClasses'), 'Title');
} else {
$fields->removeByName('ExtraCSSClasses');
}
// Viewer groups
$fields->removeFieldFromTab('Root', 'ViewerGroups');
$groupsMap = Group::get()->map('ID', 'Breadcrumbs')->toArray();
asort($groupsMap);
$viewersOptionsField = new OptionsetField("CanViewType", _t('SiteTree.ACCESSHEADER', "Who can view this page?"));
$viewerGroupsField = ListboxField::create("ViewerGroups", _t('SiteTree.VIEWERGROUPS', "Viewer Groups"))->setMultiple(true)->setSource($groupsMap)->setAttribute('data-placeholder', _t('SiteTree.GroupPlaceholder', 'Click to select group'));
$viewersOptionsSource = array();
$viewersOptionsSource["Anyone"] = _t('SiteTree.ACCESSANYONE', "Anyone");
$viewersOptionsSource["LoggedInUsers"] = _t('SiteTree.ACCESSLOGGEDIN', "Logged-in users");
$viewersOptionsSource["OnlyTheseUsers"] = _t('SiteTree.ACCESSONLYTHESE', "Only these people (choose from list)");
$viewersOptionsField->setSource($viewersOptionsSource)->setValue("Anyone");
$fields->addFieldsToTab('Root.ViewerGroups', array($viewersOptionsField, $viewerGroupsField));
// Disabled for now, until we can list ALL pages this block is applied to (inc via sets)
// As otherwise it could be misleading
// Show a GridField (list only) with pages which this block is used on
// $fields->removeFieldFromTab('Root.Pages', 'Pages');
// $fields->addFieldsToTab('Root.Pages',
// new GridField(
// 'Pages',
// 'Used on pages',
// $this->Pages(),
// $gconf = GridFieldConfig_Base::create()));
// enhance gridfield with edit links to pages if GFEditSiteTreeItemButtons is available
// a GFRecordEditor (default) combined with BetterButtons already gives the possibility to
// edit versioned records (Pages), but STbutton loads them in their own interface instead
// of GFdetailform
// if(class_exists('GridFieldEditSiteTreeItemButton')){
// $gconf->addComponent(new GridFieldEditSiteTreeItemButton());
// }
return $fields;
}
示例4: updateCMSFields
/**
* Update SiteConfig with the top level fields
*
* @param FieldSet $fields
* @return void
*/
function updateCMSFields(&$fields)
{
$fields->addFieldsToTab("Root.Access", array(new HeaderField(_t('SiteConfigCMSWorkflow.PUBLISHAPPROVEDHEADER', "Who can publish requests inside the CMS?"), 2), $actionTypeField = new OptionsetField("CanPublishType", "", array("LoggedInUsers" => _t('SiteTree.EDITANYONE', "Anyone who can log-in to the CMS"), "OnlyTheseUsers" => _t('SiteTree.EDITONLYTHESE', "Only these people (choose from list)")), "OnlyTheseUsers"), $actionerGroupsField = new TreeMultiselectField("PublisherGroups", "Publisher groups")));
if (!Permission::check('ADMIN')) {
$fields->replaceField('CanPublishType', $actionTypeField->performReadonlyTransformation());
$fields->replaceField('PublisherGroups', $actionerGroupsField->performReadonlyTransformation());
}
}
示例5: updateCMSFields
/**
* Implement permissions for TwoStep
*
* @return void
*/
public function updateCMSFields(&$fields)
{
$fields->addFieldsToTab("Root.Access", array(new HeaderField(_t('SiteTreeCMSWorkflow.PUBLISHHEADER', "Who can publish this inside the CMS?"), 2), $publishTypeField = new OptionsetField("CanPublishType", "", array("Inherit" => _t('SiteTree.EDITINHERIT', "Inherit from parent page"), "LoggedInUsers" => _t('SiteTree.EDITANYONE', "Anyone who can log-in to the CMS"), "OnlyTheseUsers" => _t('SiteTree.EDITONLYTHESE', "Only these people (choose from list)")), "Inherit"), $publisherGroupsField = new TreeMultiselectField("PublisherGroups", $this->owner->fieldLabel('PublisherGroups'))));
if (!$this->owner->canPublish() || !Permission::check('SITETREE_GRANT_ACCESS')) {
$fields->replaceField('CanPublishType', $publishTypeField->performReadonlyTransformation());
$fields->replaceField('PublisherGroups', $publisherGroupsField->performReadonlyTransformation());
}
}
示例6: testSetDisabledItems
public function testSetDisabledItems()
{
$f = new OptionsetField('Test', false, array(0 => 'Zero', 1 => 'One'));
$f->setDisabledItems(array(0));
$p = new CSSContentParser($f->Field());
$item0 = $p->getBySelector('#Test_0');
$item1 = $p->getBySelector('#Test_1');
$this->assertEquals((string) $item0[0]['disabled'], 'disabled');
$this->assertEquals((string) $item1[0]['disabled'], '');
}
示例7: updateLinkForm
public function updateLinkForm(Form $form)
{
Requirements::javascript(ExternalContentAdmin::$directory . "/javascript/external_tiny_mce_improvements.js");
$fields = $form->Fields();
$fields->replaceField('LinkType', $options = new OptionsetField('LinkType', _t('HtmlEditorField.LINKTO', 'Link to'), array('internal' => _t('HtmlEditorField.LINKINTERNAL', 'Page on the site'), 'external' => _t('HtmlEditorField.LINKEXTERNAL', 'Another website'), 'anchor' => _t('HtmlEditorField.LINKANCHOR', 'Anchor on this page'), 'email' => _t('HtmlEditorField.LINKEMAIL', 'Email address'), 'file' => _t('HtmlEditorField.LINKFILE', 'Download a file'), 'externalcontent' => _t('HtmlEditorField.LINKEXTERNALCONTENT', 'External Content'))));
$fields->insertAfter($tree = new ExternalTreeDropdownField('externalcontent', _t('ExternalHtmlEditorField.EXTERNAL_CONTENT', 'External Content'), 'ExternalContentSource', 'Link()'), 'file');
// Explicitly set the form on new fields so the hierarchy can be traversed.
$tree->setForm($form);
$options->setForm($form);
}
开发者ID:helpfulrobot,项目名称:silverstripe-external-content,代码行数:10,代码来源:ExternalContentHtmlEditorExtension.php
示例8: testReadonlyField
public function testReadonlyField()
{
$sourceArray = array(0 => 'No', 1 => 'Yes');
$field = new OptionsetField('FeelingOk', 'are you feeling ok?', $sourceArray, 1);
$field->setEmptyString('(Select one)');
$field->setValue(1);
$readonlyField = $field->performReadonlyTransformation();
preg_match('/Yes/', $field->Field(), $matches);
$this->assertEquals($matches[0], 'Yes');
}
示例9: testSafelyCast
public function testSafelyCast()
{
$field1 = new OptionsetField('Options', 'Options', array(1 => 'One', 2 => 'Two & Three', 3 => DBField::create_field('HTMLText', 'Four & Five & Six')));
$fieldHTML = (string) $field1->Field();
$this->assertContains('One', $fieldHTML);
$this->assertContains('Two & Three', $fieldHTML);
$this->assertNotContains('Two & Three', $fieldHTML);
$this->assertContains('Four & Five & Six', $fieldHTML);
$this->assertNotContains('Four & Five & Six', $fieldHTML);
}
示例10: updateCMSFields
/**
* Updates the fields used in the cms
* @param {FieldList} $fields Fields to be extended
*/
public function updateCMSFields(FieldList $fields)
{
$fields->addFieldToTab('Root.Main', $field = new OptionsetField('DefaultPreviewMode', _t('UserPreviewPreference.DEFAULT_MODE', '_Default Preview Mode'), array('content' => _t('UserPreviewPreference.CONTENT_MODE', '_Content Mode: Only menu and content areas are shown'), 'split' => _t('UserPreviewPreference.SPLIT_MODE', '_Split Mode: Side by Side editing and previewing'), 'preview' => _t('UserPreviewPreference.PREVIEW_MODE', '_Preview Mode: Only menu and preview areas are shown')), Config::inst()->get('UserPreviewPreference', 'DefaultMode')));
if (Session::get('ShowPreviewSettingChangeReload') == true) {
$field->setError(_t('UserPreviewPreference.CHANGE_REFRESH', '_You have updated your preview preference, you must refresh your browser to see the updated setting'), 'warning');
Requirements::javascript(CMSPREVIEWPREFERENCE_BASE . '/javascript/clear-local-preference.js');
if ($this->isSaving == false) {
Session::clear('ShowPreviewSettingChangeReload');
}
}
}
开发者ID:helpfulrobot,项目名称:webbuilders-group-silverstripe-cmspreviewpreference,代码行数:15,代码来源:UserPreviewPreference.php
示例11: getCMSFields
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->addFieldsToTab("Root.Main", array(OptionsetField::create('Status', 'Status', array("1" => "Active", "0" => "Disabled"), 1), TextField::create('AdminTitle')->setDescription('This field is for adminisration use only and will not display on the site.'), TextareaField::create('Title', 'Title')->setRows(2), HtmlEditorField::create('Content', 'Content')));
$this->extend('updateCMSFields', $fields);
return $fields;
}
示例12: __construct
public function __construct($controller, $name, Order $order)
{
$this->order = $order;
$fields = FieldList::create(HiddenField::create('OrderID', '', $order->ID));
$actions = FieldList::create();
//payment
if (self::config()->allow_paying && $order->canPay()) {
$gateways = GatewayInfo::get_supported_gateways();
//remove manual gateways
foreach ($gateways as $gateway => $gatewayname) {
if (GatewayInfo::is_manual($gateway)) {
unset($gateways[$gateway]);
}
}
if (!empty($gateways)) {
$fields->push(HeaderField::create("MakePaymentHeader", _t("OrderActionsForm.MAKEPAYMENT", "Make Payment")));
$outstandingfield = Currency::create();
$outstandingfield->setValue($order->TotalOutstanding());
$fields->push(LiteralField::create("Outstanding", sprintf(_t("OrderActionsForm.OUTSTANDING", "Outstanding: %s"), $outstandingfield->Nice())));
$fields->push(OptionsetField::create('PaymentMethod', _t("OrderActionsForm.PAYMENTMETHOD", "Payment Method"), $gateways, key($gateways)));
$actions->push(FormAction::create('dopayment', _t('OrderActionsForm.PAYORDER', 'Pay outstanding balance')));
}
}
//cancelling
if (self::config()->allow_cancelling && $order->canCancel()) {
$actions->push(FormAction::create('docancel', _t('OrderActionsForm.CANCELORDER', 'Cancel this order')));
}
parent::__construct($controller, $name, $fields, $actions);
$this->extend("updateForm", $order);
}
示例13: getFormFields
public function getFormFields(Order $order)
{
$fields = new FieldList();
$estimates = $order->getShippingEstimates();
$fields->push(OptionsetField::create("ShippingMethodID", _t('ShippingCheckoutComponent.ShippingOptions', 'Shipping Options'), $estimates->map(), $estimates->First()->ID));
return $fields;
}
示例14: __construct
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);
}
示例15: getCMSFields
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->merge(new FieldList(TextField::create("Title", _t("TagCloudWidget.TILE", "Title")), TextField::create("Limit", _t("TagCloudWidget.LIMIT", "Limit number of tags")), OptionsetField::create("SortParam"), OptionsetField::create("SortOrder")));
$this->extend('updateCMSFields', $fields);
return $fields;
}