• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP field_info_instances函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中field_info_instances函数的典型用法代码示例。如果您正苦于以下问题:PHP field_info_instances函数的具体用法?PHP field_info_instances怎么用?PHP field_info_instances使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: bootstrap_clean_blog_form_system_theme_settings_alter

/**
 * Implements hook_form_system_theme_settings_alter().
 */
function bootstrap_clean_blog_form_system_theme_settings_alter(&$form, $form_state, $form_id = NULL)
{
    // Work-around for a core bug affecting admin themes. See issue #943212.
    if (isset($form_id)) {
        return;
    }
    $form['instant_vertical_tabs'] = array('#type' => 'vertical_tabs', '#prefix' => '<h2><small>' . t('Bootstrap Clean Blog settings') . '</small></h2>');
    $form['header'] = array('#type' => 'fieldset', '#title' => t('Site header'), '#group' => 'instant_vertical_tabs');
    $article_fields = (array) field_info_instances('node', 'article');
    if (!empty($article_fields)) {
        foreach ($article_fields as $key => $field) {
            if ($field['widget']['type'] !== 'image_image') {
                unset($article_fields[$key]);
            } else {
                $article_fields[$key] = $field['field_name'];
            }
        }
    }
    $fields = (array) array_merge(array('none' => t('-- Select --')), $article_fields);
    $form['header']['header_image'] = array('#type' => 'select', '#title' => t('Header image'), '#options' => $fields, '#description' => t('Big image for nodes, display in header. The field must be created for all types of material.'), '#default_value' => theme_get_setting('header_image'));
    $form['social_buttons'] = array('#type' => 'fieldset', '#title' => t('Social buttons'), '#group' => 'instant_vertical_tabs');
    $form['social_buttons']['social_facebook'] = array('#type' => 'textfield', '#title' => t('Facebook'), '#default_value' => theme_get_setting('social_facebook'));
    $form['social_buttons']['social_twitter'] = array('#type' => 'textfield', '#title' => t('Twitter'), '#default_value' => theme_get_setting('social_twitter'));
    $form['social_buttons']['social_github'] = array('#type' => 'textfield', '#title' => t('Github'), '#default_value' => theme_get_setting('social_github'));
}
开发者ID:xin07crc,项目名称:iluminacionesmap,代码行数:28,代码来源:theme-settings.php


示例2: alterDependencies

 /**
  * Overrides Drupal\configuration\Config\Configuration::alterDependencies().
  */
 public static function alterDependencies(Configuration $config)
 {
     if ($config->getComponent() == 'content_type') {
         $variables = array('field_bundle_settings_node_', 'language_content_type', 'node_options', 'node_preview', 'node_submitted');
         if (module_exists('comment')) {
             $variables += array('comment', 'comment_anonymous', 'comment_controls', 'comment_default_mode', 'comment_default_order', 'comment_default_per_page', 'comment_form_location', 'comment_preview', 'comment_subject_field');
         }
         if (module_exists('menu')) {
             $variables += array('menu_options', 'menu_parent');
         }
         $entity_type = $config->getEntityType();
         $fields = field_info_instances($entity_type, $config->getIdentifier());
         foreach ($variables as $variable) {
             $identifier = $variable . '_' . $config->getIdentifier();
             $in_db = db_query("SELECT 1 FROM {variable} WHERE name = :name", array(':name' => $identifier))->fetchField();
             // Some variables are not in the database and their values are
             // provided by the second paramenter of variable_get.
             // Only inform about configurations that are indeed in the database.
             if ($in_db) {
                 $var_config = new VariableConfiguration($identifier);
                 $var_config->build();
                 $config->addToDependencies($var_config);
             }
         }
     }
 }
开发者ID:gnulugtn,项目名称:portal,代码行数:29,代码来源:VariableConfiguration.php


示例3: dxray_get_node_type

/**
 *  Получаем список NODE_TYPE
 * modules/node/node.module
 * @link https://api.drupal.org/api/drupal/modules%21node%21node.api.php/function/hook_node_info/7 description param
 * @link https://www.drupal.org/node/1027630 info
 */
