@Override public void execute( Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { Integer folderId = Integer.parseInt(params.get("folderId").toString()); try { Folder folder = folderService.getFolderById(folderId); env.setVariable("tag_folder", DEFAULT_WRAPPER.wrap(folder)); } catch (FolderNotFoundException e) { env.setVariable("tag_folder", DEFAULT_WRAPPER.wrap(new Folder())); } body.render(env.getOut()); }
@SuppressWarnings("unchecked") public void execute( Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { CmsSite site = FrontUtils.getSite(env); List<ContentTag> list = contentTagMng.getListForTag(FrontUtils.getCount(params)); Map<String, TemplateModel> paramWrap = new HashMap<String, TemplateModel>(params); paramWrap.put(OUT_LIST, DEFAULT_WRAPPER.wrap(list)); Map<String, TemplateModel> origMap = DirectiveUtils.addParamsToVariable(env, paramWrap); InvokeType type = DirectiveUtils.getInvokeType(params); String listStyle = DirectiveUtils.getString(PARAM_STYLE_LIST, params); if (InvokeType.sysDefined == type) { if (StringUtils.isBlank(listStyle)) { throw new ParamsRequiredException(PARAM_STYLE_LIST); } env.include(TPL_STYLE_LIST + listStyle + TPL_SUFFIX, UTF8, true); } else if (InvokeType.userDefined == type) { if (StringUtils.isBlank(listStyle)) { throw new ParamsRequiredException(PARAM_STYLE_LIST); } FrontUtils.includeTpl(TPL_STYLE_LIST, site, env); } else if (InvokeType.custom == type) { FrontUtils.includeTpl(TPL_NAME, site, params, env); } else if (InvokeType.body == type) { body.render(env.getOut()); } else { throw new RuntimeException("invoke type not handled: " + type); } DirectiveUtils.removeParamsFromVariable(env, paramWrap, origMap); }
@SuppressWarnings("unchecked") public void execute( Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { CmsSite site = FrontUtils.getSite(env); InvokeType type = DirectiveUtils.getInvokeType(params); Pagination page = bbsTopicMng.getMemberTopic( site.getId(), getCreaterId(params), FrontUtils.getPageNo(env), FrontUtils.getCount(params)); Map<String, TemplateModel> paramWrap = new HashMap<String, TemplateModel>(params); paramWrap.put(OUT_PAGINATION, DEFAULT_WRAPPER.wrap(page)); Map<String, TemplateModel> origMap = DirectiveUtils.addParamsToVariable(env, paramWrap); if (InvokeType.custom == type) { FrontUtils.includeTpl(TPL_MY_TOPIC, site, params, env); FrontUtils.includePagination(site, params, env); } else if (InvokeType.body == type) { body.render(env.getOut()); FrontUtils.includePagination(site, params, env); } else { throw new RuntimeException("invoke type not handled: " + type); } DirectiveUtils.removeParamsFromVariable(env, paramWrap, origMap); }
@SuppressWarnings("unchecked") public void execute( Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { Integer siteId = getSiteId(params); if (siteId == null) { siteId = FrontUtils.getSite(env).getId(); } List<CmsFriendlinkCtg> list = cmsFriendlinkCtgMng.getList(siteId); Map<String, TemplateModel> paramWrap = new HashMap<String, TemplateModel>(params); paramWrap.put(OUT_LIST, DEFAULT_WRAPPER.wrap(list)); Map<String, TemplateModel> origMap = DirectiveUtils.addParamsToVariable(env, paramWrap); body.render(env.getOut()); DirectiveUtils.removeParamsFromVariable(env, paramWrap, origMap); }
@SuppressWarnings("unchecked") public void execute( Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { CmsSite site = FrontUtils.getSite(env); Integer parentId = DirectiveUtils.getInt(PARAM_PARENT_ID, params); Integer siteId = DirectiveUtils.getInt(PARAM_SITE_ID, params); boolean hasContentOnly = getHasContentOnly(params); Pagination page; if (parentId != null) { page = channelMng.getChildPageForTag( parentId, hasContentOnly, FrontUtils.getPageNo(env), FrontUtils.getCount(params)); } else { if (siteId == null) { siteId = site.getId(); } page = channelMng.getTopPageForTag( siteId, hasContentOnly, FrontUtils.getPageNo(env), FrontUtils.getCount(params)); } Map<String, TemplateModel> paramWrap = new HashMap<String, TemplateModel>(params); paramWrap.put(OUT_PAGINATION, DEFAULT_WRAPPER.wrap(page)); Map<String, TemplateModel> origMap = DirectiveUtils.addParamsToVariable(env, paramWrap); InvokeType type = DirectiveUtils.getInvokeType(params); String listStyle = DirectiveUtils.getString(PARAM_STYLE_LIST, params); if (InvokeType.sysDefined == type) { if (StringUtils.isBlank(listStyle)) { throw new ParamsRequiredException(PARAM_STYLE_LIST); } env.include(TPL_STYLE_LIST + listStyle + TPL_SUFFIX, UTF8, true); } else if (InvokeType.userDefined == type) { if (StringUtils.isBlank(listStyle)) { throw new ParamsRequiredException(PARAM_STYLE_LIST); } FrontUtils.includeTpl(TPL_STYLE_LIST, site, env); } else if (InvokeType.custom == type) { FrontUtils.includeTpl(TPL_NAME, site, params, env); } else if (InvokeType.body == type) { body.render(env.getOut()); } else { throw new RuntimeException("invoke type not handled: " + type); } DirectiveUtils.removeParamsFromVariable(env, paramWrap, origMap); }
@SuppressWarnings("unchecked") public void execute( Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { Integer id = getId(params); Boolean next = DirectiveUtils.getBool(PRAMA_NEXT, params); Content content; if (next == null) { content = contentMng.findById(id); } else { CmsSite site = FrontUtils.getSite(env); Integer channelId = DirectiveUtils.getInt(PARAM_CHANNEL_ID, params); content = contentMng.getSide(id, site.getId(), channelId, next); } Map<String, TemplateModel> paramWrap = new HashMap<String, TemplateModel>(params); paramWrap.put(OUT_BEAN, DEFAULT_WRAPPER.wrap(content)); Map<String, TemplateModel> origMap = DirectiveUtils.addParamsToVariable(env, paramWrap); body.render(env.getOut()); DirectiveUtils.removeParamsFromVariable(env, paramWrap, origMap); }