Пример #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var menuMan = new MenuManager(true, false);
        var currentMenu = ((PigeonCms.BasePage)this.Page).MenuEntry;
        var menuList = new List<PigeonCms.Menu>();

        while (currentMenu.Id > 0)
        {
            menuList.Add(currentMenu);

            if (currentMenu.ParentId > 0)
                currentMenu = menuMan.GetByKey(currentMenu.ParentId);
            else
                currentMenu = new PigeonCms.Menu();
        }

        for (int i = 0; i < menuList.Count; i++)
        {
            string link = "<a href='" + menuList[i].Url + "'>" + menuList[i].Title + "</a>";
            string liClass = "";
            if (i == 0)
            {
                liClass = "last";
                link = menuList[i].Title;
            }
            else if (i == menuList.Count - 1)
                liClass = "first";

            LblContent = "<li class='"+ liClass +"'>" + link +"</li>" + LblContent;
        }
        LblContent = "<ul class='breadcrumbs " + this.BaseModule.CssClass + "'>" + LblContent + "</ul>";
    }
Пример #2
0
 public static PigeonCms.Menu GetCurrentMenu(string  menuType)
 {
     var res = new PigeonCms.Menu();
     var menuMan = new MenuManager(true, false);
     var filter = new MenuFilter();
     filter.FilterContentType = false;
     filter.MenuType = menuType;
     filter.Alias = MenuHelper.GetCurrentAlias();
     filter.RoutePattern = MenuHelper.GetCurrentRoutePattern();
     filter.ParentId = -1;
     List<PigeonCms.Menu> list = menuMan.GetByFilter(filter, "");
     if (list.Count > 0)
     {
         res = list[0];
     }
     return res;
 }
Пример #3
0
    private void editRow(int recordId, bool changeType, bool changeView, bool copyRow)
    {
        var obj = new PigeonCms.Menu();
        LitOk.Text = RenderSuccess("");
        LitErr.Text = RenderError("");

        clearForm();
        base.CurrentId = recordId;

        DropDownList drop;
        if (changeType)
            drop = DropModuleTypes;
        else
            drop = DropNewItem;
        MenuContentType contentType = MenuContentType.Module;
        int newItemValue = -1;
        if (int.TryParse(drop.SelectedValue, out newItemValue))
        {
            //url|javascript|alias
            contentType = (MenuContentType)newItemValue;
        }

        if (base.CurrentId == 0)
        {
            obj.ContentType = contentType;
            Utility.SetDropByValue(DropModuleTypes, drop.SelectedValue);
            //LitModuleType.Text = DropNewItem.SelectedValue;
            obj2form(obj, changeType, changeView);
        }
        else
        {
            obj = new MenuManager().GetByKey(base.CurrentId);
            if (changeType)
                obj.ContentType = contentType;
            obj2form(obj, changeType, changeView);
        }
        if (copyRow)
        {
            base.CurrentId = 0;
            LblId.Text = "0";
            LblModuleId.Text = "0";
            ChkIsCore.Checked = false;
            TxtAlias.Text += "-copy";
            TxtName.Text += "-copy";
        }

        MultiView1.ActiveViewIndex = 1;
    }
