Esempio n. 1
0
    /// <summary>
    /// Raises the <see cref="E:Init"/> event.
    /// </summary>
    protected override void OnInit(EventArgs e)
    {
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.contentpersonalization", "Read"))
        {
            RedirectToAccessDenied(String.Format(GetString("general.permissionresource"), "Read", "Content personalization"));
        }

        // Set the ParentObject manually tor inherited templates
        if (editElem.UIFormControl.ParentObject == null)
        {
            string aliasPath = QueryHelper.GetString("aliaspath", string.Empty);
            // Get page info for the given document
            PageInfo pi = PageInfoProvider.GetPageInfo(CMSContext.CurrentSiteName, aliasPath, CMSContext.PreferredCultureCode, null, CMSContext.CurrentSite.CombineWithDefaultCulture);
            if (pi != null)
            {
                editElem.UIFormControl.ParentObject = pi.PageTemplateInfo;
            }
        }

        // Get information whether the control is used for a web part or zone variant
        variantType = VariantTypeFunctions.GetVariantTypeEnum(QueryHelper.GetString("varianttype", string.Empty));

        base.OnInit(e);

        // Check permissions and redirect
        OnlineMarketingContext.CheckPermissions(variantType);

        // Get the alias path of the current node
        if (Node == null)
        {
            editElem.StopProcessing = true;
        }

        editElem.UIFormControl.OnBeforeSave += new EventHandler(UIFormControl_OnBeforeSaved);
    }
Esempio n. 2
0
    /// <summary>
    /// Clones template as adhoc from original node.
    /// </summary>
    /// <param name="newNode">New node which will use new adhoc template</param>
    private void CloneTemplateAsAdHoc(TreeNode newNode)
    {
        PageInfo originalPage = PageInfoProvider.GetPageInfo(mNode.NodeSiteName, mNode.NodeAliasPath, mNode.DocumentCulture, null, mNode.NodeID, false);

        if (originalPage == null)
        {
            return;
        }

        PageTemplateInfo originalTemplate = originalPage.UsedPageTemplateInfo;

        // If template is not adhoc or is inherited, create adhoc from original node template
        if ((originalTemplate != null) && (originalTemplate.IsReusable || mNode.NodeInheritPageTemplate))
        {
            var newDisplayName = string.Format("Ad-hoc: {0} ({1})", txtDocumentName.Text.Trim(), GetString("abtesting.abvarianttemplate"));
            var adHocTemplate  = PageTemplateInfoProvider.CloneTemplateAsAdHoc(originalTemplate, newDisplayName, SiteContext.CurrentSiteID, Guid.Empty);

            if (newNode.NodeTemplateForAllCultures)
            {
                newNode.NodeTemplateID = adHocTemplate.PageTemplateId;
            }
            else
            {
                newNode.DocumentPageTemplateID = adHocTemplate.PageTemplateId;
            }
            newNode.NodeInheritPageTemplate = false;
        }
    }
Esempio n. 3
0
    /// <summary>
    /// Fires when the page loads
    /// </summary>
    private void OnLoad(object sender, EventArgs eventArgs)
    {
        var page = (CMSPage)Control.Page;

        var manager = page.DocumentManager;

        manager.RedirectForNonExistingDocument = false;
        manager.Tree.CombineWithDefaultCulture = false;

        var node = manager.Node;

        if (node != null)
        {
            Node = node;

            ScriptHelper.RegisterScriptFile(Control.Page, "~/CMSModules/Content/CMSDesk/EditTabs.js");

            // Document from different site
            if (node.NodeSiteID != SiteContext.CurrentSiteID)
            {
                URLHelper.Redirect(DocumentUIHelper.GetPageNotAvailable(string.Empty, false, node.DocumentName));
            }

            showProductTab = node.HasSKU;

            // Initialize required variables
            isWireframe  = node.IsWireframe();
            hasWireframe = isWireframe || (node.NodeWireframeTemplateID > 0);

            try
            {
                var pi = PageInfoProvider.GetPageInfo(node.NodeSiteName, node.NodeAliasPath, node.DocumentCulture, node.DocumentUrlPath, false);
                if ((pi != null) && (pi.DesignPageTemplateInfo != null))
                {
                    var pti = pi.DesignPageTemplateInfo;

                    showMasterPage = pti.IsPortal && ((node.NodeAliasPath == "/") || pti.ShowAsMasterTemplate);

                    showDesign = ((pti.PageTemplateType == PageTemplateTypeEnum.Portal) || (pti.PageTemplateType == PageTemplateTypeEnum.AspxPortal));
                }
            }
            catch
            {
                // Page info not found - probably tried to display document from different site
            }

            if (node.NodeClassName.EqualsCSafe("CMS.File", true))
            {
                showDesign     = false;
                showMasterPage = false;
            }

            DocumentUIHelper.EnsureDocumentBreadcrumbs(page.PageBreadcrumbs, node, null, null);
        }
        else if (!PortalContext.ViewMode.IsDesign(true))
        {
            // Document does not exist -> redirect to new culture version creation dialog
            RedirectToNewCultureVersionPage();
        }
    }
Esempio n. 4
0
    /// <summary>
    /// Gets the inherited page template from the parent node
    /// </summary>
    /// <param name="currentNode">Document node</param>
    protected int GetInheritedPageTemplateId(TreeNode currentNode)
    {
        string aliasPath = currentNode.NodeAliasPath;

        // For root, there is no inheritance possible
        if (String.IsNullOrEmpty(aliasPath) || (aliasPath == "/"))
        {
            return(0);
        }

        aliasPath = TreePathUtils.GetParentPath(aliasPath);

        // Get the parent page info
        PageInfo pi = PageInfoProvider.GetPageInfo(currentNode.NodeSiteName, aliasPath, currentNode.DocumentCulture, null, currentNode.NodeParentID, true);

        if (pi == null)
        {
            return(0);
        }

        // Get template used by the page info
        pageTemplateInfo = pi.UsedPageTemplateInfo;

        return(pageTemplateInfo != null ? pageTemplateInfo.PageTemplateId : 0);
    }
Esempio n. 5
0
    /// <summary>
    /// Gets the inherited page template from the parent node
    /// </summary>
    /// <param name="node">Document node</param>
    protected int GetInheritedPageTemplateId(TreeNode node)
    {
        string aliasPath = node.NodeAliasPath;

        // For root, there is no inheritance possible
        if (String.IsNullOrEmpty(aliasPath) || (aliasPath == "/"))
        {
            return(0);
        }

        aliasPath = TreePathUtils.GetParentPath(aliasPath);

        // Get the page info
        PageInfo pi = PageInfoProvider.GetPageInfo(node.NodeSiteName, aliasPath, node.DocumentCulture, node.DocumentUrlPath, node.NodeParentID, true);

        if (pi != null)
        {
            // Get template used by the page info
            pti = pi.UsedPageTemplateInfo;
            if (pti != null)
            {
                return(pti.PageTemplateId);
            }
        }

        return(0);
    }
    /// <summary>
    /// Raises the <see cref="E:Init"/> event.
    /// </summary>
    protected override void OnInit(EventArgs e)
    {
        if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.mvtest", "Read"))
        {
            RedirectToAccessDenied(String.Format(GetString("general.permissionresource"), "Read", "MVT testing"));
        }

        // Register the Save and close button as the form submit button
        HeaderActions.Visible = false;
        editElem.UIFormControl.SubmitButton.Visible = false;
        btnOk.Click += (s, ea) => editElem.UIFormControl.SaveData(null);

        // Turn off update document for this page
        EnsureDocumentManager = false;

        // Set the ParentObject manually tor inherited templates
        if (editElem.UIFormControl.ParentObject == null)
        {
            var aliasPath = QueryHelper.GetString("aliaspath", string.Empty);
            var siteName  = SiteContext.CurrentSiteName;

            // Get page info for the given document
            PageInfo pi = PageInfoProvider.GetPageInfo(siteName, aliasPath, LocalizationContext.PreferredCultureCode, null, SiteInfoProvider.CombineWithDefaultCulture(siteName));
            if (pi != null)
            {
                editElem.UIFormControl.ParentObject = pi.UsedPageTemplateInfo;
            }
        }

        // Get information whether the control is used for a web part or zone variant
        variantType = VariantTypeFunctions.GetVariantTypeEnum(QueryHelper.GetString("varianttype", string.Empty));

        mTemplateID = QueryHelper.GetInteger("templateid", 0);

        base.OnInit(e);

        // Check permissions and redirect
        VariantPermissionsChecker.CheckPermissions(variantType);

        // Get the alias path of the current node
        if (Node == null)
        {
            editElem.StopProcessing = true;
        }

        editElem.UIFormControl.OnBeforeSave += UIFormControl_OnBeforeSaved;
    }
