private void gridBannerManagement_OnAction(string actionName, object actionArgument)
    {
        switch (actionName)
        {
        case "delete":
            int categoryID = ValidationHelper.GetInteger(actionArgument, 0);

            BannerCategoryInfo bannerCategory = BannerCategoryInfoProvider.GetBannerCategoryInfo(categoryID);

            // If category wasn't found
            if (bannerCategory == null)
            {
                ShowError(GetString("banner.bannercategory_list.nocategoryid"));

                return;
            }

            CheckModifyPermission(bannerCategory.BannerCategorySiteID);

            // Delete the class
            bannerCategory.Delete();

            break;
        }
    }
Ejemplo n.º 2
0
    private void EditForm_OnBeforeValidate(object sender, EventArgs e)
    {
        BannerCategoryInfo catInfo = (BannerCategoryInfo)UIContext.EditedObjectParent;

        EditForm.Data["BannerCategoryID"] = catInfo.BannerCategoryID;
        EditForm.Data["BannerSiteID"]     = catInfo.BannerCategorySiteID;
    }
Ejemplo n.º 3
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        BannerCategoryInfo info = bcBLL.GetDataById(id);

        info.bc_title = txtTitle.Text;
        info.bc_show  = bool.Parse(rbShow.SelectedValue);
        if (bcBLL.Update(info) > 0)
        {
            Response.Redirect("List.aspx?header=" + Getmessage("30014"));
        }
    }
Ejemplo n.º 4
0
        public BannerCategoryInfo GetDataById(int bc_id)
        {
            BannerCategoryInfo info   = new BannerCategoryInfo();
            IDataReader        reader = db.GetDataById(bc_id).CreateDataReader();

            if (reader.Read())
            {
                info = BannerCategoryInfo.Populate(reader);
            }
            return(info);
        }
Ejemplo n.º 5
0
        public List <BannerCategoryInfo> getAllByShow(bool show)
        {
            List <BannerCategoryInfo> infos = new List <BannerCategoryInfo>();
            IDataReader reader = db.GetDataByShow(show).CreateDataReader();

            while (reader.Read())
            {
                infos.Add(BannerCategoryInfo.Populate(reader));
            }
            return(infos);
        }
Ejemplo n.º 6
0
 protected void Bind()
 {
     if (id != 0)
     {
         if (Tools.TryParseMethod(id.ToString()) > 0)
         {
             BannerCategoryInfo info = bcBLL.GetDataById(id);
             txtTitle.Text        = info.bc_title;
             rbShow.SelectedValue = info.bc_show.ToString();
         }
     }
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Initialize the grid view
        this.gridBanners.OnAction            += new OnActionEventHandler(gridBanners_OnAction);
        this.gridBanners.OnExternalDataBound += new OnExternalDataBoundEventHandler(gridBanners_OnExternalDataBound);
        this.gridBanners.ZeroRowsText         = ResHelper.GetString("banner.bannercategory_edit_banners.nobanners");

        // Look for category ID in the query string
        BannerCategoryInfo bci = EditedObject as BannerCategoryInfo;

        if (bci != null)
        {
            gridBanners.WhereCondition = "(BannerCategoryID = " + bci.BannerCategoryID + ")";
        }
        else
        {
            gridBanners.Visible        = false;
            gridBanners.StopProcessing = true;
        }
    }
