private void ProcessTemplates(bool storeInDB, bool deleteFiles)
    {
        if (PageTemplateInfoProvider.StorePageTemplatesInExternalStorage == !storeInDB)
        {
            return;
        }

        if (storeInDB)
        {
            if (deleteFiles)
            {
                AddLog(string.Format(GetString("Deployment.DeletingDeployedFiles"), GetString("objecttype." + PageTemplateInfo.OBJECT_TYPE.Replace(".", "_"))));
            }

            foreach (PageTemplateInfo info in PageTemplateInfoProvider.GetTemplates())
            {
                ProcessTemplateToDB(info);
            }

            if (deleteFiles)
            {
                DeleteDir("~/CMSVirtualFiles/Templates/");
                PageTemplateInfoProvider.StorePageTemplatesInExternalStorage = false;
            }
        }
        else
        {
            PageTemplateInfoProvider.StorePageTemplatesInExternalStorage = true;

            foreach (PageTemplateInfo info in PageTemplateInfoProvider.GetTemplates())
            {
                ProcessTemplateToFS(info);
            }
        }
    }
    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();
        }
    }
    /// <summary>
    /// PreInit event handler.
    /// </summary>
    protected override void OnPreInit(EventArgs e)
    {
        base.OnPreInit(e);

        // Init the page components
        PageManager = manPortal;
        manPortal.SetMainPagePlaceholder(plc);

        int pageTemplateId = QueryHelper.GetInteger("templateid", 0);

        UIContext.EditedObject = PageTemplateInfoProvider.GetPageTemplateInfo(pageTemplateId);

        // Prepare the page info
        PageInfo pi = PageInfoProvider.GetVirtualPageInfo(pageTemplateId);

        pi.DocumentNamePath = "/" + ResHelper.GetString("edittabs.design");

        DocumentContext.CurrentPageInfo = pi;

        // Set the design mode
        PortalContext.SetRequestViewMode(ViewModeEnum.Design);
        ContextHelper.Add("DisplayContentInDesignMode", "0", true, false, false, DateTime.MinValue);

        ManagersContainer    = plcManagers;
        ScriptManagerControl = manScript;
    }
    /// <summary>
    /// PreInit event handler
    /// </summary>
    protected override void OnPreInit(EventArgs e)
    {
        base.OnPreInit(e);

        // Disable check save changes script
        DocumentManager.RegisterSaveChangesScript = false;

        // Check UI elements for web part zone
        var currentUser = MembershipContext.AuthenticatedUser;

        if (!currentUser.IsAuthorizedPerUIElement("CMS.Design", new string[] { "Design", "Design.WebPartZoneProperties" }, SiteContext.CurrentSiteName))
        {
            RedirectToUIElementAccessDenied("CMS.Design", "Design;Design.WebPartZoneProperties");
        }

        // When displaying an existing variant of a web part, get the variant mode for its original web part
        if ((variantId > 0) || (zoneVariantId > 0))
        {
            PageTemplateInfo pti = PageTemplateInfoProvider.GetPageTemplateInfo(templateId);
            if ((pti != null) && ((pti.TemplateInstance != null)))
            {
                // Get the original webpart and retrieve its variant mode
                WebPartInstance webpartInstance = pti.TemplateInstance.GetWebPart(instanceGuid, zoneVariantId, 0);
                if (webpartInstance != null)
                {
                    variantMode = webpartInstance.VariantMode;
                }
            }
        }
    }
    /// <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 templateId = ValidationHelper.GetInteger(selectedValue, 0);

            // Get the template data
            DataSet ds = PageTemplateInfoProvider.GetTemplates()
                         .WhereEquals("PageTemplateID", templateId)
                         .Columns("PageTemplateDisplayName", "PageTemplateDescription", "PageTemplateType");

            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                DataRow dr = ds.Tables[0].Rows[0];

                description = ResHelper.LocalizeString(ValidationHelper.GetString(dr["PageTemplateDescription"], ""));
            }
        }

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

        return(String.Empty);
    }
Example #6
0
    /// <summary>
    /// Ensures dashboard initialization.
    /// </summary>
    public void SetupDashboard()
    {
        // Register placeholder for context menu
        ICMSPage page = Page as ICMSPage;

        if (page != null)
        {
            page.ContextMenuContainer = plcCtx;
        }

        if (PortalPageInstance == null)
        {
            throw new Exception("[DashboardControl.SetupDashboard] Portal page instance must be set.");
        }

        // Default settings for drag and drop for dashboard
        manPortal.HighlightDropableAreas = HighlightDropableAreas;
        manPortal.ActivateZoneBorder     = ActivateZoneBorder;

        string dashboardName = QueryHelper.GetString("DashboardName", PersonalizationInfoProvider.UNDEFINEDDASHBOARD);

        // Set culture
        CultureInfo ci = CultureHelper.PreferredUICultureInfo;

        Thread.CurrentThread.CurrentCulture   = ci;
        Thread.CurrentThread.CurrentUICulture = ci;

        // Init the page components
        PortalPageInstance.PageManager = manPortal;
        manPortal.SetMainPagePlaceholder(plc);

        string templateName = QueryHelper.GetString("templatename", String.Empty);

        PageTemplateInfo pti = PageTemplateInfoProvider.GetPageTemplateInfo(templateName);

        if (pti != null)
        {
            if (pti.PageTemplateType != PageTemplateTypeEnum.Dashboard)
            {
                RedirectToAccessDenied("dashboard.invalidpagetemplate");
            }

            // Prepare virtual page info
            PageInfo pi = PageInfoProvider.GetVirtualPageInfo(pti.PageTemplateId);
            pi.DocumentNamePath = "/" + templateName;

            DocumentContext.CurrentPageInfo = pi;

            // Set the design mode
            PortalContext.SetRequestViewMode(ViewModeEnum.DashboardWidgets);
            PortalContext.DashboardName = dashboardName;

            PortalPageInstance.ManagersContainer    = plcManagers;
            PortalPageInstance.ScriptManagerControl = manScript;
        }
        else
        {
            RedirectToInformation(GetString("dashboard.notemplate"));
        }
    }
Example #7
0
    /// <summary>
    /// Retrieves the stylesheets of the page template from the database.
    /// </summary>
    /// <param name="templateName">Template name</param>
    /// <returns>The stylesheet data (plain version only)</returns>
    private static CMSOutputResource GetTemplate(string templateName)
    {
        // Try to get global one
        PageTemplateInfo templateInfo = PageTemplateInfoProvider.GetPageTemplateInfo(templateName);

        // Try to get site one (ad-hoc) if not found
        if (templateInfo == null)
        {
            templateInfo = PageTemplateInfoProvider.GetPageTemplateInfo(templateName, CMSContext.CurrentSiteID);
        }

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

        // Build the result
        CMSOutputResource resource = new CMSOutputResource()
        {
            Data         = HTMLHelper.ResolveCSSUrls(templateInfo.PageTemplateCSS, URLHelper.ApplicationPath),
            LastModified = templateInfo.PageTemplateLastModified,
            Etag         = templateInfo.PageTemplateVersionGUID
        };

        return(resource);
    }
    /// <summary>
    /// PreRender event handler
    /// </summary>
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);

        int templateId = ValidationHelper.GetInteger(hdnSelected.Value, 0);

        if (templateId > 0)
        {
            btnInherit.Enabled      = true;
            txtPageTemplate.Enabled = true;

            PageTemplateInfo pi = PageTemplateInfoProvider.GetPageTemplateInfo(templateId);
            txtPageTemplate.Text = pi.DisplayName;
        }
        else
        {
            btnInherit.Enabled      = false;
            txtPageTemplate.Enabled = false;
        }

        if (!String.IsNullOrEmpty(pageScript))
        {
            ScriptHelper.RegisterStartupScript(this, typeof(string), "Script", pageScript);
        }
    }
Example #9
0
    /// <summary>
    /// Deletes page template scope. Called when the "Delete scope" button is pressed.
    /// Expects the CreatePageTemplateScope method to be run first.
    /// </summary>
    private bool DeletePageTemplateScope()
    {
        string columns = "";

        string where = "";

        // Get template object
        PageTemplateInfo template = PageTemplateInfoProvider.GetPageTemplateInfo("MyNewTemplate");

        // If template exists
        if (template != null)
        {
            where = "PageTemplateScopeTemplateID = " + template.PageTemplateId;
        }


        DataSet scopes = PageTemplateScopeInfoProvider.GetTemplateScopes(columns, where, null, 0);

        if (!DataHelper.DataSourceIsEmpty(scopes))
        {
            // Get the page template scope
            PageTemplateScopeInfo deleteScope = new PageTemplateScopeInfo(scopes.Tables[0].Rows[0]);

            // Delete the page template scope
            PageTemplateScopeInfoProvider.DeletePageTemplateScopeInfo(deleteScope);

            return(true);
        }
        return(false);
    }
Example #10
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);
    }
Example #11
0
    public void ReloadData()
    {
        // Load the data
        DataSet templates = PageTemplateInfoProvider.GetTemplates()
                            .WhereTrue("PageTemplateIsReusable")
                            .WhereTrue("PageTemplateShowAsMasterTemplate")
                            .OrderBy("PageTemplateDisplayName")
                            .Columns("PageTemplateID", "PageTemplateDisplayName", "PageTemplateDescription", "PageTemplateThumbnailGUID", "PageTemplateIconClass");

        ucSelector.DataSource = templates;
        ucSelector.IDColumn   = "PageTemplateID";

        ucSelector.DisplayNameColumn   = "PageTemplateDisplayName";
        ucSelector.DescriptionColumn   = "PageTemplateDescription";
        ucSelector.ThumbnailGUIDColumn = "PageTemplateThumbnailGUID";
        ucSelector.IconClassColumn     = "PageTemplateIconClass";

        ucSelector.ObjectType = PageTemplateInfo.OBJECT_TYPE;
        ucSelector.DataBind();

        if (ucSelector.SelectedId == 0)
        {
            if (!DataHelper.DataSourceIsEmpty(templates))
            {
                int firstTemplateId = ValidationHelper.GetInteger(templates.Tables[0].Rows[0]["PageTemplateID"], 0);
                ucSelector.SelectedId = firstTemplateId;
            }
        }
    }
Example #12
0
    protected void DocumentManager_OnAfterAction(object sender, DocumentManagerEventArgs e)
    {
        TreeNode node = e.Node;

        int newNodeId = node.NodeID;

        if (newdocument || newculture)
        {
            // Store error text
            if (!string.IsNullOrEmpty(formElem.MessagesPlaceHolder.ErrorText))
            {
                SessionHelper.SetValue("FormErrorText|" + newNodeId, formElem.MessagesPlaceHolder.ErrorText);
            }

            var pti = PageTemplateInfoProvider.GetPageTemplateInfo(node.NodeTemplateID);
            if ((pti != null) && !pti.IsReusable)
            {
                // Update node guid and display name when new document selected template is ad-hoc
                pti.PageTemplateNodeGUID = node.NodeGUID;
                pti.DisplayName          = "Ad-hoc: " + node.DocumentName;

                PageTemplateInfoProvider.SetPageTemplateInfo(pti);
            }
        }
        else
        {
            // Reload the values in the form
            formElem.LoadControlValues();
        }
    }
Example #13
0
    protected void Page_Load(object sender, EventArgs e)
    {
        pageTemplateId = QueryHelper.GetInteger("templateid", 0);
        if (pageTemplateId > 0)
        {
            pt = PageTemplateInfoProvider.GetPageTemplateInfo(pageTemplateId);
        }

        categorySelector.StartingPath = QueryHelper.GetString("startingpath", String.Empty);

        // Check the authorization per UI element
        var currentUser = MembershipContext.AuthenticatedUser;

        if (!currentUser.IsAuthorizedPerUIElement("CMS.Content", new[] { "Properties", "Properties.Template", "Template.SaveAsNew" }, SiteContext.CurrentSiteName))
        {
            RedirectToUIElementAccessDenied("CMS.Content", "Properties;Properties.Template;Template.SaveAsNew");
        }

        PageTitle.TitleText = GetString("PortalEngine.SaveNewPageTemplate.PageTitle");

        // Set category selector
        if (!RequestHelper.IsPostBack() && (pt != null))
        {
            categorySelector.Value = pt.CategoryID.ToString();
        }
    }
