5 * Contains install and update functions for ctools.
9 * Use requirements to ensure that the CTools CSS cache directory can be
10 * created and that the PHP version requirement is met.
12 function ctools_requirements($phase) {
13 $requirements = array();
14 if ($phase == 'runtime') {
15 $requirements['ctools_css_cache'] = array(
16 'title' => t('CTools CSS Cache'),
17 'severity' => REQUIREMENT_OK
,
18 'value' => t('Exists'),
21 $path = 'public://ctools/css';
22 if (!file_prepare_directory($path, FILE_CREATE_DIRECTORY
)) {
23 $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' => file_uri_target($path)));
24 $requirements['ctools_css_cache']['severity'] = REQUIREMENT_ERROR
;
25 $requirements['ctools_css_cache']['value'] = t('Unable to create');
28 if (!function_exists('error_get_last')) {
29 $requirements['ctools_php_52']['title'] = t('CTools PHP requirements');
30 $requirements['ctools_php_52']['description'] = t('CTools requires certain features only available in PHP 5.2.0 or higher.');
31 $requirements['ctools_php_52']['severity'] = REQUIREMENT_WARNING
;
32 $requirements['ctools_php_52']['value'] = t('PHP !version', array('!version' => phpversion()));
40 * Implements hook_schemea
42 function ctools_schema() {
43 return ctools_schema_2();
47 * Version 2 of the CTools schema.
49 function ctools_schema_2() {
50 $schema = ctools_schema_1();
52 // update the 'name' field to be 128 bytes long:
53 $schema['ctools_object_cache']['fields']['name']['length'] = 128;
55 // DO NOT MODIFY THIS TABLE -- this definition is used to create the table.
56 // Changes to this table must be made in schema_3 or higher.
57 $schema['ctools_css_cache'] = array(
58 'description' => 'A special cache used to store CSS that must be non-volatile.',
63 'description' => 'The CSS ID this cache object belongs to.',
69 'description' => 'The filename this CSS is stored in.',
74 'description' => 'CSS being stored.',
80 'description' => 'Whether or not this CSS needs to be filtered.',
83 'primary key' => array('cid'),
90 * CTools' initial schema; separated for the purposes of updates.
92 * DO NOT MAKE CHANGES HERE. This schema version is locked.
94 function ctools_schema_1() {
95 $schema['ctools_object_cache'] = array(
96 'description' => t('A special cache used to store objects that are being edited; it serves to save state in an ordinarily stateless environment.'),
102 'description' => 'The session ID this cache object belongs to.',
108 'description' => 'The name of the object this cache is attached to.',
114 '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.',
121 'description' => 'The time this cache was created or updated.',
126 'description' => 'Serialized data being stored.',
130 'primary key' => array('sid', 'obj', 'name'),
131 'indexes' => array('updated' => array('updated')),
137 * Enlarge the ctools_object_cache.name column to prevent truncation and weird
140 function ctools_update_6001() {
141 // Perform updates like this to reduce code duplication.
142 $schema = ctools_schema_2();
144 db_change_field('ctools_object_cache', 'name', 'name', $schema['ctools_object_cache']['fields']['name']);
148 * Add the new css cache table.
150 function ctools_update_6002() {
151 // Schema 2 is locked and should not be changed.
152 $schema = ctools_schema_2();
154 db_create_table('ctools_css_cache', $schema['ctools_css_cache']);
158 * Take over for the panels_views module if it was on.
160 function ctools_update_6003() {
161 $result = db_query('SELECT status FROM {system} WHERE name = :name', array(':name' => 'panels_views'))->fetchField();
163 db_delete('system')->condition('name', 'panels_views')->execute();
164 module_enable(array('views_content'), TRUE
);
169 * Add primary key to the ctools_object_cache table.
171 function ctools_update_6004() {
172 db_add_primary_key('ctools_object_cache', array('sid', 'obj', 'name'));
173 db_drop_index('ctools_object_cache', 'sid_obj_name');
179 function ctools_update_6005() {
184 * ctools_custom_content table was originally here, but is now moved to
187 function ctools_update_6007() {
189 if (db_table_exists('ctools_custom_content')) {
190 // Enable the module to make everything as seamless as possible.
191 module_enable(array('ctools_custom_content'), TRUE
);