本文整理汇总了PHP中drupal_map_assoc函数的典型用法代码示例。如果您正苦于以下问题:PHP drupal_map_assoc函数的具体用法?PHP drupal_map_assoc怎么用?PHP drupal_map_assoc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了drupal_map_assoc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: build
public function build($form, &$form_state)
{
/** @var Remote $remote */
$remote = $this->getRemote($form_state);
$form = array('#tree' => true, 'info' => array('#type' => 'html_tag', '#tag' => 'p', '#value' => t('Select the entities you would like to send to <strong>:remote.</strong><br /><a href="#" id="deselect-all-entities">Deselect All Items</a>', array(':remote' => $remote->label))));
// If they have opted to display the forced message...
if ($this->getForced($form_state)) {
$form['forced_message'] = array('#type' => 'html_tag', '#tag' => 'p', '#value' => t('<strong>Note:</strong> It appears you have opted to force sending some entities to the ' . 'remote. If you notice a large number of entities marked as \'Must be synced,\' this is probably the ' . 'cause.'));
}
$form['entities'] = array();
$statuses = $this->getStatuses($form_state);
if (is_array($statuses)) {
foreach ($statuses as $uuid => $status) {
// Add the main form entity item.
$form_entity = array('check' => array('#type' => 'checkbox', '#disabled' => $status['required'], '#default_value' => $status['required'] || $status['root_entity'], '#attributes' => array('data-entity-uuid' => $uuid, 'class' => array('entity-checkbox'))), 'label' => array('#type' => 'html_tag', '#tag' => 'span', '#attributes' => array('class' => 'entity-label'), '#value' => $status['label']), 'status' => array('#type' => 'html_tag', '#tag' => 'span', '#value' => $status['required'] ? 'Must be synced.' : 'Can be synced.', '#attributes' => array('class' => 'status-holder')));
// Prepare the JS.
$form_entity['check']['#attached']['js'][] = array('data' => drupal_get_path('module', 'publisher') . '/js/entity_select.js');
$form_entity['check']['#attached']['js'][] = array('type' => 'setting', 'data' => array('publisher' => array($uuid => drupal_map_assoc($status['required_if']))));
$form['entities'][$uuid] = $form_entity;
}
}
$deleted_entities = publisher_deleted_entities();
if (count($deleted_entities) > 0) {
$form['deleted_entitites'] = array('#type' => 'html_tag', '#tag' => 'p', '#value' => t('Additionally, there are <strong>!count</strong> entities waiting to be deleted from @remote. Would you like to !link', array('!count' => count($deleted_entities), '@remote' => $remote->label, '!link' => l('review them now?', 'admin/reports/publisher/' . $remote->name . '/deleted', array('attributes' => array('target' => '_blank'))))));
}
if (count($form['entities']) > 0) {
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Sync Entities'));
$form['actions']['sync_all'] = array('#type' => 'submit', '#value' => t('Sync All Entities'));
$form['actions']['cancel'] = array('#type' => 'submit', '#value' => t('Cancel'));
}
return $form;
}
示例2: setTranslatableProperties
protected function setTranslatableProperties()
{
/**
* 0. Logon Options
*/
$values['authenticationModeOptions'] = array(LDAP_AUTHENTICATION_MIXED => t('Mixed mode. Drupal authentication is tried first. On failure, LDAP authentication is performed.'), LDAP_AUTHENTICATION_EXCLUSIVE => t('Only LDAP Authentication is allowed except for user 1.
If selected, (1) reset password links will be replaced with links to ldap end user documentation below.
(2) The reset password form will be left available at user/password for user 1; but no links to it
will be provided to anonymous users.
(3) Password fields in user profile form will be removed except for user 1.'));
$values['authenticationServersDescription'] = t('Check all LDAP server configurations to use in authentication.
Each will be tested for authentication until successful or
until each is exhausted. In most cases only one server configuration is selected.');
/**
* 1. User Login Interface
*/
$values['loginUIUsernameTxtDescription'] = t('Text to be displayed to user below the username field of
the user login screen.');
$values['loginUIPasswordTxtDescription'] = t('Text to be displayed to user below the password field of
the user login screen.');
$values['ldapUserHelpLinkUrlDescription'] = t('URL to LDAP user help/documentation for users resetting
passwords etc. Should be of form http://domain.com/. Could be the institutions ldap password support page
or a page within this drupal site that is available to anonymous users.');
$values['ldapUserHelpLinkTextDescription'] = t('Text for above link e.g. Account Help or Campus Password Help Page');
/**
* 2. LDAP User Restrictions
*/
$values['allowOnlyIfTextInDnDescription'] = t('A list of text such as ou=education
or cn=barclay that at least one of be found in user\'s dn string. Enter one per line
such as <pre>ou=education') . "\n" . t('ou=engineering</pre> This test will be case insensitive.');
$values['excludeIfTextInDnDescription'] = t('A list of text such as ou=evil
or cn=bad that if found in a user\'s dn, exclude them from ldap authentication.
Enter one per line such as <pre>ou=evil') . "\n" . t('cn=bad</pre> This test will be case insensitive.');
$values['allowTestPhpDescription'] = t('PHP code which should print 1
for allowing ldap authentication or 0 for not allowed. Available variables are:
$_name and $_ldap_user_entry See readme.txt for more info.');
$values['excludeIfNoAuthorizationsDescription'] = t('If the user is not granted any drupal roles,
organic groups, etc. by LDAP Authorization, login will be denied. LDAP Authorization must be
enabled for this to work.');
/**
* 4. Email
*/
$values['emailOptionOptions'] = array(LDAP_AUTHENTICATION_EMAIL_FIELD_REMOVE => t('Don\'t show an email field on user forms. LDAP derived email will be used for user and connot be changed by user'), LDAP_AUTHENTICATION_EMAIL_FIELD_DISABLE => t('Show disabled email field on user forms with LDAP derived email. LDAP derived email will be used for user and connot be changed by user'), LDAP_AUTHENTICATION_EMAIL_FIELD_ALLOW => t('Leave email field on user forms enabled. Generally used when provisioning to LDAP or not using email derived from LDAP.'));
$values['emailUpdateOptions'] = array(LDAP_AUTHENTICATION_EMAIL_UPDATE_ON_LDAP_CHANGE_ENABLE_NOTIFY => t('Update stored email if LDAP email differs at login and notify user.'), LDAP_AUTHENTICATION_EMAIL_UPDATE_ON_LDAP_CHANGE_ENABLE => t('Update stored email if LDAP email differs at login but don\'t notify user.'), LDAP_AUTHENTICATION_EMAIL_UPDATE_ON_LDAP_CHANGE_DISABLE => t('Don\'t update stored email if LDAP email differs at login.'));
/**
* 5. Single Sign-On / Seamless Sign-On
*/
$values['ldapImplementationOptions'] = array('mod_auth_sspi' => t('mod_auth_sspi'), 'mod_auth_kerb' => t('mod_auth_kerb'));
$values['cookieExpirePeriod'] = array(0 => t('Immediately')) + drupal_map_assoc(array(3600, 86400, 604800, 2592000, 31536000, 315360000), 'format_interval') + array(-1 => t('Never'));
$values['ssoEnabledDescription'] = '<strong>' . t('Single Sign on is enabled.') . '</strong> ' . t('To disable it, disable the LDAP SSO Module on the') . ' ' . l(t('Modules Form'), 'admin/modules') . '.<p>' . t('Single Sign-On enables ' . 'users of this site to be authenticated by visiting the URL ' . '"user/login/sso, or automatically if selecting "automated ' . 'single sign-on" below. Set up of LDAP authentication must be ' . 'performed on the web server. Please review the !readme file ' . 'for more information.', array('!readme' => l(t('README.txt'), drupal_get_path('module', 'ldap_sso') . '/README.txt'))) . '</p>';
$values['ssoExcludedPathsDescription'] = '<p>' . t("Which paths will not check for SSO? cron.php is common example. Specify pages by using their paths. Enter one path per line. The '*' character is a wildcard.\n Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>'));
'</p>';
$values['ssoRemoteUserStripDomainNameDescription'] = t('Useful when the ' . 'WWW server provides authentication in the form of user@realm and you ' . 'want to have both SSO and regular forms based authentication ' . 'available. Otherwise duplicate accounts with conflicting e-mail ' . 'addresses may be created.');
$values['seamlessLogInDescription'] = t('This requires that you ' . 'have operational NTLM or Kerberos authentication turned on for at least ' . 'the path user/login/sso, or for the whole domain.');
$values['cookieExpireDescription'] = t('If using the seamless login, a ' . 'cookie is necessary to prevent automatic login after a user ' . 'manually logs out. Select the lifetime of the cookie.');
$values['ldapImplementationDescription'] = t('Select the type of ' . 'authentication mechanism you are using.');
foreach ($values as $property => $default_value) {
$this->{$property} = $default_value;
}
}
示例3: simple_geo_settings
/**
* @file
* Admin functions for simple geo
*/
function simple_geo_settings()
{
$form = array();
$form['position_set'] = array('#type' => 'fieldset', '#title' => t('Default position'), '#after_build' => array('simple_geo_add_form_js'));
$form['position_set']['simple_geo_default_position'] = array('#type' => 'textfield', '#title' => t('Coordinates'), '#default_value' => variable_get('simple_geo_default_position', ''), '#prefix' => '<div class="map-placeholder"></div><div id="edit-simple-geo-position-wrapper">', '#suffix' => '</div>', '#attributes' => array('id' => 'edit-simple-geo-position'));
$form['user_set'] = array('#type' => 'fieldset', '#title' => t('Users'));
$form['user_set']['simple_geo_position_users'] = array('#type' => 'checkbox', '#default_value' => variable_get('simple_geo_position_users', 1), '#title' => t('Enable user positioning'));
$form['user_set']['simple_geo_search_address'] = array('#type' => 'checkbox', '#default_value' => variable_get('simple_geo_search_address', 1), '#title' => t('Enable "Search for address" field'));
$form['user_set']['simple_geo_search_address_icon'] = array('#type' => 'checkbox', '#default_value' => variable_get('simple_geo_search_address_icon', 1), '#title' => t('Enable marker icon for search result'));
$form['node_set'] = array('#type' => 'fieldset', '#title' => t('Node rendering'));
$form['node_set']['simple_geo_show_map_link'] = array('#type' => 'select', '#title' => t('Show map links for nodes'), '#options' => array('always' => t('Always'), 'teaser' => t('In teaser'), 'full' => t('When viewing full node'), 'never' => t('Never')), '#default_value' => variable_get('simple_geo_show_map_link', 'always'));
$form['node_set']['simple_geo_add_microformat_tag'] = array('#type' => 'checkbox', '#default_value' => variable_get('simple_geo_add_microformat_tag', 1), '#title' => t('Show microformat tag for node positions'));
$form['micromap_set'] = array('#type' => 'fieldset', '#title' => t('Micromap'));
$form['micromap_set']['simple_geo_use_microformat_map'] = array('#type' => 'checkbox', '#default_value' => variable_get('simple_geo_use_microformat_map', 1), '#title' => t('Use map to display microformat positions'));
$form['micromap_set']['simple_geo_micromap_parent'] = array('#type' => 'textfield', '#default_value' => variable_get('simple_geo_micromap_parent', '#main-inner'), '#title' => t('Parent element'), '#description' => t('The jQuery expression that should be used to find the micromap parent'));
$form['micromap_set']['simple_geo_use_microformat_map'] = array('#type' => 'checkbox', '#default_value' => variable_get('simple_geo_use_microformat_map', 1), '#title' => t('Use map to display microformat positions'));
$form['micromap_set']['simple_geo_micromap_add_mode'] = array('#type' => 'select', '#title' => t('Add method'), '#options' => array('prepend' => t('Prepend'), 'append' => t('Append')), '#default_value' => variable_get('simple_geo_micromap_add_mode', 'prepend'));
$form['micromap_set']['simple_geo_geocoding_suffix'] = array('#type' => 'textfield', '#default_value' => variable_get('simple_geo_geocoding_suffix', ''), '#title' => t('Geocoding suffix'), '#description' => t('Any suffix entered here will be appended to the address with a separating comma before a geocoding lookup is performed'));
$array = drupal_map_assoc(range(1, 17));
$form['micromap_set']['simple_geo_max_zoom'] = array('#type' => 'select', '#title' => t('Max zoom level'), '#options' => $array, '#default_value' => variable_get('simple_geo_max_zoom', 14), '#description' => t('This affects only the zoom level that\'s automatically chosen by the micromap'));
$form['micromap_set']['simple_geo_min_zoom'] = array('#type' => 'select', '#title' => t('Minimum zoom level'), '#options' => $array, '#default_value' => variable_get('simple_geo_min_zoom', 1), '#description' => t('This affects only the zoom level that\'s automatically chosen by the micromap'));
$form['google'] = array('#type' => 'fieldset', '#title' => t('Google maps'), '#description' => t('Google Maps must be configured for most of the simple_geo functionality'));
$form['google']['simple_geo_manually_load'] = array('#type' => 'checkbox', '#default_value' => variable_get('simple_geo_manually_load', 1), '#title' => t('Automatically load Google Maps scripts'));
$form['google']['gmaps_api_key'] = array('#type' => 'textfield', '#default_value' => variable_get('gmaps_api_key', ''), '#title' => t('Your google maps api key'));
$form['google']['simple_geo_add_google_jsapi'] = array('#type' => 'checkbox', '#default_value' => variable_get('simple_geo_add_google_jsapi', 1), '#title' => t('Add the Google AJAX API Loader to the page'), '#description' => t('Adds a script tag that loads the Google AJAX API Loader from Google. Disable this if another module or theme already handles this'));
return system_settings_form($form);
}
示例4: local_storage_admin_form
/**
* Form callback for "admin/config/administration/local_storage".
*/
function local_storage_admin_form($form, &$form_state)
{
$form['local_storage_enable'] = array('#type' => 'checkbox', '#title' => t('Enable Local Storage'), '#description' => t('Enable automatic storing of entered data for all new fields by default.'), '#default_value' => variable_get('local_storage_enable', 0));
$form['local_storage_default'] = array('#type' => 'checkbox', '#title' => t('Show default (original) value by default'), '#description' => t('Show default (original) value by default for all new fields by default.'), '#default_value' => variable_get('local_storage_default', 0));
$form['local_storage_expire'] = array('#type' => 'select', '#options' => drupal_map_assoc(range(1, 48)), '#title' => t('Expiration time'), '#description' => t('Set default expiration time for stored data (in hours).'), '#default_value' => variable_get('local_storage_expire', 48));
return system_settings_form($form);
}
示例5: _fly_flower_settings_form
/**
* Contains the form for the theme settings.
*
* @param array $form
* The form array, passed by reference.
* @param array $form_state
* The form state array, passed by reference.
*/
function _fly_flower_settings_form(array &$form, array $form_state)
{
$form['cdrupal'] = array('#type' => 'vertical_tabs', '#prefix' => '<h2><small>' . t('Fly Flower Settings') . '</small></h2>', '#weight' => -11);
// cDrupal general.
$form['general_settings'] = array('#type' => 'fieldset', '#title' => t('General'), '#group' => 'cdrupal');
// Socials network.
$form['general_settings']['socials'] = array('#type' => 'fieldset', '#title' => t('Socials network'), '#collapsible' => TRUE, '#collapsed' => TRUE);
// Facebook.
$form['general_settings']['socials']['facebook'] = array('#type' => 'textfield', '#title' => t('Facebook'), '#default_value' => theme_get_setting('facebook'));
// Twitter.
$form['general_settings']['socials']['twitter'] = array('#type' => 'textfield', '#title' => t('Twitter'), '#default_value' => theme_get_setting('twitter'));
// Pinterest.
$form['general_settings']['socials']['pinterest'] = array('#type' => 'textfield', '#title' => t('Pinterest'), '#default_value' => theme_get_setting('pinterest'));
// Footer.
$form['footer'] = array('#type' => 'fieldset', '#title' => t('Footer'), '#group' => 'cdrupal');
// Copyright text.
$form['footer']['copyright'] = array('#type' => 'textarea', '#title' => t('Copyright'), '#default_value' => theme_get_setting('copyright'));
// Credit.
$form['footer']['credit'] = array('#type' => 'checkbox', '#title' => t('Don\'t not show theme author: Theme by <a href="http://cdrupal.com/"><strong>cDrupal</strong></a>'), '#default_value' => theme_get_setting('credit'));
// Wrap global setting fieldsets in vertical tabs.
$form['general'] = array('#type' => 'vertical_tabs', '#prefix' => '<h2><small>' . t('Override Global Settings') . '</small></h2>', '#weight' => -9);
$form['theme_settings']['#group'] = 'general';
$form['logo']['#group'] = 'general';
$form['favicon']['#group'] = 'general';
// Do not add Bootstrap specific settings to global settings.
if (empty($form_state['build_info']['args'][0])) {
unset($form['general']['#prefix']);
return;
}
// BootstrapCDN.
$form['advanced']['bootstrap_cdn'] = array('#type' => 'fieldset', '#title' => t('BootstrapCDN'), '#description' => t('Use !bootstrapcdn to serve the Bootstrap framework files. Enabling this setting will prevent this theme from attempting to load any Bootstrap framework files locally. !warning', array('!bootstrapcdn' => l(t('BootstrapCDN'), 'http://bootstrapcdn.com', array('external' => TRUE)), '!warning' => '<div class="alert alert-info messages info"><strong>' . t('NOTE') . ':</strong> ' . t('While BootstrapCDN (content distribution network) is the preferred method for providing huge performance gains in load time, this method does depend on using this third party service. BootstrapCDN is under no obligation or commitment to provide guaranteed up-time or service quality for this theme. If you choose to disable this setting, you must provide your own Bootstrap source and/or optional CDN delivery implementation.') . '</div>')), '#collapsible' => TRUE, '#collapsed' => TRUE);
$form['advanced']['bootstrap_cdn']['bootstrap_cdn'] = array('#type' => 'select', '#title' => t('BootstrapCDN version'), '#options' => drupal_map_assoc(array('3.0.0', '3.0.1', '3.0.2', '3.3.4')), '#default_value' => theme_get_setting('bootstrap_cdn'), '#empty_option' => t('Disabled'), '#empty_value' => NULL);
}
示例6: 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
示例7: presetFormAlter
/**
* Preset form altering.
*
* @inhetirdoc
*/
public function presetFormAlter(&$form, &$form_state, $preset_data)
{
$elements = array();
$elements['maptype'] = array('#type' => 'select', '#title' => t('Map Type'), '#default_value' => !empty($preset_data['maptype']) ? $preset_data['maptype'] : '', '#options' => $this->mapTypes());
$elements['zoom'] = array('#type' => 'select', '#title' => t('Zoom'), '#options' => array('auto' => t('Automatic')) + drupal_map_assoc(range(0, 21)), '#default_value' => isset($preset_data['zoom']) ? $preset_data['zoom'] : 'auto');
return $elements;
}
示例8: update_script_selection_form
function update_script_selection_form()
{
$form = array();
$form['start'] = array('#tree' => TRUE, '#type' => 'fieldset', '#title' => 'Select versions', '#collapsible' => TRUE, '#collapsed' => TRUE);
// Ensure system.module's updates appear first
$form['start']['system'] = array();
$modules = drupal_get_installed_schema_version(NULL, FALSE, TRUE);
foreach ($modules as $module => $schema_version) {
$updates = drupal_get_schema_versions($module);
// Skip incompatible module updates completely, otherwise test schema versions.
if (!update_check_incompatibility($module) && $updates !== FALSE && $schema_version >= 0) {
// module_invoke returns NULL for nonexisting hooks, so if no updates
// are removed, it will == 0.
$last_removed = module_invoke($module, 'update_last_removed');
if ($schema_version < $last_removed) {
$form['start'][$module] = array('#value' => '<em>' . $module . '</em> module can not be updated. Its schema version is ' . $schema_version . '. Updates up to and including ' . $last_removed . ' have been removed in this release. In order to update <em>' . $module . '</em> module, you will first <a href="http://drupal.org/upgrade">need to upgrade</a> to the last version in which these updates were available.', '#prefix' => '<div class="warning">', '#suffix' => '</div>');
$form['start']['#collapsed'] = FALSE;
continue;
}
$updates = drupal_map_assoc($updates);
$updates[] = 'No updates available';
$default = $schema_version;
foreach (array_keys($updates) as $update) {
if ($update > $schema_version) {
$default = $update;
break;
}
}
$form['start'][$module] = array('#type' => 'select', '#title' => $module . ' module', '#default_value' => $default, '#options' => $updates);
}
}
$form['has_js'] = array('#type' => 'hidden', '#default_value' => FALSE);
$form['submit'] = array('#type' => 'submit', '#value' => 'Update');
return $form;
}
示例9: queryLoad
protected function queryLoad($ids)
{
$multifields = multifield_get_fields();
foreach (array_keys($multifields) as $field_name) {
$query = new EntityFieldQuery();
if ($ids) {
$query->fieldCondition($field_name, 'id', $ids, 'IN');
} else {
$query->fieldCondition($field_name, 'id', 0, '>');
}
if ($results = $query->execute()) {
$pseudo_entities = array();
$field = field_info_field($field_name);
foreach ($results as $entity_type => $entities) {
// Simply doing an entity load on the entities with multifield values
// will cause the cacheSet() from multifield_field_load() to get
// invoked.
$entities = entity_load($entity_type, array_keys($entities));
foreach ($entities as $entity) {
if ($items = field_get_items($entity_type, $entity, $field_name)) {
foreach ($items as $item) {
$pseudo_entities[$item['id']] = _multifield_field_item_to_entity($field['type'], $item);
}
}
}
}
$this->cacheSet($pseudo_entities);
}
}
return array_intersect_key($this->entityCache, drupal_map_assoc($ids, $ids));
}
示例10: __construct
/**
* Constructs a FullcalendarPluginBag object.
*
* @param \Drupal\Component\Plugin\PluginManagerInterface $manager
* The manager to be used for instantiating plugins.
* @param \Drupal\views\Plugin\views\style\StylePluginBase $style
* The style plugin that contains these plugins.
*/
public function __construct(PluginManagerInterface $manager, StylePluginBase $style)
{
$this->manager = $manager;
$this->style = $style;
// Store all display IDs to access them easy and fast.
$definitions = $this->manager->getDefinitions();
$this->instanceIDs = drupal_map_assoc(array_keys($definitions));
}
示例11: settingsForm
/**
* Settings form for the simple scheduler.
*/
public function settingsForm(&$form, &$form_state, $job = NULL)
{
$elements =& $form['settings'][$this->type][$this->name];
$values =& $form_state['values']['settings'][$this->type][$this->name];
$rule = is_array($values['rules']) ? reset($values['rules']) : '';
$intervals = drupal_map_assoc($this->presets, 'format_interval');
$options = array_combine(array_keys($this->presets), $intervals);
$elements['rules'] = array('#type' => 'select', '#title' => t('Run cron every'), '#default_value' => $rule, '#description' => t('Select the interval you wish cron to run on.'), '#options' => $options, '#fallback' => TRUE, '#required' => TRUE);
}
示例12: settingsForm
function settingsForm()
{
$form = parent::settingsForm();
// Provider specific settings.
$form['devel_image_provider_' . $this->plugin['name']]['devel_image_provider_categories'] = array('#type' => 'select', '#title' => t('Lorempixum Categories'), '#options' => drupal_map_assoc(array('any', 'abstract', 'animals', 'city', 'food', 'nightlife', 'fashion', 'people', 'nature', 'sports', 'technics', 'transport')), '#multiple' => TRUE, '#size' => 12, '#default_value' => isset($this->settings['devel_image_provider_categories']) ? $this->settings['devel_image_provider_categories'] : 'any');
$form['devel_image_provider_' . $this->plugin['name']]['devel_image_provider_include_text'] = array('#type' => 'radios', '#title' => t('Choose whether or not to add text inside the generated image'), '#default_value' => isset($this->settings['devel_image_provider_include_text']) ? $this->settings['devel_image_provider_include_text'] : 'default', '#options' => array('default' => t('No text'), 'random' => t('Random text'), 'custom' => t('Custom text')));
$form['devel_image_provider_' . $this->plugin['name']]['devel_image_provider_custom_text'] = array('#type' => 'textfield', '#title' => t('Custom Text'), '#maxlength' => 255, '#description' => t('Enter some custom text to be rendered instead of the default image dimensions.'), '#default_value' => isset($this->settings['devel_image_provider_custom_text']) ? $this->settings['devel_image_provider_custom_text'] : NULL, '#states' => array('visible' => array(':input[name="available_providers[devel_image_provider_method_selected][devel_image_provider_' . $this->plugin['name'] . '][devel_image_provider_include_text]"]' => array('value' => 'custom'))));
return $form;
}
示例13: update_script_selection_form
function update_script_selection_form()
{
$form = array();
$count = 0;
$form['start'] = array('#tree' => TRUE, '#type' => 'fieldset', '#collapsed' => TRUE, '#collapsible' => TRUE);
// Ensure system.module's updates appear first
$form['start']['system'] = array();
$modules = drupal_get_installed_schema_version(NULL, FALSE, TRUE);
foreach ($modules as $module => $schema_version) {
$pending = array();
$updates = drupal_get_schema_versions($module);
// Skip incompatible module updates completely, otherwise test schema versions.
if (!update_check_incompatibility($module) && $updates !== FALSE && $schema_version >= 0) {
// module_invoke returns NULL for nonexisting hooks, so if no updates
// are removed, it will == 0.
$last_removed = module_invoke($module, 'update_last_removed');
if ($schema_version < $last_removed) {
$form['start'][$module] = array('#title' => $module, '#item' => '<em>' . $module . '</em> module can not be updated. Its schema version is ' . $schema_version . '. Updates up to and including ' . $last_removed . ' have been removed in this release. In order to update <em>' . $module . '</em> module, you will first <a href="http://drupal.org/upgrade">need to upgrade</a> to the last version in which these updates were available.', '#prefix' => '<div class="warning">', '#suffix' => '</div>');
continue;
}
$updates = drupal_map_assoc($updates);
foreach (array_keys($updates) as $update) {
if ($update > $schema_version) {
// The description for an update comes from its Doxygen.
$func = new ReflectionFunction($module . '_update_' . $update);
$description = str_replace(array("\n", '*', '/'), '', $func->getDocComment());
$pending[] = "{$update} - {$description}";
if (!isset($default)) {
$default = $update;
}
}
}
if (!empty($pending)) {
if (!isset($default)) {
$default = $schema_version;
}
$form['start'][$module] = array('#type' => 'hidden', '#value' => $default);
$form['start'][$module . '_updates'] = array('#markup' => theme('item_list', $pending, $module . ' module'));
}
}
unset($default);
$count = $count + count($pending);
}
if (empty($count)) {
drupal_set_message(t('No pending updates.'));
unset($form);
$form['links'] = array('#markup' => theme('item_list', update_helpful_links()));
} else {
$form['help'] = array('#markup' => '<p>The version of Drupal you are updating from has been automatically detected.</p>', '#weight' => -5);
$form['start']['#title'] = strtr('!num pending updates', array('!num' => $count));
$form['has_js'] = array('#type' => 'hidden', '#default_value' => FALSE);
$form['submit'] = array('#type' => 'submit', '#value' => 'Apply pending updates');
}
return $form;
}
示例14: buildForm
/**
* {inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state)
{
$form['#form_horizontal'] = true;
$form['interface'] = ['#type' => 'fieldset', '#title' => $this->t("User interface")];
$form['interface'][APB_VAR_USER_PAGER_LIMIT] = ['#type' => 'select', '#title' => $this->t("User notification page limit"), '#options' => drupal_map_assoc([5, 10, 20, 30, 50, 100]), '#description' => $this->t("Number of notifications being displayed per page in user notification page."), '#default_value' => variable_get(APB_VAR_USER_PAGER_LIMIT, APB_DEF_USER_PAGER_LIMIT)];
$form['interface'][APB_VAR_USER_BLOCK_LIMIT] = ['#type' => 'select', '#title' => $this->t("User notification block limit"), '#options' => drupal_map_assoc([3, 5, 8, 10, 13, 15, 20]), '#description' => $this->t("Number of notifications being displayed per in the user notification block."), '#default_value' => variable_get(APB_VAR_USER_BLOCK_LIMIT, APB_DEF_USER_BLOCK_LIMIT)];
$form['interface'][APB_VAR_IMG_STYLE] = ['#type' => 'select', '#title' => $this->t("Notification image style"), '#empty_option' => $this->t("Do not display image"), '#options' => image_style_options(true), '#description' => $this->t("Number of notifications being displayed per page in user notification page."), '#default_value' => variable_get(APB_VAR_IMG_STYLE, APB_DEF_IMG_STYLE)];
$form['advanced'] = ['#type' => 'fieldset', '#title' => $this->t("Advanced / Performance")];
$form['advanced'][APB_VAR_ENABLE_PROD] = ['#type' => 'checkbox', '#title' => $this->t("Enable production mode"), '#description' => $this->t("Will suppress some warnings, errors and exceptions. Always check this option on a production site."), '#default_value' => variable_get(APB_VAR_ENABLE_PROD, APB_DEF_ENABLE_PROD)];
$form['advanced'][APB_VAR_ENABLE_FORMATTED_CONTENT] = ['#type' => 'checkbox', '#title' => $this->t("Store content inside messages"), '#description' => $this->t("If checked, formatted messages will be sent in the message contents instead of being formatted at view time. This will bypass translation but allows you to display those notifications outside of the originating website. If checked generated links inside formatted notifications will all be absolute. Note that if you change this setting and data has already been sent some notifications might not be displayed correctly."), '#default_value' => variable_get(APB_VAR_ENABLE_FORMATTED_CONTENT, APB_DEF_ENABLE_FORMATTED_CONTENT)];
return system_settings_form($form);
}
示例15: spaces_preset_list
/**
* Presets form.
*/
function spaces_preset_list($form, &$form_state, $export_ui)
{
// Some setup for the spaces_preset_name_validation
$form_state['plugin'] = $export_ui->plugin;
$form_state['object'] =& $export_ui;
$types = array();
foreach (spaces_types(TRUE) as $type => $info) {
$types[$type] = $info['title'];
}
$form['new'] = array('#tree' => FALSE, '#theme' => 'spaces_preset_list_new', 'space_type' => array('#title' => t('Type'), '#type' => 'select', '#options' => $types), 'name' => array('#type' => 'textfield', '#maxlength' => 64, '#size' => 32, '#title' => t('Machine ID'), '#element_validate' => array('spaces_preset_name_validate')), 'title' => array('#type' => 'textfield', '#maxlength' => 64, '#size' => 32, '#title' => t('Name')), 'submit' => array('#type' => 'submit', '#value' => t('Create new preset'), '#submit' => array('spaces_preset_list_new')));
// Generate preset options.
foreach ($types as $type => $title) {
module_load_include('inc', 'spaces', 'spaces.admin');
$presets = spaces_preset_load(NULL, $type, TRUE);
ksort($presets);
$form[$type] = spaces_preset_form($presets, $type, TRUE);
$form[$type]['#title'] = t('@spacetype presets', array('@spacetype' => $title));
$form[$type]['#description'] = t('Select a default preset for each new @spacetype.', array('@spacetype' => $title));
$plugin = $export_ui->plugin;
foreach ($presets as $name => $item) {
// Note: Creating this list seems a little clumsy, but can't think of
// better ways to do this.
$allowed_operations = drupal_map_assoc(array_keys($plugin['allowed operations']));
$not_allowed_operations = array('import');
if ($item->type == t('Normal')) {
$not_allowed_operations[] = 'revert';
} elseif ($item->type == t('Overridden')) {
$not_allowed_operations[] = 'delete';
} else {
$not_allowed_operations[] = 'revert';
$not_allowed_operations[] = 'delete';
}
$not_allowed_operations[] = empty($item->disabled) ? 'enable' : 'disable';
foreach ($not_allowed_operations as $op) {
// Remove the operations that are not allowed for the specific exportable.
unset($allowed_operations[$op]);
}
$operations = array();
foreach ($allowed_operations as $op) {
$operations[$op] = array('title' => $plugin['allowed operations'][$op]['title'], 'href' => ctools_export_ui_plugin_menu_path($plugin, $op, $name));
if (!empty($plugin['allowed operations'][$op]['token'])) {
$operations[$op]['query'] = array('token' => drupal_get_token($op));
}
}
$form[$type]['storage'][$item->name] = array('#type' => 'markup', '#markup' => isset($item->disabled) && $item->disabled ? t('Disabled') : check_plain($item->type));
$form[$type]['actions'][$item->name] = array('#type' => 'markup', '#markup' => theme('links', array('links' => $operations)));
$form[$type]["spaces_preset_{$type}"][$name] = array();
}
}
$form = system_settings_form($form);
return $form;
}