|  | @@ -275,4 +275,116 @@ function tripal_core_field_widget_form_alter(&$element, &$form_state, $context)
 | 
	
		
			
				|  |  |        );
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/**
 | 
	
		
			
				|  |  | + * Implements hook_block_info().
 | 
	
		
			
				|  |  | + */
 | 
	
		
			
				|  |  | +function tripal_core_block_info() {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  $blocks['tripal_search'] = array(
 | 
	
		
			
				|  |  | +    'info' => t('Tripal Search Block'),
 | 
	
		
			
				|  |  | +    'cache' => DRUPAL_NO_CACHE,
 | 
	
		
			
				|  |  | +  );
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  return $blocks;
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/**
 | 
	
		
			
				|  |  | + * Implements hook_block_view().
 | 
	
		
			
				|  |  | + */
 | 
	
		
			
				|  |  | +function tripal_core_block_view($delta = '') {
 | 
	
		
			
				|  |  | +  $block = array();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  switch ($delta) {
 | 
	
		
			
				|  |  | +    case 'tripal_search':
 | 
	
		
			
				|  |  | +      $block['title'] = 'Search';
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +      $form_render_arr = drupal_get_form('tripal_core_search_block');
 | 
	
		
			
				|  |  | +      $block['content'] = array(
 | 
	
		
			
				|  |  | +        '#markup' => drupal_render($form_render_arr),
 | 
	
		
			
				|  |  | +      );
 | 
	
		
			
				|  |  | +      break;
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  return $block;
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/**
 | 
	
		
			
				|  |  | + * A simple search box form.
 | 
	
		
			
				|  |  | + */
 | 
	
		
			
				|  |  | +function tripal_core_search_block($form, $form_state) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  $form['wrapper'] = array(
 | 
	
		
			
				|  |  | +    '#prefix' => '<div id="search-block-form" class="container-inline">',
 | 
	
		
			
				|  |  | +    '#suffix' => '</div>',
 | 
	
		
			
				|  |  | +  );
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  $form['wrapper']['title'] = array(
 | 
	
		
			
				|  |  | +    '#markup' => '<h2 class="element-invisible">Search form</h2>',
 | 
	
		
			
				|  |  | +  );
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  $form['wrapper']['search_block_form'] = array(
 | 
	
		
			
				|  |  | +    '#title' => 'Search',
 | 
	
		
			
				|  |  | +    '#title_display' => 'invisible',
 | 
	
		
			
				|  |  | +    '#type' => 'textfield',
 | 
	
		
			
				|  |  | +    '#size' => 15,
 | 
	
		
			
				|  |  | +    '#maxlength' => 128,
 | 
	
		
			
				|  |  | +    '#attributes' =>array('placeholder' => t('Keywords'))
 | 
	
		
			
				|  |  | +  );
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  $form['wrapper']['submit'] = array(
 | 
	
		
			
				|  |  | +    '#type' => 'submit',
 | 
	
		
			
				|  |  | +    '#value' => 'Search',
 | 
	
		
			
				|  |  | +    '#prefix' => '<div class="form-actions form-wrapper" id="edit-actions">',
 | 
	
		
			
				|  |  | +    '#suffix' => '</div>'
 | 
	
		
			
				|  |  | +  );
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  return $form;
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/**
 | 
	
		
			
				|  |  | + * Submit for tripal_core_search_block form.
 | 
	
		
			
				|  |  | + */
 | 
	
		
			
				|  |  | +function tripal_core_search_block_submit($form, &$form_state) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  $form_state['redirect'] = array(
 | 
	
		
			
				|  |  | +    variable_get('tripal_search_block_url', 'search/data'),
 | 
	
		
			
				|  |  | +    array(
 | 
	
		
			
				|  |  | +      'query' => array(
 | 
	
		
			
				|  |  | +        'keywords' => $form_state['values']['search_block_form']
 | 
	
		
			
				|  |  | +      ),
 | 
	
		
			
				|  |  | +    ),
 | 
	
		
			
				|  |  | +  );
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/**
 | 
	
		
			
				|  |  | + * Implements hook_block_configure().
 | 
	
		
			
				|  |  | + */
 | 
	
		
			
				|  |  | +function tripal_core_block_configure ($delta = '') {
 | 
	
		
			
				|  |  | +  $form = array();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  $form['search_url'] = array(
 | 
	
		
			
				|  |  | +    '#type' => 'textfield',
 | 
	
		
			
				|  |  | +    '#title' => 'Search Page URL',
 | 
	
		
			
				|  |  | +    '#description' => 'The URL for the page you would like to redirect to when the user
 | 
	
		
			
				|  |  | +        clicks "Search". It is expected that this page will be a view with an exposed
 | 
	
		
			
				|  |  | +        filter having a "Filter Identifier" (in "More" fieldset on the edit filter form)
 | 
	
		
			
				|  |  | +        of "keywords".',
 | 
	
		
			
				|  |  | +    '#default_value' => variable_get('tripal_search_block_url', 'search/data'),
 | 
	
		
			
				|  |  | +  );
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  return $form;
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/**
 | 
	
		
			
				|  |  | + * Implements hook_block_save().
 | 
	
		
			
				|  |  | + */
 | 
	
		
			
				|  |  | +function tripal_core_block_save($delta = '', $edit = array()) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  // We simply want to save this information in a Drupal variable for use in the form submit.
 | 
	
		
			
				|  |  | +  if (!empty($edit['search_url'])) {
 | 
	
		
			
				|  |  | +    variable_set('tripal_search_block_url', $edit['search_url']);
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  |  }
 |