Bläddra i källkod

Merge pull request #454 from tripal/449-tv3-content_type_table

Tripal Content Types are no alphabetical and list the ontology term
Bradford Condon 6 år sedan
förälder
incheckning
e8a8a91189

+ 49 - 0
tripal/includes/TripalBundleUIController.inc

@@ -56,6 +56,55 @@ class TripalBundleUIController extends EntityDefaultUIController {
 
     return $forms;
   }
+  
+  /**
+   * Renders the Bundle overview table
+   */
+  public function overviewTable($conditions = array()) {
+    $entities = entity_load($this->entityType, FALSE, $conditions);
+
+    // Sort the entities by label.
+    $sorted = [];    
+    foreach ($entities as $entity) {
+      $sorted[$entity->label] = $entity;
+    }
+    ksort($sorted, SORT_STRING|SORT_FLAG_CASE);
+    
+    $rows = array();
+    foreach ($sorted as $entity) {
+      // Get the term for this content type
+      $additional_cols = [$entity->term->name . ' (' . l($entity->accession, 'cv/lookup/' . $entity->term->vocab->vocabulary . '/' . $entity->term->accession) . ')'];
+      $rows[] = $this->overviewTableRow($conditions, 
+        entity_id($this->entityType, $entity), $entity,
+        $additional_cols);
+    }
+    // Assemble the right table header.
+    $header = array(t('Label'));
+    if (!empty($this->entityInfo['exportable'])) {
+      $header[] = t('Status');
+    }
+    $header[] = array(
+      'data' => t('Term'),
+    );
+    // Add operations with the right colspan.
+    $field_ui = !empty($this->entityInfo['bundle of']) && module_exists('field_ui');
+    $exportable = !empty($this->entityInfo['exportable']);
+    $colspan = 3;
+    $colspan = $field_ui ? $colspan + 2 : $colspan;
+    $colspan = $exportable ? $colspan + 1 : $colspan;
+    $header[] = array(
+      'data' => t('Operations'),
+      'colspan' => $colspan,
+    );
+    
+    $render = array(
+      '#theme' => 'table',
+      '#header' => $header,
+      '#rows' => $rows,
+      '#empty' => t('None.'),
+    );
+    return $render;
+  }
 
 }
 

+ 1 - 1
tripal/includes/TripalEntityUIController.inc

@@ -316,7 +316,7 @@ function tripal_view_entity($entity, $view_mode = 'full') {
        $query->propertyCondition('status', 0);
      }
    }
-   //$query->propertyOrderBy('created', 'DESC');
+   $query->propertyOrderBy('label', 'ASC');
 
    // Find out the total number of records and determine what page we're on, and
    // initialize the pager.