<?php
/**
* @package Mambo Open Source
* @subpackage Search
* @copyright (C) 2005 - 2006 Mambo Foundation Inc.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*
* Mambo was originally developed by Miro (www.miro.com.au) in 2000. Miro assigned the copyright in Mambo to The Mambo Foundation in 2005 to ensure
* that Mambo remained free Open Source software owned and managed by the community.
* Mambo is Free Software
*/ 

/** ensure this file is being included by a parent file */
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

class search_html {
	
	function openhtml( $params ) {
		if ( $params->get( 'page_title' ) ) {
			?>
			<div class="componentheading<?php echo $params->get( 'pageclass_sfx' ); ?>">
			<?php echo $params->get( 'header' ); ?>
			</div> 
			<?php 
		}
	}

	function searchbox( $searchword, &$lists, $params ) {
		global $Itemid;
		?>
		<form action="index.php" method="post">
		<table class="contentpaneopen<?php echo $params->get( 'pageclass_sfx' ); ?>">
			<tr>
				<td nowrap="nowrap">
				<?php echo T_('Search Keyword'); ?>:
				</td>
				<td nowrap="nowrap">
				<input type="text" name="searchword"size="15" value="<?php echo stripslashes($searchword);?>" class="inputbox" />
				</td>
				<td width="100%" nowrap="nowrap">
				<input type="submit" name="submit" value="<?php echo T_('Search');?>" class="button" />
				</td>
			</tr>
			<tr>
				<td colspan="3">
				<?php echo $lists['searchphrase']; ?>
				</td>
			</tr>
			<tr>
				<td colspan="3"><?php echo T_('Ordering');?>: <?php echo $lists['ordering'];?></td>
			</tr>
		</table>
		
		<input type="hidden" name="option" value="com_search" />
		<input type="hidden" name="Itemid" value="<?php echo $Itemid; ?>" />
		</form>
		<?php
	}

	function searchintro( $searchword, $params ) {
		?>
		<table class="searchintro<?php echo $params->get( 'pageclass_sfx' ); ?>">
		<tr>
			<td colspan="3" align="left">
			<?php echo T_('Search Keyword') . ' <b>' . stripslashes($searchword) . '</b>'; ?>	
		<?php
	}

	function message( $message, $params ) {
		?>
		<table class="searchintro<?php echo $params->get( 'pageclass_sfx' ); ?>">
		<tr>
			<td colspan="3" align="left">
			<?php eval ('echo "'.$message.'";');	?>
			</td>
		</tr>
		</table>
		<?php
	}

	function displaynoresult() {
		?>
			</td>
		</tr>
		<?php
	}

	function display( &$rows, $params ) {
		global $mosConfig_offset;
		
		$c 			= count ($rows);
		$tabclass 	= array("sectiontableentry1", "sectiontableentry2");
		$k 			= 0;
				
		// number of matches found
		printf( Tn_('returned %d match', 'returned %d matches',$c), $c );
		?>
			</td>
		</tr>
		</table>
		<br />
		<table class="contentpaneopen<?php echo $params->get( 'pageclass_sfx' ); ?>">
		<?php
		foreach ($rows as $row) {
			if ($row->created) {
				$created = mosFormatDate ($row->created, '%d %B, %Y');
			} else {
				$created = '';
			}
			?>
			<tr class="<?php echo $tabclass[$k] . $params->get( 'pageclass_sfx' ); ?>">
				<td>
				<?php
				if ($row->browsernav == 1) {
					?>
					<a href="<?php echo sefRelToAbs($row->href); ?>" target="_blank">
					<?php
				} else {
					?>
					<a href="<?php echo sefRelToAbs($row->href); ?>">
					<?php
				}
				echo $row->title;
				?>
				</a>
				<span class="small<?php echo $params->get( 'pageclass_sfx' ); ?>">
				(<?php echo $row->section; ?>)
				</span>
				</td>
			</tr>
			<tr class="<?php echo $tabclass[$k] . $params->get( 'pageclass_sfx' ); ?>">
				<td>
				<?php echo $row->text;?> &#133;
				</td>
			</tr>
			<tr>
				<td class="small<?php echo $params->get( 'pageclass_sfx' ); ?>">
				<?php echo $created; ?>
				</td>
			</tr>
			<tr>
				<td>
				&nbsp;
				</td>
			</tr>
			<?php
			$k = 1 - $k;
		}
	}

	function conclusion( $totalRows, $searchword ) {
		global $mosConfig_live_site;
		?>
		<tr>
			<td colspan="3">
			&nbsp;
			</td>
		</tr>
		<tr>
			<td colspan="3">
			<?php
			printf('Total %d results found.  Search for %s with', $totalRows, "<b>$searchword</b>");
			?>
			<a href="http://www.google.com/search?q=<?php echo stripslashes($searchword);?>" target="_blank">
			<img src="<?php echo $mosConfig_live_site;?>/images/M_images/google.png" border="0" align="texttop" />
			</a>
			</td>
		</tr>
		</table>	
		<?php
	}
}
?>