123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <?php
- /**
- * @file
- * Contains core functions for the Custom Formatters module.
- */
- /**
- * Include additional files.
- */
- foreach (module_list() as $module) {
- if (file_exists($file = dirname(__FILE__) . "/includes/{$module}.inc")) {
- require_once $file;
- }
- }
- /**
- * Implements hook_permission().
- */
- function custom_formatters_permission() {
- return array(
- 'administer custom formatters' => 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;
- }
|