Exemplo n.º 1
0
        /// <summary>
        /// Gets the item from parameters.
        /// </summary>
        /// <param name="args">The arguments.</param>
        /// <returns>The item.</returns>
        private Item GetItemFromPipelineArgs(ClientPipelineArgs args)
        {
            var item = Database.GetItem(ItemUri.Parse(args.Parameters["uri"]));

            Assert.IsNotNull(item, "item");
            return(item);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Cleans the VirtualProductResolver caches.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="args">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        public void OnItemSaved(object sender, EventArgs args)
        {
            Assert.ArgumentNotNull(sender, "sender");
            Assert.ArgumentNotNull(args, "args");

            Item item = Event.ExtractParameter(args, 0) as Item;

            if (item == null)
            {
                return;
            }

            var virtualProductResolver = Context.Entity.Resolve <VirtualProductResolver>();

            Assert.IsNotNull(virtualProductResolver, "Virtual product resolver is null");

            lock (virtualProductResolver.ProductsUrlsCollection.SyncRoot)
            {
                if (virtualProductResolver.ProductsUrlsCollection == null || virtualProductResolver.ProductsUrlsCollection.Count <= 0)
                {
                    return;
                }

                var keysToRemove = new List <string>();

                foreach (DictionaryEntry urlsCollection in virtualProductResolver.ProductsUrlsCollection)
                {
                    if (!(urlsCollection.Value is ProductUriLine))
                    {
                        continue;
                    }

                    var productUriLine = (ProductUriLine)urlsCollection.Value;

                    var productUriValues = new[]
                    {
                        productUriLine.ProductCatalogItemUri,
                        productUriLine.ProductItemUri,
                        productUriLine.ProductPresentationItemUri
                    };

                    foreach (var productUriValue in productUriValues)
                    {
                        if (string.IsNullOrEmpty(productUriValue) || !ItemUri.IsItemUri(productUriValue))
                        {
                            continue;
                        }

                        var productUri = ItemUri.Parse(productUriValue);
                        if (productUri.ItemID.Equals(item.ID))
                        {
                            keysToRemove.Add(urlsCollection.Key as string);
                            break;
                        }
                    }
                }

                keysToRemove.ForEach(k => virtualProductResolver.ProductsUrlsCollection.Remove(k));
            }
        }
Exemplo n.º 3
0
        protected void Restore(object sender, EventArgs e)
        {
            var selectedItem = ListBox.SelectedItem;

            if (selectedItem == null)
            {
                return;
            }

            var uriText      = selectedItem.Value;
            var uri          = ItemUri.Parse(uriText);
            var db           = Factory.GetDatabase(uri.DatabaseName);
            var dataProvider = db.GetDataProviders()
                               .OfType <CompositeDataProvider>()
                               .First();

            var headProvider = dataProvider
                               .HeadProvider;

            var itemDefinition = new ItemDefinition(uri.ItemID, string.Empty, Data.ID.Undefined, Data.ID.Undefined);
            var callContext    = new CallContext(db.DataManager, 1);

            headProvider.DeleteItem(itemDefinition, callContext);
            db.RemoveFromCaches(uri.ItemID);

            var parentId = dataProvider.GetParentID(itemDefinition, callContext);

            db.RemoveFromCaches(parentId);

            ListBox.Items.Remove(selectedItem);
        }
Exemplo n.º 4
0
        /// <summary>Closes this dialog.</summary>
        /// <param name="uploadedItemsRaw">The uploaded items raw.</param>
        public void Close(string uploadedItemsRaw)
        {
            Assert.ArgumentNotNull((object)uploadedItemsRaw, "uploadedItemsRaw");
            ListString listString = new ListString(uploadedItemsRaw);

            if (uploadedItemsRaw == "undefined" || listString.Count == 0)
            {
                base.OK_Click();
            }
            else
            {
                ItemUri itemUri = ItemUri.Parse(listString[0]);
                Assert.IsNotNull((object)itemUri, "uri");
                if (WebUtil.GetQueryString("edit") == "1")
                {
                    UrlString urlString = new UrlString("/sitecore/shell/Applications/Content Manager/default.aspx");
                    urlString["fo"]    = itemUri.ItemID.ToString();
                    urlString["mo"]    = "popup";
                    urlString["wb"]    = "0";
                    urlString["pager"] = "0";
                    urlString[Sitecore.Configuration.State.Client.UsesBrowserWindowsQueryParameterName] = WebUtil.GetQueryString(Sitecore.Configuration.State.Client.UsesBrowserWindowsQueryParameterName, "0");
                    urlString.Add("sc_content", WebUtil.GetQueryString("sc_content"));
                    SheerResponse.ShowModalDialog(urlString.ToString(), string.Equals(Sitecore.Context.Language.Name, "ja-jp", StringComparison.InvariantCultureIgnoreCase) ? "1115" : "955", "560");
                }
                SheerResponse.SetDialogValue(itemUri.ItemID.ToString());
                base.OK_Click();
            }
        }
Exemplo n.º 5
0
        protected override void OnOK(object sender, EventArgs args)
        {
            if (this.ItemList.Items.Length == 0)
            {
                Context.ClientPage.ClientResponse.Alert(MessageNoItemsSelected);
                return;
            }

            List <MigrationWorker.ItemReference> itemsToProcess = new List <MigrationWorker.ItemReference>();

            foreach (ListviewItem item in this.ItemList.Items)
            {
                string[] textArray = item.Value.Split(new char[] { ':' }, 2);
                ItemUri  uri       = ItemUri.Parse(textArray[1]);
                if (uri != null)
                {
                    itemsToProcess.Add(new MigrationWorker.ItemReference(uri, textArray[0] == "recursive"));
                }
            }

            bool convertToBlob = this.TargetGroup.Value.Equals(ConvertToBlob, StringComparison.InvariantCultureIgnoreCase);
            Job  job           = MigrationWorker.CreateJob(itemsToProcess.ToArray(), convertToBlob);

            JobManager.Start(job);
            string url = "/sitecore/shell/default.aspx?xmlcontrol=MediaConversionToolWorkingForm&handle=" + job.Handle;

            SheerResponse.SetLocation(url);
        }
Exemplo n.º 6
0
        private void PopulateAvailableColumns()
        {
            var handle = UrlHandle.Get();

            var itemUri = ItemUri.Parse(handle["id"]);

            var item = Sitecore.Data.Database.GetItem(itemUri);

            if (item == null)
            {
                return;
            }

            try
            {
                var referenceItem = new ReferenceItem(item);
                var viewer        = BaseViewer.Create(referenceItem.FullType, string.Empty);
                if (viewer == null)
                {
                    return;
                }


                foreach (var availableColumn in viewer.AvailableColumns)
                {
                    ColumnName.Controls.Add(new ListItem {
                        Header = availableColumn, Value = availableColumn.ToLowerInvariant()
                    });
                }
            }
            catch (FileNotFoundException)
            {
                //todo
            }
        }
 protected override void OnLoad(EventArgs e)
 {
     base.OnLoad(e);
     if (!Sitecore.Context.ClientPage.IsEvent)
     {
         SetTestDetailsOptions options = SetTestDetailsOptions.Parse();
         DeviceId            = options.DeviceId;
         ContextItemUri      = ItemUri.Parse(options.ItemUri);
         RenderingUniqueId   = options.RenderingUniqueId;
         LayoutSessionHandle = options.LayoutSessionHandle;
         InitVariableValues();
         if (VariableValues.FindIndex(v => !string.IsNullOrEmpty(v.ReplacementComponent)) > -1)
         {
             ComponentReplacing.Checked = true;
         }
         else
         {
             Variations.Class = "hide-test-component";
         }
         if (VariableValues.Count > 0)
         {
             ResetContainer.Visible = true;
         }
         if (Rendering != null)
         {
             Item variableItem = TestingUtil.MultiVariateTesting.GetVariableItem(Rendering, Client.ContentDatabase);
             if ((variableItem != null) && !variableItem.Access.CanCreate())
             {
                 NewVariation.Disabled = true;
             }
         }
         SetControlsState();
         Render();
     }
 }
Exemplo n.º 8
0
        public Guid ReturnSourceID(IGlassBase i)
        {
            if (i == null)
            {
                return(Guid.Empty);
            }

            Item itm = _dependencies.SitecoreServiceMaster.GetItem <Item>(i._Id);

            if (itm == null)
            {
                return(Guid.Empty);
            }

            Field f = itm.Fields[Sitecore.FieldIDs.Source];

            if (f == null)
            {
                return(Guid.Empty);
            }

            if (!ItemUri.IsItemUri(f.Value))
            {
                return(Guid.Empty);
            }

            return(ItemUri.Parse(f.Value).ItemID.Guid);
        }
        /// <summary>Executes the  event.</summary>
        /// <param name="uploadedItems">The uploaded items.</param>
        protected void Done(string uploadedItems)
        {
            Assert.ArgumentNotNull((object)uploadedItems, "uploadedItems");
            List <Item> items = new List <Item>();
            string      str   = uploadedItems;

            char[] chArray = new char[1] {
                '|'
            };
            foreach (string itemUri1 in new ListString(str.TrimEnd(chArray)).Items)
            {
                ItemUri itemUri2 = ItemUri.Parse(itemUri1);
                Assert.IsNotNull((object)itemUri2, "uploaded uri");
                Database database = Factory.GetDatabase(itemUri2.DatabaseName);
                Assert.IsNotNull((object)database, "database");
                Item obj = database.GetItem(itemUri2.ToDataUri());
                if (obj != null)
                {
                    items.Add(obj);
                }
            }
            UploadedItems.Set(items);
            SheerResponse.Eval("document.body.parentNode.removeChild(document.body);");
            SheerResponse.Eval("scForm.getParentForm().postRequest('', '', '', 'item:refreshchildren(id=" + WebUtil.GetQueryString("id") + ")');");
            SheerResponse.Eval("scForm.getParentForm().postRequest('', '', '', 'item:refresh');");
        }
Exemplo n.º 10
0
        /// <summary>
        /// Gets the <see cref="ItemUri"/>s for the entries that have the most comments.
        /// </summary>
        /// <param name="item">The root blog item to search below.</param>
        /// <param name="maximumCount">The maximum number of entry <see cref="ItemUri"/>s to return.</param>
        /// <returns>The list of <see cref="ItemUri"/>s for the entries.</returns>
        public IList <ItemUri> GetMostCommentedEntries(Item item, int maximumCount)
        {
            if (item == null || maximumCount <= 0)
            {
                return(new ItemUri[0]);
            }

            var results = SearchComments <ItemUri>(item, queryable =>
            {
                if (!queryable.Any())
                {
                    return(new ItemUri[0]);
                }

                var facets       = queryable.FacetOn(x => x.EntryUri);
                var facetResults = facets.GetFacets();

                if (!facetResults.Categories.Any())
                {
                    return(new ItemUri[0]);
                }

                var orderedRawUris = facetResults.Categories[0].Values.OrderByDescending(x => x.AggregateCount).Where(x => x.AggregateCount != 0).Take(maximumCount).ToList();
                var parsedUris     = orderedRawUris.Select(x => ItemUri.Parse(x.Name));
                return(parsedUris.ToList());
            });

            return(results);
        }
 public static ItemUri ToItemUri(this string uri)
 {
     Assert.IsNotNullOrEmpty(uri, "Uri parameter is expected");
     uri = uri.DecodeUrl();
     Assert.IsTrue(ItemUri.IsItemUri(uri), "Uri parameter is not properly formed");
     return(ItemUri.Parse(uri));
 }
Exemplo n.º 12
0
        public void Run(ClientPipelineArgs args)
        {
            Item item       = Database.GetItem(ItemUri.Parse(args.Parameters["uri"]));
            bool isPostBack = args.IsPostBack;

            if (isPostBack)
            {
                isPostBack = !args.HasResult;
                if (!isPostBack)
                {
                    UrlHandle       urlHandle       = UrlHandle.Get(new UrlString(string.Concat("hdl=", args.Result)), "hdl", true);
                    string          str             = urlHandle["fields"];
                    FieldDescriptor fieldDescriptor = FieldDescriptor.Parse(str);
                    string          value           = fieldDescriptor.Value;
                    item.Editing.BeginEdit();
                    item.Fields[Data.ProjectFieldId].Value = value;
                    item.Editing.EndEdit();

                    String refresh = String.Format("item:refreshchildren(id={0})", item.Parent.ID);
                    Sitecore.Context.ClientPage.SendMessage(this, refresh);
                }
            }
            else
            {
                SheerResponse.ShowModalDialog(GetOptions(args, args.Parameters).ToUrlString().ToString(), "720", "320", string.Empty, true);
                args.WaitForPostBack();
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Gets the configured Field Editor options. Options determine both the look of Field Editor and the actual fields available for editing.
        /// </summary>
        /// <param name="args">The pipeline arguments. Current item URI is accessible as 'uri' parameter</param>
        /// <param name="form">The form values.</param>
        /// <returns>The options.</returns>
        protected override PageEditFieldEditorOptions GetOptions(ClientPipelineArgs args, NameValueCollection form)
        {
            List <FieldDescriptor> fieldDescriptors = new List <FieldDescriptor>();
            Item item = Database.GetItem(ItemUri.Parse(args.Parameters["uri"]));

            Assert.IsNotNull(item, "item");
            string fields = args.Parameters["fields"];

            Assert.IsNotNullOrEmpty(fields, "Field Editor command expects 'fields' parameter");
            string title = args.Parameters["title"];

            Assert.IsNotNullOrEmpty(title, "Field Editor command expects 'title' parameter");
            string icon = args.Parameters["icon"];

            Assert.IsNotNullOrEmpty(icon, "Field Editor command expects 'icon' parameter");

            foreach (string field in new ListString(fields))
            {
                if (item.Fields[field] != null)
                {
                    fieldDescriptors.Add(new FieldDescriptor(item, field));
                }
            }
            PageEditFieldEditorOptions options = new PageEditFieldEditorOptions(form, fieldDescriptors);

            options.Title = title;
            options.Icon  = icon;
            return(options);
        }
Exemplo n.º 14
0
        protected virtual void Run(ClientPipelineArgs args)
        {
            ItemUri itemUri = ItemUri.Parse(args.Parameters["uri"]);
            Item    item    = Database.GetItem(itemUri);

            Error.AssertItemFound(item);
            bool   flag = true;
            string str1 = string.Concat(Settings.DataFolder.TrimStart(new char[] { '/' }), "\\", Settings.GetSetting("Sitecore.Scientist.MediaExportImport.ExportFolderName", "MediaExports"));

            if (!IsValidPath(str1))
            {
                str1 = HttpContext.Current.Server.MapPath("~/") + str1;
            }
            str1 = str1.Replace("/", "\\");
            FileUtil.CreateFolder(FileUtil.MapPath(str1));
            var innerfolders = item.Paths.FullPath.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var folder in innerfolders)
            {
                str1 = str1 + "\\" + folder;
                FileUtil.CreateFolder(FileUtil.MapPath(str1));
            }
            Log.Info(string.Concat("Starting export of media items to: ", string.Concat(Settings.DataFolder.TrimStart(new char[] { '/' }), "\\", Settings.GetSetting("Sitecore.Scientist.MediaExportImport.ExportFolderName", "MediaExports"))), this);
            ProgressBoxMethod progressBoxMethod = new ProgressBoxMethod(StartProcess);

            object[] objArray = new object[] { item, str1, flag };
            ProgressBox.Execute("Export Media Items...", "Export Media Items", progressBoxMethod, objArray);
        }
        protected new void Run(ClientPipelineArgs args)
        {
            Item obj1 = Database.GetItem(ItemUri.Parse(args.Parameters["uri"]));

            if (obj1 == null)
            {
                SheerResponse.Alert("Item not found.");
            }
            else
            {
                string str = obj1.ID.ToString();
                if (args.IsPostBack)
                {
                    if (args.Result != "yes")
                    {
                        return;
                    }
                    Item obj2 = Context.ContentDatabase.GetItem(LinkManager.GetPreviewSiteContext(obj1).StartPath);
                    if (obj2 == null)
                    {
                        SheerResponse.Alert("Start item not found.");
                        return;
                    }
                    str = obj2.ID.ToString();
                }
                else if (!HasPresentationPipeline.Run(obj1))
                {
                    SheerResponse.Confirm("The current item cannot be previewed because it has no layout for the current device.\n\nDo you want to preview the start Web page instead?");
                    args.WaitForPostBack();
                    return;
                }
                SheerResponse.CheckModified(false);
                SiteContext previewSiteContext = LinkManager.GetPreviewSiteContext(obj1);
                if (previewSiteContext == null)
                {
                    SheerResponse.Alert(Translate.Text("Site \"{0}\" not found", Settings.Preview.DefaultSite));
                }
                else
                {
                    WebUtil.SetCookieValue(previewSiteContext.GetCookieKey("sc_date"), string.Empty);
                    PreviewManager.StoreShellUser(Settings.Preview.AsAnonymous);
                    UrlString urlString = new UrlString("/");
                    urlString["sc_itemid"]  = str;
                    urlString["sc_mode"]    = "preview";
                    urlString["sc_compare"] = "true";
                    urlString["sc_lang"]    = obj1.Language.ToString();
                    urlString["sc_site"]    = previewSiteContext.Name;
                    DeviceSimulationUtil.DeactivateSimulators();
                    if (UIUtil.IsChrome())
                    {
                        SheerResponse.Eval("setTimeout(function () { window.open('" + urlString + "', '_blank');}, 0);");
                    }
                    else
                    {
                        SheerResponse.Eval("window.open('" + urlString + "', '_blank');");
                    }
                }
            }
        }
Exemplo n.º 16
0
        internal void Run(StringList values)
        {
            if (string.IsNullOrEmpty(Command))
            {
                return;
            }

            List <Item> items       = new List <Item>();
            StringList  othervalues = new StringList();

            foreach (var val in values)
            {
                ItemUri uri = ItemUri.Parse(val);
                if (uri != null)
                {
                    items.Add(Sitecore.Data.Database.GetItem(uri));
                }
                else
                {
                    othervalues.Add(val);
                }
            }

            Command command = CommandManager.GetCommand(Command);

            Debug.Assert(command != null, Command + " not found.");

            // If our command can hanlde more than one item in the context we run it once
            if (!SingleItemContext)
            {
                CommandContext cc = new CommandContext(items.ToArray());
                cc.CustomData = othervalues;
                command.Execute(cc);
            }
            //otherwise we have to generate as many commands as items
            else
            {
                if (items.Count > 0)
                {
                    foreach (var item in items)
                    {
                        CommandContext cc = new CommandContext(item);
                        command.Execute(cc);
                    }
                }
                if (othervalues.Count > 0)
                {
                    foreach (var othervalue in othervalues)
                    {
                        CommandContext cc = new CommandContext();
                        cc.CustomData = othervalue;
                        command.Execute(cc);
                    }
                }
            }
        }
Exemplo n.º 17
0
        protected virtual void EnsureContext(ClientPipelineArgs args)
        {
            var path        = args.Parameters[PathParameter];
            var currentItem = Database.GetItem(ItemUri.Parse(args.Parameters[UriParameter]));

            currentItem = string.IsNullOrEmpty(path) ? currentItem : global::Sitecore.Client.ContentDatabase.GetItem(path);
            Assert.IsNotNull(currentItem, CurrentItemIsNull);
            CurrentItem           = currentItem;
            IncludeStandardFields = args.Parameters[IncludeStandardFieldsParameter] == "1";
        }
Exemplo n.º 18
0
    public static object GetObject(SearchResult hit)
    {
        Assert.ArgumentNotNull(hit, "hit");
        string url = hit.Url;

        if ((url != null) && url.StartsWith("sitecore:"))
        {
            return(Database.GetItem(Assert.ResultNotNull <ItemUri>(ItemUri.Parse(url), "Url is not a parseable URI")));
        }
        return(null);
    }
Exemplo n.º 19
0
 protected void OnOpen()
 {
     if (this.ItemList.GetSelectedItems().Length > 0)
     {
         var o   = this.ItemList.GetSelectedItems()[0].Value;
         var uri = ItemUri.Parse(o);
         if (uri != null)
         {
             Util.OpenItem(uri);
         }
     }
 }
        protected new void Run(ClientPipelineArgs args)
        {
            var contentItem = Database.GetItem(ItemUri.Parse(args.Parameters["uri"]));

            if (contentItem == null)
            {
                SheerResponse.Alert("Item not found.");
            }
            else
            {
                var itemId = contentItem.ID.ToString();
                if (args.IsPostBack)
                {
                    if (args.Result != "yes")
                    {
                        return;
                    }
                    var startItem = Context.ContentDatabase.GetItem(Context.Site.StartPath);
                    if (startItem == null)
                    {
                        SheerResponse.Alert("Start item not found.");
                        return;
                    }
                    if (!HasPresentationPipeline.Run(startItem))
                    {
                        SheerResponse.Alert("The start item cannot be previewed because it has no layout for the current device.\n\nPreview cannot be started.");
                        return;
                    }
                    itemId = startItem.ID.ToString();
                }
                else if (!HasPresentationPipeline.Run(contentItem))
                {
                    SheerResponse.Confirm("The current item cannot be previewed because it has no layout for the current device.\n\nDo you want to preview the start Web page instead?");
                    args.WaitForPostBack();
                    return;
                }
                SheerResponse.CheckModified(false);

                //Dynamically Speaking, we want the site of the item as it relates to a home Item.
                //If not found, fallback to default functionalty.
                var site = DynamicSiteManager.GetSiteContextByContentItem(contentItem) ??
                           Factory.GetSite(Settings.Preview.DefaultSite);
                Assert.IsNotNull(site, "Site \"{0}\" not found", Settings.Preview.DefaultSite);
                WebUtil.SetCookieValue(site.GetCookieKey("sc_date"), string.Empty);
                PreviewManager.StoreShellUser(Settings.Preview.AsAnonymous);
                var webSiteUrl = SiteContext.GetWebSiteUrl();
                webSiteUrl["sc_itemid"] = itemId;
                webSiteUrl["sc_mode"]   = "preview";
                webSiteUrl["sc_lang"]   = contentItem.Language.ToString();
                DeviceSimulationUtil.DeacitvateSimulators();
                SheerResponse.Eval("window.open('" + webSiteUrl + "', '_blank')");
            }
        }
Exemplo n.º 21
0
 protected void OnOpen()
 {
     if (ItemList.GetSelectedItems().Length > 0)
     {
         string  o   = ItemList.GetSelectedItems()[0].Value;
         ItemUri uri = ItemUri.Parse(o);
         if (uri != null)
         {
             Util.OpenItem(uri);
         }
     }
 }
Exemplo n.º 22
0
        protected virtual void EnsureContext(ClientPipelineArgs args)
        {
            var path        = args.Parameters[PathParameter];
            var currentItem = Database.GetItem(ItemUri.Parse(args.Parameters[UriParameter]));

            currentItem = string.IsNullOrEmpty(path) ? currentItem : Sitecore.Client.ContentDatabase.GetItem(path);
            Assert.IsNotNull(currentItem, CurrentItemIsNull);
            CurrentItem = currentItem;
            var settingsItem = Sitecore.Client.CoreDatabase.GetItem(args.Parameters[ButtonParameter]);

            Assert.IsNotNull(settingsItem, SettingsItemIsNull);
            SettingsItem = settingsItem;
        }
Exemplo n.º 23
0
        protected virtual void Run(ClientPipelineArgs args)
        {
            var  uri  = ItemUri.Parse(args.Parameters["uri"]);
            Item item = Database.GetItem(uri);

            Error.AssertItemFound(item);

            if (!args.IsPostBack)
            {
                UrlString urlString = ResourceUri.Parse("control:ExportMedia").ToUrlString();
                uri.AddToUrlString(urlString);
                SheerResponse.ShowModalDialog(urlString.ToString(), "280", "220", "", true);
                args.WaitForPostBack();
                return;
            }

            if (string.IsNullOrEmpty(args.Result) || args.Result == "undefined")
            {
                return;
            }

            string[] paramsArray    = args.Result.Split('|');
            string   exportFileName = paramsArray[0];

            if (string.IsNullOrWhiteSpace(exportFileName))
            {
                return;
            }

            bool recursive = extractRecursiveParam(paramsArray);

            string exportfolderName = Settings.DataFolder + "/" +
                                      Settings.GetSetting("SharedSource.MediaExporterModule.ExportFolderName", "MediaExports");

            string exportFileNameWithExtension = exportFileName.EndsWith(".zip") ? exportFileName : exportFileName + ".zip";

            FileUtil.CreateFolder(FileUtil.MapPath(exportfolderName));

            string zipPath = FileUtil.MapPath(FileUtil.MakePath(exportfolderName,
                                                                exportFileNameWithExtension,
                                                                '/'));

            Log.Info("Starting export of media items to: " + zipPath, this);
            Sitecore.Shell.Applications.Dialogs.ProgressBoxes.ProgressBox.Execute(
                "Export Media Items...",
                "Export Media Items",
                new Sitecore.Shell.Applications.Dialogs.ProgressBoxes.ProgressBoxMethod(StartProcess),
                new[] { item as object, zipPath, recursive });

            Context.ClientPage.ClientResponse.Download(zipPath);
        }
Exemplo n.º 24
0
        public override TElement MapToType <TElement>(Document document, SelectMethod selectMethod,
                                                      IEnumerable <IFieldQueryTranslator> virtualFieldProcessors,
                                                      IEnumerable <IExecutionContext> executionContexts,
                                                      SearchSecurityOptions securityOptions)
        {
            var typeOfTElement = typeof(TElement);

            if (!typeof(IItemWrapper).IsAssignableFrom(typeOfTElement))
            {
                return(base.MapToType <TElement>(document, selectMethod, virtualFieldProcessors, executionContexts,
                                                 securityOptions));
            }

            Guid itemId;
            Guid templateId;

            var fields = ExtractFieldsFromDocument(document, virtualFieldProcessors);

            if (fields.ContainsKey(Templates.Fields.Group) &&
                fields.ContainsKey(Templates.Fields.TemplateName) &&
                Guid.TryParse(fields[Templates.Fields.Group].ToString(), out itemId) &&
                Guid.TryParse(fields[Templates.Fields.TemplateName].ToString(), out templateId))
            {
                var item = Global.SpawnProvider.FromItem(itemId, templateId, typeOfTElement, fields);

                if (item is TElement)
                {
                    return((TElement)item);
                }
            }

            if (fields.ContainsKey(Templates.Fields.UniqueId))
            {
                var id = fields[Templates.Fields.UniqueId].ToString();

                var uri  = ItemUri.Parse(id);
                var item = Sitecore.Context.Database.GetItem(uri.ToDataUri());

                if (item != null)
                {
                    var mappedItem = Global.SpawnProvider.FromItem(item);
                    if (mappedItem is TElement)
                    {
                        return((TElement)mappedItem);
                    }
                }
            }

            return(default(TElement));
        }
Exemplo n.º 25
0
        protected void OnOpen()
        {
            if (ItemList.GetSelectedItems().Length <= 0)
            {
                return;
            }
            var o   = ItemList.GetSelectedItems()[0].Value;
            var uri = ItemUri.Parse(o);

            if (uri != null)
            {
                Util.OpenItem(uri);
            }
        }
Exemplo n.º 26
0
        protected void Load(string uri)
        {
            Assert.ArgumentNotNull(uri, "uri");
            var uri2 = ItemUri.Parse(uri);

            if (uri2 != null)
            {
                var item = Database.GetItem(uri2);
                if (item != null)
                {
                    SheerResponse.Eval(
                        string.Concat("scForm.getParentForm().invoke(\"ise:mruopen(id=", item.ID, ",language=",
                                      item.Language, ",version=", item.Version, ",db=", item.Database.Name, ")\")"));
                }
            }
        }
Exemplo n.º 27
0
        protected virtual void EnsureContext(ClientPipelineArgs args)
        {
#if !DEBUG
            //Ah.Compiler directives. This will not compile. Comment it out!
#endif

            var path        = args.Parameters[PathParameter];
            var currentItem = Database.GetItem(ItemUri.Parse(args.Parameters[UriParameter]));

            currentItem = string.IsNullOrEmpty(path) ? currentItem : Sitecore.Client.ContentDatabase.GetItem(path);
            Assert.IsNotNull(currentItem, CurrentItemIsNull);
            CurrentItem = currentItem;
            var settingsItem = Sitecore.Client.CoreDatabase.GetItem(args.Parameters[ButtonParameter]);
            Assert.IsNotNull(settingsItem, SettingsItemIsNull);
            SettingsItem = settingsItem;
        }
Exemplo n.º 28
0
        protected void Run(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");


            string[] uris = StringUtil.Split(args.Parameters["uris"], '|', false);
            if (args.IsPostBack)
            {
                if (args.HasResult)
                {
                    string result = args.Result;
                    if (result == "-")
                    {
                        result = string.Empty;
                    }

                    foreach (var uri in uris)
                    {
                        if (ItemUri.IsItemUri(uri))
                        {
                            Item item = Database.GetItem(ItemUri.Parse(uri));
                            item.Editing.BeginEdit();
                            item[FieldIDs.Owner] = result;
                            item.Editing.EndEdit();
                            Log.Audit(this, "Set owner: {0}", new string[] { AuditFormatter.FormatItem(item) });
                        }
                    }
                }
            }
            else
            {
                if (ItemUri.IsItemUri(uris[0]))
                {
                    ItemUri   uri  = ItemUri.Parse(uris[0]);
                    UrlString str6 = new UrlString("/sitecore/shell/~/xaml/Sitecore.Shell.Applications.Security.SetOwner.aspx");

                    str6.Append("id", uri.Path);
                    str6.Append("la", uri.Language.ToString());
                    str6.Append("vs", uri.Version.ToString());
                    str6.Append("db", uri.DatabaseName);
                    SheerResponse.ShowModalDialog(str6.ToString(), "450", "180", string.Empty, true);
                    args.WaitForPostBack();
                }
            }
        }
        public void Run(ClientPipelineArgs args)
        {
            if (!args.IsPostBack)
            {
                var item   = Sitecore.Data.Database.GetItem(ItemUri.Parse(args.Parameters["uri"]));
                var fields = new List <FieldDescriptor>();
                FieldEditorOptions options = new FieldEditorOptions(fields);
                options.SaveItem    = true;
                options.DialogTitle = "Item Bucket settings";
                foreach (var fieldDescriptor in GetFields(item).Select(s => new FieldDescriptor(item, s)))
                {
                    options.Fields.Add(fieldDescriptor);
                }
                Context.ClientPage.ClientResponse.ShowModalDialog(options.ToUrlString().ToString(), true);

                args.WaitForPostBack();
            }
        }
        protected FieldEditorOptions GetOptions(ClientPipelineArgs args, NameValueCollection form)
        {
            Item item = Database.GetItem(ItemUri.Parse(args.Parameters["uri"]));
            List <FieldDescriptor> fieldDescriptors = new List <FieldDescriptor>();

            fieldDescriptors.Add(new FieldDescriptor(item, Data.ProjectFieldId.ToString()));
            List <FieldDescriptor> fieldDescriptors1 = fieldDescriptors;

            Assert.IsNotNull(item, "item");
            FieldEditorOptions pageEditFieldEditorOption = new FieldEditorOptions(fieldDescriptors1);

            pageEditFieldEditorOption.Title       = "Select Project";
            pageEditFieldEditorOption.Icon        = "";
            pageEditFieldEditorOption.DialogTitle = "Select Project";
            FieldEditorOptions pageEditFieldEditorOption1 = pageEditFieldEditorOption;

            return(pageEditFieldEditorOption1);
        }