Пример #4
0
    private bool saveForm()
    {
        bool res = false;
        LitErr.Text = RenderError("");
        LitOk.Text = RenderSuccess("");

        try
        {
            var o1 = new PigeonCms.Menu();
            var currModule = new Module();

            //save menu
            if (base.CurrentId == 0)
            {
                form2obj(o1);
                o1 = new MenuManager().Insert(o1);

            }
            else
            {
                o1 = new MenuManager().GetByKey(base.CurrentId);
                form2obj(o1);
                new MenuManager().Update(o1);
            }

            //save module
            if (o1.ContentType == MenuContentType.Module)
            {
                if (form2module(o1, currModule))
                {
                    if (o1.ModuleId > 0)
                    {
                        currModule = new ModulesManager().GetByKey(o1.ModuleId);
                    }
                    if (currModule.Id > 0)
                    {
                        form2module(o1, currModule);
                        new ModulesManager().Update(currModule);
                    }
                    else
                    {
                        currModule = new ModulesManager().Insert(currModule);
                        o1.ModuleId = currModule.Id;
                        new MenuManager().Update(o1);
                    }
                }
            }
            else if (o1.ModuleId > 0)
            {
                new ModulesManager().DeleteById(o1.ModuleId);
                o1.ModuleId = 0;
                new MenuManager().Update(o1);
            }

            Grid1.DataBind();
            LitOk.Text = RenderSuccess(Utility.GetLabel("RECORD_SAVED_MSG"));
            res = true;
        }
        catch (Exception e1)
        {
            LitErr.Text = RenderError(
                Utility.GetLabel("RECORD_ERR_MSG") + "<br />" + e1.ToString());
        }
        finally
        {
        }
        return res;
    }
Пример #5
0
    protected void Grid1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            var linkedModule = new PigeonCms.Module();
            var item = new PigeonCms.Menu();
            item = (PigeonCms.Menu)e.Row.DataItem;

            Literal LitStyle = (Literal)e.Row.FindControl("LitStyle");
            LitStyle.Text = "";
            if (!string.IsNullOrEmpty(item.CssClass))
                LitStyle.Text += "C: " + item.CssClass + "<br />";
            if (!string.IsNullOrEmpty(item.CurrThemeStored))
                LitStyle.Text += "T: " + item.CurrThemeStored + "<br />";
            if (!string.IsNullOrEmpty(item.CurrMasterPageStored))
                LitStyle.Text += "M: " + item.CurrMasterPageStored + "<br />";

            Literal LitModuleNameDesc = (Literal)e.Row.FindControl("LitModuleNameDesc");
            switch (item.ContentType)
            {
                case MenuContentType.Module:
                    linkedModule = new ModulesManager().GetByKey(item.ModuleId);
                    LitModuleNameDesc.Text = linkedModule.ModuleFullName + "<br>"
                        + "<i>"+ linkedModule.CurrView +"</i>";
                    break;
                case MenuContentType.Url:
                    LitModuleNameDesc.Text = MenuContentType.Url.ToString();
                    break;
                case MenuContentType.Javascript:
                    LitModuleNameDesc.Text = MenuContentType.Javascript.ToString();
                    break;
                case MenuContentType.Alias:
                    LitModuleNameDesc.Text = MenuContentType.Alias.ToString();
                    break;
                default:
                    break;
            }

            LinkButton LnkSel = (LinkButton)e.Row.FindControl("LnkSel");
            LnkSel.Text = "<i class='fa fa-pgn_edit fa-fw'></i>" + Utility.Html.GetTextPreview(item.Name, 20, "");

            var LitAlias = (Literal)e.Row.FindControl("LitAlias");
            string alias = item.Alias;
            if (item.ContentType == MenuContentType.Url && !string.IsNullOrEmpty(item.Link))
            {
                alias = "<a href='" + item.Link + "' target='_blank' title='" + item.Link + "'>" +
                    item.Alias + "</a>";
            }
            LitAlias.Text = alias + "<br />" + item.RoutePattern;

            //moduleContent
            if (this.AllowEditContentUrl && linkedModule.Id > 0)
            {
                var LnkModuleContent = (HyperLink)e.Row.FindControl("LnkModuleContent");
                if (!string.IsNullOrEmpty(linkedModule.EditContentUrl))
                {
                    LnkModuleContent.Visible = true;
                    LnkModuleContent.NavigateUrl = linkedModule.EditContentUrl;
                }
            }

            var LitAccessTypeDesc = (Literal)e.Row.FindControl("LitAccessTypeDesc");
            LitAccessTypeDesc.Text = RenderAccessTypeSummary(item);

            //Visible
            if (item.Visible)
            {
                var img1 = e.Row.FindControl("ImgVisibleOk");
                img1.Visible = true;
            }
            else
            {
                var img1 = e.Row.FindControl("ImgVisibleKo");
                img1.Visible = true;
            }

            //Published
            if (item.Published)
            {
                var img1 = e.Row.FindControl("ImgPublishedOk");
                img1.Visible = true;
            }
            else
            {
                var img1 = e.Row.FindControl("ImgPublishedKo");
                img1.Visible = true;
            }

            //Use SSL
            if (item.CurrentUseSsl)
            {
                var img1 = e.Row.FindControl("ImgUseSsl");
                img1.Visible = true;
            }

            //Delete
            if (item.IsCore)
            {
                var img1 = e.Row.FindControl("LnkDel");
                img1.Visible = false;
            }
            else
            {
                var img1 = e.Row.FindControl("LnkDel");
                img1.Visible = true;
            }
        }
    }
