Package org.apache.roller.weblogger.business.themes

Examples of org.apache.roller.weblogger.business.themes.ThemeManager


    public Theme getTheme() {
       
        if(theme == null && themeName != null) {
            try {
                ThemeManager themeMgr = WebloggerFactory.getWeblogger().getThemeManager();
                theme = themeMgr.getTheme(themeName);
            } catch(ThemeNotFoundException tnfe) {
                // bogus theme specified ... don't worry about it
            } catch(WebloggerException re) {
                log.error("Error looking up theme "+themeName, re);
            }
View Full Code Here


     * Get the Theme object in use by this weblog, or null if no theme selected.
     */
    public WeblogTheme getTheme() {
        try {
            // let the ThemeManager handle it
            ThemeManager themeMgr = WebloggerFactory.getWeblogger().getThemeManager();
            return themeMgr.getTheme(this);
        } catch (WebloggerException ex) {
            log.error("Error getting theme for weblog - "+getHandle(), ex);
        }
       
        // TODO: maybe we should return a default theme in this case?
View Full Code Here

        }
    }
   
   
    public List getThemes() {
        ThemeManager themeMgr = WebloggerFactory.getWeblogger().getThemeManager();
        return themeMgr.getEnabledThemesList();
    }
View Full Code Here

        return WeblogPermission.ADMIN;
    }
   
   
    public void myPrepare() {
        ThemeManager themeMgr = WebloggerFactory.getWeblogger().getThemeManager();
        setThemes(themeMgr.getEnabledThemesList());
    }
View Full Code Here

            if(WebloggerRuntimeConfig.getBooleanProperty("themes.customtheme.allowed")) {
               
                // do theme import if necessary
                SharedTheme importTheme = null;
                if(isImportTheme() && !StringUtils.isEmpty(getImportThemeId())) try {
                    ThemeManager themeMgr = WebloggerFactory.getWeblogger().getThemeManager();
                    importTheme = themeMgr.getTheme(getImportThemeId());
                    themeMgr.importTheme(getActionWeblog(), importTheme);
                } catch(WebloggerException re) {
                    log.error("Error customizing theme for weblog - "+getActionWeblog().getHandle(), re);
                    // TODO: i18n
                    addError("Error importing theme");
                }
               
                if(!hasActionErrors()) try {
                    weblog.setEditorTheme(WeblogTheme.CUSTOM);
                    log.debug("Saving custom theme for weblog "+weblog.getHandle());
                   
                    // save updated weblog and flush
                    UserManager userMgr = WebloggerFactory.getWeblogger().getUserManager();
                    userMgr.saveWebsite(weblog);
                    WebloggerFactory.getWeblogger().flush();
                   
                    // make sure to flush the page cache so ppl can see the change
                    CacheManager.invalidate(weblog);
                   
                    // TODO: i18n
                    addMessage("Successfully set theme to - "+WeblogTheme.CUSTOM);
                    if(importTheme != null) {
                        addMessage("Successfully copied templates from theme - "+importTheme.getName());
                    }
                   
                    // reset import theme options
                    setImportTheme(false);
                    setImportThemeId(null);
                   
                } catch(WebloggerException re) {
                    log.error("Error saving weblog - "+getActionWeblog().getHandle(), re);
                    addError("Error setting theme");
                }
            } else {
                // TODO: i18n
                addError("Sorry, custom themes are not allowed");
            }
           
        // we are dealing with a shared theme scenario
        } else if("shared".equals(getThemeType())) {
           
            // make sure theme is valid and enabled
            Theme newTheme = null;
            if(getThemeId() == null) {
                // TODO: i18n
                addError("No theme specified");
               
            } else {
                try {
                    ThemeManager themeMgr = WebloggerFactory.getWeblogger().getThemeManager();
                    newTheme = themeMgr.getTheme(getThemeId());
                   
                    if(!newTheme.isEnabled()) {
                        // TODO: i18n
                        addError("Theme not enabled");
                    }
View Full Code Here

        if(!hasActionErrors()) try {
           
            WeblogTemplate stylesheet = getTemplate();
           
            // lookup the theme used by this weblog
            ThemeManager tmgr = WebloggerFactory.getWeblogger().getThemeManager();
            Theme theme = tmgr.getTheme(getActionWeblog().getEditorTheme());
           
            // lookup
            stylesheet.setLastModified(new Date());
            stylesheet.setContents(theme.getStylesheet().getContents());
           
View Full Code Here

        InputStream resourceStream = null;
        String previewImagePath = null;
       
        // try looking up selected theme
        try {
            ThemeManager tmgr = WebloggerFactory.getWeblogger().getThemeManager();
            SharedTheme previewTheme = tmgr.getTheme(theme);
            ThemeResource previewImage = previewTheme.getPreviewImage();
            if(previewImage != null) {
                previewImagePath = previewImage.getPath();
                resourceLastMod = previewImage.getLastModified();
                resourceStream = previewImage.getInputStream();
View Full Code Here

        }

        // Development only. Reload if theme has been modified
    if (themeReload) {
      try {
        ThemeManager manager = WebloggerFactory.getWeblogger().getThemeManager();
        boolean reloaded = manager.reLoadThemeFromDisk(weblog.getEditorTheme());
        if (reloaded) {
          if (WebloggerRuntimeConfig.isSiteWideWeblog(searchRequest.getWeblogHandle())) {
            SiteWideCache.getInstance().clear();
          } else {
            WeblogPageCache.getInstance().clear();
View Full Code Here

        }
       
        // Development only. Reload if theme has been modified
    if (themeReload) {
      try {
        ThemeManager manager = WebloggerFactory.getWeblogger().getThemeManager();
        boolean reloaded = manager.reLoadThemeFromDisk(weblog.getEditorTheme());
        if (reloaded) {
          if (isSiteWide) {
            siteWideCache.clear();
          } else {
            weblogPageCache.clear();
View Full Code Here

            String[] split = name.split(":", 2);
            if(split.length < 2)
                throw new ResourceNotFoundException("Invalid ThemeRL key "+name);
           
            // lookup the template from the proper theme
            ThemeManager themeMgr = WebloggerFactory.getWeblogger().getThemeManager();
            Theme theme = themeMgr.getTheme(split[0]);
            ThemeTemplate template = theme.getTemplateByName(split[1]);
           
            if(template == null)
                throw new ResourceNotFoundException("Template ["+split[1]+
                        "] doesn't seem to be part of theme ["+split[0]+"]");
View Full Code Here

TOP

Related Classes of org.apache.roller.weblogger.business.themes.ThemeManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.