protected void btnSaveWidget_Click(object sender, EventArgs e)
    {
        try
        {
            BSWidget bsWidget = new BSWidget();
            bsWidget.Title       = txtTitle.Text;
            bsWidget.Description = tmceDescription.Content;
            bsWidget.Visible     = Convert.ToBoolean(ddlVisible.SelectedValue);
            bsWidget.PlaceHolder = ddlPlace.SelectedValue;

            MessageBox1.Type = MessageBox.ShowType.Error;

            if (Request["p"] != null && Request["p"] == "AddWidget")
            {
                bsWidget.Type = WidgetTypes.Page;
                if (bsWidget.Save())
                {
                    Response.Redirect("Widgets.aspx?Message=1");
                }
                else
                {
                    MessageBox1.Message = "Error";
                }
            }
            else
            {
                bsWidget = BSWidget.GetWidget(Convert.ToInt32(Request["WidgetID"]));

                if (!divWidgetContent.Visible)
                {
                    bsWidget.Description = string.Empty;
                }

                if (bsWidget.Save())
                {
                    Response.Redirect("Widgets.aspx?Message=1");
                }
                else
                {
                    MessageBox1.Message = "Error";
                }
            }
        }
        catch (Exception ex)
        {
            MessageBox1.Message = ex.Message;
            MessageBox1.Type    = MessageBox.ShowType.Error;
        }
    }
    protected void rpAllWidgets_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        try
        {
            if (e.CommandName == "Add")
            {
                Hashtable   hT         = new Hashtable();
                string      folderName = e.CommandArgument.ToString();
                XmlDocument xDoc       = new XmlDocument();
                xDoc.Load(Server.MapPath("~/Widgets/" + folderName + "/Widget.xml"));
                XmlNode node = xDoc.SelectSingleNode("//widget/title");
                if (node != null)
                {
                    string  title  = node.InnerText;
                    XmlNode xnType = xDoc.SelectSingleNode("//widget/type");

                    string strError = string.Empty;

                    bool bSaved = false;

                    if (xnType == null || (!xnType.InnerText.ToLower().Equals("page")))
                    {
                        BSWidget bsWidget = new BSWidget();
                        bsWidget.Title       = title;
                        bsWidget.FolderName  = folderName;
                        bsWidget.Type        = 0;
                        bsWidget.Sort        = (short)(gvWidgets.Rows.Count + 1);
                        bsWidget.PlaceHolder = "Default";
                        bsWidget.Visible     = true;
                        bSaved = bsWidget.Save();
                    }
                    else if (xnType.InnerText.ToLower().Equals("page"))
                    {
                        strError = Language.Admin["NotSideBarWidget"];
                    }

                    if (bSaved)
                    {
                        MessageBox1.Message = Language.Admin["WidgetAdded"];
                        MessageBox1.Type    = MessageBox.ShowType.Information;
                    }
                    else
                    {
                        MessageBox1.Message = strError;
                        MessageBox1.Type    = MessageBox.ShowType.Error;
                    }
                }
                GetWidgets();
                GetAllWidgets();
            }
        }
        catch (Exception ex)
        {
            MessageBox1.Message = ex.Message;
            MessageBox1.Type    = MessageBox.ShowType.Error;
        }
    }
