Browse Source

move theme files for tripal_unigene_search

ccheng 13 years ago
parent
commit
e852f2d0db

+ 40 - 0
tripal_search_unigene/theme/css/tripal_search_unigene.css

@@ -0,0 +1,40 @@
+.tripal_search_unigene-views-exposed-form {
+	margin: 10px;
+	padding:10px;
+	background: #FFFFFF;
+	border: 1px solid #CCCCCC;
+}
+
+.tripal-search-unigene-exposed-widget {
+	clear:both;
+	padding: 5px;
+}
+
+.tripal-search-unigene-form-labels {
+	float:left;
+}
+
+.tripal_search_unigene-views-operator {
+	float:left;
+	clear:none;
+	margin-left: 5px;
+}
+
+.tripal_search_unigene-views-widget {
+	float:left;
+	clear:none;
+	margin-left: 5px;
+}
+
+.tripal_search_unigene-table {
+	margin-left: 10px;
+}
+ 
+ .tripal-search-unigene-exposed-widgets-fields legend{
+   color:green;
+ }
+ 
+ #tripal_search_unigene-result-top:hover {
+   text-decoration: none;
+   color:#292929;
+ }

+ 20 - 0
tripal_search_unigene/theme/js/tripal_search_unigene.js

@@ -0,0 +1,20 @@
+//
+// Copyright 2009 Clemson University
+//
+
+if (Drupal.jsEnabled) {
+
+   $(document).ready(function(){
+
+		// Move to the result top
+		var result_top = document.getElementById('tripal_search_unigene-result-top');
+		if (result_top) {	
+			 var target_offset = $("#tripal_search_unigene-result-top").offset();
+			 var target_top = target_offset.top;
+			 if (navigator.userAgent.indexOf('MSIE 8.0') !=-1) 	{
+				target_top -= 60;	
+			}
+			$('html, body').animate({scrollTop: target_top}, 1000);
+		}
+   });
+}

+ 195 - 0
tripal_search_unigene/theme/views-exposed-form--unigene_search.tpl.php

