コード例 #1
0
 public static JSONObject ParseMailTo(string mailTo)
 {
     var result = new JSONObject();
     var parts = mailTo.Replace("mailto:", "").Split('#');
     result.AddValue("address", parts[0]);
     result.AddValue("subject", parts.Length > 1 ? parts[1] : "");
     return result;
 }
コード例 #2
0
 public static JSONObject ParseUrl(string href)
 {
     var result = new JSONObject();
     var parts = href.Split('#');
     result.AddValue("anchor", parts.Length > 1 ? parts[1] : "");
     result.AddValue("query", parts[0].Contains("?") ? parts[0].Substring(parts[0].IndexOf("?")+1) : "");
     return result;
 }
コード例 #3
0
 public static JSONObject CreateNewFolder(string providerName, string referenceId, string parentId, string name)
 {
     var provider = ProviderHelper.GetTreeNodeProvider(providerName, referenceId);
     var documentType = DocumentType.GetByAlias("GridModuleFolder");
     var treeNode = provider.CreateNode(name, parentId, documentType.Id.ToString());
     var result = new JSONObject();
     result.AddValue("parentId", parentId);
     result.AddValue("addedId", treeNode.Id);
     return result;
 }
コード例 #4
0
        public bool SubscribeToList(string listId, string email, System.Collections.Specialized.NameValueCollection userDetails)
        {
            var parameters = new JSONObject();
            parameters.AddValue("apikey", _configuration.ApiKey);
            parameters.AddValue("id", listId);
            parameters.AddValue("email_address", email);

            var result = CallMethod("listSubscribe", parameters);
            return true;
        }
コード例 #5
0
        public static JSONObject GetValues(string referenceId, string itemId)
        {
            var data = GetAccordionData(referenceId);
            var item = data.GetItem(itemId);

            JSONObject result = new JSONObject();
            result.AddValue("headline", item.Headline);
            result.AddValue("content", item.Content);

            result.AddValue("isRoot", item.Id == data.Id);

            if (item.Id == data.Id)
            {
                result.AddValue("canMoveUp", false);
                result.AddValue("canMoveDown", false);
            }
            else
            {
                var parent = item.Parent;
                var index = item.Parent.Items.IndexOf(item);
                result.AddValue("canMoveUp", index > 0);
                result.AddValue("canMoveDown", index < parent.Items.Count-1);
            }

            if (!string.IsNullOrEmpty(item.ModuleId))
            {
                var module = CmsService.Instance.GetItem<Entity>(new Id(item.ModuleId));
                if (module != null)
                {
                    result.AddValue("moduleId", item.ModuleId);
                    result.AddValue("moduleName", module.EntityName);
                }
            }
            return result;
        }
コード例 #6
0
 public static JSONObject AddAccordionSibling(string itemId, string referenceId)
 {
     var data = GetAccordionData(referenceId);
     var item = data.GetItem(itemId);
     var parent = item.Parent;
     var newItem = data.AddItem(parent.Id, "New Accordion Item", "", "");
     var result = new JSONObject();
     result.AddValue("addedId", newItem.Id);
     result.AddValue("parentId", parent.Id);
     return result;
 }
コード例 #7
0
        public static JSONObject AddImageGalleryChild(string itemId, string referenceId)
        {
            var item = new ImageGalleryItem("New Image", Id.Null, "", "");
            var data = GetImageGalleryData(referenceId);
            var before = data.Items.Where(i => i.Id == itemId).FirstOrDefault();
            if (before == null)
                data.Items.Add(item);
            else
                data.Items.Insert(data.Items.IndexOf(before)+1, item);

            var result = new JSONObject();
            result.AddValue("rootId", HttpContext.Current.Request.QueryString["itemId"]);
            result.AddValue("addedId", item.Id.ToString());
            return result;
        }
