search_results.smarty 7.76 KB
{$context->oPage->requireJSResource('resources/js/toggleselect.js')}

<div class="collapsible">
<h4 onclick="toggleElementClass('expanded', this.parentNode)">{i18n}Search Criteria{/i18n}</h4>
<div class="collapsiblebody">
<fieldset>
	<legend>{i18n}Search Criteria{/i18n}</legend>
	{$txtQuery}
	<br>
{if empty($iSavedID)}
	{capture assign=options}
    	<a href="{addQS}action=queryBuilder{/addQS}">{i18n}Search Criteria Editor{/i18n}</a>
    {/capture}
	{i18n arg_options=$options}Use the #options# to extend your search criteria.{/i18n}
{/if}
{if !$search2_anonymous && !empty($iSavedID)}
	{capture assign=options}
    	<a href="{addQS}action=queryBuilder&fSavedSearchId={$iSavedID}{/addQS}">Query Editor</a>
    {/capture}
	{i18n arg_options=$options}To edit the search criteria, use the #options#.{/i18n}
{/if}
	<font color=brown><div id="savedSearch" style="display: none">{i18n}The search criteria has been saved.{/i18n}</div></font>
</fieldset>
<br>
{if !$search2_anonymous && !empty($iSavedID)}
<fieldset>
	<legend>{i18n}Saved Search{/i18n}</legend>
	{i18n}This is the saved search criteria:{/i18n} {$txtSavedName}. <br/>
	{capture assign=options}
    	<a href="{addQS}action=manage{/addQS}">{i18n}Manage Saved Search Criteria{/i18n}</a>
    {/capture}
	{i18n arg_options=$options}To delete this saved search criteria or to edit other saved search criteria, #options#.{/i18n}
</fieldset>
{/if}
{literal}
<script language="javascript">
function saveSearch()
{
	var txtName = $('txtSaveName');
	var txtQuery = '{/literal}{$txtQuery|escape:'quotes'}{literal}';
	if (txtName.value == '')
	{
		alert("{/literal}{i18n}Please enter a name for the search expression.{/i18n}{literal}");
		txtName.focus();
		return;
	}
	url='{/literal}{$rootUrl}{literal}/search2/ajax/saveExpr.php';

	Ext.Ajax.request(
	{
	    url: url,
	    method: 'GET',
	    success: function callBack(o)
	    {
	        if (o.responseText != '{}')
	        {
	            var resp = eval('(' + o.responseText + ')');

	            if (resp.status == 0)
	            {
	                parseSuccess = true;
	                $('saveSearch').style.display='none';
	                $('savedSearch').style.display='block';
	            }
	            else
	            {
	                alert("{/literal}{i18n}There is a problem saving the expression expression.{/i18n}{literal}\n\n" + resp.message );
	            }
	        }
	    },
	    failure: function(o)
	    {
	        alert("{/literal}{i18n}There is a problem communicating with the server.{/i18n}{literal}" +  o.responseText);
	    },
	    params: {
	        txtName: txtName.value,
	        txtQuery: txtQuery
	    }
	});
}

function onSelectAll()
{
	var cbSelectAll = $('cbSelectAll');

	for(var i={/literal}{$firstRec}{literal};i<{/literal}{$lastRec}{literal};i++)
	{
		var cb = $('cb' + i);

		cb.checked = cbSelectAll.checked;
	}
}

function onShowAll(showall)
{
	url = "{/literal}{addQS}{literal}action=searchResults&pageOffset={/literal}{$pageOffset}{literal}&showAll=" + showall + "{/literal}{/addQS}{literal}";

	document.location = url;
}

</script>
{/literal}
</div>
</div>
{if !$search2_anonymous && empty($iSavedID)}
<div id="saveSearch">
<fieldset>
	<legend>{i18n}You can save this search:{/i18n}</legend>
	<input id=txtSaveName>
	<input type=button value="{i18n}Save{/i18n}" onclick="saveSearch()">
</fieldset>
</div>
{/if}


<fieldset>

<legend>{i18n}Search Results{/i18n}</legend>

{if $numResults == 0}

	{i18n}There are no search results matching your search criteria.{/i18n}

	<p>
	{capture assign=options}
		<a href="{addQS}action=queryBuilder{/addQS}">{i18n}Search Criteria Editor{/i18n}</a>
	{/capture}

	{i18n arg_options=$options}Use the #options# to extend this query.{/i18n}

