Exemplo n.º 1
0
        private void bindPickedList(IList serviceData, IBlock block)
        {
            for (int i = 1; i < serviceData.Count; i++)
            {
                ContentPost post = serviceData[i] as ContentPost;

                IPageAdminSection sectionController = BinderUtils.GetPageSectionAdmin(post, ctx, "AdminSectionShow");
                String            typeIcon          = sectionController.GetSectionIcon(post.SectionId);

                String attIcon = post.Attachments > 0 ? BinderUtils.iconAttachment : "";

                if (strUtil.HasText(post.TitleHome))
                {
                    block.Set("post.Title", post.TitleHome);
                }
                else
                {
                    block.Set("post.Title", post.Title);
                }


                block.Set("post.Url", alink.ToAppData(post, ctx));
                block.Set("post.DataIcon", typeIcon);
                block.Set("post.AttachmentIcon", attIcon);
                block.Set("post.Created", post.Created.ToShortDateString());
                block.Next();
            }
        }
Exemplo n.º 2
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());
        }
Exemplo n.º 3
0
        private void bindSectionShow(List <ContentPost> posts, ContentPost img)
        {
            IBlock block = getBlock("list");

            foreach (ContentPost post in posts)
            {
                BinderUtils.bindPostSingle(block, post, ctx);

                block.Next();
            }

            IBlock imgBlock = getBlock("img");

            if (img != null)
            {
                imgBlock.Set("ipost.TitleCss", img.Style);

                String content = strUtil.HasText(img.Summary) ? img.Summary : strUtil.ParseHtml(img.Content, 50);
                imgBlock.Set("ipost.Content", content);

                int width  = img.Width <= 0 ? 120 : img.Width;
                int height = img.Height <= 0 ? 90 : img.Height;

                imgBlock.Set("ipost.Width", width);
                imgBlock.Set("ipost.Height", height);

                imgBlock.Set("ipost.Url", alink.ToAppData(img, ctx));

                imgBlock.Bind("ipost", img);

                imgBlock.Next();
            }
        }
Exemplo n.º 4
0
        public virtual void List()
        {
            DataPage <ContentSectionType> list = sectionTypeService.GetPage();
            String thumbPath       = BinderUtils.GetSectionTemplateThumbPath();
            String sectionTypeName = getSectionTypeName();

            IBlock block = getBlock("list");

            foreach (ContentSectionType c in list.Results)
            {
                String thumb = strUtil.Join(thumbPath, c.TypeFullName) + ".png";

                block.Set("c.Name", c.Name);
                block.Set("c.Thumb", thumb);
                block.Set("c.TypeFullName", c.TypeFullName);

                String strChecked = "";
                if (sectionTypeName.Equals(c.TypeFullName))
                {
                    strChecked = " checked ";
                }
                block.Set("c.Checked", strChecked);

                block.Next();
            }

            set("page", list.PageBar);
        }
