Exemple #1
0
    protected void repeat_bloc_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        string seo  = "" + Request.QueryString["sn"];
        Club   club = DataMapping.GetClubBySeo(seo);

        News news = DataMapping.ListNews(cric: club.cric, category: "accueilclub").FirstOrDefault() == null ? new News() : DataMapping.ListNews(cric: club.cric, category: "accueilclub").FirstOrDefault();

        News.Bloc        bloc  = (News.Bloc)e.Item.DataItem;
        List <News.Bloc> blocs = DataMapping.GetNews_EN(news.id).GetListBlocs();


        Panel pnl_display = (Panel)e.Item.FindControl("pnl_display");

        pnl_display.CssClass += " Bloc" + bloc.type;

        LinkButton btn_editBloc = (LinkButton)e.Item.FindControl("btn_editBloc");

        btn_editBloc.CommandArgument = bloc.id;

        LinkButton btn_delete = (LinkButton)e.Item.FindControl("btn_delete");

        LinkButton lbt_up   = (LinkButton)e.Item.FindControl("lbt_up");
        LinkButton lbt_down = (LinkButton)e.Item.FindControl("lbt_down");



        if (Functions.CurrentCric != club.cric)
        {
            btn_editBloc.Visible = false;
            btn_delete.Visible   = false;
            lbt_down.Visible     = false;
            lbt_up.Visible       = false;
        }
        else
        {
            btn_editBloc.Visible = true;
            btn_delete.Visible   = true;
            lbt_down.Visible     = bloc.ord < blocs.Count * 10;
            lbt_up.Visible       = bloc.ord > 10;
        }

        Label lbl_contenu = (Label)e.Item.FindControl("lbl_content");

        if (bloc.type == "BlocVideo")
        {
            Video vid = new Video();
            vid = (Video)Functions.Deserialize(bloc.content, vid.GetType());
            Panel pnl_contentToDisplay = (Panel)e.Item.FindControl("pnl_contentToDisplay");
            pnl_contentToDisplay.CssClass += " videoContainer";
            lbl_contenu.Text = vid.getLink();
        }
    }
Exemple #2
0
    protected void btn_yes_Click(object sender, EventArgs e)
    {
        News news = DataMapping.GetNews_EN(Request.QueryString["newsid"]);

        News.Bloc        bloc       = null;
        List <News.Bloc> blocsAfter = new List <News.Bloc>();

        foreach (News.Bloc b in news.GetListBlocs())
        {
            if (b.id == Request.QueryString["blocid"])
            {
                bloc = b;
            }
            if (bloc != null && b.ord > bloc.ord)
            {
                blocsAfter.Add(b);
            }
        }
        if (bloc != null)
        {
            if (!DataMapping.DeleteNewsBloc(bloc))
            {
                throw new Exception("Can't delete bloc");
            }
        }
        foreach (News.Bloc b in blocsAfter)
        {
            b.ord -= 10;
            if (!DataMapping.UpdateNewsBloc(b))
            {
                throw new Exception("Error update ord");
            }
        }
        string url = Functions.UrlAddParam(Globals.NavigateURL(), "newsid", Request.QueryString["newsid"]);

        Response.Redirect(url);
    }