function dxray_get_node_type()
{
    $GML = new GraphML();
    $optN1 = $GML->setOptionsNode()->Fill_setColor('#ccffff')->Label_setFontSize('22')->getOptions();
    $aNtypes = node_type_get_types();
    foreach ($aNtypes as $oType) {
        // 1. Сначала создаем узел NODE_TYPE
        $data['attributes'] = array('Base: ' . $oType->base, 'Type: ' . $oType->type, 'Help: ' . PHP_EOL . $oType->help . PHP_EOL, 'Custom: ' . $oType->custom, 'Modified: ' . $oType->modified, 'Locked: ' . $oType->locked, 'Disabled: ' . $oType->disabled, 'Is new: ' . $oType->is_new, 'Has title: ' . $oType->has_title, 'Title label: ' . $oType->title_label, 'Module: ' . $oType->module);
        $options['NodeFill']['color'] = '#ccffff';
        $ID_bundle = $GML->addNode($oType->name, 'UMLClassNode', $optN1, $data);
        dxray_debug_stdout('Добавили bundle номер: ' . $ID_bundle);
        // 2. Получаем поля данного контента и строем зависимости
        $fields = field_info_instances('node', $oType->type);
        foreach ($fields as $field) {
            $finfo = field_info_field($field['field_name']);
            $data['attributes'] = array('Label: ' . $field['label'], 'Required: ' . $field['required'], 'Module: ' . $finfo['module'], 'Locked: ' . $finfo['locked'], 'Cardinality: ' . $finfo['cardinality'], 'Description: ' . $field['description']);
            $dataHTML['attributes'] = array('<html>', 'Label: ' . $field['label'] . '<br>', 'Required: ' . $field['required'] . '<br>', '<b>Module:</b> ' . $finfo['module'] . '<br>', 'Locked: ' . $finfo['locked'] . '<br>', 'Cardinality: ' . $finfo['cardinality'] . '<br>', 'Description: ' . $field['description'] . '<br>', '</html>');
            $ID_field = $GML->addNode($field['field_name'], 'UMLClassNode', null, $dataHTML);
            dxray_debug_stdout('Добавили field номер: ' . $ID_field);
            dxray_debug_stdout("{EDGE} SRC: {$ID_bundle} TARGET: {$ID_field} " . $ID_field);
            $GML->addEdge($ID_bundle, $ID_field);
        }
    }
    $file = DXRAY_OUTPATH . '/NodeType-' . date('d-m-Y_H-i-s') . '.graphml';
    $GML->createFullGraphML($file);
    $dbg = 0;
}
开发者ID:JKeySZR,项目名称:GraphML,代码行数:33,代码来源:drupal.php


示例4: settingsForm

 /**
  * Implements EntityReferenceHandler::settingsForm().
  */
 public static function settingsForm($field, $instance)
 {
     $entity_info = entity_get_info($field['settings']['target_type']);
     if (!empty($entity_info['entity keys']['bundle'])) {
         $bundles = array();
         foreach ($entity_info['bundles'] as $bundle_name => $bundle_info) {
             $bundles[$bundle_name] = $bundle_info['label'];
         }
         $form['target_bundles'] = array('#type' => 'select', '#title' => t('Target bundles'), '#options' => $bundles, '#default_value' => isset($field['settings']['handler_settings']['target_bundles']) ? $field['settings']['handler_settings']['target_bundles'] : array(), '#size' => 6, '#multiple' => TRUE, '#description' => t('The bundles of the entity type that can be referenced. Optional, leave empty for all bundles.'));
     } else {
         $form['target_bundles'] = array('#type' => 'value', '#value' => array());
     }
     $form['sort']['type'] = array('#type' => 'radios', '#title' => t('Sort by'), '#options' => array('none' => t("Don't sort"), 'property' => t('A property of the base table of the entity'), 'field' => t('A field attached to this entity')), '#default_value' => isset($field['settings']['handler_settings']['sort']['type']) ? $field['settings']['handler_settings']['sort']['type'] : 'none');
     $form['sort']['property'] = array('#type' => 'select', '#title' => t('Sort property'), '#options' => drupal_map_assoc($entity_info['schema_fields_sql']['base table']), '#default_value' => isset($field['settings']['handler_settings']['sort']['property']) ? $field['settings']['handler_settings']['sort']['property'] : '', '#states' => array('visible' => array(':input[name="field[settings][handler_settings][sort][type]"]' => array('value' => 'property'))));
     $fields = array();
     foreach (field_info_instances($field['settings']['target_type']) as $bundle_name => $bundle_instances) {
         foreach ($bundle_instances as $instance_name => $instance_info) {
             $field_info = field_info_field($instance_name);
             foreach ($field_info['columns'] as $column_name => $column_info) {
                 $fields[$instance_name . ':' . $column_name] = t('@label (column @column)', array('@label' => $instance_info['label'], '@column' => $column_name));
             }
         }
     }
     $form['sort']['field'] = array('#type' => 'select', '#title' => t('Sort field'), '#options' => $fields, '#default_value' => isset($field['settings']['handler_settings']['sort']['type']) ? $field['settings']['handler_settings']['sort']['type'] : '', '#states' => array('visible' => array(':input[name="field[settings][handler_settings][sort][type]"]' => array('value' => 'field'))));
     $form['sort']['direction'] = array('#type' => 'select', '#title' => t('Sort direction'), '#options' => array('ASC' => t('Ascending'), 'DESC' => t('Descending')), '#default_value' => isset($field['settings']['handler_settings']['sort']['direction']) ? $field['settings']['handler_settings']['sort']['direction'] : 'ASC', '#states' => array('invisible' => array(':input[name="field[settings][handler_settings][sort][type]"]' => array('value' => 'none'))));
     return $form;
 }
