protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        CMSContentPage.CheckSecurity();

        // Check module permissions
        if (!ECommerceContext.IsUserAuthorizedForPermission("ReadProducts"))
        {
            RedirectToAccessDenied("CMS.Ecommerce", "EcommerceRead OR ReadProducts");
        }

        SKUInfo sku = null;

        if (Node != null)
        {
            sku = SKUInfoProvider.GetSKUInfo(Node.NodeSKUID);
        }

        if ((sku != null) && (sku.SKUSiteID != SiteContext.CurrentSiteID) && ((sku.SKUSiteID != 0) || !ECommerceSettings.AllowGlobalProducts(SiteContext.CurrentSiteName)))
        {
            EditedObject = null;
        }

        productEditElem.ProductSaved += productEditElem_ProductSaved;

        string action = QueryHelper.GetString("action", string.Empty).ToLowerCSafe();

        if (action == "newculture")
        {
            // Ensure breadcrumb for new culture version of product
            EnsureDocumentBreadcrumbs(PageBreadcrumbs, action: GetString("content.newcultureversiontitle"));
        }
    }
示例#2
0
    /// <summary>
    /// Initializes the extender
    /// </summary>
    public override void OnInit()
    {
        // Check security for content and ecommerce
        CMSContentPage.CheckSecurity("product");

        Control.Page.Load += OnLoad;
    }
