コード例 #1
0
        protected void ProcessView()
        {
            List <ContentGroupItemType> EditableItemsTypes = new List <ContentGroupItemType>();

            if (CurrentlyEditedItems.Any() && CurrentlyEditedItems.Any(c => c.ItemType == ContentGroupItemType.Content))
            {
                EditableItemsTypes.Add(ContentGroupItemType.Content);
                EditableItemsTypes.Add(ContentGroupItemType.Presentation);
            }
            if (SortOrder == -1 || CurrentlyEditedItems.Any(c => c.ItemType == ContentGroupItemType.ListContent))
            {
                EditableItemsTypes.Add(ContentGroupItemType.ListContent);
                EditableItemsTypes.Add(ContentGroupItemType.ListPresentation);
            }

            if (Items.Any() && Items.First().TemplateID.HasValue)
            {
                foreach (var TemplateDefault in Sexy.GetTemplateDefaults(Items.First().TemplateID.Value).Where(c => EditableItemsTypes.Contains(c.ItemType)))
                {
                    if (TemplateDefault.ContentTypeID.HasValue && TemplateDefault.ContentTypeID.Value > 0)
                    {
                        ContentGroupItem ContentGroupItem = null;
                        if (CurrentlyEditedItems.Any() && CurrentlyEditedItems.First().ContentGroupItemID != 0)
                        {
                            ContentGroupItem = CurrentlyEditedItems.FirstOrDefault(p => p.ItemType == TemplateDefault.ItemType);
                        }

                        var editControl = (EditContentGroupItem)LoadControl(System.IO.Path.Combine(TemplateSourceDirectory, "EditContentGroupItem.ascx"));
                        editControl.ContentGroupItemID = ContentGroupItem != null && ContentGroupItem.ContentGroupID != 0 ? ContentGroupItem.ContentGroupItemID : new int?();
                        editControl.ContentGroupID     = ContentGroupID.Value;
                        editControl.AppId          = AppId.Value;
                        editControl.ZoneId         = ZoneId.Value;
                        editControl.ItemType       = TemplateDefault.ItemType;
                        editControl.TemplateID     = Items.First().TemplateID.Value;
                        editControl.SortOrder      = CurrentlyEditedItems.Any() || SortOrder == -1 ? SortOrder : new int?();
                        editControl.ModuleID       = ModuleId;
                        editControl.TabID          = TabId;
                        editControl.AttributeSetID = TemplateDefault.ContentTypeID.Value;
                        phNewOrEditControls.Controls.Add(editControl);
                    }
                }
            }

            // Directly edit entity Id
            if ((!SortOrder.HasValue && EntityId.HasValue) || (!SortOrder.HasValue && AttributeSetId.HasValue && NewMode))
            {
                var editControl = (EditEntity)LoadControl(System.IO.Path.Combine(TemplateSourceDirectory, "EditEntity.ascx"));
                editControl.AppId          = AppId.Value;
                editControl.ZoneId         = ZoneId.Value;
                editControl.ModuleID       = ModuleId;
                editControl.TabID          = TabId;
                editControl.AttributeSetID = AttributeSetId.HasValue ? AttributeSetId.Value : Sexy.ContentContext.GetEntity(EntityId.Value).AttributeSetID;
                editControl.EntityId       = EntityId;
                phNewOrEditControls.Controls.Add(editControl);
            }
        }
コード例 #2
0
        /// <summary>
        /// Handles the control load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            // Add DNN Version to body Class
            SexyContent.AddDNNVersionToBodyClass(this);

            // Bind Languages Repeater
            var Languages = Sexy.ContentContext.GetLanguages().Where(l => l.Active).OrderByDescending(l => l.DimensionID == DefaultLanguageID).ThenBy(l => l.ExternalKey);

            if (Languages.Count() == 0)
            {
                pnlDimensionNav.Visible = false;
            }
            rptDimensions.DataSource = Languages;
            rptDimensions.DataBind();

            btnDelete.OnClientClick = "return confirm('" + LocalizeString("btnDelete.Confirm") + "')";
            btnDelete.Text          = Items.Count(p => p.ItemType == ContentGroupItemType.Content) > 1 ? LocalizeString("btnDelete.ListText") : LocalizeString("btnDelete.Text");
            btnDelete.Visible       = !NewMode && ContentGroupID.HasValue;

            // If there is something to edit
            if (CurrentlyEditedItems.Any())
            {
                // Settings link (to change content)
                hlkChangeContent.NavigateUrl = Sexy.GetElementSettingsLink(CurrentlyEditedItems.First().ContentGroupItemID, ModuleId, TabId, Request.RawUrl);

                // Show Change Content or Reference Link only if this is the default language
                var IsDefaultLanguage = LanguageID == DefaultLanguageID;
                hlkChangeContent.Visible = !NewMode && IsDefaultLanguage && (CurrentlyEditedItems.First().ItemType == ContentGroupItemType.Content || CurrentlyEditedItems.First().ItemType == ContentGroupItemType.ListContent);
            }

            // Show message if language is not active
            if (!Sexy.ContentContext.HasLanguages() || (LanguageID.HasValue && Sexy.ContentContext.GetDimension(LanguageID.Value).Active))
            {
                ProcessView();
            }
            else
            {
                pnlActions.Visible           = false;
                pnlLanguageNotActive.Visible = true;
                litLanguageName.Text         = LocaleController.Instance.GetLocale(System.Threading.Thread.CurrentThread.CurrentCulture.Name).Text;
                if (UserInfo.IsInRole(PortalSettings.AdministratorRoleName))
                {
                    btnActivateLanguage.Visible = true;
                }
            }
        }