colorbox.install 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. /**
  3. * @file
  4. * Install, update and uninstall functions for the colorbox module.
  5. */
  6. /**
  7. * Implements hook_requirements().
  8. */
  9. function colorbox_requirements($phase) {
  10. $requirements = array();
  11. if ($phase == 'runtime') {
  12. $t = get_t();
  13. $library = libraries_detect('colorbox');
  14. $error_type = isset($library['error']) ? drupal_ucfirst($library['error']) : '';
  15. $error_message = isset($library['error message']) ? $library['error message'] : '';
  16. if (empty($library['installed'])) {
  17. $requirements['colorbox_plugin'] = array(
  18. 'title' => $t('Colorbox plugin'),
  19. 'value' => $t('@e: At least @a', array('@e' => $error_type, '@a' => COLORBOX_MIN_PLUGIN_VERSION)),
  20. 'severity' => REQUIREMENT_ERROR,
  21. 'description' => $t('!error You need to download the !colorbox, extract the archive and place the colorbox directory in the %path directory on your server.', array('!error' => $error_message, '!colorbox' => l($t('Colorbox plugin'), $library['download url']), '%path' => 'sites/all/libraries')),
  22. );
  23. }
  24. elseif (version_compare($library['version'], COLORBOX_MIN_PLUGIN_VERSION, '>=')) {
  25. $requirements['colorbox_plugin'] = array(
  26. 'title' => $t('Colorbox plugin'),
  27. 'severity' => REQUIREMENT_OK,
  28. 'value' => $library['version'],
  29. );
  30. }
  31. else {
  32. $requirements['colorbox_plugin'] = array(
  33. 'title' => $t('Colorbox plugin'),
  34. 'value' => $t('At least @a', array('@a' => COLORBOX_MIN_PLUGIN_VERSION)),
  35. 'severity' => REQUIREMENT_ERROR,
  36. 'description' => $t('You need to download a later version of the !colorbox and replace the old version located in the %path directory on your server.', array('!colorbox' => l($t('Colorbox plugin'), $library['download url']), '%path' => $library['library path'])),
  37. );
  38. }
  39. }
  40. return $requirements;
  41. }
  42. /**
  43. * Implements hook_uninstall().
  44. */
  45. function colorbox_uninstall() {
  46. db_delete('variable')->condition('name', db_like('colorbox_') . '%', 'LIKE')->execute();
  47. }
  48. /**
  49. * Delete the unused colorbox_login_form variable.
  50. */
  51. function colorbox_update_7001() {
  52. $ret = array();
  53. variable_del('colorbox_login_form');
  54. return $ret;
  55. }
  56. /**
  57. * Delete the unused colorbox_title_trim and
  58. * colorbox_title_trim_length variables.
  59. */
  60. function colorbox_update_7002() {
  61. $ret = array();
  62. $colorbox_title_trim = variable_get('colorbox_title_trim', NULL);
  63. $colorbox_title_trim_length = variable_get('colorbox_title_trim_length', NULL);
  64. if (!empty($colorbox_title_trim)) {
  65. variable_set('colorbox_caption_trim', $colorbox_title_trim);
  66. }
  67. if (!empty($colorbox_title_trim_length)) {
  68. variable_set('colorbox_caption_trim_length', $colorbox_title_trim_length);
  69. }
  70. variable_del('colorbox_title_trim');
  71. variable_del('colorbox_title_trim_length');
  72. return $ret;
  73. }
  74. /**
  75. * Delete the unused colorbox_login and colorbox_login_links variables.
  76. */
  77. function colorbox_update_7200() {
  78. $ret = array();
  79. variable_del('colorbox_login');
  80. variable_del('colorbox_login_links');
  81. return $ret;
  82. }
  83. /**
  84. * Delete the unused colorbox_auto_image_nodes variable.
  85. */
  86. function colorbox_update_7201() {
  87. $ret = array();
  88. variable_del('colorbox_auto_image_nodes');
  89. return $ret;
  90. }
  91. /**
  92. * Update the colorbox_compression_type variable.
  93. */
  94. function colorbox_update_7202() {
  95. $ret = array();
  96. if (variable_get('colorbox_compression_type', 'minified') == 'none') {
  97. variable_set('colorbox_compression_type', 'source');
  98. }
  99. else {
  100. variable_set('colorbox_compression_type', 'minified');
  101. }
  102. return $ret;
  103. }