Example #1
0
        /// <summary>
        /// Initializes a new instance class.
        /// </summary>
        /// <param name="ui">User interface.</param>
        public EditContentWindow(Ui ui) : base(WindowType.Toplevel)
        {
            this.Build();
            this.ui = ui;

            try
            {
                this.Icon = IconTheme.Default.LoadIcon("glippy", 128, Gtk.IconLookupFlags.GenericFallback);
            }
            catch (Exception ex)
            {
                Tools.PrintInfo(ex, this.GetType());
            }

            if (Core.Clipboard.Instance.Items.Count > 0)
            {
                Core.Item item = Core.Clipboard.Instance.Items[0];

                if (item.IsData)
                {
                    this.content.Buffer.Text = item.Target.Name == Core.Targets.Html ? Encoding.Unicode.GetString(item.Data) : Encoding.Unicode.GetString(item.DataText);
                }
                else
                {
                    this.content.Buffer.Text = item.Text;
                }
            }

            this.Destroyed += (s, e) => this.Purge();
        }
Example #2
0
        public override void ExtractingProperty(Core.Item item, ItemProviders.ContentProperty propertyData)
        {
            //convert any node guids back to node Ids
            propertyData.Value = Umbraco.Courier.Core.Helpers.XmlDependencies.ReplaceIds(propertyData.Value.ToString(), dataXpath, Core.Enums.IdentifierReplaceDirection.FromGuidToNodeId);

            //register any uploaded media
        }
Example #3
0
        public override void PackagingProperty(Core.Item item, ItemProviders.ContentProperty propertyData)
        {
            if (propertyData != null && item != null && propertyData.Value != null)
            {
                List <string> idsFound = new List <string>();
                propertyData.Value = XmlDependencies.ReplaceIds(propertyData.Value.ToString(), "//* [@propertyid != '']", Core.Enums.IdentifierReplaceDirection.FromNodeIdToGuid, out idsFound);

                Logging._Debug(idsFound.Count + " Embedded content ids found");
                //we find and replace ids
                foreach (var id in idsFound)
                {
                    Guid g = Guid.Empty;
                    //we have to it this way, as there is no indication in the data whether the ID is media or document
                    if (Guid.TryParse(id, out g))
                    {
                        //is it content?
                        if (PersistenceManager.Default.GetNodeId(g, NodeObjectTypes.Document) != 0)
                        {
                            item.Dependencies.Add(id, ProviderIDCollection.documentItemProviderGuid);
                        }
                        else if (PersistenceManager.Default.GetNodeId(g, NodeObjectTypes.Media) != 0)
                        {
                            item.Dependencies.Add(id, ProviderIDCollection.mediaItemProviderGuid);
                        }
                    }
                }
            }
        }
Example #4
0
 public override void ExtractingProperty(Core.Item item, ContentProperty propertyData)
 {
     propertyData.Value = XmlDependencies.ReplaceIds(
         propertyData.Value.ToString(),
         dataXpath,
         IdentifierReplaceDirection.FromGuidToNodeId);
 }
Example #5
0
        /// <summary>
        /// Handles button apply clicked event.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="args">Event arguments.</param>
        private void OnButtonApplyClicked(object sender, EventArgs args)
        {
            if (this.content.Buffer.Text.Length == 0)
                return;

            Core.Item item = new Core.Item(this.content.Buffer.Text);
            Core.Clipboard.Instance.SetAsContent(item);
            this.OnButtonCancelClicked(sender, args);
        }
Example #6
0
        /// <summary>
        /// Handles button apply clicked event.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="args">Event arguments.</param>
        private void OnButtonApplyClicked(object sender, EventArgs args)
        {
            if (this.content.Buffer.Text.Length == 0)
            {
                return;
            }

            Core.Item item = new Core.Item(this.content.Buffer.Text);
            Core.Clipboard.Instance.SetAsContent(item);
            this.OnButtonCancelClicked(sender, args);
        }
Example #7
0
        public override void PackagingProperty(Core.Item item, ItemProviders.ContentProperty propertyData)
        {
            List <string> replacedIds = new List <string>();

            propertyData.Value = Umbraco.Courier.Core.Helpers.XmlDependencies.ReplaceIds(propertyData.Value.ToString(), dataXpath, Core.Enums.IdentifierReplaceDirection.FromNodeIdToGuid, out replacedIds);

            //these are the IDs we found in the picker, those documents are a dependency
            foreach (string guid in replacedIds)
            {
                if (!string.IsNullOrEmpty(guid.Trim()))
                {
                    item.Dependencies.Add(guid, Courier.ItemProviders.ProviderIDCollection.documentItemProviderGuid);
                }
            }
        }
