accessibility_content.module

  1. cis7 sites/all/modules/ulmus/accessibility/modules/accessibility_content/accessibility_content.module
  2. cle7 sites/all/modules/ulmus/accessibility/modules/accessibility_content/accessibility_content.module
  3. ecd7 sites/all/modules/ulmus/accessibility/modules/accessibility_content/accessibility_content.module
  4. elmsmedia7 sites/all/modules/ulmus/accessibility/modules/accessibility_content/accessibility_content.module
  5. harmony7 sites/all/modules/ulmus/accessibility/modules/accessibility_content/accessibility_content.module
  6. icor7 sites/all/modules/ulmus/accessibility/modules/accessibility_content/accessibility_content.module
  7. meedjum_blog7 sites/all/modules/ulmus/accessibility/modules/accessibility_content/accessibility_content.module
  8. mooc7 sites/all/modules/ulmus/accessibility/modules/accessibility_content/accessibility_content.module

Functions

File

sites/all/modules/ulmus/accessibility/modules/accessibility_content/accessibility_content.module
View source
  1. <?php
  2. /**
  3. * Implements hook_menu().
  4. */
  5. function accessibility_content_menu() {
  6. $items = array();
  7. $items['admin/config/accessibility/content'] = array(
  8. 'title' => 'Content',
  9. 'description' => 'Enable or disable toggle for users to view content alerts and manage language of content toggle.',
  10. 'page callback' => 'drupal_get_form',
  11. 'page arguments' => array('accessibility_content_admin_form'),
  12. 'access arguments' => array('administer site configuration'),
  13. 'file' => 'accessibility_content.admin.inc',
  14. );
  15. return $items;
  16. }
  17. /**
  18. * Implements hook_form_FORM_ID_alter().
  19. */
  20. function accessibility_content_form_field_ui_field_edit_form_alter(&$form, $form_state) {
  21. if (in_array($form['#field']['type'], array('text_with_summary'))) {
  22. $form['instance']['accessibility_content'] = array(
  23. '#type' => 'checkbox',
  24. '#title' => t('Check this field for accessibility'),
  25. '#description' => t('Allow appropriate users to check this field for accessibility'),
  26. '#default_value' => (isset($form['#instance']['accessibility_content'])) ?
  27. $form['#instance']['accessibility_content'] :
  28. FALSE,
  29. );
  30. $form['instance']['accessibility_content_block_submit'] = array(
  31. '#type' => 'checkboxes',
  32. '#title' => t('Block saving content if there are any errors that are:'),
  33. '#options' => array('severe' => t('Severe'),
  34. 'moderate' => t('Moderate'),
  35. 'suggestion' => t('Suggestion')
  36. ),
  37. '#default_value' => (isset($form['#instance']['accessibility_content_block_submit'])) ?
  38. $form['#instance']['accessibility_content_block_submit'] :
  39. FALSE,
  40. );
  41. }
  42. }
  43. /**
  44. * Implements hook_field_attach_view_alter().
  45. */
  46. function accessibility_content_field_attach_view_alter(&$output, $context) {
  47. if (user_access('check content for accessibility')) {
  48. foreach ($output as $field_key => $field) {
  49. if (is_array($field) && isset($field['#field_name'])) {
  50. $field = field_info_instance($field['#entity_type'], $field['#field_name'], $field['#bundle']);
  51. if (isset($field['accessibility_content']) && $field['accessibility_content']) {
  52. module_load_include('inc', 'accessibility_content', 'accessibility_content');
  53. accessibility_content_init();
  54. $output[$field_key]['#pre_render'][] = '_accessibility_content_field_pre_render';
  55. }
  56. }
  57. }
  58. }
  59. }
  60. /**
  61. * Implements field_widget_form_alter().
  62. */
  63. function accessibility_content_field_widget_form_alter(&$element, &$form_state, $context) {
  64. if (!isset($element['#type']) || !in_array($element['#type'], array('text_format'))) {
  65. return;
  66. }
  67. $field = field_info_instance($element['#entity_type'], $element['#field_name'], $element['#bundle']);
  68. $options = array();
  69. if (isset($field['accessibility_content_block_submit'])) {
  70. foreach ($field['accessibility_content_block_submit'] as $severity => $active) {
  71. if ($active) {
  72. $options[] = $severity;
  73. }
  74. }
  75. }
  76. if (!count($options)) {
  77. return;
  78. }
  79. drupal_add_js(array('accessibility_content_form_message' => variable_get('accessibility_disabled_form_message', t('You have been prevented from submitting this form because of the following accessibility errors.'))), 'setting');
  80. module_load_include('inc', 'accessibility_content');
  81. accessibility_content_init(array('form' => TRUE));
  82. $element['#attributes'] = (is_array($element['#attributes']['class'])) ? $element['#attributes']['class'] : array();
  83. $element['#attributes']['class'][] = 'accessible-content-check-form';
  84. $element['#attributes']['data-accessible-content-severity'] = implode(',', $options);
  85. }
  86. /**
  87. * Implements hook_permission().
  88. */
  89. function accessibility_content_permission() {
  90. return array(
  91. 'check content for accessibility' => array(
  92. 'title' => t('Check content for accessibility'),
  93. 'description' => t('Show accessibility problems in content the user has access to view.')
  94. ),
  95. );
  96. }