当前位置: 首页>>代码示例>>PHP>>正文


PHP FormField::name_to_label方法代码示例

本文整理汇总了PHP中FormField::name_to_label方法的典型用法代码示例。如果您正苦于以下问题:PHP FormField::name_to_label方法的具体用法?PHP FormField::name_to_label怎么用?PHP FormField::name_to_label使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FormField的用法示例。


在下文中一共展示了FormField::name_to_label方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getHeading

 /**
  * Gets the heading, or label, for the interface, e.g. "Select the categories for this product"
  *
  * @return string
  */
 public function getHeading()
 {
     if (!$this->get('Heading')) {
         return FormField::name_to_label($this->getParentNode()->transform("BedrockComponent")->getName());
     }
     return $this->get('Heading');
 }
开发者ID:Tangdongle,项目名称:SilverSmith,代码行数:12,代码来源:BedrockInterface.php

示例2: updateCMSFields

 public function updateCMSFields(FieldList $fields)
 {
     $extFields = self::$db;
     $fields->removeByName(array_keys($extFields));
     if (!$this->owner->WordpressID) {
         return;
     }
     $compositeFields = array();
     foreach ($extFields as $name => $type) {
         $value = $this->owner->getField($name);
         $compositeFields[$name] = ReadonlyField::create($name . '_Readonly', FormField::name_to_label($name), $value);
     }
     if ($compositeFields) {
         $wordpressCompositeField = ToggleCompositeField::create('WordpressCompositeField', 'Wordpress', $compositeFields)->setHeadingLevel(4);
         if ($fields->fieldByName('Metadata')) {
             $fields->insertBefore($wordpressCompositeField, 'Metadata');
         } else {
             if ($fields->fieldByName('Root')) {
                 $fields->addFieldToTab('Root.Main', $wordpressCompositeField);
             } else {
                 $fields->push($wordpressCompositeField);
             }
         }
     }
 }
开发者ID:silbinarywolf,项目名称:silverstripe-wordpressmigrationtools,代码行数:25,代码来源:WordpressImportDataExtension.php

示例3: handlePost

 protected function handlePost(array $data, $settings = [])
 {
     $post = ['ID' => isset($data['id']) && isset($data['id']['videoId']) ? $data['id']['videoId'] : '0', 'Author' => isset($data['snippet']) && isset($data['snippet']['channelTitle']) ? \FormField::name_to_label($data['snippet']['channelTitle']) : '', 'AuthorID' => isset($data['snippet']) && isset($data['snippet']['channelId']) ? $data['snippet']['channelId'] : 0, 'AuthorURL' => isset($data['snippet']) && isset($data['snippet']['channelId']) ? \Controller::join_links($this->url, 'channel', $data['snippet']['channelId']) : '', 'Title' => isset($data['snippet']) && isset($data['snippet']['title']) ? $data['snippet']['title'] : '', 'Content' => isset($data['snippet']) && isset($data['snippet']['description']) ? $this->textParser()->text($data['snippet']['description']) : '', 'Priority' => isset($data['snippet']) && isset($data['snippet']['publishedAt']) ? strtotime($data['snippet']['publishedAt']) : 0, 'Posted' => isset($data['snippet']) && isset($data['snippet']['publishedAt']) ? \DBField::create_field('SS_Datetime', strtotime($data['snippet']['publishedAt'])) : null];
     if (isset($data['snippet']) && isset($data['snippet']['thumbnails'])) {
         if (isset($data['snippet']['thumbnails']['high']) && isset($data['snippet']['thumbnails']['high']['url'])) {
             $post['Cover'] = $data['snippet']['thumbnails']['high']['url'];
         } else {
             if (isset($data['snippet']['thumbnails']['medium']) && isset($data['snippet']['thumbnails']['medium']['url'])) {
                 $post['Cover'] = $data['snippet']['thumbnails']['medium']['url'];
             } else {
                 if (isset($data['snippet']['thumbnails']['default']) && isset($data['snippet']['thumbnails']['default']['url'])) {
                     $post['Cover'] = $data['snippet']['thumbnails']['default']['url'];
                 }
             }
         }
     }
     if ($post['ID']) {
         $params = (array) singleton('env')->get('Youtube.video_params');
         if (isset($settings['videoParams'])) {
             $params = array_merge($params, (array) $settings['videoParams']);
         }
         $params['v'] = $post['ID'];
         $post['Link'] = \Controller::join_links($this->url, 'watch', '?' . http_build_query($params));
         $this->setFromEmbed($post);
     }
     if (isset($post['ObjectDescription']) && $post['ObjectDescription'] == $post['Content']) {
         unset($post['ObjectDescription']);
     }
     if (isset($post['Description']) && $post['Description'] == $post['Content']) {
         unset($post['Description']);
     }
     return $post;
 }
