Explorar o código

Renamed tripal_fields_layout module to tripal_panes, copied in some missing CSS, renamed CSS, clened up template a bit

Stephen Ficklin %!s(int64=9) %!d(string=hai) anos
pai
achega
a30f71beef

+ 0 - 11
tripal_fields_layout/theme/css/tripal_fields_layout.css

@@ -1,11 +0,0 @@
-@CHARSET "UTF-8";
-
-.tripal-entity-panel {
-  border: solid 1px #CCC;
-  margin: 15px 0px;
-  padding: 15px;
-}
-
-.tripal-entity-panel h2 {
-  margin-top: 0px;
-}

+ 0 - 10
tripal_fields_layout/theme/css/tripal_fields_layout_panels.css

@@ -1,10 +0,0 @@
-@CHARSET "UTF-8";
-
-.tripal_fields_layout-panel_configure-fieldset .form-type-radio {
-  display: inline;
-  margin-right: 15px !important;
-}
-
-.tripal_panel-configure_panel_table td {
-  width:50%;
-}

+ 0 - 53
tripal_fields_layout/theme/js/tripal_fields_layout.js

@@ -1,53 +0,0 @@
-(function($) {
-
-  Drupal.behaviors.tripal_fields_layout = {
-    attach: function (context, settings){
-    
-      // Add a close button for each panel
-      $('.tripal_panel-fieldset .fieldset-legend').each(function (i) {
-        $(this).append('<div class="tripal_panel-fieldset-close_button">[X]</div>');
-      });
-      // Hide the panel when the close button is clicked
-      $('.tripal_panel-fieldset-close_button').each(function (i) {
-    	$(this).css('float', 'right');
-    	$(this).css('cursor', 'pointer');
-    	$(this).css('margin', '0px 5px');
-    	$(this).click(function () {
-    		var fs = $(this).parent().parent().parent();
-    		var fsid = fs.attr('id');
-    		if (fsid.indexOf('tripal_panel-fieldset-') == 0) {
-    		  $(fs).fadeOut(300);
-    		}
-    	});
-      });
-      
-      // Move the panel to the first when its TOC item is clicked.
-      $('.tripal_toc_list_item_link').each(function (i) {
-    	  $(this).click(function() {
-    		  var id = '#tripal_panel-fieldset-' + $(this).attr('id');
-    		  $(id).removeClass('collapsed');
-  		      $(id + ' .fieldset-wrapper').show();
-    		  var prevObj = $(id).prev().attr('class');
-    		  // Highlight the panel if it's already at the top
-    		  if (prevObj.indexOf('tripal_panel-base_panel') == 0 && $(id).css('display') == 'block') {
-    		    var color = $(id).css('background-color') ? $(id).css('background-color') : '#FFFFFF';
-                    if (jQuery.ui) {
-                      $(id).fadeTo(10, 0.5, function() {});
-                      $(id).fadeTo(100, 1, function() {});
-                      //$(id).effect('highlight', {color: '#DDDEEE'});
-                    }
-    		  }
-    		  // Move the panel
-    		  else {
-    		    $(id).hide();
-    		    var obj = $(id).detach();
-    		    $('.tripal_panel-base_panel').after(obj);
-    		    $(id).show(300);
-    		  }
-    		  return false;
-    	  });
-      });
-    },
-  };
-  
-})(jQuery);

+ 0 - 147
tripal_fields_layout/theme/templates/tripal_fields_layout_generic.tpl.php

@@ -1,147 +0,0 @@
-<?php
-
-drupal_add_js('misc/form.js');
-drupal_add_js('misc/collapse.js');
-drupal_add_js(drupal_get_path('module','tripal_fields_layout') . '/theme/js/tripal_fields_layout.js');
-$panels = $variables['element']['#panels'];
-$fields = $variables['element']['#fields'];
-
-// Render fields in a table
-function render_table ($table_layout) {
-  $table = '';
-  if (count($table_layout) != 0) {
-    $rows = array();
-    foreach ($table_layout as $field) {
-      $rows[] = array(
-        array(
-          'data' => $field['#title'],
-          'header' => TRUE,
-          'width' => '20%',
-          'nowrap' => 'nowrap'
-        ),
-        $field[0]['#markup']
-      );
-    }
-    $table = theme_table(array(
-      'header' => array(),
-      'rows' => $rows,
-      'attributes' => array(
-        'id' => '',  // TODO: need to add an ID
-        'class' => 'tripal-data-horz-table'
-      ),
-      'sticky' => FALSE,
-      'caption' => '',
-      'colgroups' => array(),
-      'empty' => '',
-    ));
-  }
-  return $table;
-}
-
-// Render fields not in a group
-function render_fields($no_group) {
-  $ungrouped = '';
-  if (count($no_group) != 0) {
-    foreach ($no_group as $field) {
-      $ungrouped .= render($field);
-    }
-  }
-  return $ungrouped;
-}
-
-// Process fields in panels
-$content = '';
-$toc = '';
-$has_base_panel_only = TRUE;
-foreach ($panels AS $panel_id => $panel) {
-  if ($panel->name != 'te_base') {
-    $has_base_panel_only = FALSE;
-  }
-  $panel_settings = unserialize($panel->settings);
-  $table_layout_group = key_exists('table_layout', $panel_settings) ? $panel_settings['table_layout'] : array();
-
-  // Rearrange fields into groups for each panel
-  $panel_fields = $fields[$panel_id];
-
-  // Keyed by field's '#weight' and '#field_name so we can ksort() by weight
-  $weighed_fields = array();
-  foreach ($panel_fields AS $field) {
-      $weighed_fields [$field['#weight'] . $field['#field_name']] = $field;
-  }
-  ksort($weighed_fields, SORT_NUMERIC);
-  
-  // Render weighed fields
-  $table_layout = array();
-  $no_group = array();
-  $output = '';
-  $current_layout = '';
-  $counter = 0;
-  foreach ($weighed_fields AS $field) {
-    // The field is in a table
-    if (in_array($field['#field_name'], $table_layout_group)) {
-  
-      if ($counter != 0 && $current_layout != 'Table') {
-        $output .= render_fields($no_group);
-        $no_group = array();
-      }
-      $table_layout [$field['#weight'] . $field['#field_name']] = $field;
-      $current_layout = 'Table';
-    }
-    // The field is not in a table
-    else {
-      if ($counter != 0 && $current_layout != 'Default') {
-        $output .= render_table($table_layout);
-        $table_layout = array();
-      }
-      $no_group [$field['#weight'] . $field['#field_name']] = $field;
-      $current_layout = 'Default';
-    }
-    $counter ++;
-  }
-  if ($current_layout == 'Table') {
-    $output .= render_table($table_layout);
-  }
-  else if ($current_layout == 'Default') {
-    $output .= render_fields($no_group);
-  }
-
-  // If this is a base content, do not organize the content in a fieldset
-  if ($panel->name == 'te_base') {
-    $content .= '<div class="tripal_panel-base_panel">' . $output . '</div>';
-  } else {
-    $collapsible_item = array('element' => array());
-    $collapsible_item['element']['#description'] = $output;
-    $collapsible_item['element']['#title'] = $panel->label;
-    $collapsible_item['element']['#children'] = '';
-    $collapsible_item['element']['#attributes']['id'] = 'tripal_panel-fieldset-' . $panel->name;
-    $collapsible_item['element']['#attributes']['class'][] = 'tripal_panel-fieldset';
-    $collapsible_item['element']['#attributes']['class'][] = 'collapsible';
-    $collapsible_item['element']['#attributes']['class'][] = 'collapsed';
-    $toc_item_id = $panel_id;
-    $toc .= "<div class=\"tripal_toc_list_item\"><a id=\"" . $panel->name . "\" class=\"tripal_toc_list_item_link\" href=\"?pane=" . $panel->name . "\">" . $panel->label . "</a></div>";
-    $content .= theme('fieldset', $collapsible_item);
-  }
-}
-
-$bundle_type = ''; // TODO: need to add the bundle type
-
-if ($has_base_panel_only) { ?>
-  <div id ="tripal-<?php print $bundle_type?>-contents-box"> <?php
-    // print the rendered content
-    print $content; ?>
-  </div> <?php
-} else { ?>
-  <table id ="tripal-<?php print $bundle_type?>-contents-table" class="tripal-contents-table">
-    <tr class="tripal-contents-table-tr"> <?php 
-      ?>
-      <td nowrap class="tripal-contents-table-td tripal-contents-table-td-toc" align="left"><?php
-        print $toc; ?>
-      </td>
-      <td class="tripal-contents-table-td-data" align="left" width="100%"> <?php
-
-        // print the rendered content
-        print $content; ?>
-      </td>
-    </tr>
-  </table> <?php 
-} ?>

+ 109 - 0
tripal_panes/theme/css/tripal_panes.css

@@ -0,0 +1,109 @@
+@CHARSET "UTF-8";
+
+.tripal-entity-pane {
+  border: solid 1px #CCC;
+  margin: 15px 0px;
+  padding: 15px;
+}
+
+.tripal-entity-pane h2 {
+  margin-top: 0px;
+}
+
+.tripal_panes-pane_configure-fieldset .form-type-radio {
+  display: inline;
+  margin-right: 15px !important;
+}
+
+.tripal_pane-configure_pane_table td {
+  width:50%;
+}
+
+/**
+ * The Tripal generic pane template (tripal_panes_generic.tpl.php)
+ * has an outer div box with class 'tripal-panes' and with an inner
+ * table with an id of 'tripal-panes-table'.  The table has a single
+ * row with two columns.  The smaller left column houses the table of
+ * contents (TOC) for the node data.  The larger right column houses the data:
+ *
+ * |-----------------------------------------------|
+ * |  .tripal-panes                                |
+ * | |-------------------------------------------| |
+ * | | .tripal-panes-table                       | |
+ * | |        |                                  | |
+ * | |        |                                  | |
+ * | | TOC    |          Data                    | |
+ * | | column |          Column                  | |
+ * | |        |                                  | |
+ * | |        |                                  | |
+ * | |        |                                  | |
+ * | |-------------------------------------------| |
+ * |-----------------------------------------------|
+ *
+ * The tripal-panes box and the inner table are designed to fill the width
+ * of the contents section of any theme.  Customize the CSS below to change
+ * the look-and-feel.
+ *
+ */
+
+.tripal-panes {
+  width: 100%;
+}
+
+.tripal-panes-links {
+}
+
+.tripal-panes_table {
+  padding: 0px !important;
+  margin:  0px !important;
+}
+
+/**
+ * The table formatting must override the default theme.  This is because
+ * the table is meant for organizing the sidebar and contents so they don't
+ * slip and slide around as would happen with div boxes that were floated.
+ * Therefore, we use !important to keep the default theme from overrideing
+ * the table settings.
+ */
+
+.tripal-panes-table tbody {
+  padding: 0px !important;
+  margin:  0px !important;
+  border:  none !important;
+  background-color: transparent !important;
+}
+.tripal-panes-table-tr {
+  padding: 0px !important;
+  margin:  0px !important;
+  border:  none !important;
+  background-color: transparent !important;
+}
+.tripal-panes-table-td-toc {
+  border-right: 1px solid #CCCCCC !important;
+  margin:  0px !important;
+  padding: 0px !important;
+  background-color: transparent !important;
+  text-align: left !important;
+  vertical-align: top !important;
+}
+.tripal-panes-table-td-data {
+  border: none !important;
+  margin:  0px !important;
+  padding: 0px 0px 0px 20px !important;
+  background-color: transparent !important;
+  text-align: left !important;
+  vertical-align: top !important;
+}
+
+/**
+ * The table of contents is an unordered list. The following can are used
+ * to style the list
+ */
+.tripal-panes-toc-list {
+
+}
+.tripal-panes-toc-list-item  {
+  padding: 3px 20px 3px 0px !important;
+  margin: 2px 0 2px 0 !important;
+}
+

+ 55 - 0
tripal_panes/theme/js/tripal_panes.js

@@ -0,0 +1,55 @@
+(function($) {
+
+  Drupal.behaviors.tripal_panes = {
+    attach: function (context, settings){
+    
+      // Add a close button for each pane
+      $('.tripal_pane-fieldset .fieldset-legend').each(function (i) {
+        $(this).append('<div class="tripal_pane-fieldset-close_button">[X]</div>');
+      });
+      
+      // Hide the pane when the close button is clicked
+      $('.tripal_pane-fieldset-close_button').each(function (i) {
+        $(this).css('float', 'right');
+        $(this).css('cursor', 'pointer');
+        $(this).css('margin', '0px 5px');
+        $(this).click(function () {
+          var fs = $(this).parent().parent().parent();
+          var fsid = fs.attr('id');
+          if (fsid.indexOf('tripal_pane-fieldset-') == 0) {
+            $(fs).fadeOut(300);
+          }
+        });
+      });
+      
+      // Move the pane to the first when its TOC item is clicked.
+      $('.tripal_toc_list_item_link').each(function (i) {
+        $(this).click(function() {
+          var id = '#tripal_pane-fieldset-' + $(this).attr('id');
+          $(id).removeClass('collapsed');
+          $(id + ' .fieldset-wrapper').show();
+          var prevObj = $(id).prev().attr('class');
+          
+          // Highlight the pane if it's already at the top
+          if (prevObj.indexOf('tripal_pane-base_pane') == 0 && $(id).css('display') == 'block') {
+            var color = $(id).css('background-color') ? $(id).css('background-color') : '#FFFFFF';
+            if (jQuery.ui) {
+              $(id).fadeTo(10, 0.5, function() {});
+              $(id).fadeTo(100, 1, function() {});
+              //$(id).effect('highlight', {color: '#DDDEEE'});
+            }
+          }
+          // Move the pane
+          else {
+            $(id).hide();
+            var obj = $(id).detach();
+            $('.tripal_pane-base_pane').after(obj);
+            $(id).show(300);
+          }
+          return false;
+        });
+      });
+    },
+  };
+  
+})(jQuery);

+ 176 - 0
tripal_panes/theme/templates/tripal_panes_generic.tpl.php

