Projet

Général

Profil

Paste
Télécharger (2,94 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / addthis / addthis.install @ ba09eb79

1
<?php
2
/**
3
 * @file
4
 * Install, update and uninstall functions for the AddThis module.
5
 */
6

    
7
// We need some constant values from the AddThis class.
8
include_once('classes/AddThis.php');
9

    
10
/**
11
 * Implements hook_field_schema().
12
 */
13
function addthis_field_schema($field) {
14
  $schema = array();
15
  if ($field['type'] == AddThis::FIELD_TYPE) {
16
    $columns = array(
17
      'value' => array(
18
        'type' => 'varchar',
19
        'length' => $field['settings']['max_length'],
20
        'not null' => FALSE,
21
      ),
22
    );
23
    $schema = array(
24
      'columns' => $columns,
25
      'indexes' => array(),
26
      'foreign keys' => array(),
27
    );
28
  }
29
  return $schema;
30
}
31

    
32
/**
33
 * Implements hook_uninstall().
34
 */
35
function addthis_uninstall() {
36
  variable_del(AddThis::ADDRESSBOOK_ENABLED_KEY);
37
  variable_del(AddThis::BLOCK_WIDGET_TYPE_KEY);
38
  variable_del(AddThis::BOOKMARK_URL_KEY);
39
  variable_del(AddThis::CLICKBACK_TRACKING_ENABLED_KEY);
40
  variable_del(AddThis::CLICK_TO_OPEN_COMPACT_MENU_ENABLED_KEY);
41
  variable_del(AddThis::CO_BRAND_KEY);
42
  variable_del(AddThis::COMPLIANT_508_KEY);
43
  variable_del(AddThis::CUSTOM_CONFIGURATION_CODE_ENABLED_KEY);
44
  variable_del(AddThis::CUSTOM_CONFIGURATION_CODE_KEY);
45
  variable_del(AddThis::ENABLED_SERVICES_KEY);
46
  variable_del(AddThis::EXCLUDED_SERVICES_KEY);
47
  variable_del(AddThis::OPEN_WINDOWS_ENABLED_KEY);
48
  variable_del(AddThis::PROFILE_ID_KEY);
49
  variable_del(AddThis::SERVICES_CSS_URL_KEY);
50
  variable_del(AddThis::SERVICES_JSON_URL_KEY);
51
  variable_del(AddThis::STANDARD_CSS_ENABLED_KEY);
52
  variable_del(AddThis::UI_DELAY_KEY);
53
  variable_del(AddThis::UI_HEADER_BACKGROUND_COLOR_KEY);
54
  variable_del(AddThis::UI_HEADER_COLOR_KEY);
55
  variable_del(AddThis::WIDGET_JS_URL_KEY);
56
  variable_del(AddThis::WIDGET_JS_LOAD_DOMREADY);
57
  variable_del(AddThis::WIDGET_JS_LOAD_ASYNC);
58
}
59

    
60
/**
61
 * Remove old WIDGET_JS_ASYNC variable.
62
 */
63
function addthis_update_7401() {
64
  variable_del('addthis_widget_async');
65
}
66

    
67
/**
68
 * Remove old addthis_widget_load_type and transform it into new values.
69
 *
70
 * Transform variable in settings for domready and async.
71
 * If value = async set domready TRUE and async TRUE.
72
 * If value = domready set domready TRUE and async FALSE.
73
 * If value = include set domready FALSE and async FALSE.
74
 */
75
function addthis_update_7402() {
76
  $load_type = variable_get('addthis_widget_load_type', NULL);
77

    
78
  switch ($load_type) {
79
    case 'async':
80
      variable_set(AddThis::WIDGET_JS_LOAD_DOMREADY, TRUE);
81
      variable_set(AddThis::WIDGET_JS_LOAD_ASYNC, TRUE);
82
      break;
83
    case 'domready':
84
      variable_set(AddThis::WIDGET_JS_LOAD_DOMREADY, TRUE);
85
      variable_set(AddThis::WIDGET_JS_LOAD_ASYNC, FALSE);
86
      break;
87
    case 'include':
88
      variable_set(AddThis::WIDGET_JS_LOAD_DOMREADY, FALSE);
89
      variable_set(AddThis::WIDGET_JS_LOAD_ASYNC, FALSE);
90
      break;
91
    default:
92
      variable_set(AddThis::WIDGET_JS_LOAD_DOMREADY, TRUE);
93
      variable_set(AddThis::WIDGET_JS_LOAD_ASYNC, FALSE);
94
      break;
95
  }
96

    
97
  variable_del('addthis_widget_load_type');
98
}