Browse Source

Changes to the BLASTDB node so that it displays it's data on the node page & saves the new more readable db type

Lacey Sanderson 10 years ago
parent
commit
b063c68c1f
5 changed files with 168 additions and 4 deletions
  1. 18 1
      blast_ui.install
  2. 10 1
      blast_ui.module
  3. 2 2
      includes/blast_ui.node.inc
  4. 28 0
      theme/blast_ui.theme.inc
  5. 110 0
      theme/node--blastdb.tpl.php

+ 18 - 1
blast_ui.install

@@ -50,7 +50,7 @@ function blast_ui_schema(){
       'dbtype' => array(
         'description' => t('Type of the blast database. Should be either n for nucleotide or p for protein.'),
         'type' => 'varchar',
-        'length' => 8,
+        'length' => 15,
         'not null' => true,
        ),
     ),
@@ -66,3 +66,20 @@ function blast_ui_schema(){
   return $schema;
 
 }
+
+/**
+ * Changing the length of the type field to allow it to be more readable.
+ */
+function blast_ui_update_7101() {
+
+  // Changing the length of the type field to allow it to be more readable.
+  db_change_field('blastdb', 'dbtype', 'dbtype',
+    array(
+        'description' => t('Type of the blast database. Should be either n for nucleotide or p for protein.'),
+        'type' => 'varchar',
+        'length' => 15,
+        'not null' => true,
+    )
+  );
+
+}

+ 10 - 1
blast_ui.module

@@ -28,6 +28,14 @@ require_once 'includes/blast_ui.admin.inc';
  */
 function blast_ui_menu() {
 
+  // BLAST DB Node
+  $items['node__blastdb'] = array(
+    'template' => 'node--blastdb',
+    'render element' => 'node',
+    'base hook' => 'node',
+    'path' => 'theme',
+  );
+
   // Single All-in-One BLAST submission form
   $items['blast'] = array(
     'title' => 'BLAST',
@@ -35,7 +43,8 @@ function blast_ui_menu() {
     'page arguments' => array('blast_ui_all_in_one_form'),
     'access arguments' => array('access content'),
     'file' => 'includes/blast_ui.form_single.inc',
-    'type' => MENU_SUGGESTED_ITEM
+    'type' => MENU_NORMAL_ITEM,
+    'expanded' => TRUE,
   );
 
   // Per Query Type BLAST submission forms

+ 2 - 2
includes/blast_ui.node.inc

@@ -85,8 +85,8 @@ function blastdb_form($node, &$form_state) {
     '#type' => 'radios',
     '#title' => t('Type of the blast database'),
     '#options' => array(
-      'n' => t('Nucleotide'),
-      'p' => t('Protein'),
+      'nucleotide' => t('Nucleotide'),
+      'protein' => t('Protein'),
     ),
     '#required' => TRUE,
     '#default_value' => isset($node->db_dbtype) ? $node->db_dbtype : 'n',

+ 28 - 0
theme/blast_ui.theme.inc

@@ -29,3 +29,31 @@ function blast_ui_preprocess_show_blast_report(&$vars) {
   $vars['html_filename'] = variable_get('file_public_path', conf_path() . '/files') . '/' . $job_args['output_filename'] . '.blast.html';
 
 }
+
+/**
+ * Implements hook_theme_registery_alter().
+ */
+function blast_ui_theme_registry_alter(&$theme_registry) {
+  $theme_registry_copy = $theme_registry;
+  $module_path = drupal_get_path('module', 'blast_ui') . '/theme';
+  _theme_process_registry($theme_registry_copy, 'phptemplate', 'theme_engine', 'my_custom_theme', $module_path);
+  $theme_registry += array_diff_key($theme_registry_copy, $theme_registry);
+  // A list of templates the module will provide templates for
+  $hooks = array('page');
+  foreach ($hooks as $hook) {
+    // Add the key 'theme paths' if it doesn't exist in this theme's registry
+    if (!isset($theme_registry[$hook]['theme paths'])) {
+      $theme_registry[$hook]['theme paths'] = array();
+    }
+    // Shift this module's directory to the top of the theme path list
+    if (is_array($theme_registry[$hook]['theme paths'])) {
+      $first_element = array_shift($theme_registry[$hook]['theme paths']);
+      if ($first_element) {
+        array_unshift($theme_registry[$hook]['theme paths'], $first_element, $module_path);
+      }
+      else {
+        array_unshift($theme_registry[$hook]['theme paths'], $module_path);
+      }
+    }
+  }
+}

+ 110 - 0
theme/node--blastdb.tpl.php

@@ -0,0 +1,110 @@
+<?php
+
+/**
+ * @file
+ * Bartik's theme implementation to display a node.
+ *
+ * Available variables:
+ * - $title: the (sanitized) title of the node.
+ * - $content: An array of node items. Use render($content) to print them all,
+ *   or print a subset such as render($content['field_example']). Use
+ *   hide($content['field_example']) to temporarily suppress the printing of a
+ *   given element.
+ * - $user_picture: The node author's picture from user-picture.tpl.php.
+ * - $date: Formatted creation date. Preprocess functions can reformat it by
+ *   calling format_date() with the desired parameters on the $created variable.
+ * - $name: Themed username of node author output from theme_username().
+ * - $node_url: Direct URL of the current node.
+ * - $display_submitted: Whether submission information should be displayed.
+ * - $submitted: Submission information created from $name and $date during
+ *   template_preprocess_node().
+ * - $classes: String of classes that can be used to style contextually through
+ *   CSS. It can be manipulated through the variable $classes_array from
+ *   preprocess functions. The default values can be one or more of the
+ *   following:
+ *   - node: The current template type; for example, "theming hook".
+ *   - node-[type]: The current node type. For example, if the node is a
+ *     "Blog entry" it would result in "node-blog". Note that the machine
+ *     name will often be in a short form of the human readable label.
+ *   - node-teaser: Nodes in teaser form.
+ *   - node-preview: Nodes in preview mode.
+ *   The following are controlled through the node publishing options.
+ *   - node-promoted: Nodes promoted to the front page.
+ *   - node-sticky: Nodes ordered above other non-sticky nodes in teaser
+ *     listings.
+ *   - node-unpublished: Unpublished nodes visible only to administrators.
+ * - $title_prefix (array): An array containing additional output populated by
+ *   modules, intended to be displayed in front of the main title tag that
+ *   appears in the template.
+ * - $title_suffix (array): An array containing additional output populated by
+ *   modules, intended to be displayed after the main title tag that appears in
+ *   the template.
+ *
+ * Other variables:
+ * - $node: Full node object. Contains data that may not be safe.
+ * - $type: Node type; for example, story, page, blog, etc.
+ * - $comment_count: Number of comments attached to the node.
+ * - $uid: User ID of the node author.
+ * - $created: Time the node was published formatted in Unix timestamp.
+ * - $classes_array: Array of html class attribute values. It is flattened
+ *   into a string within the variable $classes.
+ * - $zebra: Outputs either "even" or "odd". Useful for zebra striping in
+ *   teaser listings.
+ * - $id: Position of the node. Increments each time it's output.
+ *
+ * Node status variables:
+ * - $view_mode: View mode; for example, "full", "teaser".
+ * - $teaser: Flag for the teaser state (shortcut for $view_mode == 'teaser').
+ * - $page: Flag for the full page state.
+ * - $promote: Flag for front page promotion state.
+ * - $sticky: Flags for sticky post setting.
+ * - $status: Flag for published status.
+ * - $comment: State of comment settings for the node.
+ * - $readmore: Flags true if the teaser content of the node cannot hold the
+ *   main body content.
+ * - $is_front: Flags true when presented in the front page.
+ * - $logged_in: Flags true when the current user is a logged-in member.
+ * - $is_admin: Flags true when the current user is an administrator.
+ *
+ * Field variables: for each field instance attached to the node a corresponding
+ * variable is defined; for example, $node->body becomes $body. When needing to
+ * access a field's raw values, developers/themers are strongly encouraged to
+ * use these variables. Otherwise they will have to explicitly specify the
+ * desired field language; for example, $node->body['en'], thus overriding any
+ * language negotiation rule that was previously applied.
+ *
+ * @see template_preprocess()
+ * @see template_preprocess_node()
+ * @see template_process()
+ */
+?>
+<div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
+
+  <?php print render($title_prefix); ?>
+  <?php if (!$page): ?>
+    <h2<?php print $title_attributes; ?>>
+      <a href="<?php print $node_url; ?>"><?php print $title; ?></a>
+    </h2>
+  <?php endif; ?>
+  <?php print render($title_suffix); ?>
+
+  <div class="content clearfix"<?php print $content_attributes; ?>>
+    <?php
+      // We hide the comments and links now so that we can render them later.
+      hide($content['comments']);
+      hide($content['links']);
+    ?>
+
+    <table>
+      <tr><th>Human-Readable Name</th><td><?php print $node->db_name; ?></td></tr>
+      <tr><th>Database Path</th><td><?php print $node->db_path; ?></td></tr>
+      <tr><th>Database Type</th><td><?php print $node->db_dbtype; ?></td></tr>
+    </table>
+
+    <?php
+      // Add in any remaining content
+      print render($content);
+    ?>
+  </div>
+
+</div>