ds.install 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. <?php
  2. /**
  3. * @file
  4. * Display Suite install file.
  5. */
  6. /**
  7. * Implements hook_install().
  8. */
  9. function ds_install() {
  10. db_update('system')
  11. ->fields(array('weight' => 1))
  12. ->condition('name', 'ds')
  13. ->execute();
  14. }
  15. /**
  16. * Implements hook_uninstall().
  17. */
  18. function ds_uninstall() {
  19. variable_del('ds_classes_regions');
  20. }
  21. /**
  22. * Implements hook_schema().
  23. */
  24. function ds_schema() {
  25. $schema['ds_field_settings'] = array(
  26. 'description' => 'The table that holds Display Suite field settings per display.',
  27. // CTools export definitions.
  28. 'export' => array(
  29. 'key' => 'id',
  30. 'identifier' => 'ds_fieldsetting',
  31. 'default hook' => 'ds_field_settings_info',
  32. 'can disable' => FALSE,
  33. 'api' => array(
  34. 'owner' => 'ds',
  35. 'api' => 'ds',
  36. 'minimum_version' => 1,
  37. 'current_version' => 1,
  38. ),
  39. ),
  40. 'fields' => array(
  41. 'id' => array(
  42. 'description' => 'The unique id this setting.',
  43. 'type' => 'varchar',
  44. 'length' => 255,
  45. 'not null' => TRUE,
  46. 'default' => '',
  47. ),
  48. 'entity_type' => array(
  49. 'description' => 'The name of the entity.',
  50. 'type' => 'varchar',
  51. 'length' => 32,
  52. 'not null' => TRUE,
  53. 'default' => '',
  54. ),
  55. 'bundle' => array(
  56. 'description' => 'The name of the entity.',
  57. 'type' => 'varchar',
  58. 'length' => 64,
  59. 'not null' => TRUE,
  60. 'default' => '',
  61. ),
  62. 'view_mode' => array(
  63. 'description' => 'The name of the view_mode.',
  64. 'type' => 'varchar',
  65. 'length' => 64,
  66. 'not null' => TRUE,
  67. 'default' => '',
  68. ),
  69. 'settings' => array(
  70. 'description' => 'The Display Suite field settings for this layout.',
  71. 'type' => 'blob',
  72. 'not null' => FALSE,
  73. 'size' => 'big',
  74. 'serialize' => TRUE,
  75. ),
  76. ),
  77. 'primary key' => array('id'),
  78. 'indexes' => array(
  79. 'ds_entity' => array('entity_type'),
  80. 'ds_bundle' => array('bundle'),
  81. 'ds_view_mode' => array('view_mode'),
  82. ),
  83. );
  84. $schema['ds_layout_settings'] = array(
  85. 'description' => 'The table that holds the layouts configuration.',
  86. // CTools export definitions.
  87. 'export' => array(
  88. 'key' => 'id',
  89. 'identifier' => 'ds_layout',
  90. 'default hook' => 'ds_layout_settings_info',
  91. 'can disable' => FALSE,
  92. 'api' => array(
  93. 'owner' => 'ds',
  94. 'api' => 'ds',
  95. 'minimum_version' => 1,
  96. 'current_version' => 1,
  97. ),
  98. ),
  99. 'fields' => array(
  100. 'id' => array(
  101. 'description' => 'The unique id the layout.',
  102. 'type' => 'varchar',
  103. 'length' => 255,
  104. 'not null' => TRUE,
  105. 'default' => '',
  106. ),
  107. 'entity_type' => array(
  108. 'description' => 'The name of the entity.',
  109. 'type' => 'varchar',
  110. 'length' => 32,
  111. 'not null' => TRUE,
  112. 'default' => '',
  113. ),
  114. 'bundle' => array(
  115. 'description' => 'The name of the entity.',
  116. 'type' => 'varchar',
  117. 'length' => 64,
  118. 'not null' => TRUE,
  119. 'default' => '',
  120. ),
  121. 'view_mode' => array(
  122. 'description' => 'The name of the view_mode.',
  123. 'type' => 'varchar',
  124. 'length' => 64,
  125. 'not null' => TRUE,
  126. 'default' => '',
  127. ),
  128. 'layout' => array(
  129. 'description' => 'The name of the layout.',
  130. 'type' => 'varchar',
  131. 'length' => 64,
  132. 'not null' => TRUE,
  133. 'default' => '',
  134. ),
  135. 'settings' => array(
  136. 'description' => 'The settings for this layout.',
  137. 'type' => 'blob',
  138. 'not null' => FALSE,
  139. 'size' => 'big',
  140. 'serialize' => TRUE,
  141. ),
  142. ),
  143. 'primary key' => array('id'),
  144. 'indexes' => array(
  145. 'ds_entity' => array('entity_type'),
  146. 'ds_bundle' => array('bundle'),
  147. 'ds_view_mode' => array('view_mode'),
  148. ),
  149. );
  150. $schema['ds_view_modes'] = array(
  151. 'description' => 'The table that holds custom view modes managed by Display Suite.',
  152. // CTools export definitions.
  153. 'export' => array(
  154. 'key' => 'view_mode',
  155. 'identifier' => 'ds_view_mode',
  156. 'default hook' => 'ds_view_modes_info',
  157. 'can disable' => FALSE,
  158. 'api' => array(
  159. 'owner' => 'ds',
  160. 'api' => 'ds',
  161. 'minimum_version' => 1,
  162. 'current_version' => 1,
  163. ),
  164. ),
  165. 'fields' => array(
  166. 'view_mode' => array(
  167. 'description' => 'The machine name of the view mode.',
  168. 'type' => 'varchar',
  169. 'length' => 64,
  170. 'not null' => TRUE,
  171. 'default' => '',
  172. ),
  173. 'label' => array(
  174. 'description' => 'The label of the view mode.',
  175. 'type' => 'varchar',
  176. 'length' => 32,
  177. 'not null' => TRUE,
  178. 'default' => '',
  179. ),
  180. 'entities' => array(
  181. 'description' => 'The entities for this view mode.',
  182. 'type' => 'blob',
  183. 'not null' => FALSE,
  184. 'size' => 'big',
  185. 'serialize' => TRUE,
  186. ),
  187. ),
  188. 'primary key' => array('view_mode'),
  189. );
  190. $schema['ds_fields'] = array(
  191. 'description' => 'The table that holds custom fields managed by Display Suite.',
  192. // CTools export definitions.
  193. 'export' => array(
  194. 'key' => 'field',
  195. 'identifier' => 'ds_field',
  196. 'default hook' => 'ds_custom_fields_info',
  197. 'can disable' => FALSE,
  198. 'api' => array(
  199. 'owner' => 'ds',
  200. 'api' => 'ds',
  201. 'minimum_version' => 1,
  202. 'current_version' => 1,
  203. ),
  204. ),
  205. 'fields' => array(
  206. 'field' => array(
  207. 'description' => 'The machine name of the field.',
  208. 'type' => 'varchar',
  209. 'length' => 32,
  210. 'not null' => TRUE,
  211. 'default' => '',
  212. ),
  213. 'label' => array(
  214. 'description' => 'The label of the field.',
  215. 'type' => 'varchar',
  216. 'length' => 128,
  217. 'not null' => TRUE,
  218. 'default' => '',
  219. ),
  220. 'field_type' => array(
  221. 'description' => 'The type of of the field',
  222. 'type' => 'int',
  223. 'size' => 'small',
  224. 'not null' => TRUE,
  225. 'default' => 0,
  226. ),
  227. 'entities' => array(
  228. 'description' => 'The entities for this field.',
  229. 'type' => 'blob',
  230. 'not null' => FALSE,
  231. 'size' => 'big',
  232. 'serialize' => TRUE,
  233. ),
  234. 'ui_limit' => array(
  235. 'description' => 'The UI limit for this field.',
  236. 'type' => 'blob',
  237. 'not null' => FALSE,
  238. 'size' => 'big',
  239. 'serialize' => TRUE,
  240. ),
  241. 'properties' => array(
  242. 'description' => 'The properties for this field.',
  243. 'type' => 'blob',
  244. 'not null' => FALSE,
  245. 'size' => 'big',
  246. 'serialize' => TRUE,
  247. ),
  248. ),
  249. 'primary key' => array('field'),
  250. );
  251. return $schema;
  252. }
  253. /**
  254. * Add the ui_limit table to the fields table.
  255. */
  256. function ds_update_7201() {
  257. $schema = ds_schema();
  258. if (!db_field_exists('ds_fields', 'ui_limit')) {
  259. db_add_field('ds_fields', 'ui_limit', $schema['ds_fields']['fields']['ui_limit']);
  260. }
  261. }
  262. /**
  263. * Increase the label storage length to 128.
  264. */
  265. function ds_update_7202() {
  266. db_change_field('ds_fields', 'label', 'label',
  267. array(
  268. 'description' => 'The label of the field.',
  269. 'type' => 'varchar',
  270. 'length' => 128,
  271. 'not null' => TRUE,
  272. 'default' => '',
  273. ));
  274. }
  275. /**
  276. * Increase the view_mode storage length to 64
  277. */
  278. function ds_update_7203() {
  279. db_change_field('ds_field_settings', 'view_mode', 'view_mode',
  280. array(
  281. 'description' => 'The name of the view_mode.',
  282. 'type' => 'varchar',
  283. 'length' => 64,
  284. 'not null' => TRUE,
  285. 'default' => '',
  286. )
  287. );
  288. db_change_field('ds_layout_settings', 'view_mode', 'view_mode',
  289. array(
  290. 'description' => 'The name of the view_mode.',
  291. 'type' => 'varchar',
  292. 'length' => 64,
  293. 'not null' => TRUE,
  294. 'default' => '',
  295. )
  296. );
  297. db_change_field('ds_view_modes', 'view_mode', 'view_mode',
  298. array(
  299. 'description' => 'The machine name of the view mode.',
  300. 'type' => 'varchar',
  301. 'length' => 64,
  302. 'not null' => TRUE,
  303. 'default' => '',
  304. )
  305. );
  306. }