コード例 #8
0
        public IEnumerable<MailingList> GetLists()
        {
            var parameters = new JSONObject();
            parameters.AddValue("apikey", _configuration.ApiKey);
            var result = CallMethod("lists", parameters);
            var count = (int) result["total"];
            if (count == 0)
                return new MailingList[0];
            var data = (JSONArray) result["data"];

            return data.Values.Cast<JSONObject>().Select(o => new MailingList((string)o["id"], HttpUtility.HtmlDecode((string)o["name"]))).ToArray();
        }
コード例 #9
0
ファイル: TinyMCEditor.cs プロジェクト: Psolow/Umbraco-Public
        protected override void OnPreRender(EventArgs e)
        {
            var options = new JSONObject();
            options.AddValue("mode", "exact");
            if (Width.HasValue)
                options.AddValue("width", Width.Value.Value.ToString());
            options.AddValue("elements", _textbox.ClientID);
            options.AddValue("theme", "advanced");
            options.AddValue("plugins", GetPlugins());
            options.AddValue("theme_advanced_buttons1", GetButtons1());
            options.AddValue("theme_advanced_buttons2", GetButtons2());
            options.AddValue("theme_advanced_buttons3", GetButtons3());
            //options.AddValue("theme_advanced_buttons4", GetButtons4());
            options.AddValue("theme_advanced_toolbar_location", "top");
            options.AddValue("theme_advanced_toolbar_align", "left");
            options.AddValue("theme_advanced_statusbar_location", "bottom");
            //options.AddValue("theme_advanced_resizing", true);
            options.AddValue("template_external_list_url", "lists/template_list.js");
            options.AddValue("external_link_list_url", "lists/link_list.js");
            options.AddValue("external_image_list_url", "lists/image_list.js");
            options.AddValue("media_external_list_url", "lists/media_list.js");
            //options.AddValue("style_formats", JSONArray.Parse("[{title : 'Bold text', inline : 'b'},{title : 'Red text', inline : 'span', styles : {color : '#ff0000'}},{title : 'Red header', block : 'h1', styles : {color : '#ff0000'}},{title : 'Example 1', inline : 'span', classes : 'example1'},{title : 'Example 2', inline : 'span', classes : 'example2'},{title : 'Table styles'},{title : 'Table row 1', selector : 'tr', classes : 'tablerow1'}]"));
            options.AddValue("template_replace_values", JSONObject.Parse("{ username : \"Some User\", staffid : \"991234\" }"));

            if (!string.IsNullOrEmpty(HiddenId))
            {
                var setup = new JSONDelegate("ed");
                setup.Lines.Add("ed.onInit.add(function(ed, evt) {");
                setup.Lines.Add("initializeEditorValue(ed, doc, '" + HiddenId + "');");
                setup.Lines.Add("var dom = ed.dom;");
                setup.Lines.Add("var doc = ed.getDoc();");
                setup.Lines.Add("tinymce.dom.Event.add(doc, 'blur', function(e) {");
                setup.Lines.Add("updateEditorValue(ed, doc,'" + HiddenId + "');");
                setup.Lines.Add("});");
                setup.Lines.Add("});");
                options.AddValue("setup", setup);
            }
            var script = new StringBuilder();
            script.AppendLine("tinyMCE.init(" + options.ToString() + ");");

            if (RegisterFormBind)
                script.AppendLine("$(theForm).bind(\"onSave\", function() { $(\"#" + _textbox.ClientID + "\").val(tinyMCE.get('" + _textbox.ClientID + "').save()); });");

            Page.ClientScript.RegisterStartupScript(Page.GetType(), "tinyMCEditor" + _textbox.ClientID, script.ToString(), true);

            base.OnPreRender(e);
        }
コード例 #10
0
 public override string ToString()
 {
     var result = new JSONObject();
     if (!string.IsNullOrEmpty(Query))
         result.AddValue("q", Query);
     if (!string.IsNullOrEmpty(TemplateName))
         result.AddValue("t", TemplateName);
     if (From.HasValue)
         result.AddValue("df", From.Value);
     if (To.HasValue)
         result.AddValue("dt", To.Value);
     if (CategorizationIds != null && CategorizationIds.Any())
     {
         var cids = new JSONArray();
         cids.AddRange(CategorizationIds.Select(id => id.IntValue));
         result.AddValue("cids", cids);
     }
     return result.ToString();
 }
