#* Don't include this directly! Use ie. general-pagelist.vm or macro-pagelist.vm instead. *#

#set ($pageList = $stack.findValue($parameters.pages))
#set ($rawTitle = $!parameters.get('mytitle'))
#if ($rawTitle)
    #set ($labelValue = $i18n.getText($rawTitle) )
#end
#if (!$labelValue)
    #set ($labelValue = $!rawTitle)
#end

#if ("$!labelValue" != "")
<div class="tabletitle" style="width: $tableWidth">
    #if ($showmore || $showless || $showrss)
        <div style="float:right;" valign="bottom" class="tabletitleops">
            &nbsp;
            #if ($showrss)
                <a href="$req.contextPath/spaces/rss.action?key=$generalUtil.urlEncode($space.key)"><img border="0" src="$staticResourceUrlPrefix/images/icons/rss.gif" title="RSS"></a>
                &nbsp;
            #end
            #if ($showless)
                <a href="$showless"><img border="0" width="12" height="12" src="$staticResourceUrlPrefix/images/icons/subtract_16.gif" title="$textShowLess"></a>
            #end
            #if ($showmore)
                <a href="$showmore"><img border="0" width="12" height="12" src="$staticResourceUrlPrefix/images/icons/add_16.gif" title="$textShowMore"></a>
            #end
        </div>
    #end
    #if ("$!labelValue" != "")
        $labelValue
    #else
        &nbsp;
    #end
</div>
#end

<table width="$tableWidth" cellspacing="1"  border="0" class="tableview">
    #if( !$pageList || $pageList.size()==0 )
    <tr>
        <td colspan="3">
            $thereAreNoPages
        </td>
    </tr>
    #else
        #if ($textUtils.stringSet($statusMessage))
        <tr>
            <td>$statusMessage</td>
        </tr>
        #end
        #if ($textUtils.stringSet($pageListDescription))
        <tr>
            <td>$pageListDescription</td>
        </tr>
        #end
        #foreach ($page in $pageList)
            #if ($previousLoginDate && $page.lastModificationDate.after($previousLoginDate))
                #if( $page.isNew() )
                    #set ($colorHtml = 'style="color: #008800"')
                #elseif( $page.lastModificationDate )
                    #set ($colorHtml = 'style="color: #008800"')
                #end
            #else
                #set ($colorHtml = "")
            #end
            <tr>
                <td>
                    #if ($showModifier == true)
                    <div style="float:right;" class="smalltext">
                         by
                        #if ($parentWindow)
                            #usernameLinkParentWindow ($page.lastModifierName)
                        #else
                            #usernameLink ($page.lastModifierName)
                        #end

                        (#if ($generalUtil.isInLastDays($page.lastModificationDate, 1))$generalUtil.getRelativeTime($page.lastModificationDate)#else$generalUtil.getFormatDateSimple($page.lastModificationDate)#end)
                    </div>
                    #end

                    #set ($linkHref = "$req.contextPath$page.urlPath")
                    <a $colorHtml href="$req.contextPath$page.urlPath" title="$webwork.htmlEncode($page.displayTitle)">#contentIcon2($page $colorHtml $linkHref $webwork.htmlEncode($page.displayTitle))</a>

                    #if ($parentWindow)
                        <a $colorHtml href="$req.contextPath$page.urlPath" onClick="javascript:window.opener.location=this.href; window.close();">$webwork.htmlEncode($page.displayTitle)</a>
                    #else
                        #if ($insertLink)
                            #if ($page.type == 'blogpost')
                                <a $colorHtml href="#" onClick="populateDestinationLinkField('$generalUtil.htmlEscapeQuotes($page.space.key):/$page.getDatePath()/$generalUtil.htmlEscapeQuotes($page.title)')">$webwork.htmlEncode($page.displayTitle)</a>
                            #elseif ($page.type == 'mail')
                                <a $colorHtml href="#" onClick="populateDestinationLinkField('$$page.id')">$webwork.htmlEncode($page.displayTitle)</a>
                            #elseif ($page.type == 'attachment')
                                <a $colorHtml href="#" onClick="populateDestinationLinkField('$generalUtil.htmlEscapeQuotes($page.content.space.key):${page.content.title}^$page.displayTitle')">$webwork.htmlEncode($page.displayTitle)</a>
                            #else
                                <a $colorHtml href="#" onClick="populateDestinationLinkField('$generalUtil.htmlEscapeQuotes($page.space.key):$generalUtil.htmlEscapeQuotes(${page.title})')">$webwork.htmlEncode($page.displayTitle)</a>
                            #end
                        #else
                            #if($page.type == "status")
                                <a $colorHtml href="$req.contextPath$page.urlPath" title="$webwork.htmlEncode($page.displayTitle)">$webwork.htmlEncode($page.displayTitle)</a>
                            #else
                                <a $colorHtml href="$req.contextPath$page.urlPath" title="$webwork.htmlEncode($page.displayTitle)">$webwork.htmlEncode($generalUtil.trimDownStringToWord($page.displayTitle))</a>
                            #end
                        #end
                    #end

                    #if ($contentOther)
                        <span class="smalltext">#contentOther($page)</span>
                    #end
                    #if ($displayPageSummaries && $displayPageSummaries == 'true')
                        #if ($page.content && $page.content.length() > 0)
                            <div class="smalltext" style="padding: 3px 0 0 0;">$webwork.htmlEncode($generalUtil.summarise($page.content))</div>
                        #end
                    #end
                    #if ($displayChangeComments && $displayChangeComments == true)
                        #if ($page.isVersionCommentAvailable() == true)
                            <div class="smalltext" style="padding: 3px 0 0 22px;">$page.renderedVersionComment</div>
                        #end
                        #if ($page.getComment())
                            <div class="smalltext" style="padding: 3px 0 0 22px;">$page.getComment()</div>
                        #end
                    #end
                </td>
            </tr>
        #end
    #end
</table>
