Example #1
0
        public void Bind()
        {
            DbContentClipCollection rootCatalogClips;
            CssInfo rootCssInfo;

            // Load the catalog to start building a menu from
            rootCatalogClips = __rootCatalog.GetClips();
            rootCatalogClips.Sort(ContentCompareKey.MenuOrder);

            // Set menu css to catalog css properties
            rootCssInfo = new CssInfo(__rootCatalog.MenuCssClass);

            if (__looksEnabled)
            {
                rootCssInfo.SetLook(__menu);
            }

            DbContentCatalogCollection catalogs = __rootCatalog.GetCatalogs();

            catalogs.Sort(ContentCompareKey.MenuOrder);

            for (int catalogIndex = 0; catalogIndex < catalogs.Count; catalogIndex++)
            {
                addCatalogToMenu(__menu.Items, catalogs[catalogIndex]);
            }

            addClipsToMenu(__menu.Items, __rootCatalog, rootCatalogClips);
        }
Example #2
0
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            EnsureChildControls();

            // Cached menus are already Loaded
            if (_cached)
            {
                return;
            }

            DbContentCatalog        rootCatalog;
            DbContentClipCollection rootCatalogClips;
            CssInfo rootCssInfo;

            // Load the catalog to start building a menu from
            rootCatalog      = new DbContentCatalog(_catalogID);
            rootCatalogClips = rootCatalog.GetClips();
            rootCatalogClips.Sort(ContentCompareKey.MenuOrder);

            // Set menu css to catalog css properties
            rootCssInfo = new CssInfo(rootCatalog.MenuCssClass);
            rootCssInfo.SetLook(_menu);

            DbContentCatalogCollection catalogs = rootCatalog.GetCatalogs();

            catalogs.Sort(ContentCompareKey.MenuOrder);

            for (int catalogIndex = 0; catalogIndex < catalogs.Count; catalogIndex++)
            {
                addCatalogToMenu(_menu.Items, rootCatalog, catalogs[catalogIndex]);
            }

            addClipsToMenu(_menu.Items, rootCatalog, rootCatalog, rootCatalogClips);

            _menu.Width = _width;

            MenuCacheControl.SetMenu(_catalogID, _linkFormat, _menu);
        }
Example #3
0
        protected override void OnLoad(EventArgs e)
        {
            EnsureChildControls();

            // Cached menus are already Loaded
            if (_cached)
            {
                return;
            }

            DbContentCatalog rootCatalog;

//			CssInfo rootCssInfo;

            // Load the catalog to start building a menu from
            rootCatalog = new DbContentCatalog(_catalogID);

            DbContentCatalogCollection catalogs = rootCatalog.GetCatalogs();;

            catalogs.Sort(ContentCompareKey.MenuOrder);

            for (int catalogIndex = 0; catalogIndex < catalogs.Count; catalogIndex++)
            {
                addCatalogToSiteMap(_siteMap.Nodes, rootCatalog, catalogs[catalogIndex]);
            }

            DbContentClipCollection clips = rootCatalog.GetClips();

            clips.Sort(ContentCompareKey.MenuOrder);

            addClipsToSiteMap(_siteMap.Nodes, rootCatalog, rootCatalog, clips);

            _siteMap.Width = _width;

            SiteMapCacheControl.SetSiteMap(_catalogID, _linkFormat, _siteMap);
        }
