View Javadoc

1   package net.sourceforge.blogentis.storage.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: StorageNavigationExtension.java,v 1.3 2004/11/01 22:45:23 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  import net.sourceforge.blogentis.utils.BlogConstants;
33  
34  /***
35   * Extension to merge storage-related ling to navigations.
36   * 
37   * @author abas
38   */
39  public class StorageNavigationExtension
40          extends AbstractNavigationExtension {
41      public static final String MEDIA_LIST_NAME = "MediaList";
42      public static final String TEMPLATE_LIST_NAME = "TemplateList";
43      private static final TargetAuthenticator admin = new TargetAuthenticator(
44          BlogConstants.PERM_ADMIN_BLOG);
45  
46      private static final LinkToTemplate[] adminPages = new LinkToTemplate[] {
47              new LinkToTemplate("BlogFiles", "Templates", admin),
48              new LinkToTemplate("BlogMedia", "Media Files", admin)};
49  
50      private static final LinkToTemplate[] templatePages = new LinkToSplitPage[] {
51              new LinkToSplitPage("BlogFiles", "List Templates", "0", admin),
52              new LinkToSplitPage("BlogFiles", "New Template", "1", admin),
53              new LinkToSplitPage("BlogFiles", "Add/Replace Image", "2", admin),
54              new LinkToSplitPage("BlogFiles", "Backup Templates", "3", admin),
55              new LinkToSplitPage("BlogFiles", "Restore Templates", "4", admin)};
56  
57      private static final LinkToTemplate[] mediaPages = new LinkToSplitPage[] {
58              new LinkToSplitPage("BlogMedia", "List Files", "0", admin),
59              /* new LinkToSplitPage("BlogMedia", "Add File", "2"), */
60              new LinkToSplitPage("BlogMedia", "Backup Files", "3", admin),
61              new LinkToSplitPage("BlogMedia", "Restore Files", "4", admin)};
62  
63      private static final List mediaList = Arrays.asList(mediaPages),
64              templateList = Arrays.asList(templatePages), adminList = Arrays
65                      .asList(adminPages);
66  
67      public StorageNavigationExtension(IPlugin plugin, Blog blog) {
68          super(plugin, blog);
69      }
70  
71      public String getName() {
72          return "Storage management additions to navigation";
73      }
74  
75      public void addNavigations(BlogRunData data, String navName, List links) {
76          super.addNavigations(data, navName, links);
77          if (ADMIN_LIST_NAME.equals(navName)) {
78              links.addAll(adminList);
79          } else if (TEMPLATE_LIST_NAME.equals(navName)) {
80              links.addAll(templateList);
81          } else if (MEDIA_LIST_NAME.equals(navName)) {
82              links.addAll(mediaList);
83          }
84      }
85  }