/// <summary> /// 获取聚合区块对应的 BinderController。加载模板的时候,检查是否已经自定义了模板。 /// </summary> /// <param name="section"></param> /// <param name="ctx"></param> /// <returns></returns> public static ISectionBinder GetBinder(ContentSection section, MvcContext ctx) { IContentSectionTemplateService TplService = ObjectContext.Create <IContentSectionTemplateService>(typeof(ContentSectionTemplateService)); ContentSectionTemplate template = TplService.GetById(section.TemplateId); String binderName = string.Format("wojilu.Web.Controller.Content.Binder.{0}BinderController", template.TemplateName); ControllerBase controller = ControllerFactory.FindController(binderName, ctx) as ControllerBase; if (controller == null) { throw new Exception("ISectionBinder not found:" + binderName); } String customTemplateStr = getCustomTemplateBody(section, ctx); // 自定义模板 if (strUtil.HasText(customTemplateStr)) { controller.viewContent(customTemplateStr); return(controller as ISectionBinder); } else { Template currentView = controller.utils.getTemplateByFileName(BinderUtils.GetBinderTemplatePath(template)); controller.utils.setCurrentView(currentView); return(controller as ISectionBinder); } }
public static String getServiceTemplates( String filterString, String tpl, MvcContext ctx, IContentSectionTemplateService templateService ) { String thumbPath = BinderUtils.GetBinderTemplateThumbPath(); StringBuilder builder = new StringBuilder(); builder.Append( "<table style=\"width: 100%\" cellpadding='5'><tr>" ); List<ContentSectionTemplate> templates = templateService.GetBy( filterString ); if (ctx.owner.obj is Site) { templates = TemplateUtil.addJson( templates ); } int icount = 0; foreach (ContentSectionTemplate template in templates) { builder.AppendFormat( "<td style=\"vertical-align:top;\"><label for=\"template{0}\"><img src='{1}{2}.png' style='width:150px;height:100px;' /></label><br/>", template.Id, thumbPath, template.TemplateName ); builder.AppendFormat( "<input name=\"templateId\" id=\"template{0}\" type=\"radio\" value=\"{0}\"", template.Id ); if (tpl.Equals( template.TemplateName )) builder.Append( " checked " ); builder.AppendFormat( "/><label for=\"template{0}\">{1}</label></td>", template.Id, template.Name ); if ((icount % 4) == 3) builder.Append( "</tr><tr>" ); icount++; } builder.Append( "</table>" ); return builder.ToString(); }
public SectionSettingController() { sectionService = new ContentSectionService(); ctService = new ContentCustomTemplateService(); templatelService = new ContentSectionTemplateService(); }
public TemplateCustomController() { sectionService = new ContentSectionService(); ctService = new ContentCustomTemplateService(); templatelService = new ContentSectionTemplateService(); }
public static String getServiceTemplates(String filterString, String tpl, MvcContext ctx, IContentSectionTemplateService templateService) { String thumbPath = BinderUtils.GetBinderTemplateThumbPath(); StringBuilder builder = new StringBuilder(); builder.Append("<table style=\"width: 100%\" cellpadding='5'><tr>"); List <ContentSectionTemplate> templates = templateService.GetBy(filterString); if (ctx.owner.obj is Site) { templates = TemplateUtil.addJson(templates); } int icount = 0; foreach (ContentSectionTemplate template in templates) { builder.AppendFormat("<td style=\"vertical-align:top;\"><label for=\"template{0}\"><img src='{1}{2}.png' style='width:150px;height:100px;' /></label><br/>", template.Id, thumbPath, template.TemplateName); builder.AppendFormat("<input name=\"templateId\" id=\"template{0}\" type=\"radio\" value=\"{0}\"", template.Id); if (tpl.Equals(template.TemplateName)) { builder.Append(" checked "); } builder.AppendFormat("/><label for=\"template{0}\">{1}</label></td>", template.Id, template.Name); if ((icount % 4) == 3) { builder.Append("</tr><tr>"); } icount++; } builder.Append("</table>"); return(builder.ToString()); }
public static String getServiceTemplates(String filterString, ContentSectionTemplate tpl, MvcContext ctx, IContentSectionTemplateService templateService) { String tplName = tpl == null? "json": tpl.TemplateName; return(getServiceTemplates(filterString, tplName, ctx, templateService)); }
public TemplateController() { sectionTypeService = new ContentSectionTypeService(); sectionService = new ContentSectionService(); templateService = new ContentSectionTemplateService(); }
public static String getServiceTemplates( String filterString, ContentSectionTemplate tpl, MvcContext ctx, IContentSectionTemplateService templateService ) { String tplName = tpl==null? "json": tpl.TemplateName; return getServiceTemplates( filterString, tplName, ctx, templateService ); }