开发者ID:spekulatius,项目名称:ss-social-feed,代码行数:33,代码来源:Youtube.php

示例4: __construct

 /**
  * @param string $name Identifier
  * @param string $title (Optional) Natural language title of the tabset
  * @param Tab|TabSet $unknown All further parameters are inserted as children into the TabSet
  */
 public function __construct($name)
 {
     $args = func_get_args();
     $name = array_shift($args);
     if (!is_string($name)) {
         user_error('TabSet::__construct(): $name parameter to a valid string', E_USER_ERROR);
     }
     $this->name = $name;
     $this->id = $name;
     // Legacy handling: only assume second parameter as title if its a string,
     // otherwise it might be a formfield instance
     if (isset($args[0]) && is_string($args[0])) {
         $title = array_shift($args);
     }
     $this->title = isset($title) ? $title : FormField::name_to_label($name);
     if ($args) {
         foreach ($args as $tab) {
             $isValidArg = is_object($tab) && (!$tab instanceof Tab || !$tab instanceof TabSet);
             if (!$isValidArg) {
                 user_error('TabSet::__construct(): Parameter not a valid Tab instance', E_USER_ERROR);
             }
             $tab->setTabSet($this);
         }
     }
     parent::__construct($args);
 }
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:31,代码来源:TabSet.php

示例5: getAreasForPageType

 /**
  * Gets an array of all areas defined for the current theme that are compatible
  * with pages of type $class
  * @param string $class
  * @return array $areas
  **/
 public function getAreasForPageType($class)
 {
     $areas = $this->getAreasForTheme(null, false);
     if (!$areas) {
         return false;
     }
     foreach ($areas as $area => $config) {
         if (!is_array($config)) {
             continue;
         }
         if (isset($config['except'])) {
             $except = $config['except'];
             if (is_array($except) ? in_array($class, $except) : $except == $class) {
                 unset($areas[$area]);
                 continue;
             }
         }
         if (isset($config['only'])) {
             $only = $config['only'];
             if (is_array($only) ? !in_array($class, $only) : $only != $class) {
                 unset($areas[$area]);
                 continue;
             }
         }
     }
     if (count($areas)) {
         foreach ($areas as $k => $v) {
             $areas[$k] = FormField::name_to_label($k);
         }
         return $areas;
     } else {
         return $areas;
     }
 }
开发者ID:mhssmnn,项目名称:silverstripe-blocks,代码行数:40,代码来源:BlockManager.php

示例6: updateFieldLabels

 public function updateFieldLabels(&$labels)
 {
     foreach (array('db', 'has_one', 'has_many', 'many_many', 'belongs_many_many') as $type) {
         if (property_exists(__CLASS__, $type)) {
             foreach (self::${$type} as $name => $val) {
                 $labels[$name] = _t(__CLASS__ . ".{$type}_{$name}", FormField::name_to_label($name));
             }
         }
     }
 }