@@ -0,0 +1,195 @@
+<?php
+// $Id: views-exposed-form.tpl.php,v 1.4.4.1 2009/11/18 20:37:58 merlinofchaos Exp $
+/**
+ * @file views-exposed-form.tpl.php
+ *
+ * This template handles the layout of the views exposed filter form.
+ *
+ * Variables available:
+ * - $widgets: An array of exposed form widgets. Each widget contains:
+ * - $widget->label: The visible label to print. May be optional.
+ * - $widget->operator: The operator for the widget. May be optional.
+ * - $widget->widget: The widget itself.
+ * - $button: The submit button for the form.
+ *
+ * @ingroup views_templates
+ */
+?>
+<?php if (!empty($q)): ?>
+  <?php
+    // This ensures that, if clean URLs are off, the 'q' is added first so that
+    // it shows up first in the URL.
+    print $q;
+
+  ?>
+<?php endif;     //dsm($widgets);?>
+<div class="tripal_search_unigene-views-exposed-form views-exposed-form">
+  <div class="views-exposed-widgets clear-block">
+    
+    <?php 
+    	$feature_type_id =  $widgets['filter-feature_type']; 
+    	$orgnism_common_name =  $widgets['filter-organism_common_name'];
+    	$analysis_name =  $widgets['filter-unigene'];
+    	$feature_name =  $widgets['filter-feature_name'];
+    	$feature_seqlen =  $widgets['filter-feature_seqlen'];
+    	$cvterm_name =  $widgets['filter-go_term'];
+    	$blast_value =  $widgets['filter-blast_value'];
+    	$interpro_value =  $widgets['filter-interpro_value'];
+    	$kegg_value =  $widgets['filter-kegg_value'];
+    ?>
+    
+    <div id="tripal-search-unigene-exposed-widgets">
+    <div> Search ESTs or unigene contigs by name, assembly, sequence type, length, or their putative function. <br><br></div>
+			<fieldset class="tripal-search-unigene-exposed-widgets-fields">
+				<legend>Search by Name</legend>
+				<div class="tripal-search-unigene-exposed-widget">
+					<div class="tripal-search-unigene-form-labels">
+						<label for="<?php print $orgnism_common_name->id; ?>"><?php print $orgnism_common_name->label; ?>
+						</label>
+					</div>
+					<?php if (!empty($orgnism_common_name->operator)): ?>
+					<div class="tripal_search_unigene-views-operator">
+					<?php print $orgnism_common_name->operator; ?>
+					</div>
+					<?php endif; ?>
+					<div class="tripal_search_unigene-views-widget">
+					<?php print $orgnism_common_name->widget; ?>
+					</div>
+				</div>
+				<div class="tripal-search-unigene-exposed-widget">
+					<div class="tripal-search-unigene-form-labels">
+						<label for="<?php print $feature_name->id; ?>"><?php print $feature_name->label; ?>
+						</label>
+					</div>
+					<?php if (!empty($feature_name->operator)): ?>
+					<div class="tripal_search_unigene-views-operator">
+					<?php print $feature_name->operator; ?>
+					</div>
+					<?php endif; ?>
+					<div class="tripal_search_unigene-views-widget">
+						<?php print $feature_name->widget; ?>
+					</div>
+				</div>
+			</fieldset>
+
+			<fieldset class="tripal-search-unigene-exposed-widgets-fields">
+				<legend>Search by Assembly</legend>
+				<div class="tripal-search-unigene-exposed-widget">
+					<div class="tripal-search-unigene-form-labels">
+						<label for="<?php print $feature_type_id->id; ?>"><?php print $feature_type_id->label; ?>
+						</label>
+					</div>
+					<?php if (!empty($feature_type_id->operator)): ?>
+					<div class="tripal_search_unigene-views-operator">
+					<?php print $feature_type_id->operator; ?>
+					</div>
+					<?php endif; ?>
+					<div class="tripal_search_unigene-views-widget">
+					<?php print $feature_type_id->widget; ?>
+					</div>
+				</div>
+				<div class="tripal-search-unigene-exposed-widget">
+					<div class="tripal-search-unigene-form-labels">
+						<label for="<?php print $analysis_name->id; ?>"><?php print $analysis_name->label; ?>
+						</label>
+					</div>
+					<?php if (!empty($analysis_name->operator)): ?>
+					<div class="tripal_search_unigene-views-operator">
+					<?php print $analysis_name->operator; ?>
+					</div>
+					<?php endif; ?>
+					<div class="tripal_search_unigene-views-widget">
+						<?php print $analysis_name->widget; ?>
+					</div>
+				</div>
+			</fieldset>
+
+			<fieldset class="tripal-search-unigene-exposed-widgets-fields">
+				<legend>Search by Sequence</legend>
+				<div class="tripal-search-unigene-exposed-widget">
+					<div class="tripal-search-unigene-form-labels">
+						<label for="<?php print $feature_seqlen->id; ?>"><?php print $feature_seqlen->label; ?>
+						</label>
+					</div>
+					<?php if (!empty($feature_seqlen->operator)): ?>
+					<div class="tripal_search_unigene-views-operator">
+					<?php print $feature_seqlen->operator; ?>
+					</div>
+					<?php endif; ?>
+					<div class="tripal_search_unigene-views-widget">
+					<?php print $feature_seqlen->widget; ?>
+					</div>
+				</div>
+			</fieldset>
+
+			<fieldset class="tripal-search-unigene-exposed-widgets-fields">
+				<legend>Search by Putative Function</legend>
+				<div class="tripal-search-unigene-exposed-widget">
+					<div class="tripal-search-unigene-form-labels">
+						<label for="<?php print $cvterm_name->id; ?>"><?php print $cvterm_name->label; ?>
+						</label>
+					</div>
+					<?php if (!empty($cvterm_name->operator)): ?>
+					<div class="tripal_search_unigene-views-operator">
+					<?php print $cvterm_name->operator; ?>
+					</div>
+					<?php endif; ?>
+					<div class="tripal_search_unigene-views-widget">
+					<?php print $cvterm_name->widget; ?>
+					</div>
+				</div>
+
+				<div class="tripal-search-unigene-exposed-widget">
+					<div class="tripal-search-unigene-form-labels">
+						<label for="<?php print $blast_value->id; ?>"><?php print $blast_value->label; ?>
+						</label>
+					</div>
+					<?php if (!empty($blast_value->operator)): ?>
+					<div class="tripal_search_unigene-views-operator">
+					<?php print $blast_value->operator; ?>
+					</div>
+					<?php endif; ?>
+					<div class="tripal_search_unigene-views-widget">
+						<?php print $blast_value->widget; ?>
+					</div>
+				</div>
+				
+				<div class="tripal-search-unigene-exposed-widget">
+					<div class="tripal-search-unigene-form-labels">
+						<label for="<?php print $kegg_value->id; ?>"><?php print $kegg_value->label; ?>
+						</label>
+					</div>
+					<?php if (!empty($kegg_value->operator)): ?>
+					<div class="tripal_search_unigene-views-operator">
+					<?php print $kegg_value->operator; ?>
+					</div>
+					<?php endif; ?>
+					<div class="tripal_search_unigene-views-widget">
+						<?php print $kegg_value->widget; ?>
+					</div>
+				</div>
+				
+				<div class="tripal-search-unigene-exposed-widget">
+					<div class="tripal-search-unigene-form-labels">
+						<label for="<?php print $interpro_value->id; ?>"><?php print $interpro_value->label; ?>
+						</label>
+					</div>
+					<?php if (!empty($interpro_value->operator)): ?>
+					<div class="tripal_search_unigene-views-operator">
+					<?php print $interpro_value->operator; ?>
+					</div>
+					<?php endif; ?>
+					<div class="tripal_search_unigene-views-widget">
+						<?php print $interpro_value->widget; ?>
+					</div>
+				</div>
+			</fieldset>
+
+		</div>
+    
+    <div class="tripal-search-unigene-exposed-widget">
+    	<input TYPE="Button" value="Reset" onClick="window.location = '<?php global $base_url; print "$base_url/est_search"?>';">
+      <?php $button = preg_replace("'Apply'", "Search", $button); print $button ?>
+    </div>
+  </div>
+</div>

