accessibility-8.x-1.x-dev/accessibility.admin.inc

accessibility.admin.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
 
/**
 * Batch import finished callback.
 */
function accessibility_tests_list_done($success, $results, $operations) {
  if ($success) {
    // Here we do something meaningful with the results.
    $message = count($results) . ' imported.';
    $message .= theme('item_list', $results);
  }
  else {
    // An error occurred.
    // $operations contains the operations that remained unprocessed.
    $error_operation = reset($operations);
    $message = t('An error occurred while processing %error_operation with arguments: @arguments', array('%error_operation' => $error_operation[0], '@arguments' => print_r($error_operation[1], TRUE)));
  }
  drupal_set_message($message);
}
 
/**
 * Creates a test entity from a quail test.
 */
function _accessibility_create_test_from_quail($quail_name, $test, &$context) {
  $language = language_default();
  $new_test = entity_create('accessibility_test', array(
      'language' => $language->id,
      'quail_name' => $quail_name,
      'name' => $test['title'],
      'severity' => (isset($test['severity'])) ? $test['severity'] : 'suggestion',
      'status' => 1
    ));
  $new_test->set('error_description', array('value'  => $test['description'],
                                         'format' => filter_default_format()
      ));
  $new_test->save();
  $context['message'] = t('Done importing @name', array('@name' => $new_test->name));
  $context['results'][] = $new_test->name;
}
 
/**
 * Form to filter accessibility tests.
 */
function accessibility_admin_filter_form($form, $form_state) {
  $form = array();
 
  $filter = (isset($_SESSION['accessibility_admin_filter'])) ? $_SESSION['accessibility_admin_filter'] : array();
 
  $form['filters'] = array(
    '#type' => 'fieldset'
    );
 
  $form['filters']['name'] = array(
    '#title' => t('Test name contains'),
    '#type' => 'textfield',
    '#default_value' => (isset($filter['name']) ? $filter['name'] : array())
  );
 
  $form['filters']['severity'] = array(
    '#title' => t('Severity level'),
    '#type' => 'checkboxes',
    '#options' => array(
      ACCESSIBILITY_TEST_SEVERE => t('Severe'),
      ACCESSIBILITY_TEST_MODERATE => t('Moderate'),
      ACCESSIBILITY_TEST_SUGGESTION => t('Suggestion'),
    ),
    '#default_value' => (isset($filter['severity']) ? $filter['severity'] : array())
  );
 
  $form['filters']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Search'),
    );
 
  $form['filters']['reset'] = array(
    '#type' => 'submit',
    '#value' => t('Reset'),
    );
 
  return $form;
}
 
/**
 * Form submit callback for filter form.
 */
function accessibility_admin_filter_form_submit($form, $form_state) {
  $_SESSION['accessibility_admin_filter'] = $form_state['values'];
  if ($form_state['clicked_button']['#value'] == t('Reset')) {
    $_SESSION['accessibility_admin_filter'] = array();
  }
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc