コード例 #1
0
 /// <summary>
 /// Gets a collection of links for all children to a given page. 
 /// It returns only visible links, which means:
 /// - not deleted
 /// - published
 /// </summary>
 /// <param name="pageLink"></param>
 /// <returns></returns>
 public static LinkItemCollection GetLinkCollectionChildren(PageReference pageLink)
 {
     LinkItemCollection result = null;
     var children = DataFactory.Instance.GetChildren(pageLink);
     if (children != null && children.Count > 0)
     {
         result = new LinkItemCollection();
         foreach (var page in children.Where(x => !x.IsDeleted && x.VisibleInMenu && x.CheckPublishedStatus(PagePublishedStatus.Published))
                 .OrderByDescending(x => x.StartPublish))
         {
             result.Add(
                 new LinkItem
                 {
                     Href = page.LinkURL,
                     Text = page.PageName,
                     Target = "",
                     Title = page.PageName,
                 });
         }
     }
     return result;
 }
コード例 #2
0
        /// <summary>
        /// Override which creates and adds the content of the control. 
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            var items = new LinkItemCollection();

            if (DataSource != null)
                if (DataSource is LinkItemCollection)
                    items = (LinkItemCollection)DataSource;

            if (items.Count > 0)
            {
                AddHeaderTemplate();

                for (int i = 0; i < items.Count; i++)
                {
                    if (i == 0 && FirstItemTemplate != null)
                        AddItemTemplate(FirstItemTemplate, items[i], i + 1);

                    if (i == 1 && SecondItemTemplate != null)
                        AddItemTemplate(SecondItemTemplate, items[i], i + 1);

                    if (i == 2 && ThirdItemTemplate != null)
                        AddItemTemplate(ThirdItemTemplate, items[i], i + 1);

                    if (i == 3 && FourthItemTemplate != null)
                        AddItemTemplate(FourthItemTemplate, items[i], i + 1);

                    if (!_added && i % 2 == 1 && AlternatingItemTemplate != null)
                        AddItemTemplate(AlternatingItemTemplate, items[i], i + 1);

                    if (!_added && ItemTemplate != null)
                        AddItemTemplate(ItemTemplate, items[i], i + 1);

                    if (_added)
                    {
                        _added = false;
                        _addSeparator = true;
                    }
                }

                AddFooterTemplate();
            }
            else
            {
                HideOrEmpty();
            }
        }
コード例 #3
0
 private static void AppendFiles(LinkItemCollection files, StringBuilder outputString, string formatString)
 {
     if (files != null && files.Count > 0)
     {
         foreach (var item in files)
         {
            
             if (!string.IsNullOrEmpty(item.Href))
             {
                 outputString.AppendLine(string.Format(formatString, item.Href));
             }
         }
     }
 }
コード例 #4
0
        public static MvcHtmlString RenderExtendedScriptFiles(this HtmlHelper helper, LinkItemCollection scriptFiles)
        {
            StringBuilder outputCSS = new StringBuilder(string.Empty);

            AppendFiles(scriptFiles, outputCSS, ScriptFormat);          

            return new MvcHtmlString(outputCSS.ToString());
        }
コード例 #5
0
        public static MvcHtmlString RenderExtendedCSS(this HtmlHelper helper, string inline, LinkItemCollection cssFiles)
        {
            StringBuilder outputCSS = new StringBuilder(string.Empty);
            StartPage start = ServiceLocator.Current.GetInstance<IContentLoader>().Get<StartPage>(ContentReference.StartPage);

            if ((cssFiles == null || cssFiles.Count == 0) && start.CSSFiles != null)
            {
                AppendFiles(start.CSSFiles, outputCSS, CssFormat);
            }           
            AppendFiles(cssFiles, outputCSS, CssFormat);            

            if (!string.IsNullOrWhiteSpace(inline))
            {
                outputCSS.AppendLine("<style>");
                outputCSS.AppendLine(inline);
                outputCSS.AppendLine("</style>");
            }
            else
            {
                string startCSS;
                
                startCSS = start.CSS;
                outputCSS.AppendLine("<style>");
                outputCSS.AppendLine(startCSS);
                outputCSS.AppendLine("</style>");
            }

            return new MvcHtmlString(outputCSS.ToString());
        }
コード例 #6
0
ファイル: HtmlHelpers.cs プロジェクト: Siim/AlloyDemoKit
        public static MvcHtmlString RenderExtendedCSS(this HtmlHelper helper, string inline, LinkItemCollection cssFiles)
        {
            StringBuilder outputCSS = new StringBuilder(string.Empty);

            AppendFiles(cssFiles, outputCSS, CssFormat);

            if (!string.IsNullOrWhiteSpace(inline))
            {
                outputCSS.AppendLine("<style>");
                outputCSS.AppendLine(inline);
                outputCSS.AppendLine("</style>");
            }

            return new MvcHtmlString(outputCSS.ToString());
        }