开发者ID:helpfulrobot,项目名称:plishkin-ss-mapael,代码行数:10,代码来源:MapaelCountryHolderPageExtension.php

示例7: updateCMSFields

 /**
  * @param FieldList $fields
  * @return FieldList
  */
 public function updateCMSFields(FieldList $fields)
 {
     if ($this->currencyService instanceof CurrencyServiceInterface) {
         foreach ($this->currencyService->getCurrencies() as $currency) {
             $columnName = $this->getColumnName($currency);
             $fields->removeByName($columnName);
             $fields->addFieldToTab('Root.Prices', new NumericField($columnName, \FormField::name_to_label($columnName)));
         }
     }
     return $fields;
 }
开发者ID:heyday,项目名称:heystack-ecommerce-coredb,代码行数:15,代码来源:PricingByCurrencyExtension.php

示例8: __construct

 public function __construct($name)
 {
     Requirements::css(RIGHTSIDEBAR_DIR . '/css/cms.css');
     Requirements::javascript(RIGHTSIDEBAR_DIR . '/js/cms.js');
     $args = func_get_args();
     $name = array_shift($args);
     if (!is_string($name)) {
         user_error('RightSidebar::__construct(): $name parameter to a valid string', E_USER_ERROR);
     }
     $this->name = $name;
     $this->id = preg_replace('/[^0-9A-Za-z]+/', '', $name);
     $this->title = isset($title) ? $title : FormField::name_to_label($name);
     parent::__construct($args);
 }
开发者ID:helpfulrobot,项目名称:micschk-silverstripe-rightsidebar,代码行数:14,代码来源:RightSidebar.php

示例9: getLockedMessage

 /**
  * Generates the edit lock warning message displayed to the user
  * @return String
  **/
 public function getLockedMessage()
 {
     $editor = $this->Editor();
     $editorString = $editor->getTitle();
     if ($editor->Email) {
         $editorString .= " &lt;<a href='mailto:{$editor->Email}'>{$editor->Email}</a>&gt;";
     }
     $message = sprintf(_t('RecordBeingEdited.LOCKEDMESSAGE', 'Sorry, this %s is currently being edited by %s. To avoid conflicts and data loss, editing will be locked until they are finished.'), FormField::name_to_label($this->RecordClass), $editorString);
     if ($this->canEditAnyway()) {
         $editAnywayLink = Controller::join_links(Controller::curr()->getRequest()->requestVar('url'), '?editanyway=1');
         $message .= "<span style='float:right'>";
         $message .= sprintf(_t('RecordBeingEdited.EDITANYWAY', 'I understand the risks, %s edit anyway %s'), "<a href='{$editAnywayLink}'>", "</a>");
         $message .= "</span>";
     }
     return $message;
 }
开发者ID:sheadawson,项目名称:silverstripe-editlock,代码行数:20,代码来源:RecordBeingEdited.php

示例10: __construct

 /**
  * @uses FormField::name_to_label()
  * 
  * @param string $name Identifier of the tab, without characters like dots or spaces
  * @param string $title Natural language title of the tab. If its left out,
  *  the class uses {@link FormField::name_to_label()} to produce a title from the {@link $name} parameter.
  * @param FormField All following parameters are inserted as children to this tab
  */
 public function __construct($name)
 {
     $args = func_get_args();
     $name = array_shift($args);
     if (!is_string($name)) {
         user_error('TabSet::__construct(): $name parameter to a valid string', E_USER_ERROR);
     }
     $this->name = $name;
     $this->id = preg_replace('/[^0-9A-Za-z]+/', '', $name);
     // Legacy handling: only assume second parameter as title if its a string,
     // otherwise it might be a formfield instance
     if (isset($args[0]) && is_string($args[0])) {
         $title = array_shift($args);
     }
     $this->title = isset($title) ? $title : FormField::name_to_label($name);
     parent::__construct($args);
 }