Example #8
0
        public override void PackagingProperty(Core.Item item, ItemProviders.ContentProperty propertyData)
        {
            //first we need to get the mode of the picker
            XmlDocument doc = Umbraco.Courier.Core.Helpers.XmlDependencies.LoadXml(propertyData.Value.ToString());

            if (doc != null)
            {
                XmlNode node = doc.SelectSingleNode("/url-picker");

                Umbraco.Courier.Core.Helpers.Logging._Debug("loading node");

                if (node != null && node.Attributes["mode"] != null)
                {
                    string mode = node.Attributes["mode"].Value.ToLower();
                    Umbraco.Courier.Core.Helpers.Logging._Debug("node mode:" + mode);

                    if (mode == "upload")
                    {
                        foreach (var resource in Umbraco.Courier.Core.Helpers.XmlDependencies.FindResources(propertyData.Value.ToString(), resourceXpath, null))
                        {
                            item.Resources.Add(resource);
                        }
                    }

                    if (mode == "content" || mode == "media")
                    {
                        var provider = Courier.ItemProviders.ProviderIDCollection.documentItemProviderGuid;
                        if (mode == "media")
                        {
                            provider = Courier.ItemProviders.ProviderIDCollection.mediaItemProviderGuid;
                        }


                        List <string> replacedIds = new List <string>();
                        propertyData.Value = Umbraco.Courier.Core.Helpers.XmlDependencies.ReplaceIds(propertyData.Value.ToString(), dataXpath, Core.Enums.IdentifierReplaceDirection.FromNodeIdToGuid, out replacedIds);

                        foreach (string guid in replacedIds)
                        {
                            if (!string.IsNullOrEmpty(guid.Trim()))
                            {
                                item.Dependencies.Add(guid, provider);
                            }
                        }
                    }
                }
            }
        }
        public override bool ShouldExecute(Core.Item item, Core.Enums.ItemEvent itemEvent)
        {
            var type = item.GetType();

            if (type == typeof(ContentPropertyData))
            {
                var propertyData = (ContentPropertyData)item;

                var rightEvent = (itemEvent == ItemEvent.Extracting || itemEvent == ItemEvent.Packaging);

                if (!rightEvent)
                {
                    return(false);
                }

                var hasType = propertyData.Data.Any(x => x.Value != null && DataTypeIds.Contains(x.DataTypeEditor));
                return(hasType);
            }
            else
            {
                var dataType = (DataType)item;
                return(DataTypeIds.Contains(dataType.DataEditorId));
            }
        }
Example #10
0
 public override void ExtractingProperty(Core.Item item, ItemProviders.ContentProperty propertyData)
 {
     propertyData.Value = Umbraco.Courier.Core.Helpers.XmlDependencies.ReplaceIds(propertyData.Value.ToString(), dataXpath, Core.Enums.IdentifierReplaceDirection.FromGuidToNodeId);
 }
Example #11
0
        /// <summary>
        /// Initializes a new instance of class.
        /// </summary>
        /// <param name="plugin">Plugin.</param>
        public UploadWindow(Upload plugin) : base(WindowType.Toplevel)
        {
            this.Build();
            this.plugin = plugin;

            try
            {
                this.Icon = IconTheme.Default.LoadIcon("glippy", 128, IconLookupFlags.GenericFallback);
            }
            catch (Exception ex)
            {
                Core.Tools.PrintInfo(ex, this.GetType());
            }

            if (!string.IsNullOrWhiteSpace(Core.Settings.Instance[SettingsKeys.PastebinUserKey].AsString()))
            {
                this.useAccount.Sensitive = this.useAccount.Active = true;
            }

            this.Destroyed += (s, e) => this.Purge();

            Core.Item item = Core.Clipboard.Instance.Items.FirstOrDefault();

            if (item == null)
            {
                radiobuttonImage.Sensitive = false;
            }
            else if (item.IsImage)
            {
                int width, height;

                if (item.Image.Width < item.Image.Height)
                {
                    if (item.Image.Height > MaxImageSize)
                    {
                        height = MaxImageSize;
                        width  = MaxImageSize * item.Image.Width / item.Image.Height;
                    }
                    else
                    {
                        height = item.Image.Height;
                        width  = item.Image.Width;
                    }
                }
                else
                {
                    if (item.Image.Width > MaxImageSize)
                    {
                        width  = MaxImageSize;
                        height = MaxImageSize * item.Image.Height / item.Image.Width;
                    }
                    else
                    {
                        width  = item.Image.Width;
                        height = item.Image.Height;
                    }
                }

                this.imageClip.Pixbuf = item.Image.ScaleSimple(width, height, Gdk.InterpType.Bilinear);
                this.image            = new Gdk.Pixbuf(item.Image, 0, 0, item.Image.Width, item.Image.Height);

                this.radiobuttonImage.Active = true;
                this.SetItemsSensitivity(false);
                this.clipType.Page = 1;
            }
            else
            {
                TextBuffer buffer = new TextBuffer(null);

                if (item.IsData)
                {
                    buffer.Text = item.Target == Core.Targets.Html ? Encoding.UTF8.GetString(item.Data) : Encoding.UTF8.GetString(item.DataText);
                }
                else
                {
                    buffer.Text = item.Text;
                }

                this.textClip.Buffer            = buffer;
                this.radiobuttonImage.Sensitive = false;
            }
        }
Example #12
0
 /// <summary>
 /// Sets image as clipboard content.
 /// </summary>
 /// <param name="sender">Sender.</param>
 /// <param name="args">Event arguments.</param>
 private void OnButtonCopyToClipboardClicked(object sender, EventArgs args)
 {
     Core.Item item = new Core.Item(new Gdk.Pixbuf(this.image, 0, 0, this.image.Width, this.image.Height));
     Core.Clipboard.Instance.SetAsContent(item);
     this.buttonCopyToClipboard.Sensitive = false;
 }
Example #13
0
 /// <summary>
 /// Sets image as clipboard content.
 /// </summary>
 /// <param name="sender">Sender.</param>
 /// <param name="args">Event arguments.</param>
 private void OnButtonCopyToClipboardClicked(object sender, EventArgs args)
 {
     Core.Item item = new Core.Item(new Gdk.Pixbuf(this.image, 0, 0, this.image.Width, this.image.Height));
     Core.Clipboard.Instance.SetAsContent(item);
     this.buttonCopyToClipboard.Sensitive = false;
 }