<?php

/**
 * Implementation of hook_help().
 */
function testthemepatch_help($section) {
  switch ($section) {
    case 'admin/modules#description':
      return t('test case for theme patch.');
  }
}
/**
 * Implementation of hook_menu() to inform drupal about the view that the login form submits to.  
 */
function testthemepatch_menu() {
	$items = array ();
	if (!$may_cache) { 
		$items[] = array (
				'path' => 'testthemepatch/test',
				'title' => t('Test old and new functionality.'), 
				'callback' => 'testthemepatch_test_callback', 
				'access' => user_access('access content'), 
				'type' => MENU_CALLBACK
		);
	}
	return $items;
} // end whoisdomain_menu

/**
 * Callback function for theme patch.
 * show old and new funcionality. 
 */
function testthemepatch_test_callback(){
	$output	  = "simple form<br>";
	$output  .= theme('testthemepatch_simple');
	$output	 .= "<br>simple form with header<br>";
	$output  .= theme('testthemepatch_simple_header');
	$output	 .= "<br>simple form with header and attributes<br>";
	$output  .= theme('testthemepatch_simple_header_attributes');
	$output	 .= "<br>simple form with header and attributes and caption<br>";
	$output  .= theme('testthemepatch_simple_header_attributes_caption');
	$output	 .= "<br>complex form with header and attributes and caption<br>";
	$output  .= theme('testthemepatch_complex_header_attributes_caption');
	$output	 .= "<br>complex form with header attributes<br>";
	$output  .= theme('testthemepatch_complex_header_attr_caption');
	$output	 .= "<br><hr><hr><br>";
	$output	 .= "<br>new header functionality<br>";
	$output  .= theme('testthemepatch_complex_new_header');
	$output	 .= "<br><hr><hr><br>";
	$output	 .= "<br>singel span<br>";
	$output  .= theme('testthemepatch_single_span');
	$output	 .= "<br>multiple span<br>";
	$output  .= theme('testthemepatch_multiple_span');
	$output	 .= "<br>singel link<br>";
	$output  .= theme('testthemepatch_single_link');
	$output	 .= "<br>multiple link<br>";
	$output  .= theme('testthemepatch_multiple_link');
	$output	 .= "<br><hr><hr><br>";
	$output	 .= "<br>new singel span<br>";
	$output  .= theme('testthemepatch_new_single_span');
	$output	 .= "<br>new multiple span<br>";
	$output  .= theme('testthemepatch_new_multiple_span');
	$output	 .= "<br>new singel link<br>";
	$output  .= theme('testthemepatch_new_single_link');
	$output	 .= "<br>new multiple link<br>";
	$output  .= theme('testthemepatch_new_multiple_link');
	
	return $output;
}

/**
 * A simple table with text cells.
 */
function theme_testthemepatch_simple() {
	$rows = array( array( 'Cell 1', 'Cell 2', 'Cell 3' ));
	return theme('table',array(),$rows);
}
/**
 * A simple table with text cells and a header.
 */
function theme_testthemepatch_simple_header() {
	$header = array('head1','head2','head3');
	$rows = array( array( 'Cell 1', 'Cell 2', 'Cell 3' ));
	return theme('table',$header,$rows);
}
/**
 * A simple table with header and and attributes.
 */
function theme_testthemepatch_simple_header_attributes() {
	$header = array('head1','head2','head3');
	$rows[] = array( 'Cell 1', 'Cell 2', 'Cell 3' );
	$attributes = array('width' => '100%');
	return theme('table',$header,$rows,$attributes);
}
/**
 * A simple table with header attributes and caption.
 */
function theme_testthemepatch_simple_header_attributes_caption() {
	$header = array('head1','head2','head3');
	$rows[] = array( 'Cell 1', 'Cell 2', 'Cell 3' );
	$attributes = array('width' => '100%');
	$caption = 'caption';
	return theme('table',$header,$rows,$attributes,$caption);
}
/**
 * A complex table with cell attributes.
 */
function theme_testthemepatch_complex_header_attributes_caption() {
	$header = array('head1','head2','head3');
	$cells[] = 'Cell 1';
	$cells[] = array('data' => 'Cell 2', 'colspan' => 2);
	
	$rows[] = array(
		'data' =>	$cells,
		'style' => 'font-weight : bold;'
	);

	$attributes = array('width' => '100%');
	$caption = 'caption';
	return theme('table',$header,$rows,$attributes,$caption);
}
/**
 * a complex table with cell and header attributes.
 */
function theme_testthemepatch_complex_header_attr_caption() {
	$header[] = 'head1';
	$header[] = array('data' => 'head2', 'style' => 'color : Blue;');
	$header[] = 'head3';
	$cells[] = 'Cell 1';
	$cells[] = array('data' => 'Cell 2', 'colspan' => 2);
	
	$rows[] = array(
		'data' =>	$cells,
		'style' => 'font-weight : bold;'
	);
	$rows[] = array( 'Bell 1', 'Bell 2', 'Bell 3' );

	$attributes = array('width' => '100%');
	$caption = 'caption';
	return theme('table',$header,$rows,$attributes,$caption);
}