开发者ID:racontemoi,项目名称:shibuichi,代码行数:25,代码来源:Tab.php

示例11: getCMSFields

 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->addFieldToTab('Root', new TabSet('Profile', _t('MemberProfiles.PROFILE', 'Profile')));
     $fields->addFieldToTab('Root', new Tab('ContentBlocks', _t('MemberProfiles.CONTENTBLOCKS', 'Content Blocks')));
     $fields->addFieldToTab('Root', new Tab('Email', _t('MemberProfiles.Email', 'Email')));
     $fields->fieldByName('Root.Main')->setTitle(_t('MemberProfiles.MAIN', 'Main'));
     $fields->addFieldsToTab('Root.Profile', array(new Tab('Fields', _t('MemberProfiles.FIELDS', 'Fields'), new GridField('Fields', _t('MemberProfiles.PROFILEFIELDS', 'Profile Fields'), $this->Fields(), $grid = GridFieldConfig_RecordEditor::create()->removeComponentsByType('GridFieldDeleteAction')->removeComponentsByType('GridFieldAddNewButton'))), new Tab('Groups', _t('MemberProfiles.GROUPS', 'Groups'), $groups = new TreeMultiselectField('Groups', _t('MemberProfiles.GROUPS', 'Groups'), 'Group'), $selectable = new TreeMultiselectField('SelectableGroups', _t('MemberProfiles.SELECTABLEGROUPS', 'Selectable Groups'), 'Group')), new Tab('PublicProfile', _t('MemberProfiles.PUBLICPROFILE', 'Public Profile'), new GridField('Sections', _t('MemberProfiles.PROFILESECTIONS', 'Profile Sections'), $this->Sections(), GridFieldConfig_RecordEditor::create()->removeComponentsByType('GridFieldAddNewButton')->addComponent(new MemberProfilesAddSectionAction())))));
     $grid->getComponentByType('GridFieldDataColumns')->setFieldFormatting(array('Unique' => function ($val, $obj) {
         return $obj->dbObject('Unique')->Nice();
     }, 'Required' => function ($val, $obj) {
         return $obj->dbObject('Required')->Nice();
     }));
     if (class_exists('GridFieldOrderableRows')) {
         $grid->addComponent(new GridFieldOrderableRows('Sort'));
     } elseif (class_exists('GridFieldSortableRows')) {
         $grid->addComponent(new GridFieldSortableRows('Sort'));
     }
     if (!$this->AllowProfileViewing) {
         $disabledNote = new LiteralField('PublisProfileDisabledNote', sprintf('<p class="message notice">%s</p>', _t('MemberProfiles.PUBLICPROFILEDISABLED', 'Public profiles are currently disabled, you can enable them ' . 'in the "Settings" tab.')));
         $fields->insertBefore($disabledNote, 'Sections');
     }
     $groups->setDescription(_t('MemberProfiles.GROUPSNOTE', 'Any users registering via this page will always be added to ' . 'these groups (if registration is enabled). Conversely, a member ' . 'must belong to these groups in order to edit their profile on ' . 'this page.'));
     $selectable->setDescription(_t('MemberProfiles.SELECTABLENOTE', 'Users can choose to belong to these groups, if the  "Groups" field ' . 'is enabled in the "Fields" tab.'));
     $fields->removeByName('Content', true);
     $contentFields = array();
     if ($this->AllowRegistration) {
         $contentFields[] = 'Registration';
         $contentFields[] = 'AfterRegistration';
     }
     if ($this->AllowProfileEditing) {
         $contentFields[] = 'Profile';
     }
     foreach ($contentFields as $type) {
         $fields->addFieldToTab("Root.ContentBlocks", new ToggleCompositeField("{$type}Toggle", _t('MemberProfiles.' . strtoupper($type), FormField::name_to_label($type)), array(new TextField("{$type}Title", _t('MemberProfiles.TITLE', 'Title')), $content = new HtmlEditorField("{$type}Content", _t('MemberProfiles.CONTENT', 'Content')))));
         $content->setRows(15);
     }
     $fields->addFieldsToTab('Root.Email', array(new OptionsetField('EmailType', _t('MemberProfiles.EMAILSETTINGS', 'Email Settings'), array('Validation' => _t('MemberProfiles.EMAILVALIDATION', 'Require email validation'), 'Confirmation' => _t('MemberProfiles.EMAILCONFIRMATION', 'Send a confirmation email'), 'None' => _t('MemberProfiles.NONE', 'None'))), new ToggleCompositeField('EmailContentToggle', _t('MemberProfiles.EMAILCONTENT', 'Email Content'), array(new TextField('EmailSubject', _t('MemberProfiles.EMAILSUBJECT', 'Email subject')), new TextField('EmailFrom', _t('MemberProfiles.EMAILFROM', 'Email from')), new TextareaField('EmailTemplate', _t('MemberProfiles.EMAILTEMPLATE', 'Email template')), new LiteralField('TemplateNote', sprintf('<div class="field">%s</div>', MemberConfirmationEmail::TEMPLATE_NOTE)))), new ToggleCompositeField('ConfirmationContentToggle', _t('MemberProfiles.CONFIRMCONTENT', 'Confirmation Content'), array(new TextField('ConfirmationTitle', _t('MemberProfiles.TITLE', 'Title')), $confContent = new HtmlEditorField('ConfirmationContent', _t('MemberProfiles.CONTENT', 'Content'))))));
     $confContent->setRows(15);
     return $fields;
 }
