Package org.apache.roller.weblogger.pojos

Examples of org.apache.roller.weblogger.pojos.ThemeTemplate


       
        Map pages = new TreeMap();
       
        // first get the pages from the db
        try {
            ThemeTemplate template = null;
            Iterator dbPages = WebloggerFactory.getWeblogger().getWeblogManager()
                    .getPages(this.weblog).iterator();
            while(dbPages.hasNext()) {
                template = (ThemeTemplate) dbPages.next();
                pages.put(template.getName(), template);
            }
        } catch(Exception e) {
            // db error
            log.error(e);
        }
       
       
        // now get theme pages if needed and put them in place of db pages
        try {
            ThemeTemplate template = null;
            Iterator themePages = this.theme.getTemplates().iterator();
            while(themePages.hasNext()) {
                template = (ThemeTemplate) themePages.next();
               
                // note that this will put theme pages over custom
                // pages in the pages list, which is what we want
                pages.put(template.getName(), template);
            }
        } catch(Exception e) {
            // how??
            log.error(e);
        }
View Full Code Here


        // stylesheet is handled differently than other templates because with
        // the stylesheet we want to return the weblog custom version if it
        // exists, otherwise we return the shared theme version
       
        // load from theme first to see if we even support a stylesheet
        ThemeTemplate stylesheet = this.theme.getStylesheet();
        if(stylesheet != null) {
            // now try getting custom version from weblog
            ThemeTemplate override = WebloggerFactory.getWeblogger()
                    .getWeblogManager().getPageByLink(this.weblog, stylesheet.getLink());
            if(override != null) {
                stylesheet = override;
            }
        }