Esempio n. 7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var previewState = GetPreviewStateFromCookies(MASTERPAGE);

        // Keep current user
        var user = MembershipContext.AuthenticatedUser;

        // Get document node
        tree = new TreeProvider(user);
        node = UIContext.EditedObject as TreeNode;

        // Register the dialog script
        ScriptHelper.RegisterDialogScript(Page);

        // Register save changes
        ScriptHelper.RegisterSaveChanges(Page);

        // Save changes support
        bool   confirmChanges = SettingsKeyInfoProvider.GetBoolValue(SiteContext.CurrentSiteName + ".CMSConfirmChanges");
        string script         = string.Empty;

        if (confirmChanges)
        {
            script  = "CMSContentManager.confirmLeave=" + ScriptHelper.GetString(ResHelper.GetString("Content.ConfirmLeave", user.PreferredUICultureCode), true, false) + "; \n";
            script += "CMSContentManager.confirmLeaveShort=" + ScriptHelper.GetString(ResHelper.GetString("Content.ConfirmLeaveShort", user.PreferredUICultureCode), true, false) + "; \n";
        }
        else
        {
            script += "CMSContentManager.confirmChanges = false;";
        }

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "saveChangesScript", script, true);

        try
        {
            if (node != null)
            {
                DocumentContext.CurrentPageInfo = PageInfoProvider.GetPageInfo(node.NodeSiteName, node.NodeAliasPath, node.DocumentCulture, null, node.NodeID, false);

                // Title
                string title = DocumentContext.CurrentTitle;
                if (!string.IsNullOrEmpty(title))
                {
                    title = "<title>" + title + "</title>";
                }

                // Body class
                string bodyCss = DocumentContext.CurrentBodyClass;

                if (bodyCss != null && bodyCss.Trim() != "")
                {
                    bodyCss = "class=\"" + bodyCss + "\"";
                }
                else
                {
                    bodyCss = "";
                }

                // Metadata
                string meta = "<meta http-equiv=\"pragma\" content=\"no-cache\" />";

                string description = DocumentContext.CurrentDescription;
                if (description != "")
                {
                    meta += "<meta name=\"description\" content=\"" + description + "\" />";
                }

                string keywords = DocumentContext.CurrentKeyWords;
                if (keywords != "")
                {
                    meta += "<meta name=\"keywords\"  content=\"" + keywords + "\" />";
                }

                // Site style sheet
                string cssSiteSheet = "";

                int stylesheetId = DocumentContext.CurrentPageInfo.DocumentStylesheetID;

                CssStylesheetInfo cssInfo = CssStylesheetInfoProvider.GetCssStylesheetInfo((stylesheetId > 0) ? stylesheetId : SiteContext.CurrentSite.SiteDefaultStylesheetID);

                if (cssInfo != null)
                {
                    cssSiteSheet = CssLinkHelper.GetCssFileLink(CssLinkHelper.GetStylesheetUrl(cssInfo.StylesheetName));
                }

                // Theme CSS files
                string themeCssFiles = "";
                if (cssInfo != null)
                {
                    try
                    {
                        string directory = URLHelper.GetPhysicalPath(string.Format("~/App_Themes/{0}/", cssInfo.StylesheetName));
                        if (Directory.Exists(directory))
                        {
                            foreach (string file in Directory.GetFiles(directory, "*.css"))
                            {
                                themeCssFiles += CssLinkHelper.GetCssFileLink(CssLinkHelper.GetPhysicalCssUrl(cssInfo.StylesheetName, Path.GetFileName(file)));
                            }
                        }
                    }
                    catch
                    {
                    }
                }

                // Add values to page
                mHead = FormatHTML(HighlightHTML(title + meta + cssSiteSheet + themeCssFiles), 2);
                mBody = bodyCss;
            }
        }
        catch
        {
            ShowError(GetString("MasterPage.PageEditErr"));
        }

        LoadData();

        // Add save action
        SaveAction save = new SaveAction();

        save.CommandArgument = ComponentEvents.SAVE_DATA;
        save.CommandName     = ComponentEvents.SAVE_DATA;

        headerActions.ActionsList.Add(save);

        if (pti != null)
        {
            // Disable buttons for no-template
            bool actionsEnabled = (pti.PageTemplateId > 0);

            // Edit layout
            HeaderAction action = new HeaderAction
            {
                Text          = GetString("content.ui.pagelayout"),
                Tooltip       = GetString("pageplaceholder.editlayouttooltip"),
                OnClientClick = "EditLayout();return false;",
                Enabled       = actionsEnabled
            };
            headerActions.ActionsList.Add(action);

            string elemUrl = ApplicationUrlHelper.GetElementDialogUrl("cms.design", "PageTemplate.EditPageTemplate", pti.PageTemplateId);

            // Edit page properties action
            action = new HeaderAction
            {
                Text          = GetString("PageProperties.EditTemplateProperties"),
                Tooltip       = GetString("PageProperties.EditTemplateProperties"),
                OnClientClick = "modalDialog('" + elemUrl + "', 'TemplateSelection', '85%', '85%');return false;",
                Enabled       = actionsEnabled
            };

            CMSPagePlaceholder.RegisterEditLayoutScript(this, pti.PageTemplateId, node.NodeAliasPath, null);
            headerActions.ActionsList.Add(action);

            // Preview
            HeaderAction preview = new HeaderAction
            {
                Text          = GetString("general.preview"),
                OnClientClick = "performToolbarAction('split');return false;",
                Visible       = ((previewState == 0) && !PortalUIHelper.DisplaySplitMode),
                Tooltip       = GetString("preview.tooltip")
            };
            headerActions.ActionsList.Add(preview);

            headerActions.ActionPerformed += headerActions_ActionPerformed;
        }

        RegisterInitScripts(pnlBody.ClientID, pnlMenu.ClientID, false);
    }
    /// <summary>
    /// Displays the report
    /// </summary>
    /// <param name="reload">If true display reload control is reloaded</param>
    private void DisplayReport(bool reload)
    {
        ucGraphType.ProcessChartSelectors(false);

        // Prepare report parameters
        DataTable dtp = new DataTable();

        dtp.Columns.Add("FromDate", typeof(DateTime));
        dtp.Columns.Add("ToDate", typeof(DateTime));
        dtp.Columns.Add("CodeName", typeof(string));
        dtp.Columns.Add("MVTestName", typeof(string));
        dtp.Columns.Add("ConversionName", typeof(string));
        dtp.Columns.Add("CombinationName", typeof(string));

        object[] parameters = new object[6];

        parameters[0] = ucGraphType.From;
        parameters[1] = ucGraphType.To;
        parameters[2] = "";
        parameters[3] = ValidationHelper.GetString(ucMVTests.Value, String.Empty);

        // Conversion
        String conversion = ValidationHelper.GetString(ucConversions.Value, String.Empty);

        if (conversion == ucConversions.AllRecordValue)
        {
            conversion = String.Empty;
        }

        parameters[4] = ValidationHelper.GetString(conversion, String.Empty);

        // Combination
        String combination = ValidationHelper.GetString(usCombination.Value, String.Empty);

        if (combination == usCombination.AllRecordValue)
        {
            combination = String.Empty;
        }

        parameters[5] = ValidationHelper.GetString(combination, String.Empty);

        dtp.Rows.Add(parameters);
        dtp.AcceptChanges();

        string reportName = ucGraphType.GetReportName(QueryHelper.GetString("reportCodeName", String.Empty));

        // Hide show selectors by report name
        if (reportName.Contains("mvtestconversionsbycombinations"))
        {
            pnlConversion.Visible = false;
        }
        else
        {
            pnlCultures.Visible    = false;
            pnlCombination.Visible = false;
        }

        // Load conversion by mvt code name
        if (pnlConversion.Visible)
        {
            ucConversions.MVTestName = ValidationHelper.GetString(ucMVTests.Value, String.Empty);
            ucConversions.PostbackOnDropDownChange = true;
            ucConversions.ReloadData(true);
        }

        // Load combination by mvt name
        if (pnlCombination.Visible)
        {
            string name = ValidationHelper.GetString(ucMVTests.Value, String.Empty);
            if ((name != String.Empty) && (name != ucMVTests.AllRecordValue))
            {
                string cultureWhere = String.Empty;
                string siteName     = CMSContext.CurrentSiteName;

                MVTestInfo mvt = MVTestInfoProvider.GetMVTestInfo(name, siteName);
                if (mvt != null)
                {
                    string culture = ValidationHelper.GetString(usCulture.Value, String.Empty);
                    if ((culture != String.Empty) && (culture != usCulture.AllRecordValue))
                    {
                        cultureWhere = " AND DocumentCulture = '" + culture.Replace("'", "''") + "'";
                    }

                    // Get the used page template column
                    string colName = "DocumentPageTemplateID";

                    PageInfo pi = PageInfoProvider.GetPageInfo(siteName, mvt.MVTestPage, culture, null, SiteInfoProvider.CombineWithDefaultCulture(siteName));
                    if (pi != null)
                    {
                        colName = pi.GetUsedPageTemplateIdColumn();
                    }

                    // Prepare where condition
                    string where = String.Format("MVTCombinationPageTemplateID IN (SELECT {0} FROM View_CMS_Tree_Joined WHERE NodeSiteID = {1} AND NodeAliasPath ='{2}'{3})", colName, CMSContext.CurrentSiteID, mvt.MVTestPage, cultureWhere);

                    usCombination.WhereCondition = SqlHelperClass.AddWhereCondition(usCombination.WhereCondition, where);
                    usCombination.ReloadData(true);
                }
            }
        }

        // Set report
        ucDisplayReport.ReportName = reportName;

        if (!ucDisplayReport.IsReportLoaded())
        {
            ShowError(String.Format(GetString("Analytics_Report.ReportDoesnotExist"), reportName));
        }
        else
        {
            ucDisplayReport.LoadFormParameters   = false;
            ucDisplayReport.DisplayFilter        = false;
            ucDisplayReport.ReportParameters     = dtp.Rows[0];
            ucDisplayReport.GraphImageWidth      = 100;
            ucDisplayReport.IgnoreWasInit        = true;
            ucDisplayReport.UseExternalReload    = true;
            ucDisplayReport.UseProgressIndicator = true;
            ucDisplayReport.SelectedInterval     = HitsIntervalEnumFunctions.HitsConversionToString(ucGraphType.SelectedInterval);

            // Reload data only if parameter is set
            if (reload)
            {
                ucDisplayReport.ReloadData(true);
            }
        }
    }
