Defines an item or element in an tree structure.
예제 #1
0
        protected List<TreeElement> ctPages_Populate(object sender, PopulateEventArgs e)
        {
            string currentNamespace = DetectNamespace();
            if(string.IsNullOrEmpty(currentNamespace)) currentNamespace = null;

            List<TreeElement> result = new List<TreeElement>(100);
            foreach(PageInfo pi in Pages.GetPages(Pages.FindNamespace(lstNamespace.SelectedValue))) {
                string pageNamespace = NameTools.GetNamespace(pi.FullName);
                if(string.IsNullOrEmpty(pageNamespace)) pageNamespace = null;
                PageContent cont = Content.GetPageContent(pi, true);
                string formattedTitle = FormattingPipeline.PrepareTitle(cont.Title, false, FormattingContext.Other, pi);
                string onClickJavascript = "javascript:";
                // Populate the page title box if the title is different to the page name
                if (pi.FullName != cont.Title) {
                    // Supply the page title to the Javascript that sets the page title on the page
                    // We can safely escape the \ and ' characters, but the " character is interpreted by the browser even if it is escaped to Javascript, so we can't allow it.
                    // Instead we replace it with an escaped single quote.
                    // Similarly, < on it's own is fine, but causes problems when combined with text and > to form a tag.  Safest to remove < characters to prevent
                    // breaking the drop-down.
                    onClickJavascript += "SetValue('txtPageTitle', '" + cont.Title.Replace("\\", "\\\\").Replace("'", "\\'").Replace("\"", "\\'").Replace("<", "") + "');";
                }
                else {
                    onClickJavascript += "SetValue('txtPageTitle', '');";
                }
                // Populate the page name
                onClickJavascript += "return SetValue('txtPageName', '" +
                    ((pageNamespace == currentNamespace ? NameTools.GetLocalName(pi.FullName) : ("++" + pi.FullName))).Replace("++++", "++") + "');";
                TreeElement item = new TreeElement(pi.FullName, formattedTitle, onClickJavascript);
                result.Add(item);
            }
            return result;
        }
        protected List<TreeElement> ctPages_Populate(object sender, PopulateEventArgs e)
        {
            List<TreeElement> result = new List<TreeElement>(100);

            NamespaceInfo selectedNamespace = Pages.FindNamespace(lstNamespace.SelectedValue);
            NamespaceInfo currentNamespace = DetectNamespaceInfo();

            foreach(PageInfo pi in Pages.GetPages(selectedNamespace)) {
                PageContent cont = Content.GetPageContent(pi, true);
                string formattedTitle = FormattingPipeline.PrepareTitle(cont.Title, false, FormattingContext.Other, pi);
                string onClickJavascript = "javascript:";
                // Populate the page title box if the title is different to the page name
                if (pi.FullName != cont.Title) {
                    // Supply the page title to the Javascript that sets the page title on the page
                    // We can safely escape the \ character, but the " character is interpreted by the browser even if it is escaped to Javascript, so we can't allow it.
                    // The non-wysiwyg version escapes ' and replaces " with escaped ', but ' breaks the html insertion, so remove it altogether
                    // Similarly, < on it's own is fine, but causes problems when combined with text and > to form a tag.  Safest to remove < characters to prevent
                    // breaking the drop-down.
                    onClickJavascript += "SetValue('txtPageTitle', '" + cont.Title.Replace("\\", "\\\\").Replace("'", "").Replace("\"", "").Replace("<", "") + "');";
                }
                else {
                    onClickJavascript += "SetValue('txtPageTitle', '');";
                }
                // Populate the page name (#468: add ++ to all ReverseFormatter to work)
                onClickJavascript += "return SetValue('txtPageName', '" + (selectedNamespace != currentNamespace ? "++" : "") + pi.FullName + "');";
                TreeElement item = new TreeElement((selectedNamespace != currentNamespace ? "++" : "") + pi.FullName, formattedTitle, onClickJavascript);
                result.Add(item);
            }
            return result;
        }
