filter.install

  1. drupal
    1. 6 modules/filter/filter.install
    2. 7 modules/filter/filter.install
    3. 8 core/modules/filter/filter.install

Install, update and uninstall functions for the filter module.

Functions & methods

NameDescription
filter_installImplements hook_install().
filter_schemaImplements hook_schema().

File

core/modules/filter/filter.install
View source
  1. <?php
  2. /**
  3. * @file
  4. * Install, update and uninstall functions for the filter module.
  5. */
  6. /**
  7. * Implements hook_schema().
  8. */
  9. function filter_schema() {
  10. $schema['filter'] = array(
  11. 'description' => 'Table that maps filters (HTML corrector) to text formats (Filtered HTML).',
  12. 'fields' => array(
  13. 'format' => array(
  14. 'type' => 'varchar',
  15. 'length' => 255,
  16. 'not null' => TRUE,
  17. 'description' => 'Foreign key: The {filter_format}.format to which this filter is assigned.',
  18. ),
  19. 'module' => array(
  20. 'type' => 'varchar',
  21. 'length' => 64,
  22. 'not null' => TRUE,
  23. 'default' => '',
  24. 'description' => 'The origin module of the filter.',
  25. ),
  26. 'name' => array(
  27. 'type' => 'varchar',
  28. 'length' => 32,
  29. 'not null' => TRUE,
  30. 'default' => '',
  31. 'description' => 'Name of the filter being referenced.',
  32. ),
  33. 'weight' => array(
  34. 'type' => 'int',
  35. 'not null' => TRUE,
  36. 'default' => 0,
  37. 'description' => 'Weight of filter within format.',
  38. ),
  39. 'status' => array(
  40. 'type' => 'int',
  41. 'not null' => TRUE,
  42. 'default' => 0,
  43. 'description' => 'Filter enabled status. (1 = enabled, 0 = disabled)',
  44. ),
  45. 'settings' => array(
  46. 'type' => 'blob',
  47. 'not null' => FALSE,
  48. 'size' => 'big',
  49. 'serialize' => TRUE,
  50. 'description' => 'A serialized array of name value pairs that store the filter settings for the specific format.',
  51. ),
  52. ),
  53. 'primary key' => array('format', 'name'),
  54. 'indexes' => array(
  55. 'list' => array('weight', 'module', 'name'),
  56. ),
  57. );
  58. $schema['filter_format'] = array(
  59. 'description' => 'Stores text formats: custom groupings of filters, such as Filtered HTML.',
  60. 'fields' => array(
  61. 'format' => array(
  62. 'type' => 'varchar',
  63. 'length' => 255,
  64. 'not null' => TRUE,
  65. 'description' => 'Primary Key: Unique machine name of the format.',
  66. ),
  67. 'name' => array(
  68. 'type' => 'varchar',
  69. 'length' => 255,
  70. 'not null' => TRUE,
  71. 'default' => '',
  72. 'description' => 'Name of the text format (Filtered HTML).',
  73. 'translatable' => TRUE,
  74. ),
  75. 'cache' => array(
  76. 'type' => 'int',
  77. 'not null' => TRUE,
  78. 'default' => 0,
  79. 'size' => 'tiny',
  80. 'description' => 'Flag to indicate whether format is cacheable. (1 = cacheable, 0 = not cacheable)',
  81. ),
  82. 'status' => array(
  83. 'type' => 'int',
  84. 'unsigned' => TRUE,
  85. 'not null' => TRUE,
  86. 'default' => 1,
  87. 'size' => 'tiny',
  88. 'description' => 'The status of the text format. (1 = enabled, 0 = disabled)',
  89. ),
  90. 'weight' => array(
  91. 'type' => 'int',
  92. 'not null' => TRUE,
  93. 'default' => 0,
  94. 'description' => 'Weight of text format to use when listing.',
  95. ),
  96. ),
  97. 'primary key' => array('format'),
  98. 'unique keys' => array(
  99. 'name' => array('name'),
  100. ),
  101. 'indexes' => array(
  102. 'status_weight' => array('status', 'weight'),
  103. ),
  104. );
  105. $schema['cache_filter'] = drupal_get_schema_unprocessed('system', 'cache');
  106. $schema['cache_filter']['description'] = 'Cache table for the Filter module to store already filtered pieces of text, identified by text format and hash of the text.';
  107. return $schema;
  108. }
  109. /**
  110. * Implements hook_install().
  111. */
  112. function filter_install() {
  113. // All sites require at least one text format (the fallback format) that all
  114. // users have access to, so add it here. We initialize it as a simple, safe
  115. // plain text format with very basic formatting, but it can be modified by
  116. // installation profiles to have other properties.
  117. $plain_text_format = array(
  118. 'format' => 'plain_text',
  119. 'name' => 'Plain text',
  120. 'weight' => 10,
  121. 'filters' => array(
  122. // Escape all HTML.
  123. 'filter_html_escape' => array(
  124. 'weight' => 0,
  125. 'status' => 1,
  126. ),
  127. // URL filter.
  128. 'filter_url' => array(
  129. 'weight' => 1,
  130. 'status' => 1,
  131. ),
  132. // Line break filter.
  133. 'filter_autop' => array(
  134. 'weight' => 2,
  135. 'status' => 1,
  136. ),
  137. ),
  138. );
  139. $plain_text_format = (object) $plain_text_format;
  140. filter_format_save($plain_text_format);
  141. // Set the fallback format to plain text.
  142. variable_set('filter_fallback_format', $plain_text_format->format);
  143. }
Login or register to post comments