Exemple #3
0
    protected void LI_Blocs_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        try
        {
            News.Bloc bloc = new News.Bloc();
            News      news = DataMapping.GetNews_EN(Request.QueryString["newsid"]);
            if (Request.QueryString["blocid"] != "" && Request.QueryString["blocid"] != null)
            {
                foreach (News.Bloc b in news.GetListBlocs())
                {
                    if (b.id == Request.QueryString["blocid"])
                    {
                        bloc = b;
                    }
                }
            }

            if (e.CommandSource == e.Item.FindControl("lbt_delete"))
            {
                LinkButton lbt_delete = (LinkButton)e.Item.FindControl("lbt_delete");
                foreach (News.Bloc b in news.GetListBlocs())
                {
                    if (b.id == lbt_delete.CommandArgument)
                    {
                        theBloc = b;
                    }
                }
                if (!DataMapping.DeleteNewsBloc(theBloc))
                {
                    throw new Exception("Error deleting");
                }

                string url = Functions.UrlAddParam(Globals.NavigateURL(), "newsid", Request.QueryString["newsid"]);

                Response.Redirect(url);
            }

            #region Type
            if (e.CommandSource == e.Item.FindControl("btn_type"))
            {
                RadioButtonList rbl = (RadioButtonList)e.Item.FindControl("rbl_type");
                foreach (ListItem li in rbl.Items)
                {
                    if (li.Selected)
                    {
                        bloc.type = "Bloc" + li.Value;
                    }
                }
                List <News.Bloc> blocs = new List <News.Bloc>();
                blocs.Add(bloc);
                LI_Blocs.DataSource = blocs;
                LI_Blocs.DataBind();
            }
            #endregion Type

            #region Validate
            if (e.CommandSource == e.Item.FindControl("btn_validate"))
            {
                Button btn = (Button)e.Item.FindControl("btn_validate");


                TextBox tbx_title = (TextBox)e.Item.FindControl("tbx_titre");
                if (tbx_title.Text != null)
                {
                    bloc.title = tbx_title.Text;
                }
                else
                {
                    bloc.title = "";
                }
                Panel pnl_links = (Panel)e.Item.FindControl("pnl_links");
                Panel pnl_files = (Panel)e.Item.FindControl("pnl_files");
                Panel pnl_video = (Panel)e.Item.FindControl("pnl_video");

                #region General
                if (!pnl_links.Visible && !pnl_files.Visible && !pnl_video.Visible)
                {
                    TextBox tbx_content = (TextBox)e.Item.FindControl("tbx_contenu");
                    if (tbx_content.Text != null && tbx_content.Visible)
                    {
                        bloc.content = tbx_content.Text;
                    }
                    else
                    {
                        bloc.content = "";
                    }

                    Image img = (Image)e.Item.FindControl("Image2");
                    if (img.ImageUrl != null && img.Visible)
                    {
                        bloc.photo = img.ImageUrl;
                    }
                    else
                    {
                        bloc.photo = "";
                    }

                    if (bloc.content_type == null || bloc.content_type == "")
                    {
                        bloc.content_type = "text";
                    }
                }
                #endregion General

                #region Links
                else if (pnl_links.Visible)
                {
                    TextBox tbx_link1 = (TextBox)e.Item.FindControl("tbx_link1");
                    TextBox tbx_link2 = (TextBox)e.Item.FindControl("tbx_link2");
                    TextBox tbx_link3 = (TextBox)e.Item.FindControl("tbx_link3");
                    TextBox tbx_link4 = (TextBox)e.Item.FindControl("tbx_link4");

                    TextBox tbx_text1 = (TextBox)e.Item.FindControl("tbx_text1");
                    TextBox tbx_text2 = (TextBox)e.Item.FindControl("tbx_text2");
                    TextBox tbx_text3 = (TextBox)e.Item.FindControl("tbx_text3");
                    TextBox tbx_text4 = (TextBox)e.Item.FindControl("tbx_text4");

                    DropDownList ddl_target1 = (DropDownList)e.Item.FindControl("ddl_target1");
                    DropDownList ddl_target2 = (DropDownList)e.Item.FindControl("ddl_target2");
                    DropDownList ddl_target3 = (DropDownList)e.Item.FindControl("ddl_target3");
                    DropDownList ddl_target4 = (DropDownList)e.Item.FindControl("ddl_target4");

                    List <Link> links = new List <Link>();


                    if (tbx_link1.Text != "")
                    {
                        Link link1 = new Link();
                        link1.Url    = tbx_link1.Text;
                        link1.Texte  = tbx_text1.Text;
                        link1.Target = (ddl_target1.SelectedIndex == 1 ? "_blank" : "");
                        links.Add(link1);
                    }
                    if (tbx_link2.Text != "")
                    {
                        Link link2 = new Link();
                        link2.Url    = tbx_link2.Text;
                        link2.Texte  = tbx_text2.Text;
                        link2.Target = (ddl_target2.SelectedIndex == 1 ? "_blank" : "");
                        links.Add(link2);
                    }
                    if (tbx_link3.Text != "")
                    {
                        Link link3 = new Link();
                        link3.Url    = tbx_link3.Text;
                        link3.Texte  = tbx_text3.Text;
                        link3.Target = (ddl_target3.SelectedIndex == 1 ? "_blank" : "");
                        links.Add(link3);
                    }
                    if (tbx_link4.Text != "")
                    {
                        Link link4 = new Link();
                        link4.Url    = tbx_link4.Text;
                        link4.Texte  = tbx_text4.Text;
                        link4.Target = (ddl_target4.SelectedIndex == 1 ? "_blank" : "");
                        links.Add(link4);
                    }

                    bloc.content      = Functions.Serialize(links);
                    bloc.content_type = "links";
                    bloc.photo        = "";
                }
                #endregion Links

                #region Video
                else if (pnl_video.Visible)
                {
                    TextBox tbx_urlYT = (TextBox)e.Item.FindControl("tbx_urlYT");
                    Video   video     = new Video();
                    video.Url = tbx_urlYT.Text;
                    if (video.Url.Contains("youtube"))
                    {
                        video.Type = "youtube";
                    }
                    else if (video.Url.Contains("vimeo"))
                    {
                        video.Type = "vimeo";
                    }
                    else
                    {
                        video.Type = "daily";
                    }
                    bloc.content      = Functions.Serialize(video);
                    bloc.photo        = "";
                    bloc.content_type = "video/" + video.Type;
                }
                #endregion Video

                #region Files
                else
                {
                    List <AIS_File> files = new List <AIS_File>();

                    if (bloc.content != null && bloc.content != "")
                    {
                        files = (List <AIS_File>)Functions.Deserialize(bloc.content, files.GetType());
                    }

                    if (hfd_files.Value != "")
                    {
                        files = (List <AIS_File>)Functions.Deserialize(hfd_files.Value, files.GetType());
                    }

                    hfd_filesToDelete.Value = "";



                    bloc.content      = Functions.Serialize(files);
                    bloc.photo        = "";
                    bloc.content_type = "files";
                }
                #endregion Files

                bloc.visible = "O";
                RadioButtonList rbl = (RadioButtonList)e.Item.FindControl("rbl_type");
                foreach (ListItem li in rbl.Items)
                {
                    if (li.Selected)
                    {
                        bloc.type = "Bloc" + li.Value;
                    }
                }
                if (bloc.ord == 0)
                {
                    bloc.ord = (news.GetListBlocs().Count + 1) * 10;
                }

                if (!DataMapping.UpdateNewsBloc(bloc, Request.QueryString["newsid"]))
                {
                    throw new Exception("Error during update");
                }

                string url = Functions.UrlAddParam(Globals.NavigateURL(), "newsid", Request.QueryString["newsid"]);

                Response.Redirect(url);
            }
            #endregion Validate

            #region Upload Image
            if (e.CommandSource == e.Item.FindControl("btn_upload"))
            {
                FileUpload ful = (FileUpload)e.Item.FindControl("ful_img");
                if (ful.HasFile)
                {
                    ///////////////////////////////////////////////////////*Changer ici l'image*//////////////////////////////////
                    string fileName = Path.GetFileName(Guid.NewGuid().ToString() + "-" + ful.PostedFile.FileName);
                    string path     = PortalSettings.HomeDirectory + accessPath + "/" + news.tag1 + "/Images/2015-2016/";
                    if (accessPath == "")
                    {
                        path = PortalSettings.HomeDirectory + "District/Courrier du District/" + news.tag1 + "/Images/2015-2016/";
                    }
                    DirectoryInfo d = new DirectoryInfo(Server.MapPath(path));
                    if (!d.Exists)
                    {
                        d.Create();
                    }
                    ful.PostedFile.SaveAs(Server.MapPath(path) + fileName);

                    TextBox tbx_title = (TextBox)e.Item.FindControl("tbx_titre");
                    if (tbx_title.Text != null)
                    {
                        bloc.title = tbx_title.Text;
                    }
                    else
                    {
                        bloc.title = "";
                    }

                    TextBox tbx_content = (TextBox)e.Item.FindControl("tbx_contenu");
                    if (tbx_content.Text != null)
                    {
                        bloc.content = tbx_content.Text;
                    }
                    else
                    {
                        bloc.content = "";
                    }

                    RadioButtonList rbl_type = (RadioButtonList)e.Item.FindControl("rbl_type");
                    foreach (ListItem li in rbl_type.Items)
                    {
                        if (li.Selected)
                        {
                            bloc.type = "Bloc" + li.Value;
                        }
                    }

                    bloc.photo = path + fileName;
                    List <News.Bloc> blocs = new List <News.Bloc>();
                    blocs.Add(bloc);
                    LI_Blocs.DataSource = blocs;
                    LI_Blocs.DataBind();
                    Button btn_upload = (Button)e.Item.FindControl("btn_upload");
                    btn_upload.Text = "Changer l'image";
                }
            }
            #endregion Upload Image

            #region Upload Files
            if (e.CommandSource == e.Item.FindControl("btn_uploadFiles"))
            {
                FileUpload ful = (FileUpload)e.Item.FindControl("ful_files");
                if (ful.HasFile)
                {
                    string fileName = Path.GetFileName(Guid.NewGuid().ToString() + "-" + ful.PostedFile.FileName);
                    string path     = PortalSettings.HomeDirectory + accessPath + "/" + news.tag1 + "/Documents/2015-2016/";
                    if (accessPath == "")
                    {
                        path = PortalSettings.HomeDirectory + "District/Courrier du District/" + news.tag1 + "/Documents/2015-2016/";
                    }
                    DirectoryInfo d = new DirectoryInfo(Server.MapPath(path));
                    if (!d.Exists)
                    {
                        d.Create();
                    }
                    ful.PostedFile.SaveAs(Server.MapPath(path) + fileName);

                    TextBox tbx_title = (TextBox)e.Item.FindControl("tbx_titre");
                    if (tbx_title.Text != null)
                    {
                        bloc.title = tbx_title.Text;
                    }
                    else
                    {
                        bloc.title = "";
                    }



                    RadioButtonList rbl_type = (RadioButtonList)e.Item.FindControl("rbl_type");
                    foreach (ListItem li in rbl_type.Items)
                    {
                        if (li.Selected)
                        {
                            bloc.type = "Bloc" + li.Value;
                        }
                    }

                    bloc.visible = "O";

                    List <AIS_File> files = new List <AIS_File>();

                    if (bloc.content != null && bloc.content != "")
                    {
                        files = (List <AIS_File>)Functions.Deserialize(bloc.content, files.GetType());
                    }
                    else if (Request.QueryString["add"] != null && Request.QueryString["add"] != "" && Request.QueryString["add"] == "true")
                    {
                        files = hfd_filesToDelete.Value == "" ? new List <AIS_File>() : (List <AIS_File>)Functions.Deserialize(hfd_filesToDelete.Value, files.GetType());
                    }
                    AIS_File file = new AIS_File();
                    file.Name = ful.PostedFile.FileName;
                    file.Url  = path + fileName;

                    files.Add(file);
                    bloc.content      = Functions.Serialize(files);
                    bloc.content_type = "files";
                    bloc.photo        = "";
                    hfd_files.Value   = Functions.Serialize(files);

                    List <AIS_File> filesToDelete = new List <AIS_File>();
                    if (hfd_filesToDelete.Value != "")
                    {
                        filesToDelete = (List <AIS_File>)Functions.Deserialize(hfd_filesToDelete.Value, files.GetType());
                    }
                    filesToDelete.Add(file);
                    hfd_filesToDelete.Value = Functions.Serialize(filesToDelete);


                    List <News.Bloc> blocs = new List <News.Bloc>();
                    blocs.Add(bloc);
                    if (bloc.id != null && Request.QueryString["newsid"] != null && Request.QueryString["newsid"] != "")
                    {
                        if (!DataMapping.UpdateNewsBloc(bloc, Request.QueryString["newsid"]))
                        {
                            throw new Exception("Error during update");
                        }
                    }



                    LI_Blocs.DataSource = blocs;
                    LI_Blocs.DataBind();

                    /*blocs = DataMapping.GetNews_EN(news.id).GetListBlocs();
                     *
                     * foreach(News.Bloc b in blocs)
                     * {
                     *  if (b.content == bloc.content)
                     *      bloc = b;
                     * }
                     * String url = Functions.UrlAddParam(Globals.NavigateURL(), "newsid", news.id);
                     * url = Functions.UrlAddParam(Globals.NavigateURL(), "blocid", bloc.id);
                     * if(Request.QueryString["add"]!= null && Request.QueryString["add"]!="" && Request.QueryString["add"] =="true")
                     *  url = Functions.UrlAddParam(Globals.NavigateURL(), "add", "true");
                     * else if (Request.QueryString["edit"] != null && Request.QueryString["edit"] != "" && Request.QueryString["edit"] == "true")
                     *  url = Functions.UrlAddParam(Globals.NavigateURL(), "edit", "true");
                     *
                     * Response.Redirect(url);*/
                }
            }
            #endregion Upload Files

            #region Up/Down
            if (e.CommandSource == e.Item.FindControl("ibt_up"))
            {
                foreach (News.Bloc b in news.GetListBlocs())
                {
                    if (b.id == e.CommandName)
                    {
                        bloc = b;
                    }
                }
                if (bloc.ord > 10)
                {
                    News.Bloc blocOnTop = null;
                    foreach (News.Bloc b in news.GetListBlocs())
                    {
                        if (b.ord == bloc.ord - 10)
                        {
                            blocOnTop = b;
                        }
                    }
                    if (blocOnTop == null)
                    {
                        throw new Exception("Error bloc on top");
                    }
                    int tempOrd = bloc.ord;
                    bloc.ord      = blocOnTop.ord;
                    blocOnTop.ord = tempOrd;


                    if (!DataMapping.UpdateNewsBloc(bloc))
                    {
                        throw new Exception("Error update bloc");
                    }
                    if (!DataMapping.UpdateNewsBloc(blocOnTop))
                    {
                        throw new Exception("Error update bloc on top");
                    }
                }
                news = DataMapping.GetNews_EN(Request.QueryString["newsid"]);
                LI_Blocs.DataSource = news.GetListBlocs();
                LI_Blocs.DataBind();
            }
            if (e.CommandSource == e.Item.FindControl("ibt_down"))
            {
                foreach (News.Bloc b in news.GetListBlocs())
                {
                    if (b.id == e.CommandName)
                    {
                        bloc = b;
                    }
                }
                if (bloc.ord < 10 * (news.GetListBlocs().Count))
                {
                    News.Bloc blocOnBot = null;
                    foreach (News.Bloc b in news.GetListBlocs())
                    {
                        if (b.ord == bloc.ord + 10)
                        {
                            blocOnBot = b;
                        }
                    }
                    if (blocOnBot == null)
                    {
                        throw new Exception("Error bloc on top");
                    }
                    int tempOrd = bloc.ord;
                    bloc.ord      = blocOnBot.ord;
                    blocOnBot.ord = tempOrd;


                    if (!DataMapping.UpdateNewsBloc(bloc))
                    {
                        throw new Exception("Error update bloc");
                    }
                    if (!DataMapping.UpdateNewsBloc(blocOnBot))
                    {
                        throw new Exception("Error update bloc on bottom");
                    }
                }
                news = DataMapping.GetNews_EN(Request.QueryString["newsid"]);
                LI_Blocs.DataSource = news.GetListBlocs();
                LI_Blocs.DataBind();
            }
            #endregion Up/Down

            #region cancel
            if (e.CommandSource == e.Item.FindControl("btn_cancel"))
            {
                if (bloc.content != "" && bloc.type == "BlocFiles")
                {
                    List <AIS_File> files = new List <AIS_File>();

                    if (bloc.content != null && bloc.content != "")
                    {
                        files = (List <AIS_File>)Functions.Deserialize(bloc.content, files.GetType());
                    }

                    if (hfd_files.Value != "")
                    {
                        files = (List <AIS_File>)Functions.Deserialize(hfd_files.Value, files.GetType());
                    }

                    List <AIS_File> filesToDelete = new List <AIS_File>();

                    if (hfd_filesToDelete.Value != "")
                    {
                        filesToDelete = (List <AIS_File>)Functions.Deserialize(hfd_filesToDelete.Value, filesToDelete.GetType());
                        if (filesToDelete.Count == 0)
                        {
                            throw new Exception("Zero files");
                        }
                        foreach (AIS_File fi in files)
                        {
                            bool breaker = false;
                            foreach (AIS_File f in filesToDelete)
                            {
                                if (fi.Url == f.Url)
                                {
                                    files.Remove(fi);
                                    breaker = true;
                                    break;
                                }
                            }
                            if (breaker)
                            {
                                break;
                            }
                        }
                    }



                    bloc.content      = Functions.Serialize(files);
                    bloc.photo        = "";
                    bloc.content_type = "files";


                    bloc.visible = "O";
                    RadioButtonList rbl = (RadioButtonList)e.Item.FindControl("rbl_type");
                    foreach (ListItem li in rbl.Items)
                    {
                        if (li.Selected)
                        {
                            bloc.type = "Bloc" + li.Value;
                        }
                    }
                    if (bloc.ord == 0)
                    {
                        bloc.ord = (news.GetListBlocs().Count + 1) * 10;
                    }

                    if (!DataMapping.UpdateNewsBloc(bloc, Request.QueryString["newsid"]))
                    {
                        throw new Exception("Error during update");
                    }
                }


                String url = Functions.UrlAddParam(Globals.NavigateURL(), "newsid", Request.QueryString["newsid"]);
                Response.Redirect(url);
            }

            #endregion cancel
        }
        catch (Exception ee)
        {
            Functions.Error(ee);
        }
    }
