Browse Source

refactoring of tripal_views_search to tripal_views_setup"

alexgl 13 years ago
parent
commit
5f07c79d7c

+ 0 - 89
base/tripal_views_search/includes/tripal_views_search.admin.inc

@@ -1,89 +0,0 @@
-<?php 
-
-function tripal_views_search_admin(){
-	$add_url = url('admin/tripal/tripal_views_search/new');
-	$output = "<div id='add-new-search'><a href=\"$add_url\">Add New Search</a><div>";
-	$output .= drupal_get_form(tripal_views_search_admin_form);
-	
-	dsm($output, 'tvs admin output');
-	return $output;
-}
-
-
-function tripal_views_search_admin_form(){
-	
-	$query_resulst = db_query('SELECT * FROM public.tripal_views_search;');
-	
-	$form = array();
-	$int_i = 0; 
-	while($record = db_fetch_object($query_resulst)){
-		dpm($record, 'record' . (string)$int_i);
-		
-		$item_name = 'query-record-' . (string)$int_i; 
-		$form[$item_name] = array(
-			'#type' => '#checkbox',
-			'#title' => t('Search '),
-			'#description' => t('')
-		);
-		
-	 	$int_i++;	
-	}
-	
-
-	return system_settings_form($form);
-}
-
-function tripal_views_search_new_search_form(){
-	$form = array();
-		$form['tripal_views_search_config_mview'] = array(
-		'#type' => 'textfield',
-		'#title' => t('Materialized View'),
-		'#description' => t('Select which materialized view needs to be used for this search'),
-		'#required' => TRUE,
-	);
-	
-	/*
-	$form['tripal_views_search_config_mview'] = array(
-		'#type' => 'select',
-		'#title' => t('Materialized View'),
-		'#options' => tripal_views_search_mview_list(),
-		'#description' => t('Select which materialized view needs to be used for this search'),
-		'#required' => TRUE,
-	);
-
-	$form['tripal_views_search_config_btable'] = array(
-		'#type' => 'select',
-		'#title' => t('Chado base table'),
-		'#options' => tripal_views_search_btable_list(),
-		'#description' => t('Select which chado table needs to be used for this earch'),
-		'#required' => TRUE,
-	);
-
-	dpm($form, 'tripal_views_search_admin form');
-	 */
-	
-	
-	return $form;
-}
-
-function tripal_views_search_mview_list(){
-	//must return an array of strings ie:
-	$options = array(
-		'dummyoption' => t('dummyoptiontext'),
-	);
-
-	return $options;
-}
-
-function tripal_views_search_btable_list(){
-	//must return an array of strings ie:
-	$options = array(
-		'dummyoption2' => t('dummyoptiontext2'),
-	);
-
-	return $options;
-}
-
-
-
-

+ 0 - 7
base/tripal_views_search/tripal_views_search.info

@@ -1,7 +0,0 @@
-name = Tripal Views Search
-description = Tripal suite module to perform searches as views, instead of the built in drupal search
-core = 6.x
-package = Tripal
-
-dependencies[] = schema
-

+ 97 - 0
base/tripal_views_setup/includes/tripal_views_setup.admin.inc

@@ -0,0 +1,97 @@
+<?php 
+
+function tripal_views_setup_admin(){
+	// $add_url = url('admin/tripal/tripal_views_setup/new');
+	// $output = "<div id='add-new-search'><a href=\"$add_url\">Add New Search</a><div>";
+	// $output .= drupal_get_form('tripal_views_setup_admin_form');
+// 	
+	
+// 	
+	
+
+	return $rows;
+}
+
+
+function tripal_views_setup_admin_form(){
+	
+	$query_resulst = db_query('SELECT * FROM public.tripal_views_setup;');
+	
+	$form = array();
+	$int_i = 0;
+	
+	$records = array();
+	while($record = db_fetch_object($query_resulst)){
+		dpm($record, 'record' . (string)$int_i);
+		
+		$item_name = 'tripal_views_setup_config_query_record_' . (string)$int_i;
+		
+		$form[$item_name] = array(
+			'#type' => 'checkbox',
+			'#title' => t($record->name),
+			'#description' => t('Search of mview ' . $record->mview_id . ' and ' . $record->base_table_name),
+			'#required' => TRUE,
+		);
+		
+	 	$int_i++;	
+	}
+	
+	dpm($form, 'admin_form');
+	return $form;
+	//return system_settings_form($form);
+}
+
+function tripal_views_setup_new_search_form(){
+	$form = array();
+		$form['tripal_views_setup_config_mview'] = array(
+		'#type' => 'textfield',
+		'#title' => t('Materialized View'),
+		'#description' => t('Select which materialized view needs to be used for this search'),
+		'#required' => TRUE,
+	);
+	
+	/*
+	$form['tripal_views_setup_config_mview'] = array(
+		'#type' => 'select',
+		'#title' => t('Materialized View'),
+		'#options' => tripal_views_setup_mview_list(),
+		'#description' => t('Select which materialized view needs to be used for this search'),
+		'#required' => TRUE,
+	);
+
+	$form['tripal_views_setup_config_btable'] = array(
+		'#type' => 'select',
+		'#title' => t('Chado base table'),
+		'#options' => tripal_views_setup_btable_list(),
+		'#description' => t('Select which chado table needs to be used for this earch'),
+		'#required' => TRUE,
+	);
+
+	dpm($form, 'tripal_views_setup_admin form');
+	 */
+	
+	
+	return $form;
+}
+
+function tripal_views_setup_mview_list(){
+	//must return an array of strings ie:
+	$options = array(
+		'dummyoption' => t('dummyoptiontext'),
+	);
+
+	return $options;
+}
+
+function tripal_views_setup_btable_list(){
+	//must return an array of strings ie:
+	$options = array(
+		'dummyoption2' => t('dummyoptiontext2'),
+	);
+
+	return $options;
+}
+
+
+
+

+ 7 - 0
base/tripal_views_setup/tripal_views_setup.info

@@ -0,0 +1,7 @@
+name = Tripal Views Setup 
+description = Tripal suite module to perform setup as views, instead of the built in drupal setup 
+core = 6.x
+package = Tripal
+
+dependencies[] = schema
+

+ 23 - 23
base/tripal_views_search/tripal_views_search.install → base/tripal_views_setup/tripal_views_setup.install

@@ -1,36 +1,36 @@
 <?php
