/[drupal]/contributions/modules/js/js.install
ViewVC logotype

Contents of /contributions/modules/js/js.install

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


Revision 1.2 - (show annotations) (download) (as text)
Thu Jul 23 10:47:04 2009 UTC (4 months ago) by sun
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +1 -2 lines
File MIME type: text/x-php
by sun: Minor code and documentation clean-up.
1 <?php
2 // $Id: js.install,v 1.1 2008/06/02 02:17:51 sun Exp $
3
4 /**
5 * @file
6 * Ensures JavaScript callback handler has been setup properly.
7 */
8
9 /**
10 * Implementation of hook_requirements().
11 */
12 function js_requirements($phase) {
13 $requirements = array();
14 $t = get_t();
15 switch ($phase) {
16 case 'install':
17 case 'runtime':
18 $path = drupal_get_path('module', 'js') .'/js.php';
19 $title = $t('JavaScript callback handler');
20 // Warn about missing js.php in root directoy.
21 if (file_exists($path) && file_exists('js.php') && md5_file($path) != md5_file('js.php')) {
22 $requirements['js'] = array(
23 'title' => $title,
24 'description' => $t('In order for JavaScript callbacks to work correctly, please copy the file at %mod and use it to replace %core.', array('%core' => 'js.php', '%mod' => $path)),
25 'severity' => $phase == 'install' ? REQUIREMENT_WARNING : REQUIREMENT_ERROR,
26 'value' => $t('Please copy js.php'),
27 );
28 }
29 // Warn about moved (instead of copied) js.php.
30 else if (!file_exists($path)) {
31 $requirements['js'] = array(
32 'title' => $title,
33 'description' => $t('You probably <em>moved</em> rather than <em>copied</em> the js.php file from %mod to %core. You should leave a copy of this file in the module directory so that you will not lose this file when you upgrade to another revision of Drupal.', array('%core' => 'js.php', '%mod' => $path)),
34 'severity' => $phase == 'install' ? REQUIREMENT_WARNING : REQUIREMENT_ERROR,
35 'value' => $t('js.php no longer exists in the js directory'),
36 );
37 }
38 else if ($phase == 'runtime') {
39 // Warn about disabled clean URLs.
40 if (!variable_get('clean_url', FALSE)) {
41 $requirements['js'] = array(
42 'title' => $title,
43 'description' => $t('In order for JavaScript callbacks to work correctly, please <a href="!clean-urls">enable clean URLs</a>', array('!clean-urls' => url('admin/settings/clean-urls'))),
44 'severity' => REQUIREMENT_ERROR,
45 'value' => $t('Enable clean URLs'),
46 );
47 }
48 // Warn about missing RewriteRule in .htaccess.
49 else if (strpos(file_get_contents('.htaccess'), 'js.php') === FALSE) {
50 $requirements['js'] = array(
51 'title' => $title,
52 'description' => $t('In order for increasing performance of JavaScript callbacks, please add the required <a href="!readme">RewriteRule</a>', array('!readme' => url(drupal_get_path('module', 'js') .'/README.txt'))),
53 'severity' => REQUIREMENT_WARNING,
54 'value' => $t('Add Apache RewriteRule to .htaccess'),
55 );
56 }
57 // Return positive status message.
58 else {
59 $requirements['js'] = array(
60 'title' => $title,
61 'description' => t('The JavaScript callback handler has been installed correctly.',
62 array('%core' => 'js.php')
63 ),
64 'severity' => REQUIREMENT_OK,
65 'value' => $t('Installed correctly'),
66 );
67 }
68 }
69 }
70 return $requirements;
71 }
72

  ViewVC Help
Powered by ViewVC 1.1.2