Example #4
0
        private void renderCatalog(DbContentCatalog catalog, HtmlTextWriter output)
        {
            float calcSize;                                                                             // Calculated size of objects
            bool  openCatalog   = catalogIsOpen(catalog.ID);
            bool  catalogSelect = Page.User.IsInRole("CMS/Administrator") || Page.User.IsInRole(catalog.EditorRole.Name);
            bool  clipSelect;

            output.WriteFullBeginTag("tr");
            output.WriteLine();
            output.Indent++;

            output.WriteBeginTag("td");
            output.WriteAttribute("style", "padding-left:" + (indent * indentMultiplier + CellPadding.Value).ToString() + "px;");
            output.WriteAttribute("valign", "middle");
            output.WriteAttribute("width", "100%");
            output.Write(HtmlTextWriter.TagRightChar);

            //			if(catalogSelect)
            //			{
            output.WriteBeginTag("a");
            output.WriteAttribute("href", "javascript:" + Page.ClientScript.GetPostBackEventReference(this, "tog_" + catalog.ID.ToString()));
            output.Write(HtmlTextWriter.TagRightChar);
            //			}

            if (openCatalog)
            {
                output.WriteBeginTag("img");
                output.WriteAttribute("src", Page.ResolveUrl(minusIcon));
                output.WriteAttribute("align", "absmiddle");
                output.WriteAttribute("border", "0");
                output.Write(HtmlTextWriter.TagRightChar);
            }
            else
            {
                output.WriteBeginTag("img");
                output.WriteAttribute("src", Page.ResolveUrl(plusIcon));
                output.WriteAttribute("align", "absmiddle");
                output.WriteAttribute("border", "0");
                output.Write(HtmlTextWriter.TagRightChar);
            }

            //			if(catalogSelect)
            output.WriteEndTag("a");

            //			if(catalogSelect)
            //			{
            output.WriteBeginTag("a");
            output.WriteAttribute("href", "javascript:" + GetSelectReference(catalog.ID));
            output.Write(HtmlTextWriter.TagRightChar);
            //			}

            output.WriteBeginTag("img");
            output.WriteAttribute("src", Page.ResolveUrl(catalogIcon));
            output.WriteAttribute("align", "absmiddle");
            output.WriteAttribute("border", "0");
            output.Write(HtmlTextWriter.TagRightChar);

            if (catalog.ID == selectedID & isCatalogSelected)
            {
                output.Write("<strong>");
            }
            output.Write(catalog.ToString());
            if (catalog.ID == selectedID & isCatalogSelected)
            {
                output.Write("</strong>");
            }

            //			if(catalogSelect)
            output.WriteEndTag("a");

            output.WriteEndTag("td");
            output.WriteLine();

            output.WriteBeginTag("td");
            output.WriteAttribute("valign", "top");
            output.Write(HtmlTextWriter.TagRightChar);
            output.Write("&nbsp;");
            output.WriteEndTag("td");

            // Menu Tag
            output.WriteBeginTag("td");
            output.WriteAttribute("valign", "top");
            output.Write(HtmlTextWriter.TagRightChar);
            if (catalog.MenuEnabled)
            {
                output.Write("Menu");
            }
            else
            {
                output.Write("&nbsp;");
            }
            output.WriteEndTag("td");

            output.WriteBeginTag("td");
            output.WriteAttribute("valign", "top");
            output.Write(HtmlTextWriter.TagRightChar);
            output.Write("Catalog");
            output.WriteEndTag("td");

            output.WriteBeginTag("td");
            output.WriteAttribute("valign", "top");
            output.Write(HtmlTextWriter.TagRightChar);
            output.Write(catalog.ModifyDate.ToShortDateString());
            output.WriteEndTag("td");

            //			output.WriteFullBeginTag("td");
            //			output.Write("&nbsp;");
            //			output.WriteEndTag("td");
            //
            //			output.WriteFullBeginTag("td");
            //			output.Write("&nbsp;");
            //			output.WriteEndTag("td");

            output.Indent--;
            output.WriteEndTag("tr");
            output.WriteLine();

            indent++;

            if (openCatalog)
            {
                for (int x = 0; x < catalogs.Count; x++)
                {
                    DbContentCatalog childCatalog = catalogs[x];
                    if (childCatalog.ParentCatalog != null && childCatalog.ParentCatalog.ID == catalog.ID)
                    {
                        renderCatalog(childCatalog, output);
                    }
                }

                DbContentClipCollection clips = catalog.GetClips();
                clips.Sort(ContentCompareKey.MenuEnabled, ContentCompareKey.MenuOrder);

                foreach (DbContentClip clip in clips)
                {
                    // Do not display expired clips unless expire checkbox is selected
                    if (!cbExpired.Checked && DateTime.Now > clip.ExpirationDate)
                    {
                        continue;
                    }

                    // All clips to be selected ONLY if editor, author
                    clipSelect = Page.User.IsInRole(catalog.EditorRole.Name);

                    output.WriteFullBeginTag("tr");
                    output.WriteBeginTag("td");
                    output.WriteAttribute("style", "padding-left:" + (indent * indentMultiplier + CellPadding.Value).ToString() + "px;");
                    output.WriteAttribute("valign", "middle");
                    output.WriteAttribute("width", "100%");
                    output.Write(HtmlTextWriter.TagRightChar);

                    #region Prefix Icon Output - Should Be Empty For All Clips

                    output.WriteBeginTag("div");
                    output.WriteAttribute("style", "float:left;");
                    output.Write(HtmlTextWriter.TagRightChar);

                    output.WriteBeginTag("img");
                    output.WriteAttribute("src", Page.ResolveUrl(blankIcon));
                    output.WriteAttribute("align", "absmiddle");
                    output.WriteAttribute("border", "0");
                    output.Write(HtmlTextWriter.TagRightChar);

                    output.WriteEndTag("div");

                    #endregion

                    #region Icon Output

                    output.WriteBeginTag("div");
                    output.WriteAttribute("style", "float:left;");
                    output.Write(HtmlTextWriter.TagRightChar);

                    if (clipSelect)
                    {
                        output.WriteBeginTag("a");
                        output.WriteAttribute("href", "javascript:" + Page.ClientScript.GetPostBackEventReference(this, "csel_" + clip.ID.ToString()));
                        output.Write(HtmlTextWriter.TagRightChar);
                    }

                    // Clip Icon
                    output.WriteBeginTag("img");
                    if (clip.ExpirationDate <= DateTime.Now)
                    {
                        output.WriteAttribute("src", Page.ResolveUrl(expiredIcon));
                    }
                    else if (clip.PublishDate <= DateTime.Now)
                    {
                        output.WriteAttribute("src", Page.ResolveUrl(publishedIcon));
                    }
                    else
                    {
                        output.WriteAttribute("src", Page.ResolveUrl(prePublishedIcon));
                    }
                    output.WriteAttribute("align", "absmiddle");
                    output.WriteAttribute("border", "0");
                    output.Write(HtmlTextWriter.TagRightChar);

                    if (clipSelect)
                    {
                        output.WriteEndTag("a");
                    }

                    output.WriteEndTag("div");

                    #endregion

                    #region Title Output

                    output.WriteBeginTag("div");
                    output.WriteAttribute("style", "padding-top:3px;float:left;");

                    // Tooltip Properties
                    output.WriteAttribute("onmouseover",
                                          ControlExtender.GetTooltipStartReference(constructTooltip(clip), "#ffffe0", 0));
                    output.WriteAttribute("onmouseout", ControlExtender.GetTooltipEndReference());

                    output.Write(HtmlTextWriter.TagRightChar);

                    if (clipSelect)
                    {
                        output.WriteBeginTag("a");
                        output.WriteAttribute("href", "javascript:" + Page.ClientScript.GetPostBackEventReference(this, "csel_" + clip.ID.ToString()));
                        output.Write(HtmlTextWriter.TagRightChar);
                    }

                    if (selectedClipID == clip.ID & !isCatalogSelected)
                    {
                        output.Write("<strong>");
                    }
                    // Be sure to strip html tags!
                    output.Write(Regex.Replace(clip.Title, "<[^>]*>", ""));
                    if (selectedClipID == clip.ID & !isCatalogSelected)
                    {
                        output.Write("</strong>");
                    }

                    if (clipSelect)
                    {
                        output.WriteEndTag("a");
                    }

                    output.WriteEndTag("div");

                    #endregion

                    output.WriteEndTag("td");

                    // Calculate size
                    calcSize = ((float)clip.Body.Length) / 1024;
                    output.WriteBeginTag("td");
                    output.WriteAttribute("nowrap", "true");
                    output.WriteAttribute("valign", "top");
                    output.Write(HtmlTextWriter.TagRightChar);
                    output.Write(calcSize.ToString("n1"));
                    output.Write(" KB");
                    output.WriteEndTag("td");

                    // Menu Tag
                    output.WriteBeginTag("td");
                    output.WriteAttribute("valign", "top");
                    output.Write(HtmlTextWriter.TagRightChar);
                    if (clip.MenuEnabled)
                    {
                        output.Write("Menu");
                    }
                    else
                    {
                        output.Write("&nbsp;");
                    }
                    output.WriteEndTag("td");

                    output.WriteBeginTag("td");
                    output.WriteAttribute("valign", "top");
                    output.Write(HtmlTextWriter.TagRightChar);
                    output.Write("Clip");
                    output.WriteEndTag("td");

                    output.WriteBeginTag("td");
                    output.WriteAttribute("valign", "top");
                    output.Write(HtmlTextWriter.TagRightChar);
                    output.Write(clip.ModifyDate.ToShortDateString());
                    output.WriteEndTag("td");

                    //					output.WriteBeginTag("td");
                    //					output.WriteAttribute("valign", "top");
                    //					output.Write(HtmlTextWriter.TagRightChar);
                    //					output.Write(clip.PublishDate.ToShortDateString());
                    //					output.WriteEndTag("td");
                    //
                    //					output.WriteBeginTag("td");
                    //					output.WriteAttribute("valign", "top");
                    //					output.Write(HtmlTextWriter.TagRightChar);
                    //					output.Write(clip.ExpirationDate.ToShortDateString());
                    //					output.WriteEndTag("td");

                    output.WriteEndTag("tr");
                }
            }

            indent--;
        }
