1 package net.sourceforge.blogentis.storage.impl;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
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 }