Exemple #4
0
    protected void LI_Blocs_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        try
        {
            News      news = DataMapping.GetNews_EN(Request.QueryString["newsid"]);
            News.Bloc bloc = (News.Bloc)e.Item.DataItem;

            string add = "" + Request.QueryString["add"];
            if (bloc == null)
            {
                return;
            }
            if (Request.QueryString["nbfiles"] != "" && Request.QueryString["nbfiles"] != null)
            {
                bloc.type = "BlocFiles";
            }



            var panel = e.Item.FindControl("Panel1") as Panel;
            panel.CssClass = panel.CssClass + " " + bloc.type + " " + style;
            Panel pnl_content = (Panel)e.Item.FindControl("pnl_content");
            if (bloc.type.Contains("Video"))
            {
                pnl_content.CssClass += " videoContainer";
            }

            var image = e.Item.FindControl("Image1") as Image;
            image.ImageUrl = bloc.photo;
            image.Visible  = image.ImageUrl != "" && image.ImageUrl != Const.no_image;

            HyperLink hlk = (HyperLink)e.Item.FindControl("hlk_modif");
            hlk.NavigateUrl = Functions.UrlAddParam(Globals.NavigateURL(), "edit", "true");
            hlk.NavigateUrl = Functions.UrlAddParam(hlk.NavigateUrl, "newsid", Request.QueryString["newsid"]);
            hlk.NavigateUrl = Functions.UrlAddParam(hlk.NavigateUrl, "blocid", bloc.id);



            HiddenField hfd_blocid = (HiddenField)e.Item.FindControl("hfd_blocid");
            hfd_blocid.Value = bloc.id;


            LinkButton ibt_up   = (LinkButton)e.Item.FindControl("ibt_up");
            LinkButton ibt_down = (LinkButton)e.Item.FindControl("ibt_down");
            if (HasPermission())
            {
                Panel pnl = (Panel)e.Item.FindControl("pnl_modif");
                pnl.Visible = true;


                ibt_up.Visible = bloc.ord > 10 && (Request.QueryString["edit"] == "" || Request.QueryString["edit"] == null) && (Request.QueryString["add"] == "" || Request.QueryString["add"] == null) && (Request.QueryString["delete"] == "" || Request.QueryString["delete"] == null);

                ibt_down.Visible = bloc.ord < 10 * (news.GetListBlocs().Count) && (Request.QueryString["edit"] == "" || Request.QueryString["edit"] == null) && (Request.QueryString["add"] == "" || Request.QueryString["add"] == null) && (Request.QueryString["delete"] == "" || Request.QueryString["delete"] == null);
            }

            var             image2   = e.Item.FindControl("Image2") as Image;
            TextBox         tbx      = (TextBox)e.Item.FindControl("tbx_contenu");
            RadioButtonList rbl_type = (RadioButtonList)e.Item.FindControl("rbl_type");

            foreach (ListItem li in rbl_type.Items)
            {
                if ("Bloc" + li.Value == bloc.type)
                {
                    li.Selected = true;
                }
            }

            image2.ImageUrl = bloc.photo;
            image2.Visible  = image2.ImageUrl != "" && image2.ImageUrl != Const.no_image;

            string edit = ("" + Request.QueryString["edit"]);

            var Panel2 = e.Item.FindControl("Panel2") as Panel;
            if (edit == "true" || add == "true")
            {
                panel.Visible  = false;
                Panel2.Visible = true;
                hlk.Visible    = false;
            }
            string supp = ("" + Request.QueryString["delete"]);
            if (supp == "true")
            {
                pnl_delete.Visible = true;
                hlk.Visible        = false;
            }

            int cric = Functions.CurrentCric;



            Label      contenu    = (Label)e.Item.FindControl("lbl_contenu");
            Label      lbl_img    = (Label)e.Item.FindControl("lbl_img");
            FileUpload ful        = (FileUpload)e.Item.FindControl("ful_img");
            Button     btn_upload = (Button)e.Item.FindControl("btn_upload");
            Panel      pnl_links  = (Panel)e.Item.FindControl("pnl_links");
            Panel      pnl_files  = (Panel)e.Item.FindControl("pnl_files");
            Panel      pnl_video  = (Panel)e.Item.FindControl("pnl_video");



            switch (bloc.type)
            {
            case "BlocNoPhoto":
                lbl_img.Visible    = false;
                contenu.Visible    = true;
                ful.Visible        = false;
                btn_upload.Visible = false;
                image2.Visible     = false;
                tbx.Visible        = true;
                break;

            case "BlocPhoto":
                lbl_img.Visible    = true;
                contenu.Visible    = false;
                ful.Visible        = true;
                btn_upload.Visible = true;
                tbx.Visible        = false;
                image2.Visible     = true;
                break;

            case "BlocLinks":
                lbl_img.Visible    = false;
                contenu.Visible    = false;
                ful.Visible        = false;
                btn_upload.Visible = false;
                image2.Visible     = false;
                tbx.Visible        = false;
                pnl_links.Visible  = true;
                break;

            case "BlocFiles":
                lbl_img.Visible    = false;
                contenu.Visible    = false;
                ful.Visible        = false;
                btn_upload.Visible = false;
                image2.Visible     = false;
                tbx.Visible        = false;
                pnl_files.Visible  = true;
                break;

            case "BlocVideo":
                lbl_img.Visible    = false;
                contenu.Visible    = false;
                ful.Visible        = false;
                btn_upload.Visible = false;
                image2.Visible     = false;
                tbx.Visible        = false;
                pnl_video.Visible  = true;
                break;

            default:
                lbl_img.Visible    = true;
                contenu.Visible    = true;
                ful.Visible        = true;
                btn_upload.Visible = true;
                image2.Visible     = true;
                tbx.Visible        = true;
                break;
            }



            DropDownList ddl_target1 = (DropDownList)e.Item.FindControl("ddl_target1");
            DropDownList ddl_target2 = (DropDownList)e.Item.FindControl("ddl_target2");
            DropDownList ddl_target3 = (DropDownList)e.Item.FindControl("ddl_target3");
            DropDownList ddl_target4 = (DropDownList)e.Item.FindControl("ddl_target4");

            BindDDL(ddl_target1);
            BindDDL(ddl_target2);
            BindDDL(ddl_target3);
            BindDDL(ddl_target4);



            if (bloc.type == "BlocVideo" && bloc.content != null)
            {
                Label Texte1 = (Label)e.Item.FindControl("Texte1");
                Video video  = new Video();
                video       = (Video)Functions.Deserialize(bloc.content, video.GetType());
                Texte1.Text = video.getLink();
                TextBox tbx_urlYT = (TextBox)e.Item.FindControl("tbx_urlYT");
                tbx_urlYT.Text = video.Url;
            }

            if (bloc.type == "BlocLinks" && bloc.content != null)
            {
                Label       Texte1 = (Label)e.Item.FindControl("Texte1");
                List <Link> links  = new List <Link>();
                links       = (List <Link>)Functions.Deserialize(bloc.content, links.GetType());
                Texte1.Text = createListLinks(links);
                for (int i = 0; i < links.Count; i++)
                {
                    TextBox tbx_link = (TextBox)e.Item.FindControl("tbx_link" + (i + 1));
                    tbx_link.Text = links.ElementAt(i).Url;
                    DropDownList ddl = (DropDownList)e.Item.FindControl("ddl_target" + (i + 1));
                    ddl.SelectedIndex = links.ElementAt(i).Target == "" ? 0 : 1;
                    TextBox tbx_texte = (TextBox)e.Item.FindControl("tbx_text" + (i + 1));
                    tbx_texte.Text = links.ElementAt(i).Texte;
                }
            }
            if (bloc.type == "BlocFiles" && bloc.content != null)
            {
                try
                {
                    Label           Texte1 = (Label)e.Item.FindControl("Texte1");
                    List <AIS_File> files  = new List <AIS_File>();
                    if (bloc.content != null && bloc.content != "")
                    {
                        files = (List <AIS_File>)Functions.Deserialize(bloc.content, files.GetType());
                    }

                    //if (hfd_files.Value != "")
                    //    files = (List<AIS_File>) Functions.Deserialize(hfd_files.Value, files.GetType());



                    Panel pnl_filesUploaded = (Panel)e.Item.FindControl("pnl_filesUploaded");


                    #region Edit mode

                    if (files.Count > 0)
                    {
                        if (hfd_files.Value == "")
                        {
                            hfd_files.Value = bloc.content;
                        }
                        GridView gvw_filesUploaded = (GridView)e.Item.FindControl("gvw_filesUploaded");
                        gvw_filesUploaded.DataSource = files;
                        gvw_filesUploaded.DataBind();
                    }



                    #endregion Edit mode

                    #region Display mode

                    Texte1.Text = createListFile(files);

                    #endregion Display mode



                    btn_upload.Text = "Changer l'image";
                }
                catch (Exception ee)
                {
                    Functions.Error(ee);
                }
            }

            LinkButton lbt_delete = (LinkButton)e.Item.FindControl("lbt_delete");
            lbt_delete.CommandArgument = bloc.id;

            String  Stringscript = "<script> CKEDITOR.replace('" + tbx.ClientID + "', { uiColor: '#CCEAEE'});</script> ";
            Literal script       = (Literal)e.Item.FindControl("script");
            script.Text = Stringscript;
        }
        catch (Exception ee)
        {
            Functions.Error(ee);
        }
    }
Exemple #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            List <News.Bloc> blocs = new List <News.Bloc>();
            if (!IsPostBack)
            {
                pnl_add.Visible     = HasPermission() && Request.QueryString["edit"] != "true" && Request.QueryString["add"] != "true" && Request.QueryString["delete"] != "true";
                pnl_type.Visible    = Request.QueryString["edit"] == "true" || Request.QueryString["add"] == "true";
                hlk_add.NavigateUrl = Functions.UrlAddParam(Globals.NavigateURL(), "add", "true");
                hlk_add.NavigateUrl = Functions.UrlAddParam(hlk_add.NavigateUrl, "newsid", Request.QueryString["newsid"]);



                string newsid = ("" + Request.QueryString["newsid"]);
                if (newsid == "")
                {
                    Functions.Error(new Exception("Newsid inconnu : " + newsid));
                }

                HL_Print.NavigateUrl = print + "?popUp=true&print=yes&newsid=" + newsid;

                if (("" + Request.QueryString["print"]) != "")
                {
                    Response.Write("<script>window.print();</script>");
                    P_Share.Visible = false;
                }

                News news = DataMapping.GetNews_EN(newsid);
                if (news != null)
                {
                    LBL_Titre.Text = news.title;
                    LBL_Date.Text  = news.dt.ToShortDateString();

                    Club c = DataMapping.GetClub(news.cric);
                    if (c != null)
                    {
                        HLK_Club.Text        = c.name;
                        HLK_Club.NavigateUrl = Request.Url.AbsoluteUri.ToString().Replace(Request.Url.PathAndQuery, "") + "/" + c.seo + "/";
                    }
                    else
                    {
                        HLK_Club.Visible = false;
                    }


                    string blocid = ("" + Request.QueryString["blocid"]);
                    string add    = "" + Request.QueryString["add"];
                    if (blocid != "")
                    {
                        foreach (News.Bloc b in news.GetListBlocs())
                        {
                            if (b.id == blocid)
                            {
                                blocs.Add(b);
                            }
                        }
                    }
                    else
                    {
                        blocs = news.GetListBlocs();
                    }

                    if (add == "true")
                    {
                        blocs = new List <News.Bloc>();
                        News.Bloc bloc = new News.Bloc();
                        bloc.type = "BlocPhotoTop";
                        blocs.Add(bloc);
                    }
                }

                LI_Blocs.DataSource = blocs;
                LI_Blocs.DataBind();
            }
        }
        catch (Exception ee)
        {
            Functions.Error(ee);
        }
    }
