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

Contents of /contributions/modules/page_title/page_title.install

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


Revision 1.11 - (show annotations) (download) (as text)
Sat Aug 15 22:05:04 2009 UTC (3 months, 1 week ago) by njt1982
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-7--1, DRUPAL-7--2
Changes since 1.10: +65 -7 lines
File MIME type: text/x-php
Work on porting Page Title to Drupal 7
1 <?php
2 // $Id: page_title.install,v 1.10 2008/05/02 16:29:11 njt1982 Exp $
3
4 /**
5 * Implementation of hook_install().
6 */
7 function page_title_install() {
8 drupal_install_schema('page_title');
9 }
10
11
12 function page_title_schema() {
13 $schema['page_title'] = array(
14 'fields' => array(
15 'type' => array('type' => 'varchar', 'length' => 15, 'not null' => TRUE, 'default' => 'node'),
16 'id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
17 'page_title' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '')
18 ),
19 'primary key' => array('type', 'id'),
20 );
21
22 return $schema;
23 }
24
25
26 /**
27 * Implementation of hook_update_n().
28 */
29 function page_title_update_6200() {
30 $ret = array();
31
32 if (db_column_exists('page_title', 'id')) {
33 return $ret;
34 }
35
36 db_create_table($ret, 'page_title_temp', array(
37 'fields' => array(
38 'type' => array('type' => 'varchar', 'length' => 15, 'not null' => TRUE, 'default' => 'node'),
39 'id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
40 'page_title' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '')
41 ),
42 'primary key' => array('type', 'id'),
43 ));
44
45 $ret[] = update_sql('INSERT INTO {page_title_temp} (id, page_title) SELECT nid, page_title FROM {page_title}');
46
47 db_rename_table($ret, 'page_title', 'page_title_old');
48
49 db_rename_table($ret, 'page_title_temp', 'page_title');
50
51 $display_settings = variable_get('page_title_display', array());
52 foreach ($display_settings as $type) {
53 if ($type) {
54 variable_set('page_title_type_'. $type .'_showfield', 1);
55 }
56 }
57 variable_del('page_title_display');
58
59 return $ret;
60 }
61
62
63 /**
64 * Implementation of hook_uninstall().
65 */
66 function page_title_uninstall() {
67 drupal_uninstall_schema('page_title');
68
69 // Clear variables
70 variable_del('page_title_default');
71 variable_del('page_title_individual');
72 variable_del('page_title_front');
73 variable_del('page_title_blog');
74 variable_del('page_title_user');
75 variable_del('page_title_user_showfield');
76 variable_del('page_title_pager_pattern');
77
78 // Clear the node specific variables
79 $types = node_type_get_names();
80 foreach ($types as $type => $name) {
81 variable_del("page_title_type_{$type}");
82 variable_del("page_title_type_{$type}_showfield");
83 }
84
85 // Clear the vocab specific variables
86 if(module_exists('taxonomy')) {
87 $vocabs = taxonomy_get_vocabularies();
88 foreach ($vocabs as $vid => $vocab) {
89 variable_del("page_title_vocab_{$vid}");
90 variable_del("page_title_vocab_{$vid}_showfield");
91 }
92 }
93 }

  ViewVC Help
Powered by ViewVC 1.1.2