开发者ID:leloulight,项目名称:drupal-micah-blog,代码行数:30,代码来源:EntityReference_SelectionHandler_Generic.class.php


示例5: getInstances

 /**
  * Get all instances of the given field
  *
  * @param string $name
  */
 protected function getInstances($name)
 {
     $ret = array();
     foreach (field_info_instances() as $bundles) {
         foreach ($bundles as $instance) {
             if ($instance['field_name'] === $name) {
                 $ret[] = $instance;
             }
         }
     }
     return $ret;
 }
开发者ID:makinacorpus,项目名称:drupal-usync,代码行数:17,代码来源:FieldLoader.php


示例6: getDependencies

 public function getDependencies(NodeInterface $node, Context $context)
 {
     /* @var $node EntityNode */
     $order = [];
     $bundle = $node->getBundle();
     // First, fields
     $field = [];
     foreach (field_info_instances('node', $bundle) as $instance) {
         $field[] = 'entity.node.' . $bundle . '.field.' . $instance['field_name'];
         $order[] = isset($instance['weight']) ? $instance['weight'] : 0;
     }
     array_multisort($order, $field);
     return $field;
 }
开发者ID:makinacorpus,项目名称:drupal-usync,代码行数:14,代码来源:NodeEntityLoader.php


示例7: getUserEntityFields

 /**
  * @param string $group
  *   The name of a group. Can be "locators" or "required" only.
  *
  * @return array
  *   If group is "required" that an array with labels of all required fields
  *   will be returned, if "locators" - will return an array with field names,
  *   keyed by label or machine name.
  */
 public static function getUserEntityFields($group = '')
 {
     static $results = [];
     if (empty($results)) {
         // The fields in "locators" array stored by machine name of a field and duplicates by field label.
         foreach (field_info_instances('user', 'user') as $field_name => $definition) {
             $results['locators'][$definition['label']] = $results['locators'][$field_name] = $field_name;
             if ($definition['required']) {
                 $results['required'][$field_name] = $definition['label'];
             }
         }
     }
     return empty($results[$group]) ? $results : $results[$group];
 }
开发者ID:spheresh,项目名称:behat-drupal-propeople-context,代码行数:23,代码来源:UserEntity.php


示例8: settingsForm

 /**
  * Override settings form().
  */
 public static function settingsForm($field, $instance)
 {
     $form = parent::settingsForm($field, $instance);
     $entity_type = $field['settings']['target_type'];
     $entity_info = entity_get_info($entity_type);
     $bundles = array();
     foreach ($entity_info['bundles'] as $bundle_name => $bundle_info) {
         if (og_is_group_type($entity_type, $bundle_name)) {
             $bundles[$bundle_name] = $bundle_info['label'];
         }
     }
     if (!$bundles) {
         $form['target_bundles'] = array('#type' => 'item', '#title' => t('Target bundles'), '#markup' => t('Error: The selected "Target type" %entity does not have bundles that are a group type', array('%entity' => $entity_info['label'])));
     } else {
         $settings = $field['settings']['handler_settings'];
         $settings += array('target_bundles' => array(), 'membership_type' => OG_MEMBERSHIP_TYPE_DEFAULT, 'reference_type' => 'my_groups', 'primary_field' => FALSE, 'hide_secondary_field' => TRUE);
         $form['target_bundles'] = array('#type' => 'select', '#title' => t('Target bundles'), '#options' => $bundles, '#default_value' => $settings['target_bundles'], '#size' => 6, '#multiple' => TRUE, '#description' => t('The bundles of the entity type acting as group, that can be referenced. Optional, leave empty for all bundles.'));
         $options = array();
         foreach (og_membership_type_load() as $og_membership) {
             $options[$og_membership->name] = $og_membership->description;
         }
         $form['membership_type'] = array('#type' => 'select', '#title' => t('OG membership type'), '#description' => t('Select the membership type that will be used for a subscribing user.'), '#options' => $options, '#default_value' => $settings['membership_type'], '#required' => TRUE);
         $form['reference_type'] = array('#type' => 'select', '#title' => t('Reference'), '#options' => array('my_groups' => t('My groups'), 'other_groups' => t('Other groups'), 'all_groups' => t('All groups')), '#description' => t('What groups should be referenced.'), '#default_value' => $settings['reference_type']);
         $options = array('0' => t('None'));
         // Get all the other group audience fields in this bundle.
         $entity_type = $instance['entity_type'];
         $bundle = $instance['bundle'];
         $fields_info = field_info_fields();
         foreach (field_info_instances($entity_type, $bundle) as $field_name => $field_instance) {
             if ($field_name == $field['field_name']) {
                 // This is the current field.
                 continue;
             }
             if ($fields_info[$field_name]['type'] != 'entityreference' || $fields_info[$field_name]['settings']['handler'] != 'og') {
                 // This is not an Entity reference field.
                 continue;
             }
             if (!empty($fields_info[$field_name]['settings']['handler_settings']['primary_field'])) {
                 // Field is already a secondary field.
                 continue;
             }
             $options[$field_name] = $field_instance['label'] . ' (' . $field_name . ')';
         }
         $form['primary_field'] = array('#type' => 'select', '#title' => t('Primary field'), '#description' => t('Select a field that will be populated with the values of this field.'), '#options' => $options, '#default_value' => $settings['primary_field'], '#required' => TRUE, '#element_validate' => array('og_handler_primary_field_validate'));
         $form['hide_secondary_field'] = array('#type' => 'checkbox', '#title' => t('Hide secondary field'), '#description' => t('Show the secondary field only to users with "administer group" permission.'), '#default_value' => $settings['hide_secondary_field'], '#states' => array('invisible' => array(':input[name="field[settings][handler_settings][primary_field]"]' => array('value' => 0))));
         form_load_include($form_state, 'php', 'og', '/plugins/selection/og.class');
     }
     return $form;
 }