Example #14
0
    /// <summary>
    /// Display info messages
    /// </summary>
    /// <param name="forceDisplay">If true, message is displayed even on postback</param>
    private void DisplayMessage(bool forceDisplay)
    {
        bool showMessage = editMenuElem.ObjectManager.IsObjectChecked() && (!RequestHelper.IsPostBack() || forceDisplay);

        // Display shared template warning
        switch (EditedObjectType)
        {
        case EditedObjectTypeEnum.Template:
        {
            if (showMessage)
            {
                PageTemplateInfo pti = EditFormTemplate.EditedObject as PageTemplateInfo;
                ShowSharedTemplateWarningMessage(pti);
                codeElem.ShowMessage();
            }
        }
        break;

        case EditedObjectTypeEnum.Layout:
        {
            LayoutInfo layoutInfo = EditFormLayout.EditedObject as LayoutInfo;
            if (showMessage)
            {
                if (DialogMode && ShowSharedLayoutWarnings && (layoutInfo != null))
                {
                    ShowInformation(string.Format(GetString("layout.sharedwarning"), layoutInfo.LayoutDisplayName));
                }
                codeLayoutElem.ShowMessage();
            }
        }
        break;

        case EditedObjectTypeEnum.DeviceLayout:
        {
            PageTemplateDeviceLayoutInfo deviceLayout = EditFormDeviceLayout.EditedObject as PageTemplateDeviceLayoutInfo;
            if (showMessage)
            {
                if (deviceLayout != null)
                {
                    if (DialogMode && (deviceLayout.LayoutID > 0))
                    {
                        ShowInformation(GetString("layout.sharedwarning"));
                    }
                    else
                    {
                        PageTemplateInfo pti = PageTemplateInfoProvider.GetPageTemplateInfo(deviceLayout.PageTemplateID);
                        ShowSharedTemplateWarningMessage(pti);
                    }
                }
                deviceCode.ShowMessage();
            }
        }
        break;
        }

        if (!RequestHelper.IsPostBack() && DialogMode)
        {
            SetDeviceWarning();
        }
    }
Example #15
0
    /// <summary>
    /// Clones template as adhoc from original node.
    /// </summary>
    /// <param name="newNode">New node which will use new adhoc template</param>
    private void CloneTemplateAsAdHoc(TreeNode newNode)
    {
        PageInfo originalPage = PageInfoProvider.GetPageInfo(mNode.NodeSiteName, mNode.NodeAliasPath, mNode.DocumentCulture, null, mNode.NodeID, false);

        if (originalPage == null)
        {
            return;
        }

        PageTemplateInfo originalTemplate = originalPage.UsedPageTemplateInfo;

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

            if (newNode.NodeTemplateForAllCultures)
            {
                newNode.NodeTemplateID = adHocTemplate.PageTemplateId;
            }
            else
            {
                newNode.DocumentPageTemplateID = adHocTemplate.PageTemplateId;
            }
            newNode.NodeInheritPageTemplate = false;
        }
    }
    void EditForm_OnAfterSave(object sender, EventArgs e)
    {
        elementInfo = (UIElementInfo)EditForm.EditedObject;

        if (refreshTree)
        {
            RefreshTree();
        }

        // When template was changed, delete all adhoc templates assigned to current UI element (if adhoc template is not assigned).
        bool templateChanged = ValidationHelper.GetBoolean(EditForm.FieldControls["ElementPageTemplateID"].GetValue("TemplateChanged"), false);

        if (templateChanged)
        {
            bool delete = true;
            if (elementInfo.ElementType == UIElementTypeEnum.PageTemplate)
            {
                PageTemplateInfo pti = PageTemplateInfoProvider.GetPageTemplateInfo(elementInfo.ElementPageTemplateID);

                // Ad hoc template is assigned, do not delete
                if ((pti != null) && !pti.IsReusable)
                {
                    delete = false;
                }
            }

            if (delete)
            {
                PageTemplateInfoProvider.DeleteAdHocTemplates(elementInfo.ElementGUID);
            }
        }
    }
