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

Diff of /contributions/modules/nodewords_bypath/nodewords_bypath.install

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

revision 1.1, Tue Jun 17 18:36:25 2008 UTC revision 1.1.2.1, Tue Jun 17 18:36:25 2008 UTC
# Line 0  Line 1 
1    <?php
2    // $Id$
3    
4    /**
5     * @file Provides the (un)installation logic for the Meta Tags by Path
6     *       module.
7     */
8    
9    
10    /**
11     * Implementation of hook_install().
12     */
13    function nodewords_bypath_install() {
14            switch ($GLOBALS['db_type']) {
15                    case 'mysql':
16                    case 'mysqli':
17                      // -----------------------------------------------------------------------
18                      // Maps a Drupal path expression or PHP logic to a set of meta tags and
19                      // their values that should be placed in the HTML head on pages matching
20                      // that expression.
21                      //
22                      // The 'type' column indicates whether the path_expr is a list of paths
23                      // or a block of PHP code. The allowed values are:
24                      //        0 - Reserved (don't use)
25                      //        1 - Show on only the listed pages.
26                      //        2 - Show if path_expr contains PHP code that returns TRUE
27                      //
28                      // 'weight' is the order in which the expressions are evaluated. Items
29                      // with lower weights are evaluated before items with higher weights.
30                      db_query("CREATE TABLE {nodewords_bypath_rules} (
31                                             id          int        unsigned NOT NULL,
32                                             name        varchar(128)        NOT NULL,
33                                             type        tinyint(1) unsigned NOT NULL default 1,
34                                             path_expr   text                NOT NULL,
35                                             weight      tinyint             NOT NULL default 0,
36                                       PRIMARY KEY (id)
37                               )"
38                      );
39    
40                      db_query('CREATE TABLE {nodewords_bypath_tags} (
41                                             rule_id    int unsigned NOT NULL,
42                                             meta_tag   varchar(32)  NOT NULL,
43                                             meta_value text,
44                                       PRIMARY KEY (rule_id, meta_tag)
45                               )'
46                      );
47    
48                            $success = TRUE;
49                            break;
50                    default:
51                            drupal_set_message(t('Unsupported database.'));
52            }
53    
54            if ($success) {
55                    drupal_set_message(t('Meta tags by path installed all tables successfully.'));
56            }
57            else {
58                    drupal_set_message(t('Meta tags by path could not be installed.'), 'error');
59            }
60    }
61    
62    
63    /**
64     * Implementation of hook_uninstall().
65     */
66    function nodewords_bypath_uninstall() {
67            switch ($GLOBALS['db_type']) {
68                    case 'mysql':
69                    case 'mysqli':
70                      db_query('DROP TABLE IF EXISTS {nodewords_bypath_rules} CASCADE');
71                      db_query('DROP TABLE IF EXISTS {nodewords_bypath_tags} CASCADE');
72                            $success = TRUE;
73                            break;
74                    default:
75                            drupal_set_message(t('Unsupported database.'));
76            }
77    
78            if ($success) {
79                    drupal_set_message(t('Meta tags by path uninstalled successfully.'));
80            }
81            else {
82                    drupal_set_message(t('Meta tags by path could not be uninstalled.'), 'error');
83            }
84    }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.1.2.1

  ViewVC Help
Powered by ViewVC 1.1.2