@@ -0,0 +1,176 @@
+<?php
+/**
+ * This template file provides the layout for the Tripal Panes modules.  It
+ * allows fields to be displayed inside of collapsible panes.
+ *
+ */
+
+// Add some necessary JavaScript dependencies.
+drupal_add_js('misc/form.js');
+drupal_add_js('misc/collapse.js');
+drupal_add_js(drupal_get_path('module','tripal_panes') . '/theme/js/tripal_panes.js');
+
+// Get the variables passed into this template.
+$panes = $variables['element']['#panes'];
+$fields = $variables['element']['#fields'];
+
+
+// Process fields in panes
+$content = '';
+$toc = '';
+$has_base_pane_only = TRUE;
+foreach ($panes AS $pane_id => $pane) {
+  if ($pane->name != 'te_base') {
+    $has_base_pane_only = FALSE;
+  }
+  $pane_settings = unserialize($pane->settings);
+  $table_layout_group = key_exists('table_layout', $pane_settings) ? $pane_settings['table_layout'] : array();
+
+  // Rearrange fields into groups for each pane
+  $pane_fields = $fields[$pane_id];
+
+  // Keyed by field's '#weight' and '#field_name so we can ksort() by weight
+  $weighed_fields = array();
+  foreach ($pane_fields as $field) {
+    $weighed_fields [$field['#weight'] . $field['#field_name']] = $field;
+  }
+  ksort($weighed_fields, SORT_NUMERIC);
+
+  // Render weighed fields
+  $table_layout = array();
+  $no_group = array();
+  $output = '';
+  $current_layout = '';
+  $counter = 0;
+  foreach ($weighed_fields AS $field) {
+    // The field is in a table
+    if (in_array($field['#field_name'], $table_layout_group)) {
+
+      if ($counter != 0 && $current_layout != 'Table') {
+        $output .= tripal_panes_generic_render_fields($no_group);
+        $no_group = array();
+      }
+      $table_layout [$field['#weight'] . $field['#field_name']] = $field;
+      $current_layout = 'Table';
+    }
+    // The field is not in a table
+    else {
+      if ($counter != 0 && $current_layout != 'Default') {
+        $output .= tripal_panes_generic_render_table($table_layout);
+        $table_layout = array();
+      }
+      $no_group [$field['#weight'] . $field['#field_name']] = $field;
+      $current_layout = 'Default';
+    }
+    $counter ++;
+  }
+  if ($current_layout == 'Table') {
+    $output .= tripal_panes_generic_render_table($table_layout);
+  }
+  else if ($current_layout == 'Default') {
+    $output .= tripal_panes_generic_render_fields($no_group);
+  }
+
+  // If this is a base content, do not organize the content in a fieldset
+  if ($pane->name == 'te_base') {
+    $content .= '<div class="tripal_pane-base_pane">' . $output . '</div>';
+  }
+  else {
+    $collapsible_item = array('element' => array());
+    $collapsible_item['element']['#description'] = $output;
+    $collapsible_item['element']['#title'] = $pane->label;
+    $collapsible_item['element']['#children'] = '';
+    $collapsible_item['element']['#attributes']['id'] = 'tripal_pane-fieldset-' . $pane->name;
+    $collapsible_item['element']['#attributes']['class'][] = 'tripal_pane-fieldset';
+    $collapsible_item['element']['#attributes']['class'][] = 'collapsible';
+    $collapsible_item['element']['#attributes']['class'][] = 'collapsed';
+    $toc_item_id = $pane_id;
+    $toc .= "<div class=\"tripal-panes-toc-list-item\"><a id=\"" . $pane->name . "\" class=\"tripal-panes-toc-list-item-link\" href=\"?pane=" . $pane->name . "\">" . $pane->label . "</a></div>";
+    $content .= theme('fieldset', $collapsible_item);
+  }
+}
+
+// TODO: need to add the bundle type
+$bundle_type = '';
+
+if ($has_base_pane_only) { ?>
+  <div id ="tripal-<?php print $bundle_type?>-contents-box"> <?php
+    // print the rendered content
+    print $content; ?>
+  </div> <?php
+}
+else { ?>
+  <table id ="tripal-<?php print $bundle_type?>-contents-table" class="tripal-panes-table">
+    <tr class="tripal-panes-table-tr">
+      <td nowrap class="tripal-panes-table-td tripal-panes-table-td-toc" align="left"><?php
+        print $toc; ?>
+      </td>
+      <td class="tripal-panes-table-td-data" align="left" width="100%"> <?php
+
+        // print the rendered content
+        print $content; ?>
+      </td>
+    </tr>
+  </table> <?php
+}
+
+/**
+ * A wrapper function for placing fields inside of a Drupal themed table.
+ *
+ * @param $fields
+ *   The list of fields present in the pane.
+ * @return
+ *   A string containing the HTMLified table.
+ */
+function tripal_panes_generic_render_table($fields) {
+  // If we have no fields in table layout
+  if (count($fields) == 0) {
+    return '';
+  }
+  // Create the rows for the table.
+  $header = array();
+  $rows = array();
+  foreach ($fields as $field) {
+    $rows[] = array(
+      array(
+        'data' => $field['#title'],
+        'header' => TRUE,
+        'width' => '20%',
+        'nowrap' => 'nowrap'
+      ),
+      $field[0]['#markup']
+    );
+  }
+  // Theme the table.
+  return theme_table(array(
+    'header' => $header,
+    'rows' => $rows,
+    'attributes' => array(
+      'id' => '',  // TODO: need to add an ID
+      'class' => 'tripal-data-horz-table'
+    ),
+    'sticky' => FALSE,
+    'caption' => '',
+    'colgroups' => array(),
+    'empty' => '',
+  ));
+}
+
+/**
+ * A wrapper function for default rending of fields.
+ *
+ * @param $fields
+ *   An array of fields to be rendered
+ * @return
+ *   A string containing the HTML of the rendered fields.
+ */
+function tripal_panes_generic_render_fields($fields) {
+  if (count($fields) == 0) {
+    return '';
+  }
+  $content = '';
+  foreach ($fields as $field) {
+    $content .= render($field);
+  }
+  return $content;
+}

