コード例 #1
0
    /// <summary>
    /// Gets and bulk updates layouts. Called when the "Get and bulk update layouts" button is pressed.
    /// Expects the CreateLayout method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateLayouts()
    {
        // Prepare the parameters
        string where = "LayoutCodeName LIKE N'MyNewLayout%'";

        // Get the data
        DataSet layouts = LayoutInfoProvider.GetLayouts(where, null);

        if (!DataHelper.DataSourceIsEmpty(layouts))
        {
            // Loop through the individual items
            foreach (DataRow layoutDr in layouts.Tables[0].Rows)
            {
                // Create object from DataRow
                LayoutInfo modifyLayout = new LayoutInfo(layoutDr);

                // Update the properties
                modifyLayout.LayoutDisplayName = modifyLayout.LayoutDisplayName.ToUpper();

                // Save the changes
                LayoutInfoProvider.SetLayoutInfo(modifyLayout);
            }

            return(true);
        }

        return(false);
    }
コード例 #2
0
    /// <summary>
    /// Executes the UnsetTragetLayout client action using parameters passed in hidden fields.
    /// </summary>
    private void UnsetTargetLayout()
    {
        int sourceLayoutId = ValidationHelper.GetInteger(SourceLayoutIdentifierHiddenField.Value, 0);

        using (var scope = new CMSTransactionScope())
        {
            LayoutInfo sourceLayout = LayoutInfoProvider.GetLayoutInfo(sourceLayoutId);
            if (sourceLayout == null)
            {
                throw new ApplicationException(GetString("device_profile.layoutmapping.errors.nosourcelayout"));
            }

            InfoObjectCollection <DeviceProfileLayoutInfo> bindings = DeviceProfileLayoutInfoProvider.GetDeviceProfileLayouts()
                                                                      .WhereEquals("DeviceProfileID", DeviceProfile.ProfileID)
                                                                      .WhereEquals("SourceLayoutID", sourceLayout.LayoutId)
                                                                      .TypedResult
                                                                      .Items;

            if (bindings.Count > 0)
            {
                DeviceProfileLayoutInfoProvider.DeleteDeviceProfileLayoutInfo(bindings[0]);
            }
            scope.Commit();
        }
    }
コード例 #3
0
    /// <summary>
    /// Generates HTML text to be used in description area.
    /// </summary>
    ///<param name="selectedValue">Selected item for which generate description</param>
    private string ShowInDescriptionArea(string selectedValue)
    {
        string name        = String.Empty;
        string description = String.Empty;

        if (!String.IsNullOrEmpty(selectedValue))
        {
            int     layoutId = ValidationHelper.GetInteger(selectedValue, 0);
            DataSet ds       = LayoutInfoProvider.GetLayouts("LayoutID = " + layoutId, null, 0, "LayoutDisplayName, LayoutDescription");
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                name        = ValidationHelper.GetString(ds.Tables[0].Rows[0]["LayoutDisplayName"], "");
                description = ValidationHelper.GetString(ds.Tables[0].Rows[0]["LayoutDescription"], "");
            }
        }
        else
        {
            name = GetString("layouts.selectlayout");
        }

        string text = "<div class=\"ItemName\">" + HTMLHelper.HTMLEncode(name) + "</div>";

        if (description != null)
        {
            text += "<div class=\"Description\">" + HTMLHelper.HTMLEncode(description) + "</div>";
        }

        return(text);
    }
コード例 #4
0
    /// <summary>
    /// Radio button changed.
    /// </summary>
    protected void radShared_CheckedChanged(object sender, EventArgs e)
    {
        if (radCustom.Checked)
        {
            txtCustom.ReadOnly    = false;
            txtCustomCSS.ReadOnly = false;

            drpType.Enabled = true;

            selectShared.Enabled = false;
        }
        else
        {
            drpType.Enabled = false;

            txtCustom.ReadOnly    = true;
            txtCustomCSS.ReadOnly = true;

            selectShared.Enabled = true;

            LayoutInfo li = LayoutInfoProvider.GetLayoutInfo(ValidationHelper.GetInteger(selectShared.Value, 0));
            if (li != null)
            {
                txtCustom.Text    = li.LayoutCode;
                txtCustomCSS.Text = li.LayoutCSS;
            }
        }
    }
コード例 #5
0
    /// <summary>
    /// Saves the layout.
    /// </summary>
    /// <returns>Returns true if successful</returns>
    private bool SaveLayout()
    {
        string codeName = tbCodeName.Text.Trim();

        // Find out whether required fields are not empty
        string result = new Validator()
                        .NotEmpty(codeName, GetString("Administration-PageLayout_New.ErrorEmptyLayoutCodeName"))
                        .NotEmpty(tbLayoutDisplayName.Text, GetString("Administration-PageLayout_New.ErrorEmptyLayoutDisplayName"))
                        .NotEmpty(tbLayoutCode.Text.Trim(), GetString("Administration-PageLayout_New.ErrorEmptyLayoutCode"))
                        .IsCodeName(codeName, GetString("general.invalidcodename"))
                        .Result;

        if (result == "")
        {
            if (li == null)
            {
                li = new LayoutInfo();
            }

            li.LayoutCodeName    = codeName;
            li.LayoutDisplayName = tbLayoutDisplayName.Text.Trim();
            li.LayoutDescription = tbLayoutDescription.Text;
            li.LayoutType        = LayoutInfoProvider.GetLayoutTypeEnum(this.drpType.SelectedValue);

            if (li.LayoutCheckedOutByUserID <= 0)
            {
                li.LayoutCode = tbLayoutCode.Text;
                li.LayoutCSS  = txtLayoutCSS.Text;
            }

            try
            {
                LayoutInfoProvider.SetLayoutInfo(li);
                lblInfo.Visible   = true;
                lblInfo.Text      = GetString("General.ChangesSaved");
                breadcrumbs[1, 0] = li.LayoutDisplayName;
            }
            catch (Exception ex)
            {
                lblInfo.Visible  = false;
                lblError.Visible = true;
                lblError.Text    = ex.Message.Replace("%%name%%", li.LayoutCodeName);
                return(false);
            }

            layoutId = li.LayoutId;

            UploadFile.ObjectID = layoutId;
            UploadFile.UploadFile();

            return(!UploadFile.SavingFailed);
        }
        else
        {
            lblError.Text    = result;
            lblError.Visible = true;
            return(false);
        }
    }