开发者ID:SilbinaryWolf,项目名称:silverstripe-memberprofiles,代码行数:41,代码来源:MemberProfilePage.php

示例12: __call

 /**
  * A wildcard method for accepting any FormField object as a method.
  * Ex: text(), currency(), dropdown(), treeDropdown(), htmlEditor()
  *
  * @param   string The method being called
  * @param   array The arguments to the method
  * @return  FieldList
  */
 public function __call($method, $args)
 {
     $formFieldClass = ucfirst($method) . "Field";
     $getter = "get" . ucfirst($method);
     if ($this->owner->hasMethod($getter)) {
         return $this->owner->{$getter}();
     }
     if (is_subclass_of($formFieldClass, "FormField")) {
         if (!isset($args[0])) {
             user_error("FieldList::{$method} -- Missing argument 1 for field name", E_ERROR);
         }
         if (!isset($args[1])) {
             $args[1] = FormField::name_to_label($args[0]);
         }
         $field = Injector::inst()->createWithArgs($formFieldClass, $args);
         $this->add($field);
         $this->field = $field;
         $field->FieldList = $this->owner;
         return $this->owner;
     } else {
         user_error("FieldList::{$method} -- {$formFieldClass} is not a FormField.", E_ERROR);
     }
 }
开发者ID:helpfulrobot,项目名称:unclecheese-zen-fields,代码行数:31,代码来源:ZenFields.php

示例13: collectFromEntityProviders

 public function collectFromEntityProviders($filePath, $module = null)
 {
     $entities = [];
     // HACK Ugly workaround to avoid "Cannot redeclare class PHPUnit_Framework_TestResult" error
     // when running text collector with PHPUnit 3.4. There really shouldn't be any dependencies
     // here, but the class reflection enforces autloading of seemingly unrelated classes.
     // The main problem here is the CMSMenu class, which iterates through test classes,
     // which in turn trigger autoloading of PHPUnit.
     $phpunitwrapper = PhpUnitWrapper::inst();
     $phpunitwrapper->init();
     $classes = ClassInfo::classes_for_file($filePath);
     if ($classes) {
         foreach ($classes as $class) {
             // Not all classes can be instanciated without mandatory arguments,
             // so entity collection doesn't work for all SilverStripe classes currently
             // Requires PHP 5.1+
             if (class_exists($class) && in_array('i18nEntityProvider', class_implements($class))) {
                 $reflectionClass = new ReflectionClass($class);
                 if ($reflectionClass->isAbstract()) {
                     continue;
                 }
                 $obj = singleton($class);
                 $entities = array_merge($entities, (array) $obj->provideI18nEntities());
                 if ($obj->is_a('DataObject')) {
                     foreach (['db', 'has_one', 'has_many', 'many_many', 'belongs_many_many'] as $type) {
                         foreach ((array) Config::inst()->get($obj->class, $type, Config::UNINHERITED) as $name => $spec) {
                             $entities["{$obj->class}.{$type}_{$name}"] = [FormField::name_to_label($name)];
                         }
                     }
                 }
             }
         }
     }
     ksort($entities);
     return $entities;
 }
