page_title.install 2.1 KB
Newer Older
1
<?php
JohnAlbin's avatar
JohnAlbin committed
2
// $Id$
3

4
5
6
7
8
/**
 * @file
 * The install file for Page Title allows the module to install (and uninstall) itself. This is required as this module uses its own table.
 */

9
10
11
/**
 * Implementation of hook_install().
 */
12
function page_title_install() {
13
14
  drupal_install_schema('page_title');
}
15
16


17
18
19
/**
 * Implementation of hook_schema().
 */
20
21
22
function page_title_schema() {
  $schema['page_title'] = array(
    'fields' => array(
23
24
      'type'       => array('type' => 'varchar', 'length' => 15,  'not null' => TRUE, 'default' => 'node'),
      'id'         => array('type' => 'int', 'unsigned' => TRUE,  'not null' => TRUE, 'default' => 0),
25
26
      'page_title' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '')
    ),
27
    'primary key' => array('type', 'id'),
28
29
30
  );

  return $schema;
31
}
JohnAlbin's avatar
JohnAlbin committed
32

33

34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/**
 * Implementation of hook_update_n().
 */
function page_title_update_6200() {
  $ret = array();

  db_create_table($ret, 'page_title_temp', array(
    'fields' => array(
      'type'       => array('type' => 'varchar', 'length' => 15,  'not null' => TRUE, 'default' => 'node'),
      'id'         => array('type' => 'int', 'unsigned' => TRUE,  'not null' => TRUE, 'default' => 0),
      'page_title' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '')
    ),
    'primary key' => array('type', 'id'),
  ));

  $ret[] = update_sql('INSERT INTO {page_title_temp} (id, page_title) SELECT nid, page_title FROM {page_title}');

  db_rename_table($ret, 'page_title', 'page_title_old');

  db_rename_table($ret, 'page_title_temp', 'page_title');

  $display_settings = variable_get('page_title_display', array());
  foreach ($display_settings as $type) {
    if ($type) {
      variable_set('page_title_type_'. $type .'_showfield', 1);
    }
  }
  variable_del('page_title_display');

  return $ret;
}


JohnAlbin's avatar
JohnAlbin committed
67
68
69
70
/**
 * Implementation of hook_uninstall().
 */
function page_title_uninstall() {
71
  drupal_uninstall_schema('page_title');
72
73
  variable_del('page_title_individual');
  variable_del('page_title_front');
74
75
76
  foreach (node_get_types('names') AS $type => $name) {
    variable_del("page_title_display_$type");
  }
77
}