Beispiel #1
0
        private void Page_Prerender(object sender, EventArgs e)
        {
            CDefault page = (CDefault)sender;

            var lcs = page.GetAllControls().OfType <LiteralControl>().Where(c => c.Parent.ID == "lblContent" &&
                                                                            c.Parent.Parent.GetType().BaseType.FullName == "DotNetNuke.Modules.Html.HtmlModule");

            foreach (var item in lcs)
            {
                LiteralControl lc = (LiteralControl)item;
                lc.Text = TokenReplaceUtils.Replace(lc.Text);
            }

            var labels = page.GetAllControls().OfType <Label>().Where(c => c.ID == "lblText" &&
                                                                      c.Parent.GetType().BaseType.FullName == "DotNetNuke.UI.Skins.Controls.Text");

            foreach (var label in labels)
            {
                label.Text = TokenReplaceUtils.Replace(label.Text);
            }

            /*
             * var blogContents = page.GetAllControls().OfType<UserControl>().Where(c => c.ID == "vtContents"
             *             && c.Parent.GetType().BaseType.FullName == "DotNetNuke.Modules.Blog.Blog");
             *
             * foreach (var blog in blogContents)
             * {
             *  object template = Reflection.GetProperty(blog.GetType(), "Template", blog);
             *  object contents = Reflection.GetProperty(template.GetType(), "Contents", template);
             *
             *  string newContents = TokenReplaceUtils.Replace(contents as string);
             *  Reflection.SetProperty(template.GetType(), "Contents", template, new object[]{newContents});
             * }
             */
            var literalsPA = page.GetAllControls().OfType <LiteralControl>().Where(c => c.Parent.ID == "phProperty" &&
                                                                                   c.Parent.Parent.GetType().BaseType.FullName == "Ventrian.PropertyAgent.ViewProperty");

            foreach (var item in literalsPA)
            {
                LiteralControl lc = (LiteralControl)item;
                lc.Text = TokenReplaceUtils.Replace(lc.Text);
            }


            /*
             * var htmlFinder = new ControlFinder<HtmlModule>();
             * htmlFinder.FindChildControlsRecursive(page);
             * foreach (var html in htmlFinder.FoundControls)
             * {
             *  var literalFinder = new ControlFinder<DNNLabelEdit>();
             *  literalFinder.FindChildControlsRecursive(html);
             *  foreach (var item in literalFinder.FoundControls)
             *      {
             *      LiteralControl lc = (LiteralControl)item.Controls[0];
             *      lc.Text = TokenReplaceUtils.Replace(lc.Text);
             *      }
             * }
             */
        }
Beispiel #2
0
 public static string filter_TransformString(string output)
 {
     if (PortalSettings.Current.UserMode == PortalSettings.Mode.View)
     {
         return(TokenReplaceUtils.Replace(output));
     }
     else
     {
         return(output);
     }
 }
Beispiel #3
0
        public override string Execute(Dictionary <string, string> parameters)
        {
            string Name = parameters["name"];

            if (string.IsNullOrEmpty(Name))
            {
                return(string.Format("[TokenProvider : parameter {0} missing]", Name));
            }
            int             PortalId = PortalSettings.Current.PortalId;
            BlockController bc       = new BlockController();
            var             b        = bc.GetBlock(Name, PortalId, LocaleController.Instance.GetCurrentLocale(PortalId).Code);

            if (b != null)
            {
                return(string.IsNullOrEmpty(b.Content) ? "" : TokenReplaceUtils.Replace(HttpUtility.HtmlDecode(b.Content)));
            }
            else
            {
                return(string.Format("[TokenProvider : no block with name {0} exist]", Name));
            }
        }