コード例 #6
0
    /// <summary>
    /// Gets the edited object.
    /// </summary>
    private object GetEditedObject()
    {
        object editedObject = null;

        if (PageTemplate != null)
        {
            int newSharedLayoutId = QueryHelper.GetInteger("newshared", -1);
            int oldSharedLayoutId = QueryHelper.GetInteger("oldshared", -1);

            // Default state - no radio buttons used
            if ((newSharedLayoutId == -1) && (oldSharedLayoutId == -1))
            {
                editedObject = PageTemplate;
            }
            else
            {
                // If new shared layout is set, than it should be used as edited object
                // This happens when switched from custom to a shared layout
                if (newSharedLayoutId > 0)
                {
                    // Standard page layout
                    editedObject = LayoutInfoProvider.GetLayoutInfo(newSharedLayoutId);
                }
                // This means user switched from shared layout to custom
                else
                {
                    var layout = LayoutInfoProvider.GetLayoutInfo(oldSharedLayoutId);

                    // We have to work with the clone, because we need to change the data of the object
                    // (copy from shared layout)
                    var pageTemplateClone = PageTemplate.Clone();

                    if (layout != null)
                    {
                        // Delete the shared layout
                        pageTemplateClone.LayoutID = 0;

                        // Copy values
                        pageTemplateClone.PageTemplateLayout     = layout.LayoutCode;
                        pageTemplateClone.PageTemplateCSS        = layout.LayoutCSS;
                        pageTemplateClone.PageTemplateLayoutType = layout.LayoutType;
                    }

                    editedObject = pageTemplateClone;
                }
            }
        }
        // Load the layout  object
        else
        {
            var layoutId = QueryHelper.GetInteger("layoutid", 0);
            if (layoutId > 0)
            {
                editedObject = LayoutInfoProvider.GetLayoutInfo(layoutId);
            }
        }

        return(editedObject);
    }
コード例 #7
0
    private string LayoutSelector_OnItemSelected(string value)
    {
        int targetLayoutId = ValidationHelper.GetInteger(value, 0);

        TargetLayout = LayoutInfoProvider.GetLayoutInfo(targetLayoutId);

        return(ExecuteFunction(() => GetTargetLayoutDescription()));
    }
コード例 #8
0
    /// <summary>
    /// Creates a new instance of control that displays layout mapping for the specified layout, and returns it.
    /// </summary>
    /// <param name="sourceLayoutId">An identifier of the source layout.</param>
    /// <returns>A new instance of control that displays layout mapping for the specified layout.</returns>
    private CMSModules_DeviceProfiles_Controls_LayoutBinding CreateLayoutBindingControl(int sourceLayoutId)
    {
        CMSModules_DeviceProfiles_Controls_LayoutBinding control = LoadControl("~/CMSModules/DeviceProfiles/Controls/LayoutBinding.ascx") as CMSModules_DeviceProfiles_Controls_LayoutBinding;

        control.SourceLayout  = LayoutInfoProvider.GetLayoutInfo(sourceLayoutId);
        control.DeviceProfile = DeviceProfile;

        return(control);
    }
コード例 #9
0
ファイル: EditLayout.ascx.cs プロジェクト: kudutest2/Kentico
    /// <summary>
    /// Check in event handler.
    /// </summary>
    protected void btnCheckIn_Click(object sender, EventArgs e)
    {
        LayoutInfo       li  = this.PagePlaceholder.LayoutInfo;
        PageTemplateInfo pti = this.PagePlaceholder.PageTemplateInfo;

        if ((li != null) || (pti != null))
        {
            string filename    = "";
            string tmpFileName = "";

            if (li != null)
            {
                tmpFileName = li.LayoutCheckedOutFilename;
            }
            else
            {
                tmpFileName = pti.PageTemplateLayoutCheckedOutFileName;
            }

            if (HttpContext.Current != null)
            {
                filename = HttpContext.Current.Server.MapPath(tmpFileName);
            }
            StreamReader sr = StreamReader.New(filename);

            // Read away the directive lines
            int skiplines = LayoutInfoProvider.GetLayoutDirectives().Split('\n').Length - 1;
            for (int i = 0; i < skiplines; i++)
            {
                sr.ReadLine();
            }

            string newcode = sr.ReadToEnd();
            sr.Close();
            File.Delete(filename);

            if (li != null)
            {
                li.LayoutCheckedOutByUserID    = 0;
                li.LayoutCheckedOutFilename    = "";
                li.LayoutCheckedOutMachineName = "";
                li.LayoutCode = newcode;
                LayoutInfoProvider.SetLayoutInfo(li);
            }
            else
            {
                pti.PageTemplateLayoutCheckedOutByUserID    = 0;
                pti.PageTemplateLayoutCheckedOutFileName    = "";
                pti.PageTemplateLayoutCheckedOutMachineName = "";
                pti.PageTemplateLayout = newcode;
                PageTemplateInfoProvider.SetPageTemplateInfo(pti);
            }

            txtLayout.Text = newcode;
        }
    }
コード例 #10
0
    /// <summary>
    /// Deletes layout. Called when the "Delete layout" button is pressed.
    /// Expects the CreateLayout method to be run first.
    /// </summary>
    private bool DeleteLayout()
    {
        // Get the layout
        LayoutInfo deleteLayout = LayoutInfoProvider.GetLayoutInfo("MyNewLayout");

        // Delete the layout
        LayoutInfoProvider.DeleteLayoutInfo(deleteLayout);

        return(deleteLayout != null);
    }
コード例 #11
0
    protected override void OnPreInit(EventArgs e)
    {
        dialogMode = QueryHelper.GetBoolean("editonlycode", false);
        layoutId   = QueryHelper.GetInteger("layoutid", 0);
        templateId = QueryHelper.GetInteger("templateid", 0);

        if (dialogMode)
        {
            MasterPageFile = "~/CMSMasterPages/UI/Dialogs/TabsHeader.master";
        }
        else
        {
            CheckAccessToSiteManager();
        }

        CurrentMaster.Title.HelpName      = "helpTopic";
        CurrentMaster.Title.HelpTopicName = "CMS_Design_page_layout";

        if (templateId > 0)
        {
            CurrentMaster.Title.TitleImage = GetImageUrl("Objects/CMS_Layout/object.png");
            CurrentMaster.Title.TitleText  = GetString("pagetemplate.layoutproperties");
        }
        else
        {
            CurrentMaster.Title.TitleImage = GetImageUrl("Objects/CMS_Layout/object.png");
            CurrentMaster.Title.TitleText  = GetString("administration-pagelayout_new.editlayout");
        }

        if (templateId > 0)
        {
            var template = PageTemplateInfoProvider.GetPageTemplateInfo(templateId);

            if (template.LayoutID > 0)
            {
                layoutId = template.LayoutID;
            }
            else
            {
                EditedObject = template;
                displayName  = template.DisplayName;
                themePath    = template.GetThemePath();
            }
        }

        if (layoutId > 0)
        {
            var layout = LayoutInfoProvider.GetLayoutInfo(layoutId);
            EditedObject = layout;
            displayName  = layout.LayoutDisplayName;
            themePath    = layout.GetThemePath();
        }

        base.OnPreInit(e);
    }