Example #5
0
        // --- Begin Custom Code ---

        private void initializeDefaults()
        {
            int newMenuOrder = 1;
            int newSortOrder = 1;

            DbContentCatalog        catalog = new DbContentCatalog(catalogID);
            DbContentClipCollection clips   = catalog.GetClips();

            // Find Max Orders
            foreach (DbContentClip clip in clips)
            {
                if (clip.MenuOrder >= newMenuOrder)
                {
                    newMenuOrder = clip.MenuOrder + 1;
                }
                if (clip.SortOrder >= newSortOrder)
                {
                    newSortOrder = clip.SortOrder + 1;
                }
            }

            this.tbKeywords.Text = catalog.DefaultKeywords;
            this.calPublishDateP.SelectedDate =
                DateTime.Now.Add(catalog.DefaultTimeToPublish);
            this.calExpirationDateP.SelectedDate =
                this.calPublishDateP.SelectedDate.Add(catalog.DefaultTimeToExpire);
            this.calArchiveDateP.SelectedDate =
                this.calPublishDateP.SelectedDate.Add(catalog.DefaultTimeToArchive);
            this.cbCommentsEnabled.Checked = catalog.CommentsEnabled;
            this.cbMenuEnabled.Checked     = catalog.MenuEnabled;
            this.tbAuthors.Text            = string.Empty;
            this.tbEditors.Text            = string.Empty;
            this.tbMenuOrder.Text          = newMenuOrder.ToString();
            this.tbPriority.Text           = "-1";
            this.tbSortOrder.Text          = newSortOrder.ToString();

            foreach (ListItem item in msParentCatalog.Items)
            {
                item.Selected = catalogID.ToString() == item.Value;
            }

            if (catalog.DefaultStatus != null)
            {
                foreach (ListItem item in msStatus.Items)
                {
                    item.Selected = catalog.DefaultStatus.ID.ToString() == item.Value;
                }
            }
            else
            {
                msStatus.SelectedIndex = 0;
            }

            if (catalog.DefaultRating != null)
            {
                foreach (ComboBoxItem item in ratingComboBox.Items)
                {
                    item.Selected = catalog.DefaultRating.ID.ToString() == item.Value;
                }
            }
            else
            {
                ratingComboBox.SelectedIndex = 0;
            }
        }