// *********************************************************************
        //  ApplyTemplates
        //
        /// <summary>
        /// Applies templates to control the ui generated by the control. If no
        /// template is specified a custom template is used. If a template is found
        /// in the skins directory, that template is loaded and used. If a user defined
        /// template is found, that template takes priority.
        /// </summary>
        ///
        // ********************************************************************/
        private void ApplyTemplates()
        {
            string pathToHeaderTemplate;
            string pathToFooterTemplate;
            string pathToItemTemplate;
            string pathToAlternatingItemTemplate;
            string keyForHeaderTemplate;
            string keyForItemTemplate;
            string keyForAlternatingItemTemplate;
            string keyForFooterTemplate;

            // Are we using skinned template?
            if (Page != null)
            {
                // Set the file paths to where the templates should be found
                keyForHeaderTemplate          = skinName + "/Templates/ThreadList-Header.ascx";
                keyForItemTemplate            = skinName + "/Templates/ThreadList-Item.ascx";
                keyForAlternatingItemTemplate = skinName + "/Templates/ThreadList-AlternatingItem.ascx";
                keyForFooterTemplate          = skinName + "/Templates/ThreadList-Footer.ascx";

                // Set the file paths to where the templates should be found
                pathToHeaderTemplate          = Globals.ApplicationVRoot + "/Skins/" + keyForHeaderTemplate;
                pathToItemTemplate            = Globals.ApplicationVRoot + "/Skins/" + keyForItemTemplate;
                pathToAlternatingItemTemplate = Globals.ApplicationVRoot + "/Skins/" + keyForAlternatingItemTemplate;
                pathToFooterTemplate          = Globals.ApplicationVRoot + "/Skins/" + keyForFooterTemplate;

                // Attempt to get the skinned header template
                if (HeaderTemplate == null)
                {
                    HeaderTemplate = Globals.LoadSkinnedTemplate(pathToHeaderTemplate, keyForHeaderTemplate, Page);
                }

                // Attempt to get the skinned item template
                if (ItemTemplate == null)
                {
                    ItemTemplate = Globals.LoadSkinnedTemplate(pathToItemTemplate, keyForItemTemplate, Page);
                }

                // Attempt to get the skinned alternating item template
                if (AlternatingItemTemplate == null)
                {
                    AlternatingItemTemplate = Globals.LoadSkinnedTemplate(pathToAlternatingItemTemplate, keyForAlternatingItemTemplate, Page);
                }

                // Attempt to get the footer template
                if (FooterTemplate == null)
                {
                    FooterTemplate = Globals.LoadSkinnedTemplate(pathToFooterTemplate, keyForFooterTemplate, Page);
                }
            }

            // If the item template is null we force our view
            if (ItemTemplate == null)
            {
                ExtractTemplateRows = true;
                HeaderTemplate      = new CompiledTemplateBuilder(new BuildTemplateMethod(BuildHeaderTemplate));
                ItemTemplate        = new CompiledTemplateBuilder(new BuildTemplateMethod(BuildItemTemplate));
                FooterTemplate      = new CompiledTemplateBuilder(new BuildTemplateMethod(BuildFooterTemplate));
            }
        }
        // *********************************************************************
        //  ApplyTemplates
        //
        /// <summary>
        /// Applies templates to control the ui generated by the control. If no
        /// template is specified a custom template is used. If a template is found
        /// in the skins directory, that template is loaded and used. If a user defined
        /// template is found, that template takes priority.
        /// </summary>
        ///
        // ********************************************************************/
        public virtual void ApplyTemplates()
        {
            string pathToHeaderTemplate;
            string pathToItemTemplate;
            string pathToFooterTemplate;
            string keyForHeaderTemplate;
            string keyForItemTemplate;
            string keyForFooterTemplate;

            // Are we using skinned template?
            if (Page != null)
            {
                // Set the file paths to where the templates should be found
                pathToHeaderTemplate = Globals.ApplicationVRoot + "/Skins/" + SkinName + "/Templates/ForumGroupRepeater-Header.ascx";
                pathToItemTemplate   = Globals.ApplicationVRoot + "/skins/" + SkinName + "/Templates/ForumGroupRepeater-Item.ascx";
                pathToFooterTemplate = Globals.ApplicationVRoot + "/skins/" + SkinName + "/Templates/ForumGroupRepeater-Footer.ascx";

                // Set the file paths to where the templates should be found
                keyForHeaderTemplate = SkinName + "/Templates/ForumGroupRepeater-Header.ascx";
                keyForItemTemplate   = SkinName + "/Templates/ForumGroupRepeater-Item.ascx";
                keyForFooterTemplate = SkinName + "/Templates/ForumGroupRepeater-Footer.ascx";

                // Attempt to get the skinned header template
                if (HeaderTemplate == null)
                {
                    HeaderTemplate = Globals.LoadSkinnedTemplate(pathToHeaderTemplate, keyForHeaderTemplate, Page);
                }

                // Attempt to get the skinned item template
                if (ItemTemplate == null)
                {
                    ItemTemplate = Globals.LoadSkinnedTemplate(pathToItemTemplate, keyForItemTemplate, Page);
                }

                // Attempt to get the footer template
                if (FooterTemplate == null)
                {
                    FooterTemplate = Globals.LoadSkinnedTemplate(pathToFooterTemplate, keyForFooterTemplate, Page);
                }
            }

            // No skinned or user defined template, load the default
            if (HeaderTemplate == null)
            {
                HeaderTemplate = new CompiledTemplateBuilder(new BuildTemplateMethod(BuildHeaderTemplate));
            }

            // No skinned or user defined template, load the default
            if (ItemTemplate == null)
            {
                ItemTemplate = new CompiledTemplateBuilder(new BuildTemplateMethod(BuildItemTemplate));
            }


            // No skinned or user defined template, load the default
            if (FooterTemplate == null)
            {
                FooterTemplate = new CompiledTemplateBuilder(new BuildTemplateMethod(BuildFooterTemplate));
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Creates a control hierarchy, with or without the specified data source.
 /// </summary>
 /// <param name="useDataSource">Indicates whether to use the specified data source.</param>
 protected override void CreateControlHierarchy(bool useDataSource)
 {
     if (IsReadOnly && DataSourceCount < 1)
     {
         return;
     }
     if (HeaderTemplate == null)
     {
         HeaderTemplate = new CompiledTemplateBuilder(BuildTemplate);
     }
     if (ItemTemplate == null)
     {
         ItemTemplate = !string.IsNullOrEmpty(DefaultItemTemplateUrl)
                                 ? Page.LoadTemplate(DefaultItemTemplateUrl)
                                 : new CompiledTemplateBuilder(BuildTemplate);
     }
     if (FooterTemplate == null)
     {
         FooterTemplate = new CompiledTemplateBuilder(BuildTemplate);
     }
     base.CreateControlHierarchy(useDataSource);
 }
Exemplo n.º 4
0
        // *********************************************************************
        //  ApplyTemplates
        //
        /// <summary>
        /// Applies templates to control the ui generated by the control. If no
        /// template is specified a custom template is used. If a template is found
        /// in the skins directory, that template is loaded and used. If a user defined
        /// template is found, that template takes priority.
        /// </summary>
        ///
        // ********************************************************************/
        private void ApplyTemplates()
        {
            string pathToHeaderTemplate;
            string pathToItemTemplate;
            string pathToAlternatingItemTemplate;
            string pathToFooterTemplate;
            string keyForHeaderTemplate;
            string keyForItemTemplate;
            string keyForAlternatingItemTemplate;
            string keyForFooterTemplate;

            // Are we using skinned template?
            if (Page != null)
            {
                // Set the file paths to where the templates should be found
                keyForHeaderTemplate          = Globals.Skin + "/Templates/PostList-Header.ascx";
                keyForItemTemplate            = Globals.Skin + "/Templates/PostList-Item.ascx";
                keyForAlternatingItemTemplate = Globals.Skin + "/Templates/PostList-AlternatingItem.ascx";
                keyForFooterTemplate          = Globals.Skin + "/Templates/PostList-Footer.ascx";

                // Set the file paths to where the templates should be found
                pathToHeaderTemplate          = Globals.ApplicationVRoot + "/Skins/" + keyForHeaderTemplate;
                pathToItemTemplate            = Globals.ApplicationVRoot + "/skins/" + keyForItemTemplate;
                pathToAlternatingItemTemplate = Globals.ApplicationVRoot + "/skins/" + keyForAlternatingItemTemplate;
                pathToFooterTemplate          = Globals.ApplicationVRoot + "/skins/" + keyForFooterTemplate;

                // Attempt to get the skinned header template
                if (HeaderTemplate == null)
                {
                    HeaderTemplate = Globals.LoadSkinnedTemplate(pathToHeaderTemplate, keyForHeaderTemplate, Page);
                }

                // Attempt to get the skinned item template
                if (ItemTemplate == null)
                {
                    ItemTemplate = Globals.LoadSkinnedTemplate(pathToItemTemplate, keyForItemTemplate, Page);
                }

                // Attempt to get the skinned alternating item template
                if (AlternatingItemTemplate == null)
                {
                    AlternatingItemTemplate = Globals.LoadSkinnedTemplate(pathToAlternatingItemTemplate, keyForAlternatingItemTemplate, Page);
                }

                // Attempt to get the footer template
                if (FooterTemplate == null)
                {
                    FooterTemplate = Globals.LoadSkinnedTemplate(pathToFooterTemplate, keyForFooterTemplate, Page);
                }
            }

            // Are any templates specified yet?
            if (ItemTemplate == null)
            {
                // Looks like we're using custom templates
                ExtractTemplateRows = true;

                HeaderTemplate = new CompiledTemplateBuilder(new BuildTemplateMethod(BuildHeaderTemplate));
                ItemTemplate   = new CompiledTemplateBuilder(new BuildTemplateMethod(BuildItemTemplate));
                //TODO: BUGBUG with DATALIST? SeparatorTemplate = new CompiledTemplateBuilder(new BuildTemplateMethod(BuildSeparatorTemplate));
                AlternatingItemTemplate = new CompiledTemplateBuilder(new BuildTemplateMethod(BuildAlternatingItemTemplate));
                FooterTemplate          = new CompiledTemplateBuilder(new BuildTemplateMethod(BuildFooterTemplate));
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Adds icons to the configuration area of a block instance.  Can be overridden to
        /// add additionsl icons
        /// </summary>
        /// <param name="canConfig"></param>
        /// <param name="canEdit"></param>
        /// <returns></returns>
        public virtual List <Control> GetConfigurationControls(bool canConfig, bool canEdit)
        {
            List <Control> configControls = new List <Control>();

            if (canConfig || canEdit)
            {
                // Attributes
                CompiledTemplateBuilder upContent = new CompiledTemplateBuilder(
                    delegate(Control content)
                {
                    Button trigger       = new Button();
                    trigger.ClientIDMode = System.Web.UI.ClientIDMode.Static;
                    trigger.ID           = string.Format("blck-cnfg-trggr-{0}", BlockInstance.Id.ToString());
                    trigger.Click       += trigger_Click;
                    content.Controls.Add(trigger);

                    HiddenField triggerData  = new HiddenField();
                    triggerData.ClientIDMode = System.Web.UI.ClientIDMode.Static;
                    triggerData.ID           = string.Format("blck-cnfg-trggr-data-{0}", BlockInstance.Id.ToString());
                    content.Controls.Add(triggerData);
                }
                    );

                UpdatePanel upTrigger = new UpdatePanel();
                upTrigger.ContentTemplate = upContent;
                configControls.Add(upTrigger);
                upTrigger.Attributes.Add("style", "display:none");

                // Icon to display block properties
                HtmlGenericControl aAttributes = new HtmlGenericControl("a");
                aAttributes.Attributes.Add("class", "properties icon-button show-modal-iframe");
                aAttributes.Attributes.Add("height", "500px");
                aAttributes.Attributes.Add("href", ResolveUrl(string.Format("~/BlockProperties/{0}?t=Block Properties", BlockInstance.Id)));
                //aAttributes.Attributes.Add( "instance-id", BlockInstance.Id.ToString() );
                configControls.Add(aAttributes);
            }

            if (canConfig)
            {
                // Security
                HtmlGenericControl aSecureBlock = new HtmlGenericControl("a");
                aSecureBlock.Attributes.Add("class", "security icon-button show-modal-iframe");
                aSecureBlock.Attributes.Add("height", "500px");
                aSecureBlock.Attributes.Add("href", ResolveUrl(string.Format("~/Secure/{0}/{1}?t=Block Security",
                                                                             Security.Authorization.EncodeEntityTypeName(BlockInstance.GetType()), BlockInstance.Id)));
                configControls.Add(aSecureBlock);

                // Move
                HtmlGenericControl aMoveBlock = new HtmlGenericControl("a");
                aMoveBlock.Attributes.Add("class", "block-move icon-button blockinstance-move");
                aMoveBlock.Attributes.Add("href", BlockInstance.Id.ToString());
                aMoveBlock.Attributes.Add("zone", BlockInstance.Zone);
                aMoveBlock.Attributes.Add("zoneloc", BlockInstance.BlockInstanceLocation.ToString());
                aMoveBlock.Attributes.Add("title", "Move");
                configControls.Add(aMoveBlock);

                // Delete
                HtmlGenericControl aDeleteBlock = new HtmlGenericControl("a");
                aDeleteBlock.Attributes.Add("class", "delete icon-button blockinstance-delete");
                aDeleteBlock.Attributes.Add("href", BlockInstance.Id.ToString());
                aDeleteBlock.Attributes.Add("title", "Delete");
                configControls.Add(aDeleteBlock);
            }

            return(configControls);
        }
        public void Deny_Unrestricted()
        {
            CompiledTemplateBuilder ctb = new CompiledTemplateBuilder(new BuildTemplateMethod(BuildTemplate));

            ctb.InstantiateIn(control);
        }