{else}

	<form method=post action="{$rootUrl}/action.php">
	<table border=0 cellpadding="1" cellspacing="1" width="100%" align=center>
	{assign var=cbid value=0}

	{i18n arg_count=$numResults}Search results found: #count#{/i18n}
    <br/>
    <br/>

	{foreach item=hit from=$results}
		<tr><td>
		<input type="checkbox" {if $hit->IsDocument}name="selection_d[]"{else}name="selection_f[]"{/if} id="cb{$cbid}" value="{$hit->Id}"><nobr>
	    <span class="contenttype {$hit->MimeIconPath}">

		{if $hit->IsDocument}
		&nbsp;&nbsp;<a href="{$rootUrl}/view.php?fDocumentId={$hit->Id}"><B>{$hit->Title|truncate:80}</b></a>
		{if $hit->Title != $hit->Filename}
			&nbsp;&nbsp;
			<font style=" color: green "> - {i18n}Filename:{/i18n} {$hit->Filename|truncate:40}</font>
		{/if}
		{if $hit->IsAvailable}
		    &nbsp;&nbsp;
            <img src="{$rootUrl}/resources/graphics/download.png" title="Download Document" onclick="document.location='{$rootUrl}/action.php?kt_path_info=ktcore.actions.document.view&fDocumentId={$hit->Id}';"></a>

		{/if}


		{if !$hit->IsAvailable}
			&nbsp;&nbsp;
			<font style=" color: red "><B> * {i18n}NOT AVAILABLE{/i18n} * </B></font>
		{/if}

		{else}
		&nbsp;&nbsp;<a href="{$rootUrl}/browse.php?fFolderId={$hit->RealId}{if $hit->IsProxy}&fShortcutFolder={$hit->Id}{/if}"><B>{$hit->Title|truncate:80}</b></a>

        {/if}

		</nobr>
		</td><td align=right>
		    {if $hit->IsDocument}
			     <font style="color: green ">{i18n}Document ID:{/i18n} {$hit->Id}</font>
			     &nbsp;&nbsp;
			     <font style=" color: orange ">{i18n}Version:{/i18n} {$hit->Version}</font></td>
		    {else}
			     <font style="color: green ">{i18n}Folder ID:{/i18n} {$hit->Id}</font>
		    {/if}
		</tr>
		<tr><td colspan=2>{$hit->Text}</td></tr>
		<tr><td>
		{if $hit->IsDocument}
		      <font style=" color: green "><a href="{$rootUrl}/browse.php?fFolderId={$hit->FolderId}" tag="{$hit->FullPath}">{$hit->FullPath|truncate:40}</a>/{$hit->Title|truncate:40} - {$hit->Filesize}</font>
		{else}
		      <font style=" color: green "><a href="{$rootUrl}/browse.php?fFolderId={$hit->FolderId}" tag="{$hit->FullPath}">{$hit->FullPath|truncate:40}</a></font>
		{/if}
		</td>
			<td align=right><nobr>
				<font style="color: orange ">
				{i18n}Created By:{/i18n} {$hit->CreatedBy}
				{if $hit->IsDocument}
				{i18n}on{/i18n} {$hit->DateCreated}
				{/if}
				</font>
			</td>
	    {if $hit->IsDocument}
		<tr><td>
			{if $workflow != ''}
				<font style="color: orange ">{i18n}Workflow:{/i18n} $hit->Workflow}</font>
			{/if}
			</td>
			<td align=right><nobr>
				<font style="color: brown ">
				{if $hit->CheckedOutUser != ''}
					<b>{i18n}Checked out by:{/i18n} {$hit->CheckedOutUser}
					{i18n}on{/i18n} {$hit->DateCheckedOut}</b>
				{else}
					{i18n}Modified by:{/i18n} {$hit->ModifiedBy}
					{i18n}on{/i18n} {$hit->DateModified}
				{/if}
				</font>
			</td>
		{/if}

		<tr><td colspan=2><br></br></td></tr></tr>

		{assign var=cbid value=$cbid+1}
	{/foreach}

	<tr><td>
		<input type="checkbox" id="cbSelectAll" onclick="onSelectAll()">&nbsp;&nbsp;{i18n}Select All{/i18n}
		{if $showAll}
			<input type="checkbox"  onclick="onShowAll('false')" checked>&nbsp;&nbsp;{i18n}Show All{/i18n}
		{/if}
		{if !$showAll}
			<input type="checkbox"  onclick="onShowAll('true')">&nbsp;&nbsp;{i18n}Show All{/i18n}
		{/if}
		<br>
  		<input type="hidden" name="fFolderId" value="1" />
  		<input type="hidden" name="sListCode" value="" />
  		<input type="hidden" name="action" value="bulkaction" />
  		<input type="hidden" name="fReturnAction" value="search2" />
  		<input type="hidden" name="fReturnData" value="1" />

  		<nobr>
  		{foreach from=$bulkactions item=bulkaction}
      		<input type="submit" name="submit[{$bulkaction->getName()}]" value="{$bulkaction->getDisplayName()}" />
		{/foreach}
  		</nobr>
</table>
</form>

{/if}


</fieldset>

{if $endMovement - $startMovement > 0}
<br>
<br>
<table align="center">
<tr>
	{foreach item=move from=$pageMovement}
		{if $move == $startMovement}
			<td></td>
		{/if}
			<td><a href="{$rootUrl}/search2.php?action=searchResults&pageOffset={$move}">{$move}</a></td>
		{if $move == $endMovement}
			<td></td>
		{/if}
	{/foreach}
</tr>
</table>
{/if}