<div class="page-info">
    <div class="container">
      <div id="breadcrumbs">
        <a href="/" class="first">صفحه اصلی</a>

            / <a href="/categories/all/">جستجو</a>
/
      </div>

<h1 class="page-title">        {$searchText}

</h1>
      
    </div>

  </div>

<div id="content">
      <div class="container">
          
<div class="content-l ">
    <div id="paginated-content-container">
  <div class="page-controls">
  {if $type == 'users'}
  <form action="" class="sort-control" id="sort-by-form" method="get">
  <label for="sort_by" class="sort-control-label">{$lang.order_by}:</label>
				<select class="sort_select" id="sort_by" name="sort_by">
	    			<option value="date">{$lang.date}</option>
						<option value="name" {if $smarty.get.sort_by == 'name'}selected="selected"{/if}>{$lang.name}</option>
						<option value="average_rating" {if $smarty.get.sort_by == 'average_rating'}selected="selected"{/if}>{$lang.rating}</option>
						<option value="sales_count" {if $smarty.get.sort_by == 'sales_count'}selected="selected"{/if}>{$lang.sales}</option>
					</select>
				</select>   
				<a href="javascript: void(0);" onclick="submitOrder(this);" title="" class="{if $smarty.get.order == 'asc'}asc{else}desc{/if}">
				<img src="/static/img/{if $smarty.get.order == 'asc'}asc{else}desc{/if}.png"  alt="" /></a>
	     				  <input id="type" name="type" type="hidden" value="users" />			  
				  <input id="term" name="term" type="hidden" value="{$searchText|escape}" />
</form>
  	{elseif $type == 'collections'}
	<form action="" class="sort-control" id="sort-by-form" method="get">
  <label for="sort_by" class="sort-control-label">{$lang.order_by}:</label>
				<select class="sort_select" id="sort_by" name="sort_by">
						<option value="published_at">{$lang.date}</option>
						<option value="name" {if $smarty.get.sort_by == 'name'}selected="selected"{/if}>{$lang.name}</option>
						<option value="average_rating" {if $smarty.get.sort_by == 'average_rating'}selected="selected"{/if}>{$lang.rating}</option>
				</select>   
				<a href="javascript: void(0);" onclick="submitOrder(this);" title="" class="{if $smarty.get.order == 'asc'}asc{else}desc{/if}">
				<img src="/static/img/{if $smarty.get.order == 'asc'}asc{else}desc{/if}.png"  alt="" /></a>
				  <input id="type" name="type" type="hidden" value="collections" />			  
				  <input id="term" name="term" type="hidden" value="{$searchText|escape}" />
</form>
		{else}
		
			<form action="" class="sort-control" id="sort-by-form" method="get">
					<label>{$lang.order_by}:</label>
					<select name="sort_by" class="sort_select" onchange="this.form.submit()">
						<option value="published_at">{$lang.date}</option>
						<option value="name" {if $smarty.get.sort_by == 'name'}selected="selected"{/if}>{$lang.name}</option>
						<option value="average_rating" {if $smarty.get.sort_by == 'average_rating'}selected="selected"{/if}>{$lang.rating}</option>
						<option value="sales_count" {if $smarty.get.sort_by == 'sales_count'}selected="selected"{/if}>{$lang.sales}</option>
						<option value="price" {if $smarty.get.sort_by == 'price'}selected="selected"{/if}>{$lang.price}</option>
					</select>
					<a href="javascript: void(0);" onclick="submitOrder(this);" title="" class="order-{if $smarty.get.order == 'asc'}asc{else}desc{/if} sprite left"></a>
				  <input id="type" name="type" type="hidden" value="files" />			  
				  <input id="term" name="term" type="hidden" value="{$searchText|escape}" />
				  <input id="collection_id" name="collection_id" type="hidden" value="{$smarty.get.collection_id}" />
				  {if isset($smarty.get.categories) && is_array($smarty.get.categories)}
				  	{foreach from=$smarty.get.categories item=c key=k}
				  		<input type="hidden" name="categories[{$k}]" value="1" />
				  	{/foreach}
				  {/if}
				</form>
	{/if}
    <div class="layout-switcher sort-control">
  <a href="#" class="layout-list sort-control-tooltip active" data-tooltip="List View"></a>
  <a href="#" class="layout-grid sort-control-tooltip" data-tooltip="Grid View"></a>
</div>

    <div class="pagination">{$paging}</div>   
  </div>
{if $results}

	
				{* SHOW USERS *}
				{if $type == 'users'}
<ul class="user-list">
	{foreach from=$results item=u name=foo}
<li>
  <div class="thumbnail">
    <a href="/{$languageURL}users/{$u.username}" class="avatar" title="{$u.username}">
							{if $u.avatar != ''}  
							  <img alt="{$u.username}" height="80" src="{$data_server}/uploads/users/{$u.user_id}/A_{$u.avatar}" width="80" />
							{else}
								<img alt="{$u.username}" height="80" src="{$data_server}/images/common/default-user.jpg" width="80" />
							{/if}
	</a>

  </div>

  <div class="user-info">
    <h3><a href="/{$languageURL}users/{$u.username}">{$u.username}</a></h3>
    <ul class="badges">