Example #17
0
    /// <summary>
    /// Gets and bulk updates page templates. Called when the "Get and bulk update templates" button is pressed.
    /// Expects the CreatePageTemplate method to be run first.
    /// </summary>
    private bool GetAndBulkUpdatePageTemplates()
    {
        // Prepare the parameters
        string where = "PageTemplateCodeName LIKE N'MyNewTemplate%'";

        // Get the data
        DataSet templates = PageTemplateInfoProvider.GetTemplates(where, null);

        if (!DataHelper.DataSourceIsEmpty(templates))
        {
            // Loop through the individual items
            foreach (DataRow templateDr in templates.Tables[0].Rows)
            {
                // Create object from DataRow
                PageTemplateInfo modifyTemplate = new PageTemplateInfo(templateDr);

                // Update the properties
                modifyTemplate.DisplayName = modifyTemplate.DisplayName.ToUpper();

                // Save the changes
                PageTemplateInfoProvider.SetPageTemplateInfo(modifyTemplate);
            }

            return(true);
        }

        return(false);
    }
Example #18
0
    /// <summary>
    /// Creates page template scope. Called when the "Create scope" button is pressed.
    /// </summary>
    private bool CreatePageTemplateScope()
    {
        // Get template object
        PageTemplateInfo template = PageTemplateInfoProvider.GetPageTemplateInfo("MyNewTemplate");

        // If template exists
        if (template != null)
        {
            // Page template isn't from all pages
            template.PageTemplateForAllPages = false;

            // Create new template scope
            PageTemplateScopeInfo newScope = new PageTemplateScopeInfo();

            // Set some properties
            newScope.PageTemplateScopeTemplateID = template.PageTemplateId;
            newScope.PageTemplateScopeSiteID     = CMSContext.CurrentSiteID;
            newScope.PageTemplateScopePath       = "/";
            newScope.PageTemplateScopeLevels     = "/{0}/{1}";

            // Save scope to database
            PageTemplateScopeInfoProvider.SetPageTemplateScopeInfo(newScope);

            // Update page template
            PageTemplateInfoProvider.SetPageTemplateInfo(template);

            return(true);
        }

        return(false);
    }
        private static void SetPageTemplate(TreeNode node, string templateName)
        {
            var pageTemplateInfo = PageTemplateInfoProvider.GetPageTemplateInfo(templateName);

            node.DocumentPageTemplateID     = pageTemplateInfo?.PageTemplateId ?? 0;
            node.NodeTemplateForAllCultures = true;
        }
