This class is used as a representation for the Settings of the Custom Display control. It contains strongly typed names for each of the required settings. The reason it exists is so that it can be used in two contexts. The CustomDisplayOption control and CustomDisplay control. This centralizes the settings properties into one place to avoid duplicate code and errors. HK
        private void Page_Load(object sender, EventArgs e)
        {
            //store the "view" for this item
            RecordView();

            //SetPageTitle();
            _categoryId = ItemId;
            _customDisplaySettings = new CustomDisplaySettings(Settings, TabModuleId);

            UsePaging = _customDisplaySettings.AllowPaging;
            UseCustomSort = _customDisplaySettings.UseCustomSort;

            if (_customDisplaySettings.GetParentFromQueryString)
            {
                //CHECK IF THERE'S ANYTHING IN THE QS AND REACT

                object o = Request.QueryString["ItemId"];
                if (o != null)
                {
                    int itemId;
                    if (int.TryParse(o.ToString(), NumberStyles.Integer, CultureInfo.InvariantCulture, out itemId))
                    {
                        //we need to load the children, rather than siblings if _customDisplaySettings.GetRelatedChildren is enabled and the itemid is for a category, not an article
                        if (_customDisplaySettings.GetRelatedChildren && Item.GetItemType(itemId) == ItemType.Category.Name)
                        {
                            _categoryId = itemId;
                        }
                        //otherwise we're going to get the parent category for the itemid passed in.
                        else
                            _categoryId = Category.GetParentCategory(itemId, PortalId);
                    }
                }
            }

            if (_customDisplaySettings.EnableRss)
            {

                //TODO: replace the hyperlink control on the display side and insert our Link/IMAGE dynamically so we can set the alt text.
                lnkRss.Visible = true;
                string rssImage = Localization.GetString("rssImage", LocalResourceFile);
            #if DEBUG
                rssImage = rssImage.Replace("[L]", string.Empty);
            #endif

                imgRss.Src= ApplicationUrl + rssImage; //"/images/xml.gif";
                imgRss.Alt = Localization.GetString("rssAlt", LocalResourceFile);

                lnkRss.Attributes.Add("type", "application/rss+xml");
                lnkRss.ToolTip = Localization.GetString("rssAlt", LocalResourceFile);

                if (AllowTags && _tagQuery != null && _tagQuery.Count > 0)
                {
                    lnkRss.NavigateUrl = GetRssLinkUrl(PortalId, "TagFeed", _qsTags);
                    SetRssUrl(lnkRss.NavigateUrl, Localization.GetString("rssAlt", LocalResourceFile));
                }
                else
                {
                    //check for a setting of an external URL
                    ItemVersionSetting rssSetting = ItemVersionSetting.GetItemVersionSetting(VersionInfoObject.ItemVersionId, "CategorySettings", "RssUrl", PortalId);
                    if (rssSetting != null && rssSetting.PropertyValue!=string.Empty)
                    {
                        lnkRss.NavigateUrl = rssSetting.PropertyValue;
                        SetExternalRssUrl(lnkRss.NavigateUrl, Localization.GetString("rssAlt", LocalResourceFile));

                    }
                    else
                    {
                        //TODO: configure the # of items for an RSS feed
                        lnkRss.NavigateUrl = GetRssLinkUrl(_categoryId, 25, ItemType.Article.GetId(), PortalId, "ItemListing");
                        SetRssUrl(lnkRss.NavigateUrl, Localization.GetString("rssAlt", LocalResourceFile));
                    }

                }

            }

            //store the URL into session for the return to list options
            if (UseSessionForReturnToList(PortalId))
            {
                Session["PublishListLink"] = Request.Url.PathAndQuery;
            }

            //check if admin, enable edit links
            if ((IsAdmin || IsAuthor) && IsEditable)
            {
                Visibility = true;
                EditText = Localization.GetString("EditText", LocalResourceFile);
            }
            else
            {
                Visibility = false;
                EditText = string.Empty;
            }

            try
            {
                if (_customDisplaySettings.ItemTypeId == -2)
                {
                    lblMessage.Text = Localization.GetString("SetupItemType", LocalResourceFile);
                    return;
                }

                lstItems.DataSource = GetData();
                lstItems.DataBind();

                if ((_customDisplaySettings.ShowParent || _customDisplaySettings.ShowParentDescription) && _categoryId != -1)
                {

                    Category parentCategory = Category.GetCategory(_categoryId, PortalId);
                    if (_customDisplaySettings.ShowParent)
                    {
                        divParentCategoryName.Visible = true;
                        lblCategory.Text = parentCategory.Name;
                    }

                    //show the category description if enabled.
                    if (_customDisplaySettings.ShowParentDescription)
                    {
                        divParentCategoryDescription.Visible = true;
                        lblCategoryDescription.Text = Utility.ReplaceTokens(parentCategory.Description);
                    }

                }
                else
                {
                    lblCategory.Visible = false;
                }
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
        private void Page_Load(object sender, EventArgs e)
        {
            //store the "view" for this item
            RecordView();

            //SetPageTitle();
            _categoryId            = ItemId;
            _customDisplaySettings = new CustomDisplaySettings(Settings, TabModuleId);

            UsePaging     = _customDisplaySettings.AllowPaging;
            UseCustomSort = _customDisplaySettings.UseCustomSort;

            if (_customDisplaySettings.GetParentFromQueryString)
            {
                //CHECK IF THERE'S ANYTHING IN THE QS AND REACT

                object o = Request.QueryString["ItemId"];
                if (o != null)
                {
                    int itemId;
                    if (int.TryParse(o.ToString(), NumberStyles.Integer, CultureInfo.InvariantCulture, out itemId))
                    {
                        //we need to load the children, rather than siblings if _customDisplaySettings.GetRelatedChildren is enabled and the itemid is for a category, not an article
                        if (_customDisplaySettings.GetRelatedChildren && Item.GetItemType(itemId) == ItemType.Category.Name)
                        {
                            _categoryId = itemId;
                        }
                        //otherwise we're going to get the parent category for the itemid passed in.
                        else
                        {
                            _categoryId = Category.GetParentCategory(itemId, PortalId);
                        }
                    }
                }
            }

            if (_customDisplaySettings.EnableRss)
            {
                //TODO: replace the hyperlink control on the display side and insert our Link/IMAGE dynamically so we can set the alt text.
                lnkRss.Visible = true;
                string rssImage = Localization.GetString("rssImage", LocalResourceFile);
#if DEBUG
                rssImage = rssImage.Replace("[L]", string.Empty);
#endif

                imgRss.Src = ApplicationUrl + rssImage; //"/images/xml.gif";
                imgRss.Alt = Localization.GetString("rssAlt", LocalResourceFile);

                lnkRss.Attributes.Add("type", "application/rss+xml");
                lnkRss.ToolTip = Localization.GetString("rssAlt", LocalResourceFile);


                if (AllowTags && _tagQuery != null && _tagQuery.Count > 0)
                {
                    lnkRss.NavigateUrl = GetRssLinkUrl(PortalId, "TagFeed", _qsTags);
                    SetRssUrl(lnkRss.NavigateUrl, Localization.GetString("rssAlt", LocalResourceFile));
                }
                else
                {
                    //check for a setting of an external URL
                    ItemVersionSetting rssSetting = ItemVersionSetting.GetItemVersionSetting(VersionInfoObject.ItemVersionId, "CategorySettings", "RssUrl", PortalId);
                    if (rssSetting != null && rssSetting.PropertyValue != string.Empty)
                    {
                        lnkRss.NavigateUrl = rssSetting.PropertyValue;
                        SetExternalRssUrl(lnkRss.NavigateUrl, Localization.GetString("rssAlt", LocalResourceFile));
                    }
                    else
                    {
                        //TODO: configure the # of items for an RSS feed
                        lnkRss.NavigateUrl = GetRssLinkUrl(_categoryId, 25, ItemType.Article.GetId(), PortalId, "ItemListing");
                        SetRssUrl(lnkRss.NavigateUrl, Localization.GetString("rssAlt", LocalResourceFile));
                    }
                }
            }

            //store the URL into session for the return to list options
            if (UseSessionForReturnToList(PortalId))
            {
                Session["PublishListLink"] = Request.Url.PathAndQuery;
            }

            //check if admin, enable edit links
            if ((IsAdmin || IsAuthor) && IsEditable)
            {
                Visibility = true;
                EditText   = Localization.GetString("EditText", LocalResourceFile);
            }
            else
            {
                Visibility = false;
                EditText   = string.Empty;
            }

            try
            {
                if (_customDisplaySettings.ItemTypeId == -2)
                {
                    lblMessage.Text = Localization.GetString("SetupItemType", LocalResourceFile);
                    return;
                }

                lstItems.DataSource = GetData();
                lstItems.DataBind();

                if ((_customDisplaySettings.ShowParent || _customDisplaySettings.ShowParentDescription) && _categoryId != -1)
                {
                    Category parentCategory = Category.GetCategory(_categoryId, PortalId);
                    if (_customDisplaySettings.ShowParent)
                    {
                        divParentCategoryName.Visible = true;
                        lblCategory.Text = parentCategory.Name;
                    }

                    //show the category description if enabled.
                    if (_customDisplaySettings.ShowParentDescription)
                    {
                        divParentCategoryDescription.Visible = true;
                        lblCategoryDescription.Text          = Utility.ReplaceTokens(parentCategory.Description);
                    }
                }
                else
                {
                    lblCategory.Visible = false;
                }
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
示例#3
0
        public override void LoadSettings()
        {
            _customDisplaySettings = new CustomDisplaySettings(Settings, TabModuleId);

            try
            {
                ddlItemTypeList.DataTextField  = "Name";
                ddlItemTypeList.DataValueField = "ItemTypeId";
                ddlItemTypeList.DataSource     = Item.GetItemTypes(PortalId);
                ddlItemTypeList.DataBind();

                ddlItemTypeList.Items.Insert(0, new ListItem(Localization.GetString("ChooseOne", LocalResourceFile), "-2"));
                ddlItemTypeList.Items.Insert(1, new ListItem(Localization.GetString("CategoriesAndArticles", LocalResourceFile), "-1"));
                ListItem li = ddlItemTypeList.Items.FindByValue(_customDisplaySettings.ItemTypeId.ToString(CultureInfo.InvariantCulture));
                li.Selected = true;

                li = new ListItem(Localization.GetString(DisplayOption.Title.ToString(), LocalResourceFile), DisplayOption.Title.ToString())
                {
                    Selected = _customDisplaySettings.DisplayOptionTitle
                };
                chkDisplayOptions.Items.Add(li);
                li = new ListItem(Localization.GetString(DisplayOption.Author.ToString(), LocalResourceFile), DisplayOption.Author.ToString())
                {
                    Selected = _customDisplaySettings.DisplayOptionAuthor
                };
                chkDisplayOptions.Items.Add(li);
                li = new ListItem(Localization.GetString(DisplayOption.Date.ToString(), LocalResourceFile), DisplayOption.Date.ToString())
                {
                    Selected = _customDisplaySettings.DisplayOptionDate
                };
                chkDisplayOptions.Items.Add(li);

                li = new ListItem(Localization.GetString(DisplayOption.Abstract.ToString(), LocalResourceFile), DisplayOption.Abstract.ToString())
                {
                    Selected = _customDisplaySettings.DisplayOptionAbstract
                };
                chkDisplayOptions.Items.Add(li);
                li = new ListItem(Localization.GetString(DisplayOption.Thumbnail.ToString(), LocalResourceFile), DisplayOption.Thumbnail.ToString())
                {
                    Selected = _customDisplaySettings.DisplayOptionThumbnail
                };
                chkDisplayOptions.Items.Add(li);
                li = new ListItem(Localization.GetString(DisplayOption.ReadMore.ToString(), LocalResourceFile), DisplayOption.ReadMore.ToString())
                {
                    Selected = _customDisplaySettings.DisplayOptionReadMore
                };
                chkDisplayOptions.Items.Add(li);

                li = new ListItem(Localization.GetString(DisplayOption.Stats.ToString(), LocalResourceFile), DisplayOption.Stats.ToString())
                {
                    Selected = _customDisplaySettings.DisplayOptionStats
                };
                chkDisplayOptions.Items.Add(li);


                int maxItems = _customDisplaySettings.MaxDisplayItems;
                if (maxItems > -1)
                {
                    txtMaxItems.Text = maxItems.ToString(CultureInfo.InvariantCulture);
                }
                txtMaxItems.Enabled = (maxItems > -1);
                chkShowAll.Checked  = (maxItems == -1);

                ItemRelationship.DisplayCategoryHierarchy(ddlCategory, -1, PortalId, false);
                if (ddlItemTypeList.SelectedValue != ItemType.Article.GetId().ToString(CultureInfo.InvariantCulture) && ddlCategory.Items.FindByValue("-1") == null)
                {
                    ddlCategory.Items.Insert(0, new ListItem(Localization.GetString("NoCategory", LocalResourceFile), TopLevelCategoryItemType.Category.GetId().ToString(CultureInfo.InvariantCulture)));
                    //ddlItemTypeList.Items.Insert(1, new ListItem(Localization.GetString("CategoriesAndArticles", LocalResourceFile), "-1"));
                }

                if (_customDisplaySettings.CategoryId > 0)
                {
                    li = ddlCategory.Items.FindByValue(_customDisplaySettings.CategoryId.ToString(CultureInfo.InvariantCulture));
                    if (li != null)
                    {
                        li.Selected = true;
                    }
                }

                if (ddlCategory.SelectedValue == "-1" || ddlCategory.SelectedValue == TopLevelCategoryItemType.Category.GetId().ToString(CultureInfo.InvariantCulture))
                {
                    lblShowParent.Visible            = false;
                    chkShowParent.Visible            = false;
                    lblShowParentDescription.Visible = false;
                    chkShowParentDescription.Visible = false;
                }
                else
                {
                    lblShowParent.Visible = true;
                    chkShowParent.Visible = true;
                }
                chkShowParent.Checked            = _customDisplaySettings.ShowParent;
                chkShowParentDescription.Checked = _customDisplaySettings.ShowParentDescription;

                chkRelatedItem.Checked = _customDisplaySettings.GetParentFromQueryString;

                chkRelatedItemLevel.Checked = _customDisplaySettings.GetRelatedChildren;

                chkAllowPaging.Checked = _customDisplaySettings.AllowPaging;

                ddlSortOption.Items.Add(new ListItem(Localization.GetString("TitleSort", LocalResourceFile), CustomDisplaySettings.TitleSort));
                ddlSortOption.Items.Add(new ListItem(Localization.GetString("DateSort", LocalResourceFile), CustomDisplaySettings.DateSort));
                ddlSortOption.Items.Add(new ListItem(Localization.GetString("LastUpdatedSort", LocalResourceFile), CustomDisplaySettings.LastUpdatedSort));
                ddlSortOption.Items.Add(new ListItem(Localization.GetString("StartDateSort", LocalResourceFile), CustomDisplaySettings.StartDateSort));
                if (ModuleBase.IsViewTrackingEnabledForPortal(PortalId) && ddlItemTypeList.SelectedValue == ItemType.Article.GetId().ToString(CultureInfo.InvariantCulture))
                {
                    //only show this if the Portal is configured to track views and the item type is Article. hk
                    ddlSortOption.Items.Add(new ListItem(Localization.GetString("MostPopularSort", LocalResourceFile), CustomDisplaySettings.MostPopularSort));
                }

                li = ddlSortOption.Items.FindByValue(_customDisplaySettings.SortOption);
                if (li != null)
                {
                    li.Selected = true;
                }

                li = rbSortDirection.Items.FindByValue(_customDisplaySettings.SortDirection);
                if (li != null)
                {
                    li.Selected = true;
                }
                txtDateFormat.Text = _customDisplaySettings.DateFormat;

                chkEnableRss.Checked = _customDisplaySettings.EnableRss;

                chkUseCustomSort.Checked = _customDisplaySettings.UseCustomSort;

                lnkSortCategory.NavigateUrl = BuildSortUrl();
                lnkSortCategory.Target      = "_blank";
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
        public override void LoadSettings()
        {
            _customDisplaySettings = new CustomDisplaySettings(Settings, TabModuleId);

            try
            {
                ddlItemTypeList.DataTextField = "Name";
                ddlItemTypeList.DataValueField = "ItemTypeId";
                ddlItemTypeList.DataSource = Item.GetItemTypes(PortalId);
                ddlItemTypeList.DataBind();

                ddlItemTypeList.Items.Insert(0, new ListItem(Localization.GetString("ChooseOne", LocalResourceFile), "-2"));
                ddlItemTypeList.Items.Insert(1, new ListItem(Localization.GetString("CategoriesAndArticles", LocalResourceFile), "-1"));
                ListItem li = ddlItemTypeList.Items.FindByValue(_customDisplaySettings.ItemTypeId.ToString(CultureInfo.InvariantCulture));
                li.Selected = true;

                li = new ListItem(Localization.GetString(DisplayOption.Title.ToString(), LocalResourceFile), DisplayOption.Title.ToString())
                         {Selected = _customDisplaySettings.DisplayOptionTitle};
                chkDisplayOptions.Items.Add(li);
                li = new ListItem(Localization.GetString(DisplayOption.Author.ToString(), LocalResourceFile), DisplayOption.Author.ToString())
                         {Selected = _customDisplaySettings.DisplayOptionAuthor};
                chkDisplayOptions.Items.Add(li);
                li = new ListItem(Localization.GetString(DisplayOption.Date.ToString(), LocalResourceFile), DisplayOption.Date.ToString())
                         {Selected = _customDisplaySettings.DisplayOptionDate};
                chkDisplayOptions.Items.Add(li);

                li = new ListItem(Localization.GetString(DisplayOption.Abstract.ToString(), LocalResourceFile), DisplayOption.Abstract.ToString())
                         {Selected = _customDisplaySettings.DisplayOptionAbstract};
                chkDisplayOptions.Items.Add(li);
                li = new ListItem(Localization.GetString(DisplayOption.Thumbnail.ToString(), LocalResourceFile), DisplayOption.Thumbnail.ToString())
                         {Selected = _customDisplaySettings.DisplayOptionThumbnail};
                chkDisplayOptions.Items.Add(li);
                li = new ListItem(Localization.GetString(DisplayOption.ReadMore.ToString(), LocalResourceFile), DisplayOption.ReadMore.ToString())
                         {Selected = _customDisplaySettings.DisplayOptionReadMore};
                chkDisplayOptions.Items.Add(li);

                li = new ListItem(Localization.GetString(DisplayOption.Stats.ToString(), LocalResourceFile), DisplayOption.Stats.ToString())
                    { Selected = _customDisplaySettings.DisplayOptionStats };
                chkDisplayOptions.Items.Add(li);

                int maxItems = _customDisplaySettings.MaxDisplayItems;
                if (maxItems > -1)
                {
                    txtMaxItems.Text = maxItems.ToString(CultureInfo.InvariantCulture);
                }
                txtMaxItems.Enabled = (maxItems > -1);
                chkShowAll.Checked = (maxItems == -1);

                ItemRelationship.DisplayCategoryHierarchy(ddlCategory, -1, PortalId, false);
                if (ddlItemTypeList.SelectedValue != ItemType.Article.GetId().ToString(CultureInfo.InvariantCulture) && ddlCategory.Items.FindByValue("-1") == null)
                {
                    ddlCategory.Items.Insert(0, new ListItem(Localization.GetString("NoCategory", LocalResourceFile), TopLevelCategoryItemType.Category.GetId().ToString(CultureInfo.InvariantCulture)));
                    //ddlItemTypeList.Items.Insert(1, new ListItem(Localization.GetString("CategoriesAndArticles", LocalResourceFile), "-1"));
                }

                if (_customDisplaySettings.CategoryId > 0)
                {
                    li = ddlCategory.Items.FindByValue(_customDisplaySettings.CategoryId.ToString(CultureInfo.InvariantCulture));
                    if (li != null)
                    {
                        li.Selected = true;
                    }
                }

                if (ddlCategory.SelectedValue == "-1" || ddlCategory.SelectedValue == TopLevelCategoryItemType.Category.GetId().ToString(CultureInfo.InvariantCulture))
                {
                    lblShowParent.Visible = false;
                    chkShowParent.Visible = false;
                    lblShowParentDescription.Visible = false;
                    chkShowParentDescription.Visible = false;
                }
                else
                {
                    lblShowParent.Visible = true;
                    chkShowParent.Visible = true;
                }
                chkShowParent.Checked = _customDisplaySettings.ShowParent;
                chkShowParentDescription.Checked = _customDisplaySettings.ShowParentDescription;

                chkRelatedItem.Checked = _customDisplaySettings.GetParentFromQueryString;

                chkRelatedItemLevel.Checked = _customDisplaySettings.GetRelatedChildren;

                chkAllowPaging.Checked = _customDisplaySettings.AllowPaging;

                ddlSortOption.Items.Add(new ListItem(Localization.GetString("TitleSort", LocalResourceFile), CustomDisplaySettings.TitleSort));
                ddlSortOption.Items.Add(new ListItem(Localization.GetString("DateSort", LocalResourceFile), CustomDisplaySettings.DateSort));
                ddlSortOption.Items.Add(new ListItem(Localization.GetString("LastUpdatedSort", LocalResourceFile), CustomDisplaySettings.LastUpdatedSort));
                ddlSortOption.Items.Add(new ListItem(Localization.GetString("StartDateSort", LocalResourceFile), CustomDisplaySettings.StartDateSort));
                if (ModuleBase.IsViewTrackingEnabledForPortal(PortalId) && ddlItemTypeList.SelectedValue == ItemType.Article.GetId().ToString(CultureInfo.InvariantCulture))
                {
                    //only show this if the Portal is configured to track views and the item type is Article. hk
                    ddlSortOption.Items.Add(new ListItem(Localization.GetString("MostPopularSort", LocalResourceFile), CustomDisplaySettings.MostPopularSort));
                }

                li = ddlSortOption.Items.FindByValue(_customDisplaySettings.SortOption);
                if (li != null)
                {
                    li.Selected = true;
                }

                li = rbSortDirection.Items.FindByValue(_customDisplaySettings.SortDirection);
                if (li != null)
                {
                    li.Selected = true;
                }
                txtDateFormat.Text = _customDisplaySettings.DateFormat;

                chkEnableRss.Checked = _customDisplaySettings.EnableRss;

                chkUseCustomSort.Checked = _customDisplaySettings.UseCustomSort;

                lnkSortCategory.NavigateUrl = BuildSortUrl();
                lnkSortCategory.Target = "_blank";
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }