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

Contents of /contributions/modules/custom_breadcrumbs/custom_breadcrumbs.install

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


Revision 1.4 - (show annotations) (download) (as text)
Sun Oct 4 19:20:16 2009 UTC (7 weeks, 6 days ago) by mgn
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-7--1
Changes since 1.3: +28 -10 lines
File MIME type: text/x-php
Updating HEAD for D7 development
1 <?php
2 // $Id$
3
4 /**
5 * @file
6 * Install file for the custom_breadcrumbs module.
7 */
8
9 /**
10 * Implementation of hook_install().
11 */
12 function custom_breadcrumbs_install() {
13 drupal_install_schema('custom_breadcrumbs');
14 }
15
16 function custom_breadcrumbs_schema() {
17 $schema['custom_breadcrumb'] = array(
18 'description' => 'Stores custom breadcrumb trail overrides.',
19 'fields' => array(
20 'bid' => array(
21 'type' => 'serial',
22 'unsigned' => TRUE,
23 'not null' => TRUE,
24 'description' => 'Unique identifier for the {custom_breadcrumb}.',
25 ),
26 'titles' => array(
27 'type' => 'varchar',
28 'length' => 255,
29 'not null' => TRUE,
30 'default' => '',
31 'description' => 'A return-delimited list of titles for the breadcrumb links.',
32 ),
33 'paths' => array(
34 'type' => 'varchar',
35 'length' => 255,
36 'not null' => FALSE,
37 'description' => 'A return-delimited list of url paths for the breadcrumb links.',
38 ),
39 'visibility_php' => array(
40 'type' => 'text',
41 'not null' => TRUE,
42 'size' => 'medium',
43 'description' => 'An optional PHP snippet to control the {custom_breadcrumb} visibility.',
44 ),
45 'node_type' => array(
46 'type' => 'varchar',
47 'length' => 64,
48 'not null' => FALSE,
49 'default' => 'AND',
50 'description' => 'Node types the {custom_breadcrumb} should apply to.',
51 ),
52 ),
53 'primary key' => array('bid'),
54 );
55 return $schema;
56 }
57
58
59 // Update old-style tokens from early versions of token.module.
60 // Most users aren't using them, but we might as well handle them
61 // properly.
62
63 function custom_breadcrumbs_update_1() {
64 $stuff = array(
65 '%author_id' => '[author-uid]',
66 '%author_name' => '[author-name]',
67 '%user_id' => '[user-id]',
68 '%user_name' => '[user-name]',
69 '%node_id' => '[nid]',
70 '%node_type' => '[type]',
71 '%node_type_name' => '[type-name]',
72 '%top_term' => '[term]',
73 '%top_tname' => '[term-id]',
74 '%created_d' => '[dd]',
75 '%created_D' => '[ddd]',
76 '%created_j' => '[d]',
77 '%created_l' => '[day]',
78 '%created_F' => '[month]',
79 '%created_m' => '[mm]',
80 '%created_M' => '[mon]',
81 '%created_n' => '[m]',
82 '%created_y' => '[yy]',
83 '%created_Y' => '[yyyy]',
84 );
85
86 $search = array_keys($stuff);
87 $replace = array_values($stuff);
88
89 $result = db_query("SELECT * FROM {custom_breadcrumb} cb");
90 while ($crumb = db_fetch_object($result)) {
91 $crumb->titles = str_replace($search, $replace, $crumb->titles);
92 $crumb->paths = str_replace($search, $replace, $crumb->paths);
93 custom_breadcrumbs_save_breadcrumb($crumb);
94 }
95
96 return array(t('Custom Breadcrumb replacement strings updated for use with Token module.'));
97 }
98
99 function custom_breadcrumbs_update_2() {
100 $ret = array();
101 switch ($GLOBALS['db_type']) {
102 case 'mysql':
103 case 'mysqli':
104 $ret[] = update_sql("ALTER TABLE {custom_breadcrumb} ADD visibility_php text NOT NULL default ''");
105 break;
106 case 'pgsql':
107 db_add_column($ret, 'custom_breadcrumb', 'visibility_php', 'text', array('not null' => TRUE, 'default' => "''"));
108 break;
109 }
110 return $ret;
111 }
112
113 // Add the menu flag.
114 function custom_breadcrumbs_update_6001() {
115 $ret = array();
116 db_add_field($ret, 'custom_breadcrumb', 'set_active_menu', array('type' => 'int', 'default' => 1, 'NOT NULL' => TRUE));
117 return $ret;
118 }
119
120 // Remove the menu flag.
121 function custom_breadcrumbs_update_6101() {
122 $ret = array();
123 db_drop_field($ret, 'custom_breadcrumb', 'set_active_menu');
124 return $ret;
125 }
126
127 function custom_breadcrumbs_uninstall() {
128 drupal_uninstall_schema('custom_breadcrumbs');
129 }

  ViewVC Help
Powered by ViewVC 1.1.2