taxonomy_display.install 2.5 KB
Newer Older
Cody Craven's avatar
Cody Craven committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
// $Id$

/**
 * @file
 * Install, update and uninstall functions for the taxonomy display module.
 */

/**
 * Implements hook_enable().
 *
 * Perform cleanup from while taxonomy_display was disabled.
 *
 * @todo test this works
 */
function taxonomy_display_enable() {
  watchdog('taxonomy_display', 'Taxonomy display is performing cleanup in response to being enabled, any changes made will be subsequently logged.', array(), WATCHDOG_INFO);

  // Retrieve all the existing vocabularies.
  $vocabularies = taxonomy_vocabulary_get_names();
  
  // Select taxonomy displays we have in the DB.
  $taxonomy_displays = db_select('taxonomy_display', 'td')
      ->fields('td', array('machine_name'))
      ->execute();

  // Loop through each display
  foreach ($taxonomy_displays as $taxonomy_display) {
    // If the vocabulary does not exist delete the taxonomy_display as it is now
    // an orphan.
    if (!isset($vocabularies[$taxonomy_display->machine_name])) {
32
      taxonomy_display_delete_taxonomy_dislpay($taxonomy_display->machine_name);
Cody Craven's avatar
Cody Craven committed
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
    }
  }
}

/**
 * Implements hook_schema().
 */
function taxonomy_display_schema() {
  $schema['taxonomy_display'] = array(
    'description' => 'Per vocabulary configuration for term pages.',
    'fields' => array(
      'machine_name' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => 'The vocabulary machine name.',
      ),
      'term_display_plugin' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => 'The plugin used to display the term.',
      ),
      'term_display_options' => array(
        'type' => 'blob',
        'not null' => FALSE,
        'size' => 'big',
        'serialize' => TRUE,
        'description' => 'The plugin data for the term display.',
      ),
      'associated_display_plugin' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => 'The plugin used to display the associated content.',
      ),
      'associated_display_options' => array(
        'type' => 'blob',
        'not null' => FALSE,
        'size' => 'big',
        'serialize' => TRUE,
        'description' => 'The plugin data for the associated content display.',
      ),
    ),
    'primary key' => array('machine_name'),
  );

  return $schema;
}

/**
 * Implements hook_uninstall().
 */
89
function taxonomy_display_uninstall() {}