source: sipes/modules_contrib/ctools/ctools.install @ 6e81fb4

stableversion-3.0
Last change on this file since 6e81fb4 was 2efe680, checked in by José Gregorio Puentes <jpuentes@…>, 8 años ago

se actualizo el modulo

  • Propiedad mode establecida a 100755
File size: 6.4 KB
Línea 
1<?php
2
3/**
4 * @file
5 * Contains install and update functions for ctools.
6 */
7
8/**
9 * Use requirements to ensure that the CTools CSS cache directory can be
10 * created and that the PHP version requirement is met.
11 */
12function ctools_requirements($phase) {
13  $requirements = array();
14  if ($phase == 'runtime') {
15    $path = file_create_path('ctools/css');
16    if (!file_check_directory($path)) {
17      $path = file_directory_path() . '/ctools';
18      file_check_directory($path, FILE_CREATE_DIRECTORY);
19      $path .= '/css';
20      file_check_directory($path, FILE_CREATE_DIRECTORY);
21    }
22
23    $requirements['ctools_css_cache'] = array(
24      'title' => t('CTools CSS Cache'),
25      'severity' => REQUIREMENT_OK,
26      'value' => t('Exists'),
27    );
28
29    if (!file_check_directory($path)) {
30      $requirements['ctools_css_cache']['description'] = t('The CTools CSS cache directory, %path could not be created due to a misconfigured files directory. Please ensure that the files directory is correctly configured and that the webserver has permission to create directories.', array('%path' => $path));
31      $requirements['ctools_css_cache']['severity'] = REQUIREMENT_ERROR;
32      $requirements['ctools_css_cache']['value'] = t('Unable to create');
33    }
34
35    if (!function_exists('error_get_last')) {
36          $requirements['ctools_php_52']['title'] = t('CTools PHP requirements');
37      $requirements['ctools_php_52']['description'] = t('CTools requires certain features only available in PHP 5.2.0 or higher.');
38      $requirements['ctools_php_52']['severity'] = REQUIREMENT_WARNING;
39      $requirements['ctools_php_52']['value'] = t('PHP !version', array('!version' => phpversion()));
40    }
41  }
42
43  return $requirements;
44}
45
46/**
47 * Implementation of hook_install()
48 */
49function ctools_install() {
50  drupal_install_schema('ctools');
51}
52
53/**
54 * Implementation of hook_uninstall()
55 */
56function ctools_uninstall() {
57  drupal_uninstall_schema('ctools');
58}
59
60/**
61 * Implementation of hook_schemea
62 */
63function ctools_schema() {
64  return ctools_schema_2();
65}
66
67/**
68 * Version 2 of the CTools schema.
69 */
70function ctools_schema_2() {
71  $schema = ctools_schema_1();
72
73  // update the 'name' field to be 128 bytes long:
74  $schema['ctools_object_cache']['fields']['name']['length'] = 128;
75
76  // DO NOT MODIFY THIS TABLE -- this definition is used to create the table.
77  // Changes to this table must be made in schema_3 or higher.
78  $schema['ctools_css_cache'] = array(
79    'description' => 'A special cache used to store CSS that must be non-volatile.',
80    'fields' => array(
81      'cid' => array(
82        'type' => 'varchar',
83        'length' => '128',
84        'description' => 'The CSS ID this cache object belongs to.',
85        'not null' => TRUE,
86      ),
87      'filename' => array(
88        'type' => 'varchar',
89        'length' => '255',
90        'description' => 'The filename this CSS is stored in.',
91      ),
92      'css' => array(
93        'type' => 'text',
94        'size' => 'big',
95        'description' => 'CSS being stored.',
96        'serialize' => TRUE,
97      ),
98      'filter' => array(
99         'type' => 'int',
100         'size' => 'tiny',
101         'description' => 'Whether or not this CSS needs to be filtered.',
102       ),
103    ),
104    'primary key' => array('cid'),
105  );
106
107  return $schema;
108}
109
110/**
111 * CTools' initial schema; separated for the purposes of updates.
112 *
113 * DO NOT MAKE CHANGES HERE. This schema version is locked.
114 */
115function ctools_schema_1() {
116  $schema['ctools_object_cache'] = array(
117    'description' => t('A special cache used to store objects that are being edited; it serves to save state in an ordinarily stateless environment.'),
118    'fields' => array(
119      'sid' => array(
120        'type' => 'varchar',
121        'length' => '64',
122        'not null' => TRUE,
123        'description' => 'The session ID this cache object belongs to.',
124      ),
125      'name' => array(
126        'type' => 'varchar',
127        'length' => '32',
128        'not null' => TRUE,
129        'description' => 'The name of the object this cache is attached to.',
130      ),
131      'obj' => array(
132        'type' => 'varchar',
133        'length' => '32',
134        'not null' => TRUE,
135        'description' => 'The type of the object this cache is attached to; this essentially represents the owner so that several sub-systems can use this cache.',
136      ),
137      'updated' => array(
138        'type' => 'int',
139        'unsigned' => TRUE,
140        'not null' => TRUE,
141        'default' => 0,
142        'description' => 'The time this cache was created or updated.',
143      ),
144      'data' => array(
145        'type' => 'text',
146        'size' => 'big',
147        'description' => 'Serialized data being stored.',
148        'serialize' => TRUE,
149      ),
150    ),
151    'primary key' => array('sid', 'obj', 'name'),
152    'indexes' => array('updated' => array('updated')),
153  );
154  return $schema;
155}
156
157/**
158 * Enlarge the ctools_object_cache.name column to prevent truncation and weird
159 * errors.
160 */
161function ctools_update_6001() {
162  $ret = array();
163
164  // Perform updates like this to reduce code duplication.
165  $schema = ctools_schema_2();
166
167  db_change_field($ret, 'ctools_object_cache', 'name', 'name', $schema['ctools_object_cache']['fields']['name']);
168
169  return $ret;
170}
171
172/**
173 * Add the new css cache table.
174 */
175function ctools_update_6002() {
176  $ret = array();
177
178  // Schema 2 is locked and should not be changed.
179  $schema = ctools_schema_2();
180
181  db_create_table($ret, 'ctools_css_cache', $schema['ctools_css_cache']);
182  return $ret;
183}
184
185/**
186 * Take over for the panels_views module if it was on.
187 */
188function ctools_update_6003() {
189  $ret = array();
190
191  $result = db_result(db_query("SELECT status FROM {system} WHERE name = 'panels_views'"));
192  if ($result) {
193    $ret[] = update_sql("DELETE from {system} WHERE name = 'panels_views'");
194    drupal_install_modules(array('views_content'));
195  }
196
197  return $ret;
198}
199
200/**
201 * Add primary key to the ctools_object_cache table.
202 */
203function ctools_update_6004() {
204  $ret = array();
205  db_add_primary_key($ret, 'ctools_object_cache', array('sid', 'obj', 'name'));
206  db_drop_index($ret, 'ctools_object_cache', 'sid_obj_name');
207  return $ret;
208}
209
210/**
211 * Removed update.
212 */
213function ctools_update_6005() {
214  return array();
215}
216
217/**
218 * ctools_custom_content table was originally here, but is now moved to
219 * its own module.
220 */
221function ctools_update_6007() {
222  $ret = array();
223  if (db_table_exists('ctools_custom_content')) {
224    // Enable the module to make everything as seamless as possible.
225    drupal_install_modules(array('ctools_custom_content'));
226  }
227
228  return $ret;
229}
230
231
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.