コード例 #12
0
 /// <summary>
 /// Handles the UniGrid's OnAction event.
 /// </summary>
 /// <param name="actionName">Name of item (button) that threw event</param>
 /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
 protected void UniGridModules_OnAction(string actionName, object actionArgument)
 {
     if (actionName == "edit")
     {
         URLHelper.Redirect("PageLayout_Frameset.aspx?layoutId=" + actionArgument.ToString());
     }
     else if (actionName == "delete")
     {
         LayoutInfoProvider.DeleteLayoutInfo(Convert.ToInt32(actionArgument));
     }
 }
コード例 #13
0
    /// <summary>
    /// DropDownlist change.
    /// </summary>
    protected void selectShared_Changed(object sender, EventArgs ea)
    {
        LayoutInfo li = LayoutInfoProvider.GetLayoutInfo(ValidationHelper.GetInteger(selectShared.Value, 0));

        if (li != null)
        {
            txtCustom.Text     = li.LayoutCode;
            txtCustom.ReadOnly = true;

            txtCustomCSS.Text     = li.LayoutCSS;
            txtCustomCSS.ReadOnly = true;
        }
    }
コード例 #14
0
    /// <summary>
    /// Creates layout. Called when the "Create layout" button is pressed.
    /// </summary>
    private bool CreateLayout()
    {
        // Create new layout object
        LayoutInfo newLayout = new LayoutInfo();

        // Set the properties
        newLayout.LayoutDisplayName = "My new layout";
        newLayout.LayoutCodeName    = "MyNewLayout";
        newLayout.LayoutDescription = "This is layout created by API Example";
        newLayout.LayoutCode        = "<cms:CMSWebPartZone ZoneID=\"zoneA\" runat=\"server\" />";

        // Save the layout
        LayoutInfoProvider.SetLayoutInfo(newLayout);

        return(true);
    }
コード例 #15
0
    /// <summary>
    /// Gets and updates layout. Called when the "Get and update layout" button is pressed.
    /// Expects the CreateLayout method to be run first.
    /// </summary>
    private bool GetAndUpdateLayout()
    {
        // Get the layout
        LayoutInfo updateLayout = LayoutInfoProvider.GetLayoutInfo("MyNewLayout");

        if (updateLayout != null)
        {
            // Update the properties
            updateLayout.LayoutDisplayName = updateLayout.LayoutDisplayName.ToLower();

            // Save the changes
            LayoutInfoProvider.SetLayoutInfo(updateLayout);

            return(true);
        }

        return(false);
    }
コード例 #16
0
ファイル: EditLayout.ascx.cs プロジェクト: kudutest2/Kentico
    /// <summary>
    /// Discard check out event handler.
    /// </summary>
    protected void btnUndoCheckOut_Click(object sender, EventArgs e)
    {
        LayoutInfo       li  = this.PagePlaceholder.LayoutInfo;
        PageTemplateInfo pti = this.PagePlaceholder.PageTemplateInfo;

        if ((li != null) || (pti != null))
        {
            string filename    = "";
            string tmpFileName = "";

            if (li != null)
            {
                tmpFileName = li.LayoutCheckedOutFilename;
            }
            else
            {
                tmpFileName = pti.PageTemplateLayoutCheckedOutFileName;
            }

            if (HttpContext.Current != null)
            {
                filename = HttpContext.Current.Server.MapPath(tmpFileName);
            }
            if (File.Exists(filename))
            {
                File.Delete(filename);
            }

            if (li != null)
            {
                li.LayoutCheckedOutByUserID    = 0;
                li.LayoutCheckedOutFilename    = "";
                li.LayoutCheckedOutMachineName = "";
                LayoutInfoProvider.SetLayoutInfo(li);
            }
            else
            {
                pti.PageTemplateLayoutCheckedOutByUserID    = 0;
                pti.PageTemplateLayoutCheckedOutFileName    = "";
                pti.PageTemplateLayoutCheckedOutMachineName = "";
                PageTemplateInfoProvider.SetPageTemplateInfo(pti);
            }
        }
    }
コード例 #17
0
ファイル: GetResource.ashx.cs プロジェクト: kudutest2/Kentico
    /// <summary>
    /// Retrieves the stylesheets of the layout from the database.
    /// </summary>
    /// <param name="layoutName">Layout name</param>
    /// <returns>The stylesheet data (plain version only)</returns>
    private static CMSOutputResource GetLayout(string layoutName)
    {
        LayoutInfo layoutInfo = LayoutInfoProvider.GetLayoutInfo(layoutName);

        if (layoutInfo == null)
        {
            return(null);
        }

        // Build the result
        CMSOutputResource resource = new CMSOutputResource()
        {
            Data         = HTMLHelper.ResolveCSSUrls(layoutInfo.LayoutCSS, URLHelper.ApplicationPath),
            LastModified = layoutInfo.LayoutLastModified,
            Etag         = layoutInfo.LayoutVersionGUID
        };

        return(resource);
    }
