#*
 * Copyright 2003-2004 The Apache Software Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * $Id: VM_global_library.vm,v 1.4 2004/02/20 13:13:42 marino Exp $
 *#

## Display all queued Struts errors
#macro (errorMarkup)
    #if ($errors.exist() )
        <ul>
        #foreach ($e in $errors.all )
            <li>$e</li>
        #end
        </ul>
    #end
#end

## Display all queued Struts errors for a particular property
#macro (errorMarkupForProperty $property)
    #if ($errors.exist($property) )
        <ul>
        #foreach ($er in $errors.get($property))
            <li>$e</li>
        #end
        </ul>
    #end
#end

## Display all queued Struts errors
#macro (messageMarkup)
    #if ($messages.exist() )
        <ul>
        #foreach ($m in $messages.all )
            <li>$m</lli>
        #end
        </ul>
    #end
#end

## Display all queued Struts action messages for a particular property
#macro (messageMarkupForProperty $property)
    #if ($messages.exist($property) )
        <ul>
        #foreach ($m in $messages.get($property))
            <li>$m</lli>
        #end
        </ul>
    #end
#end

######################################
#macro (pagerMarkup $action $pager)
	#if($pager)
		#set($action = $action.addQueryData('limit', $pager.limit))
				<span class="pager">
		#if($pager.hasPrevious())
		#set($prevAction = $action.addQueryData('offset', $pager.previousOffset))
					<a href="$prevAction"><img src="$link.setRelative('/resources/skin/default/image/icon/back.png')" /></a>
		#end
		#if($pager.hasNext())
		#set($nextAction = $action.addQueryData('offset', $pager.nextOffset))
					<a href="$nextAction"><img src="$link.setRelative('/resources/skin/default/image/icon/next.png')" /></a>
		#end
					${pager.pageRangeFirst}-${pager.pageRangeLast} / 全${pager.rowCount}件 
				</span>
	#end
#end

######################################
#macro (setDefaultPagerOfSearchQuery $action $pager)
	#if($pager)
		#set($action = $action.addQueryData('limit', $pager.limit))
	#end
#end
#macro (setBasicOfSearchQuery $action $query)
	#if($query)
		#foreach($stat in $query.status)
			#set($action = $action.addQueryData('status', $stat))
		#end
		#foreach($tg in $query.tag)
			#set($action = $action.addQueryData('tag', $tg))
		#end
		#foreach($tg in $query.excludeTag)
			#set($action = $action.addQueryData('excludeTag', $tg))
		#end
		#set($action = $action.addQueryData('keyword', $query.keyword))
		#set($action = $action.addQueryData('priorityFrom', $query.priorityFrom))
		#set($action = $action.addQueryData('priorityTo', $query.priorityTo))
		#set($action = $action.addQueryData('deadEndDateFrom', $utils.formatDate($query.deadEndDateFrom)))
		#set($action = $action.addQueryData('deadEndDateTo', $utils.formatDate($query.deadEndDateTo)))
		#set($action = $action.addQueryData('updateDateFrom', $utils.formatDate($query.updateDateFrom)))
		#set($action = $action.addQueryData('updateDateTo', $utils.formatDate($query.updateDateTo)))
		#set($action = $action.addQueryData('createDateFrom', $utils.formatDate($query.createDateFrom)))
		#set($action = $action.addQueryData('createDateTo', $utils.formatDate($query.createDateTo)))
	#end
#end
######################################
#macro (prepareSearchTaskActionPlain $action $query)
	#setBasicOfSearchQuery($action $query)
#end
######################################
#macro (prepareSearchTaskAction $action $query $pager)
	#setBasicOfSearchQuery($action $query)
	#if($pager)
		#set($action = $action.addQueryData('limit', $pager.limit))
		#set($action = $action.addQueryData('offset', $pager.offset))
	#end
#end
######################################
#macro (prepareSearchTaskActionForOrder $action $query $pager $order)
	#setBasicOfSearchQuery($action $query)
	#setDefaultPagerOfSearchQuery($action $pager)

	#set($action = $action.addQueryData('order', $order))
#end
######################################
#macro (sortImage $query $asc_order $desc_order)
	#if($query.hasOrder($asc_order))
		<img src="$link.setRelative('/resources/skin/default/image/icon/order_asc.png')" />
	#elseif($query.hasOrder($desc_order))
		<img src="$link.setRelative('/resources/skin/default/image/icon/order_desc.png')" />
	#end
#end
