Ejemplo n.º 1
0
        public List <TemplateDef> MapTemplateDef(IList <string> data)
        {
            int FieldLength = CGLTemplateFields.Fields.Length;
            var templates   = new List <TemplateDef>();

            try
            {
                for (int i = 0; i < data.Count; i += FieldLength)
                {
                    var template = new TemplateDef();
                    if (Helper.CheckIfCorrectTemplateName(data[i + 1]))
                    {
                        template.TemplateName = data[i];
                        template.FieldName    = data[i + 1];
                        template.FieldValue   = data[i + 2];
                        template.FieldDesc    = data[i + 3];
                        templates.Add(template);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            return(templates);
        }
Ejemplo n.º 2
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            LoadXsl();
            ProcessDataSources();

            if (TemplateDef == null)
            {
                try
                {
                    TemplateDef = TemplateDefinition.FromName(ClientID, DesignType, DesignStyle, true, XslSourceData, cached);
                    TemplateDef.AddTemplateArguments(TemplateArguments, true);
                    TemplateDef.AddClientOptions(ClientOptions, true);
                }
                catch (XsltException ex)
                {
                    error = ex;
                    SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory(ex.Source, TraceSeverity.High, EventSeverity.Error), TraceSeverity.High, ex.Message, ex.Data);
                }
            }

            if (!prerendered)
            {
                if (TemplateDef != null)
                {
                    TemplateDef.PreRender(Page);
                    prerendered = true;
                }
            }
        }
Ejemplo n.º 3
0
        private LightweightCache <string, TemplateDef> buildTemplateCache(BehaviorGraph behaviors)
        {
            var cache = new LightweightCache <string, TemplateDef>();

            behaviors.Behaviors.Where(x => x.InputType().CanBeCastTo <Template>()).Each(chain => {
                var def = new TemplateDef(this, chain);

                cache[def.Name] = def;
            });

            return(cache);
        }
Ejemplo n.º 4
0
        public override void PreRenderWebPart(EventArgs e)
        {
            if (TemplateDef != null && !prerendered)
            {
                TemplateDef.PreRender(Page);
                prerendered = true;
            }

            if (inEditMode)
            {
                base.PreRenderWebPart(e);
            }
        }
Ejemplo n.º 5
0
        public override void PreRenderWebPart(EventArgs e)
        {
            if (TemplateDef != null)
            {
                TemplateDef.PreRender(Page);
            }

            /*
             * if (inEditMode)
             * {
             *  base.PreRenderWebPart(e);
             * }
             */
        }
Ejemplo n.º 6
0
        internal void Render(HtmlTextWriter htmlWriter)
        {
            htmlWriter.Write("<!-- Begin SharePresence Navigation - {0} template -->", menuSettings.ControlStyle);

            TemplateDef.AddClientOptions(new List <ClientOption> {
                new ClientString(menuSettings.ControlStyle + "MenuOptions", menuSettings.ControlStyle)
            }, false);

            //MenuXml menuXml = new MenuXml { root = RootNode };
            //menuXml.ToString();
            TemplateDef.Render(new MenuXml {
                root = RootNode
            }, htmlWriter);

            htmlWriter.Write("<!-- End SharePresence Navigation - {0} template -->", menuSettings.ControlStyle);
        }
Ejemplo n.º 7
0
        internal virtual void PreRender()
        {
            TemplateDef.AddTemplateArguments(menuSettings.TemplateArguments, true);
            TemplateDef.AddClientOptions(menuSettings.ClientOptions, true);

            if (!String.IsNullOrEmpty(menuSettings.NodeXmlPath))
            {
                LoadNodeXml();
            }
            if (!String.IsNullOrEmpty(menuSettings.NodeSelector))
            {
                ApplyNodeSelector();
            }
            if (!String.IsNullOrEmpty(menuSettings.IncludeNodes))
            {
                FilterNodes(menuSettings.IncludeNodes, false);
            }
            if (!String.IsNullOrEmpty(menuSettings.ExcludeNodes))
            {
                FilterNodes(menuSettings.ExcludeNodes, true);
            }
            if (String.IsNullOrEmpty(menuSettings.NodeXmlPath) && !SkipLocalisation)
            {
                new Localiser(HostPortalSettings.PortalId).LocaliseNode(RootNode);
            }
            if (!String.IsNullOrEmpty(menuSettings.NodeManipulator))
            {
                ApplyNodeManipulator();
            }

            if (!menuSettings.IncludeHidden)
            {
                FilterHiddenNodes(RootNode);
            }

            var imagePathOption =
                menuSettings.ClientOptions.Find(o => o.Name.Equals("PathImage", StringComparison.InvariantCultureIgnoreCase));

            RootNode.ApplyContext(
                imagePathOption == null ? DNNContext.Current.PortalSettings.HomeDirectory : imagePathOption.Value);

            TemplateDef.PreRender();
        }
        internal void Render(HtmlTextWriter htmlWriter)
        {
            htmlWriter.Write("<!-- DDRmenu v02.00.01 - {0} template -->", menuSettings.MenuStyle);

            UserInfo user = null;

            if (menuSettings.IncludeContext)
            {
                user       = UserController.Instance.GetCurrentUserInfo();
                user.Roles = user.Roles;                 // Touch roles to populate
            }

            TemplateDef.AddClientOptions(new List <ClientOption> {
                new ClientString("MenuStyle", menuSettings.MenuStyle)
            }, false);

            TemplateDef.Render(new MenuXml {
                root = RootNode, user = user
            }, htmlWriter);
        }
Ejemplo n.º 9
0
        protected override void OnInit(EventArgs e)
        {
            LoadXsl();
            ProcessDataSources();

            formpanel = new UpdatePanel {
                ID = ID + "_UpdateFormPanel", RenderMode = UpdatePanelRenderMode.Block
            };                                                                                                     //, EnableViewState = true };

            contenttemplate           = new FormContentTemplate();
            contenttemplate.WebPart   = this;
            formpanel.ContentTemplate = contenttemplate;
            //Add on Page
            this.Controls.Add(formpanel);

            //Add Field Controls
            SetListFormFields(contenttemplate.canvas);

            formprogess = new UpdateProgress {
                AssociatedUpdatePanelID = formpanel.ID
            };
            formprogess.ProgressTemplate = new FormProgessTemplate();
            this.Controls.Add(formprogess);

            //if (TemplateDef == null)
            //{
            try
            {
                TemplateDef = TemplateDefinition.FromName(contenttemplate.canvas.ClientID, FormType, FormStyle, true, XslSourceData, cached);
                TemplateDef.AddTemplateArguments(TemplateArguments, true);
                TemplateDef.AddClientOptions(ClientOptions, true);
            }
            catch (Exception)
            {
            }
            //}

            base.OnInit(e);
        }
Ejemplo n.º 10
0
        public override void RenderWebPart(HtmlTextWriter writer)
        {
            writer.Write("<!-- Begin SharePresence DesignWebPart - {0} {1} -->", DesignType, DesignStyle);

            if (TemplateDef != null)
            {
                TemplateDef.AddClientOptions(new List <ClientOption> {
                    new ClientString(DesignType + "_DesignOptions_", DesignStyle)
                }, false);

                string data = string.Empty;
                try
                {
                    GetListItems(out data);
                    if (!string.IsNullOrEmpty(data))
                    {
                        TemplateDef.Render(data, writer);
                    }
                    else
                    {
                        HttpApplication application = HttpContext.Current.ApplicationInstance;
                        if (application.User.Identity.IsAuthenticated)
                        {
                            writer.Write("No DataSource and or Style configured. ");

                            if (SPContext.Current.FormContext.FormMode == Microsoft.SharePoint.WebControls.SPControlMode.Edit)
                            {
                                writer.Write(String.Format(" <a onclick=\"ShowToolPane2Wrapper('Edit',this,'{0}');return false;\"> Configure </a>", StorageKey.ToString()));
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    writer.Write(ex.Message);
                    SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory(ex.Source, TraceSeverity.High, EventSeverity.Error), TraceSeverity.High, ex.Message, ex.Data);
                }
            }
            else
            {
                HttpApplication application = HttpContext.Current.ApplicationInstance;
                if (application.User.Identity.IsAuthenticated)
                {
                    if (error != null)
                    {
                        writer.Write(error.Message + ":" + error.InnerException.Message);
                    }
                    else
                    {
                        writer.Write("No DataSource and or Style configured. ");

                        if (SPContext.Current.FormContext.FormMode == Microsoft.SharePoint.WebControls.SPControlMode.Edit)
                        {
                            writer.Write(String.Format(" <a onclick=\"ShowToolPane2Wrapper('Edit',this,'{0}');return false;\"> Configure </a>", StorageKey.ToString()));
                        }
                    }
                }
            }

            writer.Write("<!-- End SharePresence DesignWebPart - {0} {1} -->", DesignType, DesignStyle);

            if (inEditMode)
            {
                base.RenderWebPart(writer);
            }
        }
Ejemplo n.º 11
0
        public override void RenderWebPart(HtmlTextWriter writer)
        {
            string        output  = string.Empty;
            StringBuilder builder = new StringBuilder();

            using (var baseWriter = new HtmlTextWriter(new StringWriter(builder, CultureInfo.InvariantCulture)))
            {
                bool configure = false;
                baseWriter.Write("<!-- Begin SharePresence FormWebPart - {0} {1} -->", FormType, FormStyle);

                if (TemplateDef != null)
                {
                    List <TemplateArgument> args = new List <TemplateArgument>();
                    //var args = new XsltArgumentList();
                    if (!string.IsNullOrEmpty(FormTitle))
                    {
                        args.Add(new TemplateArgument("FormName", FormTitle));
                    }

                    if (!string.IsNullOrEmpty(FormDesciption))
                    {
                        args.Add(new TemplateArgument("FormDescription", FormDesciption));
                        //args.AddParam("FormDescription", "", FormDesciption);
                    }
                    TemplateDef.AddTemplateArguments(args, false);

                    //TemplateDef.TemplateArguments.ForEach(a => args.AddParam(a.Name, "", a.Value));

                    TemplateDef.AddClientOptions(new List <ClientOption> {
                        new ClientString(FormType + "_FormOptions_", FormStyle)
                    }, false);

                    string data = string.Empty;
                    try
                    {
                        GetListItems(out data);
                        if (!string.IsNullOrEmpty(data))
                        {
                            StringBuilder templatebuilder = new StringBuilder();
                            using (var templateWriter = new HtmlTextWriter(new StringWriter(templatebuilder, CultureInfo.InvariantCulture)))
                            {
                                TemplateDef.Render(data, templateWriter);
                            }

                            //Add Template for Canvas Render
                            contenttemplate.innerHtml = templatebuilder.ToString();

                            //formpanel.Triggers.Add(contenttemplate.canvas as UpdatePanelTrigger);
                            formpanel.RenderControl(baseWriter);
                        }
                        else
                        {
                            HttpApplication application = HttpContext.Current.ApplicationInstance;
                            if (application.User.Identity.IsAuthenticated)
                            {
                                baseWriter.Write("No DataSource and or Style configured. ");

                                if (SPContext.Current.FormContext.FormMode == Microsoft.SharePoint.WebControls.SPControlMode.Edit)
                                {
                                    baseWriter.Write(String.Format(" <a onclick=\"ShowToolPane2Wrapper('Edit',this,'{0}');return false;\" style=\"cursor: hand;\" >Configure</a>", StorageKey.ToString()));
                                    configure = true;
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        baseWriter.Write(ex.Message);

                        if (SPContext.Current.FormContext.FormMode == Microsoft.SharePoint.WebControls.SPControlMode.Edit)
                        {
                            baseWriter.Write(String.Format(" <a onclick=\"ShowToolPane2Wrapper('Edit',this,'{0}');return false;\" style=\"cursor: hand;\" >Configure</a>", StorageKey.ToString()));
                            configure = true;
                        }
                    }
                }
                else
                {
                    HttpApplication application = HttpContext.Current.ApplicationInstance;
                    if (application.User.Identity.IsAuthenticated)
                    {
                        baseWriter.Write("No DataSource and or Style configured. ");

                        if (SPContext.Current.FormContext.FormMode == Microsoft.SharePoint.WebControls.SPControlMode.Edit)
                        {
                            baseWriter.Write(String.Format(" <a onclick=\"ShowToolPane2Wrapper('Edit',this,'{0}');return false;\">Configure</a>", StorageKey.ToString()));
                            configure = true;
                        }
                    }
                }

                baseWriter.Write("<!-- End SharePresence FormWebPart - {0} {1} -->", FormType, FormStyle);

                if (inEditMode)
                {
                    if (!configure)
                    {
                        if (SPContext.Current.FormContext.FormMode == Microsoft.SharePoint.WebControls.SPControlMode.Edit)
                        {
                            baseWriter.Write(String.Format(" <a onclick=\"ShowToolPane2Wrapper('Edit',this,'{0}');return false;\">Configure</a>", StorageKey.ToString()));
                        }
                    }

                    menuControls.RenderControl(baseWriter);
                    //base.RenderWebPart(baseWriter);
                }

                output = builder.ToString();
            }

            writer.Write(output);
        }