Location: PHPKode > projects > OpenNitro > trunk/Nitro/Defaults/Templates/List.tpl
{*
// +---------------------------------------------------------------------------+
// | Nitro :: Defaults :: Templates :: List                                    |
// +---------------------------------------------------------------------------+
// | Copyright (c) 2004 June Systems BV                                        |
// +---------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or modify it   |
// | under the terms of the GNU Lesser General Public License as published by  |
// | the Free Software Foundation; either version 2.1 of the License, or (at   |
// | your option) any later version.                                           |
// |                                                                           |
// | This library is distributed in the hope that it will be useful, but       |
// | WITHOUT ANY WARRANTY; without even the implied warranty of                |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser   |
// | General Public License for more details.                                  |
// |                                                                           |
// | You should have received a copy of the GNU Lesser General Public License  |
// | along with this library; if not, write to the Free Software Foundation,   |
// | Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA            |
// +---------------------------------------------------------------------------+
// | Authors: Oli Oskarsson <hide@address.com>                              |
// |          Siggi Oskarsson <hide@address.com>                          |
// +---------------------------------------------------------------------------+
//
// $Id: List.tpl 229 2008-04-17 09:20:31Z oli $
//
// Nitro's default List template
//
*}
{if $inDiv}<DIV NAME="{$inDiv}" ID="{$inDiv}">{/if}
{if $EnableFilter}<FORM NAME="ListFilter" METHOD="POST" ACTION="{$ListURL}">{/if}
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
	{if $Title}
	<TR>
		<TD STYLE="text-align: center"><B>{$Title}</B><BR>&nbsp;</TD>
	</TR>
	{/if}
	{if $ListActions|count > 0}
	<TR>
		<TD STYLE="text-align: right;">{foreach from=$ListActions item=ListActionData name=ListActionName}{if !$smarty.foreach.ListActionName.first}&nbsp;&nbsp;{/if}<B><A href="{if $ListActionData.URL neq ""}{$ListActionData.URL}{else}#{/if}"{if $ListActionData.onClickAction} onclick="{$ListActionData.onClickAction}"{/if}{if $ListActionData.Style} style="{$ListActionData.Style}"{/if}{if $ListActionData.Title} title="{$ListActionData.Title}"{/if}>{$ListActionData.Type}</A></B>{/foreach}&nbsp;&nbsp;</TD>
	</TR>
	{/if}
	<TR>
		<TD>
			<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="4" CLASS="TableDefault">
				{* Header *}
				<TR>
				{foreach from=$Columns item=ColumnName key=ColumnID name=Column}
					<TD CLASS="TableColumnHeader" STYLE="border-bottom: 1px solid black;{if !$smarty.foreach.Column.first} border-left: 1px solid black;{/if}">
					{if $smarty.foreach.Column.first}<A NAME="Block_0">{/if}
					{*<B><A HREF="JavaScript: goToURL('{$ListURL}&OrderBy={$ColumnID}')" TITLE="Order by {$ColumnName.0}">{$ColumnName.0}</A>{if $OrderBy.0.0 eq $ColumnID}{if $OrderBy.0.1 eq "DESC"} ^{else} v{/if}{/if}</B>*}
					<B>{$ColumnName.0}</B>
					</TD>
				{/foreach}
				
				{foreach from=$Actions item=ActionLable key=ActionKey}
					<TD CLASS="TableColumnHeader" STYLE="border-bottom: 1px solid black; border-left: 1px solid black"><B>{$ActionLable}</B></TD>
				{/foreach}
				</TR>

				{* Filter *}
				{if $EnableFilter}
				<TR>
				{foreach from=$Columns item=ColumnName key=ColumnID name=Column}
					<TD STYLE="border-bottom: 1px solid black;{if !$smarty.foreach.Column.first} border-left: 1px solid black;{/if}">
					{if $ListFilterVariables.$ColumnID == "SELECT" OR $ListFilterVariables.$ColumnID == "VALUES" OR $ListFilterVariables.$ColumnID == "VALUES_SELECT"}
						<SELECT NAME="ListFilter[{$ListID}][{$ColumnID}]"{if $ColumnWidths[$ColumnID]} STYLE="width: {$ColumnWidths[$ColumnID]}"{/if}>
						<OPTION VALUE=""> -- </OPTION>
						{foreach from=$ListFilterVariableValues.$ColumnID key=FilterValuesKey item=FilterValues}
							<OPTION VALUE="{$FilterValuesKey}"{if $ListFilterValues.$ColumnID == $FilterValuesKey} SELECTED{/if}>{$FilterValues}</OPTION>
						{/foreach}
						</SELECT>
					{else}
						<INPUT TYPE=TEXT NAME="ListFilter[{$ListID}][{$ColumnID}]" VALUE="{$ListFilterValues.$ColumnID}{$ListFilterVariables.$ColumnID}" SIZE=20{if $ColumnWidths[$ColumnID]} STYLE="width: {$ColumnWidths[$ColumnID]}"{/if}>
					{/if}
					</TD>
				{/foreach}
				<TD STYLE="border-bottom: 1px solid black; border-left: 1px solid black" COLSPAN="{$Actions|@count}">
				<INPUT TYPE="SUBMIT" NAME="Filter" VALUE="Filter">
				</TD>
				</TR>
				</FORM>
				{/if}

				<FORM NAME="{$ListID}" ACTION="{$URL}" METHOD="POST">
				{* Rows *}
				{foreach from=$Rows item=Row name=ListRows}
					{if $RepeatHeader && !($smarty.foreach.ListRows.iteration|fmod:$RepeatHeader)}
						{* Header *}
						<TR>
						{foreach from=$Columns item=ColumnName key=ColumnID name=Column}
							{assign var="Block" value=$smarty.foreach.ListRows.iteration/$RepeatHeader|floor}
							<TD CLASS="TableColumnHeader" STYLE="border-top: 1px solid black; border-bottom: 1px solid black;{if !$smarty.foreach.Column.first} border-left: 1px solid black;{/if}">
							{if $smarty.foreach.Column.first}<A NAME="Block_{$Block}">{/if}
							<B><A HREF="JavaScript: goToURL('{$ListURL}&OrderBy={$ColumnID}')" TITLE="Order by {$ColumnName.0}">{$ColumnName.0}</A>{if $OrderBy.0.0 eq $ColumnID}{if $OrderBy.0.1 eq "DESC"} ^{else} v{/if}{/if}</B>
							</TD>
						{/foreach}
						
						{foreach from=$Actions item=ActionLable key=ActionKey}
							<TD CLASS="TableColumnHeader" STYLE="border-bottom: 1px solid black; border-left: 1px solid black"><B>{$ActionLable}</B></TD>
						{/foreach}
						</TR>
					{/if}
					<TR{if $EnableRowHighlighting} onMouseOver="javascript: this.style.backgroundColor = '#FFD4A8'" onMouseOut="javascript: this.style.backgroundColor = ''"{/if} ID="ROW_{$Row->Identifier}">
					{foreach from=$Columns item=ColumnName key=ColumnID name=Column}
						{if $EnableColumnHighlighting}
							{if $RepeatHeader}
								{assign var="Block" value=$smarty.foreach.ListRows.iteration/$RepeatHeader|floor}
							{else}
								{assign var="Block" value=1}
							{/if}
							<TD onMouseOver="HighlightColumn('TD_{$ColumnID}_{$Block}', '#FFD4A8'); this.style.backgroundColor = '#FFA851'" onMouseOut="HighlightColumn('TD_{$ColumnID}_{$Block}', ''); this.style.backgroundColor = ''" ID="TD_{$ColumnID}_{$Block}" STYLE="{if !$smarty.foreach.Column.first}border-left: 1px solid black; {/if}{if $ColumnName.1} text-align: center;{/if}">
						{else}
							<TD STYLE="{if !$smarty.foreach.Column.first}border-left: 1px solid black; {/if}{if $ColumnName.1}text-align: center;{/if}">
						{/if}
						{if $Row->Data[$ColumnID]}
							{if $ColumnWidths[$ColumnID]}
								<DIV STYLE="overflow: hidden" TITLE="{NitroStripTags String=$Row->Data[$ColumnID]}" STYLE="width: {$ColumnWidths[$ColumnID]}"><NOBR>{$Row->Data[$ColumnID]}</NOBR></DIV>
							{else}
								{$Row->Data[$ColumnID]}
							{/if}
						{else}
						&nbsp;
						{/if}
						</TD>
					{/foreach}
					{foreach from=$Actions key=ActionID item=Action}
						<TD STYLE="border-left: 1px solid black; {if $Row->ActionCenter[$ActionID]}text-align: center;{/if}">
							{if $Row->ActionName[$ActionID]}
								{if $Row->ActionNoLink[$ActionID]}
									{$Row->ActionName[$ActionID]}
								{else}
									<A href="{if $Row->ActionURL[$ActionID] neq ""}{$Row->ActionURL[$ActionID]}{else}#{/if}"{if $Row->ActionOnClick[$ActionID]} onclick="{$Row->ActionOnClick[$ActionID]}"{/if}{if $Row->ActionTitle[$ActionID]} title="{$Row->ActionTitle[$ActionID]}"{/if}{if $Row->ActionStyle[$ActionID]} style="{$Row->ActionStyle[$ActionID]}"{/if}>{$Row->ActionName[$ActionID]}</A>
								{/if}
							{else}
								&nbsp;
							{/if}
						</TD>
					{/foreach}
					</TR>
				{/foreach}
				</FORM>
			</TABLE>
		</TD>
	</TR>