Beispiel #3
0
    protected void btnSaveWidget_Click(object sender, EventArgs e)
    {
        try
        {
            BSWidget bsWidget;

            MessageBox1.Type = MessageBox.ShowType.Error;

            if ("AddWidget".Equals(Request["p"]))
            {
                bsWidget = new BSWidget();
                bsWidget.Title = txtTitle.Text;
                bsWidget.Description = tmceDescription.Content;
                bsWidget.Visible = Convert.ToBoolean(ddlVisible.SelectedValue);
                bsWidget.PlaceHolder = ddlPlace.SelectedValue;
                bsWidget.LanguageCode = Blogsa.CurrentBlogLanguage;
                bsWidget.Type = WidgetTypes.Page;
                if (bsWidget.Save())
                    Response.Redirect("Widgets.aspx?Message=1");
                else
                    MessageBox1.Message = "Error";
            }
            else
            {
                bsWidget = BSWidget.GetWidget(Convert.ToInt32(Request["WidgetID"]));

                if (!divWidgetContent.Visible)
                    bsWidget.Description = string.Empty;
                else
                {
                    bsWidget.Title = txtTitle.Text;
                    bsWidget.Description = tmceDescription.Content;
                }

                if (bsWidget.Save())
                    Response.Redirect("Widgets.aspx?Message=1");
                else
                    MessageBox1.Message = "Error";
            }
        }
        catch (Exception ex)
        {
            MessageBox1.Message = ex.Message;
            MessageBox1.Type = MessageBox.ShowType.Error;
        }
    }
    private void VisibleUnVisible(bool bVisible)
    {
        try
        {
            bool bDone = false;
            for (int i = 0; i < gvWidgets.Rows.Count; i++)
            {
                CheckBox cb = gvWidgets.Rows[i].FindControl("cb") as CheckBox;
                if (cb.Checked)
                {
                    Literal literal = gvWidgets.Rows[i].FindControl("WidgetID") as Literal;
                    if (literal != null)
                    {
                        int iWidgetID = Convert.ToInt32(literal.Text);

                        BSWidget bsWidget = BSWidget.GetWidget(iWidgetID);
                        if (bsWidget != null)
                        {
                            bsWidget.Visible = bVisible;
                            bDone            = bsWidget.Save();
                        }
                    }
                }
            }
            if (bDone)
            {
                MessageBox1.Message = bVisible ? Language.Admin["BeActive"] : Language.Admin["BePassive"];
                MessageBox1.Type    = MessageBox.ShowType.Information;
                MessageBox1.Visible = true;
            }
            GetWidgets();
        }
        catch (Exception ex)
        {
            MessageBox1.Message = ex.Message;
            MessageBox1.Type    = MessageBox.ShowType.Error;
        }
    }
    protected void gvWidgets_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        try
        {
            if (e.CommandName == "UD")
            {
                string[] values = e.CommandArgument.ToString().Split('|');
                int      val    = -1;
                if (values[0] == "U")
                {
                    val = -1;
                }
                else
                {
                    val = +1;
                }

                int iWidgetID = Convert.ToInt32(values[1]);

                BSWidget bsWidget = BSWidget.GetWidget(iWidgetID);
                bsWidget.Sort += (short)val;

                if (bsWidget.Save())
                {
                    MessageBox1.Type    = MessageBox.ShowType.Error;
                    MessageBox1.Message = "Error";
                }
                GetWidgets();
            }
        }
        catch (Exception ex)
        {
            MessageBox1.Message = ex.Message;
            MessageBox1.Type    = MessageBox.ShowType.Error;
        }
    }
Beispiel #6
0
    protected void rpAllWidgets_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        try
        {
            if (e.CommandName == "Add")
            {
                Hashtable hT = new Hashtable();
                string folderName = e.CommandArgument.ToString();
                XmlDocument xDoc = new XmlDocument();
                xDoc.Load(Server.MapPath("~/Widgets/" + folderName + "/Widget.xml"));
                XmlNode node = xDoc.SelectSingleNode("//widget/title");
                if (node != null)
                {
                    string title = node.InnerText;
                    XmlNode xnType = xDoc.SelectSingleNode("//widget/type");

                    string strError = string.Empty;

                    bool bSaved = false;

                    if (xnType == null || (!xnType.InnerText.ToLower().Equals("page")))
                    {
                        BSWidget bsWidget = new BSWidget();
                        bsWidget.Title = title;
                        bsWidget.FolderName = folderName;
                        bsWidget.Type = 0;
                        bsWidget.Sort = (short)(gvWidgets.Rows.Count + 1);
                        bsWidget.PlaceHolder = "Default";
                        bsWidget.Visible = true;
                        bSaved = bsWidget.Save();
                    }
                    else if (xnType.InnerText.ToLower().Equals("page"))
                        strError = Language.Admin["NotSideBarWidget"];

                    if (bSaved)
                    {
                        MessageBox1.Message = Language.Admin["WidgetAdded"];
                        MessageBox1.Type = MessageBox.ShowType.Information;
                    }
                    else
                    {
                        MessageBox1.Message = strError;
                        MessageBox1.Type = MessageBox.ShowType.Error;
                    }
                }
                GetWidgets();
                GetAllWidgets();
            }
        }
        catch (Exception ex)
        {
            MessageBox1.Message = ex.Message;
            MessageBox1.Type = MessageBox.ShowType.Error;
        }
    }