コード例 #18
0
    /// <summary>
    /// Executes the SetTragetLayout client action using parameters passed in hidden fields.
    /// </summary>
    private void SetTargetLayout()
    {
        int sourceLayoutId = ValidationHelper.GetInteger(SourceLayoutIdentifierHiddenField.Value, 0);
        int targetLayoutId = ValidationHelper.GetInteger(TargetLayoutIdentifierHiddenField.Value, 0);

        using (var scope = new CMSTransactionScope())
        {
            LayoutInfo sourceLayout = LayoutInfoProvider.GetLayoutInfo(sourceLayoutId);
            if (sourceLayout == null)
            {
                throw new ApplicationException(GetString("device_profile.layoutmapping.errors.nosourcelayout"));
            }
            LayoutInfo targetLayout = LayoutInfoProvider.GetLayoutInfo(targetLayoutId);
            if (targetLayout == null)
            {
                throw new ApplicationException(GetString("device_profile.layoutmapping.errors.notargetlayout"));
            }

            InfoObjectCollection <DeviceProfileLayoutInfo> bindings = DeviceProfileLayoutInfoProvider.GetDeviceProfileLayouts()
                                                                      .Where("DeviceProfileID", QueryOperator.Equals, DeviceProfile.ProfileID)
                                                                      .Where("SourceLayoutID", QueryOperator.Equals, sourceLayout.LayoutId)
                                                                      .TypedResult
                                                                      .Items;

            DeviceProfileLayoutInfo binding = null;
            if (bindings.Count > 0)
            {
                binding = bindings[0];
            }
            else
            {
                binding = new DeviceProfileLayoutInfo
                {
                    DeviceProfileID = DeviceProfile.ProfileID,
                    SourceLayoutID  = sourceLayout.LayoutId
                };
            }
            binding.TargetLayoutID = targetLayout.LayoutId;
            DeviceProfileLayoutInfoProvider.SetDeviceProfileLayoutInfo(binding);
            scope.Commit();
        }
    }
コード例 #19
0
    /// <summary>
    /// Executes the UnsetTragetLayout client action using parameters passed in hidden fields.
    /// </summary>
    private void UnsetTargetLayout()
    {
        int sourceLayoutId = ValidationHelper.GetInteger(SourceLayoutIdentifierHiddenField.Value, 0);

        using (CMSTransactionScope scope = new CMSTransactionScope())
        {
            LayoutInfo sourceLayout = LayoutInfoProvider.GetLayoutInfo(sourceLayoutId);
            if (sourceLayout == null)
            {
                throw new ApplicationException(GetString("device_profile.layoutmapping.errors.nosourcelayout"));
            }
            string condition = String.Format("DeviceProfileID = {0:D} AND SourceLayoutID = {1:D}", DeviceProfile.ProfileID, sourceLayout.LayoutId);
            InfoObjectCollection <DeviceProfileLayoutInfo> bindings = DeviceProfileLayoutInfoProvider.GetDeviceProfileLayouts(condition, null).Items;
            if (bindings.Count > 0)
            {
                DeviceProfileLayoutInfoProvider.DeleteDeviceProfileLayoutInfo(bindings[0]);
            }
            scope.Commit();
        }
    }
コード例 #20
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Setup the filesystem browser
        int layoutId = QueryHelper.GetInteger("layoutid", 0);

        if (layoutId > 0)
        {
            LayoutInfo li = LayoutInfoProvider.GetLayoutInfo(layoutId);
            EditedObject = li;

            if (li != null)
            {
                // Ensure the theme folder
                themeElem.Path = "~/App_Themes/Components/Layouts/" + ValidationHelper.GetSafeFileName(li.LayoutCodeName);
            }
        }
        else
        {
            EditedObject = null;
        }
    }
コード例 #21
0
    /// <summary>
    /// Save layout.
    /// </summary>
    public bool SaveLayout()
    {
        PageTemplateInfo pti = PageTemplateInfoProvider.GetPageTemplateInfo(templateId);

        if (pti != null)
        {
            if (radShared.Checked)
            {
                // Shared layout
                pnlCheckOutInfo.Visible = false;
                pti.LayoutID            = ValidationHelper.GetInteger(selectShared.Value, 0);
                pti.PageTemplateLayout  = "";
                pti.PageTemplateCSS     = "";
            }
            else
            {
                LayoutTypeEnum layoutType = LayoutInfoProvider.GetLayoutTypeEnum(this.drpType.SelectedValue);

                if ((layoutType != LayoutTypeEnum.Ascx) || user.IsAuthorizedPerResource("CMS.Design", "EditCode"))
                {
                    // Custom layout
                    pnlCheckOutInfo.Visible    = true;
                    pti.LayoutID               = 0;
                    pti.PageTemplateLayoutType = layoutType;
                    pti.PageTemplateLayout     = txtCustom.Text;
                    pti.PageTemplateCSS        = txtCustomCSS.Text;
                }
            }

            PageTemplateInfoProvider.SetPageTemplateInfo(pti);

            lblInfo.Visible = true;
            lblInfo.Text    = GetString("General.ChangesSaved");

            return(true);
        }

        return(false);
    }
コード例 #22
0
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);

        // Setup the filesystem browser
        int layoutId = QueryHelper.GetInteger("layoutid", 0);

        if (layoutId > 0)
        {
            LayoutInfo li = LayoutInfoProvider.GetLayoutInfo(layoutId);
            EditedObject = li;

            if (li != null)
            {
                // Ensure the theme folder
                themeElem.Path = li.GetThemePath();
            }
        }
        else
        {
            EditedObject = null;
        }
    }
コード例 #23
0
    /// <summary>
    /// Generates HTML text to be used in description area.
    /// </summary>
    ///<param name="selectedValue">Selected item for which generate description</param>
    private string ShowInDescriptionArea(string selectedValue)
    {
        string description = String.Empty;

        if (!String.IsNullOrEmpty(selectedValue))
        {
            int     layoutId = ValidationHelper.GetInteger(selectedValue, 0);
            DataSet ds       = LayoutInfoProvider.GetLayouts()
                               .WhereEquals("LayoutID", layoutId)
                               .Columns("LayoutDisplayName", "LayoutDescription");

            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                description = ResHelper.LocalizeString(ValidationHelper.GetString(ds.Tables[0].Rows[0]["LayoutDescription"], ""));
            }
        }

        if (!String.IsNullOrEmpty(description))
        {
            return("<div class=\"Description\">" + HTMLHelper.HTMLEncode(description) + "</div>");
        }

        return(String.Empty);
    }
