[177a560] | 1 | <?php |
---|
| 2 | // $Id: pathauto.install,v 1.13.2.1 2009/10/17 17:37:27 greggles Exp $ |
---|
| 3 | |
---|
| 4 | /** |
---|
| 5 | * @file |
---|
| 6 | * Install, update, and uninstall functions for Pathauto. |
---|
| 7 | * |
---|
| 8 | * @ingroup pathauto |
---|
| 9 | */ |
---|
| 10 | |
---|
| 11 | /** |
---|
| 12 | * Implementation of hook_install(). |
---|
| 13 | */ |
---|
| 14 | function pathauto_install() { |
---|
| 15 | // Check to see if taxonomy module is enabled before we set those variables |
---|
| 16 | if (module_exists('taxonomy')) { |
---|
| 17 | variable_set('pathauto_modulelist', array('node', 'user', 'taxonomy')); |
---|
| 18 | variable_set('pathauto_taxonomy_supportsfeeds', '0/feed'); |
---|
| 19 | variable_set('pathauto_taxonomy_pattern', 'category/[vocab-raw]/[catpath-raw]'); |
---|
| 20 | variable_set('pathauto_taxonomy_bulkupdate', FALSE); |
---|
| 21 | variable_set('pathauto_taxonomy_applytofeeds', FALSE); |
---|
| 22 | variable_set('pathauto_taxonomy_2_pattern', ''); |
---|
| 23 | variable_set('pathauto_taxonomy_1_pattern', ''); |
---|
| 24 | } |
---|
| 25 | else { |
---|
| 26 | // Node and user are required so we don't have to check |
---|
| 27 | variable_set('pathauto_modulelist', array('node', 'user')); |
---|
| 28 | } |
---|
| 29 | // Set the rest of the pathauto default variables |
---|
| 30 | variable_set('pathauto_ignore_words', 'a,an,as,at,before,but,by,for,from,is,in,into,like,of,off,on,onto,per,since,than,the,this,that,to,up,via,with'); |
---|
| 31 | variable_set('pathauto_indexaliases', FALSE); |
---|
| 32 | variable_set('pathauto_indexaliases_bulkupdate', FALSE); |
---|
| 33 | variable_set('pathauto_max_component_length', '100'); |
---|
| 34 | variable_set('pathauto_max_length', '100'); |
---|
| 35 | variable_set('pathauto_node_bulkupdate', FALSE); |
---|
| 36 | variable_set('pathauto_node_forum_pattern', ''); |
---|
| 37 | variable_set('pathauto_node_image_pattern', ''); |
---|
| 38 | variable_set('pathauto_node_page_pattern', ''); |
---|
| 39 | variable_set('pathauto_node_pattern', 'content/[title-raw]'); |
---|
| 40 | variable_set('pathauto_node_story_pattern', ''); |
---|
| 41 | variable_set('pathauto_punctuation_quotes', 0); |
---|
| 42 | variable_set('pathauto_separator', '-'); |
---|
| 43 | variable_set('pathauto_update_action', '2'); |
---|
| 44 | variable_set('pathauto_user_bulkupdate', FALSE); |
---|
| 45 | variable_set('pathauto_user_pattern', 'users/[user-raw]'); |
---|
| 46 | variable_set('pathauto_user_supportsfeeds', NULL); |
---|
| 47 | variable_set('pathauto_verbose', FALSE); |
---|
| 48 | variable_set('pathauto_node_applytofeeds', ''); |
---|
| 49 | |
---|
| 50 | // Make sure we "replace hyphen with separator" by default |
---|
| 51 | variable_set('pathauto_punctuation_hyphen', 1); // 1 is replace |
---|
| 52 | |
---|
| 53 | // Set the weight to 1 |
---|
| 54 | db_query("UPDATE {system} SET weight = 1 WHERE name = 'pathauto'"); |
---|
| 55 | |
---|
| 56 | // Clear the cache to get these to take effect. |
---|
| 57 | cache_clear_all(); |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | /** |
---|
| 61 | * Implementation of hook_uninstall(). |
---|
| 62 | */ |
---|
| 63 | function pathauto_uninstall() { |
---|
| 64 | // Delete all the pathauto variables and then clear the variable cache |
---|
| 65 | db_query("DELETE FROM {variable} WHERE name LIKE 'pathauto_%'"); |
---|
| 66 | cache_clear_all('variables', 'cache'); |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | /** |
---|
| 70 | * Set the weight a little heavier to allow taxonomy to do its work. |
---|
| 71 | */ |
---|
| 72 | function pathauto_update_1() { |
---|
| 73 | $ret = array(); |
---|
| 74 | $ret[] = update_sql("UPDATE {system} SET weight = 1 WHERE name = 'pathauto'"); |
---|
| 75 | return $ret; |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | /** |
---|
| 79 | * pathauto_update_4 was a backport of a feature which is in core of Drupal 6 |
---|
| 80 | * hence it is removed from the 6.x branch even though the goal is to support |
---|
| 81 | * Pathauto 5.x-1.x -> 6.x-2.x upgrades. |
---|
| 82 | */ |
---|
| 83 | |
---|
| 84 | /** |
---|
| 85 | * Delete the pathauto_node_supportsfeeds. |
---|
| 86 | */ |
---|
| 87 | function pathauto_update_3() { |
---|
| 88 | // Do nothing, this update was a mistake |
---|
| 89 | return array(); |
---|
| 90 | } |
---|
| 91 | |
---|
| 92 | /** |
---|
| 93 | * New style naming for the punctuation chars. |
---|
| 94 | */ |
---|
| 95 | function pathauto_update_4() { |
---|
| 96 | variable_set('pathauto_punctuation_quotes', variable_get('pathauto_quotes', 0)); |
---|
| 97 | variable_del('pathauto_quotes'); |
---|
| 98 | return array(); |
---|
| 99 | } |
---|
| 100 | |
---|
| 101 | /** |
---|
| 102 | * Remove the url_alias_extra table which wasn't used. |
---|
| 103 | */ |
---|
| 104 | function pathauto_update_7() { |
---|
| 105 | $ret = array(); |
---|
| 106 | if (db_table_exists('url_alias_extra')) { |
---|
| 107 | db_drop_table($ret, 'url_alias_extra'); |
---|
| 108 | } |
---|
| 109 | return $ret; |
---|
| 110 | } |
---|