Ejemplo n.º 8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string bannerCategoryCodeName = ValidationHelper.GetString(GetValue("BannerCategoryCodeName"), "");

        BannerCategoryInfo bannerCategory = BannerCategoryInfoProvider.GetBannerCategoryInfoFromSiteOrGlobal(bannerCategoryCodeName, CMSContext.CurrentSiteID);

        if ((bannerCategory == null) || (bannerCategory.BannerCategoryEnabled == false))
        {
            Visible = !HideIfBannerNotFound;
            return;
        }

        if (URLHelper.IsPostback() && KeepPreviousBannerOnPostBack && BannerIDViewState.HasValue)
        {
            bannerReused = true;
            banner       = BannerInfoProvider.GetBannerInfo(BannerIDViewState.Value);
        }

        // If random banner should be picked or banner from viewstate was not found
        if (banner == null)
        {
            bannerReused = false;
            // Get random banner from selected category. Decrement hits left for this banner only if page is displayed on the live site.
            banner = BannerInfoProvider.GetRandomValidBanner(bannerCategory.BannerCategoryID, (currentViewMode == ViewModeEnum.LiveSite));
        }

        // Exits if no banner was found
        if (banner == null)
        {
            Visible = !HideIfBannerNotFound;
            return;
        }

        // Store banner id in the viewstate if the same banner should be used if request is postback
        if (KeepPreviousBannerOnPostBack)
        {
            BannerIDViewState = banner.BannerID;
        }

        string width       = ValidationHelper.GetString(GetValue("Width"), "");
        string height      = ValidationHelper.GetString(GetValue("Height"), "");
        string anchorClass = ValidationHelper.GetString(GetValue("AnchorClass"), "");
        bool   fakeLink    = ValidationHelper.GetBoolean(GetValue("FakeLink"), true);

        if (width != "")
        {
            lnkBanner.Style["width"] = width;
        }
        if (height != "")
        {
            lnkBanner.Style["height"] = height;
        }

        lnkBanner.CssClass = string.Format("CMSBanner {0}", anchorClass).Trim();

        lnkBanner.Visible = true;



        // Do not set link if we are not on the live site.
        if ((currentViewMode == ViewModeEnum.LiveSite) || (currentViewMode == ViewModeEnum.Preview))
        {
            // Link pointing to our custum handler which logs click and redirects
            string bannerRedirectURL =
                string.Format(
                    "{0}?bannerID={1}&redirectURL={2}",
                    URLHelper.ResolveUrl("~/CMSModules/BannerManagement/CMSPages/BannerRedirect.ashx"),
                    banner.BannerID,
                    HttpUtility.UrlEncode(URLHelper.ResolveUrl(banner.BannerURL))
                    );


            if (fakeLink)
            {
                // Defaultly href attribute will be set to 'nice' URL
                lnkBanner.Attributes.Add("href", URLHelper.ResolveUrl(banner.BannerURL));

                // After clicking href will be set to URL pointing to custom handler which counts clicks
                lnkBanner.Attributes.Add("onclick", string.Format("this.href='{0}';", bannerRedirectURL));

                // GECKO doesn't count middle mouse click as click, so onmouseup (or down) needs to be added
                lnkBanner.Attributes.Add("onmouseup", string.Format("this.href='{0}';", bannerRedirectURL));
            }
            else
            {
                // If faking links is disabled, set href to redirect url
                lnkBanner.Attributes.Add("href", bannerRedirectURL);
            }

            // Add target="_blank" attribute if link should be opened in new window
            if (banner.BannerBlank)
            {
                lnkBanner.Target = "_blank";
            }
        }

        if (banner.BannerType == BannerTypeEnum.Image)
        {
            BannerImageAttributes bannerImageAttributes = BannerManagementHelper.DeserializeBannerImageAttributes(banner.BannerContent);

            imgBanner.AlternateText = bannerImageAttributes.Alt;
            imgBanner.ToolTip       = bannerImageAttributes.Title;
            imgBanner.CssClass      = bannerImageAttributes.Class;
            imgBanner.Style.Value   = HTMLHelper.HTMLEncode(bannerImageAttributes.Style);

            imgBanner.ImageUrl = URLHelper.ResolveUrl(bannerImageAttributes.Src);

            imgBanner.Visible = true;
            ltrBanner.Visible = false;
        }
        else
        {
            string text = CMSContext.ResolveMacros(banner.BannerContent);

            ltrBanner.Text    = HTMLHelper.ResolveUrls(text, null, false);
            imgBanner.Visible = false;
            ltrBanner.Visible = true;

            if (banner.BannerType == BannerTypeEnum.HTML)
            {
                ControlsHelper.ResolveDynamicControls(this);
            }
        }
    }
Ejemplo n.º 9
0
 public int Update(BannerCategoryInfo info)
 {
     return(db.Update(info.bc_title, info.bc_show, info.bc_id));
 }
Ejemplo n.º 10
0
 public int Insert(BannerCategoryInfo info)
 {
     return(db.Insert(info.bc_title, info.bc_show));
 }
Ejemplo n.º 11
0
    private void EditForm_OnCheckPermissions(object sender, EventArgs e)
    {
        BannerCategoryInfo catInfo = (BannerCategoryInfo)UIContext.EditedObjectParent;

        ((CMSBannerManagementPage)Page).CheckModifyPermission(catInfo.BannerCategorySiteID);
    }