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

Contents of /contributions/modules/title_rewrite/title_rewrite.install

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


Revision 1.2 - (show annotations) (download) (as text)
Thu Aug 7 18:13:13 2008 UTC (15 months, 3 weeks ago) by shannonlucas
Branch: MAIN
CVS Tags: DRUPAL-5--1-2, HEAD
Changes since 1.1: +21 -2 lines
File MIME type: text/x-php
[#290465] addressed default character set and collation for table. [#271653] Delete form now uses confirm_form()
1 <?php
2 // $Id: title_rewrite.install,v 1.1 2008/04/07 15:37:55 shannonlucas Exp $
3
4 /**
5 * @file
6 * Provides the (un)installation logic for the Title Reqrite module.
7 */
8
9
10 /**
11 * Implementation of hook_install().
12 */
13 function title_rewrite_install() {
14 drupal_set_message(t('Beginning installation of Title Rewrite module.'));
15 switch ($GLOBALS['db_type']) {
16 case 'mysql':
17 case 'mysqli':
18 // -----------------------------------------------------------------------
19 // Maps a Drupal path expression or PHP logic to a tokenized title
20 // (html->head->title) that should be placed on pages matching that
21 // expression.
22 //
23 // The 'type' column indicates whether the path_expr is a list of paths
24 // or a block of PHP code. The allowed values are:
25 // 0 - Reserved (don't use)
26 // 1 - Show on only the listed pages.
27 // 2 - Show if path_expr contains PHP code that returns TRUE
28 //
29 // 'weight' is the order in which the expressions are evaluated. Items
30 // with lower weights are evaluated before items with higher weights.
31 //
32 // The uniqueness of the name field is not required by the program logic.
33 // The constraint is added to force the user to choose a different
34 // name for each title pattern.
35 db_query('CREATE TABLE {title_rewrite} (
36 id int unsigned NOT NULL AUTO_INCREMENT,
37 name varchar(128) NOT NULL,
38 type tinyint(1) unsigned NOT NULL default 1,
39 path_expr varchar(4096) NOT NULL,
40 token_title varchar(1024) NOT NULL,
41 weight tinyint NOT NULL default 0,
42 PRIMARY KEY (id),
43 UNIQUE KEY (name)
44 ) /*!40100 DEFAULT CHARACTER SET UTF8 */ '
45 );
46
47 $success = TRUE;
48 break;
49 default:
50 drupal_set_message(t('Unsupported database.'));
51 }
52
53 if ($success) {
54 drupal_set_message(t('Title Rewrite installed all tables successfully.'));
55 }
56 else {
57 drupal_set_message(t('Title Rewrite could not be installed.'), 'error');
58 }
59 }
60
61
62 /**
63 * Implementation of hook_uninstall().
64 */
65 function title_rewrite_uninstall() {
66 drupal_set_message(t('Beginning removal of Title Rewrite module.'));
67 switch ($GLOBALS['db_type']) {
68 case 'mysql':
69 case 'mysqli':
70 db_query('DROP TABLE IF EXISTS {title_rewrite} CASCADE');
71 $success = TRUE;
72 break;
73 default:
74 drupal_set_message(t('Unsupported database.'));
75 }
76
77 if ($success) {
78 drupal_set_message(t("Title Rewrite's database tables were removed successfully."));
79 }
80 else {
81 drupal_set_message(t('Title Rewrite could not be uninstalled.'), 'error');
82 }
83 }
84
85
86 /**
87 * Ensure that the character set and collation for the table is set to UTF8.
88 */
89 function title_rewrite_update_1() {
90 $ret = array();
91
92 switch ($GLOBALS['db_type']) {
93 case 'mysql':
94 case 'mysqli':
95 $ret[] = update_sql("ALTER TABLE {title_rewrite} DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci");
96 break;
97 default:
98 drupal_set_message(t('Unsupported database.'));
99 }
100
101 return $ret;
102 }

  ViewVC Help
Powered by ViewVC 1.1.2