array( 'title' => t('Administer Custom Formatters'), ), ); } /** * Implements hook_menu(). */ function custom_formatters_menu() { $items = array(); $items['admin/structure/formatters/settings'] = array( 'title' => 'Settings', 'page callback' => 'drupal_get_form', 'page arguments' => array('custom_formatters_settings_form'), 'access arguments' => array('administer custom formatters'), 'file' => 'custom_formatters.admin.inc', 'file path' => drupal_get_path('module', 'custom_formatters') . '/includes', 'type' => MENU_LOCAL_TASK, ); $items['js/formatters/autocomplete'] = array( 'title' => 'Formatters autocomplete', 'page callback' => 'custom_formatters_autocomplete', 'access arguments' => array('administer custom formatters'), 'file' => 'custom_formatters.inc', 'file path' => drupal_get_path('module', 'custom_formatters') . '/plugins/export_ui', 'type' => MENU_CALLBACK, ); return $items; } /** * */ function custom_formatters_formatter_is_active($formatter) { $field_types = drupal_explode_tags($formatter->field_types); $field_info = field_info_fields(); foreach (field_info_instances() as $bundles) { foreach ($bundles as $fields) { foreach ($fields as $field) { if (in_array($field_info[$field['field_name']]['type'], $field_types)) { foreach ($field['display'] as $display) { if ($display['type'] == "custom_formatters_{$formatter->name}") { return TRUE; } } } } } } return FALSE; } /** * */ function custom_formatters_crud_load($formatter) { $formatters = custom_formatters_crud_load_all(); return isset($formatters[$formatter]) ? $formatters[$formatter] : NULL; } /** * */ function custom_formatters_crud_load_all($flush_cache = FALSE) { $formatters = &drupal_static(__FUNCTION__, array()); if (!$formatters || $flush_cache) { ctools_include('export'); foreach (ctools_export_crud_load_all('formatters') as $formatter) { if (empty($formatter->disabled)) { $formatters[$formatter->name] = $formatter; } } } return $formatters; }