1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.devacfr.maven.skins.reflow.model;
20
21 import static java.util.Objects.requireNonNull;
22
23 import java.util.List;
24
25 import javax.annotation.Nonnull;
26
27 import org.apache.maven.doxia.site.SiteModel;
28 import org.codehaus.plexus.util.xml.Xpp3Dom;
29 import org.devacfr.maven.skins.reflow.ISkinConfig;
30
31 import com.google.common.base.Strings;
32 import com.google.common.collect.Lists;
33
34
35
36
37
38
39
40 public class Footer extends BsComponent {
41
42
43 private static final String COMPONENT = "footer";
44
45
46 private final List<Column> columns = Lists.newArrayList();
47
48
49
50
51
52
53
54 public Footer(@Nonnull final ISkinConfig config) {
55 super(COMPONENT);
56 requireNonNull(config);
57 this.setTheme(config.getAttributeValue(COMPONENT, "theme", String.class, "light"));
58 this.setBackground(config.getAttributeValue(COMPONENT, "background", String.class, "light"));
59 this.setCssClass(config.getAttributeValue(COMPONENT, "cssClass", String.class, null));
60
61 final Xpp3Dom bottomNav = config.get("bottomNav");
62 final SiteModel model = config.getSiteModel();
63
64 if (model.getBody() != null && model.getBody().getMenus() != null) {
65 final List<org.apache.maven.doxia.site.Menu> menus = model.getBody().getMenus();
66 if (bottomNav != null && bottomNav.getChildren().length > 0) {
67
68 for (final Xpp3Dom col : bottomNav.getChildren()) {
69 final String regex = col.getValue();
70 if (Strings.isNullOrEmpty(regex)) {
71 continue;
72 }
73 final List<Menu> amenus = Lists.newArrayList();
74 for (final org.apache.maven.doxia.site.Menu menu : menus) {
75
76 if (Menu.matches(regex, menu)) {
77 amenus.add(new Menu(config, menu));
78 }
79 }
80 this.columns.add(new Column(config, amenus));
81 }
82 } else {
83 final List<Menu> amenus = Lists.newArrayList();
84 for (final org.apache.maven.doxia.site.Menu menu : menus) {
85 amenus.add(new Menu(config, menu));
86 }
87 this.columns.add(new Column(config, amenus));
88 }
89 }
90 }
91
92
93
94
95 public List<Column> getColumns() {
96 return columns;
97 }
98
99
100
101
102
103 public static class Column {
104
105
106 private final List<Menu> menus;
107
108
109
110
111
112
113
114 public Column(@Nonnull final ISkinConfig config, @Nonnull final List<Menu> menus) {
115 requireNonNull(config);
116 requireNonNull(menus);
117 this.menus = menus;
118 }
119
120
121
122
123 public List<Menu> getMenus() {
124 return menus;
125 }
126 }
127 }