+ 0 - 0
tripal_fields_layout/tripal_fields_layout.info → tripal_panes/tripal_panes.info


+ 19 - 19
tripal_fields_layout/tripal_fields_layout.install → tripal_panes/tripal_panes.install

@@ -3,13 +3,13 @@
 /**
  * Implements hook_schema().
  */
-function tripal_fields_layout_schema() {
+function tripal_panes_schema() {
   $schema = array();
 
-  $schema['tripal_panels'] = array(
-    'description' => 'The list of panels into which fields can be placed.',
+  $schema['tripal_panes'] = array(
+    'description' => 'The list of panes into which fields can be placed.',
     'fields' => array(
-      'panel_id' => array(
+      'pane_id' => array(
         'description' => 'The primary identifier for this table.',
         'type' => 'serial',
         'unsigned' => TRUE,
@@ -21,21 +21,21 @@ function tripal_fields_layout_schema() {
         'not null' => TRUE,
       ),
       'name' => array(
-        'description' => 'The computer readable name for the panel. This name must only have alphanumerical characters and underscores and must not begin with a number. ',
+        'description' => 'The computer readable name for the pane. This name must only have alphanumerical characters and underscores and must not begin with a number. ',
         'type' => 'varchar',
         'length' => 128,
         'not null' => TRUE,
         'default' => '',
       ),
       'label' => array(
-        'description' => 'A human readable name for panel. This name will be shown to users in the sidebar menu.',
+        'description' => 'A human readable name for pane. This name will be shown to users in the sidebar menu.',
         'type' => 'varchar',
         'length' => 128,
         'not null' => TRUE,
         'default' => '',
       ),
       'settings' => array(
-        'description' => 'Contains a serialized array tripal_fields_layoutof settings for the panel.',
+        'description' => 'Contains a serialized array tripal_panesof settings for the pane.',
         'type' => 'text',
         'not null' => FALSE,
       ),
@@ -49,7 +49,7 @@ function tripal_fields_layout_schema() {
       'bundle_id' => array('bundle_id'),
     ),
     'unique keys' => array(
-      'bundle_panel' => array('bundle_id', 'name'),
+      'bundle_pane' => array('bundle_id', 'name'),
     ),
     'foreign keys' => array(
       'tripal_bundle' => array(
@@ -59,18 +59,18 @@ function tripal_fields_layout_schema() {
         ),
       ),
     ),
-    'primary key' => array('panel_id'),
+    'primary key' => array('pane_id'),
   );
-  $schema['tripal_panel_fields'] = array(
-    'description' => 'The list of panels into which fields can be placed.',
+  $schema['tripal_pane_fields'] = array(
+    'description' => 'The list of panes into which fields can be placed.',
     'fields' => array(
-      'panel_field_id' => array(
+      'pane_field_id' => array(
         'description' => 'The primary identifier for this table.',
         'type' => 'serial',
         'unsigned' => TRUE,
         'not null' => TRUE,
       ),
-      'panel_id' => array(
+      'pane_id' => array(
         'description' => 'The primary identifier for this table.',
         'type' => 'int',
         'not null' => TRUE,
@@ -82,17 +82,17 @@ function tripal_fields_layout_schema() {
       ),
     ),
     'indexes' => array(
-      'panel_id' => array('panel_id'),
+      'pane_id' => array('pane_id'),
       'field_id' => array('field_id'),
     ),
     'unique keys' => array(
-      'panel_field' => array('panel_id', 'field_id'),
+      'pane_field' => array('pane_id', 'field_id'),
     ),
     'foreign keys' => array(
-      'tripal_panel' => array(
-        'table' => 'tripal_panel',
+      'tripal_pane' => array(
+        'table' => 'tripal_pane',
         'columns' => array(
-          'panel_id' => 'panel_id',
+          'pane_id' => 'pane_id',
         ),
       ),
       'field_config' => array(
@@ -102,7 +102,7 @@ function tripal_fields_layout_schema() {
         ),
       ),
     ),
-    'primary key' => array('panel_field_id'),
+    'primary key' => array('pane_field_id'),
   );
   
   return $schema;

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 260 - 260
tripal_panes/tripal_panes.module


Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio