1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Helper module for Ajax framework tests.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* Implements hook_menu().
|
10 |
|
|
*/
|
11 |
|
|
function ajax_test_menu() {
|
12 |
|
|
$items['ajax-test/render'] = array(
|
13 |
|
|
'title' => 'ajax_render',
|
14 |
|
|
'page callback' => 'ajax_test_render',
|
15 |
|
|
'delivery callback' => 'ajax_deliver',
|
16 |
|
|
'access callback' => TRUE,
|
17 |
|
|
'type' => MENU_CALLBACK,
|
18 |
|
|
);
|
19 |
|
|
$items['ajax-test/render-error'] = array(
|
20 |
|
|
'title' => 'ajax_render_error',
|
21 |
|
|
'page callback' => 'ajax_test_error',
|
22 |
|
|
'delivery callback' => 'ajax_deliver',
|
23 |
|
|
'access callback' => TRUE,
|
24 |
|
|
'type' => MENU_CALLBACK,
|
25 |
|
|
);
|
26 |
|
|
$items['ajax-test/link'] = array(
|
27 |
|
|
'title' => 'AJAX Link',
|
28 |
|
|
'page callback' => 'ajax_test_link',
|
29 |
|
|
'access callback' => TRUE,
|
30 |
|
|
);
|
31 |
|
|
return $items;
|
32 |
|
|
}
|
33 |
|
|
|
34 |
|
|
/**
|
35 |
|
|
* Implements hook_system_theme_info().
|
36 |
|
|
*/
|
37 |
|
|
function ajax_test_system_theme_info() {
|
38 |
|
|
$themes['test_theme'] = drupal_get_path('module', 'ajax_test') . '/themes/test_theme/test_theme.info';
|
39 |
|
|
return $themes;
|
40 |
|
|
}
|
41 |
|
|
|
42 |
|
|
/**
|
43 |
|
|
* Menu callback; Return an element suitable for use by ajax_deliver().
|
44 |
|
|
*
|
45 |
|
|
* Additionally ensures that ajax_render() incorporates JavaScript settings
|
46 |
|
|
* generated during the page request by invoking drupal_add_js() with a dummy
|
47 |
|
|
* setting.
|
48 |
|
|
*/
|
49 |
|
|
function ajax_test_render() {
|
50 |
|
|
drupal_add_js(array('ajax' => 'test'), 'setting');
|
51 |
|
|
return array('#type' => 'ajax', '#commands' => array());
|
52 |
|
|
}
|
53 |
|
|
|
54 |
|
|
/**
|
55 |
|
|
* Menu callback; Returns Ajax element with #error property set.
|
56 |
|
|
*/
|
57 |
|
|
function ajax_test_error() {
|
58 |
|
|
$message = '';
|
59 |
|
|
if (!empty($_GET['message'])) {
|
60 |
|
|
$message = $_GET['message'];
|
61 |
|
|
}
|
62 |
|
|
return array('#type' => 'ajax', '#error' => $message);
|
63 |
|
|
}
|
64 |
|
|
|
65 |
|
|
/**
|
66 |
|
|
* Menu callback; Renders a #type link with #ajax.
|
67 |
|
|
*/
|
68 |
|
|
function ajax_test_link() {
|
69 |
|
|
$build['link'] = array(
|
70 |
|
|
'#type' => 'link',
|
71 |
|
|
'#title' => 'Show help',
|
72 |
|
|
'#href' => 'filter/tips',
|
73 |
|
|
'#ajax' => array(
|
74 |
|
|
'wrapper' => 'block-system-main',
|
75 |
|
|
),
|
76 |
|
|
);
|
77 |
|
|
return $build;
|
78 |
|
|
}
|