+ 221 - 0
tripal_search_unigene/theme/views-view-table--unigene_search.tpl.php

@@ -0,0 +1,221 @@
+<?php
+// $Id: views-view-table.tpl.php,v 1.8 2009/01/28 00:43:43 merlinofchaos Exp $
+/**
+ * @file views-view-table.tpl.php
+ * Template to display a view as a table.
+ *
+ * - $title : The title of this group of rows.  May be empty.
+ * - $header: An array of header labels keyed by field id.
+ * - $fields: An array of CSS IDs to use for each field id.
+ * - $class: A class or classes to apply to the table, based on settings.
+ * - $row_classes: An array of classes to apply to each row, indexed by row
+ *   number. This matches the index in $rows.
+ * - $rows: An array of row items. Each row is an array of content.
+ *   $rows are keyed by row number, fields within rows are keyed by field ID.
+ * @ingroup views_templates
+ */
+?>
+
+<?php
+$total = $view->total_rows;
+$query = $view->build_info['query'];
+$pager = $view->pager;
+$limit = $pager ['items_per_page'];
+$offset = $pager ['current_page'] * $limit;
+$args = $view->build_info['query_args'];
+global $base_url;
+?>
+
+<a id="tripal_search_unigene-result-top" name="search_results">
+&nbsp;&nbsp;&nbsp;Your search produced <b><?php print $total ?></b> results<br>
+<i>&nbsp;&nbsp;&nbsp;Note: To get complete annotation for a sequence, click on the sequence name.</i>
+</a>
+<table class="tripal_search_unigene-table <?php print $class; ?> tripal-table-horz">
+  <?php if (!empty($title)) : ?>
+    <caption><?php print $title; ?></caption>
+  <?php endif; ?>
+  <thead>
+    <tr class="tripal_search_unigene-table-header tripal-table-header">
+      <?php foreach ($header as $field => $label): ?>
+        <th class="views-field views-field-<?php print $fields[$field]; ?>">
+          <?php print $label; ?>
+        </th>
+      <?php endforeach; ?>
+    </tr>
+  </thead>
+  <tbody>
+    <?php foreach ($rows as $count => $row): 
+    			$rowclass = "";
+    			if ($count % 2 != 0) {
+    				$rowclass = "tripal_search_unigene-table-even-row tripal-table-even-row";
+    			} else {
+    				$rowclass = "tripal_search_unigene-table-odd-row tripal-table-odd-row";
+    			}
+    ?>
+      <tr class="<?php print $rowclass?> <?php print implode(' ', $row_classes[$count]); ?>">
+        <?php foreach ($row as $field => $content): ?>
+          <td class="views-field views-field-<?php print $fields[$field]; ?>">
+            <?php print $content; ?>
+          </td>
+        <?php endforeach; ?>
+      </tr>
+    <?php endforeach; ?>
+  </tbody>
+</table>
+
+<?php /* if ($count != 0) {
+	// Generate Excel files
+	// set parameters for excel file
+	$param_excel= array();
+	global $user;
+	$dir = file_directory_path().'/tripal/tripal_search_unigene/'.session_id();
+	if (!file_exists($dir)) {
+		mkdir ($dir, 0777);
+	}
+	$file =session_id().'/unigene_search_result.xls';
+	
+	$param_excel['sheet_name']		= 'unigene_search';
+	$path = "/tripal/tripal_search_unigene/$file";
+	$param_excel['filename']		= file_directory_path().$path;
+	$path_url =url("sites/default/files/tripal/tripal_search_unigene/$file");
+	# set SQL
+	$sql = "$query LIMIT $limit OFFSET $offset";
+	# create heades
+	$col_chr = 'A';
+	$headers = array();
+	$headers[$col_chr++] = array('align' => 'left', 'width' => 20, 'type' => 'hyperlink', 'field' => 'unigene_for_search_feature_name', 'heading' => 'Feature name');
+	$headers[$col_chr++] = array('align' => 'left', 'width' => 10, 'type' => 'text', 'field' => 'unigene_for_search_organism_common_name', 'heading' => 'Organism');
+	$headers[$col_chr++] = array('align' => 'left', 'width' => 10, 'type' => 'text', 'field' => 'unigene_for_search_feature_seqlen', 'heading' => 'Length');
+	$headers[$col_chr++] = array('align' => 'left', 'width' => 10, 'type' => 'text', 'field' => 'unigene_for_search_feature_type', 'heading' => 'Type');
+	$headers[$col_chr++] = array('align' => 'left', 'width' => 20, 'type' => 'text', 'field' => 'unigene_for_search_go_term', 'heading' => 'GO term');
+	$headers[$col_chr++] = array('align' => 'left', 'width' => 20, 'type' => 'text', 'field' => 'unigene_for_search_blast_value', 'heading' => 'Blast');
+	$headers[$col_chr++] = array('align' => 'left', 'width' => 20, 'type' => 'text', 'field' => 'unigene_for_search_kegg_value', 'heading' => 'KEGG');
+	$headers[$col_chr++] = array('align' => 'left', 'width' => 20, 'type' => 'text', 'field' => 'unigene_for_search_interpro_value', 'heading' => 'Interpro');
+	
+	# populate data
+	$result = chado_query($sql, $args);
+	$data = array();
+	while ($row = db_fetch_array($result)) {
+		$data[] = array ('unigene_for_search_feature_name' => $row['unigene_for_search_feature_name'],
+									 'hyperlink_unigene_for_search_feature_name' => "$base_url/ID".$row['unigene_for_search_feature_id'],
+									 'unigene_for_search_organism_common_name' => $row['unigene_for_search_organism_common_name'],
+									 'unigene_for_search_feature_seqlen' => $row['unigene_for_search_feature_seqlen'],
+									 'unigene_for_search_feature_type' => $row['unigene_for_search_feature_type'],
+									 'unigene_for_search_go_term' => $row['unigene_for_search_go_term'],
+									 'unigene_for_search_blast_value' => $row['unigene_for_search_blast_value'],
+									 'unigene_for_search_kegg_value' => $row['unigene_for_search_kegg_value'],
+									 'unigene_for_search_interpro_value' => $row['unigene_for_search_interpro_value']
+									 );
+	}
+	# add headers and data
+	$param_excel['contents']['sheet']['headers']= $headers;
+	$param_excel['contents']['sheet']['data']= $data;
+	# generate excel
+	ml_generate_excel($param_excel);
+	print "&nbsp;&nbsp;&nbsp;<a href=\"$path_url\">Download as Excel file</a>";
+	
+}
+*/?>
+
+<?php 
+# ----------------------------------------- #
+# [UD] ml_generate_excel
+# ----------------------------------------- #
+function ml_generate_excel ($param_excel) {
+	# get and update parameters
+	$writer		= ($param_excel['version'] == '2007') ? 'Excel2007' : 'Excel5';
+	$link_clr	= (empty($param_excel['link_clr'])) ? '0000FF' : $param_excel['link_clr'];
+	$filename	= $param_excel['filename'];
+	if (!preg_match("/(xls|xlsx)$/", $filename)) {
+		$filename = ($param_excel['version'] == '2007') ? $filename.'.xlsx' : $filename.'.xls';
+	}
+	/*********************************************/
+	# create an excel file
+	/*********************************************/
+	# create new PHPExcel object
+	$excel = new PHPExcel();
+	# Set properties
+	$excel->getProperties()->setCreator("Main Lab");
+	$excel->getProperties()->setLastModifiedBy("Main Lab");
+	$excel->getProperties()->setTitle("Office 2007 XLSX Document");
+	$excel->getProperties()->setSubject("");
+	$excel->getProperties()->setKeywords("");
+	$excel->getProperties()->setCategory("");
+	$excel->getProperties()->setDescription("");
+	# set default styles
+	$excel->getDefaultStyle()->getFont()->setName('Times New Roman');
+	$excel->getDefaultStyle()->getFont()->setSize(11);
+	# create worksheets
+	$sheet_no= 0;
+	foreach ($param_excel['contents'] as $sheet_name => $sheet) {
+		if ($sheet_no != 0) {
+			# add a new worksheet
+			$excel->createSheet();
+		}	
+		# set active sheet
+		$excel->setActiveSheetIndex($sheet_no);		
+		# get current worksheet
+		$worksheet = $excel->getActiveSheet();	
+		# set title for this sheet
+		$worksheet->setTitle($sheet_name);
+		# get headers
+		$headers= $param_excel['contents'][$sheet_name]['headers'];
+		# set style and headings for headers
+		foreach ($headers as $col_chr => $prop) {
+			# set alignment for column
+			$align= PHPExcel_Style_Alignment::HORIZONTAL_LEFT;
+			if ($prop['align'] == 'right') {
+				$align= PHPExcel_Style_Alignment::HORIZONTAL_RIGHT;
+			}
+			else if ($prop['align'] == 'center') {
+				$align= PHPExcel_Style_Alignment::HORIZONTAL_CENTER;
+			}
+			$worksheet->getStyle($col_chr.'1')->getAlignment()->setHorizontal($align);		
+			# set width
+			$worksheet->getColumnDimension($col_chr)->setWidth($prop['width']);
+			$worksheet->getStyle($col_chr.'1')->getFont()->setBold(true);
+			$worksheet->getStyle($col_chr.'1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
+			$worksheet->getStyle($col_chr.'1')->getFill()->getStartColor()->setARGB('FFCDCDCD');
+			$worksheet->setCellValue($col_chr.'1', $prop['heading']);
+		}		
+		# add data to current worksheet
+		foreach ($param_excel['contents'][$sheet_name]['data'] as $idx => $row) {
+			foreach ($headers as $col_chr => $prop) {
+				$loc= $col_chr.($idx+2);
+				# set alignment for cell
+				$align= PHPExcel_Style_Alignment::HORIZONTAL_LEFT;
+				if ($prop['align'] == 'right') {
+					$align= PHPExcel_Style_Alignment::HORIZONTAL_RIGHT;
+				}
+				else if ($prop['align'] == 'center') {
+					$align= PHPExcel_Style_Alignment::HORIZONTAL_CENTER;
+				}
+				$worksheet->getStyle($loc)->getAlignment()->setHorizontal($align);
+				
+				if (!empty($row[$prop['field']])) {
+					# set cell value
+					if ($prop['type'] == 'text') {
+						$worksheet->setCellValue($loc, $row[$prop['field']]);
+					}
+					else if ($prop['type'] == 'hyperlink') {
+						$worksheet->setCellValue($loc, $row[$prop['field']]);
+						if ($row['hyperlink_'.$prop['field']]) {
+							# add underline
+							$worksheet->getStyle($loc)->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE);
+							# set link color
+							$worksheet->getStyle($loc)->getFont()->getColor()->setRGB($link_clr);		
+							# set URL
+							$worksheet->getCell($loc)->getHyperlink()->setUrl($row['hyperlink_'.$prop['field']]);
+						}
+					}
+				}
+			}
+		}
+		$sheet_no++;
+	}	
+		# create excel file
+ 		$excel->setActiveSheetIndex(0);
+ 		$objWriter = PHPExcel_IOFactory::createWriter($excel, $writer);
+ 		$objWriter->save($filename);
+}
+?>