Esempio n. 9
0
    /// <summary>
    /// Processes the specified version of the file and returns the data to the output stream.
    /// </summary>
    /// <param name="attachmentGuid">Attachment GUID</param>
    /// <param name="versionHistoryId">Document version history ID</param>
    protected void ProcessFile(Guid attachmentGuid, int versionHistoryId)
    {
        AttachmentInfo atInfo = GetFile(attachmentGuid, versionHistoryId);

        if (atInfo != null)
        {
            // If attachment is image, try resize
            byte[] mFile = atInfo.AttachmentBinary;
            if (mFile != null)
            {
                string mimetype = null;
                if (ImageHelper.IsImage(atInfo.AttachmentExtension))
                {
                    if (AttachmentManager.CanResizeImage(atInfo, Width, Height, MaxSideSize))
                    {
                        // Do not search thumbnail on the disk
                        mFile    = AttachmentManager.GetImageThumbnail(atInfo, CurrentSiteName, Width, Height, MaxSideSize, false);
                        mimetype = "image/jpeg";
                    }
                }

                if (mFile != null)
                {
                    outputFile = NewOutputFile(atInfo, mFile);
                }
                else
                {
                    outputFile = NewOutputFile();
                }
                outputFile.Height      = Height;
                outputFile.Width       = Width;
                outputFile.MaxSideSize = MaxSideSize;
                outputFile.MimeType    = mimetype;
            }

            // Get the file document
            if (node == null)
            {
                node = TreeProvider.SelectSingleDocument(atInfo.AttachmentDocumentID);
            }

            if (node != null)
            {
                // Check secured area
                SiteInfo si = SiteInfoProvider.GetSiteInfo(node.NodeSiteID);
                if (si != null)
                {
                    if (pi == null)
                    {
                        pi = PageInfoProvider.GetPageInfo(si.SiteName, node.NodeAliasPath, node.DocumentCulture, node.DocumentUrlPath, false);
                    }
                    if (pi != null)
                    {
                        URLRewriter.RequestSecurePage(pi, false, ViewMode, CurrentSiteName);
                        URLRewriter.CheckSecuredAreas(CurrentSiteName, pi, false, ViewMode);
                    }
                }

                // Check the permissions for the document
                if ((CurrentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.Read) == AuthorizationResultEnum.Allowed) || (node.NodeOwner == CurrentUser.UserID))
                {
                    if (outputFile == null)
                    {
                        outputFile = NewOutputFile();
                    }

                    outputFile.AliasPath   = node.NodeAliasPath;
                    outputFile.CultureCode = node.DocumentCulture;
                    if (IsLiveSite && AttachmentManager.CheckPublishedFiles(CurrentSiteName))
                    {
                        outputFile.IsPublished = node.IsPublished;
                    }
                    outputFile.FileNode = node;
                }
                else
                {
                    outputFile = null;
                }
            }
        }
    }
Esempio n. 10
0
    private void ReloadData()
    {
        if (Node != null)
        {
            // Hide parts which are not relevant to content only nodes
            if (ShowContentOnlyProperties)
            {
                pnlUIAdvanced.Visible        = false;
                pnlUICache.Visible           = false;
                pnlUIDesign.Visible          = false;
                plcPermanent.Visible         = false;
                pnlUIOnlineMarketing.Visible = false;
            }

            // Log activities checkboxes
            if (!RequestHelper.IsPostBack())
            {
                bool?logVisit = Node.DocumentLogVisitActivity;
                chkLogPageVisit.Checked = (logVisit == true);
                if (Node.NodeParentID > 0)  // Init "inherit" option for child nodes (and hide option for root)
                {
                    chkPageVisitInherit.Checked = (logVisit == null);
                    if (logVisit == null)
                    {
                        chkPageVisitInherit_CheckedChanged(null, EventArgs.Empty);
                    }
                }
                chkLogPageVisit.Enabled = !chkPageVisitInherit.Checked;
            }

            // Check modify permission
            canEdit = (MembershipContext.AuthenticatedUser.IsAuthorizedPerDocument(Node, NodePermissionsEnum.Modify) != AuthorizationResultEnum.Denied);

            // Show document group owner selector
            if (ModuleEntryManager.IsModuleLoaded(ModuleName.COMMUNITY) && canEditOwner && LicenseHelper.CheckFeature(RequestContext.CurrentDomain, FeatureEnum.Groups))
            {
                plcOwnerGroup.Controls.Clear();
                // Initialize panel content
                Panel rowWrapperPanel = new Panel();
                rowWrapperPanel.CssClass = "form-group";
                Panel lblPanel = new Panel();
                lblPanel.CssClass = "editing-form-label-cell";
                Panel ctrlPanel = new Panel();
                ctrlPanel.CssClass = "editing-form-value-cell";

                // Initialize caption
                LocalizedLabel lblOwnerGroup = new LocalizedLabel();
                lblOwnerGroup.EnableViewState = false;
                lblOwnerGroup.ResourceString  = "community.group.documentowner";
                lblOwnerGroup.ID       = "lblOwnerGroup";
                lblOwnerGroup.CssClass = "control-label";
                lblPanel.Controls.Add(lblOwnerGroup);

                // Initialize selector
                fcDocumentGroupSelector                = (FormEngineUserControl)Page.LoadUserControl("~/CMSAdminControls/UI/Selectors/DocumentGroupSelector.ascx");
                fcDocumentGroupSelector.ID             = "fcDocumentGroupSelector";
                fcDocumentGroupSelector.StopProcessing = pnlUIOwner.IsHidden;
                ctrlPanel.Controls.Add(fcDocumentGroupSelector);
                fcDocumentGroupSelector.Value = ValidationHelper.GetInteger(Node.GetValue("NodeGroupID"), 0);
                fcDocumentGroupSelector.SetValue("siteid", SiteContext.CurrentSiteID);
                fcDocumentGroupSelector.SetValue("nodeid", Node.NodeID);

                // Add controls to containers
                rowWrapperPanel.Controls.Add(lblPanel);
                rowWrapperPanel.Controls.Add(ctrlPanel);
                plcOwnerGroup.Controls.Add(rowWrapperPanel);
                plcOwnerGroup.Visible = true;
            }

            // Show owner editing only when authorized to change the permissions
            if (canEditOwner)
            {
                lblOwner.Visible = false;
                usrOwner.Visible = true;
                usrOwner.SetValue("AdditionalUsers", new[] { Node.NodeOwner });
            }
            else
            {
                usrOwner.Visible = false;
            }

            if (!RequestHelper.IsPostBack())
            {
                if (canEditOwner)
                {
                    usrOwner.Value = Node.GetValue("NodeOwner");
                }
            }

            // Load the data
            lblName.Text     = HttpUtility.HtmlEncode(Node.GetDocumentName());
            lblNamePath.Text = HttpUtility.HtmlEncode(Convert.ToString(Node.GetValue("DocumentNamePath")));

            lblAliasPath.Text = Convert.ToString(Node.NodeAliasPath);
            string typeName = DataClassInfoProvider.GetDataClassInfo(Node.NodeClassName).ClassDisplayName;
            lblType.Text   = HttpUtility.HtmlEncode(ResHelper.LocalizeString(typeName));
            lblNodeID.Text = Convert.ToString(Node.NodeID);

            // Modifier
            SetUserLabel(lblLastModifiedBy, "DocumentModifiedByUserId");

            // Get modified time
            TimeZoneInfo usedTimeZone;
            DateTime     lastModified = ValidationHelper.GetDateTime(Node.GetValue("DocumentModifiedWhen"), DateTimeHelper.ZERO_TIME);
            lblLastModified.Text = TimeZoneHelper.GetCurrentTimeZoneDateTimeString(lastModified, MembershipContext.AuthenticatedUser, SiteContext.CurrentSite, out usedTimeZone);
            ScriptHelper.AppendTooltip(lblLastModified, TimeZoneHelper.GetUTCLongStringOffset(usedTimeZone), "help");

            if (!canEditOwner)
            {
                // Owner
                SetUserLabel(lblOwner, "NodeOwner");
            }

            // Creator
            SetUserLabel(lblCreatedBy, "DocumentCreatedByUserId");
            DateTime createdWhen = ValidationHelper.GetDateTime(Node.GetValue("DocumentCreatedWhen"), DateTimeHelper.ZERO_TIME);
            lblCreated.Text = TimeZoneHelper.GetCurrentTimeZoneDateTimeString(createdWhen, MembershipContext.AuthenticatedUser, SiteContext.CurrentSite, out usedTimeZone);
            ScriptHelper.AppendTooltip(lblCreated, TimeZoneHelper.GetUTCLongStringOffset(usedTimeZone), "help");

            // URL
            if (plcPermanent.Visible)
            {
                string permanentUrl = DocumentURLProvider.GetPermanentDocUrl(Node.NodeGUID, Node.NodeAlias, Node.NodeSiteName, extension: ".aspx");
                permanentUrl = URLHelper.ResolveUrl(permanentUrl);

                lnkPermanentURL.HRef      = permanentUrl;
                lnkPermanentURL.InnerText = permanentUrl;
            }

            string liveUrl = DocumentURLProvider.GetAbsoluteLiveSiteURL(Node);

            lnkLiveURL.HRef      = liveUrl;
            lnkLiveURL.InnerText = liveUrl;

            bool isRoot = Node.IsRoot();

            // Hide preview URL for root node
            if (!isRoot)
            {
                plcPreview.Visible                = true;
                btnResetPreviewGuid.ToolTip       = GetString("GeneralProperties.InvalidatePreviewURL");
                btnResetPreviewGuid.Click        += btnResetPreviewGuid_Click;
                btnResetPreviewGuid.OnClientClick = "if(!confirm(" + ScriptHelper.GetLocalizedString("GeneralProperties.GeneratePreviewURLConf") + ")){return false;}";

                InitPreviewUrl();
            }

            lblGUID.Text    = Convert.ToString(Node.NodeGUID);
            lblDocGUID.Text = (Node.DocumentGUID == Guid.Empty) ? ResHelper.Dash : Node.DocumentGUID.ToString();
            lblDocID.Text   = Convert.ToString(Node.DocumentID);

            // Culture
            CultureInfo ci = CultureInfoProvider.GetCultureInfo(Node.DocumentCulture);
            lblCulture.Text = ((ci != null) ? ResHelper.LocalizeString(ci.CultureName) : Node.DocumentCulture);

            if (Node.IsPublished)
            {
                lblPublished.Text      = GetString("General.Yes");
                lblPublished.CssClass += " DocumentPublishedYes";
            }
            else
            {
                lblPublished.CssClass += " DocumentPublishedNo";
                lblPublished.Text      = GetString("General.No");
            }

            // Load page info for inherited cache settings
            currentPage = PageInfoProvider.GetPageInfo(Node.NodeSiteName, Node.NodeAliasPath, Node.DocumentCulture, null, Node.NodeID, false);

            if (!RequestHelper.IsPostBack())
            {
                // Init radio buttons for cache settings
                if (isRoot)
                {
                    radInherit.Visible   = false;
                    radFSInherit.Visible = false;
                    chkCssStyle.Visible  = false;
                }
                else
                {
                    // Show what is inherited value
                    radInherit.Text   = GetString("GeneralProperties.radInherit") + " (" + GetInheritedCacheCaption("NodeCacheMinutes") + ")";
                    radFSInherit.Text = GetString("GeneralProperties.radInherit") + " (" + GetInheritedCacheCaption("NodeAllowCacheInFileSystem") + ")";
                }

                string cacheMinutes = "";

                switch (Node.NodeCacheMinutes)
                {
                case null:
                    // Cache setting is inherited
                {
                    radNo.Checked      = true;
                    radYes.Checked     = false;
                    radInherit.Checked = false;
                    if (!isRoot)
                    {
                        radInherit.Checked = true;
                        radNo.Checked      = false;

                        if ((currentPage != null) && (currentPage.NodeCacheMinutes > 0))
                        {
                            cacheMinutes = currentPage.NodeCacheMinutes.ToString();
                        }
                    }
                }
                break;

                case 0:
                    // Cache is off
                    radNo.Checked      = true;
                    radYes.Checked     = false;
                    radInherit.Checked = false;
                    break;

                default:
                    // Cache is enabled
                    radNo.Checked      = false;
                    radYes.Checked     = true;
                    radInherit.Checked = false;
                    cacheMinutes       = Node.NodeCacheMinutes.ToString();
                    break;
                }

                // Set secured radio buttons
                switch (Node.NodeAllowCacheInFileSystem)
                {
                case false:
                    radFSNo.Checked = true;
                    break;

                case true:
                    radFSYes.Checked = true;
                    break;

                default:
                    if (!isRoot)
                    {
                        radFSInherit.Checked = true;
                    }
                    else
                    {
                        radFSYes.Checked = true;
                    }
                    break;
                }

                txtCacheMinutes.Text = cacheMinutes;

                if (!radYes.Checked)
                {
                    txtCacheMinutes.Enabled = false;
                }

                var defaultStylesheet = GetDefaultStylesheet();

                if (Node.DocumentInheritsStylesheet && !isRoot)
                {
                    chkCssStyle.Checked = true;

                    // Get stylesheet from the parent node
                    string value = GetStylesheetParentValue();
                    ctrlSiteSelectStyleSheet.Value = String.IsNullOrEmpty(value) ? defaultStylesheet : value;
                }
                else
                {
                    // Get stylesheet from the current node
                    var stylesheetId = Node.DocumentStylesheetID;
                    ctrlSiteSelectStyleSheet.Value = (stylesheetId == 0) ? defaultStylesheet : stylesheetId.ToString();
                }
            }

            // Disable new button if document inherit stylesheet
            bool disableCssSelector = (!isRoot && chkCssStyle.Checked);
            ctrlSiteSelectStyleSheet.Enabled          = !disableCssSelector;
            ctrlSiteSelectStyleSheet.ButtonNewEnabled = !disableCssSelector;

            // Initialize Rating control
            RefreshCntRatingResult();

            double rating = 0.0f;
            if (Node.DocumentRatings > 0)
            {
                rating = Node.DocumentRatingValue / Node.DocumentRatings;
            }
            ratingControl.MaxRating     = 10;
            ratingControl.CurrentRating = rating;
            ratingControl.Visible       = true;
            ratingControl.Enabled       = false;

            // Initialize Reset button for rating
            btnResetRating.OnClientClick = "if (!confirm(" + ScriptHelper.GetString(GetString("GeneralProperties.ResetRatingConfirmation")) + ")) return false;";

            object[] param = new object[1];
            param[0] = Node.DocumentID;

            plcAdHocForums.Visible = hasAdHocForum;
            plcAdHocBoards.Visible = hasAdHocBoard;

            if (!canEdit)
            {
                // Disable form editing
                DisableFormEditing();
            }
        }
        else
        {
            btnResetRating.Visible = false;
        }
    }
