You are here

function asset_widget_element_info_alter in Asset 7

Implements hook_element_info_alter().

File

modules/asset_widget/asset_widget.module, line 91
Code for the Asset widget module.

Code

function asset_widget_element_info_alter(&$info) {

  // Don't process fields if current theme is not admin, access denied or outside of asset widget form frames, field settings form and different fields added by ajax.
  if (user_access('access search widget') && _asset_widget_is_admin_theme() && !asset_widget_in_frame_form()) {

    // Add callback for text fields with wysiwyg.
    if (module_exists('ckeditor') && isset($info['text_format'])) {
      $info['text_format']['#process'][] = 'asset_widget_pre_render_text_format';
    }

    // Add callback for entityreference fields.
    if (isset($info['textfield'])) {
      $info['textfield']['#process'][] = 'asset_widget_pre_render_textfield';
    }

    // Add callback for contextual_links to alter destination in edit links after ajax enabled view in widget.
    if (isset($info['contextual_links'])) {
      $info['contextual_links']['#pre_render'][] = 'asset_widget_pre_render_contextual';
    }
  }

  // Remove any references_dialog links inside frames.
  if (asset_widget_in_frame_form() && module_exists('references_dialog')) {
    foreach (references_dialog_widgets() as $widget) {
      if (isset($info[$widget['element_type']]['#after_build']) && ($pos = array_search('references_dialog_process_widget', $info[$widget['element_type']]['#after_build'])) !== FALSE) {
        unset($info[$widget['element_type']]['#after_build'][$pos]);
      }
    }
  }
}