Example #20
0
    /// <summary>
    /// Clone button event handler
    /// </summary>
    protected void btnClone_Click(object sender, EventArgs e)
    {
        if ((pti != null) && hasModifyPermission)
        {
            TreeNode node = Node;

            // Clone the info
            string docName     = node.GetDocumentName();
            string displayName = "Ad-hoc: " + docName;

            PageTemplateInfo newInfo = PageTemplateInfoProvider.CloneTemplateAsAdHoc(pti, displayName, SiteContext.CurrentSiteID, node.NodeGUID);

            newInfo.Description = String.Format(GetString("PageTemplate.AdHocDescription"), Node.DocumentNamePath);
            PageTemplateInfoProvider.SetPageTemplateInfo(newInfo);

            // Assign the selected template for all cultures and save
            SelectedTemplateID = newInfo.PageTemplateId;

            if (radInherit.Checked)
            {
                radAllCultures.Checked = true;
                radInherit.Checked     = false;
            }

            DocumentManager.SaveDocument();
        }
    }
    /// <summary>
    /// Handle btnOK's OnClick event.
    /// </summary>
    protected void ObjectManager_OnSaveData(object sender, SimpleObjectManagerEventArgs e)
    {
        string errorMessage = "";

        // Get PageTemplateInfo.
        pti = PageTemplateInfoProvider.GetPageTemplateInfo(templateId);
        if (pti != null)
        {
            // Update WebParts configuration in PageTemplate.
            try
            {
                pti.WebParts = txtWebParts.Text;
                PageTemplateInfoProvider.SetPageTemplateInfo(pti);
                ShowChangesSaved();

                // Update textbox value
                txtWebParts.Text = HTMLHelper.ReformatHTML(pti.WebParts, "  ");
            }
            catch (UnauthorizedAccessException ex)
            {
                errorMessage = ResHelper.GetStringFormat("general.sourcecontrolerror", ex.Message);
            }
            catch (Exception ex)
            {
                errorMessage = ex.Message;
            }

            // Show error message
            if (!String.IsNullOrEmpty(errorMessage))
            {
                ShowError(errorMessage);
            }
        }
    }
Example #22
0
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        user = CMSContext.CurrentUser;

        // Get the template
        templateId = QueryHelper.GetInteger("templateid", 0);
        pti        = PageTemplateInfoProvider.GetPageTemplateInfo(templateId);

        radCustom.Text    = GetString("TemplateLayout.Custom");
        radShared.Text    = GetString("TemplateLayout.Shared");
        lblType.Text      = GetString("PageLayout.Type");
        lbLayoutCode.Text = GetString("Administration-PageLayout_New.LayoutCode");

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

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

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

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

        InitializeHeaderActions();
    }
Example #23
0
    /// <summary>
    /// Handle btnOK's OnClick event.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        string errorMessage = "";

        // Get PageTemplateInfo.
        PageTemplateInfo pti = PageTemplateInfoProvider.GetPageTemplateInfo(templateId);

        if (pti != null)
        {
            // Update WebParts configuration in PageTemplate.
            try
            {
                pti.WebParts = txtWebParts.Text;
                PageTemplateInfoProvider.SetPageTemplateInfo(pti);
                lblInfo.Text    = GetString("General.ChangesSaved");
                lblInfo.Visible = true;

                // Update textbox value
                txtWebParts.Text = HTMLHelper.ReformatHTML(pti.WebParts, "  ");
            }
            catch (Exception ex)
            {
                errorMessage = ex.Message;
            }

            // Show error message
            if (errorMessage != "")
            {
                lblError.Text    = errorMessage;
                lblError.Visible = true;
            }
        }
    }
