browser_test.module 1.97 KB
Newer Older
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
<?php
// $Id$

/**
 * @file
 * Provide various pages for testing the internal browser.
 */

/**
 * Implement hook_menu().
 */
function browser_test_menu() {
  $items['browser_test/print/get'] = array(
    'page callback' => 'browser_test_print_get',
    'access arguments' => array('access content'),
  );
  $items['browser_test/print/post'] = array(
    'page callback' => 'drupal_get_form',
    'page arguments' => array('browser_test_print_post_form'),
    'access arguments' => array('access content'),
  );

  $items['browser_test/refresh/meta'] = array(
    'page callback' => 'browser_test_refresh_meta',
    'access arguments' => array('access content'),
  );
  $items['browser_test/refresh/header'] = array(
    'page callback' => 'browser_test_refresh_header',
    'access arguments' => array('access content'),
  );

  return $items;
}

function browser_test_print_get() {
  echo $_GET['foo'];
  exit;
}

40
function browser_test_print_post_form($form, &$form_state) {
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
  $form['foo'] = array(
    '#type' => 'textfield',
  );
  $form['op'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
  );

  return $form;
}

function browser_test_print_post_form_submit($form, &$form_state) {
  echo $form_state['values']['foo'];
  exit;
}

function browser_test_refresh_meta() {
  if (!isset($_GET['refresh'])) {
59
    $url = url('browser_test/refresh/meta', array('absolute' => TRUE, 'query' => array('refresh' => 'true')));
60
61
62
63
64
65
66
67
    $element = array(
      '#tag' => 'meta',
      '#attributes' => array(
        'http-equiv' => 'Refresh',
        'content' => '0; URL=' . $url,
      ),
    );
    drupal_add_html_head($element, 'browser_test_refresh_meta');
68
69
70
71
72
73
74
75
    return '';
  }
  echo 'Refresh successful';
  exit;
}

function browser_test_refresh_header() {
  if (!isset($_GET['refresh'])) {
76
    $url = url('browser_test/refresh/header', array('absolute' => TRUE, 'query' => array('refresh' => 'true')));
77
    drupal_add_http_header('Location', $url);
78
79
80
81
82
    return '';
  }
  echo 'Refresh successful';
  exit;
}