Exemplo n.º 5
0
        // TODO
        //private void makeHtml( String ids ) {

        //    List<ContentPost> posts = postService.GetByIds( ids );
        //    foreach (ContentPost post in posts) {

        //        HtmlHelper.SetCurrentPost( ctx, post );

        //        HtmlHelper.DeleteDetailHtml( ctx );

        //        int sectionId = post.PageSection.Id;
        //        int recordCount = postService.CountBySection( sectionId );
        //        new HtmlListMaker().MakeHtml( ctx, sectionId, recordCount );

        //    }
        //}

        private void bindAdminList(DataPage <ContentPost> posts, bool isTrash)
        {
            IBlock block = getBlock("list");

            foreach (ContentPost post in posts.Results)
            {
                IPageAdminSection sectionController = BinderUtils.GetPageSectionAdmin(post, ctx, "AdminSectionShow");

                String typeIcon = BinderUtils.getTypeIcon(sectionController, post);
                String pickIcon = BinderUtils.getPickedIcon(post);
                String attIcon  = post.Attachments > 0 ? BinderUtils.iconAttachment : "";

                block.Set("post.ImgIcon", typeIcon);
                block.Set("post.PickIcon", pickIcon);
                block.Set("post.AttachmentIcon", attIcon);

                block.Set("post.Title", strUtil.SubString(post.GetTitle(), 50));
                block.Set("post.TitleCss", post.Style);
                block.Set("post.TitleFull", post.Title);

                block.Set("post.SectionName", post.SectionName);

                block.Set("post.Url", post.SourceLink);
                block.Set("post.Link", alink.ToAppData(post));
                block.Set("post.PubDate", post.Created);

                if (post.Creator != null)
                {
                    block.Set("post.Submitter", string.Format("<a href=\"{0}\" target=\"_blank\">{1}</a>", toUser(post.Creator), post.Creator.Name));
                }
                else
                {
                    block.Set("post.Submitter", "无");
                }

                block.Bind("post", post);

                String lnkEdit = isTrash ? "#" : sectionController.GetEditLink(post.Id);

                String lnkDelete = to(Delete, post.Id);
                if (isTrash)
                {
                    lnkDelete = to(DeleteSys, post.Id);
                }

                block.Set("post.EditUrl", lnkEdit);
                block.Set("post.DeleteUrl", lnkDelete);

                block.Set("post.RestoreUrl", to(Restore, post.Id));
                block.Set("post.EditTitleStyleUrl", to(EditTitleStyle, post.Id));

                block.Set("post.AttachmentLink", to(new AttachmentController().AdminList, post.Id));

                block.Next();
            }
            set("page", posts.PageBar);
        }
Exemplo n.º 6
0
        private String bindData(IBlock sectionBlock, ContentSection articleSection)
        {
            IPageAdminSection section    = BinderUtils.GetPageSectionAdmin(articleSection, ctx, "AdminSectionShow");
            ControllerBase    controller = section as ControllerBase;

            bindSettingLink(sectionBlock, section.GetSettingLink(articleSection.Id));
            section.AdminSectionShow(articleSection.Id);
            return(controller.utils.getActionResult());
        }
Exemplo n.º 7
0
        private String getData(ContentSection articleSection)
        {
            IPageSection   section           = BinderUtils.GetPageSection(articleSection, ctx);
            ControllerBase sectionController = section as ControllerBase;

            section.SectionShow(articleSection.Id);
            String actionContent = sectionController.utils.getActionResult();

            return(actionContent);
        }
Exemplo n.º 8
0
        private void bindSectionPosts(IList posts)
        {
            IBlock block = getBlock("list");

            foreach (ContentPost post in posts)
            {
                BinderUtils.bindPostSingle(block, post, ctx);

                block.Next();
            }
        }
Exemplo n.º 9
0
        private void bindSectionShow(ContentSection section, List <ContentPost> posts)
        {
            set("m.Title", section.Title);
            IBlock block = getBlock("list");

            foreach (ContentPost post in posts)
            {
                BinderUtils.bindPostSingle(block, post);

                block.Next();
            }
        }
Exemplo n.º 10
0
        public virtual void Bind(ContentSection section, IList serviceData)
        {
            IBlock block = base.getBlock("list");

            int i = 1;

            foreach (IBinderValue item in serviceData)
            {
                BinderUtils.bindMashupData(block, item, i, ctx);
                block.Next();
                i++;
            }
        }
Exemplo n.º 11
0
        private void bindSectionShow(List <ContentPost> posts, ContentPost img)
        {
            IBlock block = getBlock("list");

            foreach (ContentPost post in posts)
            {
                BinderUtils.bindPostSingle(block, post);

                block.Next();
            }

            IBlock imgBlock = getBlock("img");

            if (img != null)
            {
                imgBlock.Set("ipost.TitleCss", img.Style);
                imgBlock.Set("ipost.TitleFull", img.Title);

                if (strUtil.HasText(img.TitleHome))
                {
                    block.Set("ipost.Title", img.TitleHome);
                }
                else
                {
                    block.Set("ipost.Title", img.Title);
                }

                if (img.ImgLink.StartsWith("/") || img.ImgLink.StartsWith("http://"))
                {
                    imgBlock.Set("ipost.ImgUrl", img.ImgLink);
                }
                else
                {
                    imgBlock.Set("ipost.ImgUrl", img.GetImgThumb());
                }
                String content = strUtil.HasText(img.Summary) ? img.Summary : strUtil.ParseHtml(img.Content, 50);
                imgBlock.Set("ipost.Content", content);

                int width  = img.Width <= 0 ? 120 : img.Width;
                int height = img.Height <= 0 ? 90 : img.Height;

                imgBlock.Set("ipost.Width", width);
                imgBlock.Set("ipost.Height", height);

                imgBlock.Set("ipost.Url", alink.ToAppData(img));

                imgBlock.Bind("ipost", img);

                imgBlock.Next();
            }
        }
Exemplo n.º 12
0
        public void Bind(ContentSection section, IList serviceData)
        {
            TemplateUtil.loadTemplate(this, section, ctService);

            IBlock block = base.getBlock("list");

            int i = 1;

            foreach (IBinderValue item in serviceData)
            {
                BinderUtils.bindMashupData(block, item, i);
                block.Next();
                i++;
            }
        }
        private void bindPickedList(IList serviceData, IBlock block)
        {
            for (int i = 1; i < serviceData.Count; i++)
            {
                ContentPost a = serviceData[i] as ContentPost;

                String typeIcon = BinderUtils.getTypeIcon(a);
                String attIcon  = a.Attachments > 0 ? BinderUtils.iconAttachment : "";

                block.Set("post.Title", a.Title);
                block.Set("post.Url", alink.ToAppData(a));
                block.Set("post.DataIcon", typeIcon);
                block.Set("post.AttachmentIcon", attIcon);
                block.Set("post.Created", a.Created.ToShortDateString());
                block.Next();
            }
        }
Exemplo n.º 14
0
        private void bindPostList(ContentSection section, DataPage <ContentPost> posts, ContentSetting setting)
        {
            set("section.Name", section.Title);
            IBlock block = getBlock("list");

            foreach (ContentPost post in posts.Results)
            {
                BinderUtils.bindPostSingle(block, post, ctx);

                if (setting.ArticleListMode == ArticleListMode.Summary)
                {
                    block.Set("post.Summary", post.GetSummary(setting.SummaryLength));
                }

                block.Next();
            }
        }
Exemplo n.º 15
0
        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));
            }

            ISectionBinder binder = BinderUtils.GetBinder(section, ctx);

            binder.Bind(section, data);
            ControllerBase sectionController = binder as ControllerBase;

            return(sectionController.utils.getActionResult());
        }
Exemplo n.º 16
0
        private void bindPosts(DataPage <ContentPost> posts)
        {
            IBlock block = getBlock("list");

            foreach (ContentPost post in posts.Results)
            {
                if (post.PageSection == null)
                {
                    continue;
                }
                if (post.PageSection.SectionType == typeof(TextController).FullName)
                {
                    continue;
                }

                BinderUtils.bindListItem(block, post, ctx);
                block.Next();
            }
            set("page", posts.PageBar);
        }
        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());
        }
Exemplo n.º 18
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));
            }


            ISectionBinder binder = BinderUtils.GetBinder(section, ctx);

            binder.Bind(section, data);
            ControllerBase cb2 = binder as ControllerBase;

            return(cb2.utils.getActionResult());
        }
Exemplo n.º 19
0
        private void bindSectionShow(List <ContentPost> posts, List <ContentPost> imgs)
        {
            IBlock block = getBlock("list");

            foreach (ContentPost post in posts)
            {
                BinderUtils.bindPostSingle(block, post);

                block.Next();
            }

            IBlock imgBlock = getBlock("imgs");

            foreach (ContentPost img in imgs)
            {
                imgBlock.Set("img.TitleFull", img.Title);
                imgBlock.Set("img.TitleCss", img.Style);

                if (strUtil.HasText(img.TitleHome))
                {
                    imgBlock.Set("img.Title", img.TitleHome);
                }
                else
                {
                    imgBlock.Set("img.Title", img.Title);
                }


                imgBlock.Set("img.Thumb", img.GetImgThumb());
                imgBlock.Set("img.Url", alink.ToAppData(img));

                imgBlock.Bind("img", img);

                imgBlock.Next();
            }
        }
Exemplo n.º 20
0
        public bool IsValidDottedNameNode(DottedNameNode node, TexlBinding binding, OperationCapabilityMetadata metadata, IOpDelegationStrategy opDelStrategy)
        {
            Contracts.AssertValue(node);
            Contracts.AssertValue(binding);
            Contracts.AssertValueOrNull(opDelStrategy);

            var isRowScoped = binding.IsRowScope(node);

            if (!isRowScoped)
            {
                return(IsValidNode(node, binding));
            }

            bool isRowScopedDelegationExempted;

            if (!IsValidRowScopedDottedNameNode(node, binding, metadata, out isRowScopedDelegationExempted))
            {
                var telemetryMessage = string.Format("Kind:{0}, isRowScoped:{1}",
                                                     node.Kind, isRowScoped);

                SuggestDelegationHintAndAddTelemetryMessage(node, binding, telemetryMessage);
                return(false);
            }

            if (isRowScopedDelegationExempted)
            {
                binding.SetBlockScopedConstantNode(node);
                return(true);
            }

            if (binding.TryGetFullRecordRowScopeAccessInfo(node, out var firstNameInfo))
            {
                // This means that this row scoped field is from some parent scope which is non-delegatable. That should deny delegation at that point.
                // For this scope, this means that value will be provided from some other source.
                // For example, AddColumns(CDS As Left, "Column1", LookUp(CDS1, Left.Name in FirstName))
                // CDS - *[Name:s], CDS1 - *[FirstName:s]
                if (GetCapabilityMetadata(firstNameInfo) == null)
                {
                    return(true);
                }
            }

            if (!binding.GetType(node.Left).HasExpandInfo)
            {
                DPath columnPath;
                if (!BinderUtils.TryConvertNodeToDPath(binding, node, out columnPath) || !metadata.IsDelegationSupportedByColumn(columnPath, _function.FunctionDelegationCapability))
                {
                    var safeColumnName = CharacterUtils.MakeSafeForFormatString(columnPath.ToDottedSyntax());
                    var message        = string.Format(StringResources.Get(TexlStrings.OpNotSupportedByColumnSuggestionMessage_OpNotSupportedByColumn), safeColumnName);
                    SuggestDelegationHintAndAddTelemetryMessage(node, binding, message, TexlStrings.OpNotSupportedByColumnSuggestionMessage_OpNotSupportedByColumn, safeColumnName);
                    TrackingProvider.Instance.SetDelegationTrackerStatus(DelegationStatus.NoDelSupportByColumn, node, binding, _function, DelegationTelemetryInfo.CreateNoDelSupportByColumnTelemetryInfo(columnPath.ToDottedSyntax()));
                    return(false);
                }

                // If there is any operator applied on this node then check if column supports operation.
                return(opDelStrategy?.IsOpSupportedByColumn(metadata, node, columnPath, binding) ?? true);
            }

            // If there is an entity reference then we need to do additional verification.
            IExpandInfo info           = binding.GetType(node.Left).ExpandInfo.VerifyValue();
            var         dataSourceInfo = info.ParentDataSource;

            IDataEntityMetadata entityMetadata;

            if (!dataSourceInfo.DataEntityMetadataProvider.TryGetEntityMetadata(info.Identity, out entityMetadata))
            {
                var telemetryMessage = string.Format("Kind:{0}, isRowScoped:{1}, no metadata found for entity {2}",
                                                     node.Kind, isRowScoped, CharacterUtils.MakeSafeForFormatString(info.Identity));

                SuggestDelegationHintAndAddTelemetryMessage(node, binding, telemetryMessage);
                return(false);
            }

            OperationCapabilityMetadata entityCapabilityMetadata = GetScopedOperationCapabilityMetadata(entityMetadata.DelegationMetadata);
            string maybeLogicalName;
            DName  columnName = node.Right.Name;

            if (entityMetadata.DisplayNameMapping.TryGetFromSecond(node.Right.Name.Value, out maybeLogicalName))
            {
                columnName = new DName(maybeLogicalName);
            }

            var entityColumnPath = DPath.Root.Append(columnName);

            if (!entityCapabilityMetadata.IsDelegationSupportedByColumn(entityColumnPath, _function.FunctionDelegationCapability))
            {
                var safeColumnName = CharacterUtils.MakeSafeForFormatString(columnName.Value);
                var message        = string.Format(StringResources.Get(TexlStrings.OpNotSupportedByColumnSuggestionMessage_OpNotSupportedByColumn), safeColumnName);
                SuggestDelegationHintAndAddTelemetryMessage(node, binding, message, TexlStrings.OpNotSupportedByColumnSuggestionMessage_OpNotSupportedByColumn, safeColumnName);
                TrackingProvider.Instance.SetDelegationTrackerStatus(DelegationStatus.NoDelSupportByColumn, node, binding, _function, DelegationTelemetryInfo.CreateNoDelSupportByColumnTelemetryInfo(columnName));
                return(false);
            }

            // If there is any operator applied on this node then check if column supports operation.
            return(opDelStrategy?.IsOpSupportedByColumn(entityCapabilityMetadata, node, entityColumnPath, binding) ?? true);
        }