Example #24
0
    /// <summary>
    /// Reloads the controls on the page to the appropriate state
    /// </summary>
    protected void ReloadControls()
    {
        TreeNode node = DocumentManager.Node;

        if (node.NodeAliasPath == "/")
        {
            // For root, inherit option means no page template
            radInherit.ResourceString = "Template.NoTemplate";
        }

        // Get the template ID
        int    templateId = SelectedTemplateID;
        string suffix     = null;
        bool   inherit    = radInherit.Checked;

        plcUIClone.Visible = false;
        plcUIEdit.Visible  = false;
        plcUISave.Visible  = false;

        if (inherit)
        {
            // Inherited
            selectorEnabled = false;

            // Inherit
            templateId = GetInheritedPageTemplateId(node);

            if (templateId > 0)
            {
                suffix = " " + GetString("Template.Inherited");
            }
        }
        else
        {
            // Standard selection
            selectorEnabled = true;
        }

        // Set modal dialogs
        btnSave.OnClientClick = "modalDialog('" + ResolveUrl("~/CMSModules/PortalEngine/UI/Layout/SaveNewPageTemplate.aspx") + "?templateId=" + templateId + "&siteid=" + CMSContext.CurrentSiteID + "', 'SaveNewTemplate', 600, 400); return false;";
        btnEditTemplateProperties.OnClientClick = "modalDialog('" + ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_Edit.aspx") + "?templateid=" + templateId + "&aliaspath=" + node.NodeAliasPath + "&dialog=1', 'TemplateSelection', 850, 680); return false;";

        // Load the page template name
        pti = PageTemplateInfoProvider.GetPageTemplateInfo(templateId);
        if (pti != null)
        {
            txtTemplate.Text = pti.DisplayName;

            plcUISave.Visible  = true;
            plcUIEdit.Visible  = (!pti.IsReusable || currentUser.IsAuthorizedPerUIElement("CMS.Content", "Template.ModifySharedTemplates"));
            plcUIClone.Visible = pti.IsReusable || inherit;
        }
        else
        {
            txtTemplate.Text = GetString("Template.SelectorNoTemplate");
        }

        txtTemplate.Text += suffix;
    }
 /// <summary>
 /// Saves webpart properties.
 /// </summary>
 public void Save()
 {
     // Update page template
     PageTemplateInfoProvider.SetPageTemplateInfo(pti);
     txtSourceId.Text          = "";
     txtSourceProperty.Text    = "";
     drpProperty.SelectedIndex = 0;
 }
 /// <summary>
 /// Updates PageTemplateForAllPages property of template info.
 /// </summary>
 private void UpdatePageTemplateInfo()
 {
     if (template != null)
     {
         template.PageTemplateForAllPages = radAllPages.Checked;
         PageTemplateInfoProvider.SetPageTemplateInfo(template);
     }
 }
    protected void DocumentManager_OnSaveData(object sender, DocumentManagerEventArgs e)
    {
        e.UpdateDocument = false;

        string errorMessage = null;
        string newPageName  = txtPageName.Text.Trim();

        if (!String.IsNullOrEmpty(newPageName))
        {
            // Limit length
            newPageName = TreePathUtils.EnsureMaxNodeNameLength(newPageName, pageClassName);
        }

        TreeNode node = e.Node;

        node.DocumentName = newPageName;

        bool updateGuidAfterInsert = false;

        // Same template for all language versions by default
        PageTemplateInfo pti = selTemplate.EnsureTemplate(node.DocumentName, node.NodeGUID, ref errorMessage);

        if (pti != null)
        {
            node.SetDefaultPageTemplateID(pti.PageTemplateId);

            // Template should by updated after document insert
            if (!pti.IsReusable)
            {
                updateGuidAfterInsert = true;
            }
        }

        // Insert node if no error
        if (String.IsNullOrEmpty(errorMessage))
        {
            // Insert the document
            // Ensures documents consistency (blog post hierarchy etc.)
            DocumentManager.EnsureDocumentsConsistency();
            DocumentHelper.InsertDocument(node, DocumentManager.ParentNode, DocumentManager.Tree);

            if (updateGuidAfterInsert)
            {
                PageTemplateInfo pageTemplateInfo = PageTemplateInfoProvider.GetPageTemplateInfo(node.NodeTemplateID);
                if (pageTemplateInfo != null)
                {
                    // Update template's node GUID
                    pageTemplateInfo.PageTemplateNodeGUID = node.NodeGUID;
                    PageTemplateInfoProvider.SetPageTemplateInfo(pageTemplateInfo);
                }
            }
        }
        else
        {
            e.IsValid      = false;
            e.ErrorMessage = errorMessage;
        }
    }