开发者ID:natemudd,项目名称:drupal-test-environment,代码行数:52,代码来源:OgSelectionHandler.class.php


示例9: __construct

 /**
  * @param string $entity
  * @param string $bundle
  */
 public function __construct($entity, $bundle = '')
 {
     $this->entity = $entity;
     if (empty($bundle)) {
         $this->bundle = $this->entity;
     }
     // The fields in "locators" array stored by machine name of a field and duplicates by field label.
     foreach (field_info_instances($this->entity, $this->bundle) as $field_name => $definition) {
         $this->fields['locators'][$definition['label']] = $this->fields['locators'][$field_name] = $field_name;
         if ($definition['required']) {
             $this->fields['required'][$field_name] = $definition['label'];
         }
         $this->instances[$field_name] = $definition;
     }
 }
开发者ID:arrrtem,项目名称:TqExtension,代码行数:19,代码来源:EntityDrupalWrapper.php


示例10: settingsForm

 /**
  * Implements EntityReferenceHandler::settingsForm().
  */
 public static function settingsForm($field, $instance)
 {
     $entity_info = entity_get_info($field['settings']['target_type']);
     // Merge-in default values.
     $field['settings']['handler_settings'] += array('target_bundles' => array(), 'sort' => array('type' => 'none'));
     if (!empty($entity_info['entity keys']['bundle'])) {
         $bundles = array();
         foreach ($entity_info['bundles'] as $bundle_name => $bundle_info) {
             $bundles[$bundle_name] = $bundle_info['label'];
         }
         $form['target_bundles'] = array('#type' => 'checkboxes', '#title' => t('Target bundles'), '#options' => $bundles, '#default_value' => $field['settings']['handler_settings']['target_bundles'], '#size' => 6, '#multiple' => TRUE, '#description' => t('The bundles of the entity type that can be referenced. Optional, leave empty for all bundles.'), '#element_validate' => array('_entityreference_element_validate_filter'));
     } else {
         $form['target_bundles'] = array('#type' => 'value', '#value' => array());
     }
     $form['sort']['type'] = array('#type' => 'select', '#title' => t('Sort by'), '#options' => array('none' => t("Don't sort"), 'property' => t('A property of the base table of the entity'), 'field' => t('A field attached to this entity')), '#ajax' => TRUE, '#limit_validation_errors' => array(), '#default_value' => $field['settings']['handler_settings']['sort']['type']);
     $form['sort']['settings'] = array('#type' => 'container', '#attributes' => array('class' => array('entityreference-settings')), '#process' => array('_entityreference_form_process_merge_parent'));
     if ($field['settings']['handler_settings']['sort']['type'] == 'property') {
         // Merge-in default values.
         $field['settings']['handler_settings']['sort'] += array('property' => NULL);
         $form['sort']['settings']['property'] = array('#type' => 'select', '#title' => t('Sort property'), '#required' => TRUE, '#options' => drupal_map_assoc($entity_info['schema_fields_sql']['base table']), '#default_value' => $field['settings']['handler_settings']['sort']['property']);
     } elseif ($field['settings']['handler_settings']['sort']['type'] == 'field') {
         // Merge-in default values.
         $field['settings']['handler_settings']['sort'] += array('field' => NULL);
         $fields = array();
         foreach (field_info_instances($field['settings']['target_type']) as $bundle_name => $bundle_instances) {
             foreach ($bundle_instances as $instance_name => $instance_info) {
                 $field_info = field_info_field($instance_name);
                 foreach ($field_info['columns'] as $column_name => $column_info) {
                     $fields[$instance_name . ':' . $column_name] = t('@label (column @column)', array('@label' => $instance_info['label'], '@column' => $column_name));
                 }
             }
         }
         $form['sort']['settings']['field'] = array('#type' => 'select', '#title' => t('Sort field'), '#required' => TRUE, '#options' => $fields, '#default_value' => $field['settings']['handler_settings']['sort']['field']);
     }
     if ($field['settings']['handler_settings']['sort']['type'] != 'none') {
         // Merge-in default values.
         $field['settings']['handler_settings']['sort'] += array('direction' => 'ASC');
         $form['sort']['settings']['direction'] = array('#type' => 'select', '#title' => t('Sort direction'), '#required' => TRUE, '#options' => array('ASC' => t('Ascending'), 'DESC' => t('Descending')), '#default_value' => $field['settings']['handler_settings']['sort']['direction']);
     }
     // Provide an option to lock the entity reference to the current revision if
     // the entity supports it.
     if (!empty($entity_info['revision table'])) {
         $form['lock_revision'] = array('#type' => 'checkbox', '#title' => t('Lock the field to the revision of the entity at the time it was referenced.'), '#default_value' => !empty($field['settings']['handler_settings']['lock_revision']) ? TRUE : FALSE, '#description' => t('When this is enabled, the reference will track the latest revision to that entity when this field is saved. This, combined with e.g. the <a href="!url">Workbench Moderation module</a>, can be used to provide limited workflow functionality around the referenced content.', array('!url' => 'http://drupal.org/project/workbench_moderation')));
     }
     return $form;
 }
开发者ID:jhwestover,项目名称:opendata-portal,代码行数:49,代码来源:EntityReference_SelectionHandler_Generic.class.php


示例11: settingsForm

 /**
  * Implements EntityReferenceHandler::settingsForm().
  */
 public static function settingsForm($field, $instance)
 {
     $entity_info = entity_get_info($field['settings']['target_type']);
     // Merge-in default values.
     $field['settings']['handler_settings'] += array('target_bundles' => array(), 'sort' => array('type' => 'none'));
     if (!empty($entity_info['entity keys']['bundle'])) {
         $bundles = array();
         foreach ($entity_info['bundles'] as $bundle_name => $bundle_info) {
             $bundles[$bundle_name] = $bundle_info['label'];
         }
         $form['target_bundles'] = array('#type' => 'checkboxes', '#title' => t('Target bundles'), '#options' => $bundles, '#default_value' => $field['settings']['handler_settings']['target_bundles'], '#size' => 6, '#multiple' => TRUE, '#description' => t('The bundles of the entity type that can be referenced. Optional, leave empty for all bundles.'), '#element_validate' => array('_entityreference_element_validate_filter'));
     } else {
         $form['target_bundles'] = array('#type' => 'value', '#value' => array());
     }
     $form['sort']['type'] = array('#type' => 'select', '#title' => t('Sort by'), '#options' => array('none' => t("Don't sort"), 'property' => t('A property of the base table of the entity'), 'field' => t('A field attached to this entity')), '#ajax' => TRUE, '#limit_validation_errors' => array(), '#default_value' => $field['settings']['handler_settings']['sort']['type']);
     $form['sort']['settings'] = array('#type' => 'container', '#attributes' => array('class' => array('entityreference-settings')), '#process' => array('_entityreference_form_process_merge_parent'));
     if ($field['settings']['handler_settings']['sort']['type'] == 'property') {
         // Merge-in default values.
         $field['settings']['handler_settings']['sort'] += array('property' => NULL);
         $form['sort']['settings']['property'] = array('#type' => 'select', '#title' => t('Sort property'), '#required' => TRUE, '#options' => drupal_map_assoc($entity_info['schema_fields_sql']['base table']), '#default_value' => $field['settings']['handler_settings']['sort']['property']);
     } elseif ($field['settings']['handler_settings']['sort']['type'] == 'field') {
         // Merge-in default values.
         $field['settings']['handler_settings']['sort'] += array('field' => NULL);
         $fields = array();
         foreach (field_info_instances($field['settings']['target_type']) as $bundle_name => $bundle_instances) {
             foreach ($bundle_instances as $instance_name => $instance_info) {
                 $field_info = field_info_field($instance_name);
                 foreach ($field_info['columns'] as $column_name => $column_info) {
                     $fields[$instance_name . ':' . $column_name] = t('@label (column @column)', array('@label' => $instance_info['label'], '@column' => $column_name));
                 }
             }
         }
         $form['sort']['settings']['field'] = array('#type' => 'select', '#title' => t('Sort field'), '#required' => TRUE, '#options' => $fields, '#default_value' => $field['settings']['handler_settings']['sort']['field']);
     }
     if ($field['settings']['handler_settings']['sort']['type'] != 'none') {
         // Merge-in default values.
         $field['settings']['handler_settings']['sort'] += array('direction' => 'ASC');
         $form['sort']['settings']['direction'] = array('#type' => 'select', '#title' => t('Sort direction'), '#required' => TRUE, '#options' => array('ASC' => t('Ascending'), 'DESC' => t('Descending')), '#default_value' => $field['settings']['handler_settings']['sort']['direction']);
     }
     // Provide options to reference revisions if the entity supports it.
     if (!empty($entity_info['revision table'])) {
         $form['reference_revisions'] = array('#type' => 'checkbox', '#title' => t('Reference revisions'), '#default_value' => !empty($field['settings']['handler_settings']['reference_revisions']), '#description' => t('When this is enabled, the reference will track the current revision at the time it is referenced. When disabled the reference will always point to the newest revision of the entity.'));
         $form['lock_revision'] = array('#type' => 'checkbox', '#title' => t('Lock the revision.'), '#default_value' => !empty($field['settings']['handler_settings']['lock_revision']), '#description' => t('Locks the field to the revision of the entity at the time it was referenced. If this is disabled the revision will be updated each time the referencing entity is saved.'), '#states' => array('visible' => array(':input[name="field[settings][handler_settings][reference_revisions]"]' => array('checked' => TRUE))));
     }
     return $form;
 }
