Example #1
0
        public virtual void SetObject(IMediaDetail obj)
        {
            SelectedItem = obj;

            var commonPanel = (WebApplication.Admin.Controls.MediaTypes.CommonPanel)WebFormHelper.FindControlRecursive(this, "CommonPanel");

            if (commonPanel != null)
            {
                commonPanel.SetObject(obj);

                var panelFields = (Panel)WebFormHelper.FindControlRecursive(this, "PanelFields");

                if (panelFields != null)
                {
                    commonPanel.SetPanelFields(panelFields);
                }
            }
        }
Example #2
0
        protected void Reply_OnClick(object sender, EventArgs e)
        {
            var linkButton = (LinkButton)sender;
            var replyPanel = (Panel)WebFormHelper.FindControlRecursive(linkButton.Parent, "ReplyPanel");

            var replyPanels = WebFormHelper.FindControlsRecursive(ItemsList, "ReplyPanel");

            foreach (var panel in replyPanels)
            {
                panel.Visible = false;
            }

            ReplyToCommentID = long.Parse(linkButton.CommandArgument);

            if (replyPanel != null)
            {
                replyPanel.Visible = true;
            }
        }
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            canAccessSection = CurrentUser.HasPermission(PermissionsEnum.AccessAdvanceOptions);

            base.OnInit(e);

            if ((!canAccessSection) && (!IsPostBack))
            {
                DisplayAccessError();
            }

            Control ContentPlaceHolder1 = WebFormHelper.FindControlRecursive(Page.Master, "ContentPlaceHolder1");

            if ((ContentPlaceHolder1 != null) && (!canAccessSection))
            {
                ContentPlaceHolder1.Visible = false;
            }
        }
Example #4
0
 public Control FindControlRecursive(string id)
 {
     return(WebFormHelper.FindControlRecursive(this.Page, id));
 }
Example #5
0
        private void UpdateMediaFieldsFromObject()
        {
            foreach (var FieldGroupTabContent in FieldGroupTabContents.Items)
            {
                var MediaFieldsList = (ListView)FieldGroupTabContent.FindControl("MediaFieldsList");

                var index = 0;
                foreach (var item in MediaFieldsList.Items)
                {
                    var mediaDetailField = (MediaDetailField)((IEnumerable <object>)MediaFieldsList.DataSource).ElementAt(index);
                    index++;

                    var fieldIdField = (HiddenField)item.FindControl("FieldID");
                    var dynamicField = (PlaceHolder)item.FindControl("DynamicField");
                    var fieldId      = long.Parse(fieldIdField.Value.ToString());

                    if (dynamicField.Controls.Count == 0)
                    {
                        return;
                    }

                    var control = dynamicField.Controls[0];

                    if (control.Controls.Count > 0)
                    {
                        foreach (Control ctrl in control.Controls)
                        {
                            if (!(ctrl is LiteralControl))
                            {
                                control = ctrl;
                            }
                        }
                    }

                    var adminPanel = WebFormHelper.FindControlRecursive(dynamicField, "AdminPanel");

                    if (adminPanel != null)
                    {
                        control = adminPanel.Parent;
                    }

                    var fieldValue = mediaDetailField.FieldValue.Replace("{BaseUrl}", URIHelper.BaseUrl);

                    if (control is WebApplication.Admin.Controls.Fields.IFieldControl)
                    {
                        var ctrl = ((WebApplication.Admin.Controls.Fields.IFieldControl)control);
                        ctrl.FieldID = fieldId;
                        ctrl.SetValue(fieldValue);
                    }
                    else
                    {
                        if (mediaDetailField.FieldValue != "{" + mediaDetailField.SetAdminControlValue + "}")
                        {
                            if (mediaDetailField.SetAdminControlValue.Contains("@"))
                            {
                                try
                                {
                                    var returnData = ParserHelper.ParseData(mediaDetailField.SetAdminControlValue, new { Control = control, Field = mediaDetailField, NewValue = fieldValue });
                                }
                                catch (Exception ex)
                                {
                                    BasePage.DisplayErrorMessage("Error", ErrorHelper.CreateError(ex));
                                }
                            }
                            else
                            {
                                ParserHelper.SetValue(control, mediaDetailField.SetAdminControlValue, fieldValue);
                            }
                        }
                    }
                }
            }
        }
Example #6
0
        private void UpdateObjectFromMediaFields()
        {
            foreach (var FieldGroupTabContent in FieldGroupTabContents.Items)
            {
                var MediaFieldsList = (ListView)FieldGroupTabContent.FindControl("MediaFieldsList");

                var index = 0;
                foreach (var item in MediaFieldsList.Items)
                {
                    var fieldIdField = (HiddenField)item.FindControl("FieldID");
                    var dynamicField = (PlaceHolder)item.FindControl("DynamicField");
                    var fieldId      = long.Parse(fieldIdField.Value.ToString());

                    //var dataItem = MediasMapper.GetDataModel().Fields.SingleOrDefault(i => i.ID == fieldId);

                    var dataItem = (MediaDetailField)((IEnumerable <object>)MediaFieldsList.DataSource).ElementAt(index);
                    index++;

                    if (dynamicField.Controls.Count == 0)
                    {
                        return;
                    }

                    var control = dynamicField.Controls[0];

                    if (control.Controls.Count > 0)
                    {
                        foreach (Control ctrl in control.Controls)
                        {
                            if (!(ctrl is LiteralControl))
                            {
                                control = ctrl;
                            }
                        }
                    }

                    var adminPanel = WebFormHelper.FindControlRecursive(dynamicField, "AdminPanel");

                    if (adminPanel != null)
                    {
                        control = adminPanel.Parent;
                    }

                    if (control is WebApplication.Admin.Controls.Fields.IFieldControl)
                    {
                        var valAsString = ((WebApplication.Admin.Controls.Fields.IFieldControl)control).GetValue().ToString();

                        if (!string.IsNullOrEmpty(valAsString))
                        {
                            valAsString = MediaDetailsMapper.ConvertUrlsToShortCodes(valAsString);

                            if (valAsString.Contains(URIHelper.BaseUrl))
                            {
                                valAsString = valAsString.Replace(URIHelper.BaseUrl, "{BaseUrl}");
                            }
                        }

                        dataItem.FieldValue = MediaDetailsMapper.ConvertUrlsToShortCodes(valAsString);
                    }
                    else
                    {
                        var fieldValue = "";

                        if (dataItem.GetAdminControlValue.Contains("@"))
                        {
                            fieldValue = ParserHelper.ParseData(dataItem.GetAdminControlValue, new { Control = control });
                        }
                        else
                        {
                            fieldValue = ParserHelper.ParseData("{" + dataItem.GetAdminControlValue + "}", control);
                        }

                        if (fieldValue != "{" + dataItem.GetAdminControlValue + "}")
                        {
                            fieldValue          = MediaDetailsMapper.ConvertUrlsToShortCodes(fieldValue);
                            dataItem.FieldValue = fieldValue.Replace(URIHelper.BaseUrl, "{BaseUrl}");
                        }
                        else
                        {
                            dataItem.FieldValue = "";
                        }
                    }
                }
            }

            /*var returnObj = MediaDetailsMapper.Update(SelectedItem);
             *
             * if (returnObj.IsError)
             *  BasePage.DisplayErrorMessage("Error", returnObj.Error);*/
        }