Exemple #6
0
    protected void repeat_bloc_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        string seo  = "" + Request.QueryString["sn"];
        Club   club = DataMapping.GetClubBySeo(seo);

        #region editBloc
        if (e.CommandSource == (LinkButton)e.Item.FindControl("btn_editBloc"))
        {
            LinkButton btn_editBloc = (LinkButton)e.Item.FindControl("btn_editBloc");
            btn_validate.CommandArgument = btn_editBloc.CommandArgument;
            pnl_add.Visible     = true;
            btn_addBloc.Visible = false;
            repeat_bloc.Visible = false;
            News.Bloc bloc = DataMapping.GetNews_EN(DataMapping.ListNews(cric: club.cric, category: "accueilclub").FirstOrDefault().id).GetListBlocs().Where(x => x.id == btn_editBloc.CommandArgument).First();
            switch (bloc.type)
            {
            case "BlocNoPhoto":

                tbx_contenu.Text = bloc.content;
                break;

            case "BlocVideo":

                Video vid = new Video();
                vid          = (Video)Functions.Deserialize(bloc.content, vid.GetType());
                tbx_url.Text = vid.Url;
                break;

            default:
                img.ImageUrl = bloc.photo;
                break;
            }
            foreach (ListItem li in rbl_type.Items)
            {
                if ("Bloc" + li.Value == bloc.type)
                {
                    li.Selected = true;
                }
            }
            tbx_titre.Text = bloc.title;
        }
        #endregion editBloc

        else if (e.CommandSource == (LinkButton)e.Item.FindControl("btn_delete"))
        {
            LinkButton btn_delete = (LinkButton)e.Item.FindControl("btn_delete");
            News.Bloc  bloc       = DataMapping.GetNews_EN(DataMapping.ListNews(cric: club.cric, category: "accueilclub").FirstOrDefault().id).GetListBlocs().Where(x => x.id == btn_delete.CommandArgument).FirstOrDefault();

            if (bloc == null)
            {
                throw new Exception("bloc null");
            }
            if (!DataMapping.DeleteNewsBloc(bloc))
            {
                throw new Exception("An error occured while deleting the bloc");
            }

            Response.Redirect("~/" + club.seo + "/");
        }
        else if (e.CommandSource == (LinkButton)e.Item.FindControl("lbt_up"))
        {
            int        cric    = club.cric;
            LinkButton lbt_up  = (LinkButton)e.Item.FindControl("lbt_up");
            News       news    = DataMapping.ListNews(cric: cric, category: "accueilclub").FirstOrDefault();
            News.Bloc  bloc    = DataMapping.GetNews_EN(DataMapping.ListNews(cric: club.cric, category: "accueilclub").FirstOrDefault().id).GetListBlocs().Where(x => x.id == lbt_up.CommandArgument).FirstOrDefault();;
            News.Bloc  bloc_up = null;

            foreach (News.Bloc b in DataMapping.GetNews_EN(DataMapping.ListNews(cric: club.cric, category: "accueilclub").FirstOrDefault().id).GetListBlocs())
            {
                if (bloc != null && b.ord == bloc.ord - 10)
                {
                    bloc_up = b;
                }
            }

            if (bloc == null || bloc_up == null)
            {
                throw new Exception("Error can't find blocs");
            }


            int tempord = bloc.ord;
            bloc.ord    = bloc_up.ord;
            bloc_up.ord = tempord;

            DataMapping.UpdateNewsBloc(bloc, news.id);
            DataMapping.UpdateNewsBloc(bloc_up, news.id);

            Response.Redirect("~/" + club.seo + "/");
        }
        else if (e.CommandSource == (LinkButton)e.Item.FindControl("lbt_down"))
        {
            int        cric     = club.cric;
            LinkButton lbt_down = (LinkButton)e.Item.FindControl("lbt_down");
            News       news     = DataMapping.ListNews(cric: cric, category: "accueilclub").FirstOrDefault();
            News.Bloc  bloc     = DataMapping.GetNews_EN(DataMapping.ListNews(cric: club.cric, category: "accueilclub").FirstOrDefault().id).GetListBlocs().Where(x => x.id == lbt_down.CommandArgument).FirstOrDefault();;
            News.Bloc  bloc_up  = null;

            foreach (News.Bloc b in DataMapping.GetNews_EN(DataMapping.ListNews(cric: club.cric, category: "accueilclub").FirstOrDefault().id).GetListBlocs())
            {
                if (bloc != null && b.ord == bloc.ord + 10)
                {
                    bloc_up = b;
                }
            }

            if (bloc == null || bloc_up == null)
            {
                throw new Exception("Error can't find blocs");
            }


            int tempord = bloc.ord;
            bloc.ord    = bloc_up.ord;
            bloc_up.ord = tempord;

            DataMapping.UpdateNewsBloc(bloc, news.id);
            DataMapping.UpdateNewsBloc(bloc_up, news.id);

            Response.Redirect("~/" + club.seo + "/");
        }
    }
