Пример #1
0
        private void CloneDatasource()
        {
            Item selectionItem = this.CloneDestination.GetSelectionItem();

            if (selectionItem == null)
            {
                SheerResponse.Alert("Parent not found", new string[0]);
            }
            else
            {
                string str2;
                string name = this.CloneName.Value;
                if (!this.ValidateNewItemName(name, out str2))
                {
                    SheerResponse.Alert(str2, new string[0]);
                }
                else
                {
                    Item currentDatasourceItem = this.CurrentDatasourceItem;
                    Assert.IsNotNull(currentDatasourceItem, "currentDatasource");
                    if (selectionItem.Paths.LongID.StartsWith(currentDatasourceItem.Paths.LongID))
                    {
                        SheerResponse.Alert("An item cannot be copied below itself.", new string[0]);
                    }
                    else
                    {
                        name = ItemUtil.GetCopyOfName(selectionItem, name);
                        Item selectedItem = currentDatasourceItem.CloneTo(selectionItem, name, true);
                        this.SetDialogResult(selectedItem);
                        SheerResponse.CloseWindow();
                    }
                }
            }
        }
Пример #2
0
        // Methods
        public new void Execute(CopyItemsArgs args)
        {
            Event.RaiseEvent("item:bucketing:cloning", args, this);
            Assert.ArgumentNotNull(args, "args");
            var items = GetItems(args);

            if (args.IsNotNull())
            {
                var itemId = args.Parameters["destination"];
                if (itemId.IsNotNull())
                {
                    var database = GetDatabase(args);
                    if (database.GetItem(itemId).IsBucketItemCheck())
                    {
                        var list = new ArrayList();
                        foreach (var item3 in from item2 in items
                                 where item2.IsNotNull()
                                 let item = BucketManager.CreateAndReturnDateFolderDestination(database.GetItem(itemId), item2)
                                            let copyOfName = ItemUtil.GetCopyOfName(item, item2.Name)
                                                             select item2.CloneTo(item, copyOfName, true))
                        {
                            list.Add(item3);
                        }

                        args.Copies = list.ToArray(typeof(Item)) as Item[];
                        Event.RaiseEvent("item:bucketing:cloned", args, this);
                        args.AbortPipeline();
                    }
                }
            }
        }
Пример #3
0
 protected override void OnLoad(EventArgs e)
 {
     Assert.ArgumentNotNull(e, "e");
     base.OnLoad(e);
     if (!Context.ClientPage.IsEvent)
     {
         this.SelectOption.Click = string.Format("ChangeMode(\"{0}\")", "Select");
         this.CreateOption.Click = string.Format("ChangeMode(\"{0}\")", "Create");
         this.CloneOption.Click  = string.Format("ChangeMode(\"{0}\")", "Clone");
         this.SearchOption.Click = string.Format("ChangeMode(\"{0}\")", "Search");
         SelectDatasourceOptions options = SelectItemOptions.Parse <SelectDatasourceOptions>();
         if (options.DatasourcePrototype == null)
         {
             this.DisableCreateOption();
         }
         else
         {
             this.Prototype = options.DatasourcePrototype;
         }
         if (!string.IsNullOrEmpty(options.DatasourceItemDefaultName))
         {
             this.NewDatasourceName.Value = this.GetNewItemDefaultName(options.DatasourceRoot, options.DatasourceItemDefaultName);
         }
         if (options.ContentLanguage != null)
         {
             this.ContentLanguage = options.ContentLanguage;
         }
         if (!string.IsNullOrEmpty(options.CurrentDatasource))
         {
             this.CurrentDatasourcePath = options.CurrentDatasource;
             if (options.DatasourceRoot != null)
             {
                 string copyOfName = string.Empty;
                 if (!string.IsNullOrEmpty(options.DatasourceItemDefaultName))
                 {
                     copyOfName = ItemUtil.GetCopyOfName(options.DatasourceRoot, options.DatasourceItemDefaultName);
                 }
                 if (this.CurrentDatasourceItem != null)
                 {
                     copyOfName = this.CloneName.Value = ItemUtil.GetCopyOfName(options.DatasourceRoot, this.CurrentDatasourceItem.Name);
                 }
                 this.CloneName.Value = copyOfName;
             }
         }
         else
         {
             this.CloneOption.Visible = false;
         }
         this.SetDataContexts();
         Item folder = base.DataContext.GetFolder();
         this.SetControlsForSelection(folder);
         this.SetSectionHeader();
     }
 }
Пример #4
0
        protected virtual Item CopyItem(Item target, Item itemToCopy)
        {
            Assert.ArgumentNotNull((object)target, nameof(target));
            Assert.ArgumentNotNull((object)itemToCopy, nameof(itemToCopy));
            string str        = target.Uri.ToString();
            string copyOfName = ItemUtil.GetCopyOfName(target, itemToCopy.Name);
            Item   obj        = Context.Workflow.CopyItem(itemToCopy, target, copyOfName);

            Log.Audit((object)this, "Copy item from: {0} to {1}", AuditFormatter.FormatItem(itemToCopy), AuditFormatter.FormatItem(obj), str);
            return(obj);
        }
Пример #5
0
        public virtual void Execute(CopyItemsArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            Item item = GetDatabase(args).GetItem(args.Parameters["destination"]);

            Assert.IsNotNull(item, args.Parameters["destination"]);
            ArrayList   list  = new ArrayList();
            List <Item> items = GetSubItems(args);
            string      str   = item.Uri.ToString();

            foreach (Item item2 in items)
            {
                if (item2 != null)
                {
                    Log.Audit(this, "Copy sub items: {0}", new string[] { AuditFormatter.FormatItem(item2), str });
                    string copyOfName = ItemUtil.GetCopyOfName(item, item2.Name);
                    Item   item3      = Context.Workflow.CopyItem(item2, item, copyOfName);
                    list.Add(item3);
                }
            }
            args.Copies = list.ToArray(typeof(Item)) as Item[];
        }