瀏覽代碼

figured out the direction to take for layout of the admin pages, following example of tripal_features

alexgl 13 年之前
父節點
當前提交
d101d95768

+ 21 - 36
base/tripal_views_search/includes/tripal_views_search.admin.inc

@@ -1,6 +1,15 @@
 <?php 
 
 function tripal_views_search_admin(){
+	$add_url = url('admin/tripal/tripal_views_search/new');
+	$output = "<a href=\"$add_url\">Add New Search";
+	$output .= drupal_get_form(tripal_views_search_admin_form);
+	
+	return $output;
+}
+
+
+function tripal_views_search_admin_form(){
 	$form = array();
 
 	$form['tripal_views_search_config_mview'] = array(
@@ -19,21 +28,20 @@ function tripal_views_search_admin(){
 		'#required' => TRUE,
 	);
 
+	dpm($form, 'tripal_views_search_admin form');
 	return system_settings_form($form);
 }
 
-/* this needs to go into the function tripal_views_search_block()
- $limitnum = variable_get("onthisdate_maxdisp", 3);
-
-$query = "SELECT nid, title, created FROM " .
-"{node} WHERE created >= %d " .
-"AND created <= %d";
-
-$query_result = db_query_range($query, $start_time, $end_time, 0, $limitnum);
-*/
-
-//TODO: validation for the admin pages
-
+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,
+	);
+	return $form;
+}
 
 function tripal_views_search_mview_list(){
 	//must return an array of strings ie:
@@ -53,29 +61,6 @@ function tripal_views_search_btable_list(){
 	return $options;
 }
 
-/**
- *
- * Use this hook for the admin form page,
- * once changes are saved, use this to update
- * the tripal_views_search related tables.
- *
- * @param array $form
- * @param array $form_state
- * @param int $form_id
- */
-function tripal_views_search_form_alter(&$form, &$form_state, $form_id){
-	if(strstr('tripal-views-search-admin', $form['#id'] != FALSE)){
-		$form['#submit']['tripal_views_search_admin_submit'] = array();
-	}
-}
 
-/**
- *
- * the actual submit callback function
- * @param int $form_id
- * @param array $form_values
- */
-function tripal_views_search_admin_submit($form_id, &$form_values){
-	//populate db tables based on settings
-}
+
 

+ 7 - 0
base/tripal_views_search/tripal_views_search.install

@@ -22,6 +22,13 @@ function tripal_views_search_schema(){
 				'not null' => TRUE,
 				'default' => '',
 			),
+			'status' => array(
+				'description' => 'Weather this search will be used: 0 = inactive, 1 = active.',
+				'type' => 'int',
+				'unsigned' => TRUE,
+				'not null' => TRUE,
+				'default' => '0',
+			),
 		),
 		'unique_keys' => array(
 			'tripal_search_id' => array('tripal_search_id'),

+ 42 - 4
base/tripal_views_search/tripal_views_search.module

@@ -5,15 +5,53 @@ require_once 'includes/tripal_views_search.admin.inc';
 function tripal_views_search_menu(){
 	$items = array();
 	
-	$items['admin/settings/tripal_views_search'] = array(
+	//parents admin page TODO: figure out what to do here: add / remove searches
+	$items['admin/tripal/tripal_views_search'] = array(
 	  'title' => t('Tripal Views Search settings'),
-	  'description' => t('Tripal Views Search settings page, allows you to select which materialized views and chado tables to use for searches.'),
-	  'page callback' => 'drupal_get_form',
-	  'page arguments' => array('tripal_views_search_admin'),
+	  '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'),
 	  'access arguments' => array('access administration pages'),
 	  'type' => MENU_NORMAL_ITEM,
 	);
 	
+	/////////////////////////////////
+	
+	 // managing relationship aggregates
+   // $items['admin/tripal/tripal_feature/aggregate'] = array(
+     // 'title' => 'Feature Relationship Aggegators',
+     // 'description' => t('Features have relationships with other features and it may be desirable to aggregate the content from one ore more child or parent feature.'),
+     // 'page callback' => 'tripal_feature_aggregator_page',
+     // 'access arguments' => array('manage chado_feature aggregator'),
+     // 'type' => MENU_NORMAL_ITEM,
+   // );
+	
+	
+	//////////////////////////
+	
+	//page to actually create searche->mview->chado table relationships
+ 	$items['admin/tripal/tripal_views_search/new'] = array(
+		 'title' => 'Create New Search',
+     'page callback' => 'drupal_get_form',
+     'page arguments' => array('tripal_views_search_new_search_form'),
+     'access arguments' => array('access administration pages'), //TODO: figure out the proper permissions arguments
+     'type' => MENU_NORMAL_ITEM,
+ 	);
+	
 	return $items;
 }
 
+
+/* this needs to go into the function tripal_views_search_block()
+ $limitnum = variable_get("onthisdate_maxdisp", 3);
+
+$query = "SELECT nid, title, created FROM " .
+"{node} WHERE created >= %d " .
+"AND created <= %d";
+
+$query_result = db_query_range($query, $start_time, $end_time, 0, $limitnum);
+*/
+
+//TODO: validation for the admin pages
+
+