コード例 #24
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Use UI culture for strings
        string culture = MembershipContext.AuthenticatedUser.PreferredUICultureCode;

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

        // Prepare script to display versions dialog
        StringBuilder script = new StringBuilder();

        script.Append(
            @"
function ShowVersionsDialog(objectType, objectId, objectName) {
  modalDialog('", ResolveUrl("~/CMSModules/Objects/Dialogs/ObjectVersionDialog.aspx"), @"' + '?objecttype=' + objectType + '&objectid=' + objectId + '&objectname=' + objectName,'VersionsDialog','800','600');
}"
            );

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

        // Check if template is ASPX one and initialize PageTemplateInfo variable
        bool isAspx = false;

        PageTemplateInfo pti = null;

        if (mPagePlaceholder != null)
        {
            pi = mPagePlaceholder.PageInfo;
        }

        if (pi != null)
        {
            pti = pi.UsedPageTemplateInfo;
            if (pti != null)
            {
                isAspx = pti.IsAspx;
            }
        }

        bool documentExists = ((pi != null) && (pi.DocumentID > 0));

        if ((mPagePlaceholder != null) && (mPagePlaceholder.ViewMode == ViewModeEnum.DesignDisabled))
        {
            // Hide edit layout and edit template if design mode is disabled
            iLayout.Visible   = false;
            iTemplate.Visible = false;
        }
        else
        {
            if ((mPagePlaceholder != null) && (mPagePlaceholder.LayoutTemplate == null))
            {
                // Edit layout
                iLayout.Text = ResHelper.GetString("PlaceholderMenu.IconLayout", culture);
                iLayout.Attributes.Add("onclick", "EditLayout();");

                if ((pti != null) && (pti.LayoutID > 0))
                {
                    LayoutInfo li = LayoutInfoProvider.GetLayoutInfo(pti.LayoutID);

                    // Display layout versions sub-menu
                    if ((li != null) && ObjectVersionManager.DisplayVersionsTab(li))
                    {
                        menuLayout.Visible           = true;
                        iLayout.Text                 = ResHelper.GetString("PlaceholderMenu.IconLayoutMore", culture);
                        lblSharedLayoutVersions.Text = ResHelper.GetString("PlaceholderMenu.SharedLayoutVersions", culture);
                        pnlSharedLayout.Attributes.Add("onclick", GetVersionsDialog(li.TypeInfo.ObjectType, li.LayoutId));
                    }
                }
            }
            else
            {
                iLayout.Visible = false;
            }

            if (documentExists)
            {
                // Template properties
                iTemplate.Text = ResHelper.GetString("PlaceholderMenu.IconTemplate", culture);

                int    templateID = (pti != null) ? pti.PageTemplateId : 0;
                String aliasPath  = (pi != null) ? pi.NodeAliasPath : "";

                String url = ApplicationUrlHelper.GetElementDialogUrl("cms.design", "PageTemplate.EditPageTemplate", templateID, String.Format("aliaspath={0}", aliasPath));
                iTemplate.Attributes.Add("onclick", String.Format("modalDialog('{0}', 'edittemplate', '95%', '95%');", url));

                if (pti != null)
                {
                    // Display template versions sub-menu
                    if (ObjectVersionManager.DisplayVersionsTab(pti))
                    {
                        menuTemplate.Visible     = true;
                        iTemplate.Text           = ResHelper.GetString("PlaceholderMenu.IconTemplateMore", culture);
                        lblTemplateVersions.Text = ResHelper.GetString("PlaceholderMenu.TemplateVersions", culture);
                        pnlTemplateVersions.Attributes.Add("onclick", GetVersionsDialog(pti.TypeInfo.ObjectType, pti.PageTemplateId));
                    }
                }
            }
        }

        if (pti != null)
        {
            if ((!isAspx) && documentExists && pti.IsReusable)
            {
                if (!SynchronizationHelper.UseCheckinCheckout || CurrentPageInfo.UsedPageTemplateInfo.Generalized.IsCheckedOutByUser(MembershipContext.AuthenticatedUser))
                {
                    iClone.Text          = ResHelper.GetString("PlaceholderMenu.IconClone", culture);
                    iClone.OnClientClick = "CloneTemplate(GetContextMenuParameter('pagePlaceholderMenu'));";
                }
            }
            else
            {
                iSaveAsNew.Text = ResHelper.GetString("PageProperties.Save", culture);

                int templateId = pi.UsedPageTemplateInfo.PageTemplateId;
                iSaveAsNew.OnClientClick = String.Format(
                    "modalDialog('{0}?refresh=1&templateId={1}&siteid={2}', 'SaveNewTemplate', 720, 430); return false;",
                    ResolveUrl("~/CMSModules/PortalEngine/UI/Layout/SaveNewPageTemplate.aspx"),
                    templateId,
                    SiteContext.CurrentSiteID);
            }
        }

        iRefresh.Text = ResHelper.GetString("PlaceholderMenu.IconRefresh", culture);
        iRefresh.Attributes.Add("onclick", "RefreshPage();");
    }
