tripal_ds.field_group.inc 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. <?php
  2. /**
  3. * Creates the Summary tripal pane and the table within that pane.
  4. *
  5. * @param $bundle_name
  6. * Machine name of bundle, example bio_data_1
  7. * @param $fields
  8. * Array of the machine names of the children of the field group being created.
  9. */
  10. function tripal_ds_add_summary_field_group($bundle_name, $fields) {
  11. //Tripal pane to nest the summary fieldset within.
  12. $field_group_tripalpane = new stdClass();
  13. $field_group_tripalpane->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially*/
  14. $field_group_tripalpane->api_version = 1;
  15. $field_group_tripalpane->identifier = 'group_summary_tripalpane|TripalEntity|' . $bundle_name . '|default';
  16. $field_group_tripalpane->group_name = 'group_summary_tripalpane';
  17. $field_group_tripalpane->entity_type = 'TripalEntity';
  18. $field_group_tripalpane->bundle = $bundle_name;
  19. $field_group_tripalpane->mode = 'default';
  20. $field_group_tripalpane->parent_name = '';
  21. $field_group_tripalpane->data = [
  22. 'label' => 'Summary',
  23. 'weight' => '1',
  24. 'children' => [
  25. 0 => 'group_summary_table',
  26. ],
  27. 'format_type' => 'tripalpane',
  28. 'format_settings' => [
  29. 'label' => 'Summary',
  30. 'instance_settings' => [
  31. 'id' => 'tripal_ds-fieldset-group_summary_tripalpane',
  32. 'classes' => 'group-summary-tripalpane field-group-tripalpane',
  33. 'description' => '',
  34. 'hide' => 0,
  35. ],
  36. ],
  37. ];
  38. drupal_write_record('field_group', $field_group_tripalpane);
  39. //Write to the tripal_ds table to record the new tripal pane.
  40. tripal_ds_bundle_menu_item($bundle_name, 'Summary', 'group_summary_tripalpane', 'TripalEntity');
  41. //Table of fields.
  42. $field_group = new stdClass();
  43. $field_group->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially*/
  44. $field_group->api_version = 1;
  45. $field_group->identifier = 'group_summary_table|TripalEntity|' . $bundle_name . '|default';
  46. $field_group->group_name = 'group_summary_table';
  47. $field_group->entity_type = 'TripalEntity';
  48. $field_group->bundle = $bundle_name;
  49. $field_group->mode = 'default';
  50. $field_group->parent_name = 'group_summary_tripalpane';
  51. $field_group->data = [
  52. 'label' => 'Summary Table',
  53. 'weight' => '1',
  54. 'children' => $fields,
  55. 'format_type' => 'table',
  56. 'format_settings' => [
  57. 'label' => 'Summary Table',
  58. 'instance_settings' => [
  59. 'label_visibility' => '1',
  60. 'desc' => '',
  61. 'first_column' => '',
  62. 'second_column' => '',
  63. 'empty_label_behavior' => '1',
  64. 'table_row_striping' => 0,
  65. 'always_show_field_label' => 0,
  66. 'classes' => 'group-summary-table field-group-table',
  67. ],
  68. ],
  69. ];
  70. drupal_write_record('field_group', $field_group);
  71. }
  72. /**
  73. * Creates the Properties Table tripal pane and the table within that pane.
  74. *
  75. * @param $bundle_name
  76. * Machine name of bundle, example bio_data_1
  77. * @param $fields
  78. * Array of the machine names of the children of the field group being created.
  79. */
  80. function tripal_ds_add_prop_field_group($bundle_name, $fields) {
  81. //Tripal pane to nest the fieldset within.
  82. $field_group_tripalpane = new stdClass();
  83. $field_group_tripalpane->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially*/
  84. $field_group_tripalpane->api_version = 1;
  85. $field_group_tripalpane->identifier = 'group_prop_tripalpane|TripalEntity|' . $bundle_name . '|default';
  86. $field_group_tripalpane->group_name = 'group_prop_tripalpane';
  87. $field_group_tripalpane->entity_type = 'TripalEntity';
  88. $field_group_tripalpane->bundle = $bundle_name;
  89. $field_group_tripalpane->mode = 'default';
  90. $field_group_tripalpane->parent_name = '';
  91. $field_group_tripalpane->data = [
  92. 'label' => 'Properties',
  93. 'weight' => '1',
  94. 'children' => [
  95. 0 => 'group_prop_table',
  96. ],
  97. 'format_type' => 'tripalpane',
  98. 'format_settings' => [
  99. 'label' => 'Properties',
  100. 'instance_settings' => [
  101. 'id' => 'tripal_ds-fieldset-group_prop_tripalpane',
  102. 'classes' => 'group-prop-tripalpane field-group-tripalpane',
  103. 'description' => '',
  104. 'hide' => 1,
  105. ],
  106. ],
  107. ];
  108. drupal_write_record('field_group', $field_group_tripalpane);
  109. //Write to the tripal_ds table to record the new tripal pane.
  110. tripal_ds_bundle_menu_item($bundle_name, 'Properties', 'group_prop_tripalpane', 'TripalEntity');
  111. //Table of fields.
  112. $field_group = new stdClass();
  113. $field_group->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially*/
  114. $field_group->api_version = 1;
  115. $field_group->identifier = 'group_prop_table|TripalEntity|' . $bundle_name . '|default';
  116. $field_group->group_name = 'group_prop_table';
  117. $field_group->entity_type = 'TripalEntity';
  118. $field_group->bundle = $bundle_name;
  119. $field_group->mode = 'default';
  120. $field_group->parent_name = 'group_prop_tripalpane';
  121. $field_group->data = [
  122. 'label' => 'Properties Table',
  123. 'weight' => '1',
  124. 'children' => $fields,
  125. 'format_type' => 'table',
  126. 'format_settings' => [
  127. 'label' => 'Properties Table',
  128. 'instance_settings' => [
  129. 'label_visibility' => '1',
  130. 'desc' => '',
  131. 'first_column' => '',
  132. 'second_column' => '',
  133. 'empty_label_behavior' => '1',
  134. 'table_row_striping' => 0,
  135. 'always_show_field_label' => 0,
  136. 'classes' => 'group-prop-table field-group-table',
  137. ],
  138. ],
  139. ];
  140. drupal_write_record('field_group', $field_group);
  141. }
  142. /**
  143. * Creates the Data Sequence tripal pane and the table within that pane.
  144. *
  145. * @param $bundle_name
  146. * Machine name of bundle, example bio_data_1
  147. * @param $fields
  148. * Array of the machine names of the children of the field group being created.
  149. */
  150. function tripal_ds_add_sequences_field_group($bundle_name, $fields) {
  151. //Tripal pane to nest the fieldset within.
  152. $field_group_tripalpane = new stdClass();
  153. $field_group_tripalpane->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially*/
  154. $field_group_tripalpane->api_version = 1;
  155. $field_group_tripalpane->identifier = 'group_sequence_tripalpane|TripalEntity|' . $bundle_name . '|default';
  156. $field_group_tripalpane->group_name = 'group_sequence_tripalpane';
  157. $field_group_tripalpane->entity_type = 'TripalEntity';
  158. $field_group_tripalpane->bundle = $bundle_name;
  159. $field_group_tripalpane->mode = 'default';
  160. $field_group_tripalpane->parent_name = '';
  161. $field_group_tripalpane->data = [
  162. 'label' => 'Sequences',
  163. 'weight' => '1',
  164. 'children' => [
  165. 0 => 'group_sequence_table',
  166. ],
  167. 'format_type' => 'tripalpane',
  168. 'format_settings' => [
  169. 'label' => 'Sequences',
  170. 'instance_settings' => [
  171. 'id' => 'tripal_ds-fieldset-group_sequence_tripalpane',
  172. 'classes' => 'group-sequence-tripalpane field-group-tripalpane ',
  173. 'description' => '',
  174. 'hide' => 1,
  175. ],
  176. ],
  177. ];
  178. drupal_write_record('field_group', $field_group_tripalpane);
  179. //Write to the tripal_ds table to record the new tripal pane.
  180. tripal_ds_bundle_menu_item($bundle_name, 'Sequences', 'group_sequence_tripalpane', 'TripalEntity');
  181. //Table of fields.
  182. $field_group = new stdClass();
  183. $field_group->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially*/
  184. $field_group->api_version = 1;
  185. $field_group->identifier = 'group_sequence_table|TripalEntity|' . $bundle_name . '|default';
  186. $field_group->group_name = 'group_sequence_table';
  187. $field_group->entity_type = 'TripalEntity';
  188. $field_group->bundle = $bundle_name;
  189. $field_group->mode = 'default';
  190. $field_group->parent_name = 'group_sequence_tripalpane';
  191. $field_group->data = [
  192. 'label' => 'Sequences Table',
  193. 'weight' => '1',
  194. 'children' => $fields,
  195. 'format_type' => 'table',
  196. 'format_settings' => [
  197. 'label' => 'Sequences Table',
  198. 'instance_settings' => [
  199. 'label_visibility' => '1',
  200. 'desc' => '',
  201. 'first_column' => '',
  202. 'second_column' => '',
  203. 'empty_label_behavior' => '1',
  204. 'table_row_striping' => 0,
  205. 'always_show_field_label' => 0,
  206. 'classes' => 'group-sequence-table field-group-table',
  207. ],
  208. ],
  209. ];
  210. drupal_write_record('field_group', $field_group);
  211. }
  212. /**
  213. * Processes all fields other than those that belong in the summary table,
  214. * property table, or data sequence table.
  215. *
  216. * @param $bundle_name
  217. * Machine name of bundle, example bio_data_1
  218. * @param $field_label
  219. * Human readable name of the field.
  220. * @param $group_field_name
  221. * Machine name of the field.
  222. * @param $field_name
  223. * Machine name of the child element.
  224. */
  225. function tripal_ds_add_generic_field_group($bundle_name, $field_label, $group_field_name, $field_name) {
  226. //Write to the tripal_ds table to record the new tripal pane.
  227. tripal_ds_bundle_menu_item($bundle_name, $field_label, $group_field_name, 'TripalEntity');
  228. //Tripal pane to nest the fieldset within.
  229. $field_group_fieldset = new stdClass();
  230. $field_group_fieldset->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially*/
  231. $field_group_fieldset->api_version = 1;
  232. $field_group_fieldset->identifier = $group_field_name . '|TripalEntity|' . $bundle_name . '|default';
  233. $field_group_fieldset->group_name = $group_field_name;
  234. $field_group_fieldset->entity_type = 'TripalEntity';
  235. $field_group_fieldset->bundle = $bundle_name;
  236. $field_group_fieldset->mode = 'default';
  237. $field_group_fieldset->parent_name = '';
  238. $field_group_fieldset->data = [
  239. 'label' => $field_label,
  240. 'weight' => '1',
  241. 'children' => [
  242. 0 => $field_name,
  243. ],
  244. 'format_type' => 'tripalpane',
  245. 'format_settings' => [
  246. 'label' => $field_label,
  247. 'instance_settings' => [
  248. 'id' => 'tripal_ds-fieldset-' . $group_field_name,
  249. 'classes' => '' . $group_field_name . ' field-group-tripalpane',
  250. 'description' => '',
  251. 'hide' => 1,
  252. ],
  253. ],
  254. ];
  255. drupal_write_record('field_group', $field_group_fieldset);
  256. }
  257. /**
  258. * Creates the tripal panes for Publications..
  259. *
  260. * @param $bundle_name
  261. * Machine name of bundle, example bio_data_1
  262. * @param $fields
  263. * Array of the machine names of the children of the field group being created.
  264. */
  265. function _publication_prop_field_group_info($bundle_name, $fields) {
  266. //Tripal pane to nest the fieldset within.
  267. $field_group_tripalpane = new stdClass();
  268. $field_group_tripalpane->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially*/
  269. $field_group_tripalpane->api_version = 1;
  270. $field_group_tripalpane->identifier = 'group_summary_tripalpane|TripalEntity|' . $bundle_name . '|default';
  271. $field_group_tripalpane->group_name = 'group_summary_tripalpane';
  272. $field_group_tripalpane->entity_type = 'TripalEntity';
  273. $field_group_tripalpane->bundle = $bundle_name;
  274. $field_group_tripalpane->mode = 'default';
  275. $field_group_tripalpane->parent_name = '';
  276. $field_group_tripalpane->data = [
  277. 'label' => 'Summary',
  278. 'weight' => '1',
  279. 'children' => [
  280. 0 => 'group_summary_table',
  281. ],
  282. 'format_type' => 'tripalpane',
  283. 'format_settings' => [
  284. 'label' => 'Properties',
  285. 'instance_settings' => [
  286. 'id' => 'tripal_ds-fieldset-group_prop_tripalpane',
  287. 'classes' => 'group-prop-tripalpane field-group-tripalpane',
  288. 'description' => '',
  289. 'hide' => 0,
  290. ],
  291. ],
  292. ];
  293. drupal_write_record('field_group', $field_group_tripalpane);
  294. //Write to the tripal_ds table to record the new tripal pane.
  295. tripal_ds_bundle_menu_item($bundle_name, 'Summary', 'group_summary_tripalpane', 'TripalEntity');
  296. //Table of fields.
  297. $field_group = new stdClass();
  298. $field_group->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially*/
  299. $field_group->api_version = 1;
  300. $field_group->identifier = 'group_summary_table|TripalEntity|' . $bundle_name . '|default';
  301. $field_group->group_name = 'group_summary_table';
  302. $field_group->entity_type = 'TripalEntity';
  303. $field_group->bundle = $bundle_name;
  304. $field_group->mode = 'default';
  305. $field_group->parent_name = 'group_summary_tripalpane';
  306. $field_group->data = [
  307. 'label' => 'Summary Table',
  308. 'weight' => '1',
  309. 'children' => [
  310. 0 => 'tpub__doi',
  311. 1 => 'tpub__publication_date',
  312. 2 => 'schema__additional_type',
  313. 3 => 'tpub__abstract',
  314. 4 => 'tpub__citation',
  315. ],
  316. 'format_type' => 'table',
  317. 'format_settings' => [
  318. 'label' => 'Summary Table',
  319. 'instance_settings' => [
  320. 'label_visibility' => '1',
  321. 'desc' => '',
  322. 'first_column' => '',
  323. 'second_column' => '',
  324. 'empty_label_behavior' => '1',
  325. 'table_row_striping' => 0,
  326. 'always_show_field_label' => 0,
  327. 'classes' => 'group-prop-table field-group-table',
  328. ],
  329. ],
  330. ];
  331. drupal_write_record('field_group', $field_group);
  332. }