</ul>

  </div>

  <small class="meta">
    <strong>{$u.items}</strong> {$lang.items}<br>
    <strong>{$u.followers}</strong> {$lang.followers}<br>
    					    {$lang.member_since}: {$u.register_datetime|date_format:"j F Y"}<br>
					    {if $u.freelance == 'true'}
					    	{$lang.available_freelancer}<br>
					    {/if}
    </small>

  <div class="sale-info">
      <em class="sale-count">{$u.sales}</em>
      <small>{$lang.sales}</small>
    <div class="rating">
							{section name=foo1 start=1 loop=6 step=1}
								{if $u.rating >= $smarty.section.foo1.index}
						    	<img src="/static/img/star-on.png" alt="" />
							  {else}
						    	<img src="/static/img/star-off.png" alt="" />
							  {/if}
							{/section}
	 </div>
  </div>
</li>		
{/foreach}				
</ul>				
				
				
				
				
				{elseif $type == 'collections'}
<ul class="collection-list">
					{foreach from=$results item=c name=foo}
<li class="content-box">
  <a href="/{$languageURL}collections/view/{$c.id}/{$c.name|url}" class="collection-image">
						  {if $c.photo != ''}
						  <img alt="{$c.name|escape}" src="{$data_server}/uploads/collections/{$c.photo}" width="260" height="140">
						  {else}
						  	<img alt="{$c.name|escape}" src="/static/img/default-collection.jpg" width="260" height="140">
						  {/if}  					
   </a>

  <div class="collection-info">
    <h3><a href="/{$languageURL}collections/view/{$c.id}/{$c.name|url}">{$c.name}</a></h3>
    <span>By <a href="/{$languageURL}users/{$users[$c.user_id].username}">{$users[$c.user_id].username}</a></span>
    <p>{$c.text|nl2br}</p>  
  </div>

  <div class="collection-meta">
    <strong>{$c.items} {$lang.items}</strong>
    <br>
    
								{section name=foo start=1 loop=6 step=1}
								  {if $c.rating >= $smarty.section.foo.index}
							    	<img src="/static/img/star-on.png" alt="" />
								  {else}
							    	<img src="/static/img/star-off.png" alt="" />
								  {/if}
								{/section}
							  														
	<br><small>{$c.votes} ratings</small>
  </div>
</li>
{/foreach}				
</ul>				

				{else}

    <ul class="item-list">
	{foreach from=$results item=i name=foo}
      <li class="source">

  <div class="thumbnail">
    <a href="/{$langaugeURL}items/{$i.id}/{$i.name|url}.html" onclick="">

          <img alt="{$i.name|escape}" border="0" class="landscape-image-magnifier preload no_preview" data-item-author="توسط {$users[$i.user_id].username}" data-item-category="{foreach from=$i.categories item=e}{foreach from=$e item=c name=foo}{$categories[$c].name} {if !$smarty.foreach.foo.last} \ {/if}{/foreach}{/foreach}" data-item-cost="{$i.price} {$currency.symbol}" data-item-name="{$i.name|escape}" data-preview-height="" data-preview-url="{$data_server}/uploads/items/{$i.id}/preview.jpg" data-preview-width="" height="80" src="{$data_server}/uploads/items/{$i.id}/{$i.thumbnail}" title="{$i.name|escape}" width="80" />
    </a>  
   </div>

  <div class="item-info">
    <h3>
      <a href="/{$languageURL}items/{$i.id}/{$i.name|url}.html">{$i.name}</a>
    </h3>

    <span class="author">توسط</span> <a href="/{$languageURL}users/{$users[$i.user_id].username}/" class="author">{$users[$i.user_id].username}</a>

      </div>

  <small class="meta"><span class="meta-categories"> </span><br /></small>

  <div class="sale-info">
    <small class="sale-count">{$i.sales} {$lang.sales}</small>
    <small class="price">{$i.price} {$currency.symbol}</small>
    <div class="rating">
		{section name=foo start=1 loop=6 step=1}
							  {if $i.rating >= $smarty.section.foo.index}
						    	<img src="/static/img/star-on.png" alt="" />
							  {else}
						    	<img src="/static/img/star-off.png" alt="" />
							  {/if}
		{/section}
    </div>

   </div>
</li>
{/foreach}
    </ul>
	
{/if}	
	<div class="pagination">{$paging}</div>
		{else}
			<div class="content-box vertical-space">{$lang.no_results_found}</div>
			{/if}
    </div>

</div>
	

<div class="sidebar-s sidebar-right">
    <h2 class="box-heading">جستجوی شما</h2>
    <div class="content-box">
      <p style="font-family:BBCNassim;font-size:18px;">نتایج این جستجو</p>

      <form class="sidebar-search" action="/{$languageURL}search/" method="get">
	  <input type="text" onclick="this.value = &quot;&quot;" type="text" value="{$lang.search_within}"></input>
	  
					  <input id="type" name="type" type="hidden" value="{$type}" />
					  <input id="category" name="category" type="hidden" value="" />
					  <input id="base" name="base" type="hidden" value="{$smarty.get.term|escape}" />
					  <input id="collection_id" name="collection_id" type="hidden" value="{$smarty.get.collection_id}" />
					  {if isset($smarty.get.categories) && is_array($smarty.get.categories)}
					  	{foreach from=$smarty.get.categories item=c key=k}
					  		<input type="hidden" name="categories[{$k}]" value="1" />
					  	{/foreach}
					  {/if}
 <button type="submit" class="image-button search no-margin">Search</button>
</form>

    </div>
</div>

<script>
{literal}
  marketplace.queue( function(){
    marketplace.initializers.itemList({
      ajaxPagination: true,
      layoutSwitcher: true
    });
  });{/literal}
</script>

      </div>
    </div>