Example #28
0
    /// <summary>
    /// Ensures dashboard inicialization.
    /// </summary>
    public void SetupDashboard()
    {
        if (PortalPageInstance == null)
        {
            throw new Exception("[DashboardControl.SetupDashboard] Portal page instance must be set.");
        }

        // Default settings for drag and drop for dashboard
        manPortal.HighlightDropableAreas = HighlightDropableAreas;
        manPortal.ActivateZoneBorder     = ActivateZoneBorder;

        string dashboardName = QueryHelper.GetString("DashboardName", PersonalizationInfoProvider.UNDEFINEDDASHBOARD);

        // Set culture
        CultureInfo ci = CultureHelper.PreferredUICultureInfo;

        Thread.CurrentThread.CurrentCulture   = ci;
        Thread.CurrentThread.CurrentUICulture = ci;

        // Init the page components
        PortalPageInstance.PageManager = manPortal;
        manPortal.SetMainPagePlaceholder(plc);

        string templateName = QueryHelper.GetString("templatename", String.Empty);

        PageTemplateInfo pti = PageTemplateInfoProvider.GetPageTemplateInfo(templateName);

        if (pti != null)
        {
            if (pti.PageTemplateType != PageTemplateTypeEnum.Dashboard)
            {
                URLHelper.Redirect(URLHelper.ResolveUrl("~/CMSDesk/accessdenied.aspx") + "?message=" + ResHelper.GetString("dashboard.invalidpagetemplate"));
            }

            // Prepare virtual page info
            PageInfo pi = new PageInfo();
            pi.DocumentPageTemplateID = pti.PageTemplateId;
            pi.PageTemplateInfo       = pti;
            pi.ClassName        = "CMS.Root";
            pi.NodeAliasPath    = String.Empty;
            pi.DocumentNamePath = "/" + templateName;
            pi.NodeSiteId       = CMSContext.CurrentSiteID;

            CMSContext.CurrentPageInfo = pi;

            // Set the design mode
            PortalContext.SetRequestViewMode(ViewModeEnum.DashboardWidgets);
            PortalContext.DashboardName = dashboardName;
            ContextHelper.Add("DisplayContentInDesignMode", "0", true, false, false, DateTime.MinValue);

            PortalPageInstance.ManagersContainer    = plcManagers;
            PortalPageInstance.ScriptManagerControl = manScript;
        }
        else
        {
            RedirectToInformation(GetString("dashboard.notemplate"));
        }
    }
Example #29
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        if (pt != null)
        {
            // Limit text length
            txtTemplateCodeName.Text    = TextHelper.LimitLength(txtTemplateCodeName.Text.Trim(), 100, "");
            txtTemplateDisplayName.Text = TextHelper.LimitLength(txtTemplateDisplayName.Text.Trim(), 200, "");

            // finds whether required fields are not empty
            string result = new Validator().NotEmpty(txtTemplateDisplayName.Text, GetString("Administration-PageTemplate_General.ErrorEmptyTemplateDisplayName")).NotEmpty(txtTemplateCodeName.Text, GetString("Administration-PageTemplate_General.ErrorEmptyTemplateCodeName"))
                            .IsCodeName(txtTemplateCodeName.Text, GetString("general.invalidcodename"))
                            .Result;

            if (String.IsNullOrEmpty(result))
            {
                // Check if template with given name already exists
                if (PageTemplateInfoProvider.PageTemplateNameExists(txtTemplateCodeName.Text))
                {
                    lblError.Text = GetString("general.codenameexists");
                    return;
                }

                if (pt.IsReusable == true)
                {
                    // Clone template with clear
                    pt = pt.Clone(true);
                }
                pt.CodeName    = txtTemplateCodeName.Text;
                pt.DisplayName = txtTemplateDisplayName.Text;
                pt.Description = txtTemplateDescription.Text;

                pt.CategoryID = Convert.ToInt32(categorySelector.Value);

                pt.IsReusable         = true;
                pt.PageTemplateSiteID = 0;
                try
                {
                    PageTemplateInfoProvider.SetPageTemplateInfo(pt);
                    int siteId = QueryHelper.GetInteger("siteid", 0);
                    if (siteId > 0)
                    {
                        PageTemplateInfoProvider.AddPageTemplateToSite(pt.PageTemplateId, siteId);
                    }
                    ltlScript.Text = ScriptHelper.GetScript("SelectActualData(" + pt.PageTemplateId.ToString() + ", " + pt.IsPortal.ToString().ToLower() + ", " + pt.IsReusable.ToString().ToLower() + ");");
                }
                catch (Exception ex)
                {
                    lblError.Text = ex.Message;
                }
            }
            else
            {
                lblError.Visible = true;
                lblError.Text    = result;
            }
        }
    }
Example #30
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);
    }