[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/sites/all/modules/date/date_popup/ -> date_popup.install (source)

   1  <?php
   2  
   3  /**
   4   * Implementation of hook_requirements().
   5   * Added to be sure the Date API version matches this code so invalid
   6   * functions are not called.
   7   */
   8  function date_popup_requirements($phase) {
   9    $requirements = array();
  10    $t = get_t();
  11    switch ($phase) {
  12      case 'runtime':
  13        if (!module_exists('jquery_ui')) {
  14          $requirements['date_popup_jquery_ui'] = array(
  15            'title' => $t('Date Popup requirements'),
  16            'value' => $t('The Date Popup module needs code added by the <a href="http://drupal.org/project/jquery_ui">jQuery UI module.</a> This is not yet a requirement, but soon will be, so you are encouraged to install that module as soon as possible. In the meantime, a version of the needed code is included here.'),
  17            'severity' => REQUIREMENT_WARNING,
  18            );
  19        }
  20        break;
  21    }
  22    return $requirements;
  23  }
  24  
  25  /**
  26   * Implementation of hook_install().
  27   */
  28  function date_popup_install() {
  29    if (module_exists('content')) {
  30      drupal_load('module', 'content');
  31      if (!db_table_exists(content_instance_tablename())) {
  32        return;
  33      }
  34      if (module_exists('date_repeat')) {
  35        db_query("UPDATE {". content_instance_tablename() ."} SET widget_active=1 WHERE widget_type='%s' OR widget_type='%s'", 'date_popup', 'date_popup_repeat');
  36      }
  37      else {
  38        db_query("UPDATE {". content_instance_tablename() ."} SET widget_active=1 WHERE widget_type='%s'", 'date_popup');
  39      }
  40      content_clear_type_cache(TRUE);
  41    }
  42  }
  43  
  44  /**
  45   * Implementation of hook_uninstall().
  46   */
  47  function date_popup_uninstall() {
  48    if (module_exists('content')) {
  49      drupal_load('module', 'content');
  50      if (!db_table_exists(content_instance_tablename())) {
  51        return;
  52      }
  53      if (module_exists('date_repeat')) {
  54        db_query("UPDATE {". content_instance_tablename() ."} SET widget_active=0 WHERE widget_type='%s' OR widget_type='%s'", 'date_popup', 'date_popup_repeat');
  55      }
  56      else {
  57        db_query("UPDATE {". content_instance_tablename() ."} SET widget_active=0 WHERE widget_type='%s'", 'date_popup');
  58      }
  59      content_clear_type_cache(TRUE);
  60    }
  61  }
  62  
  63  /**
  64   * Implementation of hook_enable().
  65   */
  66  function date_popup_enable() {
  67    if (module_exists('content')) {
  68      drupal_load('module', 'content');
  69      if (!db_table_exists(content_instance_tablename())) {
  70        return;
  71      }
  72      if (module_exists('date_repeat')) {
  73        db_query("UPDATE {". content_instance_tablename() ."} SET widget_active=1 WHERE widget_type='%s' OR widget_type='%s'", 'date_popup', 'date_popup_repeat');
  74      }
  75      else {
  76        db_query("UPDATE {". content_instance_tablename() ."} SET widget_active=1 WHERE widget_type='%s'", 'date_popup');
  77      }
  78      content_clear_type_cache(TRUE);
  79    }
  80  }
  81  
  82  /**
  83   * Implementation of hook_disable().
  84   */
  85  function date_popup_disable() {
  86    if (module_exists('content')) {
  87      drupal_load('module', 'content');
  88      if (!db_table_exists(content_instance_tablename())) {
  89        return;
  90      }
  91      if (module_exists('date_repeat')) {
  92        db_query("UPDATE {". content_instance_tablename() ."} SET widget_active=0 WHERE widget_type='%s' OR widget_type='%s'", 'date_popup', 'date_popup_repeat');
  93      }
  94      else {
  95        db_query("UPDATE {". content_instance_tablename() ."} SET widget_active=0 WHERE widget_type='%s'", 'date_popup');
  96      }
  97      content_clear_type_cache(TRUE);
  98    }
  99  }
 100  
 101  /**
 102   * Update default path for date popup css
 103   */
 104  function date_popup_update_6001() {
 105    $ret = array();
 106    $version = function_exists('jquery_ui_get_version') ? jquery_ui_get_version() : '1.6';
 107    switch ($version) {
 108      case '1.6':
 109        $path = drupal_get_path('module', 'date_popup') . '/themes/datepicker.css';
 110        break;
 111      default:
 112        $path = drupal_get_path('module', 'date_popup') . '/themes/datepicker.1.7.css';
 113        break;
 114    }
 115    variable_set('date_popup_css_file', $path);
 116    if (!module_exists('jquery_ui')) {
 117      drupal_set_message('The jQuery UI module is now required when using Date Popup. See the <a href="http://drupal.org/project/jquery_ui">jQuery UI</a> page for installation instructions.', 'error');
 118    }
 119    return $ret;
 120  }


Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7