Exemplo n.º 21
0
        private void bindAdminList(DataPage <ContentPost> posts, bool isTrash)
        {
            IBlock block = getBlock("list");


            foreach (ContentPost post in posts.Results)
            {
                String typeIcon = BinderUtils.getTypeIcon(post);
                String pickIcon = BinderUtils.getPickedIcon(post);
                String attIcon  = post.Attachments > 0 ? BinderUtils.iconAttachment : "";

                block.Set("post.ImgIcon", typeIcon);
                block.Set("post.PickIcon", pickIcon);
                block.Set("post.AttachmentIcon", attIcon);

                block.Set("post.Title", strUtil.SubString(post.GetTitle(), 50));
                block.Set("post.TitleCss", post.Style);
                block.Set("post.TitleFull", post.Title);

                //String sectionName = post.PageSection == null ? "" : post.PageSection.Title;
                //block.Set( "post.SectionName", sectionName );

                block.Set("post.Url", post.SourceLink);
                block.Set("post.Link", alink.ToAppData(post));
                block.Set("post.PubDate", post.Created);

                if (post.Creator != null)
                {
                    block.Set("post.Submitter", string.Format("<a href=\"{0}\" target=\"_blank\">{1}</a>", Link.ToMember(post.Creator), post.Creator.Name));
                }
                else
                {
                    block.Set("post.Submitter", "无");
                }



                block.Bind("post", post);

                String lnkEdit = "";
                if (isTrash)
                {
                    lnkEdit = "#";
                }
                else if (post.HasImg())
                {
                    lnkEdit = to(new PostController().EditImg, post.Id);
                }
                else
                {
                    lnkEdit = to(new PostController().Edit, post.Id);
                }

                String lnkDelete = to(Delete, post.Id);
                if (isTrash)
                {
                    lnkDelete = to(DeleteTrue, post.Id);
                }

                block.Set("post.EditUrl", lnkEdit);
                block.Set("post.DeleteUrl", lnkDelete);

                block.Set("post.RestoreUrl", to(Restore, post.Id));
                block.Set("post.EditSectionUrl", to(EditSection, post.Id));
                block.Set("post.EditTitleStyleUrl", to(EditTitleStyle, post.Id));

                block.Set("post.AttachmentLink", to(new AttachmentController().AdminList, post.Id));


                block.Next();
            }
            set("page", posts.PageBar);
        }