colorbox.install 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. if (empty($library['installed'])) {
  15. $requirements['colorbox_plugin'] = array(
  16. 'title' => $t('Colorbox plugin'),
  17. 'value' => $t('At least @a', array('@a' => COLORBOX_MIN_PLUGIN_VERSION)),
  18. 'severity' => REQUIREMENT_ERROR,
  19. 'description' => $t('You need to download the !colorbox, extract the archive and place the colorbox directory in the %path directory on your server.', array('!colorbox' => l($t('Colorbox plugin'), $library['download url']), '%path' => 'sites/all/libraries')),
  20. );
  21. }
  22. elseif (version_compare($library['version'], COLORBOX_MIN_PLUGIN_VERSION, '>=')) {
  23. $requirements['colorbox_plugin'] = array(
  24. 'title' => $t('Colorbox plugin'),
  25. 'severity' => REQUIREMENT_OK,
  26. 'value' => $library['version'],
  27. );
  28. }
  29. else {
  30. $requirements['colorbox_plugin'] = array(
  31. 'title' => $t('Colorbox plugin'),
  32. 'value' => $t('At least @a', array('@a' => COLORBOX_MIN_PLUGIN_VERSION)),
  33. 'severity' => REQUIREMENT_ERROR,
  34. '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'])),
  35. );
  36. }
  37. }
  38. return $requirements;
  39. }
  40. /**
  41. * Implements hook_uninstall().
  42. */
  43. function colorbox_uninstall() {
  44. db_query("DELETE FROM {variable} WHERE name LIKE 'colorbox_%'");
  45. }
  46. /**
  47. * Delete the unused colorbox_login_form variable.
  48. */
  49. function colorbox_update_7001() {
  50. $ret = array();
  51. variable_del('colorbox_login_form');
  52. return $ret;
  53. }
  54. /**
  55. * Delete the unused colorbox_title_trim and
  56. * colorbox_title_trim_length variables.
  57. */
  58. function colorbox_update_7002() {
  59. $ret = array();
  60. $colorbox_title_trim = variable_get('colorbox_title_trim', NULL);
  61. $colorbox_title_trim_length = variable_get('colorbox_title_trim_length', NULL);
  62. if (!empty($colorbox_title_trim)) {
  63. variable_set('colorbox_caption_trim', $colorbox_title_trim);
  64. }
  65. if (!empty($colorbox_title_trim_length)) {
  66. variable_set('colorbox_caption_trim_length', $colorbox_title_trim_length);
  67. }
  68. variable_del('colorbox_title_trim');
  69. variable_del('colorbox_title_trim_length');
  70. return $ret;
  71. }
  72. /**
  73. * Delete the unused colorbox_login and colorbox_login_links variables.
  74. */
  75. function colorbox_update_7200() {
  76. $ret = array();
  77. variable_del('colorbox_login');
  78. variable_del('colorbox_login_links');
  79. return $ret;
  80. }
  81. /**
  82. * Delete the unused colorbox_auto_image_nodes variable.
  83. */
  84. function colorbox_update_7201() {
  85. $ret = array();
  86. variable_del('colorbox_auto_image_nodes');
  87. return $ret;
  88. }
  89. /**
  90. * Update the colorbox_compression_type variable.
  91. */
  92. function colorbox_update_7202() {
  93. $ret = array();
  94. if (variable_get('colorbox_compression_type', 'minified') == 'none') {
  95. variable_set('colorbox_compression_type', 'source');
  96. }
  97. else {
  98. variable_set('colorbox_compression_type', 'minified');
  99. }
  100. return $ret;
  101. }