Esempio n. 11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ScriptHelper.RegisterProgress(this);

        if (!RequestHelper.IsPostBack())
        {
            chkWebParts.Checked = PortalHelper.DisplayContentInDesignMode;
        }

        chkWebParts.Attributes.Add("onclick", "SaveSettings()");
        chkWebParts.Text = GetString("EditTabs.DisplayContent");

        string scripts =
            @"
function SetTabsContext(mode) {
    if ((mode == 'design') || (mode == 'wireframe')) {
        document.getElementById('divDesign').style.display = 'block';
    } else {
        document.getElementById('divDesign').style.display = 'none';
    }
    parent.SetSelectedMode(mode);
}

function RefreshContent() {
    parent.frames['contenteditview'].document.location.replace(parent.frames['contenteditview'].document.location);
}

function SaveSettings() { 
    __theFormPostData = ''; 
    WebForm_InitCallback(); " +
            ClientScript.GetCallbackEventReference(this, "'save'", "RefreshContent", null) + @"; 
}";

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "editTabsScripts", scripts, true);

        // Initialize tabs
        tabsModes.OnTabCreated       += tabModes_OnTabCreated;
        tabsModes.OnCheckTabSecurity += tabsModes_OnCheckTabSecurity;
        tabsModes.SelectedTab         = 0;
        tabsModes.UrlTarget           = "contenteditview";

        // Process the page mode
        currentUser = CMSContext.CurrentUser;

        if (Node != null)
        {
            // Product tab
            showProductTab = Node.HasSKU;

            // Initialize required variables
            authorizedPerDesign = currentUser.IsAuthorizedPerResource("CMS.Design", "Design");

            isWireframe  = Node.IsWireframe();
            hasWireframe = isWireframe || (Node.NodeWireframeTemplateID > 0);

            // Get page template information
            try
            {
                PageInfo pi = PageInfoProvider.GetPageInfo(CMSContext.CurrentSiteName, Node.NodeAliasPath, Node.DocumentCulture, Node.DocumentUrlPath, false);
                if ((pi != null) && (pi.DesignPageTemplateInfo != null))
                {
                    PageTemplateInfo pti = pi.DesignPageTemplateInfo;
                    isPortalPage  = pti.IsPortal;
                    isMasterPage  = isPortalPage && ((Node.NodeAliasPath == "/") || pti.ShowAsMasterTemplate);
                    designEnabled = ((pti.PageTemplateType == PageTemplateTypeEnum.Portal) || (pti.PageTemplateType == PageTemplateTypeEnum.AspxPortal));
                }
            }
            catch
            {
                // Page info not found - probably tried to display document from different site
            }

            // Do not show design tab for CMS.File
            if (Node.NodeClassName.EqualsCSafe("CMS.File", true))
            {
                designEnabled = false;
            }
        }
    }
Esempio n. 12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        CMSContext.ViewMode = ViewModeEnum.MasterPage;

        // Keep current user
        user = CMSContext.CurrentUser;

        // Check UIProfile
        if (!user.IsAuthorizedPerUIElement("CMS.Content", "MasterPage"))
        {
            RedirectToCMSDeskUIElementAccessDenied("CMS.Content", "MasterPage");
        }

        // Check "Design" permission
        if (!user.IsAuthorizedPerResource("CMS.Design", "Design"))
        {
            RedirectToAccessDenied("CMS.Design", "Design");
        }

        // Register the scripts
        ScriptHelper.RegisterProgress(this);
        ScriptHelper.RegisterSaveShortcut(btnSave, null, false);

        // Save changes support
        bool   confirmChanges = SettingsKeyProvider.GetBoolValue(CMSContext.CurrentSiteName + ".CMSConfirmChanges");
        string script         = string.Empty;

        if (confirmChanges)
        {
            script = "var confirmLeave='" + ResHelper.GetString("Content.ConfirmLeave", user.PreferredUICultureCode) + "'; \n";
        }
        else
        {
            script += "confirmChanges = false;";
        }

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "saveChangesScript", ScriptHelper.GetScript(script));

        nodeId = QueryHelper.GetInteger("NodeId", 0);

        try
        {
            CMSContext.CurrentPageInfo = PageInfoProvider.GetPageInfo(CMSContext.CurrentSiteName, "/", CMSContext.PreferredCultureCode, null, false);

            // Title
            string title = CMSContext.CurrentTitle;
            if (!string.IsNullOrEmpty(title))
            {
                title = "<title>" + title + "</title>";
            }

            // Body class
            string bodyCss = CMSContext.CurrentBodyClass;
            if (bodyCss != null && bodyCss.Trim() != "")
            {
                bodyCss = "class=\"" + bodyCss + "\"";
            }
            else
            {
                bodyCss = "";
            }

            // metadata
            string meta = "<meta http-equiv=\"pragma\" content=\"no-cache\" />";

            string description = CMSContext.CurrentDescription;
            if (description != "")
            {
                meta += "<meta name=\"description\" content=\"" + description + "\" />";
            }

            string keywords = CMSContext.CurrentKeyWords;
            if (keywords != "")
            {
                meta += "<meta name=\"keywords\"  content=\"" + keywords + "\" />";
            }

            // Site style sheet
            string cssSiteSheet = "";

            CssStylesheetInfo cssInfo = null;
            int stylesheetId          = CMSContext.CurrentPageInfo.DocumentStylesheetID;

            cssInfo = CssStylesheetInfoProvider.GetCssStylesheetInfo((stylesheetId > 0) ? stylesheetId : CMSContext.CurrentSite.SiteDefaultStylesheetID);

            if (cssInfo != null)
            {
                cssSiteSheet = CSSHelper.GetCSSFileLink(CSSHelper.GetStylesheetUrl(cssInfo.StylesheetName));
            }

            // Theme css files
            string themeCssFiles = "";
            if (cssInfo != null)
            {
                try
                {
                    string directory = URLHelper.GetPhysicalPath(string.Format("~/App_Themes/{0}/", cssInfo.StylesheetName));
                    if (Directory.Exists(directory))
                    {
                        foreach (string file in Directory.GetFiles(directory, "*.css"))
                        {
                            themeCssFiles += CSSHelper.GetCSSFileLink(CSSHelper.GetPhysicalCSSUrl(cssInfo.StylesheetName, Path.GetFileName(file)));
                        }
                    }
                }
                catch
                {
                }
            }

            // Add values to page
            mHead = FormatHTML(HighlightHTML(title + meta + cssSiteSheet + themeCssFiles), 2);
            mBody = bodyCss;
        }
        catch
        {
            lblError.Visible = true;
            lblError.Text    = GetString("MasterPage.PageEditErr");
        }

        // Prepare the hints and typw dropdown
        lblType.Text = ResHelper.GetString("PageLayout.Type");

        if (drpType.Items.Count == 0)
        {
            drpType.Items.Add(new ListItem(ResHelper.GetString("TransformationType.Ascx"), TransformationTypeEnum.Ascx.ToString()));
            drpType.Items.Add(new ListItem(ResHelper.GetString("TransformationType.Html"), TransformationTypeEnum.Html.ToString()));
        }

        string lang = ValidationHelper.GetString(SettingsHelper.AppSettings["CMSProgrammingLanguage"], "C#");

        ltlDirectives.Text = "&lt;%@ Control Language=\"" + lang + "\" ClassName=\"Simple\" Inherits=\"CMS.PortalControls.CMSAbstractLayout\" %&gt;<br />&lt;%@ Register Assembly=\"CMS.PortalControls\" Namespace=\"CMS.PortalControls\" TagPrefix=\"cc1\" %&gt;";

        if (!SettingsKeyProvider.UsingVirtualPathProvider)
        {
            lblChecked.Visible = true;
            lblChecked.Text    = "<br />" + AddSpaces(2) + GetString("MasterPage.VirtualPathProviderNotRunning");
            txtLayout.ReadOnly = true;
        }

        LoadData();

        // Register synchronization script for split mode
        if (CMSContext.DisplaySplitMode)
        {
            RegisterSplitModeSync(true, false);
        }
    }
