Пример #1
0
        private static string RenderTags(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            string result       = args.Result;
            string str3         = args.Parameters["itemid"];
            string name         = args.Parameters["language"];
            string str5         = args.Parameters["version"];
            string str6         = args.Parameters["fieldid"];
            string currentValue = "|" + args.Parameters["currentValue"] + "|";

            Item item = Context.ContentDatabase.GetItem(ID.Parse(str3), Language.Parse(name), Sitecore.Data.Version.Parse(str5));

            if (item == null)
            {
                SheerResponse.Alert("The item was not found.\n\nIt may have been deleted by another user.", new string[0]);
                return(null);
            }
            Field field = item.Fields[ID.Parse(str6)];

            if (field == null)
            {
                SheerResponse.Alert("The field was not found.\n\nIt may have been deleted by another user.", new string[0]);
                return(null);
            }

            string newTag = string.Format("{0}:{1}", result, "{C1453A1D-9ED2-428A-8BB3-50B4A877BEA7}");

            if (args.Parameters["mode"] == "check")
            {
                string tagNotFound = string.Format("|{0}:{1}|", ID.Null, args.Parameters["tagNotFound"]);
                currentValue = args.HasResult && args.Result != "undefined" ? currentValue.Replace(tagNotFound, "|" + newTag + "|") : currentValue.Replace(tagNotFound, "|");
            }
            else
            {
                currentValue += string.Format("{0}|", newTag);
            }

            currentValue = currentValue.Trim("|".ToCharArray());
            args.Parameters["currentValue"] = currentValue;

            FieldRenderer renderer = new FieldRenderer();

            renderer.Item      = item;
            renderer.FieldName = field.Name;
            renderer.OverrideFieldValue(currentValue);
            renderer.DisableWebEditing = false;
            return(renderer.Render());
        }
Пример #2
0
        private static RenderFieldResult RenderLink(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            string result = args.Result;
            string value  = args.Parameters["itemid"];
            string name   = args.Parameters["language"];
            string value2 = args.Parameters["version"];
            string value3 = args.Parameters["fieldid"];
            Item   item   = Context.ContentDatabase.GetItem(ID.Parse(value), Language.Parse(name),
                                                            Sitecore.Data.Version.Parse(value2));

            if (item == null)
            {
                SheerResponse.Alert("The item was not found.\n\nIt may have been deleted by another user.");
                new RenderFieldResult();
            }

            Field field = item.Fields[ID.Parse(value3)];

            using (FieldRenderer fieldRenderer = new FieldRenderer())
            {
                string text = args.Parameters["webeditparams"];
                SafeDictionary <string> parameters = new SafeDictionary <string>();
                if (!string.IsNullOrEmpty(text))
                {
                    parameters = WebUtil.ParseQueryString(text);
                }

                fieldRenderer.Item       = item;
                fieldRenderer.FieldName  = field.Name;
                fieldRenderer.Parameters = WebUtil.BuildQueryString(parameters, xhtml: false);
                fieldRenderer.OverrideFieldValue(result);
                fieldRenderer.DisableWebEditing = true;
                string formValue = WebUtil.GetFormValue("scSite");
                if (!string.IsNullOrEmpty(formValue))
                {
                    SiteContext siteContext = SiteContextFactory.GetSiteContext(formValue);
                    Assert.IsNotNull(siteContext, "siteContext");
                    using (new SiteContextSwitcher(siteContext))
                    {
                        return(fieldRenderer.RenderField());
                    }
                }

                return(fieldRenderer.RenderField());
            }
        }
Пример #3
0
        private static string RenderDate(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull(args, nameof(args));
            string result     = args.Result;
            string parameter1 = args.Parameters["format"];
            // ReSharper disable once StringLiteralTypo - Must match
            string parameter2 = args.Parameters["itemid"];
            string parameter3 = args.Parameters["language"];
            string parameter4 = args.Parameters["version"];
            // ReSharper disable once StringLiteralTypo - Must match
            string parameter5 = args.Parameters["fieldid"];
            Item   obj        = Context.ContentDatabase.GetItem(ID.Parse(parameter2), Language.Parse(parameter3), Version.Parse(parameter4));

            if (obj == null)
            {
                SheerResponse.Alert("The item was not found.\n\nIt may have been deleted by another user.");
                return(null);
            }

            Field field = obj.Fields[ID.Parse(parameter5)];

            if (field == null)
            {
                SheerResponse.Alert("The field was not found.\n\nIt may have been deleted by another user.");
                return(null);
            }

            using (FieldRenderer fieldRenderer = new FieldRenderer())
            {
                fieldRenderer.Item       = obj;
                fieldRenderer.FieldName  = field.Name;
                fieldRenderer.Parameters = "format=" + parameter1;
                fieldRenderer.OverrideFieldValue(result);
                fieldRenderer.DisableWebEditing = true;
                return(fieldRenderer.Render());
            }
        }
Пример #4
0
      private static string RenderTags(ClientPipelineArgs args) 
      {
        Assert.ArgumentNotNull(args, "args");
        string result = args.Result;
        string str3 = args.Parameters["itemid"];
        string name = args.Parameters["language"];
        string str5 = args.Parameters["version"];
        string str6 = args.Parameters["fieldid"];
        string currentValue = "|" + args.Parameters["currentValue"] + "|";

        Item item = Context.ContentDatabase.GetItem(ID.Parse(str3), Language.Parse(name), Sitecore.Data.Version.Parse(str5));
        if (item == null)
        {
          SheerResponse.Alert("The item was not found.\n\nIt may have been deleted by another user.", new string[0]);
          return null;
        }
        Field field = item.Fields[ID.Parse(str6)];
        if (field == null)
        {
          SheerResponse.Alert("The field was not found.\n\nIt may have been deleted by another user.", new string[0]);
          return null;
        }

        string newTag = string.Format("{0}:{1}", result, "{C1453A1D-9ED2-428A-8BB3-50B4A877BEA7}");
        if (args.Parameters["mode"] == "check")
        {
          string tagNotFound = string.Format("|{0}:{1}|", ID.Null, args.Parameters["tagNotFound"]);
          currentValue = args.HasResult && args.Result != "undefined" ? currentValue.Replace(tagNotFound, "|" + newTag + "|") : currentValue.Replace(tagNotFound, "|");
        }
        else
        {
          currentValue += string.Format("{0}|", newTag);
        }

        currentValue = currentValue.Trim("|".ToCharArray());
        args.Parameters["currentValue"] = currentValue;

        FieldRenderer renderer = new FieldRenderer();
        renderer.Item = item;
        renderer.FieldName = field.Name;
        renderer.OverrideFieldValue(currentValue);
        renderer.DisableWebEditing = false;
        return renderer.Render();         
      }