Exemple #7
0
    /*protected void btn_editBloc_Click(object sender, EventArgs e)
     * {
     *  //btn_editBloc.Visible = false;
     *  //pnl_content.Visible = false;
     *  //lbt_deleteBloc.Visible = false;
     *  pnl_add.Visible = true;
     *  string seo = "" + Request.QueryString["sn"];
     *
     *  Club club = DataMapping.GetClubBySeo(seo);
     *  News news = DataMapping.ListNews(cric: club.cric, category: "accueilclub").FirstOrDefault()==null? new News() : DataMapping.ListNews(cric: club.cric, category: "accueilclub").FirstOrDefault();
     *
     *  img.ImageUrl = news.photo;
     *  tbx_titre.Text = news.title;
     *
     *  if (news != null)
     *  {
     *
     *      switch (news.tag2)
     *      {
     *          case "BlocNoPhoto":
     *              tbx_contenu.Text = news.text;
     *              break;
     *          case null:
     *              tbx_contenu.Text = news.text;
     *              break;
     *          case "BlocVideo":
     *              Video vid = new Video();
     *              vid = (Video)Functions.Deserialize(news.text, vid.GetType());
     *              tbx_url.Text = vid.Url;
     *              tbx_contenu.Visible = false;
     *              break;
     *          default:
     *              tbx_contenu.Text = news.text;
     *              pnl_image.Visible = true;
     *              break;
     *      }
     *
     *      foreach (ListItem li in rbl_type.Items)
     *      {
     *          if ("Bloc" + li.Value == news.tag2)
     *          {
     *              li.Selected = true;
     *              break;
     *          }
     *
     *      }
     *
     *  }
     * }*/

    #region buttons

    protected void btn_validate_Click(object sender, EventArgs e)
    {
        string seo  = "" + Request.QueryString["sn"];
        Club   club = DataMapping.GetClubBySeo(seo);
        int    cric = club.cric;
        News   news = DataMapping.ListNews(cric: cric, category: "accueilclub").FirstOrDefault();

        News.Bloc bloc = new News.Bloc();
        btn_addBloc.Visible = false;
        repeat_bloc.Visible = false;
        if (btn_validate.CommandArgument != null && btn_validate.CommandArgument != "")
        {
            foreach (News.Bloc b in DataMapping.GetNews_EN(news.id).GetListBlocs())
            {
                if (b.id == btn_validate.CommandArgument)
                {
                    bloc = b;
                }
            }
        }

        switch (rbl_type.SelectedValue)
        {
        case "NoPhoto":
            bloc.content      = tbx_contenu.Text;
            bloc.content_type = "text";
            bloc.photo        = "";
            break;

        case "Video":
            Video vid = new Video();
            vid.Url = tbx_url.Text;
            if (vid.Url.Contains("youtube"))
            {
                vid.Type = "youtube";
            }
            else if (vid.Url.Contains("daily"))
            {
                vid.Type = "daily";
            }
            else
            {
                vid.Type = "vimeo";
            }
            bloc.content      = Functions.Serialize(vid);
            bloc.photo        = "";
            bloc.content_type = "video/" + vid.Type;
            break;

        default:
            bloc.photo        = img.ImageUrl;
            bloc.content      = tbx_contenu.Text;
            bloc.content_type = "photo";
            break;
        }

        bloc.type    = "Bloc" + rbl_type.SelectedValue;
        bloc.title   = tbx_titre.Text;
        bloc.ord     = bloc.id == null? (1 + DataMapping.GetNews_EN(news.id).GetListBlocs().Count) * 10 : bloc.ord;
        bloc.visible = "O";

        DataMapping.UpdateNewsBloc(bloc, news.id);



        Response.Redirect("~/" + Request.QueryString["sn"] + "/");
    }