/[drupal]/contributions/modules/ac/ac.module
ViewVC logotype

Contents of /contributions/modules/ac/ac.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.4 - (show annotations) (download) (as text)
Wed Jun 17 08:43:33 2009 UTC (5 months, 1 week ago) by ac
Branch: MAIN
CVS Tags: DRUPAL-6--1-5, HEAD
Changes since 1.3: +2 -2 lines
File MIME type: text/x-php
New maintainer. #451572 by ac: use post instead of get
1 <?php
2 // $Id: ac.module,v 1.4 2009/06/17 22:48:15 ac Exp $
3
4 /**
5 * @file
6 * Ajax callback controller API.
7 * @author Tj Holowaychuk <tj@vision-media.ca>
8 * @maintainer ac <alex@spoon.com.au>
9 * @package ac
10 */
11
12 /**
13 * @name Callback Status
14 * @{
15 */
16
17 /**
18 * Indicates that an error has occurred and 'message' is considered
19 * an optional error message.
20 */
21 define('AC_STATUS_ERROR', 0);
22
23 /**
24 * Indicates that the request was successful and 'message is considered
25 * an optional success message.
26 */
27 define('AC_STATUS_OK', 1);
28
29 /**
30 * Indicates that the 'message is considered an optional warning message.
31 */
32 define('AC_STATUS_WARNING', 2);
33
34 /**
35 * Default error message to display when none is provided.
36 * The message defaults to "An error has occurred".
37 */
38 define('AC_STATUS_ERROR_MESSAGE', variable_get('ac_error_message', t('An error has occurred.')));
39
40 /**
41 * @} End of "Callback Status".
42 */
43
44 /**
45 * @name Output Formats
46 * @{
47 */
48
49 /**
50 * Format output as JavaScript Object Notation.
51 */
52 define('AC_OUTPUT_JSON', 1);
53
54 /**
55 * @} End of "Output Formats".
56 */
57
58 /**
59 * @name Output Encoding
60 * @{
61 */
62
63 /**
64 * Do not encode output.
65 */
66 define('AC_ENCODING_PLAIN', 0);
67
68 /**
69 * Compress output using Gzip.
70 *
71 * NOTE: data returned with a small string length should NOT
72 * be Gzipped since this requires additional CPU cycles and may
73 * prove to waste resources, rather than improving performance.
74 */
75 define('AC_ENCODING_GZIP', 1);
76
77 /**
78 * Automatically assign output encoding.
79 *
80 * NOTE: when data may benefit from gzip compression
81 * then AC_ENCODING_GZIP will be used, otherwise
82 * AC_ENCODING_PLAIN is used.
83 */
84 define('AC_ENCODING_AUTO', 2);
85
86 /**
87 * Auto compression threshold.
88 *
89 * NOTE: when using AC_ENCODING_AUTO only once
90 * the length out output is larger than this value
91 * will it be compressed via AC_ENCODING_GZIP. This
92 * is generally a good idea as only large bodies of text
93 * will really benefit from compression.
94 */
95 define('AC_ENCODING_AUTO_THRESHOLD', variable_get('ac_encoding_auto_threshold', 1500));
96
97 /**
98 * Wither or not PHP compression can occur.
99 *
100 * This constant utilizes Drupal's page compression
101 * option which can disable PHP compression for those
102 * of you using Apache's mod_deflate.
103 */
104 define('AC_ENCODING_MAY_COMPRESS', variable_get('page_compression', TRUE));
105
106 /**
107 * @} End of "Output Encoding".
108 */
109
110 /* -----------------------------------------------------------------
111
112 Hook Implementations
113
114 ------------------------------------------------------------------ */
115
116 /**
117 * Implementation of hook_init().
118 */
119 function ac_init() {
120 $_SESSION['ac_token'] = drupal_get_token('ac');
121 drupal_add_js(array('ac' => array('token' => $_SESSION['ac_token'])), 'setting');
122 drupal_add_js(drupal_get_path('module', 'ac') . '/ac.js');
123 }
124
125 /**
126 * Implementation of hook_menu().
127 */
128 function ac_menu(){
129 $items = array();
130
131 $items['js/%/%'] = array(
132 'page callback' => 'ac_process_request',
133 'page arguments' => array(1, 2),
134 'access callback' => 'user_access',
135 'access arguments' => array('access content'),
136 'file' => 'ac.inc',
137 );
138
139 return $items;
140 }

  ViewVC Help
Powered by ViewVC 1.1.2