浏览代码

adding theme and form helpers module for tripal

alexgl 13 年之前
父节点
当前提交
290fd83544

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

@@ -36,6 +36,12 @@ function tripal_views_setup_admin_form(){
 	 	$int_i++;	
 	}
 	
+	$form['featured'] = array(
+		'#type' => 'checkboxes',
+		'#options' => $options,
+		'#default_value' => $status,
+	);
+	
 	dpm($form, 'admin_form');
 	return $form;
 	//return system_settings_form($form);

+ 1 - 0
base/tripal_views_setup/tripal_views_setup.info

@@ -4,4 +4,5 @@ core = 6.x
 package = Tripal
 
 dependencies[] = schema
+dependencies[] = tripal_helper_form
 

+ 7 - 0
base/tripal_views_setup/tripal_views_setup.install

@@ -36,6 +36,13 @@ function tripal_views_setup_schema(){
 				'not null' => TRUE,
 				'default' => '',
 			),
+			'description' => array(
+				'description' => 'description of this row',
+				'type' => 'varchar',
+				'length' => 255,
+				'not null' => TRUE,
+				'default' => '',
+			),
 		),
 		'unique_keys' => array(
 			'setup_id' => array('setup_id'),

+ 14 - 1
base/tripal_views_setup/tripal_views_setup.module

@@ -40,4 +40,17 @@ $query_result = db_query_range($query, $start_time, $end_time, 0, $limitnum);
 
 //TODO: validation for the admin pages
 
-function tripal_views_setup_
+function tripal_views_setup_theme(){
+	$theme = array();
+	
+	$theme['tripal_views_setup_form'] = array(
+		'arguments' => array('form' => NULL,),
+	);
+	
+	return $theme;
+}
+
+
+function theme_tripal_views_setup_theme($form){
+	return theme_tripal_helper_form_form($form);
+}

+ 5 - 0
tripal_helpers/tripal_helper_form/tripal_helper_form.info

@@ -0,0 +1,5 @@
+name = Tripal Helper Form
+description = Useful functions for dealing with forms for tripal 
+core = 6.x
+package = Tripal Helpers
+

+ 46 - 0
tripal_helpers/tripal_helper_form/tripal_helper_form.module

@@ -0,0 +1,46 @@
+<? php
+
+
+/**
+ * taken from http://www.akchauhan.com/create-drupal-form-using-theme_table-like-module-list-form/
+ * following as function theme_featured_product_form($form)
+ */
+function theme_tripal_helper_form_form($form, $field_keys){
+	$rows = array();
+	foreach (element_children($form) as $key) {
+		$row = array();
+		if (isset($form[$key]['name'])) {
+ 
+			$status = drupal_render($form['featured'][$key]);
+			$row[] = array(’data’ => $status, ‘class’ => ‘checkbox’);
+ 
+ 			$bool_first = TRUE;
+ 			foreach ($field_keys as $field_key => $value) {
+				if($bool_first){
+					$row[] = ‘‘. drupal_render($form[$key][$field_keys[$field_key]]) .’‘;//for "bold style"
+					$bool_first = FALSE;
+				}
+				else{
+					$row[] = array(’data’ => drupal_render($form[$key][$field_keys[$field_key]]);
+				}
+			}
+ 
+		
+ 
+			$rows[] = $row;
+		}
+	}
+ 
+	// Individual table headers.
+	$header = array();
+	$header[] = array(’data’ => t(’Featured’), ‘class’ => ‘checkbox’);
+	$header[] = t(’Name’);
+	$header[] = t(’Category’);
+	$header[] = t(’Discount’);
+	$header[] = t(’Created on’);
+ 
+	$output = theme(’table’, $header, $rows);
+	$output .= drupal_render($form);
+	return $output;
+}
+