开发者ID:redponey,项目名称:openatrium-7.x-2.51,代码行数:49,代码来源:EntityReference_SelectionHandler_Generic.class.php


示例12: getFieldHandlers

 public static function getFieldHandlers(Entity $entity, $definition = null, $subtype = false)
 {
     $instances = \field_info_instances($entity->type(), $entity->bundle());
     $handlers = array();
     $handled = array();
     foreach ($instances as $field_name => $instance) {
         $handled[] = $field_name;
         if ($handler = self::getFieldHandler($entity->type(), $field_name, $subtype)) {
             $handlers[$field_name] = $handler;
         }
     }
     // Check special fields on the entity.
     $keys = \entity_get_info($entity->type());
     if (array_key_exists('entity keys', $keys)) {
         foreach ($keys['entity keys'] as $standard => $key) {
             $handled[] = $key;
             if ($handler = self::getTypeHandler($entity->type(), $standard, $subtype)) {
                 $handlers[$key] = $handler;
             }
         }
     }
     // Various other fields.
     foreach ($entity->definition as $key => $value) {
         if (array_search($key, $handled) !== false) {
             continue;
         }
         if ($handler = self::getTypeHandler($entity->type(), $key, $subtype)) {
             $handlers[$key] = $handler;
         }
     }
     // Get other fields on the definition.
     if (is_object($definition) || is_array($definition)) {
         foreach ($definition as $key => $value) {
             if (array_search($key, $handled) !== false) {
                 continue;
             }
             if ($handler = self::getTypeHandler($entity->type(), $key, $subtype)) {
                 $handlers[$key] = $handler;
             }
         }
     }
     return $handlers;
 }
开发者ID:sammarks,项目名称:publisher,代码行数:43,代码来源:DefinitionHandlerRegistry.php


