public static function discover($path, ReaderInterface $reader) { $data = array(); $ext = $reader->getFileExtensions(); if (empty($ext)) { $pattern = '*'; } else { if (1 === count($ext)) { $pattern = '*.' . $ext; } else { $pattern = '*.{' . implode(',', $ext) . '}'; } } foreach (glob($path . '/' . $pattern, GLOB_BRACE | GLOB_NOESCAPE) as $filename) { $additions = $reader->read($filename); // Fetch section name $parts = explode('.', basename($filename)); array_pop($parts); $current =& $data; foreach ($parts as $part) { if (empty($current[$part])) { $current[$part] = array(); } $current =& $current[$part]; } $current = drupal_array_merge_deep($additions, $current); } return $data; }
/** * Constructs a DataProviderFile object. */ public function __construct(RequestInterface $request, ResourceFieldCollectionInterface $field_definitions, $account, $plugin_id, $resource_path, array $options, $langcode = NULL) { parent::__construct($request, $field_definitions, $account, $plugin_id, $resource_path, $options, $langcode); $file_options = empty($this->options['options']) ? array() : $this->options['options']; $default_values = array('validators' => array('file_validate_extensions' => array(), 'file_validate_size' => array()), 'scheme' => file_default_scheme(), 'replace' => FILE_EXISTS_RENAME); $this->options['options'] = drupal_array_merge_deep($default_values, $file_options); }
/** * PublicFieldInfoBase constructor. * * @param string $field_name * The name of the field. * @param array[] $sections * The array of categories information. */ public function __construct($field_name, array $sections = array()) { $this->fieldName = $field_name; $sections = drupal_array_merge_deep($this::$defaultSections, $sections); foreach ($sections as $section_name => $section_info) { $this->addCategory($section_name, $section_info); } }
/** * Generate a settings form for this handler. */ public function settingsForm($field, $instance) { $form['action'] = array('#type' => 'select', '#title' => t('Action'), '#options' => array('none' => t('Do nothing'), 'hide' => t('Hide field'), 'disable' => t('Disable field')), '#description' => t('Action to take when prepopulating field with values via URL.')); $form['action_on_edit'] = array('#type' => 'checkbox', '#title' => t('Apply action on edit'), '#description' => t('Apply action when editing an existing entity.'), '#states' => array('invisible' => array(':input[name="instance[settings][behaviors][prepopulate][action]"]' => array('value' => 'none')))); $form['fallback'] = array('#type' => 'select', '#title' => t('Fallback behaviour'), '#description' => t('Determine what should happen if no values are provided via URL.'), '#options' => array('none' => t('Do nothing'), 'hide' => t('Hide field'), 'form_error' => t('Set form error'), 'redirect' => t('Redirect'))); // Get list of permissions. $perms = array(); $perms[0] = t('- None -'); foreach (module_list(FALSE, FALSE, TRUE) as $module) { // By keeping them keyed by module we can use optgroups with the // 'select' type. if ($permissions = module_invoke($module, 'permission')) { foreach ($permissions as $id => $permission) { $perms[$module][$id] = strip_tags($permission['title']); } } } $form['skip_perm'] = array('#type' => 'select', '#title' => t('Skip access permission'), '#description' => t('Set a permission that will not be affected by the fallback behavior.'), '#options' => $perms); $form['providers'] = array('#type' => 'container', '#theme' => 'entityreference_prepopulate_providers_table', '#element_validate' => array('entityreference_prepopulate_providers_validate')); $providers = entityreference_prepopulate_providers_info(); // Sort providers by weight. $providers_names = !empty($instance['settings']['behaviors']['prepopulate']['providers']) ? array_keys($instance['settings']['behaviors']['prepopulate']['providers']) : array(); $providers_names = drupal_array_merge_deep($providers_names, array_keys($providers)); $weight = 0; foreach ($providers_names as $name) { // Validate that the provider exists. if (!isset($providers[$name])) { continue; } $provider = $providers[$name]; // Set default values. $provider += array('disabled' => FALSE); $form['providers']['title'][$name] = array('#type' => 'item', '#markup' => filter_xss($provider['title']), '#description' => filter_xss($provider['description'])); if (!isset($instance['settings']['behaviors']['prepopulate']['providers'][$name])) { // backwards compatibility with version 1.4. if ($name == 'url') { // Enable the URL provider is it is not set in the instance yet. $default_value = TRUE; } elseif ($name == 'og_context') { $default_value = !empty($instance['settings']['behaviors']['prepopulate']['og_context']); } } else { $default_value = !empty($instance['settings']['behaviors']['prepopulate']['providers'][$name]); } $form['providers']['enabled'][$name] = array('#type' => 'checkbox', '#disabled' => $provider['disabled'], '#default_value' => $default_value); $form['providers']['weight'][$name] = array('#type' => 'weight', '#default_value' => $weight, '#attributes' => array('class' => array('provider-weight'))); ++$weight; } return $form; }
/** * Overrides \RestfulEntityBase::__construct() * * Set the "options" key from the plugin info, specific for file upload, with * the following keys: * - "validators": By default no validation is done on the file extensions or * file size. * - "scheme": By default the default scheme (e.g. public, private) is used. */ public function __construct(array $plugin, \RestfulAuthenticationManager $auth_manager = NULL, \DrupalCacheInterface $cache_controller = NULL, $language = NULL) { parent::__construct($plugin, $auth_manager, $cache_controller, $language); if (!$options = $this->getPluginKey('options')) { $options = array(); } $default_values = array( 'validators' => array( 'file_validate_extensions' => array(), 'file_validate_size' => array(), ), 'scheme' => file_default_scheme(), 'replace' => FILE_EXISTS_RENAME, ); $this->setPluginKey('options', drupal_array_merge_deep($default_values, $options)); }
protected function parseFile($source, $filename, $ret, &$loaded = [], Context $context) { $type = null; if (isset($loaded[$source])) { return $ret; } $loaded[$source] = true; if (!is_dir($filename) && !is_file($filename)) { throw new \InvalidArgumentException(sprintf("%s: file does not exists", $filename)); } $timer = $context->time('parse:' . $source); if (!empty($type)) { $readerClass = '\\USync\\Parsing\\' . ucfirst($type) . 'Reader'; if (!class_exists($readerClass)) { throw new \InvalidArgumentException(sprintf("'%s': type is not supported", $type)); } $reader = new $readerClass(); } else { $reader = new YamlReader(); } if (is_file($filename)) { $data = $reader->read($filename); } else { if (is_dir($filename)) { $discovery = new PathDiscovery(); $data = $discovery->discover($filename, $reader); } } if (empty($data)) { throw new \RuntimeException(sprintf("%s: Could not parse file or folder", $filename)); } foreach ($this->findDependencies($filename, $data) as $depSource => $depFilename) { $ret = $this->parseFile($depSource, $depFilename, $ret, $loaded, $context); } $timer->stop(); return drupal_array_merge_deep($ret, $data); }
/** * Execute an Ajax submission. * * This executes a POST as ajax.js does. It uses the returned JSON data, an * array of commands, to update $this->content using equivalent DOM * manipulation as is used by ajax.js. It also returns the array of commands. * * @param $path * Location of the form containing the Ajax enabled element to test. Can be * either a Drupal path or an absolute path or NULL to use the current page. * @param $edit * Field data in an associative array. Changes the current input fields * (where possible) to the values indicated. * @param $triggering_element * The name of the form element that is responsible for triggering the Ajax * functionality to test. May be a string or, if the triggering element is * a button, an associative array where the key is the name of the button * and the value is the button label. i.e.) array('op' => t('Refresh')). * @param $ajax_path * (optional) Override the path set by the Ajax settings of the triggering * element. In the absence of both the triggering element's Ajax path and * $ajax_path 'system/ajax' will be used. * @param $options * (optional) Options to be forwarded to url(). * @param $headers * (optional) An array containing additional HTTP request headers, each * formatted as "name: value". Forwarded to drupalPost(). * @param $form_html_id * (optional) HTML ID of the form to be submitted, use when there is more * than one identical form on the same page and the value of the triggering * element is not enough to identify the form. Note this is not the Drupal * ID of the form but rather the HTML ID of the form. * @param $ajax_settings * (optional) An array of Ajax settings which if specified will be used in * place of the Ajax settings of the triggering element. * * @return * An array of Ajax commands. * * @see drupalPost() * @see ajax.js */ protected function drupalPostAJAX($path, $edit, $triggering_element, $ajax_path = NULL, array $options = array(), array $headers = array(), $form_html_id = NULL, $ajax_settings = NULL) { // Get the content of the initial page prior to calling drupalPost(), since // drupalPost() replaces $this->content. if (isset($path)) { $this->drupalGet($path, $options); } $content = $this->content; $drupal_settings = $this->drupalSettings; // Get the Ajax settings bound to the triggering element. if (!isset($ajax_settings)) { if (is_array($triggering_element)) { $xpath = '//*[@name="' . key($triggering_element) . '" and @value="' . current($triggering_element) . '"]'; } else { $xpath = '//*[@name="' . $triggering_element . '"]'; } if (isset($form_html_id)) { $xpath = '//form[@id="' . $form_html_id . '"]' . $xpath; } $element = $this->xpath($xpath); $element_id = (string) $element[0]['id']; $ajax_settings = $drupal_settings['ajax'][$element_id]; } // Add extra information to the POST data as ajax.js does. $extra_post = ''; if (isset($ajax_settings['submit'])) { foreach ($ajax_settings['submit'] as $key => $value) { $extra_post .= '&' . urlencode($key) . '=' . urlencode($value); } } foreach ($this->xpath('//*[@id]') as $element) { $id = (string) $element['id']; $extra_post .= '&' . urlencode('ajax_html_ids[]') . '=' . urlencode($id); } if (isset($drupal_settings['ajaxPageState'])) { $extra_post .= '&' . urlencode('ajax_page_state[theme]') . '=' . urlencode($drupal_settings['ajaxPageState']['theme']); $extra_post .= '&' . urlencode('ajax_page_state[theme_token]') . '=' . urlencode($drupal_settings['ajaxPageState']['theme_token']); foreach ($drupal_settings['ajaxPageState']['css'] as $key => $value) { $extra_post .= '&' . urlencode("ajax_page_state[css][{$key}]") . '=1'; } foreach ($drupal_settings['ajaxPageState']['js'] as $key => $value) { $extra_post .= '&' . urlencode("ajax_page_state[js][{$key}]") . '=1'; } } // Unless a particular path is specified, use the one specified by the // Ajax settings, or else 'system/ajax'. if (!isset($ajax_path)) { $ajax_path = isset($ajax_settings['url']) ? $ajax_settings['url'] : 'system/ajax'; } // Submit the POST request. $return = drupal_json_decode($this->drupalPost(NULL, $edit, array('path' => $ajax_path, 'triggering_element' => $triggering_element), $options, $headers, $form_html_id, $extra_post)); // Change the page content by applying the returned commands. if (!empty($ajax_settings) && !empty($return)) { // ajax.js applies some defaults to the settings object, so do the same // for what's used by this function. $ajax_settings += array('method' => 'replaceWith'); // DOM can load HTML soup. But, HTML soup can throw warnings, suppress // them. $dom = new DOMDocument(); @$dom->loadHTML($content); // XPath allows for finding wrapper nodes better than DOM does. $xpath = new DOMXPath($dom); foreach ($return as $command) { switch ($command['command']) { case 'settings': $drupal_settings = drupal_array_merge_deep($drupal_settings, $command['settings']); break; case 'insert': $wrapperNode = NULL; // When a command doesn't specify a selector, use the // #ajax['wrapper'] which is always an HTML ID. if (!isset($command['selector'])) { $wrapperNode = $xpath->query('//*[@id="' . $ajax_settings['wrapper'] . '"]')->item(0); } elseif (in_array($command['selector'], array('head', 'body'))) { $wrapperNode = $xpath->query('//' . $command['selector'])->item(0); } if ($wrapperNode) { // ajax.js adds an enclosing DIV to work around a Safari bug. $newDom = new DOMDocument(); $newDom->loadHTML('<div>' . $command['data'] . '</div>'); $newNode = $dom->importNode($newDom->documentElement->firstChild->firstChild, TRUE); $method = isset($command['method']) ? $command['method'] : $ajax_settings['method']; // The "method" is a jQuery DOM manipulation function. Emulate // each one using PHP's DOMNode API. switch ($method) { case 'replaceWith': $wrapperNode->parentNode->replaceChild($newNode, $wrapperNode); break; case 'append': $wrapperNode->appendChild($newNode); break; case 'prepend': // If no firstChild, insertBefore() falls back to // appendChild(). $wrapperNode->insertBefore($newNode, $wrapperNode->firstChild); break; case 'before': $wrapperNode->parentNode->insertBefore($newNode, $wrapperNode); break; case 'after': // If no nextSibling, insertBefore() falls back to // appendChild(). $wrapperNode->parentNode->insertBefore($newNode, $wrapperNode->nextSibling); break; case 'html': foreach ($wrapperNode->childNodes as $childNode) { $wrapperNode->removeChild($childNode); } $wrapperNode->appendChild($newNode); break; } } break; // @todo Add suitable implementations for these commands in order to // have full test coverage of what ajax.js can do. // @todo Add suitable implementations for these commands in order to // have full test coverage of what ajax.js can do. case 'remove': break; case 'changed': break; case 'css': break; case 'data': break; case 'restripe': break; } } $content = $dom->saveHTML(); } $this->drupalSetContent($content); $this->drupalSetSettings($drupal_settings); return $return; }
public function synchronize(NodeInterface $node, Context $context, $dirtyAllowed = false) { /* @var $node ViewNode */ $entityType = $node->getEntityType(); $bundle = $node->getBundle(); $name = $node->getName(); // First populate the variable that will be used during the // hook_entity_info_alter() call to populate the view modes $viewModes = variable_get(USYNC_VAR_VIEW_MODE, []); $viewModes[$entityType][$name] = $name; variable_set(USYNC_VAR_VIEW_MODE, $viewModes); // First grab a list of everything that can be displayed in view // modes with both extra fields and real fields $instances = field_info_instances($entityType, $bundle); $bundleSettings = field_bundle_settings($entityType, $bundle); $extra = $this->getExtraFieldsDisplay($entityType, $bundle); $weight = 0; $displayExtra = []; $displayField = []; // Then deal with fields and such foreach ($node->getValue() as $propertyName => $formatter) { if (isset($instances[$propertyName])) { $display = array(); // We are working with a field if (!is_array($formatter)) { if (true === $formatter || 'default' === $formatter) { $formatter = array(); } else { if (false === $formatter || null === $formatter || 'delete' === $formatter) { continue; } else { if (!is_string($formatter)) { $context->logWarning(sprintf("%s: %s invalid value for formatter", $node->getPath(), $propertyName)); $formatter = array(); } else { $display['type'] = $formatter; } } } } else { $display = $formatter; } // Merge default and save $displayField[$propertyName] = drupal_array_merge_deep($this->getFieldDefault($node, $entityType, $bundle, $propertyName, $context), $display, array('weight' => $weight++)); } else { if (isset($extra[$propertyName])) { // We are working with and extra field if (!is_array($formatter)) { if (true === $formatter || 'default' === $formatter) { $formatter = array(); } else { if (false === $formatter || null === $formatter || 'delete' === $formatter) { continue; } else { $context->logWarning(sprintf("%s: %s extra fields can only be delete or default", $node->getPath(), $propertyName)); } } } // Merge default and save $displayExtra[$propertyName] = ['visible' => true, 'weight' => $weight++]; } else { $context->logError(sprintf("%s: %s property is nor a field nor an extra field", $node->getPath(), $propertyName)); } } } // Iterate over the fields and update each instance: we don't // need to do it with the $displayExtra property since it is // already the correctly formatted variable foreach ($displayField as $fieldName => $display) { $instances[$fieldName]['display'][$name] = $display; } // Remove non configured fields and extra fields from display foreach ($instances as $fieldName => $instance) { if (!isset($displayField[$fieldName])) { $instance['display'][$name] = array('type' => 'hidden'); } if ($dirtyAllowed) { $data = $instance; unset($data['id'], $data['field_id'], $data['field_name'], $data['entity_type'], $data['bundle'], $data['deleted']); db_update('field_config_instance')->condition('id', $instance['id'])->fields(['data' => serialize($data)])->execute(); } else { field_update_instance($instance); } } foreach (array_keys($extra) as $propertyName) { if (isset($displayExtra[$propertyName])) { $bundleSettings['extra_fields']['display'][$propertyName][$name] = $displayExtra[$propertyName]; } else { $bundleSettings['extra_fields']['display'][$propertyName][$name] = ['visible' => false, 'weight' => $weight++]; } } $bundleSettings['view_modes'][$name] = ['label' => $name, 'custom_settings' => true]; if ($dirtyAllowed) { // Hopefully nothing about display is really cached into the // internal field cache class, except the raw display array // into each instance, but nothing will use that except this // specific view mode implementation, we are going to delay // a few cache clear calls at the very end of the processing. // From field_bundle_settings(). variable_set('field_bundle_settings_' . $entityType . '__' . $bundle, $bundleSettings); } else { field_bundle_settings($entityType, $bundle, $bundleSettings); } if ($dirtyAllowed) { // From field_update_instance() cache_clear_all('*', 'cache_field', true); // From field_info_cache_clear() drupal_static_reset('field_view_mode_settings'); // We need to clear cache in order for later view modes to // load the right instance and prevent them for overriding // what we actually did here entity_info_cache_clear(); _field_info_field_cache()->flush(); } }
/** * Implements template_preprocess_node() */ function bht_theme_preprocess_node(&$variables) { // Define default theme hook suggestion for nodes. // Set node--{view_mode}.tpl.php. $variables['theme_hook_suggestions'][] = "node__" . $variables['view_mode']; // Set node--{node_type}.tpl.php. $variables['theme_hook_suggestions'][] = "node__" . $variables['type']; // Set node--{node_type}--{view_mode}.tpl.php. $variables['theme_hook_suggestions'][] = "node__" . $variables['type'] . "__" . $variables['view_mode']; if ($variables['type'] == 'events' && $variables['view_mode'] == 'full' && $variables['promote']) { // Set node--{node_type}--{view_mode}.tpl.php. $variables['theme_hook_suggestions'][] = "node__" . $variables['type'] . "__" . $variables['view_mode'] . "_promoted"; } // Set node--{nid}.tpl.php. $variables['theme_hook_suggestions'][] = "node__" . $variables['nid']; // Merge in any custom attributes set in the renderable array. if (isset($variables['node']->attributes_array) && is_array($variables['node']->attributes_array)) { $variables['attributes_array'] = drupal_array_merge_deep($variables['attributes_array'], $variables['node']->attributes_array); } // Replace || with <wbr> tag. $variables['title'] = str_replace('||', '<wbr>­', $variables['title']); }
public static function changeInstances(array $field, array $field_instance_overrides = array()) { $type_info = field_info_field_types($field['type']); $instances = field_read_instances(array('field_name' => $field['field_name'])); foreach ($instances as $instance) { $prior_instance = $instance; // Serialize properties back into the data property so it can be saved // to the database. $instance['data'] = array(); foreach ($instance as $key => $value) { switch ($key) { case 'id': case 'field_id': case 'field_name': case 'entity_type': case 'bundle': case 'deleted': case 'data': break; default: $instance['data'][$key] =& $instance[$key]; } } $instance['settings'] = array_intersect_key($instance['settings'], $type_info['instance_settings']); $instance['settings'] += $type_info['instance_settings']; // Validate the existing widget can be used with the new field type. $widget_info = field_info_widget_types($instance['widget']['type']); if (!in_array($field['type'], $widget_info['field types'])) { // Fallback to using the field type's default widget. $instance['widget']['type'] = $type_info['default_widget']; $widget_info = field_info_widget_types($type_info['default_widget']); $instance['widget']['module'] = $widget_info['module']; $instance['widget']['settings'] = array_intersect_key($instance['widget']['settings'], $widget_info['settings']); $instance['widget']['settings'] += $widget_info['settings']; } // Validate the existing formatters can be used with the new field type. foreach ($instance['display'] as $view_mode => $display) { if ($display['type'] !== 'hidden') { $formatter_info = field_info_formatter_types($display['type']); if (!in_array($field['type'], $formatter_info['field types'])) { // Fallback to using the field type's default formatter. $instance['display'][$view_mode]['type'] = $type_info['default_formatter']; $formatter_info = field_info_formatter_types($type_info['default_formatter']); $instance['display'][$view_mode]['module'] = $formatter_info['module']; $instance['display'][$view_mode]['settings'] = array_intersect_key($instance['display'][$view_mode], $formatter_info['settings']); $instance['display'][$view_mode]['settings'] += $formatter_info['settings']; } } } // Allow anything to be overridden before it gets saved. $instance = drupal_array_merge_deep($instance, $field_instance_overrides); drupal_write_record('field_config_instance', $instance, array('id')); // Clear caches. field_cache_clear(); module_invoke_all('field_update_instance', $instance, $prior_instance); } }
/** * Retrieves the git clone settings. * * @return array|string * The settings array or serialized string (depending on the original state * it was in). */ public function getSettings() { $settings = array(); if (!isset($this->settings)) { $this->settings = array(); } // Since the settings property can be both an array or a serialized string // (depending on the current point in the Entity API process), the // serialized string must be checked for, converted to and array, merged // with defaults and converted back to a serialized string. $serialized = FALSE; if (is_string($this->settings)) { if ($settings = unserialize($this->settings)) { $serialized = TRUE; } else { $settings = array(); } } elseif (is_array($this->settings)) { $settings = $this->settings; } // Merge in default settings. $defaults = array('default' => NULL, 'fetch_threshold' => 3600); $settings = drupal_array_merge_deep($defaults, $settings); // Return the correct format. return $this->settings = $serialized ? serialize($settings) : $settings; }
<?php // Merge in any custom attributes set in the renderable array. if (isset($node->attributes_array) && is_array($node->attributes_array)) { $attributes_array = drupal_array_merge_deep($attributes_array, $node->attributes_array); } $attributes_array['class'][] = 'sponsor__item'; if ($sticky) { $attributes_array['class'][] = 'sticky'; } ?> <div <?php print drupal_attributes($attributes_array); ?> > <?php print render($content); ?> </div>
/** * Call resource using the OPTIONS http method. * * This is an special method since it does not return anything in the body, it * only provides information about the selected endpoint. The information is * provided via HTTP headers. * * @param string $path * (optional) The path. * @param array $request * (optional) The request. * * @return array * Information about the fields in the current resource. */ public function options($path = '', array $request = array()) { $this->setMethod(\RestfulInterface::OPTIONS); $this->setPath($path); $this->setRequest($request); // A list of discoverable methods. $allowed_methods = array(); foreach ($this->getControllers() as $pattern => $controllers) { // Find the controllers for the provided path. if ($pattern != $path && !($pattern && preg_match('/' . $pattern . '/', $path))) { continue; } $allowed_methods = array_keys($controllers); // We have found the controllers for this path. break; } if (!empty($allowed_methods)) { $this->setHttpHeaders('Access-Control-Allow-Methods', implode(',', $allowed_methods)); } // Make your formatters discoverable. $formatter_names = $this->formatterNames(); // Loop through all the formatters and add the Content-Type header to the // array. $accepted_formats = array(); foreach ($formatter_names as $formatter_name) { $formatter = restful_get_formatter_handler($formatter_name, $this); $accepted_formats[] = $formatter->getContentTypeHeader(); } if (!empty($accepted_formats)) { $this->setHttpHeaders('Accept', implode(',', $accepted_formats)); } $output = array(); // Default options for the discovery information. $discovery_defaults = array( 'info' => array( 'label' => '', 'description' => '', ), // Describe the data. 'data' => array( 'type' => NULL, 'read_only' => FALSE, 'cardinality' => 1, 'required' => FALSE, ), // Information about the form element. 'form_element' => array( 'type' => NULL, 'default_value' => '', 'placeholder' => '', 'size' => NULL, 'allowed_values' => NULL, ), ); foreach ($this->getPublicFields() as $public_field => $field_info) { if (empty($field_info['discovery'])) { continue; } $output[$public_field] = drupal_array_merge_deep($discovery_defaults, $field_info['discovery']); } return $output; }
<?php // This function is invoked as theme wrapper, but the rendered form element // may not necessarily have been processed by form_builder(). $element['#title_display'] = 'before'; if (!isset($attributes_array)) { $attributes_array = array(); } if (!empty($element['#attributes_array'])) { $attributes_array = drupal_array_merge_deep($attributes_array, $element['#attributes_array']); } // Add element #id for #type 'item'. if (isset($element['#markup']) && !empty($element['#id'])) { $attributes_array['id'] = $element['#id']; } // Add element's #type and #name as class to aid with JS/CSS selectors. $attributes_array['class'][] = 'form-item'; $attributes_array['class'][] = 'register'; $attributes_array['class'][] = 'js-chk-dynamic'; if (!empty($element['#type'])) { $attributes_array['class'][] = 'form-type-' . strtr($element['#type'], '_', '-'); } if (!empty($element['#name'])) { $attributes_array['class'][] = 'form-item-' . strtr($element['#name'], array(' ' => '-', '_' => '-', '[' => '-', ']' => '')); } // Add a class for disabled elements to facilitate cross-browser styling. if (!empty($element['#attributes']['disabled'])) { $attributes_array['class'][] = 'form-disabled'; } // If #title is not set, we don't display any label or required marker. if (!isset($element['#title'])) {
public static function getAllReferencesTo($entity_type, array $entity_ids, EntityFieldQuery $query = NULL, $flatten = FALSE) { if (!isset($query)) { $query = new EntityFieldQuery(); $query->addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT'); } $references = array(); $fields = FieldHelper::getEntityReferencingFieldsByType($entity_type); foreach ($fields as $field_name => $columns) { foreach (array_keys($columns) as $column) { $field_query = clone $query; $field_query->fieldCondition($field_name, $column, $entity_ids); if ($results = $field_query->execute()) { if ($flatten) { $references = drupal_array_merge_deep($references, $results); } else { $references[$field_name . ':' . $column] = $results; } } } } return $references; }