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

Contents of /contributions/modules/thumb/thumb.install

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


Revision 1.1 - (show annotations) (download) (as text)
Mon Nov 24 09:28:45 2008 UTC (12 months ago) by davyvandenbremt
Branch: MAIN
CVS Tags: HEAD
File MIME type: text/x-php
Initial commit of thumb module. Thumb is an thumbnail generator built on phpThumb
1 <?php
2 // $Id$
3
4 /**
5 * Implementation of hook_uninstall().
6 */
7 function thumb_install() {
8 drupal_install_schema('thumb');
9
10 $link = array('!link' => l(t('Administer > Site building > Thumb'), 'admin/build/thumb'));
11 drupal_set_message(t("Thumb presets can be managed under !link", $link));
12 }
13
14 /**
15 * Implementation of hook_uninstall().
16 */
17 function thumb_uninstall() {
18 drupal_uninstall_schema('thumb');
19
20 db_query("DELETE FROM {variable} WHERE name LIKE 'thumb_%'");
21 cache_clear_all('variables', 'cache');
22 }
23
24 /**
25 * Implementation of hook_schema().
26 */
27 function thumb_schema() {
28 $schema['thumb_preset'] = array(
29 'description' => t("Stores thumb presets."),
30 'fields' => array(
31 'pid' => array(
32 'type' => 'serial',
33 'unsigned' => TRUE,
34 'not null' => TRUE,
35 'description' => t("The primary identifier for a thumb preset."),
36 ),
37 'identifier' => array(
38 'type' => 'varchar',
39 'default' => '',
40 'length' => 32,
41 'not null' => TRUE,
42 'description' => t('Identifier of the preset.'),
43 ),
44 'description' => array(
45 'type' => 'text',
46 'not null' => TRUE,
47 'size' => 'big',
48 'description' => t('Description of this preset.'),
49 ),
50 'data' => array(
51 'type' => 'text',
52 'not null' => TRUE,
53 'size' => 'big',
54 'description' => t('The values for the data in this preset.'),
55 ),
56 ),
57 'primary key' => array('pid'),
58 'unique keys' => array(
59 'identifier' => array('identifier'),
60 ),
61 'indexes' => array(
62 'pid' => array('pid'),
63 ),
64 );
65
66 return $schema;
67 }
68
69 /**
70 * Implementation of hook_requirements().
71 */
72 function thumb_requirements($phase) {
73 $requirements = array();
74
75 $t = get_t();
76
77 switch ($phase) {
78 case 'install':
79 case 'runtime':
80 $path = drupal_get_path('module', 'thumb');
81 if (!file_exists($path .'/phpThumb/')) {
82 $requirements['thumb'] = array(
83 'title' => $t('Thumb'),
84 'description' => $t('In order for the Thumb module to work correctly, the phpThumb directory must exist at !path.', array('!path' => $path .'/phpThumb')),
85 'severity' => $phase == 'install' ? REQUIREMENT_WARNING : REQUIREMENT_ERROR,
86 'value' => $t('Install phpThumb'),
87 );
88 }
89 elseif (!file_exists($path .'/phpThumb/phpthumb.class.php')) {
90 $requirements['thumb'] = array(
91 'title' => $t('Thumb'),
92 'description' => $t('The !path path exists but it appears that the directory structure underneath is incorrect. Please check that !phpthumb exist.', array('!path' => $path .'/phpThumb', '%phpthumb' => $path .'/phpthumb/phpthumb.class.php')),
93 'severity' => $phase == 'install' ? REQUIREMENT_WARNING : REQUIREMENT_ERROR,
94 'value' => $t('Install phpThumb'),
95 );
96 }
97 elseif ($phase == 'runtime') {
98 $requirements['thumb'] = array(
99 'title' => $t('Thumb'),
100 'severity' => REQUIREMENT_OK,
101 'value' => $t('Installed correctly'),
102 );
103 }
104 }
105
106 if ($phase == 'runtime') {
107
108 $thumb_directory = file_create_path() .'/thumb';
109
110 if (!file_check_directory($thumb_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
111 if (!is_dir($thumb_directory)) {
112 $requirements['thumb_directory'] = array(
113 'title' => $t('Thumb files directory'),
114 'value' => $t('%p does not a directory or is not readable by the webserver.', array('%p' => $thumb_directory)),
115 'severity' => REQUIREMENT_ERROR,
116 );
117 }
118 elseif (!is_writable($thumb_directory)) {
119 $requirements['thumb_directory'] = array(
120 'title' => $t('Thumb files directory'),
121 'value' => $t('%p is not writeable by the webserver.', array('%p' => $thumb_directory)),
122 'severity' => REQUIREMENT_ERROR,
123 );
124 }
125 else {
126 $requirements['thumb_directory'] = array(
127 'title' => $t('Thumb files directory'),
128 'value' => $t('An unknown error occured.'),
129 'description' => $t('An unknown error occured trying to verify %p is a directory and is writable.', array('%p' => $thumb_directory)),
130 'severity' => REQUIREMENT_ERROR,
131 );
132 }
133 }
134
135 if (!is_writable(file_directory_temp())) {
136 $requirements['thumb_tmp_directory'] = array(
137 'title' => $t('Thumb files directory'),
138 'value' => $t('%p is not writeable by the webserver.', array('%p' => file_directory_temp())),
139 'severity' => REQUIREMENT_ERROR,
140 );
141 }
142 }
143
144 return $requirements;
145 }

  ViewVC Help
Powered by ViewVC 1.1.2