Your IP : 216.73.216.170


Current Path : /var/www/iplanru/data/www/i-plan.ru/modules/mod_zoo_finder/tmpl/
Upload File :
Current File : /var/www/iplanru/data/www/i-plan.ru/modules/mod_zoo_finder/tmpl/result.php

<?php

// No direct access
defined( '_JEXEC' ) or die;

$jinput = JFactory::getApplication()->input;

//zootypes
$zt=array();
$mzootypes=array();
$mzootypes=explode("\r\n",$zootypes);
foreach($mzootypes as $item) $zt[]=explode("|",$item); 
$b=false;
foreach ($zt as $item) {if ($jinput->get( "type-{$item[1]}", 0, 'INT' )==1) $b=true;}
foreach ($zt as $item) 
{	
	$nzt[$item[1]]=	$item[0];//типы материалов с ключом
	$szt[$item[1]]=false;
	if ($jinput->get( 'alltypes', 0, 'INT' )==1) $szt[$item[1]]=true;
	if (!$b) $szt[$item[1]]=true;
	if ($jinput->get( "type-{$item[1]}", 0, 'INT' )==1) $szt[$item[1]]=true;
}

unset($mzootypes);


$q=str_replace('"',"",urldecode($_GET['q']));

if ($q)
{
	$m = modZoofinderHelper::getResult($morphy,$q,$zt,$jinput,false);
	
	if ($m)
	{
		//$res =implode("\r\n",$m);
		//$count = modZoofinderHelper::getResult($morphy,$q,$zt,$jinput,true);
		$pager = $zoolib->getPager(count($m));
	}
		
}



?>
<div class="module<?php echo $moduleclass_sfx; ?>">
<form class="zoofinder" name="zoofinder" action="<?php echo $path; ?>" method="get" role="search">
	<div class="word">
		<label for="q"> Условия поиска: </label>
		<input class="uk-search-field-full" type="search" name="q" autocomplete="off" value="<?php echo $q; ?>"/>
		<a href="javascript://" name="submit-btn" onclick="document.zoofinder.submit();">
			<div class="submit-btn"> Найти </div>
		</a>
	</div>
	
	<fieldset id="ext-finder"><legend>Дополнительные параметры</legend>
		<div class="zoofinder-extparam">
			<label id="types">
				Тип материала:
				<?php
					foreach ($zt as $item)
					{
						$ch='';
						if ($szt[$item[1]]) $ch='checked="checked"';
						echo "<input type=\"checkbox\" name=\"type-{$item[1]}\" {$ch} value=\"1\" onchange=\"document.zoofinder.submit();\"><span>{$item[0]}</span>";
					}
				?>
			</label>
			<label id="sortby">
				Сортировать по:
				<input type="radio" name="sortby" <?php if ($jinput->get('sortby',"rel")=="rel") echo 'checked="checked"'; ?> value="rel" onchange="document.zoofinder.submit();"><span>Релевантности</span>
				<input type="radio" name="sortby" <?php if ($jinput->get('sortby',"rel")=="date") echo 'checked="checked"'; ?> value="date" onchange="document.zoofinder.submit();"><span>Дате</span>
			</label>
			<label id="limit">
				Отобразить результатов:
				<select id="limit" name="limit" class="inputbox input-mini chzn-done" size="1" onchange="document.zoofinder.submit();">
					<option value="5" <?php if ($jinput->get('limit',"10")=="5") echo 'selected="selected"'; ?> >5</option>
					<option value="10" <?php if ($jinput->get('limit',"10")=="10") echo 'selected="selected"'; ?> >10</option>
					<option value="15" <?php if ($jinput->get('limit',"10")=="15") echo 'selected="selected"'; ?> >15</option>
					<option value="20" <?php if ($jinput->get('limit',"10")=="20") echo 'selected="selected"'; ?> >20</option>
					<option value="25" <?php if ($jinput->get('limit',"10")=="25") echo 'selected="selected"'; ?> >25</option>
					<option value="30" <?php if ($jinput->get('limit',"10")=="30") echo 'selected="selected"'; ?> >30</option>
					<option value="50" <?php if ($jinput->get('limit',"10")=="50") echo 'selected="selected"'; ?> >50</option>
					<option value="100" <?php if ($jinput->get('limit',"10")=="100") echo 'selected="selected"'; ?> >100</option>
				</select>
			</label>
		</div>
		<input type="hidden" name="page" value="1"/>
		<input type="hidden" name="lang" value="ru"/>
		<input type="hidden" name="Itemid" value="<?php echo $mymenuitem; ?>"/>	
	</fieldset>
</form>

<div class="zoofinder-info">
	<?php 
		if ($q)
		{
			if (count($m)>0) 
				echo "Найдено совпадений: ".count($m);
			else
				echo "Поиск не дал результатов.";
		}	
	?>
</div>

<div class="zoofinder-pager">
	<?php echo $pager; ?>
</div>

<div class="zoofinder-result">
	<?php 
		//q prepare					
		$hl=trim($q);
		$hl=strip_tags($hl);
		$hl=html_entity_decode($hl);				
		$hl=mb_ereg_replace 	("[^a-zA-Zа-яА-Я0-9ёЁ\s\-]","",$hl);		
		$hl=str_replace("  ", " ", $hl);
		$hl=explode(" ", $hl);//highlighter
		//удаление коротких слов
		foreach ($hl as $key=>$word) if (mb_strlen($word)<=2) unset($hl[$key]); 
		
		$pagepos=($jinput->get('page',"1")-1)*$jinput->get('limit',"10");
		for( $i=$pagepos; $i < $pagepos+$jinput->get('limit',"10"); $i++)
		{
			if (isset($m[$i]))
			{
				//$a=json_decode($m[$i]['elements'],true);	
				$name=$m[$i][name];
				foreach ($hl as $word) $name=str_replace( $word, "<span class=\"highlight\" rel=\"{$word}\">{$word}</span>", $name);
				
				echo "
					<div slass=\"result-item\">
						<h3><a href=\"index.php?option=com_zoo&item_id={$m[$i][id]}&Itemid=117&view=item\">{$name}</a></h3>
						<div>
							<span class=\"res-date\">{$m[$i][date]}</span>
							<span class=\"res-type\">{$nzt[$m[$i][type]]}</span>
						</div>
					</div>
				";
			}
		}
		
	?>
</div>

<div class="zoofinder-pager">
	<?php echo $pager; ?>
</div>

</div>