Esempio n. 13
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string aliasPath   = QueryHelper.GetString("aliaspath", "");
        string webpartId   = QueryHelper.GetString("webpartid", "");
        string zoneId      = QueryHelper.GetString("zoneid", "");
        Guid   webpartGuid = QueryHelper.GetGuid("webpartguid", Guid.Empty);

        // Get page info
        PageInfo pi = PageInfoProvider.GetPageInfo(CMSContext.CurrentSiteName, aliasPath, CMSContext.PreferredCultureCode, null, CMSContext.CurrentSite.CombineWithDefaultCulture);

        if (pi != null)
        {
            // Get template
            PageTemplateInfo pti = pi.GetInheritedTemplateInfo(CMSContext.PreferredCultureCode, CMSContext.CurrentSite.CombineWithDefaultCulture);

            // Get web part
            WebPartInstance webPart = pti.GetWebPart(webpartGuid, webpartId);
            if (webPart != null)
            {
                StringBuilder sb         = new StringBuilder();
                Hashtable     properties = webPart.Properties;

                // Get the webpart object
                WebPartInfo wi = WebPartInfoProvider.GetWebPartInfo(webPart.WebPartType);
                if (wi != null)
                {
                    // Add the header
                    sb.Append("Webpart properties (" + wi.WebPartDisplayName + ")" + Environment.NewLine + Environment.NewLine);
                    sb.Append("Alias path: " + aliasPath + Environment.NewLine);
                    sb.Append("Zone ID: " + zoneId + Environment.NewLine + Environment.NewLine);


                    string wpProperties = "<default></default>";
                    // Get the form info object and load it with the data

                    if (wi.WebPartParentID > 0)
                    {
                        // Load parent properties
                        WebPartInfo wpi = WebPartInfoProvider.GetWebPartInfo(wi.WebPartParentID);
                        if (wpi != null)
                        {
                            wpProperties = wpi.WebPartProperties;
                        }
                    }
                    else
                    {
                        wpProperties = wi.WebPartProperties;
                    }

                    FormInfo fi = new FormInfo(wpProperties);

                    // General properties of webparts
                    string beforeFormDefinition = PortalHelper.GetWebPartProperties((WebPartTypeEnum)wi.WebPartType, PropertiesPosition.Before);
                    string afterFormDefinition  = PortalHelper.GetWebPartProperties((WebPartTypeEnum)wi.WebPartType, PropertiesPosition.After);

                    // General properties before custom
                    if (!String.IsNullOrEmpty(beforeFormDefinition))
                    {
                        // Load before properties
                        FormInfo bfi = new FormInfo(beforeFormDefinition);
                        bfi.UpdateExistingFields(fi);
                        sb.Append(Environment.NewLine + "Default" + Environment.NewLine + Environment.NewLine + Environment.NewLine);
                        sb.Append(GetProperties(bfi.GetFormElements(true, false), webPart));
                    }

                    // Generate custom properties
                    sb.Append(GetProperties(fi.GetFormElements(true, false), webPart));

                    // General properties after custom
                    if (!String.IsNullOrEmpty(afterFormDefinition))
                    {
                        FormInfo afi = new FormInfo(afterFormDefinition);
                        // Load before properties
                        afi.UpdateExistingFields(fi);

                        sb.Append(GetProperties(afi.GetFormElements(true, false), webPart));
                    }

                    // Send the text file to the user to download
                    UTF8Encoding enc  = new UTF8Encoding();
                    byte[]       file = enc.GetBytes(sb.ToString());

                    Response.AddHeader("Content-disposition", "attachment; filename=webpartproperties_" + webPart.ControlID + ".txt");
                    Response.ContentType = "text/plain";
                    Response.BinaryWrite(file);

                    RequestHelper.EndResponse();
                }
            }
        }
    }
Esempio n. 14
0
    protected void Page_Load(object sender, EventArgs e)
    {
        RegisterResizeHeaders();

        CMSContext.ViewMode = ViewModeEnum.MasterPage;
        previewState        = GetPreviewStateFromCookies(MASTERPAGE);

        // Keep current user
        user = CMSContext.CurrentUser;

        // Get document node
        tree = new TreeProvider(user);
        node = CMSContext.EditedObject as TreeNode;

        // Register the dialog script
        ScriptHelper.RegisterDialogScript(Page);

        // Register save changes
        ScriptHelper.RegisterSaveChanges(Page);

        // Save changes support
        bool   confirmChanges = SettingsKeyProvider.GetBoolValue(CMSContext.CurrentSiteName + ".CMSConfirmChanges");
        string script         = string.Empty;

        if (confirmChanges)
        {
            script = "var confirmLeave='" + ResHelper.GetString("Content.ConfirmLeave", user.PreferredUICultureCode) + "'; \n";
        }
        else
        {
            script += "confirmChanges = false;";
        }

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "saveChangesScript", ScriptHelper.GetScript(script));

        try
        {
            if (node != null)
            {
                CMSContext.CurrentPageInfo = PageInfoProvider.GetPageInfo(CMSContext.CurrentSiteName, node.NodeAliasPath, node.DocumentCulture, null, false);

                // Title
                string title = CMSContext.CurrentTitle;
                if (!string.IsNullOrEmpty(title))
                {
                    title = "<title>" + title + "</title>";
                }

                // Body class
                string bodyCss = CMSContext.CurrentBodyClass;
                if (bodyCss != null && bodyCss.Trim() != "")
                {
                    bodyCss = "class=\"" + bodyCss + "\"";
                }
                else
                {
                    bodyCss = "";
                }

                // Metadata
                string meta = "<meta http-equiv=\"pragma\" content=\"no-cache\" />";

                string description = CMSContext.CurrentDescription;
                if (description != "")
                {
                    meta += "<meta name=\"description\" content=\"" + description + "\" />";
                }

                string keywords = CMSContext.CurrentKeyWords;
                if (keywords != "")
                {
                    meta += "<meta name=\"keywords\"  content=\"" + keywords + "\" />";
                }

                // Site style sheet
                string cssSiteSheet = "";

                int stylesheetId = CMSContext.CurrentPageInfo.DocumentStylesheetID;

                CssStylesheetInfo cssInfo = CssStylesheetInfoProvider.GetCssStylesheetInfo((stylesheetId > 0) ? stylesheetId : CMSContext.CurrentSite.SiteDefaultStylesheetID);

                if (cssInfo != null)
                {
                    cssSiteSheet = CSSHelper.GetCSSFileLink(CSSHelper.GetStylesheetUrl(cssInfo.StylesheetName));
                }

                // Theme CSS files
                string themeCssFiles = "";
                if (cssInfo != null)
                {
                    try
                    {
                        string directory = URLHelper.GetPhysicalPath(string.Format("~/App_Themes/{0}/", cssInfo.StylesheetName));
                        if (Directory.Exists(directory))
                        {
                            foreach (string file in Directory.GetFiles(directory, "*.css"))
                            {
                                themeCssFiles += CSSHelper.GetCSSFileLink(CSSHelper.GetPhysicalCSSUrl(cssInfo.StylesheetName, Path.GetFileName(file)));
                            }
                        }
                    }
                    catch
                    {
                    }
                }

                // Add values to page
                mHead = FormatHTML(HighlightHTML(title + meta + cssSiteSheet + themeCssFiles), 2);
                mBody = bodyCss;
            }
        }
        catch
        {
            ShowError(GetString("MasterPage.PageEditErr"));
        }


        LoadData();

        // Add save action
        SaveAction save = new SaveAction(Page);

        save.CommandArgument = ComponentEvents.SAVE_DATA;
        save.CommandName     = ComponentEvents.SAVE_DATA;

        headerActions.ActionsList.Add(save);

        if (pti != null)
        {
            // Edit layout
            HeaderAction action = new HeaderAction
            {
                Text          = GetString("content.ui.pagelayout"),
                Tooltip       = GetString("pageplaceholder.editlayouttooltip"),
                OnClientClick = "EditLayout();return false;",
                ImageUrl      = GetImageUrl("CMSModules/CMS_PortalEngine/Edit.png")
            };
            headerActions.ActionsList.Add(action);

            // Edit page properties action
            action = new HeaderAction
            {
                Text          = GetString("PageProperties.EditTemplateProperties"),
                Tooltip       = GetString("PageProperties.EditTemplateProperties"),
                OnClientClick = "modalDialog('" + ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_Edit.aspx") + "?templateid=" + pti.PageTemplateId + "&nobreadcrumbs=1&dialog=1', 'TemplateSelection', 850, 680, false);return false;",
                ImageUrl      = GetImageUrl("CMSModules/CMS_Content/Template/edit.png")
            };

            CMSPagePlaceholder.RegisterEditLayoutScript(this, pti.PageTemplateId, node.NodeAliasPath, null);
            headerActions.ActionsList.Add(action);

            // Preview
            HeaderAction preview = new HeaderAction
            {
                ControlType   = HeaderActionTypeEnum.LinkButton,
                Text          = GetString("general.preview"),
                OnClientClick = "performToolbarAction('split');return false;",
                ImageUrl      = GetImageUrl("CMSModules/CMS_Content/EditMenu/Preview.png"),
                SmallImageUrl = GetImageUrl("CMSModules/CMS_Content/EditMenu/16/Preview.png"),
                Visible       = ((previewState == 0) && !CMSContext.DisplaySplitMode),
                Tooltip       = GetString("preview.tooltip")
            };
            headerActions.ActionsList.Add(preview);

            headerActions.ActionPerformed += new CommandEventHandler(headerActions_ActionPerformed);
        }

        RegisterInitScripts(pnlBody.ClientID, pnlMenu.ClientID, false);
    }
Esempio n. 15
0
    private string GetFirstChildUrl()
    {
        var url = TreePathUtils.GetFirstChildUrl(PageInfoProvider.GetPageInfo(Node.DocumentGUID));

        return(string.IsNullOrEmpty(url) ? GetString("content.menu.nochilddocument") : string.Format("<a target=\"_blank\" href=\"{0}\" >{0}</a>", URLHelper.ResolveUrl(url)));
    }
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        // Public user is not allowed for widgets
        if (!AuthenticationHelper.IsAuthenticated())
        {
            RedirectToAccessDenied(GetString("widgets.security.notallowed"));
        }

        var viewMode = ViewModeCode.FromString(QueryHelper.GetString("viewmode", String.Empty));
        var hash     = QueryHelper.GetString("hash", String.Empty);

        LiveSiteWidgetsParameters dialogparameters = new LiveSiteWidgetsParameters(aliasPath, viewMode)
        {
            ZoneId         = zoneId,
            ZoneType       = zoneType,
            InstanceGuid   = instanceGuid,
            TemplateId     = templateId,
            IsInlineWidget = inline
        };

        if (!dialogparameters.ValidateHash(hash))
        {
            return;
        }

        // Set page title
        Page.Title = GetString(isNewWidget ? "widgets.propertiespage.titlenew" : "widgets.propertiespage.title");

        if ((widgetId != string.Empty) && (aliasPath != string.Empty))
        {
            // Get page info
            var      siteName = SiteContext.CurrentSiteName;
            PageInfo pi       = PageInfoProvider.GetPageInfo(siteName, aliasPath, LocalizationContext.PreferredCultureCode, null, SiteInfoProvider.CombineWithDefaultCulture(siteName));

            if (pi == null)
            {
                return;
            }

            // Get template instance
            PageTemplateInstance templateInstance = CMSPortalManager.GetTemplateInstanceForEditing(pi);

            // Get widget from instance
            WidgetInfo wi = null;
            if (!isNewWidget)
            {
                // Get the instance of widget
                WebPartInstance widgetInstance = templateInstance.GetWebPart(instanceGuid, widgetId);
                if (widgetInstance == null)
                {
                    return;
                }

                // Get widget info by widget name(widget type)
                wi = WidgetInfoProvider.GetWidgetInfo(widgetInstance.WebPartType);
            }
            // Widget instance hasn't created yet
            else
            {
                wi = WidgetInfoProvider.GetWidgetInfo(ValidationHelper.GetInteger(widgetId, 0));
            }


            if (wi != null)
            {
                WebPartZoneInstance zone = templateInstance.GetZone(zoneId);
                if (zone != null)
                {
                    var currentUser = MembershipContext.AuthenticatedUser;

                    bool checkSecurity = true;

                    // Check security
                    // It is group zone type but widget is not allowed in group
                    if (zone.WidgetZoneType == WidgetZoneTypeEnum.Group)
                    {
                        // Should always be, only group widget are allowed in group zone
                        if (wi.WidgetForGroup)
                        {
                            if (!currentUser.IsGroupAdministrator(pi.NodeGroupID))
                            {
                                RedirectToAccessDenied(GetString("widgets.security.notallowed"));
                            }

                            // All ok, don't check classic security
                            checkSecurity = false;
                        }
                    }

                    if (checkSecurity && !WidgetRoleInfoProvider.IsWidgetAllowed(wi, currentUser.UserID, AuthenticationHelper.IsAuthenticated()))
                    {
                        RedirectToAccessDenied(GetString("widgets.security.notallowed"));
                    }
                }
            }
        }
        // If all ok, set up frames
        rowsFrameset.Attributes.Add("rows", string.Format("{0}, *", TitleOnlyHeight));

        frameHeader.Attributes.Add("src", "widgetproperties_header.aspx" + RequestContext.CurrentQueryString);
        if (inline && !isNewWidget)
        {
            frameContent.Attributes.Add("src", ResolveUrl("~/CMSPages/Blank.htm"));
        }
        else
        {
            frameContent.Attributes.Add("src", "widgetproperties_properties_frameset.aspx" + RequestContext.CurrentQueryString);
        }
    }
Esempio n. 17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string aliasPath   = QueryHelper.GetString("aliaspath", "");
        string webpartId   = QueryHelper.GetString("webpartid", "");
        string zoneId      = QueryHelper.GetString("zoneid", "");
        Guid   webpartGuid = QueryHelper.GetGuid("webpartguid", Guid.Empty);
        int    templateId  = QueryHelper.GetInteger("templateId", 0);

        PageTemplateInfo pti = null;

        if (templateId > 0)
        {
            pti = PageTemplateInfoProvider.GetPageTemplateInfo(templateId);
        }

        if (pti == null)
        {
            var      siteName = SiteContext.CurrentSiteName;
            PageInfo pi       = PageInfoProvider.GetPageInfo(siteName, aliasPath, LocalizationContext.PreferredCultureCode, null, SiteInfoProvider.CombineWithDefaultCulture(siteName));
            if (pi != null)
            {
                pti = pi.UsedPageTemplateInfo;
            }
        }

        if (pti != null)
        {
            // Get web part
            WebPartInstance webPart = pti.TemplateInstance.GetWebPart(webpartGuid, webpartId);
            if (webPart != null)
            {
                StringBuilder sb         = new StringBuilder();
                Hashtable     properties = webPart.Properties;

                // Get the webpart object
                WebPartInfo wi = WebPartInfoProvider.GetWebPartInfo(webPart.WebPartType);
                if (wi != null)
                {
                    // Add the header
                    sb.Append("Webpart properties (" + wi.WebPartDisplayName + ")" + Environment.NewLine + Environment.NewLine);
                    sb.Append("Alias path: " + aliasPath + Environment.NewLine);
                    sb.Append("Zone ID: " + zoneId + Environment.NewLine + Environment.NewLine);


                    string wpProperties = "<default></default>";
                    // Get the form info object and load it with the data

                    if (wi.WebPartParentID > 0)
                    {
                        // Load parent properties
                        WebPartInfo wpi = WebPartInfoProvider.GetWebPartInfo(wi.WebPartParentID);
                        if (wpi != null)
                        {
                            wpProperties = FormHelper.MergeFormDefinitions(wpi.WebPartProperties, wi.WebPartProperties);
                        }
                    }
                    else
                    {
                        wpProperties = wi.WebPartProperties;
                    }

                    FormInfo fi = new FormInfo(wpProperties);

                    // General properties of webparts
                    string beforeFormDefinition = PortalFormHelper.GetWebPartProperties((WebPartTypeEnum)wi.WebPartType, PropertiesPosition.Before);
                    string afterFormDefinition  = PortalFormHelper.GetWebPartProperties((WebPartTypeEnum)wi.WebPartType, PropertiesPosition.After);

                    // General properties before custom
                    if (!String.IsNullOrEmpty(beforeFormDefinition))
                    {
                        // Load before definition
                        fi = new FormInfo(FormHelper.MergeFormDefinitions(beforeFormDefinition, wpProperties, true));

                        // Add Default category for first before items
                        sb.Append(Environment.NewLine + "Default" + Environment.NewLine + Environment.NewLine + Environment.NewLine);
                    }


                    // General properties after custom
                    if (!String.IsNullOrEmpty(afterFormDefinition))
                    {
                        // Load after definition
                        fi = new FormInfo(FormHelper.MergeFormDefinitions(fi.GetXmlDefinition(), afterFormDefinition, true));
                    }

                    // Generate all properties
                    sb.Append(GetProperties(fi.GetFormElements(true, false), webPart));

                    // Send the text file to the user to download
                    UTF8Encoding enc  = new UTF8Encoding();
                    byte[]       file = enc.GetBytes(sb.ToString());

                    Response.AddHeader("Content-disposition", "attachment; filename=webpartproperties_" + HTTPHelper.GetDispositionFilename(webPart.ControlID) + ".txt");
                    Response.ContentType = "text/plain";
                    Response.BinaryWrite(file);

                    RequestHelper.EndResponse();
                }
            }
        }
    }
