|
@@ -1,25 +1,14 @@
|
|
<?php
|
|
<?php
|
|
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
- *
|
|
|
|
- * Implements hook_form_FORM_ID_alter().
|
|
|
|
- *
|
|
|
|
- * The field_ui_field_edit_form is used for customizing the settings of
|
|
|
|
- * a field attached to an entity.
|
|
|
|
|
|
+ * Implements hook_form_init();
|
|
*/
|
|
*/
|
|
-function tripal_panes_form_field_ui_field_edit_form_alter(&$form, &$form_state, $form_id) {
|
|
|
|
- // For entity fields added by Tripal Entities we don't want the
|
|
|
|
- // the end-user to change the cardinality and the required fields
|
|
|
|
- // such that record can't be saved in Chado.
|
|
|
|
- // TODO: this shouldn't be hardcoded here. These settings
|
|
|
|
- // should be part of the field and handled by the tripal_entity module.
|
|
|
|
- if (in_array($form['#instance']['entity_type'], $dbs)) {
|
|
|
|
- $form['field']['cardinality']['#access'] = FALSE;
|
|
|
|
- $form['instance']['required']['#access'] = FALSE;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // TODO: don't the the maximum length be larger than the field size.
|
|
|
|
|
|
+function tripal_panes_init() {
|
|
|
|
+ $theme_dir = url(drupal_get_path('module', 'tripal_panes') . '/theme');
|
|
|
|
+ drupal_add_js("var panes_theme_dir = '$theme_dir';", 'inline', 'header');
|
|
}
|
|
}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Implements hook_form_FORM_ID_alter().
|
|
* Implements hook_form_FORM_ID_alter().
|
|
*
|
|
*
|
|
@@ -27,7 +16,11 @@ function tripal_panes_form_field_ui_field_edit_form_alter(&$form, &$form_state,
|
|
* or layout of fields attached to an entity.
|
|
* or layout of fields attached to an entity.
|
|
*/
|
|
*/
|
|
function tripal_panes_form_field_ui_display_overview_form_alter(&$form, &$form_state, $form_id) {
|
|
function tripal_panes_form_field_ui_display_overview_form_alter(&$form, &$form_state, $form_id) {
|
|
-
|
|
|
|
|
|
+ // Only modify the form for Tripal Content Type
|
|
|
|
+ if ($form['#entity_type'] != 'TripalEntity') {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ drupal_add_js(drupal_get_path('module','tripal_panes') . '/theme/js/tripal_panes.admin.js');
|
|
drupal_add_css(drupal_get_path('module','tripal_panes') . '/theme/css/tripal_panes.css');
|
|
drupal_add_css(drupal_get_path('module','tripal_panes') . '/theme/css/tripal_panes.css');
|
|
|
|
|
|
$entity_type = $form['#entity_type'];
|
|
$entity_type = $form['#entity_type'];
|
|
@@ -45,7 +38,7 @@ function tripal_panes_form_field_ui_display_overview_form_alter(&$form, &$form_s
|
|
module. If you would like to use Tripal-style panes for the layout
|
|
module. If you would like to use Tripal-style panes for the layout
|
|
of your pages please disable the Display Suite module. If you
|
|
of your pages please disable the Display Suite module. If you
|
|
prefer to use the Display Suite module then disable the Tripal
|
|
prefer to use the Display Suite module then disable the Tripal
|
|
- Fields Layout (tripal_panes) module.', 'warning');
|
|
|
|
|
|
+ Panes (tripal_panes) module.', 'warning');
|
|
}
|
|
}
|
|
|
|
|
|
// Add a vertical tab fieldset at the bottom of the
|
|
// Add a vertical tab fieldset at the bottom of the
|
|
@@ -63,15 +56,15 @@ function tripal_panes_form_field_ui_display_overview_form_alter(&$form, &$form_s
|
|
);
|
|
);
|
|
|
|
|
|
// Make sure our default pane are in the database.
|
|
// Make sure our default pane are in the database.
|
|
- _tripal_panes_check_default_field_panes($bundle);
|
|
|
|
|
|
+ tripal_panes_check_default_field_panes($bundle);
|
|
|
|
|
|
- // Add a pane
|
|
|
|
|
|
+ // Adds form elments as a vertical tab for adding a pane.
|
|
tripal_panes_form_field_ui_display_overview_form_pane_add($form, $form_state);
|
|
tripal_panes_form_field_ui_display_overview_form_pane_add($form, $form_state);
|
|
|
|
|
|
- // Arrange panes
|
|
|
|
|
|
+ // Adds form elments as a vertical tab for arranging panes.
|
|
tripal_panes_form_field_ui_display_overview_form_pane_arrange($form, $form_state, $bundle);
|
|
tripal_panes_form_field_ui_display_overview_form_pane_arrange($form, $form_state, $bundle);
|
|
|
|
|
|
- // Configure panes
|
|
|
|
|
|
+ // Adds form elments as a vertical tab for configuring panes.
|
|
tripal_panes_form_field_ui_display_overview_form_pane_configure($form, $form_state, $bundle);
|
|
tripal_panes_form_field_ui_display_overview_form_pane_configure($form, $form_state, $bundle);
|
|
|
|
|
|
// Now add each pane as a region.
|
|
// Now add each pane as a region.
|
|
@@ -83,6 +76,7 @@ function tripal_panes_form_field_ui_display_overview_form_alter(&$form, &$form_s
|
|
->orderBy('label', 'ASC')
|
|
->orderBy('label', 'ASC')
|
|
->execute();
|
|
->execute();
|
|
$pane_options = array();
|
|
$pane_options = array();
|
|
|
|
+
|
|
while ($pane = $panes->fetchObject()) {
|
|
while ($pane = $panes->fetchObject()) {
|
|
$settings = unserialize($pane->settings);
|
|
$settings = unserialize($pane->settings);
|
|
$form['fields']['#regions'][$pane->name] = array(
|
|
$form['fields']['#regions'][$pane->name] = array(
|
|
@@ -367,7 +361,7 @@ function tripal_panes_form_field_ui_display_overview_form_pane_configure (&$form
|
|
/**
|
|
/**
|
|
* A helper function for checking if the default panes are in the database.
|
|
* A helper function for checking if the default panes are in the database.
|
|
*/
|
|
*/
|
|
-function _tripal_panes_check_default_field_panes($bundle) {
|
|
|
|
|
|
+function tripal_panes_check_default_field_panes($bundle) {
|
|
// Make sure we have records for our default regions: te_base and te_hidden.
|
|
// Make sure we have records for our default regions: te_base and te_hidden.
|
|
// First check if the base region is in the database. If not, add it.
|
|
// First check if the base region is in the database. If not, add it.
|
|
$te_base = db_select('tripal_panes', 'tp')
|
|
$te_base = db_select('tripal_panes', 'tp')
|
|
@@ -659,8 +653,8 @@ function tripal_panes_action_order_panes (&$form, &$form_state) {
|
|
/**
|
|
/**
|
|
* Theme the Arrange panes as a draggable table
|
|
* Theme the Arrange panes as a draggable table
|
|
*
|
|
*
|
|
- * @param unknown $variables
|
|
|
|
- * @return unknown
|
|
|
|
|
|
+ * @param $variables
|
|
|
|
+ * @return
|
|
*/
|
|
*/
|
|
function theme_tripal_panes_form_arrange_panes ($variables) {
|
|
function theme_tripal_panes_form_arrange_panes ($variables) {
|
|
$element = $variables['element'];
|
|
$element = $variables['element'];
|
|
@@ -831,7 +825,7 @@ function tripal_panes_entity_view($entity, $type, $view_mode, $langcode) {
|
|
->execute()
|
|
->execute()
|
|
->fetchObject();
|
|
->fetchObject();
|
|
|
|
|
|
- _tripal_panes_check_default_field_panes($bundle);
|
|
|
|
|
|
+ tripal_panes_check_default_field_panes($bundle);
|
|
|
|
|
|
$results = db_select('tripal_panes', 'tp')
|
|
$results = db_select('tripal_panes', 'tp')
|
|
->fields('tp', array('pane_id','name', 'label', 'settings'))
|
|
->fields('tp', array('pane_id','name', 'label', 'settings'))
|
|
@@ -889,7 +883,7 @@ function tripal_panes_entity_view($entity, $type, $view_mode, $langcode) {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Implements hook_entity_view.
|
|
|
|
|
|
+ * Ajax callback to return pane's form elements when configuring pane
|
|
*/
|
|
*/
|
|
function tripal_panes_ajax_get_pane_setting_fieldset($form, &$form_state) {
|
|
function tripal_panes_ajax_get_pane_setting_fieldset($form, &$form_state) {
|
|
$pane_id = $form_state['values']['pane_select'];
|
|
$pane_id = $form_state['values']['pane_select'];
|