/// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        if (QueryHelper.Contains("categoryid"))
        {
            categoryId = QueryHelper.GetInteger("categoryid", 0);
            PageTemplateCategoryInfo categoryInfo = PageTemplateCategoryInfoProvider.GetPageTemplateCategoryInfo(categoryId);
            if (categoryInfo != null)
            {
                currentPageTemplateCategory = categoryInfo.DisplayName;
            }
            else
            {
                // Set root category
                PageTemplateCategoryInfo rootCategory = PageTemplateCategoryInfoProvider.GetPageTemplateCategoryInfoByCodeName("/");
                if (rootCategory != null)
                {
                    currentPageTemplateCategory = rootCategory.DisplayName;
                }
            }
        }

        // If query string contains "saved" (means: new category was created) then show second tab (general)
        if (QueryHelper.Contains("saved"))
        {
            CurrentMaster.Tabs.SelectedTab = 1;
        }

        if (!RequestHelper.IsPostBack())
        {
            InitalizeMenu();
        }

        InitializeMasterPage();
    }
    public void RaisePostBackEvent(string eventArgument)
    {
        string[] values = eventArgument.Split(';');
        if ((values != null) && (values.Length == 3))
        {
            int    id       = ValidationHelper.GetInteger(values[1], 0);
            int    parentId = ValidationHelper.GetInteger(values[2], 0);
            string script   = String.Empty;

            switch (values[0])
            {
            case "pagetemplate":
                PageTemplateInfoProvider.DeletePageTemplate(id);
                break;

            case "pagetemplatecategory":
                // Recursively delete template category and all its descendants
                PageTemplateCategoryInfoProvider.DeletePageTemplateCategory(id);
                break;
            }

            // Select parent node after delete
            PageTemplateCategoryInfo ptci = PageTemplateCategoryInfoProvider.GetPageTemplateCategoryInfo(parentId);
            if (ptci != null)
            {
                script          = SelectAtferLoad(ptci.CategoryPath, parentId, "pagetemplatecategory", ptci.ParentId, true) + script;
                ltlScript.Text += ScriptHelper.GetScript(script);
            }

            treeElem.ReloadData();
        }
    }
Beispiel #3
0
    /// <summary>
    /// Creates page template. Called when the "Create template" button is pressed.
    /// </summary>
    private bool CreatePageTemplate()
    {
        // Get the page template category
        PageTemplateCategoryInfo category = PageTemplateCategoryInfoProvider.GetPageTemplateCategoryInfo("MyNewCategory");

        if (category != null)
        {
            // Create new page template object
            PageTemplateInfo newTemplate = new PageTemplateInfo();

            // Set the properties
            newTemplate.DisplayName          = "My new template";
            newTemplate.CodeName             = "MyNewTemplate";
            newTemplate.Description          = "This is page template created by API Example";
            newTemplate.PageTemplateSiteID   = CMSContext.CurrentSiteID;
            newTemplate.FileName             = " ";
            newTemplate.ShowAsMasterTemplate = false;
            newTemplate.IsPortal             = true;
            newTemplate.InheritPageLevels    = ""; // inherits all
            newTemplate.IsReusable           = true;
            newTemplate.CategoryID           = category.CategoryId;


            // Save the page template
            PageTemplateInfoProvider.SetPageTemplateInfo(newTemplate);

            return(true);
        }

        return(false);
    }
Beispiel #4
0
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        categoryId = QueryHelper.GetInteger("categoryid", 0);

        // Register script for refresh tree after delete/destroy
        string script = @"function RefreshAdditionalContent(){
                            if (parent.parent.frames['pt_tree'])
                            {
                               parent.parent.frames['pt_tree'].location.href = '" + URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_Tree.aspx?categoryid=" + categoryId) + @"';
                            }
                         }";

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

        // Configure the UniGrid
        PageTemplateCategoryInfo categoryInfo = PageTemplateCategoryInfoProvider.GetPageTemplateCategoryInfo(categoryId);

        if (categoryInfo != null)
        {
            string categoryPath = categoryInfo.CategoryPath;
            // Add the slash character at the end of the categoryPath
            if (!categoryPath.EndsWith("/"))
            {
                categoryPath += "/";
            }
            pageTemplatesGrid.WhereCondition = "ObjectPath LIKE '" + SqlHelperClass.GetSafeQueryString(categoryPath, false) + "%' AND ObjectType = 'pagetemplate'";
        }
        pageTemplatesGrid.OnAction    += pageTemplatesGrid_OnAction;
        pageTemplatesGrid.ZeroRowsText = GetString("general.nodatafound");

        InitializeMasterPage();
    }
Beispiel #5
0
    protected override void OnInit(EventArgs e)
    {
        int classId = QueryHelper.GetInteger("classId", 0);

        // Load the root category of the selector
        DataClassInfo dci = DataClassInfoProvider.GetDataClassInfo(classId);

        if (dci != null)
        {
            selTemplate.RootCategory = dci.ClassPageTemplateCategoryID;
            if (!URLHelper.IsPostback() && (dci.ClassDefaultPageTemplateID > 0))
            {
                PageTemplateInfo pageTemplate = PageTemplateInfoProvider.GetPageTemplateInfo(dci.ClassDefaultPageTemplateID);
                if ((pageTemplate != null) && PageTemplateInfoProvider.IsPageTemplateOnSite(pageTemplate.PageTemplateId, SiteContext.CurrentSiteID))
                {
                    bool setDefaultTemplate = true;

                    // If different template categories are used
                    if (pageTemplate.CategoryID != dci.ClassPageTemplateCategoryID)
                    {
                        // Get categories info
                        PageTemplateCategoryInfo templateCategory = PageTemplateCategoryInfoProvider.GetPageTemplateCategoryInfo(pageTemplate.CategoryID);
                        PageTemplateCategoryInfo rootCategory     = PageTemplateCategoryInfoProvider.GetPageTemplateCategoryInfo(dci.ClassPageTemplateCategoryID);

                        // Check if selected root category is same as one of parent page template categories or has no parent category
                        if ((rootCategory.ParentId != 0) && !templateCategory.CategoryPath.Contains("/" + rootCategory.CategoryName + "/"))
                        {
                            setDefaultTemplate = false;
                        }
                    }

                    if (setDefaultTemplate)
                    {
                        selTemplate.SetDefaultTemplate(dci.ClassDefaultPageTemplateID);
                    }
                }
            }

            // Display footer only in dialog mode
            pnlFooterContent.Visible = RequiresDialog;

            var titleText = String.Format(GetString("content.newdocument"), dci.ClassDisplayName);

            // Set dialog title
            if (RequiresDialog)
            {
                SetTitle(HTMLHelper.HTMLEncode(titleText));
            }
            else
            {
                titleElem.TitleText = HTMLHelper.HTMLEncode(titleText);
                EnsureDocumentBreadcrumbs(titleElem.Breadcrumbs, action: titleElem.TitleText);
            }
        }

        base.OnInit(e);
    }
Beispiel #6
0
    /// <summary>
    /// Deletes page template category. Called when the "Delete category" button is pressed.
    /// Expects the CreatePageTemplateCategory method to be run first.
    /// </summary>
    private bool DeletePageTemplateCategory()
    {
        // Get the page template category
        PageTemplateCategoryInfo deleteCategory = PageTemplateCategoryInfoProvider.GetPageTemplateCategoryInfo("MyNewCategory");

        // Delete the page template category
        PageTemplateCategoryInfoProvider.DeletePageTemplateCategory(deleteCategory);

        return(deleteCategory != null);
    }
Beispiel #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        SetPropertyTab(TAB_TEMPLATE);

        // Setup child controls
        inheritElem.Node = Node;

        // Keep information whether current user has modify permission
        if (node != null)
        {
            PageTemplateCategoryInfo category = PageTemplateCategoryInfoProvider.GetPageTemplateCategoryInfo("/");
            int id = (category != null) ? category.CategoryId : 0;

            hasModifyPermission     = DocumentUIHelper.CheckDocumentPermissions(node, PermissionsEnum.Modify);
            btnSelect.OnClientClick = "modalDialog('" + ResolveUrl("~/CMSModules/PortalEngine/UI/Layout/PageTemplateSelector.aspx") + "?rootcategoryid=" + id + "&documentid=" + node.DocumentID + "&nodeguid=" + node.NodeGUID + "', 'PageTemplateSelection', '90%', '85%'); return false;";
        }

        btnSelect.Text         = GetString("PageProperties.Select");
        btnClone.OnClientClick = "return confirm(" + ScriptHelper.GetLocalizedString("Template.ConfirmClone") + ");";


        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "SelectTemplate", ScriptHelper.GetScript(
                                                   @"
function RefreshPage() {
    document.location.replace(document.location);
}

function SetTemplateToHdnField(templateId) {
    document.getElementById('" + hdnSelected.ClientID + @"').value = templateId;
}

function OnSaveAsNewPageTemplate(templateId, selectorId) {
    SetTemplateToHdnField(templateId);
    RefreshPage();
}

function OnSelectPageTemplate(templateId, selectorId) {
    SetTemplateToHdnField(templateId);
    " + ClientScript.GetPostBackEventReference(btnSelect, String.Empty) + @"
}"));

        // Reflect processing action
        pnlInherits.Enabled = DocumentManager.AllowSave;

        if (!RequestHelper.IsPostBack())
        {
            LoadData();
        }

        ReloadControls();

        HandleCultureSettings();
    }
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        parentCategoryId = QueryHelper.GetInteger("parentcategoryid", 0);

        if (!RequestHelper.IsPostBack())
        {
            lblTemplateDisplayName.Text = GetString("Administration-PageTemplate_General.TemplateDisplayName");
            lblTemplateDescription.Text = GetString("Administration-PageTemplate_General.TemplateDescription");
            lblTemplateCodeName.Text    = GetString("Administration-PageTemplate_General.TemplateCodeName");
            btnOk.Text = GetString("General.OK");

            rfvTemplateDisplayName.ErrorMessage = GetString("Administration-PageTemplate_General.ErrorEmptyTemplateDisplayName");
            rfvTemplateCodeName.ErrorMessage    = GetString("Administration-PageTemplate_General.ErrorEmptyTemplateCodeName");
            txtTemplateDisplayName.Focus();
        }
        string currentPageTemplate = GetString("Administration-PageTemplate_Header.NewPageTemplate");
        // Initialize page title
        string templates = GetString("Administration-PageTemplate_Header.Templates");
        string title     = GetString("PageTemplate.NewTitle");

        string[,] pageTitleTabs = new string[3, 4];
        int i = 0;

        pageTitleTabs[i, 0] = templates;
        pageTitleTabs[i, 1] = URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/Category_Frameset.aspx");
        pageTitleTabs[i, 2] = "";
        pageTitleTabs[i, 3] = "if (parent.frames['pt_tree']) { parent.frames['pt_tree'].location.href = '" + URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_Tree.aspx") + "'; }";
        i++;

        PageTemplateCategoryInfo categoryInfo = PageTemplateCategoryInfoProvider.GetPageTemplateCategoryInfo(parentCategoryId);

        // Check if the parent category is a root category, if not => display both (root + parent)
        if ((categoryInfo != null) && (categoryInfo.ParentId != 0))
        {
            // Add a cetegory tab
            pageTitleTabs[i, 0] = HTMLHelper.HTMLEncode(categoryInfo.DisplayName);
            pageTitleTabs[i, 1] = URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/Category_Frameset.aspx") + "?categoryid=" + categoryInfo.CategoryId;
            pageTitleTabs[i, 2] = "";
            i++;
        }

        pageTitleTabs[i, 0] = HTMLHelper.HTMLEncode(currentPageTemplate);
        pageTitleTabs[i, 1] = "";
        pageTitleTabs[i, 2] = "";
        i++;

        CurrentMaster.Title.Breadcrumbs   = pageTitleTabs;
        CurrentMaster.Title.TitleText     = title;
        CurrentMaster.Title.TitleImage    = GetImageUrl("CMSModules/CMS_PageTemplates/addpagetemplate.png");
        CurrentMaster.Title.HelpTopicName = "new_page_template";
        CurrentMaster.Title.HelpName      = "helpTopic";
    }
    /// <summary>
    /// Setups action buttons on click.
    /// </summary>
    public void SetButtonsOnClick()
    {
        int id = RootCategoryID;

        if ((id == 0) && (RootCategoryName != String.Empty))
        {
            PageTemplateCategoryInfo ptci = PageTemplateCategoryInfoProvider.GetPageTemplateCategoryInfo(RootCategoryName);
            if (ptci != null)
            {
                id = ptci.CategoryId;
            }
        }

        btnSelect.OnClientClick = "return PTS_Select('" + ClientID + "', '" + id + "', '" + ShowOnlySiteTemplates + "');";
        btnClear.OnClientClick  = "PTS_Clear('" + ClientID + "');";
    }
Beispiel #10
0
    /// <summary>
    /// Gets and updates page template category. Called when the "Get and update category" button is pressed.
    /// Expects the CreatePageTemplateCategory method to be run first.
    /// </summary>
    private bool GetAndUpdatePageTemplateCategory()
    {
        // Get the page template category
        PageTemplateCategoryInfo updateCategory = PageTemplateCategoryInfoProvider.GetPageTemplateCategoryInfo("MyNewCategory");

        if (updateCategory != null)
        {
            // Update the properties
            updateCategory.DisplayName = updateCategory.DisplayName.ToLower();

            // Save the changes
            PageTemplateCategoryInfoProvider.SetPageTemplateCategoryInfo(updateCategory);

            return(true);
        }

        return(false);
    }
Beispiel #11
0
    /// <summary>
    /// Sets the root category to the control
    /// </summary>
    protected PageTemplateCategoryInfo LoadRootCategory()
    {
        PageTemplateCategoryInfo ptci = null;

        if (RootCategory > 0)
        {
            ptci = PageTemplateCategoryInfoProvider.GetPageTemplateCategoryInfo(RootCategory);
        }
        else
        {
            ptci = PageTemplateCategoryInfoProvider.GetPageTemplateCategoryInfoByCodeName("/");
        }
        if (ptci != null)
        {
            // Select and expand root node
            treeElem.RootPath = ptci.CategoryPath;
        }

        return(ptci);
    }
Beispiel #12
0
    /// <summary>
    /// Used for maxnodes in collapsed node.
    /// </summary>
    /// <param name="itemData">The item data</param>
    /// <param name="defaultNode">The default node</param>
    protected TreeNode treeElem_OnNodeCreated(DataRow itemData, TreeNode defaultNode)
    {
        if (UseMaxNodeLimit && (MaxTreeNodes > 0))
        {
            // Get parentID from data row
            int    parentID   = ValidationHelper.GetInteger(itemData["ParentID"], 0);
            string objectType = ValidationHelper.GetString(itemData["ObjectType"], String.Empty);

            // Don't use maxnodes limitation for categories
            if (objectType.ToLowerCSafe() == "pagetemplatecategory")
            {
                return(defaultNode);
            }

            // Increment index count in collapsing
            indexMaxTreeNodes++;
            if (indexMaxTreeNodes == MaxTreeNodes)
            {
                // Load parentid
                int parentParentID = 0;
                PageTemplateCategoryInfo parentParent = PageTemplateCategoryInfoProvider.GetPageTemplateCategoryInfo(parentID);
                if (parentParent != null)
                {
                    parentParentID = parentParent.ParentId;
                }

                TreeNode node = new TreeNode();
                node.Text = "<span class=\"ContentTreeItem\" onclick=\"" + SelectFunctionName + "(" + parentID + " ,'pagetemplatecategory'," + parentParentID + ",true ); return false;\"><span class=\"Name\">" + GetString("general.seelisting") + "</span></span>";
                return(node);
            }
            if (indexMaxTreeNodes > MaxTreeNodes)
            {
                return(null);
            }
        }
        return(defaultNode);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        string selectorid   = QueryHelper.GetString("selectorid", "");
        string selectedItem = QueryHelper.GetString("selectedPageTemplateId", "");

        selectElem.DocumentID = QueryHelper.GetInteger("documentid", 0);

        // If document id is not defined try get id from nodeid if is available
        if (selectElem.DocumentID <= 0)
        {
            int nodeId = QueryHelper.GetInteger("nodeid", 0);
            if (nodeId > 0)
            {
                TreeProvider tp = new TreeProvider(MembershipContext.AuthenticatedUser);
                TreeNode     tn = tp.SelectSingleNode(nodeId);
                if (tn != null)
                {
                    selectElem.DocumentID = tn.DocumentID;
                }
            }
        }
        selectElem.IsNewPage = QueryHelper.GetBoolean("isnewpage", false);

        // Proceeds the current item selection
        string javascript =
            @"
function SelectCurrentPageTemplate()
{                      
	SelectPageTemplate(selectedValue);                
}

function SelectPageTemplate(value)
{                                
	if (value != null)
	{                                                            
		if (wopener.OnSelectPageTemplate)
		{                       
			wopener.OnSelectPageTemplate(value, "             + ScriptHelper.GetString(selectorid) + @");
		}
		CloseDialog();       
	}
	else
	{
		alert("""         + GetString("PageTemplateSelection.NoPageTemplateSelected") + @""");		    
	}                
}            
"
        ;

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "PageTemplateSelector", ScriptHelper.GetScript(javascript));

        // Set name of selection function for double click
        selectElem.SelectFunction = "SelectPageTemplate";

        int rootCategoryId = QueryHelper.GetInteger("rootcategoryid", 0);

        if (rootCategoryId > 0)
        {
            selectElem.RootCategoryID = rootCategoryId;
        }

        // Preset item
        if (!RequestHelper.IsPostBack())
        {
            selectElem.SelectedItem = selectedItem;

            // Selected category
            String selCat = QueryHelper.GetString("TreeSelectedCategory", String.Empty);
            if (selCat != String.Empty)
            {
                PageTemplateCategoryInfo cat = PageTemplateCategoryInfoProvider.GetPageTemplateCategoryInfo(selCat);
                if (cat != null)
                {
                    selectElem.TreeSelectedCategory = cat.CategoryId.ToString();
                }
            }
        }

        // Set the title and icon
        Page.Title = GetString("portalengine-PageTemplateSelection.title");

        PageTitle.TitleText = Page.Title;
        CurrentMaster.PanelContent.RemoveCssClass("dialog-content");

        // Remove default css class
        if (CurrentMaster.PanelBody != null)
        {
            Panel pnl = CurrentMaster.PanelBody.FindControl("pnlContent") as Panel;
            if (pnl != null)
            {
                pnl.CssClass = String.Empty;
            }
        }

        SetSaveJavascript("SelectCurrentPageTemplate();return false;");
        SetSaveResourceString("general.select");
    }