Пример #6
0
 private void setFlag(int recordId, bool value, string flagName)
 {
     try
     {
         PigeonCms.Menu o1 = new PigeonCms.Menu();
         o1 = new MenuManager().GetByKey(recordId);
         switch (flagName.ToLower())
         {
             case "published":
                 o1.Published = value;
                 break;
             case "visible":
                 o1.Visible = value;
                 break;
             default:
                 break;
         }
         new MenuManager().Update(o1);
     }
     catch (Exception e1)
     {
         LitErr.Text = RenderError(
             Utility.GetLabel("RECORD_ERR_MSG") + "<br />" + e1.ToString());
     }
     finally { }
 }
Пример #7
0
    protected void Grid1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            var item = new PigeonCms.Module();
            item = (Module)e.Row.DataItem;

            LinkButton LnkTitle = (LinkButton)e.Row.FindControl("LnkTitle");
            LnkTitle.Text = "<i class='fa fa-pgn_edit fa-fw'></i>" + Utility.Html.GetTextPreview(item.Title, 20, "");

            Literal LitModuleNameDesc = (Literal)e.Row.FindControl("LitModuleNameDesc");
            LitModuleNameDesc.Text = item.ModuleFullName + "<br>"
                + "<i>" + item.CurrView + "</i>";

            Literal LitMenuEntries = (Literal)e.Row.FindControl("LitMenuEntries");
            if (item.MenuSelection == ModulesMenuSelection.AllPages)
                LitMenuEntries.Text = Utility.GetLabel("LblAll", "All");
            else if (item.MenuSelection == ModulesMenuSelection.NoPages)
                LitMenuEntries.Text = Utility.GetLabel("LblNone", "None");
            else if (item.MenuSelection == ModulesMenuSelection.List)
            {
                string entries = "";
                foreach (string menuType in item.ModulesMenuTypes)
                {
                    var menuType1 = new Menutype();
                    menuType1 = new MenutypesManager().GetByMenuType(menuType);
                    entries += "[" + menuType1.MenuType + "], ";  //record1.MenuType + "|"
                }
                foreach (int menuId in item.ModulesMenu)
                {
                    PigeonCms.Menu record1 = new PigeonCms.Menu();
                    record1 = new MenuManager().GetByKey(menuId);
                    entries += record1.Name + ", ";  //record1.MenuType + "|"
                }
                if (entries.EndsWith(", ")) entries = entries.Substring(0, entries.Length - 2);
                LitMenuEntries.Text = Utility.Html.GetTextPreview(entries, 30, "");
            }

            Literal LitAccessTypeDesc = (Literal)e.Row.FindControl("LitAccessTypeDesc");
            LitAccessTypeDesc.Text = item.ReadAccessType.ToString();
            if (item.ReadAccessType != MenuAccesstype.Public)
            {
                string roles = "";
                foreach (string role in item.ReadRolenames)
                {
                    roles += role + ", ";
                }
                if (roles.EndsWith(", ")) roles = roles.Substring(0, roles.Length - 2);
                if (roles.Length > 0)
                    roles = " (" + roles + ")";
                LitAccessTypeDesc.Text += Utility.Html.GetTextPreview(roles, 30, "");

                //render access level
                if (!string.IsNullOrEmpty(item.ReadAccessCode))
                    LitAccessTypeDesc.Text += item.ReadAccessCode;
                if (item.ReadAccessLevel > 0)
                    LitAccessTypeDesc.Text += " (" + item.ReadAccessLevel.ToString() + ")";
            }

            //moduleContent
            var LnkModuleContent = (HyperLink)e.Row.FindControl("LnkModuleContent");
            if (!string.IsNullOrEmpty(item.EditContentUrl))
            {
                LnkModuleContent.Visible = true;
                LnkModuleContent.NavigateUrl = item.EditContentUrl;
            }

            //Published
            if (item.Published)
            {
                var img1 = e.Row.FindControl("ImgPublishedOk");
                img1.Visible = true;
            }
            else
            {
                var img1 = e.Row.FindControl("ImgPublishedKo");
                img1.Visible = true;
            }

            //Delete
            if (item.IsCore)
            {
                var img1 = e.Row.FindControl("LnkDel");
                img1.Visible = false;
            }
            else
            {
                var img1 = e.Row.FindControl("LnkDel");
                img1.Visible = true;
            }
        }
    }