-function tripal_views_search_schema(){
+function tripal_views_setup_schema(){
 	$schema = array();
-	$schema['tripal_views_search'] = array(
-		'description' => 'contains the searches, their materialized view id and base table name that was used.',
+	$schema['tripal_views_setup'] = array(
+		'description' => 'contains the setupes, their materialized view id and base table name that was used.',
 		'fields' => array(
-			'tripal_search_id' => array(
-				'description' => 'the id of the search',
+			'setup_id' => array(
+				'description' => 'the id of the setup',
 				'type' => 'serial',
 				'unsigned' => TRUE,
 				'not null' => TRUE,
 			),
 			'mview_id' => array(
-				'description' => 'the materialized view used for this search',
+				'description' => 'the materialized view used for this setup',
 				'type' => 'int',
 				'unsigned' => TRUE,
 			),
 			'base_table_name' => array(
-				'description' => 'the base table name to be used when using this search',
+				'description' => 'the base table name to be used when using this setup',
 				'type' => 'varchar',
 				'length' => 255,
 				'not null' => TRUE,
 				'default' => '',
 			),
 			'status' => array(
-				'description' => 'Weather this search will be used: 0 = inactive, 1 = active.',
+				'description' => 'Weather this setup will be used: 0 = inactive, 1 = active.',
 				'type' => 'int',
 				'unsigned' => TRUE,
 				'not null' => TRUE,
 				'default' => '0',
 			),
 			'name' => array(
-				'description' => 'Human readable name of this search',
+				'description' => 'Human readable name of this setup',
 				'type' => 'varchar',
 				'length' => 255,
 				'not null' => TRUE,
@@ -38,15 +38,15 @@ function tripal_views_search_schema(){
 			),
 		),
 		'unique_keys' => array(
-			'tripal_search_id' => array('tripal_search_id'),
+			'setup_id' => array('setup_id'),
 		),
-		'primary key' => array('tripal_search_id'),
+		'primary key' => array('setup_id'),
 	);
 	$schema['tripal_mviews_join'] = array(
-		'description' => 'which materialzed views and chado tables to join in a given search',
+		'description' => 'which materialzed views and chado tables to join in a given setup',
 		'fields' => array(
-			'tripal_search_id' => array(
-				'description' => 'tripal search id from tripal_views_search table',
+			'setup_id' => array(
+				'description' => 'tripal setup id from tripal_views_setup table',
 				'type' => 'serial',
 				'unsigned' => TRUE,
 				'not null'=> TRUE,
@@ -67,15 +67,15 @@ function tripal_views_search_schema(){
 			),
 		),
 		'unique_keys' => array(
-			'tripal_search_id' => array('tripal_search_id'),
+			'setup_id' => array('setup_id'),
 		),
-		'primary key' => array('tripal_search_id'),
+		'primary key' => array('setup_id'),
 	);
 	$schema['tripal_views_handlers'] = array(
 		'description' => 'in formation for views: column and views handler name',
 		'fields' => array(
-			'tripal_search_id' => array(
-				'description' => 'which search this is used by from tripal_views_search table',
+			'setup_id' => array(
+				'description' => 'which setup this is used by from tripal_views_setup table',
 					'type' => 'serial',
 					'unsigned' => TRUE,
 					'not null'=> TRUE,
@@ -88,7 +88,7 @@ function tripal_views_search_schema(){
 				'default' => '',
 			),
 			'handler_name' => array(
-				'description' => 'name of the views handler to be used for this particular search',
+				'description' => 'name of the views handler to be used for this particular setup',
 				'type' => 'varchar',
 				'length' => '255',
 				'not null' => TRUE,
@@ -99,12 +99,12 @@ function tripal_views_search_schema(){
 	return $schema;
 }
 
-function tripal_views_search_install(){
-	drupal_install_schema('tripal_views_search');
+function tripal_views_setup_install(){
+	drupal_install_schema('tripal_views_setup');
 }
 
-function tripal_views_search_uninstall(){
-	drupal_uninstall_schema('tripal_views_search');
+function tripal_views_setup_uninstall(){
+	drupal_uninstall_schema('tripal_views_setup');
 }
 
 

+ 9 - 9
base/tripal_views_search/tripal_views_search.module → base/tripal_views_setup/tripal_views_setup.module

@@ -1,25 +1,25 @@
 <?php
 
-require_once 'includes/tripal_views_search.admin.inc';
+require_once 'includes/tripal_views_setup.admin.inc';
 
-function tripal_views_search_menu(){
+function tripal_views_setup_menu(){
 	$items = array();
 	
 	//parents admin page TODO: figure out what to do here: add / remove searches
-	$items['admin/tripal/tripal_views_search'] = array(
+	$items['admin/tripal/tripal_views_setup'] = array(
 	  'title' => t('Tripal Views Search settings'),
 	  'description' => t('Tripal Views Search settings page, allows you to select and create materialized views and chado tables to use for searches.'),
-	  'page callback' => 'tripal_views_search_admin',
-	  // 'page arguments' => array('tripal_views_search_admin'),
+	  'page callback' => 'drupal_get_form',
+	  'page arguments' => array('tripal_views_setup_admin'),
 	  'access arguments' => array('access administration pages'),
 	  'type' => MENU_NORMAL_ITEM,
 	);
 	
 	//page to actually create searche->mview->chado table relationships
- 	$items['admin/tripal/tripal_views_search/new'] = array(
+ 	$items['admin/tripal/tripal_views_setup/new'] = array(
 		 'title' => 'Create New Search',
      'page callback' => 'drupal_get_form',
-     'page arguments' => array('tripal_views_search_new_search_form'),
+     'page arguments' => array('tripal_views_setup_new_search_form'),
      'access arguments' => array('access administration pages'), //TODO: figure out the proper permissions arguments
      'type' => MENU_NORMAL_ITEM,
  	);
@@ -28,7 +28,7 @@ function tripal_views_search_menu(){
 }
 
 
-/* this needs to go into the function tripal_views_search_block()
+/* this needs to go into the function tripal_views_setup_block()
  $limitnum = variable_get("onthisdate_maxdisp", 3);
 
 $query = "SELECT nid, title, created FROM " .
@@ -40,4 +40,4 @@ $query_result = db_query_range($query, $start_time, $end_time, 0, $limitnum);
 
 //TODO: validation for the admin pages
 
-
+function tripal_views_setup_