Beispiel #14
0
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        int pageTemplateId = QueryHelper.GetInteger("templateid", 0);

        if (pageTemplateId != 0)
        {
            // Initialize page title
            string           templates = GetString("Administration-PageTemplate_Header.Templates");
            string           title     = GetString("Administration-PageTemplate_Header.TemplateProperties");
            PageTemplateInfo pti       = PageTemplateInfoProvider.GetPageTemplateInfo(pageTemplateId);

            // Check if the object exists - if not->redirect and inform the user
            EditedObject = pti;

            PageTemplateCategoryInfo categoryInfo = PageTemplateCategoryInfoProvider.GetPageTemplateCategoryInfo(pti.CategoryID);
            string currentPageTemplate            = HTMLHelper.HTMLEncode(pti.DisplayName);
            string[,] breadcrumbs;

            if (!isDialog)
            {
                breadcrumbs = new string[3, 4];

                breadcrumbs[0, 0] = GetString("development.pagetemplates");
                breadcrumbs[0, 1] = URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/Category_Frameset.aspx");
                breadcrumbs[0, 2] = "_parent";
                breadcrumbs[0, 3] = "if (parent.parent.frames['pt_tree']) { parent.parent.frames['pt_tree'].location.href = '" + URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_Tree.aspx") + "'; }";

                if (categoryInfo != null)
                {
                    breadcrumbs[1, 0] = HTMLHelper.HTMLEncode(categoryInfo.DisplayName);
                    breadcrumbs[1, 1] = URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/Category_Frameset.aspx?categoryid=" + pti.CategoryID);
                    breadcrumbs[1, 2] = "_parent";
                    breadcrumbs[1, 3] = "if (parent.parent.frames['pt_tree']) { parent.parent.frames['pt_tree'].location.href = '" + URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_Tree.aspx?categoryid=" + pti.CategoryID) + "'; }";

                    breadcrumbs[2, 0] = HTMLHelper.HTMLEncode(currentPageTemplate);
                    breadcrumbs[2, 1] = "";
                    breadcrumbs[2, 2] = "";
                }
            }
            else
            {
                breadcrumbs = new string[2, 3];

                breadcrumbs[0, 0] = GetString("development.pagetemplates");;
                breadcrumbs[0, 1] = "";
                breadcrumbs[0, 2] = "";

                breadcrumbs[1, 0] = HTMLHelper.HTMLEncode(currentPageTemplate);
                breadcrumbs[1, 1] = "";
                breadcrumbs[1, 2] = "";

                if (pti.IsReusable)
                {
                    this.CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_PageTemplates/pagetemplate.png");
                }
                else
                {
                    this.CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_PageTemplates/adhoc.png");
                }
                this.CurrentMaster.Title.TitleText = title;
            }

            this.CurrentMaster.Title.Breadcrumbs   = breadcrumbs;
            this.CurrentMaster.Title.HelpTopicName = "general_tab12";
            this.CurrentMaster.Title.HelpName      = "helpTopic";

            // Initialize menu
            int i = 0;

            string dialog = String.Empty;
            if (isDialog)
            {
                dialog = "&dialog=1";
            }

            // General tab
            SetTab(i, GetString("general.general"), URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_General.aspx?templateid=" + pageTemplateId + dialog), "SetHelpTopic('helpTopic', 'general_tab12');");
            i++;

            bool showDesign = ((pti.PageTemplateType == PageTemplateTypeEnum.Portal) || (pti.PageTemplateType == PageTemplateTypeEnum.Dashboard));

            // Design tab
            if (!isDialog && showDesign)
            {
                SetTab(i, GetString("edittabs.design"), URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_Design.aspx?templateid=" + pageTemplateId), "SetHelpTopic('helpTopic', 'design_tab2');");
                i++;
            }

            CurrentUserInfo user = CMSContext.CurrentUser;
            if (!isDialog && (pti.IsReusable) && user.UserSiteManagerAdmin)
            {
                // Sites tab
                SetTab(i, GetString("general.sites"), URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_Sites.aspx?templateid=" + pageTemplateId), "SetHelpTopic('helpTopic', 'sites_tab2');");
                i++;

                if (pti.PageTemplateType != PageTemplateTypeEnum.Dashboard)
                {
                    // Scopes tab
                    SetTab(i, GetString("pagetemplate.edit.scopes"), URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/Scopes/PageTemplateScopes_List.aspx?templateid=" + pageTemplateId), "SetHelpTopic('helpTopic', 'page_templates_scopes');");
                    i++;
                }
            }

            if (showDesign)
            {
                // Layouts tab
                SetTab(i, GetString("Administration-PageTemplate_Header.Layouts"), URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_Layouts.aspx?templateid=" + pageTemplateId + dialog), "SetHelpTopic('helpTopic', 'layout');");
                i++;

                if (pti.IsReusable && !StorageHelper.IsExternalStorage && user.UserSiteManagerAdmin)
                {
                    // Theme tab
                    SetTab(i, GetString("Stylesheet.Theme"), URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_Theme.aspx?templateid=" + pageTemplateId + dialog), "SetHelpTopic('helpTopic', 'page_templates_theme');");
                    i++;
                }

                // Web parts tab
                if ((!isDialog || SettingsKeyProvider.DevelopmentMode) && CurrentUser.IsGlobalAdministrator)
                {
                    SetTab(i, GetString("Administration-PageTemplate_Header.WebParts"), URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_WebParts.aspx?templateid=" + pageTemplateId), "SetHelpTopic('helpTopic', 'web_parts');");
                    i++;

                    if (ValidationHelper.GetBoolean(SettingsHelper.AppSettings["CMSShowTemplateASPXTab"], false))
                    {
                        // ASPX tab
                        SetTab(i, GetString("Administration-PageTemplate_Header.ASPX"), URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_ASPX.aspx?templateid=" + pageTemplateId), "SetHelpTopic('helpTopic', 'page_templates_aspx_code');");
                        i++;
                    }
                }
            }

            if (pti.PageTemplateType != PageTemplateTypeEnum.Dashboard)
            {
                // Header tab
                SetTab(i, GetString("Administration-PageTemplate_Header.Header"), URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_HeaderTab.aspx?templateid=" + pageTemplateId + dialog), "SetHelpTopic('helpTopic', 'header');");
                i++;

                // Documents tab
                SetTab(i, GetString("general.documents"), URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_Documents.aspx?templateid=" + pageTemplateId + dialog), "SetHelpTopic('helpTopic', 'page_templates_documents');");
                i++;
            }
        }
    }
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        treeElem.UseGlobalSettings = true;

        // Register scripts
        ScriptHelper.RegisterJQuery(Page);
        RegisterExportScript();

        // Images
        imgNewCategory.ImageUrl  = GetImageUrl("Objects/CMS_PageTemplateCategory/new.png");
        imgNewTemplate.ImageUrl  = GetImageUrl("CMSModules/CMS_PageTemplates/addpagetemplate.png");
        imgDeleteItem.ImageUrl   = GetImageUrl("CMSModules/CMS_PageTemplates/delete.png");
        imgExportObject.ImageUrl = GetImageUrl("CMSModules/CMS_PageTemplates/exportobject.png");

        // Resource strings
        lnkDeleteItem.Text   = GetString("Development-PageTemplates_Tree.DeleteSelectedItem");
        lnkNewCategory.Text  = GetString("Development-PageTemplates_Tree.NewCategory");
        lnkNewTemplate.Text  = GetString("Development-PageTemplates_Tree.NewTemplate");
        lnkExportObject.Text = GetString("Development-PageTemplates_Tree.ExportObject");

        // Setup menu action scripts
        lnkNewTemplate.Attributes.Add("onclick", "NewItem('pagetemplate');");
        lnkNewCategory.Attributes.Add("onclick", "NewItem('pagetemplatecategory');");
        lnkDeleteItem.Attributes.Add("onclick", "DeleteItem();");
        lnkExportObject.Attributes.Add("onclick", "ExportObject();");

        // Tooltips
        lnkDeleteItem.ToolTip   = GetString("Development-PageTemplates_Tree.DeleteSelectedItem");
        lnkNewCategory.ToolTip  = GetString("Development-PageTemplates_Tree.NewCategory");
        lnkNewTemplate.ToolTip  = GetString("Development-PageTemplates_Tree.NewTemplate");
        lnkExportObject.ToolTip = GetString("Development-PageTemplates_Tree.ExportObject");

        string script = "var doNotReloadContent = false;\n";

        // URLs for menu actions
        script += " var pageTemplateCategoryURL = '" + URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/Category_Frameset.aspx") + "';";
        script += " var pageTemplateCategoryNewURL = '" + URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_Category.aspx") + "';";
        script += " var pageTemplateURL = '" + URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_Edit.aspx") + "';";
        script += " var pageTemplateNewURL = '" + URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_New.aspx") + "';";
        script += " var pageTemplateTreeURL = '" + URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_Tree.aspx") + "';";

        // Setup tree element
        treeElem.SelectPageTemplates = true;
        treeElem.UsePostBack         = false;

        // Script for deleting widget or category
        string delPostback  = ControlsHelper.GetPostBackEventReference(Page, "##");
        string deleteScript = "function DeleteItem() { \n" +
                              " if ((selectedItemId > 0) && (selectedItemParent > 0) && " +
                              " confirm('" + GetString("general.deleteconfirmation") + "')) {\n " +
                              delPostback.Replace("'##'", "selectedItemType+';'+selectedItemId+';'+selectedItemParent") + ";\n" +
                              "}\n" +
                              "}\n";

        script += deleteScript;

        // Preselect tree item
        if (!RequestHelper.IsPostBack())
        {
            // If template was edited select this template
            pageTemplateId = QueryHelper.GetInteger("templateid", 0);
            // Category
            categoryId = QueryHelper.GetInteger("categoryid", 0);
            // Parent category
            categoryId = QueryHelper.GetInteger("parentcategoryid", categoryId);

            bool reload = QueryHelper.GetBoolean("reload", false);

            // Select category
            if (categoryId > 0)
            {
                PageTemplateCategoryInfo ptci = PageTemplateCategoryInfoProvider.GetPageTemplateCategoryInfo(categoryId);
                if (ptci != null)
                {
                    // If not set explicitly stop reloading of right frame
                    if (!reload)
                    {
                        script += "doNotReloadContent = true;";
                    }
                    script += SelectAtferLoad(ptci.CategoryPath, categoryId, "pagetemplatecategory", ptci.ParentId, true);
                }
            }
            // Select widget
            else if (pageTemplateId > 0)
            {
                PageTemplateInfo pti = PageTemplateInfoProvider.GetPageTemplateInfo(pageTemplateId);
                if (pti != null)
                {
                    PageTemplateCategoryInfo ptci = PageTemplateCategoryInfoProvider.GetPageTemplateCategoryInfo(pti.CategoryID);
                    if (ptci != null)
                    {
                        // If not set explicitly stop reloading of right frame
                        if (!reload)
                        {
                            script += "doNotReloadContent = true;";
                        }
                        string path = ptci.CategoryPath + "/" + pti.CodeName;
                        script += SelectAtferLoad(path, pageTemplateId, "pagetemplate", pti.CategoryID, pti.IsReusable);
                    }
                }
            }
            // Select root by default
            else
            {
                PageTemplateCategoryInfo ptci = PageTemplateCategoryInfoProvider.GetPageTemplateCategoryInfoByCodeName("/");
                if (ptci != null)
                {
                    script += SelectAtferLoad("/", ptci.CategoryId, "pagetemplatecategory", 0, true);
                }
            }
        }

        ltlScript.Text += ScriptHelper.GetScript(script);

        // Special browser class for RTL scrollbars correction
        pnlSubBox.CssClass = BrowserHelper.GetBrowserClass();
    }
    /// <summary>
    /// Saves data of edited workflow scope from TextBoxes into DB.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        // Check whether required fields are not empty
        string displayName = txtCategoryDisplayName.Text.Trim();
        string codeName    = txtCategoryName.Text.Trim();
        string imagePath   = txtCategoryImagePath.Text.Trim();

        string result = new Validator().NotEmpty(displayName, GetString("General.RequiresDisplayName")).NotEmpty(codeName, GetString("General.RequiresCodeName")).Result;

        // Validate the codename
        if (parentCategoryId != 0)
        {
            if (!ValidationHelper.IsCodeName(codeName))
            {
                result = GetString("General.ErrorCodeNameInIdentificatorFormat");
            }
        }

        // Check codename uniqness
        if ((templateCategoryId == 0) && (PageTemplateCategoryInfoProvider.GetPageTemplateCategoryInfoByCodeName(codeName) != null))
        {
            result = GetString("General.CodeNameExists");
        }

        if (result == "")
        {
            if (templateCategoryId > 0)
            {
                PageTemplateCategoryInfo ptci = PageTemplateCategoryInfoProvider.GetPageTemplateCategoryInfo(templateCategoryId);
                if (ptci != null)
                {
                    ptci.DisplayName       = displayName;
                    ptci.CategoryName      = codeName;
                    ptci.CategoryImagePath = imagePath;
                    PageTemplateCategoryInfoProvider.SetPageTemplateCategoryInfo(ptci);
                    lblInfo.Visible        = true;
                    lblInfo.ResourceString = "General.ChangesSaved";

                    // Reload tree
                    string script = "parent.parent.frames['pt_tree'].location.href = '" + URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_Tree.aspx?categoryid=" + templateCategoryId) + "';";
                    script         += "parent.frames['categoryHeader'].location.href = '" + URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/Category_Header.aspx?categoryid=" + templateCategoryId + "&saved=1") + "';";
                    ltlScript.Text += ScriptHelper.GetScript(script);
                }
            }
            else
            {
                PageTemplateCategoryInfo ptci = new PageTemplateCategoryInfo();
                ptci.DisplayName       = displayName;
                ptci.CategoryName      = codeName;
                ptci.CategoryImagePath = imagePath;
                ptci.ParentId          = parentCategoryId;
                try
                {
                    PageTemplateCategoryInfoProvider.SetPageTemplateCategoryInfo(ptci);
                    string script = "parent.frames['pt_tree'].location.href = '" + URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_Tree.aspx?categoryid=" + ptci.CategoryId) + "';";
                    script         += "this.location.href = '" + URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/Category_Frameset.aspx?categoryid=" + ptci.CategoryId) + "';";
                    ltlScript.Text += ScriptHelper.GetScript(script);
                }
                catch (Exception ex)
                {
                    lblError.Text    = ex.Message;
                    lblError.Visible = true;
                }
            }
        }
        else
        {
            lblError.Visible = true;
            lblError.Text    = result;
        }
    }
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        if (PageTemplate != null)
        {
            // Initialize page title
            string title = GetString("Administration-PageTemplate_Header.TemplateProperties");

            // Check if the object exists - if not->redirect and inform the user
            EditedObject = PageTemplate;

            PageTemplateCategoryInfo categoryInfo = PageTemplateCategoryInfoProvider.GetPageTemplateCategoryInfo(PageTemplate.CategoryID);
            string currentPageTemplate            = HTMLHelper.HTMLEncode(PageTemplate.DisplayName);
            string[,] breadcrumbs;

            if (!isDialog)
            {
                breadcrumbs = new string[3, 4];

                breadcrumbs[0, 0] = GetString("development.pagetemplates");
                breadcrumbs[0, 1] = URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/Category_Frameset.aspx");
                breadcrumbs[0, 2] = "_parent";
                breadcrumbs[0, 3] = "if (parent.parent.frames['pt_tree']) { parent.parent.frames['pt_tree'].location.href = '" + URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_Tree.aspx") + "'; }";

                if (categoryInfo != null)
                {
                    breadcrumbs[1, 0] = HTMLHelper.HTMLEncode(categoryInfo.DisplayName);
                    breadcrumbs[1, 1] = URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/Category_Frameset.aspx?categoryid=" + PageTemplate.CategoryID);
                    breadcrumbs[1, 2] = "_parent";
                    breadcrumbs[1, 3] = "if (parent.parent.frames['pt_tree']) { parent.parent.frames['pt_tree'].location.href = '" + URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_Tree.aspx?categoryid=" + PageTemplate.CategoryID) + "'; }";

                    breadcrumbs[2, 0] = HTMLHelper.HTMLEncode(currentPageTemplate);
                    breadcrumbs[2, 1] = "";
                    breadcrumbs[2, 2] = "";
                }
            }
            else
            {
                breadcrumbs = new string[2, 3];

                breadcrumbs[0, 0] = GetString("development.pagetemplates");
                breadcrumbs[0, 1] = "";
                breadcrumbs[0, 2] = "";

                breadcrumbs[1, 0] = HTMLHelper.HTMLEncode(currentPageTemplate);
                breadcrumbs[1, 1] = "";
                breadcrumbs[1, 2] = "";

                if (PageTemplate.IsReusable)
                {
                    CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_PageTemplates/pagetemplate.png");
                }
                else
                {
                    CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_PageTemplates/adhoc.png");
                }
                CurrentMaster.Title.TitleText = title;
            }

            CurrentMaster.Title.Breadcrumbs   = breadcrumbs;
            CurrentMaster.Title.HelpTopicName = "general_tab12";
            CurrentMaster.Title.HelpName      = "helpTopic";

            // Initialize menu
            int    i = 0;
            string defaultDeviceProfileQuery = "&devicename=default&ObjectLifeTime=request";

            string dialog = String.Empty;
            if (isDialog)
            {
                dialog = "&dialog=1";
            }

            // General tab
            SetTab(i, GetString("general.general"), URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_General.aspx?templateid=" + PageTemplateID + dialog), "SetHelpTopic('helpTopic', 'general_tab12');");
            i++;

            bool showDesign = ((PageTemplate.PageTemplateType == PageTemplateTypeEnum.Portal) || (PageTemplate.PageTemplateType == PageTemplateTypeEnum.Dashboard));

            // Design tab
            if (!isDialog && showDesign)
            {
                SetTab(i, GetString("edittabs.design"), URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_Design.aspx?templateid=" + PageTemplateID + defaultDeviceProfileQuery), "SetHelpTopic('helpTopic', 'design_tab2');");
                i++;
            }

            if (showDesign)
            {
                string aliasPath = QueryHelper.GetString("aliaspath", string.Empty);
                string query     = string.IsNullOrEmpty(aliasPath) ? "" : "&aliasPath=" + aliasPath;
                query += defaultDeviceProfileQuery;

                // Layouts tab
                SetTab(i, GetString("Administration-PageTemplate_Header.Layouts"), URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageLayouts/PageLayout_Edit.aspx?allowswitch=1&templateid=" + PageTemplateID + dialog + query), "SetHelpTopic('helpTopic', 'layout');");
                i++;

                // Show the Device layouts tab
                bool deviceProfilesEnabled = DeviceProfileInfoProvider.IsDeviceProfilesEnabled(CMSContext.CurrentSiteName);
                if (deviceProfilesEnabled && (PageTemplate.PageTemplateType == PageTemplateTypeEnum.Portal))
                {
                    // Device layouts tab
                    SetTab(i, "Device layouts", URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_DeviceLayouts.aspx?templateid=" + PageTemplateID + dialog + query), "SetHelpTopic('helpTopic', 'device_layouts');");
                    i++;
                }
            }

            CurrentUserInfo user = CMSContext.CurrentUser;
            if (!isDialog && (PageTemplate.IsReusable) && user.UserSiteManagerAdmin)
            {
                // Sites tab
                SetTab(i, GetString("general.sites"), URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_Sites.aspx?templateid=" + PageTemplateID), "SetHelpTopic('helpTopic', 'sites_tab2');");
                i++;

                if (PageTemplate.PageTemplateType != PageTemplateTypeEnum.Dashboard)
                {
                    // Scopes tab
                    SetTab(i, GetString("pagetemplate.edit.scopes"), URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/Scopes/PageTemplateScopes_List.aspx?templateid=" + PageTemplateID), "SetHelpTopic('helpTopic', 'page_templates_scopes');");
                    i++;
                }
            }

            if (showDesign && PageTemplate.IsReusable && !StorageHelper.IsExternalStorage(PageTemplate.GetThemePath()) && user.UserSiteManagerAdmin)
            {
                // Theme tab
                SetTab(i, GetString("Stylesheet.Theme"), URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_Theme.aspx?templateid=" + PageTemplateID + dialog), "SetHelpTopic('helpTopic', 'page_templates_theme');");
                i++;
            }

            // Show web part tab
            if (showDesign || (PageTemplate.PageTemplateType == PageTemplateTypeEnum.AspxPortal))
            {
                // Web parts tab
                if ((!isDialog || SettingsKeyProvider.DevelopmentMode) && CurrentUser.IsGlobalAdministrator)
                {
                    SetTab(i, GetString("Administration-PageTemplate_Header.WebParts"), URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_WebParts.aspx?templateid=" + PageTemplateID + dialog), "SetHelpTopic('helpTopic', 'web_parts');");
                    i++;

                    if (ValidationHelper.GetBoolean(SettingsHelper.AppSettings["CMSShowTemplateASPXTab"], false))
                    {
                        // ASPX tab
                        SetTab(i, GetString("Administration-PageTemplate_Header.ASPX"), URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_ASPX.aspx?templateid=" + PageTemplateID), "SetHelpTopic('helpTopic', 'page_templates_aspx_code');");
                        i++;
                    }
                }
            }

            if (PageTemplate.PageTemplateType != PageTemplateTypeEnum.Dashboard)
            {
                // Header tab
                SetTab(i, GetString("Administration-PageTemplate_Header.Header"), URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_HeaderTab.aspx?templateid=" + PageTemplateID + dialog), "SetHelpTopic('helpTopic', 'header');");
                i++;

                // Documents tab
                SetTab(i, GetString("general.documents"), URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_Documents.aspx?templateid=" + PageTemplateID + dialog), "SetHelpTopic('helpTopic', 'page_templates_documents');");
                i++;
            }
        }
    }
Beispiel #18
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Select root category, don't show UI templates
        if (RootCategoryID == 0)
        {
            PageTemplateCategoryInfo ptci = PageTemplateCategoryInfoProvider.GetPageTemplateCategoryInfo("/");
            if (ptci != null)
            {
                templateSelector.RootCategoryID = ptci.CategoryId;
            }
        }

        // Check the first radio button which is visible by default
        if (!RequestHelper.IsPostBack())
        {
            if (plcRadioButtons.IsHidden || plcRadioButtonsNew.IsHidden || IsProductSection)
            {
                radInherit.Checked = true;
            }
            else
            {
                if (!plcUseTemplate.IsHidden)
                {
                    radUseTemplate.Checked = true;
                }
                else if (!plcInherit.IsHidden)
                {
                    radInherit.Checked = true;
                }
                else if (!plcCreateBlank.IsHidden)
                {
                    radCreateBlank.Checked = true;
                }
                else if (!plcCreateEmpty.IsHidden)
                {
                    radCreateEmpty.Checked = true;
                }
            }

            plcRadioButtons.Visible = !plcRadioButtons.IsHidden && !(plcUseTemplate.IsHidden && plcInherit.IsHidden && plcCreateBlank.IsHidden && plcCreateEmpty.IsHidden);

            if (!SomeOptionAvailable)
            {
                RedirectToUINotAvailable();
            }
        }

        // Check authorization per resource
        if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("CMS.Design", "Design"))
        {
            radCreateBlank.Visible = false;
            radCreateEmpty.Visible = false;
            layoutSelector.Visible = false;

            if (plcUseTemplate.IsHidden && plcInherit.IsHidden && !plcCreateBlank.IsHidden)
            {
                RedirectToAccessDenied("CMS.Design", "Design");
            }
        }

        if (IsProductSection)
        {
            radCreateBlank.Visible = false;
            radCreateEmpty.Visible = false;
            radUseTemplate.Visible = false;

            radInherit.Enabled = false;
        }

        radUseTemplate.CheckedChanged += radOptions_CheckedChanged;
        radInherit.CheckedChanged     += radOptions_CheckedChanged;
        radCreateBlank.CheckedChanged += radOptions_CheckedChanged;
        radCreateEmpty.CheckedChanged += radOptions_CheckedChanged;

        // Disable startup focus functionality
        templateSelector.UseStartUpFocus = false;

        LoadControls();
    }
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        lblCategoryDisplayName.Text = GetString("Development-PageTemplate_Category.DisplayName");
        lblCategoryName.Text        = GetString("Development-PageTemplate_Category.Name");
        btnOk.Text = GetString("General.OK");
        rfvCategoryDisplayName.ErrorMessage = GetString("General.RequiresDisplayName");
        rfvCategoryName.ErrorMessage        = GetString("General.RequiresCodeName");

        this.CurrentMaster.Title.TitleText     = GetString("development-pagetemplate_category.title");
        this.CurrentMaster.Title.TitleImage    = GetImageUrl("Objects/CMS_PageTemplateCategory/new.png");
        this.CurrentMaster.Title.HelpTopicName = "new_category";
        this.CurrentMaster.Title.HelpName      = "helpTopic";

        string templateCategoryDisplayName = "";
        string templateCategoryName        = "";
        string currentTemplateCategoryName = GetString("Development-PageTemplate_Category.Title");
        string categoryImagePath           = "";

        templateCategoryId = QueryHelper.GetInteger("categoryid", 0);
        parentCategoryId   = QueryHelper.GetInteger("parentcategoryid", 0);

        if (templateCategoryId > 0)
        {
            // Existing category

            // Hide breadcrumbs and title
            this.CurrentMaster.Title.TitleText   = "";
            this.CurrentMaster.Title.Breadcrumbs = null;
            PageTemplateCategoryInfo ptci = PageTemplateCategoryInfoProvider.GetPageTemplateCategoryInfo(templateCategoryId);
            if (ptci != null)
            {
                templateCategoryDisplayName = ptci.DisplayName;
                templateCategoryName        = ptci.CategoryName;
                currentTemplateCategoryName = ptci.CategoryName;
                categoryImagePath           = ptci.CategoryImagePath;
                parentCategoryId            = ptci.ParentId;

                // If it's root category hide category name textbox
                if ((parentCategoryId == 0) || (ptci.CategoryName == "AdHoc"))
                {
                    plcCategoryName.Visible = false;
                }
            }
        }
        else
        {
            // New category
            this.CurrentMaster.Title.HelpName      = "helpTopic";
            this.CurrentMaster.Title.HelpTopicName = "page_template_category_general";

            // Load parent category name
            PageTemplateCategoryInfo parentCategoryInfo = PageTemplateCategoryInfoProvider.GetPageTemplateCategoryInfo(parentCategoryId);
            string parentCategoryName = GetString("development.pagetemplates");
            if (parentCategoryInfo != null)
            {
                parentCategoryName = parentCategoryInfo.DisplayName;
            }

            // initializes breadcrumbs
            string[,] tabs = new string[3, 4];

            tabs[0, 0] = GetString("development.pagetemplates");
            tabs[0, 1] = URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/Category_Frameset.aspx");
            tabs[0, 2] = "";
            tabs[0, 3] = "if (parent.frames['pt_tree']) { parent.frames['pt_tree'].location.href = '" + URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_Tree.aspx") + "'; }";

            tabs[1, 0] = HTMLHelper.HTMLEncode(parentCategoryName);
            tabs[1, 1] = URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/Category_Frameset.aspx?categoryid=" + parentCategoryId);
            tabs[1, 2] = "";

            tabs[2, 0] = GetString("Development-PageTemplate_Category.TitleNew");
            tabs[2, 1] = "";
            tabs[2, 2] = "";

            // set master page
            this.CurrentMaster.Title.Breadcrumbs = tabs;
            this.CurrentMaster.Title.TitleText   = currentTemplateCategoryName;
            this.CurrentMaster.Title.TitleImage  = GetImageUrl("Objects/CMS_PageTemplateCategory/new.png");
        }

        if (!RequestHelper.IsPostBack())
        {
            txtCategoryDisplayName.Text = templateCategoryDisplayName;
            txtCategoryName.Text        = templateCategoryName;
            txtCategoryImagePath.Text   = categoryImagePath;
        }
    }