示例13: settingsForm

 /**
  * Implements EntityReferenceHandler::settingsForm().
  */
 public static function settingsForm($field, $instance)
 {
     $entity_info = entity_get_info($field['settings']['target_type']);
     // Merge-in default values.
     $field['settings']['handler_settings'] += array('target_bundles' => array(), 'sort' => array('type' => 'none'));
     if (!empty($entity_info['entity keys']['bundle'])) {
         $bundles = array();
         foreach ($entity_info['bundles'] as $bundle_name => $bundle_info) {
             $bundles[$bundle_name] = $bundle_info['label'];
         }
         $form['target_bundles'] = array('#type' => 'checkboxes', '#title' => t('Target bundles'), '#options' => $bundles, '#default_value' => $field['settings']['handler_settings']['target_bundles'], '#size' => 6, '#multiple' => TRUE, '#description' => t('The bundles of the entity type that can be referenced. Optional, leave empty for all bundles.'), '#element_validate' => array('_entityreference_element_validate_filter'));
     } else {
         $form['target_bundles'] = array('#type' => 'value', '#value' => array());
     }
     $form['sort']['type'] = array('#type' => 'select', '#title' => t('Sort by'), '#options' => array('none' => t("Don't sort"), 'property' => t('A property of the base table of the entity'), 'field' => t('A field attached to this entity')), '#ajax' => TRUE, '#limit_validation_errors' => array(), '#default_value' => $field['settings']['handler_settings']['sort']['type']);
     $form['sort']['settings'] = array('#type' => 'container', '#attributes' => array('class' => array('entityreference-settings')), '#process' => array('_entityreference_form_process_merge_parent'));
     if ($field['settings']['handler_settings']['sort']['type'] == 'property') {
         // Merge-in default values.
         $field['settings']['handler_settings']['sort'] += array('property' => NULL);
         $form['sort']['settings']['property'] = array('#type' => 'select', '#title' => t('Sort property'), '#required' => TRUE, '#options' => drupal_map_assoc($entity_info['schema_fields_sql']['base table']), '#default_value' => $field['settings']['handler_settings']['sort']['property']);
     } elseif ($field['settings']['handler_settings']['sort']['type'] == 'field') {
         // Merge-in default values.
         $field['settings']['handler_settings']['sort'] += array('field' => NULL);
         $fields = array();
         foreach (field_info_instances($field['settings']['target_type']) as $bundle_name => $bundle_instances) {
             foreach ($bundle_instances as $instance_name => $instance_info) {
                 $field_info = field_info_field($instance_name);
                 foreach ($field_info['columns'] as $column_name => $column_info) {
                     $fields[$instance_name . ':' . $column_name] = t('@label (column @column)', array('@label' => $instance_info['label'], '@column' => $column_name));
                 }
             }
         }
         $form['sort']['settings']['field'] = array('#type' => 'select', '#title' => t('Sort field'), '#required' => TRUE, '#options' => $fields, '#default_value' => $field['settings']['handler_settings']['sort']['field']);
     }
     if ($field['settings']['handler_settings']['sort']['type'] != 'none') {
         // Merge-in default values.
         $field['settings']['handler_settings']['sort'] += array('direction' => 'ASC');
         $form['sort']['settings']['direction'] = array('#type' => 'select', '#title' => t('Sort direction'), '#required' => TRUE, '#options' => array('ASC' => t('Ascending'), 'DESC' => t('Descending')), '#default_value' => $field['settings']['handler_settings']['sort']['direction']);
     }
     return $form;
 }
开发者ID:CuBoulder,项目名称:cu-express-drops-7,代码行数:44,代码来源:EntityReference_SelectionHandler_Generic.class.php


示例14: settingsForm

 /**
  * Generate a settings form for this handler.
  */
 public function settingsForm($field, $instance)
 {
     // Current settings.
     $settings = $instance['settings']['behaviors']['autofill'];
     $widget = $instance['widget'];
     // Load available fields from instance bundle.
     $entity_type = $instance['entity_type'];
     $bundle_name = $instance['bundle'];
     $bundle_info = field_info_instances($entity_type, $bundle_name);
     // Field target metadata.
     $field_map = field_info_field_map();
     $target_type = $field['settings']['target_type'];
     $target_bundles = isset($field['settings']['handler_settings']['target_bundles']);
     $target_bundles = $target_bundles ? $field['settings']['handler_settings']['target_bundles'] : array();
     // Skip autofill for the reference field.
     unset($bundle_info[$field['field_name']]);
     // Create checkboxes options for available fields.
     $field_options = array();
     foreach ($bundle_info as $field_name => $field_info) {
         if (!empty($field_map[$field_name]['bundles'][$target_type])) {
             $available_bundles = $field_map[$field_name]['bundles'][$target_type];
             // Determine all targeted bundles that use this field.
             $option_bundles = empty($target_bundles) ? $available_bundles : array_intersect($target_bundles, $available_bundles);
             if (!empty($option_bundles)) {
                 $field_options[$field_name] = t('@field_label (@field_name): <em>Available in bundle(s) @bundles</em>', array('@field_label' => $field_info['label'], '@field_name' => $field_name, '@bundles' => implode(', ', $option_bundles)));
             }
         }
     }
     $form['overwrite'] = array('#type' => 'checkbox', '#title' => t('Overwrite existing data'), '#description' => t('Select if you want to overwrite fields that already have values. <br/><em><strong>NOTE:</strong> Disabling this is experimental and might not work 100%. If you experience issues with fields being overridden nonetheless, please report what field type and settings this occurs on in the modules issue queue on drupal.org</em>'), '#default_value' => isset($settings['overwrite']) ? $settings['overwrite'] : 1);
     if (empty($field_options)) {
         $no_fields_found = t('There are no common fields between this bundle and its referenced entities.');
         $usage_instructions = t('To use autofill, you need to add instances of the same fields to its referenced bundles.');
         $form['no_fields'] = array('#markup' => '<div class="messages warning">' . $no_fields_found . $usage_instructions . '</div>', '#type' => 'item');
     } else {
         $form['fields'] = array('#type' => 'checkboxes', '#title' => t('Fields'), '#options' => $field_options, '#description' => t('Select which fields from the referenced entity you want to load on changing the value of this field.'), '#default_value' => isset($settings['fields']) ? $settings['fields'] : array());
     }
     return $form;
 }
