Beispiel #1
0
        private bool MakeControls(ReferenceItem referenceItem)
        {
            if (!referenceItem.HasParameters)
            {
                return(false);
            }

            var panel = new Panel();

            panel.Style.Add("border", "none");
            panel.Style.Add("margin-bottom", "10px");

            var literal = new Literal
            {
                Text =
                    string.Format("<div style=\"margin-left:10px;margin-top:4px;font-weight:bold\">{0}</div><br/>",
                                  referenceItem.PrettyName)
            };

            panel.ID =
                Control.GetUniqueID(
                    string.Concat("params_", referenceItem.GetType().Name.ToLower(), "_", referenceItem.Name.ToLower(),
                                  "_"));
            panel.Controls.Add(literal);
            foreach (var pi in referenceItem.Parameters)
            {
                var i = new Inline();
                var l = new Label {
                    Header = pi.Title + ":"
                };

                l.Style.Add("font-weight", "bold");
                l.Style.Add("padding-top", "5px");
                l.Style.Add("margin-right", "10px");
                l.Style.Add("margin-left", "20px");
                l.Style.Add("width", "100px");
                l.Style.Add("text-align", "right");
                l.Style.Add("float", "left");

                var input = pi.MakeControl();
                l.For = input.ID;

                i.Style.Add("display", "block");
                i.Style.Add("margin-top", "5px");
                i.Value = input.ID;
                i.ID    = Control.GetUniqueID("params_" + pi.Name + "_");
                i.Controls.Add(l);
                i.Controls.Add(input);
                var lit = new Literal {
                    Text = "<br/>"
                };
                i.Controls.Add(lit);
                panel.Controls.Add(i);
            }
            ConfigSection.Controls.Add(panel);
            return(true);
        }
Beispiel #2
0
 private void BuildDatabases()
 {
     foreach (var str in Factory.GetDatabaseNames())
     {
         if (!string.Equals(str, "core", StringComparison.OrdinalIgnoreCase) &&
             !Sitecore.Client.GetDatabaseNotNull(str).ReadOnly)
         {
             var child = new ListItem();
             Databases.Controls.Add(child);
             child.ID       = Control.GetUniqueID("ListItem");
             child.Header   = str;
             child.Value    = str;
             child.Selected = str.Equals(InitialDatabase, StringComparison.InvariantCultureIgnoreCase);
         }
     }
 }
Beispiel #3
0
        /// <summary>
        /// Builds the Checkboxes to select indexes
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="header">The header.</param>
        /// <param name="selected">The selected.</param>
        /// <param name="indexMap">The index map.</param>
        private void BuildIndexCheckbox(string name, string header, ListString selected, ListString indexMap)
        {
            Assert.ArgumentNotNull(name, "name");
            Assert.ArgumentNotNull(header, "header");
            Assert.ArgumentNotNull(selected, "selected");
            Assert.ArgumentNotNull(indexMap, "indexMap");
            var child = new Checkbox();

            this.indexes.Controls.Add(child);
            child.ID      = Control.GetUniqueID("dk_");
            child.Header  = header;
            child.Value   = name;
            child.Checked = selected.Contains(name);
            indexMap.Add(child.ID);
            indexMap.Add(name);
            this.indexes.Controls.Add(new LiteralControl("<br />"));
        }
Beispiel #4
0
        /// <summary>
        /// Initializes the checklists. Checklists provides additional search result filtering functionality.
        /// It's stored in the catalog settings folder.
        /// </summary>
        /// <param name="checklists">The checklists.</param>
        public void InitializeChecklists(IEnumerable <ChecklistDefinition> checklists)
        {
            this.Checklists = new NameValueCollection();

            foreach (var checklist in checklists)
            {
                var args = new ChecklistEventArgs {
                    ChecklistDefinition = checklist
                };
                this.OnChecklistCreating(args);

                var border = new Border();
                border.Attributes["class"] = "scChecklist";
                this.ChecklistContainer.Controls.Add(border);

                var header = new Border {
                    ID = Control.GetUniqueID("ChecklistHeader"), InnerHtml = checklist.Header
                };
                header.Attributes["class"] = "scChecklistHeader";
                border.Controls.Add(header);

                var checklistBorder = new Border {
                    ID = Control.GetUniqueID("ChecklistBody")
                };
                checklistBorder.Attributes["name"]  = CheckListIdPrefix + checklist.Field;
                checklistBorder.Attributes["class"] = "scChecklistItems";
                border.Controls.Add(checklistBorder);

                foreach (var checklistItem in checklist.Checkboxes)
                {
                    var cb = new HtmlInputCheckBox {
                        ID = string.Concat(Control.GetUniqueID("checkbox_"), CheckListIdPrefix, checklist.Field), Checked = args.CheckedValues != null && args.CheckedValues.Contains(checklistItem.Value), Value = checklistItem.Value
                    };
                    checklistBorder.Controls.Add(cb);

                    var label = new LiteralControl(string.Format("<label for=\"{0}\">{1}</label><br />", cb.ClientID, checklistItem.Text));
                    checklistBorder.Controls.Add(label);

                    if (cb.Checked)
                    {
                        AddListStringValue(this.Checklists, checklist.Field, checklistItem.Value);
                    }
                }
            }
        }
        /// <summary>
        /// Renders available publishing languages.
        /// </summary>
        private void BuildLanguages()
        {
            LanguageCollection languages = LanguageManager.GetLanguages(_database);

            if (languages == null)
            {
                Log.Warn("Scheduled Publish: No publish languages found", this);
                return;
            }

            foreach (var language in languages)
            {
                if (!CanWriteLanguage(language))
                {
                    continue;
                }

                string id = Control.GetUniqueID("lang_");

                HtmlGenericControl langInput = new HtmlGenericControl("input");
                langInput.ID = id;
                langInput.Attributes["type"]  = "checkbox";
                langInput.Attributes["value"] = language.Name;
                if (languages.Count == 1)
                {
                    langInput.Attributes["checked"] = "checked";
                }
                Languages.Controls.Add(langInput);

                HtmlGenericControl langLabel = new HtmlGenericControl("label");
                langLabel.Attributes["for"] = id;
                langLabel.InnerText         = language.CultureInfo.DisplayName;
                Languages.Controls.Add(langLabel);

                Languages.Controls.Add(new LiteralControl("<br/>"));
            }
        }