View Full Code Here

    public ThemeTemplate getTemplateByName(String name) throws WebloggerException {
       
        if(name == null)
            return null;
       
        ThemeTemplate template = null;
       
        // if name refers to the stylesheet then return result of getStylesheet()
        ThemeTemplate stylesheet = getStylesheet();
        if(stylesheet != null && name.equals(stylesheet.getName())) {
            return stylesheet;
        }
       
        // first check if this user has selected a theme
        // if so then return the proper theme template
View Full Code Here

    public ThemeTemplate getTemplateByLink(String link) throws WebloggerException {
       
        if(link == null)
            return null;
       
        ThemeTemplate template = null;
       
        // if name refers to the stylesheet then return result of getStylesheet()
        ThemeTemplate stylesheet = getStylesheet();
        if(stylesheet != null && link.equals(stylesheet.getLink())) {
            return stylesheet;
        }
       
        // first check if this user has selected a theme
        // if so then return the proper theme template
View Full Code Here

       
        MediaFileDirectory root = fileMgr.getMediaFileRootDirectory(website);
        log.warn("Weblog " + website.getHandle() + " does not have a root MediaFile directory");

        Set importedActionTemplates = new HashSet();
        ThemeTemplate themeTemplate = null;
        ThemeTemplate stylesheetTemplate = theme.getStylesheet();
        Iterator iter = theme.getTemplates().iterator();
        while (iter.hasNext()) {
            themeTemplate = (ThemeTemplate) iter.next();

            WeblogTemplate template = null;
View Full Code Here

   
   
    @Override
    public void myPrepare() {
       
        ThemeTemplate stylesheet = null;
        try {
            stylesheet = getActionWeblog().getTheme().getStylesheet();
        } catch (WebloggerException ex) {
            log.error("Error looking up stylesheet on weblog - "+getActionWeblog().getHandle(), ex);
        }
       
        if(stylesheet != null) {
            log.debug("custom stylesheet path is - "+stylesheet.getLink());
            try {
                setTemplate(WebloggerFactory.getWeblogger().getWeblogManager()
                        .getPageByLink(getActionWeblog(), stylesheet.getLink()));
               
                if(getTemplate() == null) {
                    log.debug("custom stylesheet not found, creating it");
                   
                    // template doesn't exist yet, so create it
                    WeblogTemplate stylesheetTmpl = new WeblogTemplate();
                    stylesheetTmpl.setWebsite(getActionWeblog());
                    stylesheetTmpl.setAction(stylesheet.ACTION_CUSTOM);
                    stylesheetTmpl.setName(stylesheet.getName());
                    stylesheetTmpl.setDescription(stylesheet.getDescription());
                    stylesheetTmpl.setLink(stylesheet.getLink());
                    stylesheetTmpl.setContents(stylesheet.getContents());
                    stylesheetTmpl.setHidden(false);
                    stylesheetTmpl.setNavbar(false);
                    stylesheetTmpl.setLastModified(new Date());
                    stylesheetTmpl.setTemplateLanguage(stylesheet.getTemplateLanguage());
                   
                    WebloggerFactory.getWeblogger().getWeblogManager().savePage(stylesheetTmpl);
                    WebloggerFactory.getWeblogger().flush();
                   
                    setTemplate(stylesheetTmpl);
View Full Code Here

      }
       
        }
       
        // go through templates and read in contents to a ThemeTemplate
        ThemeTemplate theme_template = null;
        ThemeMetadataTemplate templateMetadata = null;
        Iterator templatesIter = themeMetadata.getTemplates().iterator();
        while (templatesIter.hasNext()) {
            templateMetadata = (ThemeMetadataTemplate) templatesIter.next();
           
View Full Code Here

                mLogger.error("error getting weblog pages", ex);
            }
           
            Iterator pageIter = pages.iterator();
            while (pageIter.hasNext()) {
                ThemeTemplate page = (ThemeTemplate) pageIter.next();
                mPageMap.put(page.getName(),ThemeTemplateWrapper.wrap(page));
            }
        }
    }
View Full Code Here

        mLogger.debug("looking up page ["+pageName+"]");
       
        String template_id = null;
       
        try {
            ThemeTemplate pd = mWebsite.getTheme().getTemplateByName(pageName);
            if(pd != null) {
                template_id = pd.getId();
            }
        } catch(Exception e) {
            mLogger.error(e);
        }
       
View Full Code Here

        mLogger.debug("setupContext( ctx = "+ctx+")");
       
        Weblog weblog = null;
        WeblogEntry entry = null;
        WeblogCategory category = null;
        ThemeTemplate page = null;
        WeblogBookmarkFolder folder = null// don't even know how this is involved :/
        Date date = null;
        boolean isDay = false;
        boolean isMonth = false;
        String locale = null;
       
        // get data from page request
        locale = pageRequest.getLocale();
        weblog = pageRequest.getWeblog();
        entry = pageRequest.getWeblogEntry();
        category = pageRequest.getWeblogCategory();
        page = pageRequest.getWeblogPage();
        if(page == null) {
            page = weblog.getTheme().getDefaultTemplate();
        }
       
        // setup date, isDay, and isMonth
        if(pageRequest.getWeblogDate() != null) {
           
            Date now = new Date();
            if(pageRequest.getWeblogDate().length() == 8) {
                isDay = true;
                try {
                    date = DateUtil.get8charDateFormat().parse(pageRequest.getWeblogDate());
                    if(date.after(now)) {
                        date = now;
                    }
                } catch(Exception e) {
                    // bleh
                }
            } else if(pageRequest.getWeblogDate().length() == 6) {
                isMonth = true;
                try {
                    date = DateUtil.get6charDateFormat().parse(pageRequest.getWeblogDate());
                    if(date.after(now)) {
                        date = now;
                    }
                } catch(Exception e) {
                    // bleh
                }
            } else {
                isMonth = true;
            }
        }
       
        try {
            // Add old page model object to context
            OldWeblogPageModel pageModel = new OldWeblogPageModel();
            pageModel.init(urlStrategy,
                    request,
                    weblog,
                    entry,
                    category,
                    date,
                    isDay,
                    isMonth,
                    locale);
            ctx.put("pageModel", pageModel);
           
            // along with old pages list :/
            ctx.put("pages", pageModel.getPages());
           
        } catch (Exception e) {
            throw new WebloggerException("ERROR creating Page Model",e);
        }
       
        // Add page helper to context
        OldPageHelper pageHelper = new OldPageHelper(request,
                response,
                ctx,
                weblog,
                (date == null) ? new Date() : date,
                folder,
                page.getName(),
                pageContext,
                pageRequest);
        ctx.put("pageHelper", pageHelper);
       
        // Load standard Weblogger objects and values into the context
View Full Code Here

TOP

Related Classes of org.apache.roller.weblogger.pojos.ThemeTemplate

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.