001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. The ASF licenses this file to You
004: * under the Apache License, Version 2.0 (the "License"); you may not
005: * use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License. For additional information regarding
015: * copyright in this work, please see the NOTICE file in the top level
016: * directory of this distribution.
017: */
018:
019: package org.apache.roller.ui.rendering.model;
020:
021: import java.net.MalformedURLException;
022: import java.util.Arrays;
023: import java.util.HashMap;
024: import java.util.List;
025: import java.util.Map;
026: import org.apache.commons.logging.Log;
027: import org.apache.commons.logging.LogFactory;
028: import org.apache.roller.RollerException;
029: import org.apache.roller.config.RollerRuntimeConfig;
030: import org.apache.roller.pojos.wrapper.WeblogEntryDataWrapper;
031: import org.apache.roller.pojos.wrapper.WebsiteDataWrapper;
032: import org.apache.roller.ui.core.RequestConstants;
033: import org.apache.roller.ui.core.RollerContext;
034: import org.apache.struts.util.RequestUtils;
035:
036: /**
037: * Model which provides access to application config data like site
038: * config properties.
039: */
040: public class ConfigModel implements Model {
041:
042: private static Log log = LogFactory.getLog(ConfigModel.class);
043:
044: /** Template context name to be used for model */
045: public String getModelName() {
046: return "config";
047: }
048:
049: /** Init model */
050: public void init(Map map) throws RollerException {
051: // no-op
052: }
053:
054: public String getSiteName() {
055: return getProperty("site.name");
056: }
057:
058: public String getSiteShortName() {
059: return getProperty("site.shortName");
060: }
061:
062: public String getSiteDescription() {
063: return getProperty("site.description");
064: }
065:
066: public String getSiteEmail() {
067: return getProperty("site.adminemail");
068: }
069:
070: public boolean getRegistrationEnabled() {
071: return getBooleanProperty("users.registration.enabled");
072: }
073:
074: public String getRegistrationURL() {
075: return getProperty("users.registration.url");
076: }
077:
078: public int getFeedSize() {
079: return getIntProperty("site.newsfeeds.defaultEntries");
080: }
081:
082: public int getFeedMaxSize() {
083: return getIntProperty("site.newsfeeds.defaultEntries");
084: }
085:
086: public boolean getFeedStyle() {
087: return getBooleanProperty("site.newsfeeds.styledFeeds");
088: }
089:
090: public boolean getCommentAutoFormat() {
091: return getBooleanProperty("users.comments.autoformat");
092: }
093:
094: public boolean getCommentEscapeHtml() {
095: return getBooleanProperty("users.comments.escapehtml");
096: }
097:
098: public boolean getCommentEmailNotify() {
099: return getBooleanProperty("users.comments.emailnotify");
100: }
101:
102: public boolean getTrackbacksEnabled() {
103: return getBooleanProperty("users.trackbacks.enabled");
104: }
105:
106: /** Get Roller version string */
107: public String getRollerVersion() {
108: return RollerContext.getRollerContext().getRollerVersion();
109: }
110:
111: /** Get timestamp of Roller build */
112: public String getRollerBuildTimestamp() {
113: return RollerContext.getRollerContext().getRollerBuildTime();
114: }
115:
116: /** Get username who created Roller build */
117: public String getRollerBuildUser() {
118: return RollerContext.getRollerContext().getRollerBuildUser();
119: }
120:
121: private String getProperty(String name) {
122: return RollerRuntimeConfig.getProperty(name);
123: }
124:
125: private int getIntProperty(String name) {
126: return RollerRuntimeConfig.getIntProperty(name);
127: }
128:
129: private boolean getBooleanProperty(String name) {
130: return RollerRuntimeConfig.getBooleanProperty(name);
131: }
132:
133: }
|