开发者ID:helpfulrobot,项目名称:zauberfisch-silverstripe-better-i18n,代码行数:36,代码来源:BetterI18nTextCollector.php

示例14: addprovider

 /**
  * Add a new provider (triggered by the ExternalContentAdmin_left template)
  *
  * @return unknown_type
  */
 public function addprovider()
 {
     // Providers are ALWAYS at the root
     $parent = 0;
     $name = isset($_REQUEST['Name']) ? basename($_REQUEST['Name']) : _t('ExternalContent.NEWCONNECTOR', "New Connector");
     $type = $_REQUEST['ProviderType'];
     $providerClasses = ClassInfo::subclassesFor(self::$tree_class);
     if (!in_array($type, $providerClasses)) {
         throw new Exception("Invalid connector type");
     }
     $parentObj = null;
     // Create object
     $record = new $type();
     $record->ParentID = $parent;
     $record->Name = $record->Title = $name;
     // if (isset($_REQUEST['returnID'])) {
     // 	return $p->ID;
     // } else {
     // 	return $this->returnItemToUser($p);
     // }
     try {
         $record->write();
     } catch (ValidationException $ex) {
         $form->sessionMessage($ex->getResult()->message(), 'bad');
         return $this->getResponseNegotiator()->respond($this->request);
     }
     singleton('CMSPageEditController')->setCurrentPageID($record->ID);
     Session::set("FormInfo.Form_EditForm.formError.message", sprintf(_t('ExternalContent.SourceAdded', 'Successfully created %s'), $type));
     Session::set("FormInfo.Form_EditForm.formError.type", 'good');
     $msg = "New " . FormField::name_to_label($type) . " created";
     $this->response->addHeader('X-Status', rawurlencode(_t('ExternalContent.PROVIDERADDED', $msg)));
     return $this->getResponseNegotiator()->respond($this->request);
 }
开发者ID:nyeholt,项目名称:silverstripe-external-content,代码行数:38,代码来源:ExternalContentAdmin.php

示例15: getDashletsList

 public function getDashletsList()
 {
     if ($this->allowedDashlets) {
         return $this->allowedDashlets;
     }
     $dashlets = self::get_allowed_dashlets();
     // prune any that have specific requirements
     foreach ($dashlets as $cls => $title) {
         $clazz = is_int($cls) ? $title : $cls;
         $dummy = singleton($clazz);
         if (!$dummy->canCreate()) {
             unset($dashlets[$cls]);
         }
     }
     $keys = array_keys($dashlets);
     if (count($keys) && is_int($keys[0])) {
         foreach (array_values($dashlets) as $dashletClass) {
             $title = Config::inst()->get($dashletClass, 'title');
             if (!$title) {
                 FormField::name_to_label($dashletClass);
             }
             $this->allowedDashlets[$dashletClass] = $title;
         }
     } else {
         $this->allowedDashlets = $dashlets;
     }
     return $this->allowedDashlets;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-frontend-dashboards,代码行数:28,代码来源:DashboardController.php


注:本文中的FormField::name_to_label方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。