开发者ID:drupalconnect,项目名称:finsearches,代码行数:41,代码来源:EntityReferenceAutofillInstanceBehavior.class.php


示例15: workflow_transition_extra_form

/**
 * Implements hook_form().
 */
function workflow_transition_extra_form($form, &$form_state, $name)
{
    $workflow = workflow_load_by_name($name);
    $form_state['workflow'] = $workflow;
    $fields = workflow_transition_extra_get_workable_fields();
    $options = array('-- none --');
    foreach ($fields as $key => $fields) {
        list($type, $bundle) = explode(':', $key);
        foreach ($fields as $field) {
            $instance = field_info_instances($type, $bundle);
            $label = $instance[$field['field_name']]['label'];
            $options[$field['field_name']] = "{$label} - {$field['field_name']}";
        }
    }
    $states = $workflow->states;
    $form['transitions'] = array('#type' => 'fieldset', '#tree' => TRUE, '#title' => t('Select entityreference field contain user allowed to change state.'));
    foreach ($workflow->transitions as $transition) {
        $label = $workflow->states[$transition->sid]->name . ' --> ' . $workflow->states[$transition->target_sid]->name;
        $key = implode(':', array($transition->sid, $transition->target_sid));
        $form['transitions'][$key] = array('#title' => $label, '#type' => 'select', '#options' => $options, '#default_value' => @isset($workflow->options['transitions_extra'][$key]) ? $workflow->options['transitions_extra'][$key] : NULL);
    }
    $form['actions'] = array('#type' => 'actions', 'actions' => ['submit' => ['#type' => 'submit', '#value' => t('Submit')]]);
    return $form;
}
开发者ID:TommyTran1,项目名称:excelpoint,代码行数:27,代码来源:workflow_transition_extra.pages.php


示例16: hook_field_storage_delete

/**
 * Delete all field data for an entity.
 *
 * This hook is invoked from field_attach_delete() to ask the field storage
 * module to delete field data.
 *
 * @param $entity_type
 *   The entity type of entity, such as 'node' or 'user'.
 * @param $entity
 *   The entity on which to operate.
 * @param $fields
 *   An array listing the fields to delete. The keys and values of the
 *   array are field IDs.
 */
function hook_field_storage_delete($entity_type, $entity, $fields)
{
    list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
    foreach (field_info_instances($entity_type, $bundle) as $instance) {
        if (isset($fields[$instance['field_id']])) {
            $field = field_info_field_by_id($instance['field_id']);
            field_sql_storage_field_storage_purge($entity_type, $entity, $field, $instance);
        }
    }
}
开发者ID:rlugojr,项目名称:livereload-examples,代码行数:24,代码来源:field.api.php


示例17: displayedFieldsList

  /**
   * Helper method to get all the displayed fields for a bundle and a view_mode.
   *
   * @param string $view_mode
   *   The view mode.
   *
   * @return array
   *   An array of field names that are displayed in this view mode.
   */
  protected function displayedFieldsList($view_mode) {
    $entity_field_instances = field_info_instances($this->entityType);
    $bundle_field_instances = reset($entity_field_instances);
    if ($bundle = $this->bundle) {
      $bundle_field_instances = $entity_field_instances[$bundle];
    }
    // Traverse the field instance to get all non hidden fields.
    $displayed_fields = array_map(function ($field_instance) use ($view_mode) {
      if (empty($field_instance['display'][$view_mode]) || $field_instance['display'][$view_mode]['type'] == 'hidden' || $field_instance['deleted']) {
        return NULL;
      }
      return $field_instance['field_name'];
    }, $bundle_field_instances);

    // Remove all NULL fields.
    return array_filter(array_values($displayed_fields));
  }
开发者ID:humanitarianresponse,项目名称:site,代码行数:26,代码来源:RestfulEntityViewMode.php


示例18: build_type_field_list

function build_type_field_list($type)
{
    $names = field_info_instances('node', $type);
    $test = array();
    foreach ($names as $key) {
        $test[$key['field_name']] = $key['field_name'];
    }
    return $test;
}
开发者ID:ContentLEAD,项目名称:BraftonDrupal7Module,代码行数:9,代码来源:braftonAdmin.php


示例19: getTypes


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP field_ipv4函数代码示例发布时间:2022-05-15
下一篇:
PHP field_info_instance函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap