當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ArrayLib::valuekey方法代碼示例

本文整理匯總了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;
 }
開發者ID:philbenoit,項目名稱:silverstripe-mandrill,代碼行數:7,代碼來源:EmailTemplatesAdmin.php

示例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');
 }
開發者ID:fanggu,項目名稱:loveyourwater_ss_v3.1.6,代碼行數:11,代碼來源:ClassInfoTest.php

示例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;
 }
開發者ID:sachithranuwan,項目名稱:one-ring-rentals,代碼行數:9,代碼來源:Property.php

示例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;
 }
開發者ID:wernerkrauss,項目名稱:silverstripe-onepage,代碼行數:9,代碼來源:OnePageSlide.php

示例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;
 }
開發者ID:helpfulrobot,項目名稱:sheadawson-silverstripe-timednotices,代碼行數:14,代碼來源:TimedNoticeAdmin.php

示例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;
 }
開發者ID:helpfulrobot,項目名稱:silverstripe-australia-intranet-sis,代碼行數:12,代碼來源:FileListingPage.php

示例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);
     }
 }
開發者ID:antonythorpe,項目名稱:silvershop-productmodel,代碼行數:12,代碼來源:ProductModelExtension.php

示例8: testValuekey

	function testValuekey() {
		$this->assertEquals(
			ArrayLib::valuekey(
				array(
					'testkey1' => 'testvalue1',
					'testkey2' => 'testvalue2'
				)
			),
			array(
				'testvalue1' => 'testvalue1',
				'testvalue2' => 'testvalue2'
			)
		);
	}
開發者ID:redema,項目名稱:sapphire,代碼行數:14,代碼來源:ArrayLibTest.php

示例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")')))));
    }
開發者ID:Neumes,項目名稱:silverstripe-inlinehelp,代碼行數:17,代碼來源:InlineHelpTopic.php

示例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;
 }
開發者ID:lestercomia,項目名稱:onering,代碼行數:14,代碼來源:PropertySearchPage.php

示例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);
 }
開發者ID:textagroup,項目名稱:silverstripe-eventresources,代碼行數:18,代碼來源:EventResource.php

示例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;
     }
 }
開發者ID:hafriedlander,項目名稱:silverstripe-config-experiment,代碼行數:22,代碼來源:Subsite.php

示例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;
 }
開發者ID:sheadawson,項目名稱:silverstripe-timednotices,代碼行數:21,代碼來源:TimedNotice.php

示例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;
 }
開發者ID:helpfulrobot,項目名稱:smarcet-silverstripe-permamail,代碼行數:23,代碼來源:PermamailTemplateVariable.php

示例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');
     }
//.........這裏部分代碼省略.........
開發者ID:silbinarywolf,項目名稱:usersubmissionpages,代碼行數:101,代碼來源:UserSubmissionHolder.php


注:本文中的ArrayLib::valuekey方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。