#* DECORATOR FOR SPACE LEVEL INFORMATION
This decorator handles many contexts - pages, mail, blogposts, templates, space-operations, and space-administration.
*#

#set ($helper   = $params.get("helper"))
#set ($mode     = $params.get("mode"))
#set ($context  = $params.get("context"))
#set ($view-blogposts-date-mode = $params.get("view-blogposts-date-mode"))
#set ($confPage = $helper.page)

#infoPanelInitFromParams()
## GENERAL PAGE DECORATING BEGINS

#requireResourcesForContext("space")

#parse ("/decorators/includes/space-navigation.vm")

#if ($infoPanelRequired)
<content tag="sidebar">
    #infoPanel(true true true true)
</content>
#end

<div id="content" class="space $!context $!mode">
    #parse ( "/template/includes/actionerrors.vm" )

    ## CONTEXT SPECIFIC DECORATING BEGINS
    ## CONTEXT: "space-pages". MODES: "list-alphabetically", "list-recently-added", "list-content-tree"
    #if ($context == "space-pages")
        #if ($mode != "create-page")
           #permitSearchEngines()
            ## Show current mode
            <div class="greyLinks" align="left">
                $action.getText('view.name'):
                #foreach ($item in $webInterfaceManager.getDisplayableItems("system.space.pages", $action.webInterfaceContext))
                    #if ($velocityCount != 1) | #end
                    #if ($mode == $item.key)
                        <span style="padding: 5px; background-color: #f0f0f0;"><strong>$item.label.getDisplayableLabel($req, $action.webInterfaceContext)</strong></span>
                    #else
                        <a href="$item.link.getDisplayableUrl($req, $action.webInterfaceContext)">$item.label.getDisplayableLabel($req, $action.webInterfaceContext)</a>
                    #end
                #end
            </div>

            $body

        #else
            $body
        #end

    ## CONTEXT: "mail". MODES: "view-mail-archive"
    #elseif ($context == "space-mails")
        #permitSearchEngines()
        #if ($mode == "view-mail-archive")
                $body
        #end

    ## CONTEXT: "blogposts". MODES: "view-blogposts", "create-blogpost"
    #elseif ($context == "space-blogposts")
        #if ($mode == "view-blogposts")
         #permitSearchEngines()
            #if ($blogPosts.size() == 0)
                #if ($view-blogposts-date-mode == "true")
                    <p>$helper.getText("no.posts.found.for.date")</p>
                #else
                    <p>$helper.getText("no.posts.found")</p>
                #end
            #else
                #set ($dateString = "Blah")
                #foreach ($blog in $blogPosts)
                    #if ($dateString != $blog.datePath)
                        <div class="blogSurtitle">
                            <img src="$staticResourceUrlPrefix/images/icons/blogentry_16.gif" height="16" width="16" border="0" align="absmiddle">&nbsp;
                            <span class="blogDate">$blog.datePath</span>
                        </div>
                    #end
                    #set ($dateString = $blog.datePath)

                    <div class="blogpost" style="margin-bottom: 30px">
                        <a class="blogHeading" href="$req.contextPath$generalUtil.getPageUrl($blog)">$blog.title</a>

                        <div class="pagesubheading">
                            #if ($blog.creationDate != $blog.lastModificationDate)
                                Last changed: $helper.action.dateFormatter.formatDateTime( $blog.lastModificationDate ) by #usernameLink($blog.lastModifierName)
                            #end
                            #if ($blog.getLabelsForDisplay($user).size() > 0)
                                #if ($blog.creationDate != $blog.lastModificationDate)<br/>#end
                                Labels: #labels($blog.getLabelsForDisplay($user))
                            #end
                        </div>
                            <div class="wiki-content">
                            $helper.action.renderBlogPost($blog)
                            </div>
                            #if ($param.get("contentType") == "excerpts")
                                <p><a href="$req.contextPath$generalUtil.getPageUrl($post)" title="Read the rest of $generalUtil.escapeXml($post.title)">Read more...</a></p>
                            #end
                        <div class="endsection">
                            <strong>Posted at $helper.action.dateFormatter.formatBlogDate($blog.creationDate)</strong> by
                            <img src="$staticResourceUrlPrefix/images/icons/user_16.gif" height="16" width="16" border="0" align="absmiddle" title="User Profile: $webwork.htmlEncode($action.getUserFullName($blog.creatorName))">
                            #usernameLink($blog.creatorName)
                            |
                            <img src="$staticResourceUrlPrefix/images/icons/comment_16.gif" height="16" width="16" border="0" align="absmiddle">
                                <a href="$req.contextPath$generalUtil.customGetPageUrl($blog)showComments=true#comments">
                                #if ($blog.comments.size() > 0)
                                    $blog.comments.size()
                                    #if ($blog.comments.size() > 1)
                                        $action.getText("comment.plural")</a>
                                    #else
                                        $action.getText("comment.singular")</a>
                                    #end
                                #else
                                    $action.getText("comment.none")</a>
                                #end
                            #if( $permissionCheckDispatcher.isPermitted("/pages/editblogpost.action?pageId=$blog.id") )
                            |
                                   <a href="$req.contextPath/pages/editblogpost.action?pageId=$blog.id">$action.getText("edit.name")</a>
                            #end

                        </div>
                    </div>
                #end
                <p>
            #end
            <content tag="sidebar">
                <form class="quick-search" id="space-blog-quick-search" method="get" action="$req.contextPath/dosearchsite.action">
                    <fieldset>
                        <legend>$action.getText('quick.search.legend')</legend>
                        <input class="quick-search-query" id="space-blog-search-query" type="text" accessKey="$action.getTextStrict('search-pages-action.accesskey')" autocomplete="off" name="queryString" />
                        <input class="quick-search-submit" id="space-blog-search-submit" type="submit" value="$quickSearchPlaceholder" />
                        <input type="hidden" name="type" value="blogpost" />
                        <input type="hidden" name="where" value="$helper.spaceKey" />
                    </fieldset>
                </form>
                <br />
                #if ($calendarForThisMonth)
                   #blogPostsCalendarWithDateLinks($action true)
                #end
            </content>

        #elseif ($mode == "create-blogpost")
            $body
        #end

    ## CONTEXT: "templates". MODES: "view-templates"
    #elseif ($context == "space-templates")
        #if ($mode == "view-templates")

             <div style="padding: 0px 10px 10px 10px">
                $body
            </div>
        #end

    ## DEFAULT: no additional markup
    #else
        $body
    #end
    ## CONTEXT * MODE SPECIFIC DECORATING ENDS

</div>

## GENERAL PAGE DECORATING ENDS

#parse ( "/breadcrumbs.vm" )

#if ($helper.spaceKey)
    <content tag="spacename">$helper.spaceName</content>
    <content tag="spacekey">$helper.spaceKey</content>
    <content tag="spaceaction">true</content>
#end

#menuMacros_renderBrowseMenu()
