video_embed_field.install 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <?php
  2. /**
  3. * Install file for video_embed_field module
  4. * @author jcaldwell
  5. */
  6. /**
  7. * Implements hook_field_schema().
  8. */
  9. function video_embed_field_field_schema($field){
  10. switch($field['type']){
  11. case 'video_embed_field' :
  12. $columns = array(
  13. 'video_url' => array(
  14. 'type' => 'varchar',
  15. 'length' => 512,
  16. 'default' => '',
  17. ),
  18. 'thumbnail_path' => array(
  19. 'type' => 'varchar',
  20. 'length' => 512,
  21. 'default' => '',
  22. ),
  23. 'video_data' => array(
  24. 'type' => 'blob',
  25. 'not null' => FALSE,
  26. 'size' => 'big',
  27. 'serialize' => TRUE,
  28. ),
  29. 'embed_code' => array(
  30. 'type' => 'varchar',
  31. 'length' => 1024,
  32. 'default' => '',
  33. ),
  34. 'description' => array(
  35. 'type' => 'text',
  36. 'not null' => FALSE,
  37. ),
  38. );
  39. $indexes = array();
  40. break;
  41. }
  42. return array(
  43. 'columns' => $columns,
  44. 'indexes' => $indexes
  45. );
  46. }
  47. /**
  48. * Implements hook_schema().
  49. */
  50. function video_embed_field_schema(){
  51. $schema['vef_video_styles'] = array(
  52. 'description' => 'Stores video embed styles.',
  53. 'export' => array(
  54. 'key' => 'name',
  55. 'primary key' => 'vsid',
  56. 'identifier' => 'video_embed_style', // Exports will be as $video_style
  57. 'default hook' => 'default_video_embed_styles', // Function hook name.
  58. 'api' => array(
  59. 'owner' => 'video_embed_field',
  60. 'api' => 'default_video_embed_styles', // Base name for api include files.
  61. 'minimum_version' => 1,
  62. 'current_version' => 1,
  63. ),
  64. ),
  65. 'fields' => array(
  66. 'vsid' => array(
  67. 'description' => 'The primary identifier for a video style.',
  68. 'type' => 'serial',
  69. 'unsigned' => TRUE,
  70. 'not null' => TRUE,
  71. 'no export' => TRUE,
  72. ),
  73. 'name' => array(
  74. 'description' => 'The style name.',
  75. 'type' => 'varchar',
  76. 'length' => '255',
  77. 'not null' => TRUE,
  78. ),
  79. 'data' => array(
  80. 'description' => 'The configuration data for the style.',
  81. 'type' => 'blob',
  82. 'size' => 'big',
  83. 'not null' => TRUE,
  84. 'serialize' => TRUE,
  85. ),
  86. ),
  87. 'primary key' => array('vsid'),
  88. 'unique keys' => array(
  89. 'name' => array('name')
  90. ),
  91. );
  92. return $schema;
  93. }
  94. /**
  95. * Implements hook_uninstall().
  96. */
  97. function video_embed_field_uninstall(){
  98. //do nothing right now - should eventually remove all the variables
  99. }
  100. /**
  101. * Update 7000
  102. * Add an optional description form
  103. */
  104. function video_embed_field_update_7000() {
  105. // Get the list of fields of type 'video_embed_field'.
  106. $video_embed_fields = array();
  107. foreach (field_info_fields() as $field_name => $field_info) {
  108. if ($field_info['type'] == 'video_embed_field') {
  109. $video_embed_fields[$field_name] = field_read_field($field_name);
  110. }
  111. }
  112. foreach ($video_embed_fields as $field) {
  113. if ($field['deleted']) {
  114. $table = "field_deleted_data_{$field['id']}";
  115. $revision_table = "field_deleted_revision_{$field['id']}";
  116. }
  117. else {
  118. $table = "field_data_{$field['field_name']}";
  119. $revision_table = "field_revision_{$field['field_name']}";
  120. }
  121. $column = $field['field_name'] . '_' . 'description';
  122. db_add_field($table, $column, array('type' => 'text', 'not null' => FALSE));
  123. db_add_field($revision_table, $column, array('type' => 'text', 'not null' => FALSE));
  124. }
  125. return t('Additional columns added.');
  126. }
  127. /**
  128. * Update 7001
  129. * Add video style storage table
  130. */
  131. function video_embed_field_update_7001() {
  132. if (!db_table_exists('vef_video_styles')) {
  133. $schema = video_embed_field_schema();
  134. db_create_table('vef_video_styles', $schema['vef_video_styles']);
  135. }
  136. return t('Video styles storage table created.');
  137. }
  138. /**
  139. * Update 7002
  140. * Add field for storing the path to the video thumbnail
  141. */
  142. function video_embed_field_update_7002() {
  143. // Get the list of fields of type 'video_embed_field'.
  144. $video_embed_fields = array();
  145. foreach (field_info_fields() as $field_name => $field_info) {
  146. if ($field_info['type'] == 'video_embed_field') {
  147. $video_embed_fields[$field_name] = field_read_field($field_name);
  148. }
  149. }
  150. foreach ($video_embed_fields as $field) {
  151. if ($field['deleted']) {
  152. $table = "field_deleted_data_{$field['id']}";
  153. $revision_table = "field_deleted_revision_{$field['id']}";
  154. }
  155. else {
  156. $table = "field_data_{$field['field_name']}";
  157. $revision_table = "field_revision_{$field['field_name']}";
  158. }
  159. $column = $field['field_name'] . '_' . 'thumbnail_path';
  160. db_add_field($table, $column, array(
  161. 'type' => 'varchar',
  162. 'length' => 512,
  163. 'default' => ''
  164. ));
  165. db_add_field($revision_table, $column, array(
  166. 'type' => 'varchar',
  167. 'length' => 512,
  168. 'default' => ''
  169. ));
  170. }
  171. return t('Thumbnail column added.');
  172. }
  173. /**
  174. * Enable inline colorbox support if colorbox is installed [NO LONGER NEEDED - This update hook does nothing]
  175. */
  176. function video_embed_field_update_7003() {
  177. //this is no longer needed
  178. //variable_set('colorbox_inline', 1);
  179. }
  180. /**
  181. * Enable colorbox load support if colorbox is installed, we no longer need inline support
  182. */
  183. function video_embed_field_update_7004() {
  184. variable_set('colorbox_load', 1);
  185. }
  186. /**
  187. * Add data column to field database.
  188. */
  189. function video_embed_field_update_7005() {
  190. // Get the list of fields of type 'video_embed_field'.
  191. $video_embed_fields = array();
  192. foreach (field_info_fields() as $field_name => $field_info) {
  193. if ($field_info['type'] == 'video_embed_field') {
  194. $video_embed_fields[$field_name] = field_read_field($field_name);
  195. }
  196. }
  197. foreach ($video_embed_fields as $field) {
  198. if ($field['deleted']) {
  199. $table = "field_deleted_data_{$field['id']}";
  200. $revision_table = "field_deleted_revision_{$field['id']}";
  201. }
  202. else {
  203. $table = "field_data_{$field['field_name']}";
  204. $revision_table = "field_revision_{$field['field_name']}";
  205. }
  206. $column = $field['field_name'] . '_' . 'video_data';
  207. db_add_field($table, $column, array(
  208. 'type' => 'blob',
  209. 'not null' => FALSE,
  210. 'size' => 'big',
  211. 'serialize' => TRUE
  212. ));
  213. db_add_field($revision_table, $column, array(
  214. 'type' => 'blob',
  215. 'not null' => FALSE,
  216. 'size' => 'big',
  217. 'serialize' => TRUE
  218. ));
  219. }
  220. return t('Data column added. Please clear cache.');
  221. }