Beispiel #6
0
        private void PopulateItemList(int start, int count)
        {
            ItemList.Controls.Clear();
            ItemList.ColumnNames.Clear();
            ItemList.ColumnNames.Add("Icon", "Icon");

            var columnNames = new HashSet <string>();

            foreach (DisplayElement result in Current.Context.Report.GetResultElements(start - 1, count))
            {
                var lvi = new ListviewItem
                {
                    ID    = Control.GetUniqueID("lvi"),
                    Icon  = result.Icon,
                    Value = result.Value
                };
                foreach (string column in result.GetColumnNames())
                {
                    columnNames.Add(column);
                    lvi.ColumnValues.Add(column, result.GetColumnValue(column));
                }
                ItemList.Controls.Add(lvi);
            }
            foreach (string column in columnNames)
            {
                ItemList.ColumnNames.Add(column, column);
            }

            Status.Text = string.Format("{0} results found.", Current.Context.Report.ResultsCount());

            var noPages =
                (int)Math.Ceiling((decimal)Current.Context.Report.ResultsCount() / Current.Context.Settings.PageSize);

            ItemList.CurrentPage = (int)Math.Ceiling((decimal)start / Current.Context.Settings.PageSize);

            int startpage = noPages > Current.Context.Settings.MaxNumberPages &&
                            ItemList.CurrentPage > Current.Context.Settings.MaxNumberPages / 2
                                ? ItemList.CurrentPage - Current.Context.Settings.MaxNumberPages / 2
                                : 1;
            int          endpage   = Math.Min(startpage + Current.Context.Settings.MaxNumberPages, noPages);
            const string separator = "&nbsp;&nbsp;";

            if (noPages > 0)
            {
                var sb = new StringBuilder("&nbsp;&nbsp; Page ");
                if (startpage > 1)
                {
                    int newpage = Math.Max(1, startpage - Current.Context.Settings.MaxNumberPages);
                    if (newpage > 1)
                    {
                        var b = new LinkButton {
                            Header = "first", Click = "changepage:" + 1
                        };
                        sb.Append(b.RenderAsText());
                    }
                    var lb = new LinkButton {
                        Header = "...", Click = "changepage:" + newpage
                    };
                    sb.Append(lb.RenderAsText());
                }
                for (int i = startpage; i <= endpage; i++)
                {
                    var b = new LinkButton
                    {
                        Header = i.ToString(CultureInfo.InvariantCulture), Selected = i == ItemList.CurrentPage, Click = "changepage:" + i
                    };
                    b.Style.Add(HtmlTextWriterStyle.Cursor, "pointer");
                    sb.Append(b.RenderAsText());
                    sb.Append(separator);
                }
                if (endpage < noPages)
                {
                    int newpage = Math.Min(noPages, endpage + Current.Context.Settings.MaxNumberPages / 2);
                    var b       = new LinkButton {
                        Header = "...", Click = "changepage:" + newpage
                    };
                    sb.Append(b.RenderAsText());
                    if (newpage < noPages)
                    {
                        b = new LinkButton {
                            Header = "last", Click = "changepage:" + noPages
                        };
                        sb.Append(b.RenderAsText());
                    }
                }
                Status.Text += sb.ToString();
                Status.Style.Add(HtmlTextWriterStyle.Cursor, "default");
            }

            Sitecore.Context.ClientPage.ClientResponse.Refresh(ItemList);

            Sitecore.Context.ClientPage.ClientResponse.Refresh(Status);
        }