示例#3
0
    /// <summary>
    /// OnInit event handler
    /// </summary>
    public override void OnInit()
    {
        base.OnInit();

        CMSContentPage.CheckSecurity();

        Control.Page.Load += OnLoad;
    }
    /// <summary>
    /// OnInit event handler
    /// </summary>
    public override void OnInit()
    {
        base.OnInit();

        // Check page security
        string mode = QueryHelper.GetString("mode", null);
        CMSContentPage.CheckSecurity(mode);

        Control.Page.Load += OnLoad;
    }
    protected override void OnInit(EventArgs e)
    {
        // Check site availability
        if (!ResourceSiteInfoProvider.IsResourceOnSite("CMS.Content", SiteContext.CurrentSiteName))
        {
            RedirectToResourceNotAvailableOnSite("CMS.Content");
        }

        // Check security for content and properties tab
        CMSPropertiesPage.CheckPropertiesSecurity();
        CMSContentPage.CheckSecurity();

        base.OnInit(e);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Display panel with additional controls place holder if required
        if (DisplayControlsPanel)
        {
            pnlAdditionalControls.Visible = true;
        }

        // Display panel with site selector
        if (DisplaySiteSelectorPanel)
        {
            pnlSiteSelector.Visible = true;
        }

        bodyElem.Attributes["class"] = mBodyClass;

        titleElem.HelpIconUrl = UIHelper.GetImageUrl(Page, "General/HelpLargeDark.png");

        CurrentDeviceInfo device = CMSContext.CurrentDevice;

        if (!device.IsMobile)
        {
            // Footer - apply fixed position
            pnlFooterContent.Style.Add("position", "fixed");
            pnlFooterContent.Style.Add("width", "100%");
            pnlFooterContent.Style.Add("bottom", "0px");
        }

        StringBuilder resizeScript = new StringBuilder();

        resizeScript.Append(@"
var headerElem = null;
var footerElem = null;
var contentElem = null;
var jIframe = null;
var jIframeContents = null;
var oldClientWidth = 0;
var oldClientHeight = 0;
var dialogCMSHeaderPad = null;
var dialogCKFooter = null;


function ResizeWorkingAreaIE()
{
    ResizeWorkingArea();
    window.onresize = function() { ResizeWorkingArea(); };
}

function ResizeWorkingArea()
{
    if (headerElem == null)
    {
       headerElem = document.getElementById('divHeader');
    }
    if (footerElem == null)
    {
       footerElem = document.getElementById('divFooter');
    }
    if (contentElem == null)
    {
       contentElem = document.getElementById('divContent');
    }

    if (dialogCMSHeaderPad == null)
    {
       dialogCMSHeaderPad = document.getElementById('CMSHeaderPad');
    }

    if (dialogCKFooter == null)
    {
       dialogCKFooter = document.getElementById('CKFooter');
    }

    if ((headerElem != null) && (footerElem != null) && (contentElem != null))
    {
        var headerHeight = headerElem.offsetHeight + ((dialogCMSHeaderPad != null) ? dialogCMSHeaderPad.offsetHeight : 0);
        var footerHeight = footerElem.offsetHeight + ((dialogCKFooter != null) ? dialogCKFooter.offsetHeight : 0);
        var height = (document.body.offsetHeight - headerHeight - footerHeight);
        if (height > 0)
        {
            var h = (height > 0 ? height : '0') + 'px';
            if (contentElem.style.height != h)
            {
                contentElem.style.height = h;
            }
        }");

        if (device.IsMobile)
        {
            resizeScript.Append(@"
        if ((jIframe == null) || (!jIframe.length)) {
            jIframe = jQuery('.EditableTextEdit iframe:first');
        }
        if ((jIframeContents == null) || (!jIframeContents.length)) {
            jIframeContents = jIframe.contents();
        }

        // Set height of the iframe manually for mobile devices 
        jIframe.css('height', jIframeContents.height());
        // WebKit browsers fix - width of the parent element of the iframe needs to be defined
        jIframe.parent().width(jIframeContents.width());");
        }

        if (BrowserHelper.IsIE())
        {
            resizeScript.Append(@"
        var pnlBody = null;
        var formElem = null;
        var bodyElement = null;
        if (pnlBody == null)
        {
            pnlBody = document.getElementById('", pnlBody.ClientID, @"');
        }
        if (formElem == null)
        {
            formElem = document.getElementById('", form1.ClientID, @"');
        }
        if (bodyElement == null)
        {
            bodyElement = document.getElementById('", bodyElem.ClientID, @"');
        }
        if ((bodyElement != null) && (formElem != null) && (pnlBody != null))
        {
            var newClientWidth = document.documentElement.clientWidth;
            var newClientHeight = document.documentElement.clientHeight;
            if  (newClientWidth != oldClientWidth)
            {
                bodyElement.style.width = newClientWidth;
                formElem.style.width = newClientWidth;
                pnlBody.style.width = newClientWidth;
                headerElem.style.width = newClientWidth;
                contentElem.style.width = newClientWidth;
                oldClientWidth = newClientWidth;
            }
            if  (newClientHeight != oldClientHeight)
            {
                bodyElement.style.height = newClientHeight;
                formElem.style.height = newClientHeight;
                pnlBody.style.height = newClientHeight;
                oldClientHeight = newClientHeight;
            }
        }");
        }

        resizeScript.Append(@"
    }
    if (window.afterResize) {
        window.afterResize();
    }
}");
        if (BrowserHelper.IsIE())
        {
            resizeScript.Append(@"
var timer = setInterval('ResizeWorkingAreaIE();', 50);");
        }
        else
        {
            resizeScript.Append(@"
window.onresize = function() { ResizeWorkingArea(); };
window.onload = function() { ResizeWorkingArea(); };");
        }

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "resizeScript", ScriptHelper.GetScript(resizeScript.ToString()));

        if (BrowserHelper.IsIE7())
        {
            ScriptHelper.RegisterStartupScript(this, typeof(string), "ie7ResizeFix", ScriptHelper.GetScript("document.getElementById('divContent').style.height = '0px';"));
        }

        // Add custom CSS class for dialog page
        CMSContentPage page = Page as CMSContentPage;

        if ((page != null) && page.RequiresDialog && page.UseDialogContentClass)
        {
            pnlContent.CssClass = "DialogContentPanel";
        }

        // Register a script that will re-calculate content height when the CKToolbar is displayed
        const string ckEditorScript = @"
if (window.CKEDITOR) {
    CKEDITOR.on('instanceCreated', function(e) {
        e.editor.on('instanceReady', function(e) { setTimeout(function() { ResizeWorkingArea(); }, 200); });
    });
}";

        ScriptHelper.RegisterStartupScript(this, typeof(string), "ckEditorScript", ckEditorScript, true);
    }