/**
 * New functionality marking cells as th fields.
 */
function theme_testthemepatch_complex_new_header() {
	$header[] = 'head1';
	$header[] = array('data' => 'head2', 'style' => 'color : Blue;');
	$header[] = 'head3';
	$rows[] = array( 'Dell 1', array('data' => 'Dell 2','colspan' => 2));

	$cells[] = array('data' => 'Cell 1', 'header' => true);
	$cells[] = array('data' => 'Cell 2', 'header' => true);
	$cells[] = array('data' => 'Cell 3', 'header' => true);
	
	$rows[] = array(
		'data' =>	$cells,
		'style' => 'font-weight : bold;'
	);
	$rows[] = array( 'Bell 1', 'Bell 2', 'Bell 3' );

	$attributes = array('width' => '100%');
	$caption = 'caption';
	return theme('table',$header,$rows,$attributes,$caption);
}


/**
 * Old style attributes single span. 
 */
function theme_testthemepatch_single_span(){
	 $output = 		theme('links', array(array(
				'title' => t('span'), 
				'attributes' => array(
						'class' => 'modules-heading', 
						'style' => 'font-weight : bold;') 
				)
		));
		return $output;
}

/**
 * Old style attributes multiple span. 
 */
function theme_testthemepatch_multiple_span(){
	 $output = 		theme('links', array(array(
				'title' => t('span'), 
				'attributes' => array(
						'class' => 'modules-heading', 
						'style' => 'font-weight : bold;') 
				),
				array(
				'title' => t('span'), 
				'attributes' => array(
						'class' => 'modules-heading', 
						'style' => 'color : red;') 
				),
				array(
				'title' => t('span'), 
				'attributes' => array(
						'class' => 'modules-heading', 
						'style' => 'color : blue;') 
				)
		));
		return $output;
}
/**
 * Old style attributes single link. 
 */
function theme_testthemepatch_single_link(){
	 $output = 		theme('links', array(array(
				'title' => t('span'), 
				'href' => 'testthemepatch/test',
				'attributes' => array(
						'class' => 'modules-heading', 
						'style' => 'font-weight : bold;') 
				)
		));
		return $output;
}

/**
 * Old style attributes multiple links 
 */
function theme_testthemepatch_multiple_link(){
	 $output = 		theme('links', array(array(
				'title' => t('span'), 
				'href' => 'testthemepatch/test',
				'attributes' => array(
						'class' => 'modules-heading', 
						'style' => 'font-weight : bold;') 
				),
				array(
				'title' => t('span'), 
				'href' => 'testthemepatch/test',
				'attributes' => array(
						'class' => 'modules-heading', 
						'style' => 'color : red;') 
				),
				array(
				'title' => t('span'), 
				'href' => 'testthemepatch/test',
				'attributes' => array(
						'class' => 'modules-heading', 
						'style' => 'color : blue;') 
				)
		));
		return $output;
}
/**
 * New functionality consistent with table cells and header attributes.
 * Test single span.  
 */
function theme_testthemepatch_new_single_span(){
	 $output = 		theme('links', array(array(
				'title' => t('span'), 
				'class' => 'modules-heading', 
				'style' => 'font-weight : bold;' 
				)
		));
		return $output;
}
/**
 * New functionality consistent with table cells and header attributes.
 * Test multiple span.  
 */
function theme_testthemepatch_new_multiple_span(){
	 $output = 		theme('links', array(array(
				'title' => t('span'), 
				'class' => 'modules-heading', 
				'style' => 'font-weight : bold;' 
				),
				array(
				'title' => t('span'), 
				'class' => 'modules-heading', 
				'style' => 'color : red;' 
				),
				array(
				'title' => t('span'), 
				'class' => 'modules-heading', 
				'style' => 'color : blue;' 
				)
		));
		return $output;
}
/**
 * New functionality consistent with table cells and header attributes.
 * Test single links.  
 */
function theme_testthemepatch_new_single_link(){
	 $output = 		theme('links', array(array(
				'title' => t('span'), 
				'href' => 'testthemepatch/test',
				'class' => 'modules-heading', 
				'style' => 'font-weight : bold;' 
				)
		));
		return $output;
}
/**
 * New functionality consistent with table cells and header attributes.
 * Test multiple links.  
 */
function theme_testthemepatch_new_multiple_link(){
	 $output = 		theme('links', array(array(
				'title' => t('span'), 
				'href' => 'testthemepatch/test',
				'class' => 'modules-heading', 
				'style' => 'font-weight : bold;' 
				),
				array(
				'title' => t('span'), 
				'href' => 'testthemepatch/test',
				'class' => 'modules-heading', 
				'style' => 'color : red;' 
				),
				array(
				'title' => t('span'), 
				'href' => 'testthemepatch/test',
				'class' => 'modules-heading', 
				'style' => 'color : blue;' 
				)
		));
		return $output;
}
