Beispiel #1
0
        private String bindAutoData(IBlock sectionBlock, ContentSection section)
        {
            IList setttingLinks = getAutoBinderSettingLinks(section);

            bindSettingLink(sectionBlock, setttingLinks);

            Dictionary <string, string> presult = getDefaultValue(section);

            IList data = ServiceContext.GetData(section.ServiceId, section.GetServiceParamValues(), presult);

            if (section.TemplateId <= 0)
            {
                return(getJsonResult(section, data));
            }


            ContentSectionTemplate tpl = templatelService.GetById(section.TemplateId);
            Template       currentView = utils.getTemplateByFileName(BinderUtils.GetBinderTemplatePath(tpl));
            ISectionBinder binder      = BinderUtils.GetBinder(tpl, ctx, currentView);

            binder.Bind(section, data);

            ControllerBase cb2 = binder as ControllerBase;

            return(cb2.utils.getActionResult());
        }
Beispiel #2
0
        /// <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 ContentSectionTemplate getJsonTemplate()
        {
            ContentSectionTemplate ct = new ContentSectionTemplate();

            ct.Name         = "json自定义模板<br/><span class=\"note\">(需要自己写js来绑定)</span>";
            ct.TemplateName = "json";

            return(ct);
        }
Beispiel #4
0
        public void AddAutoThree(int columnId)
        {
            target(CreateAuto, columnId);
            int     serviceId  = ctx.PostInt("serviceId");
            int     templateId = ctx.PostInt("templateId");
            Service service    = ServiceContext.Get(serviceId);
            ContentSectionTemplate template = templateService.GetById(templateId);

            template = checkJsonTemplate(template);
            bindServiceThree(serviceId, templateId, service, template);
        }
 private Boolean isNeeded(ContentSectionTemplate template, string[] arrFilter)
 {
     foreach (String ft in arrFilter)
     {
         if (strUtil.HasText(ft) && template.TemplateName.Equals(ft.Trim()))
         {
             return(true);
         }
     }
     return(false);
 }
        public virtual void AddAutoThree(long columnId)
        {
            target(CreateAuto, columnId);
            long    serviceId  = ctx.PostLong("serviceId");
            long    templateId = ctx.PostLong("templateId");
            Service service    = ServiceContext.Get(serviceId);
            ContentSectionTemplate template = templateService.GetById(templateId);

            template = checkJsonTemplate(template);
            bindServiceThree(serviceId, templateId, service, template);
        }
Beispiel #7
0
        private ContentSectionTemplate checkJsonTemplate(ContentSectionTemplate template)
        {
            if (template != null)
            {
                return(template);
            }
            if (ctx.owner.obj is Site == false)
            {
                throw new NullReferenceException("模板不能为空:请正确设置模板");
            }

            return(TemplateUtil.getJsonTemplate());
        }
Beispiel #8
0
        public static ISectionBinder GetBinder(ContentSectionTemplate template, MvcContext ctx, Template currentView)
        {
            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);
            }
            controller.utils.setCurrentView(currentView);
            return(controller as ISectionBinder);
        }
        private String getAutoData(ContentSection section)
        {
            Dictionary <string, string> presult = getDefaultValue(section);

            IList data = ServiceContext.GetData(section.ServiceId, section.GetServiceParamValues(), presult);

            if (section.TemplateId <= 0)
            {
                return(getJsonResult(section, data));
            }

            ContentSectionTemplate sectionTemplate = TplService.GetById(section.TemplateId);
            Template       currentView             = utils.getTemplateByFileName(BinderUtils.GetBinderTemplatePath(sectionTemplate));
            ISectionBinder binder = BinderUtils.GetBinder(sectionTemplate, ctx, currentView);

            binder.Bind(section, data);   // custom template : SectionUtil.loadTemplate
            ControllerBase sectionController = binder as ControllerBase;

            return(sectionController.utils.getActionResult());
        }
Beispiel #10
0
        public virtual void Select(long id)
        {
            ContentSection section = sectionService.GetById(id, ctx.app.Id);

            if (section == null)
            {
                echoRedirect(lang("exDataNotFound"));
                return;
            }

            set("customLink", to(new TemplateCustomController().EditBinder, id));

            Service service            = ServiceContext.Get(section.ServiceId);
            ContentSectionTemplate tpl = templateService.GetById(section.TemplateId);

            String templateType = TemplateUtil.getServiceTemplates(service.Note, tpl, ctx, templateService);

            set("templateType", templateType);

            target(UpdateTemplate, id);
        }
Beispiel #11
0
 // 得到视图view的模板文件
 public static String GetBinderTemplatePath(ContentSectionTemplate sectionTemplate)
 {
     return("Content/Binder/" + sectionTemplate.TemplateName);
 }
Beispiel #12
0
        // Content/Binder/List
        private string getBinderTemplatePath(ContentSection s)
        {
            ContentSectionTemplate tpl = templatelService.GetById(s.TemplateId);

            return("Content/Binder/" + tpl.TemplateName);
        }
Beispiel #13
0
        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));
        }
        private void bindServiceThree(long serviceId, long templateId, Service service, ContentSectionTemplate template)
        {
            set("service.Id", serviceId);
            set("service.Name", service.Name);
            set("template.Id", templateId);
            set("template.Name", template.Name);

            StringBuilder builder = new StringBuilder();
            IList         parms   = service.GetParams();

            for (int i = 0; i < parms.Count; i++)
            {
                ParamControl control = parms[i] as ParamControl;

                builder.Append("<div>");
                builder.Append(control.Html);
                builder.Append("</div>");
            }
            set("settingList", builder.ToString());
        }