예제 #3
0
        private List<TreeElement> BuildImagesSubTree(IFilesStorageProviderV30 provider, string path)
        {
            string[] dirs = new string[0];
            string[] files = new string[0];

            if(chkImageAttachments.Checked) {
                // Load page attachments
                files = provider.ListPageAttachments(currentPage);
            }
            else {
                // Load files
                dirs = provider.ListDirectories(path);
                files = provider.ListFiles(path);
            }

            List<TreeElement> result = new List<TreeElement>(100);

            foreach(string d in dirs) {
                TreeElement item = new TreeElement(d, Tools.ExtractDirectoryName(d),
                    BuildImagesSubTree(provider, d));
                // Do not display empty folders to reduce "noise"
                if(item.SubItems.Count > 0) {
                    result.Add(item);
                }
            }

            foreach(string f in files) {
                if(IsImage(f)) {
                    string name = provider.GetType().ToString() + "|" + f;
                    TreeElement item = new TreeElement(name,
                        @"<img src=""Thumb.aspx?Provider=" + provider.GetType().ToString() +
                        @"&amp;Size=Small&amp;File=" + Tools.UrlEncode(f) +
                        @"&amp;Page=" + (chkImageAttachments.Checked ? Tools.UrlEncode(currentPage.FullName) : "") +
                        @""" alt=""" + name + @""" /><span class=""imageinfo"">" + f.Substring(f.LastIndexOf("/") + 1) + "</span>",
                        "javascript:return SelectImage('" +
                        (chkImageAttachments.Checked ? "(" + currentPage.FullName + ")" : "") + "', '" + f + "', '" +
                        (chkImageAttachments.Checked ? currentPage.FullName : "") + "');");
                    result.Add(item);
                }
            }

            return result;
        }
예제 #4
0
        private List<TreeElement> BuildFilesSubTree(IFilesStorageProviderV30 provider, string path)
        {
            string[] dirs = new string[0];
            string[] files = new string[0];

            if(chkFilesAttachments.Checked) {
                // Load page attachments
                files = provider.ListPageAttachments(currentPage);
            }
            else {
                // Load files
                dirs = provider.ListDirectories(path);
                files = provider.ListFiles(path);
            }

            List<TreeElement> result = new List<TreeElement>(100);

            foreach(string d in dirs) {
                TreeElement item = new TreeElement(d, Tools.ExtractDirectoryName(d),
                    BuildFilesSubTree(provider, d));
                // Do not display empty folders to reduce "noise"
                if(item.SubItems.Count > 0) {
                    result.Add(item);
                }
            }

            foreach(string f in files) {
                long size = chkFilesAttachments.Checked ? provider.GetPageAttachmentDetails(currentPage, f).Size : provider.GetFileDetails(f).Size;
                TreeElement item = new TreeElement(f, f.Substring(f.LastIndexOf("/") + 1) + " (" + Tools.BytesToString(size) + ")",
                    "javascript:return SelectFile('" +
                    (chkFilesAttachments.Checked ? "(" + currentPage.FullName + ")" : "") + "', '" + f.Replace("'", "\\'") + "');");
                result.Add(item);
            }

            return result;
        }
예제 #5
0
 private void RenderItem(TreeElement item, StringBuilder sb, int iteration)
 {
     if(item.SubItems.Count > 0) {
         // Expanding link
         string containerId = BuildSubTreeContainerID(iteration);
         sb.AppendFormat(@"<div class=""{0}""><a href=""#"" class=""{0}"" onclick=""javascript:return DisplayDiv('{1}');"" title=""{2}"">{3}</a></div>",
             nodeCssClass, containerId, item.Name, nodeContent + item.Text);
     }
     else {
         // Action link
         sb.AppendFormat(@"<div class=""{0}""><a href=""#"" class=""{0}"" onclick=""{1}"" title=""{2}"">{3}</a></div>",
             leafCssClass, item.OnClientClick, item.Name, item.Text);
     }
 }