</TABLE>
{if $inDiv}</DIV>{/if}
<SCRIPT LANGUAGE="JavaScript">
CallOnLoadString += "ScrollWindow();";
{if $EnableColumnHighlighting}
{literal}
	function HighlightColumn(ActiveColumnID, Color){
		var DataCells = document.getElementsByName(ActiveColumnID);
		for(var i = 0; i < DataCells.length; i++) {
			DataCells.item(i).style.backgroundColor = Color;
		}
	}
{/literal}
{/if}

{literal}
var XMLObject = null;
function goToURL(URL)
{
	try {
		XMLObject = new XMLHttpRequest();
	} catch (e) {
		var MSXML_XMLHTTP_PROGIDS = new Array(
			'MSXML2.XMLHTTP.5.0',
			'MSXML2.XMLHTTP.4.0',
			'MSXML2.XMLHTTP.3.0',
			'MSXML2.XMLHTTP',
			'Microsoft.XMLHTTP'
			);
		
		XMLObject = null;
		var success = false;
		for (var i=0;i < MSXML_XMLHTTP_PROGIDS.length && !success; i++) {
			try {
				XMLObject = new ActiveXObject(MSXML_XMLHTTP_PROGIDS[i]);
				success = true;
			} catch (e) {}
		}
	}
	
	if (document.documentElement && document.documentElement.scrollTop){
		scrollTop = document.documentElement.scrollTop;
		scrollLeft = document.documentElement.scrollLeft;
	} else {
		scrollTop = document.body.scrollTop;
		scrollLeft = document.body.scrollLeft;
	}
	XMLObject.onreadystatechange = function() {
				if(XMLObject.readyState == 4) document.location.href = URL;
			}
	{/literal}
	XMLObject.open('GET', '/XML/SaveScrollPos.php?LID={$ListID}&ScrollPosTop=' + scrollTop + '&ScrollPosLeft=' + scrollLeft, true);
	XMLObject.send(null);
	{literal}
}
function ScrollWindow(){
	{/literal}window.scrollTo({$ScrollLeft}, {$ScrollTop});{literal}
}
{/literal}
</SCRIPT>
Return current item: OpenNitro