コード例 #11
0
 public string GetListsTmp()
 {
     var parameters = new JSONObject();
     parameters.AddValue("apikey", _configuration.ApiKey);
     return CallMethod("lists", parameters).ToString();
 }
コード例 #12
0
 public JSONObject ToObject()
 {
     JSONObject result = new JSONObject();
     result.AddValue("text", Headline);
     result.AddValue("content", Content);
     result.AddValue("moduleId", ModuleId);
     JSONArray items = new JSONArray();
     foreach (var child in Items)
         items.AddValue(child.ToObject());
     result.AddValue("items", items);
     return result;
 }
コード例 #13
0
        public static JSONObject HandleChange(JSONArray request)
        {
            var provider = new LinqIt.UmbracoCustomFieldTypes.UmbracoTreeModuleProvider(HttpContext.Current.Request.QueryString["itemId"]);
            var placeholderData = provider.GetPlaceholderData();

            var layout = provider.GetLayout().Rows.SelectMany(r => r.Cells).ToArray();

            var result = layout.ToDictionary(cell => cell.Key, cell => new GridPlaceholderData(cell.Key, cell.ColumnSpan));

            var response = new JSONObject();
            var messages = new JSONArray();
            response.AddValue("messages", messages);

            foreach (JSONObject replacement in request.Values)
            {
                var from = (string) replacement["from"];
                var id = (string) replacement["id"];
                var to = (string) replacement["to"];

                var message = new JSONObject();
                message.AddValue("ph", from);
                message.AddValue("id", id);

                if (string.IsNullOrEmpty(to))
                {
                    message.AddValue("type", "alert");
                    message.AddValue("text", _removedMessage);
                }
                else
                {
                    var oldItem = placeholderData[from].Items.Where(i => i.Id == id).FirstOrDefault();
                    var newItem = provider.GetItem(id);
                    newItem.ColumnSpan = oldItem.ColumnSpan;

                    var cell = result[to];
                    if (cell.Items.Where(i => i.Id == newItem.Id).Any())
                    {
                        message.AddValue("type", "alert");
                        message.AddValue("text", _duplicateMessage);
                    }
                    else
                    {
                        if (cell.Span < newItem.ColumnSpan)
                        {
                            newItem.ColumnSpan = provider.GetItemColumnOptions(id).Where(o => o <= cell.Span).Max();
                            message.AddValue("type", "info");
                            message.AddValue("text", string.Format(_resizedMessage, newItem.ColumnSpan));
                        }
                        else
                        {
                            message.AddValue("type", "ok");
                        }
                        cell.AddItem(newItem);
                    }
                }
                messages.AddValue(message);
            }

            response.AddValue("hiddenId", HttpContext.Current.Request.QueryString["hiddenId"]);
            var values = new JSONArray();
            values.AddRange(result.Values.Select(v => v.ToJSON()).ToArray());
            response.AddValue("value", values.ToString());
            return response;
        }
コード例 #14
0
 public JSONObject ToObject()
 {
     var result = new JSONObject();
     result.AddValue("name", Text);
     result.AddValue("headline", Headline);
     result.AddValue("content", Content);
     result.AddValue("imageId", ImageId);
     return result;
 }
コード例 #15
0
        protected override void OnPreRender(EventArgs e)
        {
            var options = new JSONObject();
            options.AddValue("mode", "exact");
            if (Width.HasValue)
                options.AddValue("width", Width.Value.Value.ToString());
            else
                options.AddValue("width", 800);
            options.AddValue("elements", _textbox.ClientID);
            options.AddValue("convert_urls", false);
            options.AddValue("theme", "advanced");
            options.AddValue("plugins", GetPlugins());

            var styleOptions = GetStyleOptions();
            if (!string.IsNullOrEmpty(styleOptions))
                options.AddValue("theme_advanced_styles", styleOptions);
            options.AddValue("theme_advanced_buttons1", GetButtons1());
            options.AddValue("theme_advanced_buttons2", GetButtons2());
            options.AddValue("theme_advanced_buttons3", GetButtons3());
            options.AddValue("theme_advanced_toolbar_location", "top");
            options.AddValue("theme_advanced_toolbar_align", "left");
            options.AddValue("theme_advanced_statusbar_location", "bottom");
            options.AddValue("template_external_list_url", "lists/template_list.js");
            options.AddValue("external_link_list_url", "lists/link_list.js");
            options.AddValue("external_image_list_url", "lists/image_list.js");
            options.AddValue("media_external_list_url", "lists/media_list.js");

            if (StyleSheets != null && StyleSheets.Any())
                options.AddValue("content_css", StyleSheets.ToSeparatedString(","));

            options.AddValue("verify_html", false);
            options.AddValue("valid_elements", "*[*]");
            //options.AddValue("valid_elements", GetValidElements());
            options.AddValue("invalid_elements", GetInvalidElements());

            //options.AddValue("template_replace_values", JSONObject.Parse("{ username : \"Some User\", staffid : \"991234\" }"));

            var setup = new JSONDelegate("ed");
            if (!string.IsNullOrEmpty(HiddenId))
            {

                setup.Lines.Add("ed.onInit.add(function(ed, evt) {");
                setup.Lines.Add("initializeEditorValue(ed, doc, '" + HiddenId + "');");
                setup.Lines.Add("var dom = ed.dom;");
                setup.Lines.Add("var doc = ed.getDoc();");
                setup.Lines.Add("tinymce.dom.Event.add(doc, 'blur', function(e) {");
                setup.Lines.Add("updateEditorValue(ed, doc,'" + HiddenId + "');");
                setup.Lines.Add("});");
                setup.Lines.Add("});");
            }

            setup.Lines.Add("ed.onNodeChange.addToTop(function(ed, cm, n) {");
            setup.Lines.Add("var macroElement = ed.dom.getParent(ed.selection.getStart(), 'div.umbMacroHolder');");
            setup.Lines.Add("if (macroElement) {");
            setup.Lines.Add("ed.selection.select(macroElement);");
            setup.Lines.Add("var currentSelection = ed.selection.getStart();");
            setup.Lines.Add("if (tinymce.isIE) {");
            setup.Lines.Add("if (!ed.dom.hasClass(currentSelection, 'umbMacroHolder')) {");
            setup.Lines.Add("while (!ed.dom.hasClass(currentSelection, 'umbMacroHolder') && currentSelection.parentNode) {");
            setup.Lines.Add("currentSelection = currentSelection.parentNode;");
            setup.Lines.Add("}");
            setup.Lines.Add("ed.selection.select(currentSelection);");
            setup.Lines.Add("}");
            setup.Lines.Add("}");
            setup.Lines.Add("cm.setActive('umbracomacro', ed.dom.hasClass(currentSelection, 'umbMacroHolder') || ed.dom.hasClass(macroElement, 'umbMacroHolder'));");
            setup.Lines.Add("}");
            setup.Lines.Add("});");

            options.AddValue("setup", setup);

            var script = new StringBuilder();
            script.AppendLine("tinyMCE.init(" + options.ToString() + ");");

            if (RegisterFormBind)
                script.AppendLine("$(theForm).bind(\"onSave\", function() { $(\"#" + _textbox.ClientID + "\").val(tinyMCE.get('" + _textbox.ClientID + "').save()); });");

            Page.ClientScript.RegisterStartupScript(Page.GetType(), "tinyMCEditor" + _textbox.ClientID, script.ToString(), true);

            base.OnPreRender(e);
        }
コード例 #16
0
 public static JSONObject RemoveAccordionItem(string referenceId, string itemId)
 {
     var data = GetAccordionData(referenceId);
     var item = data.GetItem(itemId);
     var parentId = item.Parent.Id;
     data.RemoveItem(item);
     var response = new JSONObject();
     response.AddValue("parentId", parentId);
     response.AddValue("updatedValue", data.ToJSON().ToString());
     return response;
 }