Esempio n. 18
0
    public string LogHits(string pageGUID, string referrer)
    {
        string   siteName    = CMSContext.CurrentSiteName;
        UserInfo currentUser = CMSContext.CurrentUser;

        // Need to fake referrer and current page
        RequestStockHelper.Add("AnalyticsReferrerString", referrer);
        PageInfo currentPage = CMSContext.CurrentPageInfo = PageInfoProvider.GetPageInfo(new Guid(pageGUID));

        if (!AnalyticsHelper.JavascriptLoggingEnabled(siteName))
        {
            throw new InvalidOperationException("logging by JS not enabled");
        }

        // ONLINE MARKETING
        {
            // Log activities
            if (ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) && ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser))
            {
                int contactId = ModuleCommands.OnlineMarketingGetCurrentContactID();

                CMSContext.ContactID = contactId;
                if (contactId > 0)
                {
                    ModuleCommands.OnlineMarketingLogLandingPage(0);
                    ModuleCommands.OnlineMarketingLogExternalSearch(0);
                    ModuleCommands.OnlineMarketingLogPageVisit(0);
                    UpdateContactsIPandUserAgent(siteName);
                }
            }
        }

        if (AnalyticsHelper.IsLoggingEnabled(siteName, currentPage.NodeAliasPath))
        {
            // PAGE VIEW
            if (AnalyticsHelper.TrackPageViewsEnabled(siteName))
            {
                HitLogProvider.LogHit(HitLogProvider.PAGE_VIEWS, siteName, currentUser.PreferredCultureCode, currentPage.NodeAliasPath, currentPage.NodeID);
            }


            // AGGREGATED VIEW
            /// not logged by JavaScript call


            // FILE DOWNLOADS
            /// file downloads are logged via special WebPart that directly outputs specified file (and before that logs a hit), so there is no way we can log this via JS


            // BROWSER CAPABILITIES
            /// are already logged by JavaScript via WebPart AnalayicsBrowserCapabilities


            // SEARCH CRAWLER
            /// not logged by JavaScript call


            // INVALID PAGES
            /// throw 404 and there's no need to call it via JavaScript (even if RSS gets 404, we should know about it)


            // URL REFFERALS
            /// RSS readers and crawlers might set custom referral, so this is needed
            /// cannot be loopback
            /// cannot be the same host
            if (AnalyticsHelper.TrackReferralsEnabled(siteName))
            {
                TrackReferral(siteName);
            }

            // ON-SITE SEARCH KEYWORDS
            /// separate method


            // BANNER HITS
            /// separate method


            // BANNER CLICKS


            // VISITOR
            // BROWSER TYPE
            // MOBILE DEVICES
            // BROWSER TYPE
            // COUNTRIES
            /// Cookies VisitorStatus, VisitStatus (a obsolete CurrentVisitStatus)
            /// IP
            /// method uses AnalyticsHelper.GetContextStatus and AnalyticsHelper.SetContextStatus and also logs all mobile devices
            AnalyticsMethods.LogVisitor(siteName);


            // REFERRING SITE
            // ALL TRAFFIC SOURCES (REFERRINGSITE + "_local") (REFERRINGSITE + "_direct") (REFERRINGSITE + "_search") (REFERRINGSITE + "_referring")
            // SEARCH KEYWORDS
            // LANDING PAGE
            // EXIT PAGE
            // TIME ON PAGE
            AnalyticsMethods.LogAnalytics(SessionHelper.GetSessionID(), currentPage, siteName);
        }

        return("ok");
    }
Esempio n. 19
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Public user is not allowed for widgets
        if (!CMSContext.CurrentUser.IsAuthenticated())
        {
            RedirectToAccessDenied(GetString("widgets.security.notallowed"));
        }

        string widgetId     = QueryHelper.GetString("widgetid", String.Empty);
        string aliasPath    = QueryHelper.GetString("aliasPath", String.Empty);
        string zoneId       = QueryHelper.GetString("zoneid", String.Empty);
        Guid   instanceGUID = QueryHelper.GetGuid("instanceguid", Guid.Empty);
        bool   isNewWidget  = QueryHelper.GetBoolean("isnew", false);
        bool   inline       = QueryHelper.GetBoolean("inline", false);

        // Set page title
        Page.Title = GetString(isNewWidget ? "widgets.propertiespage.titlenew" : "widgets.propertiespage.title");

        if ((widgetId != string.Empty) && (aliasPath != string.Empty))
        {
            // Get pageinfo
            PageInfo pi = null;
            try
            {
                pi = PageInfoProvider.GetPageInfo(CMSContext.CurrentSiteName, aliasPath, CMSContext.PreferredCultureCode, null, CMSContext.CurrentSite.CombineWithDefaultCulture);
            }
            catch (PageNotFoundException)
            {
                // Do not throw exception if page info not found (e.g. bad alias path)
            }

            if (pi == null)
            {
                return;
            }

            // Get template instance
            PageTemplateInstance templateInstance = CMSPortalManager.GetTemplateInstanceForEditing(pi);

            // Get widget from instance
            WidgetInfo wi = null;
            if (!isNewWidget)
            {
                // Get the instance of widget
                WebPartInstance widgetInstance = templateInstance.GetWebPart(instanceGUID, widgetId);
                if (widgetInstance == null)
                {
                    return;
                }

                // Get widget info by widget name(widget type)
                wi = WidgetInfoProvider.GetWidgetInfo(widgetInstance.WebPartType);
            }
            // Widget instance hasn't created yet
            else
            {
                wi = WidgetInfoProvider.GetWidgetInfo(ValidationHelper.GetInteger(widgetId, 0));
            }


            if (wi != null)
            {
                WebPartZoneInstance zone = templateInstance.GetZone(zoneId);
                if (zone != null)
                {
                    CurrentUserInfo currentUser = CMSContext.CurrentUser;

                    bool checkSecurity = true;

                    // Check security
                    // It is group zone type but widget is not allowed in group
                    if (zone.WidgetZoneType == WidgetZoneTypeEnum.Group)
                    {
                        // Should always be, only group widget are allowed in group zone
                        if (wi.WidgetForGroup)
                        {
                            if (!currentUser.IsGroupAdministrator(pi.NodeGroupID))
                            {
                                RedirectToAccessDenied(GetString("widgets.security.notallowed"));
                            }

                            // All ok, don't check classic security
                            checkSecurity = false;
                        }
                    }

                    if (checkSecurity && !WidgetRoleInfoProvider.IsWidgetAllowed(wi, currentUser.UserID, currentUser.IsAuthenticated()))
                    {
                        RedirectToAccessDenied(GetString("widgets.security.notallowed"));
                    }
                }
            }
        }
        // If all ok, set up frames
        frameHeader.Attributes.Add("src", "widgetproperties_header.aspx" + URLHelper.Url.Query);
        if (inline && !isNewWidget)
        {
            frameContent.Attributes.Add("src", ResolveUrl("~/CMSPages/Blank.htm"));
        }
        else
        {
            frameContent.Attributes.Add("src", "widgetproperties_properties_frameset.aspx" + URLHelper.Url.Query);
        }
    }
Esempio n. 20
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            // Do nothing
        }
        else
        {
            partPlaceholder.CheckPermissions = CheckPermissions;
            partPlaceholder.CacheMinutes     = CacheMinutes;

            // Load content only when default page template or path is defined
            string templateName = PageTemplate;
            string path         = Path;

            if ((templateName != "") || (path != ""))
            {
                ViewModeEnum viewMode = ViewModeEnum.Unknown;

                // Process template only if the control is on the last hierarchy page
                PageInfo         currentPage = PagePlaceholder.PageInfo;
                PageInfo         usePage;
                PageTemplateInfo ti = null;

                if (String.IsNullOrEmpty(path))
                {
                    // Use the same page
                    usePage = PagePlaceholder.PageInfo;

                    if (UseDefaultTemplateOnSubPages || (currentPage.ChildPageInfo == null) || (currentPage.ChildPageInfo.UsedPageTemplateInfo == null) || (currentPage.ChildPageInfo.UsedPageTemplateInfo.PageTemplateId == 0))
                    {
                        ti = PageTemplateInfoProvider.GetPageTemplateInfo(templateName);
                    }
                }
                else
                {
                    // Resolve the path first
                    path = MacroResolver.ResolveCurrentPath(path);

                    // Get specific page
                    usePage = PageInfoProvider.GetPageInfo(SiteContext.CurrentSiteName, path, LocalizationContext.PreferredCultureCode, null, SiteContext.CurrentSite.CombineWithDefaultCulture);
                    if (PortalManager.ViewMode != ViewModeEnum.LiveSite)
                    {
                        viewMode = ViewModeEnum.Preview;

                        // Set design mode for document's placeholder if is currently displayed
                        TreeNode tn = DocumentContext.CurrentDocument;
                        if ((tn != null) && (PortalContext.ViewMode == ViewModeEnum.Design) && tn.NodeAliasPath.EqualsCSafe(path, true))
                        {
                            viewMode = ViewModeEnum.Design;
                        }

                        // Get latest version data of current document content
                        if (usePage != null)
                        {
                            usePage.LoadVersion();
                        }
                    }

                    // Get the appropriate page template
                    if (String.IsNullOrEmpty(templateName))
                    {
                        ti = (usePage != null) ? usePage.UsedPageTemplateInfo : null;
                    }
                    else
                    {
                        ti = PageTemplateInfoProvider.GetPageTemplateInfo(templateName);
                    }
                }

                if ((usePage != null) && (ti != null))
                {
                    // If same template as current page, avoid cycling
                    if (ti.PageTemplateId == currentPage.UsedPageTemplateInfo.PageTemplateId)
                    {
                        lblError.Text    = GetString("WebPart.PagePlaceHolder.CurrentTemplateNotAllowed");
                        lblError.Visible = true;
                    }
                    else
                    {
                        usePage = usePage.Clone();

                        // Setup the page template
                        int templateId = ti.PageTemplateId;

                        usePage.SetPageTemplateId(templateId);
                        usePage.UsedPageTemplateInfo = ti;

                        // Load the current page info with the template and document
                        if (viewMode != ViewModeEnum.Unknown)
                        {
                            partPlaceholder.ViewMode = viewMode;
                        }

                        partPlaceholder.UsingDefaultPageTemplate = !string.IsNullOrEmpty(templateName);
                        partPlaceholder.UsingDefaultDocument     = !string.IsNullOrEmpty(path);
                        partPlaceholder.PageLevel = PagePlaceholder.PageLevel;
                        partPlaceholder.LoadContent(usePage);
                    }
                }
            }
        }
    }
Esempio n. 21
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (this.StopProcessing)
        {
            // Do nothing
        }
        else
        {
            this.partPlaceholder.CheckPermissions = this.CheckPermissions;
            this.partPlaceholder.CacheMinutes     = this.CacheMinutes;

            // Load content only when default page template or path is defined
            string templateName = this.PageTemplate;
            string path         = this.Path;

            if ((templateName != "") || (path != ""))
            {
                ViewModeEnum viewMode = ViewModeEnum.Unknown;

                // Process template only if the control is on the last hierarchy page
                PageInfo         currentPage = this.PagePlaceholder.PageInfo;
                PageInfo         usePage     = null;
                PageTemplateInfo ti          = null;

                if (String.IsNullOrEmpty(path))
                {
                    // Use the same page
                    usePage = this.PagePlaceholder.PageInfo;

                    if (this.UseDefaultTemplateOnSubPages || (currentPage.ChildPageInfo == null) || (currentPage.ChildPageInfo.PageTemplateInfo == null) || (currentPage.ChildPageInfo.PageTemplateInfo.PageTemplateId == 0))
                    {
                        ti = PageTemplateInfoProvider.GetPageTemplateInfo(templateName);
                    }
                }
                else
                {
                    // Resolve the path first
                    path = CMSContext.ResolveCurrentPath(path);

                    // Get specific page
                    usePage = PageInfoProvider.GetPageInfo(CMSContext.CurrentSiteName, path, CMSContext.PreferredCultureCode, null, false);
                    if (this.PortalManager.ViewMode != ViewModeEnum.LiveSite)
                    {
                        viewMode = ViewModeEnum.Preview;

                        // Get current document content
                        if (usePage != null)
                        {
                            TreeNode node = DocumentHelper.GetDocument(usePage.DocumentId, null);
                            if (node != null)
                            {
                                usePage.LoadVersion(node);
                            }
                        }
                    }

                    // Get the appropriate page template
                    if (String.IsNullOrEmpty(templateName))
                    {
                        ti = usePage.PageTemplateInfo;
                    }
                    else
                    {
                        ti = PageTemplateInfoProvider.GetPageTemplateInfo(templateName);
                    }
                }

                if ((usePage != null) && (ti != null))
                {
                    // If same template as current page, avoid cycling
                    if (ti.PageTemplateId == currentPage.PageTemplateInfo.PageTemplateId)
                    {
                        this.lblError.Text    = GetString("WebPart.PagePlaceHolder.CurrentTemplateNotAllowed");
                        this.lblError.Visible = true;
                    }
                    else
                    {
                        usePage = usePage.Clone();
                        usePage.DocumentPageTemplateID = ti.PageTemplateId;
                        usePage.PageTemplateInfo       = ti;


                        // Load the current page info with the template and document
                        if (viewMode != ViewModeEnum.Unknown)
                        {
                            this.partPlaceholder.ViewMode = viewMode;
                        }

                        this.partPlaceholder.UsingDefaultPageTemplate = true;
                        this.partPlaceholder.PageLevel = this.PagePlaceholder.PageLevel;
                        this.partPlaceholder.LoadContent(usePage, true);
                    }
                }
            }
        }
    }
Esempio n. 22
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!RequestHelper.IsPostBack())
        {
            chkWebParts.Checked = PortalHelper.DisplayContentInDesignMode;
        }

        tabQuery = QueryHelper.GetString("tabspecific", null);

        chkWebParts.Attributes.Add("onclick", "SaveSettings()");
        chkWebParts.Text = GetString("EditTabs.DisplayContent");

        ltlScript.Text += ScriptHelper.GetScript("function SaveSettings() { __theFormPostData = ''; WebForm_InitCallback(); " + ClientScript.GetCallbackEventReference(this, "'save'", "RefreshContent", null) + "; }");

        // Initialize tabs
        tabsModes.OnTabCreated += tabModes_OnTabCreated;
        tabsModes.SelectedTab   = 0;
        tabsModes.UrlTarget     = "contenteditview";

        // Process the page mode
        currentUser = CMSContext.CurrentUser;

        // Current Node ID
        nodeId = QueryHelper.GetInteger("nodeid", 0);

        TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);
        TreeNode     node = tree.SelectSingleNode(nodeId);

        if (node != null)
        {
            // Product tab
            DataClassInfo classObj = DataClassInfoProvider.GetDataClass(node.NodeClassName);
            if (classObj != null)
            {
                showProductTab = SettingsKeyProvider.GetBoolValue(CMSContext.CurrentSiteName + ".ProductTabEnabled") && classObj.ClassIsProduct;
            }

            // Initialize required variables
            authorizedPerDesign = currentUser.IsAuthorizedPerResource("CMS.Design", "Design");
            isWireframe         = node.NodeClassName.Equals("CMS.Wireframe", StringComparison.InvariantCultureIgnoreCase);

            // Get page template information
            PageInfo pi = PageInfoProvider.GetPageInfo(CMSContext.CurrentSiteName, node.NodeAliasPath, node.DocumentCulture, node.DocumentUrlPath, false);
            if ((pi != null) && (pi.PageTemplateInfo != null))
            {
                PageTemplateInfo pti = pi.PageTemplateInfo;

                isPortalPage  = pti.IsPortal;
                isMasterPage  = isPortalPage && ((node.NodeAliasPath == "/") || pti.ShowAsMasterTemplate);
                designEnabled = ((pti.PageTemplateType == PageTemplateTypeEnum.Portal) || (pti.PageTemplateType == PageTemplateTypeEnum.AspxPortal));
            }

            // Do not show design tab for CMS.File
            if (node.NodeClassName.Equals("CMS.File", StringComparison.InvariantCultureIgnoreCase))
            {
                designEnabled = false;
            }

            // Update view mode
            UpdateViewMode(ViewModeEnum.Edit);

            // Get the page mode
            currentMode = CMSContext.ViewMode;
        }
    }
Esempio n. 23
0
    /// <summary>
    /// Handles UniGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of the action which should be performed</param>
    /// <param name="actionArgument">ID of the item the action should be performed with</param>
    protected void gridElem_OnAction(string actionName, object actionArgument)
    {
        if (!CheckPermissions("CMS.ContentPersonalization", PERMISSION_MODIFY))
        {
            return;
        }

        int variantId = ValidationHelper.GetInteger(actionArgument, 0);

        if (variantId > 0)
        {
            string action = actionName.ToLowerCSafe();
            switch (action)
            {
            case "delete":
            {
                // Get the instance in order to clear the cache
                ContentPersonalizationVariantInfo vi = ContentPersonalizationVariantInfoProvider.GetContentPersonalizationVariant(variantId);

                // Delete the object
                ContentPersonalizationVariantInfoProvider.DeleteContentPersonalizationVariant(variantId);
                RaiseOnAction(string.Empty, null);

                // Log widget variant synchronization
                if ((vi != null) && (vi.VariantDocumentID > 0))
                {
                    // Log synchronization
                    DocumentSynchronizationHelper.LogDocumentChange(Node, TaskTypeEnum.UpdateDocument, tree);
                }
            }
            break;

            case "up":
            case "down":
            {
                // Get the instance in order to clear the cache
                ContentPersonalizationVariantInfo vi = ContentPersonalizationVariantInfoProvider.GetContentPersonalizationVariant(variantId);

                // Use try/catch due to license check
                try
                {
                    if (action == "up")
                    {
                        // Move up
                        ContentPersonalizationVariantInfoProvider.MoveVariantUp(variantId);
                    }
                    else
                    {
                        // Move down
                        ContentPersonalizationVariantInfoProvider.MoveVariantDown(variantId);
                    }

                    // Reload the variants in the current cached pageInfo
                    if ((Node != null) && (vi != null))
                    {
                        // Get the PageInfo of the current document
                        PageInfo pi = PageInfoProvider.GetPageInfo(CMSContext.CurrentSiteName, Node.NodeAliasPath, CMSContext.PreferredCultureCode, null, Node.NodeID, tree.CombineWithDefaultCulture);

                        // Reload the zone/web part variants when moving up/down
                        if ((pi != null) && (pi.UsedPageTemplateInfo != null) && (pi.UsedPageTemplateInfo.TemplateInstance != null))
                        {
                            // Reload web part, widget variants
                            if (vi.VariantInstanceGUID != Guid.Empty)
                            {
                                WebPartInstance webPartInstance = pi.UsedPageTemplateInfo.TemplateInstance.GetWebPart(vi.VariantInstanceGUID);
                                if (webPartInstance != null)
                                {
                                    webPartInstance.LoadVariants(true, VariantModeEnum.ContentPersonalization);
                                }
                            }
                            // Reload zone variants
                            else
                            {
                                WebPartZoneInstance zoneInstance = pi.UsedPageTemplateInfo.TemplateInstance.GetZone(vi.VariantZoneID);
                                if (zoneInstance != null)
                                {
                                    zoneInstance.LoadVariants(true, VariantModeEnum.ContentPersonalization);
                                }
                            }
                        }

                        RaiseOnAction(string.Empty, null);

                        // Log widget variant synchronization
                        if (vi.VariantDocumentID > 0)
                        {
                            // Log synchronization
                            DocumentSynchronizationHelper.LogDocumentChange(Node, TaskTypeEnum.UpdateDocument, tree);
                        }
                    }
                }
                catch (Exception ex)
                {
                    lblError.Visible = true;
                    lblError.Text    = ex.Message;
                }
            }
            break;
            }
        }
    }