コード例 #25
0
    /// <summary>
    /// Handles the OnAfterAction event of the ObjectManager control.
    /// </summary>
    protected void ObjectManager_OnAfterAction(object sender, SimpleObjectManagerEventArgs e)
    {
        if ((e.ActionName == ComponentEvents.SAVE) || (e.ActionName == ComponentEvents.CHECKIN))
        {
            if (EditForm.ValidateData())
            {
                LayoutInfo li = EditedObject as LayoutInfo;

                if (radShared.Checked)
                {
                    // Get the current layout type
                    PageTemplateLayoutTypeEnum layoutType = PageTemplateLayoutTypeEnum.PageTemplateLayout;
                    PageTemplateDeviceLayoutInfoProvider.GetLayoutObject(PageTemplateInfo, DeviceProfileInfo, out layoutType);

                    switch (layoutType)
                    {
                    case PageTemplateLayoutTypeEnum.PageTemplateLayout:
                    case PageTemplateLayoutTypeEnum.SharedLayout:
                    {
                        int newLayoutId = ValidationHelper.GetInteger(drpLayout.Value, 0);

                        // We need to save also page template if shared template is used
                        if ((PageTemplateInfo != null) && (PageTemplateInfo.LayoutID != li.LayoutId))
                        {
                            PageTemplateInfo.LayoutID = newLayoutId;
                            PageTemplateInfo.Update();
                        }
                    }
                    break;

                    case PageTemplateLayoutTypeEnum.DeviceSharedLayout:
                    case PageTemplateLayoutTypeEnum.DeviceLayout:
                    {
                        // We need to save also template device layout if shared template is used
                        PageTemplateDeviceLayoutInfo deviceLayout = PageTemplateDeviceLayoutInfoProvider.GetTemplateDeviceLayoutInfo(TemplateID, DeviceProfileID);
                        if (deviceLayout != null)
                        {
                            deviceLayout.LayoutID   = ValidationHelper.GetInteger(drpLayout.Value, 0);
                            deviceLayout.LayoutCode = null;
                            deviceLayout.LayoutCSS  = null;
                            deviceLayout.Update();
                        }
                    }
                    break;

                    default:
                        break;
                    }
                }

                // Register refresh script
                string refreshScript = ScriptHelper.GetScript("if ((wopener != null) && (wopener.RefreshPage != null)) {wopener.RefreshPage();}");
                ScriptHelper.RegisterClientScriptBlock(Page, typeof(String), "pageTemplateRefreshScript", refreshScript);

                // Register preview refresh
                RegisterRefreshScript();

                // Close if required
                if (ValidationHelper.GetBoolean(hdnClose.Value, false))
                {
                    ScriptHelper.RegisterStartupScript(Page, typeof(string), "CloseDialogPreviewScript", ScriptHelper.GetScript("CloseDialog();"));
                }

                // Load actual layout info (it was edited during saving by LayoutInfoProvider)
                if (li != null)
                {
                    actualLayoutInfo = LayoutInfoProvider.GetLayoutInfo(li.LayoutId);
                }
            }

            // Hide warning after save
            MessagesPlaceHolder.WarningText = "";
        }
        else if (e.ActionName == ComponentEvents.UNDO_CHECKOUT)
        {
            if (AllowTypeSwitching)
            {
                var url = RequestContext.CurrentURL;
                url = URLHelper.RemoveParameterFromUrl(url, "newshared");
                url = URLHelper.RemoveParameterFromUrl(url, "oldshared");
                url = URLHelper.AddParameterToUrl(url, "wopenerrefresh", "1");
                Response.Redirect(url);
            }
        }
        else if (e.ActionName == ComponentEvents.CHECKOUT)
        {
            DisplayMessage(true);
        }

        switch (e.ActionName)
        {
        case ComponentEvents.SAVE:
        case ComponentEvents.CHECKOUT:
        case ComponentEvents.CHECKIN:
        case ComponentEvents.UNDO_CHECKOUT:
            if (DialogMode)
            {
                RegisterWOpenerRefreshScript();
            }
            else if (dialog)
            {
                ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), "parentWOpenerRefresh", ScriptHelper.GetScript("if (parent && parent.wopener && parent.wopener.refresh) { parent.wopener.refresh(); }"));
            }
            break;
        }

        if (!AllowTypeSwitching && (EditedObjectType == EditedObjectTypeEnum.Layout) && (e.ActionName != ComponentEvents.CHECKOUT) && !DialogMode)
        {
            ScriptHelper.RefreshTabHeader(Page, EditForm.EditedObject.Generalized.ObjectDisplayName);
        }

        // No save for checkout
        if (e.ActionName != ComponentEvents.CHECKOUT)
        {
            ShowChangesSaved();
        }
    }
コード例 #26
0
    /// <summary>
    /// Gets the edited object.
    /// </summary>
    private object GetEditedObject()
    {
        object editedObject = null;

        if (PageTemplate != null)
        {
            DeviceProfileInfo profileInfo = DeviceProfile;
            int newSharedLayoutId         = QueryHelper.GetInteger("newshared", -1);
            int oldSharedLayoutId         = QueryHelper.GetInteger("oldshared", -1);

            // Check modify shared templates permission
            if (PageTemplate.IsReusable && !MembershipContext.AuthenticatedUser.IsAuthorizedPerUIElement("CMS.Design", "Design.ModifySharedTemplates"))
            {
                RedirectToUIElementAccessDenied("CMS.Design", "Design.ModifySharedTemplates");
            }

            // Default state - no radio buttons used
            if ((newSharedLayoutId == -1) && (oldSharedLayoutId == -1))
            {
                editedObject = PageTemplateDeviceLayoutInfoProvider.GetLayoutObject(PageTemplate, profileInfo);
            }
            else
            {
                // If new shared layout is set, than it should be used as edited object
                // This happens when switched from custom to a shared layout
                if (newSharedLayoutId > 0)
                {
                    // Standard page layout
                    editedObject = LayoutInfoProvider.GetLayoutInfo(newSharedLayoutId);
                }
                else if (newSharedLayoutId == 0)
                {
                    // This means user switched from shared layout to custom
                    // Data has to be copied to PageTemplateInfo
                    if (profileInfo != null)
                    {
                        // Get the current device layout if exists
                        PageTemplateDeviceLayoutInfo deviceLayout = PageTemplateDeviceLayoutInfoProvider.GetTemplateDeviceLayoutInfo(PageTemplate.PageTemplateId, profileInfo.ProfileID);
                        if (deviceLayout != null)
                        {
                            // Custom device layout (use old layout)
                            editedObject = PageTemplateDeviceLayoutInfoProvider.CloneInfoObject(deviceLayout, oldSharedLayoutId) as PageTemplateDeviceLayoutInfo;
                        }
                    }
                    else
                    {
                        // We have to work with the clone, because we need to change the data of the object
                        // (copy from shared layout)
                        editedObject = PageTemplateDeviceLayoutInfoProvider.CloneInfoObject(PageTemplate, oldSharedLayoutId) as PageTemplateInfo;
                    }
                }
            }
        }
        // Load the layout  object
        else
        {
            var layoutId = QueryHelper.GetInteger("layoutid", 0);
            if (layoutId > 0)
            {
                editedObject = LayoutInfoProvider.GetLayoutInfo(layoutId);
            }
        }

        return(editedObject);
    }
コード例 #27
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if ((nodeId > 0) && (node != null))
        {
            LayoutTypeEnum layoutType = LayoutInfoProvider.GetLayoutTypeEnum(drpType.SelectedValue);

            // Check the permissions
            if ((layoutType != LayoutTypeEnum.Ascx) || user.IsAuthorizedPerResource("CMS.Design", "EditCode"))
            {
                // Update the layout
                if (node.DocumentPageTemplateID > 0)
                {
                    PageTemplateInfo pti = PageTemplateInfoProvider.GetPageTemplateInfo(node.DocumentPageTemplateID);
                    if (pti != null)
                    {
                        // Get shared layout
                        LayoutInfo li = LayoutInfoProvider.GetLayoutInfo(pti.LayoutID);
                        if (li != null)
                        {
                            // Update shared layout
                            li.LayoutCode = txtLayout.Text;
                            li.LayoutType = layoutType;

                            LayoutInfoProvider.SetLayoutInfo(li);
                        }
                        else if (pti.PageTemplateLayoutCheckedOutByUserID <= 0)
                        {
                            // Update custom layout
                            pti.PageTemplateLayout     = txtLayout.Text;
                            pti.PageTemplateLayoutType = layoutType;

                            PageTemplateInfoProvider.SetPageTemplateInfo(pti);
                        }
                    }
                }
            }

            // Update fields
            node.NodeBodyElementAttributes = txtBodyCss.Text;
            node.NodeDocType  = txtDocType.Text;
            node.NodeHeadTags = txtHeadTags.Value.ToString();

            // Update the node
            node.Update();

            // Update search index
            if ((node.PublishedVersionExists) && (SearchIndexInfoProvider.SearchEnabled))
            {
                SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Update, PredefinedObjectType.DOCUMENT, SearchHelper.ID_FIELD, node.GetSearchID());
            }

            // Log synchronization
            DocumentSynchronizationHelper.LogDocumentChange(node, TaskTypeEnum.UpdateDocument, tree);

            lblInfo.Visible = true;
            lblInfo.Text    = GetString("General.ChangesSaved");

            // Clear cache
            PageInfoProvider.RemoveAllPageInfosFromCache();
        }
    }
コード例 #28
0
    public void LoadData()
    {
        if (nodeId > 0)
        {
            // Get the document
            tree = new TreeProvider(user);
            node = tree.SelectSingleNode(nodeId, user.PreferredCultureCode);
            if (node != null)
            {
                PageTemplateInfo pti = PageTemplateInfoProvider.GetPageTemplateInfo(node.DocumentPageTemplateID);
                if (pti != null)
                {
                    // Get shared layout
                    LayoutInfo li = LayoutInfoProvider.GetLayoutInfo(pti.LayoutID);
                    if (li != null)
                    {
                        // Load shared layout
                        if (!RequestHelper.IsPostBack())
                        {
                            txtLayout.Text        = li.LayoutCode;
                            drpType.SelectedIndex = (li.LayoutType == LayoutTypeEnum.Html ? 1 : 0);
                        }

                        if (li.LayoutCheckedOutByUserID > 0)
                        {
                            lblChecked.Visible = true;
                            lblChecked.Text    = "<br />" + AddSpaces(2) + GetString("MasterPage.LayoutCheckedOut");
                            if (!RequestHelper.IsPostBack())
                            {
                                txtLayout.Text     = li.LayoutCode;
                                txtLayout.ReadOnly = true;
                            }
                        }
                    }
                    else
                    {
                        // Load custom layout
                        if (!RequestHelper.IsPostBack())
                        {
                            txtLayout.Text        = ValidationHelper.GetString(pti.PageTemplateLayout, "");
                            drpType.SelectedIndex = (pti.PageTemplateLayoutType == LayoutTypeEnum.Html ? 1 : 0);
                        }

                        if (pti.PageTemplateLayoutCheckedOutByUserID > 0)
                        {
                            lblChecked.Visible = true;
                            lblChecked.Text    = "<br />" + AddSpaces(2) + GetString("MasterPage.LayoutCheckedOut");
                            if (!RequestHelper.IsPostBack())
                            {
                                txtLayout.ReadOnly = true;
                            }
                        }
                    }
                }
                else
                {
                    txtLayout.ReadOnly = true;
                }

                // Load node data
                if (!RequestHelper.IsPostBack())
                {
                    txtBodyCss.Text   = node.NodeBodyElementAttributes;
                    txtDocType.Text   = node.NodeDocType;
                    txtHeadTags.Value = node.NodeHeadTags;
                }
            }
        }

        lblAfterDocType.Text  = HighlightHTML("<html>") + "<br />" + AddSpaces(1) + HighlightHTML("<head>");
        lblAfterHeadTags.Text = AddSpaces(1) + HighlightHTML("</head>");
        lblAfterLayout.Text   = AddSpaces(1) + HighlightHTML("</body>") + "<br />" + HighlightHTML("</html>");
        lblBodyEnd.Text       = HighlightHTML(">");
        lblBodyStart.Text     = AddSpaces(1) + HighlightHTML("<body " + HttpUtility.HtmlDecode(mBody));
    }
コード例 #29
0
    /// <summary>
    /// Save button is clicked.
    /// </summary>
    protected void SaveAction(object sender, EventArgs e)
    {
        // Check permissions
        if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerUIElement("CMS.Design", "Design.EditLayout"))
        {
            RedirectToUIElementAccessDenied("CMS.Design", "Design.EditLayout");
        }

        // New device profile
        int newDeviceProfileId = deviceProfileId;

        if (newDeviceProfileId == 0)
        {
            newDeviceProfileId = ValidationHelper.GetInteger(ucNewDeviceProfile.Value, 0);
        }

        if (newDeviceProfileId == 0)
        {
            // Show error - select device profile first
            ShowError(GetString("devicelayout.selectdeviceprofile.error"));
            rbtnDevice.Checked = true;
            return;
        }

        PageTemplateInfo pti = PageTemplateInfoProvider.GetPageTemplateInfo(templateId);

        if ((pti != null) && (newDeviceProfileId > 0))
        {
            string         layoutCode = null;
            string         layoutCSS  = null;
            int            layoutId   = 0;
            LayoutTypeEnum layoutType = LayoutTypeEnum.Ascx;

            if (rbtnDevice.Checked)
            {
                // Copy from device
                int selectedDeviceProfileId = ValidationHelper.GetInteger(ucDeviceProfile.Value, 0);
                if (selectedDeviceProfileId > 0)
                {
                    // Existing device profile
                    PageTemplateDeviceLayoutInfo selectedDeviceLayout = PageTemplateDeviceLayoutInfoProvider.GetTemplateDeviceLayoutInfo(templateId, selectedDeviceProfileId);
                    if (selectedDeviceLayout != null)
                    {
                        layoutId   = selectedDeviceLayout.LayoutID;
                        layoutCode = selectedDeviceLayout.LayoutCode;
                        layoutCSS  = selectedDeviceLayout.LayoutCSS;
                        layoutType = selectedDeviceLayout.LayoutType;
                    }
                }
                else
                {
                    // Default device
                    layoutType = pti.PageTemplateLayoutType;

                    if (pti.LayoutID > 0)
                    {
                        layoutId = pti.LayoutID;
                    }
                    else
                    {
                        layoutCode = pti.PageTemplateLayout;
                        layoutCSS  = pti.PageTemplateCSS;
                    }
                }
            }
            else if (rbtnLayout.Checked)
            {
                // Use existing layout
                int        selectedLayoutId = ValidationHelper.GetInteger(ucLayout.Value, 0);
                LayoutInfo selectedLayout   = LayoutInfoProvider.GetLayoutInfo(selectedLayoutId);
                if (selectedLayout != null)
                {
                    layoutType = selectedLayout.LayoutType;

                    if (chkCopy.Checked)
                    {
                        // Copy layout code
                        layoutCode = selectedLayout.LayoutCode;
                        layoutCSS  = selectedLayout.LayoutCSS;
                    }
                    else
                    {
                        // Copy layout id
                        layoutId = selectedLayoutId;
                    }
                }
            }
            else if (rbtnEmptyLayout.Checked)
            {
                layoutCode = "<cms:CMSWebPartZone ZoneID=\"zoneA\" runat=\"server\" />";
            }

            PageTemplateDeviceLayoutInfo deviceLayout = PageTemplateDeviceLayoutInfoProvider.GetTemplateDeviceLayoutInfo(templateId, newDeviceProfileId);

            if (deviceLayout == null)
            {
                // Create a new device profile layout object
                deviceLayout = new PageTemplateDeviceLayoutInfo();
                deviceLayout.PageTemplateID = templateId;
                deviceLayout.ProfileID      = newDeviceProfileId;
            }

            // Modify the device profile layout object with updated values
            deviceLayout.LayoutID   = layoutId;
            deviceLayout.LayoutType = layoutType;
            deviceLayout.LayoutCode = layoutCode;
            deviceLayout.LayoutCSS  = layoutCSS;

            // Save the device profile layout object
            PageTemplateDeviceLayoutInfoProvider.SetTemplateDeviceLayoutInfo(deviceLayout);
            UIContext.EditedObject = deviceLayout;
            CMSObjectManager.CheckOutNewObject(Page);

            // Register refresh page scripts
            ScriptHelper.RegisterStartupScript(this, typeof(string), "deviceLayoutSaved", "if (wopener) { wopener.location.replace(wopener.location); } CloseDialog();", true);
        }
    }
コード例 #30
0
    /// <summary>
    /// Ensures the template from the selection and returns the template ID.
    /// </summary>
    /// <param name="documentName">Document name for the ad-hoc template</param>
    /// <param name="nodeGuid">Owner node GUID in case of ad-hoc template</param>
    /// <param name="errorMessage">Returns the error message</param>
    public PageTemplateInfo EnsureTemplate(string documentName, Guid nodeGuid, ref string errorMessage)
    {
        bool cloneAsAdHoc = false;
        bool masterOnly   = false;

        PageTemplateInfo templateInfo = null;

        // Template selection
        if (radUseTemplate.Checked)
        {
            // Template page
            int templateId = ValidationHelper.GetInteger(templateSelector.SelectedItem, 0);
            if (templateId > 0)
            {
                // Get the template and check if it should be cloned
                templateInfo = PageTemplateInfoProvider.GetPageTemplateInfo(templateId);
                if (templateInfo != null)
                {
                    cloneAsAdHoc = templateInfo.PageTemplateCloneAsAdHoc;
                }
            }
            else
            {
                errorMessage = GetString("NewPage.TemplateError");

                // Reload template selector to show correct subtree
                templateSelector.ResetToDefault();
            }
        }
        else if (radInherit.Checked)
        {
            // Inherited page
        }
        else if (radCreateBlank.Checked || radCreateEmpty.Checked)
        {
            // Create custom template info for the page
            templateInfo = new PageTemplateInfo();

            if (radCreateBlank.Checked)
            {
                // Blank page with layout
                int layoutId = ValidationHelper.GetInteger(layoutSelector.SelectedItem, 0);
                if (layoutId > 0)
                {
                    templateInfo.LayoutID = layoutId;

                    // Copy layout to selected template
                    if (chkLayoutPageTemplate.Checked)
                    {
                        templateInfo.LayoutID = 0;
                        LayoutInfo li = LayoutInfoProvider.GetLayoutInfo(layoutId);
                        if (li != null)
                        {
                            templateInfo.PageTemplateLayout     = li.LayoutCode;
                            templateInfo.PageTemplateLayoutType = li.LayoutType;
                        }
                        else
                        {
                            errorMessage = GetString("NewPage.LayoutError");
                        }
                    }
                }
                else
                {
                    errorMessage = GetString("NewPage.LayoutError");
                }
            }
            else if (radCreateEmpty.Checked)
            {
                // Empty template
                templateInfo.LayoutID           = 0;
                templateInfo.PageTemplateLayout = "<cms:CMSWebPartZone ZoneID=\"zoneA\" runat=\"server\" />";

                templateInfo.PageTemplateLayoutType = LayoutTypeEnum.Ascx;
            }

            if (String.IsNullOrEmpty(errorMessage))
            {
                cloneAsAdHoc = true;
                masterOnly   = true;
            }
        }

        if (cloneAsAdHoc)
        {
            // Prepare ad-hoc template name
            string displayName = "Ad-hoc: " + documentName;

            // Create ad-hoc template
            templateInfo = PageTemplateInfoProvider.CloneTemplateAsAdHoc(templateInfo, displayName, SiteContext.CurrentSiteID, nodeGuid);

            // Set inherit only master
            if (masterOnly)
            {
                templateInfo.InheritPageLevels = "\\";
            }

            PageTemplateInfoProvider.SetPageTemplateInfo(templateInfo);

            if (SiteContext.CurrentSite != null)
            {
                PageTemplateInfoProvider.AddPageTemplateToSite(templateInfo.PageTemplateId, SiteContext.CurrentSiteID);
            }

            CheckOutTemplate(templateInfo);
        }

        // Assign owner node GUID
        if ((templateInfo != null) && !templateInfo.IsReusable)
        {
            templateInfo.PageTemplateNodeGUID = nodeGuid;
        }

        // Reload the template selector in case of error
        if (!String.IsNullOrEmpty(errorMessage))
        {
            if (radUseTemplate.Checked)
            {
                templateSelector.ReloadData();
            }
        }

        return(templateInfo);
    }