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