Пример #8
0
        protected override void OnPreInit(EventArgs e)
        {
            try
            {
                offlineRedirect();
            }
            catch (Exception ex1)
            {
                Tracer.Log("BasePage.OnPreInit>offlineRedirect(): " + ex1.ToString(), TracerItemType.Error);
            }

            base.OnPreInit(e);

            try
            {
                menuEntry = MenuHelper.GetCurrentMenu("");
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                if (Utility._QueryString("act").ToLower() == "timeout")
                {
                    //redirected from install page, wrong conn string in web.config
                }
                else
                {
                    //no connstring set, probably cms not configured. redirect to install page
                    Response.Redirect(Config.InstallationPath);
                }
            }

            if (menuEntry.CurrentUseSsl && !Request.IsSecureConnection)
            {
                //redirect to https
                Response.Redirect(Request.Url.ToString().Replace("http://", "https://"));
            }
            if (!menuEntry.CurrentUseSsl && Request.IsSecureConnection)
            {
                //redirect to http
                Response.Redirect(Request.Url.ToString().Replace("https://", "http://"));
            }

            if (menuEntry.Id == 0)
            {
                //see default 404 handler in web.config
                throw new HttpException(404, "Page not found");
            }

            setCurrentTheme();
            setCurrentMasterPage();
        }
Пример #9
0
        protected string GetLinkAddress(Category item)
        {
            string res = "javascript:void(0);";

            if (this.ItemsListTarget > 0)
            {
                if (menuTarget == null)
                {
                    menuTarget = new MenuManager().GetByKey(this.ItemsListTarget);
                }

                try
                {
                    if (menuTarget.RoutePattern.Contains("categoryname"))
                    {
                        string name = item.Alias;
                        if (string.IsNullOrEmpty(name))
                            item.TitleTranslations.TryGetValue(Config.CultureDefault, out name);
                        res = Utility.GetRoutedUrl(
                        menuTarget, new RouteValueDictionary { { "categoryname", name } }, "", Config.AddPageSuffix);
                    }
                    else
                    {
                        res = Utility.GetRoutedUrl(
                        menuTarget, new RouteValueDictionary { { "categoryid", item.Id } }, "", Config.AddPageSuffix);
                    }
                }
                catch (Exception ex)
                {
                    Tracer.Log("GetLinkAddress(): " + ex.ToString(), TracerItemType.Error);
                }
            }
            return res;
        }