View Javadoc

1   package net.sourceforge.blogentis.plugins.impl;
2   
3   //-----------------------------------------------------------------------
4   //Blogentis - a blog publishing platform.
5   //Copyright (C) 2004 Tassos Bassoukos <abassouk@gmail.com>
6   //
7   //This library is free software; you can redistribute it and/or
8   //modify it under the terms of the GNU Lesser General Public
9   //License as published by the Free Software Foundation; either
10  //version 2.1 of the License, or (at your option) any later version.
11  //
12  //This library is distributed in the hope that it will be useful,
13  //but WITHOUT ANY WARRANTY; without even the implied warranty of
14  //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  //Lesser General Public License for more details.
16  //
17  //You should have received a copy of the GNU Lesser General Public
18  //License along with this library; if not, write to the Free Software
19  //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  //-----------------------------------------------------------------------
21  //
22  //$Id: BasicNavigationExtension.java,v 1.4 2004/11/02 00:58:50 tassos Exp $
23  //
24  
25  import java.util.Arrays;
26  import java.util.List;
27  
28  import net.sourceforge.blogentis.om.Blog;
29  import net.sourceforge.blogentis.plugins.IPlugin;
30  import net.sourceforge.blogentis.plugins.base.AbstractNavigationExtension;
31  import net.sourceforge.blogentis.turbine.BlogRunData;
32  
33  /***
34   * This extension adds the basic navigations
35   * 
36   * @author abas
37   */
38  public class BasicNavigationExtension
39          extends AbstractNavigationExtension {
40      public BasicNavigationExtension(IPlugin plugin, Blog blog) {
41          super(plugin, blog);
42      }
43  
44      private static final LinkToTemplate[] adminPages = new LinkToTemplate[] {
45              new LinkToTemplate("BlogUsers", "Users", BlogAdminAuthenticator),
46              new LinkToTemplate("BlogSections", "Sections",
47                  BlogAdminAuthenticator),
48              new LinkToTemplate("BlogPlugins", "Plugins", BlogAdminAuthenticator),
49              new LinkToTemplate("BlogProperties", "Settings",
50                  BlogAdminAuthenticator)};
51  
52      private static final LinkToTemplate[] blogSettingsPages = new LinkToSplitPage[] {
53              new LinkToSplitPage("BlogProperties", "Appearance", "0",
54                  BlogAdminAuthenticator),
55              new LinkToSplitPage("BlogSideboxes", "Sideboxes", "0",
56                  BlogAdminAuthenticator),
57              new LinkToSplitPage("BlogComments", "Comments", "0",
58                  BlogAdminAuthenticator)};
59  
60      private static final LinkToTemplate[] appearancePages = new LinkToSplitPage[] {
61              new LinkToSplitPage("BlogProperties", "Blog Name", "0",
62                  BlogAdminAuthenticator),
63              new LinkToSplitPage("BlogProperties", "Main Page", "1",
64                  BlogAdminAuthenticator),
65              new LinkToSplitPage("BlogProperties", "Section Appearance", "2",
66                  BlogAdminAuthenticator),
67              new LinkToSplitPage("BlogProperties", "Post View", "3",
68                  BlogAdminAuthenticator)};
69  
70      private static final LinkToTemplate[] sideboxPages = new LinkToSplitPage[] {
71              new LinkToSplitPage("BlogSideboxes", "Recent Comments", "0",
72                  BlogAdminAuthenticator),
73              new LinkToSplitPage("BlogSideboxes", "Recent Posts", "1",
74                  BlogAdminAuthenticator)};
75  
76      private static final List adminList = Arrays.asList(adminPages),
77              blogSettingsList = Arrays.asList(blogSettingsPages),
78              appearanceList = Arrays.asList(appearancePages),
79              sideboxList = Arrays.asList(sideboxPages);
80  
81      public void addNavigations(BlogRunData data, String navName, List links) {
82          if (!BlogAdminAuthenticator.isVisible(data))
83              return;
84          if (ADMIN_LIST_NAME.equals(navName)) {
85              links.addAll(adminList);
86          } else if (BLOG_SETTINGS_NAME.equals(navName)) {
87              links.addAll(blogSettingsList);
88          } else if (APPEARANCE_LIST_NAME.equals(navName)) {
89              links.addAll(appearanceList);
90          } else if (SIDEBOX_LIST_NAME.equals(navName)) {
91              links.addAll(sideboxList);
92          }
93      }
94  
95      public String getName() {
96          return "Basic Navigation Support";
97      }
98  }