本文整理汇总了PHP中ArrayLib::valuekey方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayLib::valuekey方法的具体用法?PHP ArrayLib::valuekey怎么用?PHP ArrayLib::valuekey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayLib
的用法示例。
在下文中一共展示了ArrayLib::valuekey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSearchContext
public function getSearchContext()
{
$context = parent::getSearchContext();
$categories = EmailTemplate::get()->column('Category');
$context->getFields()->replaceField('q[Category]', new DropdownField('q[Category]', 'Category', ArrayLib::valuekey($categories)));
return $context;
}
示例2: testAncestry
/**
* @covers ClassInfo::ancestry()
*/
public function testAncestry()
{
$ancestry = ClassInfo::ancestry('ClassInfoTest_ChildClass');
$expect = ArrayLib::valuekey(array('Object', 'ViewableData', 'DataObject', 'ClassInfoTest_BaseClass', 'ClassInfoTest_ChildClass'));
$this->assertEquals($expect, $ancestry);
$ancestry = ClassInfo::ancestry('ClassInfoTest_ChildClass', true);
$this->assertEquals(array('ClassInfoTest_BaseClass' => 'ClassInfoTest_BaseClass'), $ancestry, '$tablesOnly option excludes memory-only inheritance classes');
}
示例3: getCMSFields
public function getCMSFields()
{
$fields = FieldList::create(TabSet::create('Root'));
$fields->addFieldsToTab('Root.Main', array(TextField::create('Title'), TextareaField::create('Description'), CurrencyField::create('PricePerNight', 'Price (per night)'), DropdownField::create('Bedrooms')->setSource(ArrayLib::valuekey(range(1, 10))), DropdownField::create('Bathrooms')->setSource(ArrayLib::valuekey(range(1, 10))), DropdownField::create('RegionID', 'Region')->setSource(Region::get()->map('ID', 'Title'))->setEmptyString('-- Select a region --'), CheckboxField::create('FeaturedOnHomepage', 'Feature on homepage')));
$fields->addFieldToTab('Root.Photos', $upload = UploadField::create('PrimaryPhoto', 'Primary photo'));
$upload->getValidator()->setAllowedExtensions(array('png', 'jpeg', 'jpg', 'gif'));
$upload->setFolderName('property-photos');
return $fields;
}
示例4: generateColorPalette
protected function generateColorPalette($fieldName, $paletteSetting)
{
$palette = $this->owner->config()->get($paletteSetting) ? $this->owner->config()->get($paletteSetting) : Config::inst()->get($this->class, $paletteSetting);
$field = ColorPaletteField::create($fieldName, $this->owner->fieldLabel($fieldName), ArrayLib::valuekey($palette));
if (Config::inst()->get($this->class, 'colors_can_be_empty')) {
$field = $field->setEmptyString('none');
}
return $field;
}
示例5: SearchForm
/**
* Update the SearchForm to use dropdown fields for MessageType/Status filters
* @return Form
**/
public function SearchForm()
{
$form = parent::SearchForm();
$fields = $form->Fields();
$q = $this->getRequest()->requestVar('q');
$fields->removeByName('q[MessageType]');
$fields->push(DropdownField::create('q[MessageType]', 'Message Type', ArrayLib::valuekey(Config::inst()->get('TimedNotice', 'message_types')), isset($q['MessageType']) ? $q['MessageType'] : null)->setEmptyString(' '));
$fields->push(DropdownField::create('q[Status]', 'Status', ArrayLib::valuekey(Config::inst()->get('TimedNotice', 'status_options')), isset($q['Status']) ? $q['Status'] : null)->setEmptyString(' '));
return $form;
}
示例6: getCMSFields
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Main', TreeDropdownField::create('SourceFolderID', 'Source folder', 'Folder'), 'Content');
$fields->addFieldToTab('Root.Main', NumericField::create('ItemsPerPage', 'Items per page'), 'Content');
$fileFields = singleton('File')->inheritedDatabaseFields();
$fileFields = array_merge($fileFields, array('Created' => null, 'LastEdited' => null));
$fileFields = ArrayLib::valuekey(array_keys($fileFields));
$fields->addFieldToTab('Root.Main', DropdownField::create('FileSortBy', 'Sort files by', $fileFields), 'Content');
$fields->addFieldToTab('Root.Main', DropdownField::create('FileSortDir', 'Sort direction', self::$sort_dirs_map), 'Content');
return $fields;
}
示例7: updateCMSFields
public function updateCMSFields(FieldList $fields)
{
// if there are Models set in the Product Category then use a dropdown to select
if ($this->owner->Parent && $this->owner->Parent->ProductModels()->count()) {
$fields->replaceField('Model', DropdownField::create('Model', _t("Product.MODELREQUIRED", "Model (required)"), ArrayLib::valuekey($this->owner->Parent->ProductModels()->column('Title')))->setEmptyString(_t("Product.MODELSELECT", "Select..."))->setAttribute('Required', true));
} else {
// Update Model for extended length
// see config.yml for updated db settings
$model = $fields->dataFieldByName('Model');
$model->setMaxLength(100);
}
}
示例8: testValuekey
function testValuekey() {
$this->assertEquals(
ArrayLib::valuekey(
array(
'testkey1' => 'testvalue1',
'testkey2' => 'testvalue2'
)
),
array(
'testvalue1' => 'testvalue1',
'testvalue2' => 'testvalue2'
)
);
}
示例9: getCMSFields
/**
* @return FieldSet
*/
public function getCMSFields()
{
Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
Requirements::javascript('inlinehelp/javascript/InlineHelpAdmin.js');
return new FieldList(new TabSet('Root', new Tab('Main', new HeaderField('HelpHeader', 'Help Topic'), new TextField('Title', 'Title'), new OptionSetField('DisplayType', 'Display type', array('Tooltip' => 'Display help text and/or link in tooltip', 'Link' => 'Click the icon to go to the help link')), new HtmlEditorField('Text', 'Short help text'), new TextField('Link', 'Help link')), new Tab('Subject', new HeaderField('SubjectHeader', 'Help Subject(s)'), new TextField('DOMPattern', 'DOM pattern'), new LiteralField('DOMPatternNote', '<p>This is a jQuery (CSS)
selector which specifies which elements to attach this help
topic to. The same topic can be attached to multiple elements.
</p>'), new DropdownField('DOMMethod', 'DOM attachment method', self::$attachment_method_map)), new Tab('AttachTo', new HeaderField('AttachToHeader', 'Attach Help To'), new OptionSetField('AttachType', '', array('All' => 'All pages', 'Pages' => 'Specific pages', 'Children' => 'Children of the selected page', 'Type' => 'Instances of a specific page type')), new TreeMultiSelectField('Pages', 'Pages', 'SiteTree'), new TreeDropdownField('ParentFilterID', 'Parent page', 'SiteTree'), new DropdownField('AttachPageType', 'Page type', ArrayLib::valuekey(ClassInfo::subclassesFor('Page')))), new Tab('Advanced', new HeaderField('AdvancedHeader', 'Advanced Inline Help Options'), new DropdownField('ShowTooltip', 'Show tooltip on', array('Hover' => 'On mouse hover', 'Click' => 'On mouse click')), new TextField('IconHTML', 'Icon HTML code'), new FieldGroup('Help icon position (relative to subject)', new TextField('IconMy', 'my'), new TextField('IconAt', 'at')), new FieldGroup('Help icon offset (relative to position)', new TextField('IconOffset', ''), new LiteralField('IconOffsetNote', 'format "horizontal vertical" (e.g. "15 -5")')), new FieldGroup('Tooltip position (relative to icon)', new TextField('TooltipMy', 'my'), new TextField('TooltipAt', 'at')), new LiteralField('HelpPositionNote', '<p>These allow you to
specify the position of the elements relative to each other.
Each position is in the format "horizontal vertical", where
horizontal can be one of left, center or right (default
center), and vertical can be top, center or bottom (default
center)</p>'), new FieldGroup('Tooltip size', new TextField('TooltipWidth', ''), new LiteralField('SizeSeparator', 'x'), new TextField('TooltipHeight', ''), new LiteralField('DefaultSizeNote', '(default: 300 x "auto")')))));
}
示例10: PropertySearchForm
public function PropertySearchForm()
{
$nights = array();
foreach (range(1, 14) as $i) {
$nights[$i] = "{$i} night" . ($i > 1 ? 's' : '');
}
$prices = array();
foreach (range(100, 1000, 50) as $i) {
$prices[$i] = '$' . $i;
}
$form = Form::create($this, 'PropertySearchForm', FieldList::create(TextField::create('Keywords')->setAttribute('placeholder', 'City, State, Country, etc...')->addExtraClass('form-control'), TextField::create('ArrivalDate', 'Arrive on...')->setAttribute('data-datepicker', true)->setAttribute('data-date-format', 'DD-MM-YYYY')->addExtraClass('form-control'), DropdownField::create('Nights', 'Stay for...')->setSource($nights)->addExtraClass('form-control'), DropdownField::create('Bedrooms')->setSource(ArrayLib::valuekey(range(1, 5)))->addExtraClass('form-control'), DropdownField::create('Bathrooms')->setSource(ArrayLib::valuekey(range(1, 5)))->addExtraClass('form-control'), DropdownField::create('MinPrice', 'Min. price')->setEmptyString('-- any --')->setSource($prices)->addExtraClass('form-control'), DropdownField::create('MaxPrice', 'Max. price')->setEmptyString('-- any --')->setSource($prices)->addExtraClass('form-control')), FieldList::create(FormAction::create('doPropertySearch', 'Search')->addExtraClass('btn-lg btn-fullcolor')));
$form->setFormMethod('GET')->setFormAction($this->Link())->disableSecurityToken()->loadDataFrom($this->request->getVars());
return $form;
}
示例11: getCmsExtraFields
/**
* @return FieldSet
*/
public function getCmsExtraFields($time)
{
switch ($this->Type) {
case 'Single':
$quantity = new ReadonlyField('OneAvailable', 'Quantity', '(One available)');
break;
case 'Limited':
$quantity = new DropdownField('BookingQuantity', 'Quantity', ArrayLib::valuekey(range(1, $this->getAvailableForEvent($time))), null, null, true);
break;
case 'Unlimited':
$quantity = new NumericField('BookingQuantity', 'Quantity');
break;
}
return new FieldSet(new ReadonlyField('Title', 'Resource title', $this->Title), $quantity);
}
示例12: allowedThemes
/**
* Return the themes that can be used with this subsite, as an array of themecode => description
*/
function allowedThemes()
{
if ($themes = $this->stat('allowed_themes')) {
return ArrayLib::valuekey($themes);
} else {
$themes = array();
if (is_dir('../themes/')) {
foreach (scandir('../themes/') as $theme) {
if ($theme[0] == '.') {
continue;
}
$theme = strtok($theme, '_');
$themes[$theme] = $theme;
}
ksort($themes);
}
return $themes;
}
}
示例13: getCMSFields
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->removeFieldFromTab('Root', 'ViewerGroups');
$viewersOptionsSource['LoggedInUsers'] = _t('TimedNotice.ACCESSLOGGEDIN', 'Logged-in users');
$viewersOptionsSource['OnlyTheseUsers'] = _t('TimedNotice.ACCESSONLYTHESE', 'Only these people (choose from list)');
$fields->addFieldToTab('Root.Main', $canViewTypeField = OptionsetField::create("CanViewType", _t('TimedNotice.ACCESSHEADER', "Who should see this notice?"), $viewersOptionsSource));
$groupsMap = Group::get()->map('ID', 'Breadcrumbs')->toArray();
asort($groupsMap);
$fields->addFieldToTab('Root.Main', $viewerGroupsField = ListboxField::create("ViewerGroups", _t('TimedNotice.VIEWERGROUPS', "Only people in these groups"))->setMultiple(true)->setSource($groupsMap)->setAttribute('data-placeholder', _t('TimedNotice.GroupPlaceholder', 'Click to select group')));
$viewerGroupsField->displayIf("CanViewType")->isEqualTo("OnlyTheseUsers");
$fields->addFieldToTab('Root.Main', DropdownField::create('MessageType', 'Message Type', ArrayLib::valuekey($this->config()->get('message_types'))), 'Message');
$fields->addFieldToTab('Root.Main', ReadonlyField::create('TZNote', 'Note', sprintf(_t('TimedNotice.TZNote', 'Your dates and times should be based on the server timezone: %s'), date_default_timezone_get())), 'StartTime');
$start = $fields->dataFieldByName('StartTime');
$end = $fields->dataFieldByName('EndTime');
$start->getDateField()->setConfig('showcalendar', true);
$end->getDateField()->setConfig('showcalendar', true);
$start->setTimeField(TimePickerField::create('StartTime[time]', '')->addExtraClass('fieldgroup-field'));
$end->setTimeField(TimePickerField::create('EndTime[time]', '')->addExtraClass('fieldgroup-field'));
return $fields;
}
示例14: getCMSFields
public function getCMSFields()
{
if ($this->List) {
$opts = array('random' => 'A random list of objects', 'query' => 'A specific list of objects');
} else {
$opts = array('static' => 'A static value', 'random' => 'A random object', 'query' => 'A specific object');
}
$map = ArrayLib::valuekey(ClassInfo::subclassesFor('DataObject'));
unset($map['DataObject']);
foreach ($map as $k => $class) {
if (ClassInfo::classImplements($class, 'TestOnly')) {
unset($map[$class]);
}
}
ksort($map);
$f = FieldList::create(TabSet::create('Root'));
$f->addFieldToTab('Root.Main', ReadonlyField::create('Variable', 'Variable name'));
$f->addFieldToTab('Root.Main', OptionsetField::create('ValueType', 'Value type', $opts));
$f->addFieldToTab('Root.Main', DropdownField::create('RecordClass', 'Object type', $map)->displayIf('ValueType')->isEqualTo('random')->orIf('ValueType')->isEqualTo('query')->end());
$f->addFieldToTab('Root.Main', TextField::create('Value')->displayIf('ValueType')->isEqualTo('static')->end());
$f->addFieldToTab('Root.Main', TextField::create('Query', 'Query string')->displayIf('ValueType')->isEqualTo('query')->end()->setDescription('E.g. Name:StartsWith=Uncle&Status=Awesome'));
return $f;
}
示例15: getCMSFields
public function getCMSFields()
{
Requirements::javascript(USERSUBMISSIONPAGES_DIR . '/javascript/userformpages.js');
Requirements::css(USERSUBMISSIONPAGES_DIR . '/css/userformpages.css');
$self = $this;
$this->beforeUpdateCMSFields(function ($fields) use($self) {
//
// WARNING: Some of the fields here are moved with 'insertAfter' after
// $this->extend('updateCMSFields') is called, so their location is immutable.
// However, any other data to do with the field can be modified.
//
// Add dropdown that defines what page type gets created.
$pageTypes = array();
foreach (UserSubmissionExtension::get_classes_extending() as $class) {
$pageTypes[$class] = singleton($class)->singular_name();
}
$field = null;
if ($pageTypes && count($pageTypes) > 1) {
$fields->push($field = DropdownField::create('SubmissionPageClassName', null, $pageTypes));
} else {
if ($pageTypes) {
// Seperated into *_Readonly so the value can look nice and use the 'singular_name'.
$fields->push($field = ReadonlyField::create('SubmissionPageClassName_Readonly', null, reset($pageTypes)));
}
}
if ($field) {
$field->setTitle('Submission Page Type');
$field->setRightTitle('The page type to create underneath this page when a submission is approved.');
}
// Add dropdown that defines what field is used for the Page title of the published
// submission listing items
$userFields = $self->InputFields()->map('Name', 'Title');
if (!$userFields instanceof ArrayList) {
$userFields = $userFields->toArray();
}
if ($self->SubmissionPageTitleField && !isset($userFields[$self->SubmissionPageTitleField])) {
// If set value isn't in dropdown, make it appear in there.
$userFields[$self->SubmissionPageTitleField] = '<Field Deleted>';
} else {
if (!$self->SubmissionPageTitleField) {
$userFields = array_merge(array('' => '(Select Field)'), $userFields);
}
}
$fields->push($field = DropdownField::create('SubmissionPageTitleField', 'Submission Page Title Field', $userFields));
$field->setRightTitle('Be careful when modifying this value as it will change the "Title" and "Menu Title" of all your child pages.');
// Update 'Submissions' gridfield to show the current state of a submission
$submissionsGridField = $fields->dataFieldByName('Submissions');
if ($submissionsGridField) {
$class = $submissionsGridField->getList()->dataClass();
$displayFields = ArrayLib::valuekey($class::config()->summary_fields);
$displayFields['CMSState'] = 'State';
$submissionsGridField->getConfig()->getComponentByType('GridFieldDataColumns')->setDisplayFields($displayFields);
}
// Add content
$instructions = '';
foreach ($self->ContentVariables() as $varname => $data) {
$value = isset($data['Help']) ? $data['Help'] : $data['Value'];
$instructions .= $varname . ' = ' . Convert::raw2xml($value) . '<br/>';
}
$field = $fields->dataFieldByName('Content');
if ($field) {
$field->setTitle($field->Title() . ' (Listing)');
$field->setRightTitle($instructions);
}
$fields->addFieldToTab('Root.Submissions', NumericField::create('ItemsPerPage')->setRightTitle('If set to 0, then show all items.'));
$fields->addFieldToTab('Root.Submissions', $field = HtmlEditorField::create('ContentAdd', 'Content (Form)'));
$field->setRightTitle($instructions);
// Add templating
$fields->addFieldToTab('Root.Main', $field = TextareaField::create('TemplateHolderMarkup', 'Template Holder')->setRows(10));
$fields->addFieldToTab('Root.Main', $field = TextareaField::create('TemplatePageMarkup', 'Template Page')->setRows(10));
// Add search info
if ($self->config()->enable_search_form) {
$fields->addFieldToTab('Root.Main', $field = ReadonlyField::create('Search_EnableOnSearchForm_Readonly', 'Search Form Fields'));
$field->setValue(implode(', ', $self->Fields()->filter('EnableOnSearchForm', true)->map('ID', 'Title')->toArray()));
$field->setRightTitle('Fields that currently have "Show field on search form?" checked in their options.');
$fields->addFieldToTab('Root.Main', $field = ReadonlyField::create('Search_UseInKeywordSearch_Readonly', 'Search Form Fields in Keyword Search'));
$field->setValue(implode(', ', $self->Fields()->filter('UseInKeywordSearch', true)->map('ID', 'Title')->toArray()));
$field->setRightTitle('Fields that currently have "Use for "Keywords" field search?" checked in their options.');
}
// Update Email Recipients gridfield to use custom email recipient class
$gridField = $fields->dataFieldByName('EmailRecipients');
if ($gridField) {
$gridField->setModelClass('UserSubmissionHolder_EmailRecipient');
}
});
$fields = parent::getCMSFields();
if ($field = $fields->dataFieldByName('Search_UseInKeywordSearch_Readonly')) {
$fields->insertAfter($field, 'Fields');
}
if ($field = $fields->dataFieldByName('Search_EnableOnSearchForm_Readonly')) {
$fields->insertAfter($field, 'Fields');
}
if ($field = $fields->dataFieldByName('TemplatePageMarkup')) {
$fields->insertAfter($field, 'Fields');
$this->insertCMSTemplateAddFieldButtons($fields, 'TemplatePageMarkup');
}
if ($field = $fields->dataFieldByName('TemplateHolderMarkup')) {
$fields->insertAfter($field, 'Fields');
$this->insertCMSTemplateAddFieldButtons($fields, 'TemplateHolderMarkup');
}
//.........这里部分代码省略.........