accessibility.install

  1. cis7 sites/all/modules/ulmus/accessibility/accessibility.install
  2. cle7 sites/all/modules/ulmus/accessibility/accessibility.install
  3. ecd7 sites/all/modules/ulmus/accessibility/accessibility.install
  4. elmsmedia7 sites/all/modules/ulmus/accessibility/accessibility.install
  5. harmony7 sites/all/modules/ulmus/accessibility/accessibility.install
  6. icor7 sites/all/modules/ulmus/accessibility/accessibility.install
  7. meedjum_blog7 sites/all/modules/ulmus/accessibility/accessibility.install
  8. mooc7 sites/all/modules/ulmus/accessibility/accessibility.install

Functions

File

sites/all/modules/ulmus/accessibility/accessibility.install
View source
  1. <?php
  2. /**
  3. * Implements hook_install().
  4. */
  5. function accessibility_install() {
  6. $field = field_info_field('error_description');
  7. $instance = field_info_instance('accessibility_test', 'error_description', 'accessibility_test');
  8. if (empty($field)) {
  9. $field = array(
  10. 'field_name' => 'error_description',
  11. 'type' => 'text_with_summary',
  12. 'entity_types' => array('accessibility_test'),
  13. );
  14. $field = field_create_field($field);
  15. }
  16. if (empty($instance)) {
  17. $instance = array(
  18. 'field_name' => 'error_description',
  19. 'entity_type' => 'accessibility_test',
  20. 'bundle' => 'accessibility_test',
  21. 'label' => st('Error description'),
  22. 'widget' => array('type' => 'text_textarea_with_summary'),
  23. 'settings' => array('display_summary' => TRUE),
  24. 'display' => array(
  25. 'default' => array(
  26. 'label' => 'hidden',
  27. 'type' => 'text_default',
  28. ),
  29. 'popup' => array(
  30. 'label' => 'hidden',
  31. 'type' => 'text_default',
  32. ),
  33. 'teaser' => array(
  34. 'label' => 'hidden',
  35. 'type' => 'text_summary_or_trimmed',
  36. ),
  37. ),
  38. );
  39. $instance = field_create_instance($instance);
  40. }
  41. $display_settings = array(
  42. 'view_modes' => array(
  43. 'popup' => array(
  44. 'custom_settings' => TRUE,
  45. ),
  46. 'full' => array(
  47. 'custom_settings' => FALSE,
  48. ),
  49. ),
  50. 'extra_fields' => array(
  51. 'form' => array(),
  52. 'display' => array(
  53. 'quail_name' => array(
  54. 'default' => array(
  55. 'weight' => '3',
  56. 'visible' => FALSE,
  57. ),
  58. 'popup' => array(
  59. 'weight' => '3',
  60. 'visible' => FALSE,
  61. ),
  62. ),
  63. 'severity' => array(
  64. 'default' => array(
  65. 'weight' => '2',
  66. 'visible' => FALSE,
  67. ),
  68. 'popup' => array(
  69. 'weight' => '2',
  70. 'visible' => FALSE,
  71. ),
  72. ),
  73. 'status' => array(
  74. 'default' => array(
  75. 'weight' => '1',
  76. 'visible' => FALSE,
  77. ),
  78. 'popup' => array(
  79. 'weight' => '1',
  80. 'visible' => FALSE,
  81. ),
  82. ),
  83. ),
  84. ),
  85. );
  86. field_bundle_settings('accessibility_test', 'accessibility_test', $display_settings);
  87. }
  88. /**
  89. * Implements hook_requirements().
  90. */
  91. function accessibility_requirements($phase) {
  92. if (!module_exists('libraries')) {
  93. return array();
  94. }
  95. $requirements = array('quail_installed' => array('title' => t('QUAIL library installed')));
  96. $library_path = libraries_get_path('quail');
  97. if ($library_path && file_exists($library_path . '/quail.json')) {
  98. $version = json_decode(file_get_contents($library_path . '/quail.json'));
  99. if(version_compare(ACCESSIBILITY_QUAIL_VERSION, $version->version) < 1) {
  100. $requirements['quail_installed']['value'] = t('QUAIL version @version installed', array('@version' => $version->version));
  101. $requirements['quail_installed']['severity'] = REQUIREMENT_OK;
  102. }
  103. else {
  104. $requirements['quail_installed']['value'] = t('QUAIL should be at least version 2.0.3, installed version is @version', array('@version' => $version->version));
  105. $requirements['quail_installed']['severity'] = REQUIREMENT_ERROR;
  106. $requirements['quail_installed']['description'] = t('You must download the !link and install it in your libraries folder, and make sure the folder is re-named to "quail" without a version number.', array(
  107. '!link' => l('QUAIL jQuery library', 'https://github.com/kevee/quail/releases'),
  108. )
  109. );
  110. }
  111. }
  112. else {
  113. $requirements['quail_installed']['value'] = t('QUAIL not installed');
  114. $requirements['quail_installed']['severity'] = REQUIREMENT_ERROR;
  115. $requirements['quail_installed']['description'] = t('You must download the !link version @version and install it in your libraries folder, and make sure the folder is re-named to "quail" without a version number.', array(
  116. '@version' => ACCESSIBILITY_QUAIL_VERSION,
  117. '!link' => l('QUAIL jQuery library', 'https://github.com/kevee/quail/releases'),
  118. )
  119. );
  120. }
  121. return $requirements;
  122. }
  123. /**
  124. * Implements hook_schema().
  125. */
  126. function accessibility_schema() {
  127. $schema = array();
  128. $schema['accessibility_test'] = array(
  129. 'description' => 'Accessibility tests.',
  130. 'fields' => array(
  131. 'test_id' => array(
  132. 'description' => 'Primary Key: Identifier for an accessibility test.',
  133. 'type' => 'serial',
  134. 'unsigned' => TRUE,
  135. 'not null' => TRUE,
  136. ),
  137. 'language' => array(
  138. 'description' => 'The language of the test.',
  139. 'type' => 'varchar',
  140. 'length' => 32,
  141. 'not null' => TRUE,
  142. 'default' => '',
  143. ),
  144. 'name' => array(
  145. 'description' => 'The name of the test - a human-readable identifier.',
  146. 'type' => 'varchar',
  147. 'length' => 255,
  148. 'not null' => TRUE,
  149. 'default' => '',
  150. ),
  151. 'quail_name' => array(
  152. 'description' => 'The name of the related QUAIL test label.',
  153. 'type' => 'varchar',
  154. 'length' => 255,
  155. 'not null' => TRUE,
  156. 'default' => '',
  157. ),
  158. 'severity' => array(
  159. 'description' => 'The severity of the test.',
  160. 'type' => 'varchar',
  161. 'length' => 50,
  162. 'not null' => TRUE,
  163. 'default' => 'suggestion',
  164. ),
  165. 'status' => array(
  166. 'description' => 'Whether the test is active or not.',
  167. 'type' => 'int',
  168. 'length' => 1,
  169. 'not null' => TRUE,
  170. 'default' => 1,
  171. ),
  172. 'created' => array(
  173. 'description' => 'The Unix timestamp when the test was created.',
  174. 'type' => 'int',
  175. 'not null' => TRUE,
  176. 'default' => 0,
  177. ),
  178. 'changed' => array(
  179. 'description' => 'The Unix timestamp when the test was most recently saved.',
  180. 'type' => 'int',
  181. 'not null' => TRUE,
  182. 'default' => 0,
  183. ),
  184. 'data' => array(
  185. 'type' => 'blob',
  186. 'not null' => FALSE,
  187. 'size' => 'big',
  188. 'serialize' => TRUE,
  189. 'description' => 'A serialized array of additional data.',
  190. ),
  191. ),
  192. 'primary key' => array('test_id'),
  193. );
  194. return $schema;
  195. }