コード例 #17
0
        public static JSONObject MoveAccordionItem(string referenceId, string itemId, int step)
        {
            var data = GetAccordionData(referenceId);
            var item = data.GetItem(itemId);
            var parent = item.Parent;
            var index = parent.Items.IndexOf(item) + step;
            parent.Items.Remove(item);
            parent.Items.Insert(index, item);

            var response = new JSONObject();
            response.AddValue("parentId", parent.Id);
            response.AddValue("updatedValue", data.ToJSON().ToString());
            return response;
        }
コード例 #18
0
        public static JSONObject GetLongRunningState()
        {
            var result = new JSONObject();
            var isDone = true;
            var html = HtmlWriter.Generate(w => RenderState(ref isDone, w));
            var errors = HtmlWriter.Generate(RenderErrors);
            result.AddValue("html", html);
            result.AddValue("errors", errors);
            result.AddValue("done", isDone);

            if (isDone)
                Instance = null;

            return result;
        }
コード例 #19
0
 public static JSONObject RemoveImageGalleryItem(string referenceId, string itemId)
 {
     var data = GetImageGalleryData(referenceId);
     var item = data.Items.Where(i => i.Id == itemId).FirstOrDefault();
     data.Items.Remove(item);
     var response = new JSONObject();
     response.AddValue("updatedValue", data.ToJSON().ToString());
     response.AddValue("parentId", HttpContext.Current.Request.QueryString["itemId"]);
     return response;
 }
コード例 #20
0
        public static JSONObject GetValues(string referenceId, string itemId)
        {
            var data = GetImageGalleryData(referenceId);

            var result = new JSONObject();

            var item = data.Items.Where(i => i.Id == itemId).FirstOrDefault();
            bool isRoot = item== null || item.Id == HttpContext.Current.Request.QueryString["itemid"];

            result.AddValue("isRoot", isRoot);

            if (isRoot)
            {
                result.AddValue("canMoveUp", false);
                result.AddValue("canMoveDown", false);
                result.AddValue("headline", "");
                result.AddValue("content", "");
            }
            else
            {
                var index = data.Items.IndexOf(item);
                result.AddValue("canMoveUp", index > 0);
                result.AddValue("canMoveDown", index < data.Items.Count - 1);
                result.AddValue("name", item.Text);
                result.AddValue("headline", item.Headline);
                result.AddValue("content", item.Content);
                if (!string.IsNullOrEmpty(item.ImageId))
                {
                    var media = new global::umbraco.cms.businesslogic.media.Media(Convert.ToInt32(item.ImageId));
                    {
                        result.AddValue("imageId", item.ImageId);
                        result.AddValue("imageName", media.Text);
                        result.AddValue("imageUrl", (string)media.getProperty("umbracoFile").Value);
                    }
                }
            }
            return result;
        }
コード例 #21
0
 public static JSONObject SetItemValue(string referenceId, string itemId, JSONObject value)
 {
     var result = new JSONObject();
     var data = GetImageGalleryData(referenceId);
     var item = data.Items.Where(i => i.Id == itemId).FirstOrDefault();
     foreach (var key in value.Keys)
     {
         switch (key)
         {
             case "name":
                 item.Text = (string) value[key];
                 break;
             case "headline":
                 item.Headline = (string) value[key];
                 break;
             case "content":
                 item.Content = (string) value[key];
                 break;
             case "imageId":
                 item.ImageId = (string) value[key];
                 if (!string.IsNullOrEmpty(item.ImageId))
                 {
                     var media = new global::umbraco.cms.businesslogic.media.Media(Convert.ToInt32(item.ImageId));
                     {
                         result.AddValue("imageId", item.ImageId);
                         result.AddValue("imageName", media.Text);
                         result.AddValue("imageUrl", (string)media.getProperty("umbracoFile").Value);
                     }
                 }
                 break;
         }
     }
     result.AddValue("value", data.ToJSON().ToString());
     return result;
 }