Beispiel #1
0
        /// <summary>
        /// Updates the links.
        /// </summary>
        /// <param name="root">The root.</param>
        /// <param name="currentItem">The current item.</param>
        /// <param name="mapping">The mapping.</param>
        private void UpdateLinks(Item root, Item currentItem, IDictionary <ID, string> mapping)
        {
            using (new EditContext(currentItem))
            {
                foreach (Field field in currentItem.Fields)
                {
                    ListString references = new ListString(field.Value);

                    if (references.All(ID.IsID))
                    {
                        ListString updatedReferences = new ListString();

                        foreach (string reference in references)
                        {
                            ID key = ID.Parse(reference);
                            if (mapping.ContainsKey(key))
                            {
                                updatedReferences.Add(root.Axes.GetDescendant(mapping[key]).ID.ToString());
                            }
                            else
                            {
                                updatedReferences.Add(reference);
                            }
                        }

                        field.Value = updatedReferences.ToString();
                    }
                }
            }

            foreach (Item child in currentItem.Children)
            {
                this.UpdateLinks(root, child, mapping);
            }
        }
        private void makeLink(string name, string icon, Item link)
        {
            ListString desktoplinks = new ListString(Registry.GetString("/Current_User/Desktop/Links"), '|');
            ListString parameters   = new ListString('^');

            parameters.Add(databasename);
            parameters.Add(link.ID.ToString());
            parameters.Add(name);
            parameters.Add(icon);
            desktoplinks.Add(parameters.ToString());
            Registry.SetString("/Current_User/Desktop/Links", desktoplinks.ToString());
            Sitecore.Context.ClientPage.ClientResponse.Alert("Link created. It will not appear until Desktop is refreshed");
        }
        /// <summary>
        /// Starts Building Indexes
        /// </summary>
        protected void StartRebuilding()
        {
            var str  = new ListString();
            var str2 = new ListString(this.IndexMap);

            foreach (string str3 in Context.ClientPage.ClientRequest.Form.Keys)
            {
                if (!string.IsNullOrEmpty(str3) && str3.StartsWith("dk_"))
                {
                    int index = str2.IndexOf(str3);
                    if (index >= 0)
                    {
                        str.Add(str2[index + 1]);
                    }
                }
            }

            Registry.SetString("/Current_User/Rebuild Search Index/Selected", str.ToString());


            var options2 = new JobOptions("RebuildSearchIndex", "index", Client.Site.Name,
                                          new Builder(str.ToString()), "Build")
            {
                AfterLife   = TimeSpan.FromMinutes(1.0),
                ContextUser = Context.User
            };
            var options = options2;
            var job     = JobManager.Start(options);

            Context.ClientPage.ServerProperties["handle"] = job.Handle.ToString();
            Context.ClientPage.ClientResponse.Timer("CheckStatus", 500);
        }
        /// <summary>
        /// Handles the grid row double click event.
        /// </summary>
        /// <param name="args">The arguments.</param>
        public virtual void AddButtonClick(GridCommandEventArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

            if (args.RowsID == null)
            {
                return;
            }

            var rowIDs = new ListString();
            var showProductGridItemDublicatedAlert = false;

            foreach (var id in args.RowsID.Cast <string>().Where(ID.IsID))
            {
                if (this.View.SelectedProducts.Contains(id))
                {
                    showProductGridItemDublicatedAlert = true;
                }
                else
                {
                    rowIDs.Add(id);
                }
            }

            if (rowIDs.Count > 0)
            {
                this.View.AddRowToSelectedProductsGrid(rowIDs.ToString());
            }

            if (showProductGridItemDublicatedAlert)
            {
                this.View.ShowProductGridItemDublicatedAlert();
            }
        }
    public string Execute(string itemLocators)
    {        
        Assert.ArgumentNotNullOrEmpty(itemLocators, "items");

        var masterVariablesReplacer = Configuration.Factory.GetMasterVariablesReplacer();

        var result = new ListString('|');

        foreach (var itemlocator in itemLocators.Split('|'))
        {
            var separator = itemlocator.IndexOf(':');
            var databaseName = itemlocator.Substring(0, separator);

            var database = Configuration.Factory.GetDatabase(databaseName);
            if (database == null) continue;            

            var item = database.GetItem(itemlocator.Substring(separator+1));
            if (item != null)
            {
                item.Fields.ReadAll();
                var revision = item[FieldIDs.Revision];
                using (new EditContext(item))
                {
                    masterVariablesReplacer.ReplaceItem(item);
                }
                if(item[FieldIDs.Revision] != revision)
                {
                    result.Add(string.Format("{0}:{1}",databaseName,item.ID));
                }
            }
        }
        return result.ToString();
    }
        /// <summary>
        /// Starts the rebuilding.
        /// </summary>
        protected virtual void StartRebuilding()
        {
            ListString databases = new ListString();
            ListString indexMap  = new ListString(this.IndexMap);

            foreach (string formKey in Sitecore.Context.ClientPage.ClientRequest.Form.Keys)
            {
                if (!string.IsNullOrEmpty(formKey) && formKey.StartsWith("dk_"))
                {
                    int index = indexMap.IndexOf(formKey);
                    if (index >= 0)
                    {
                        databases.Add(indexMap[index + 1]);
                    }
                }
            }

            Registry.SetString("/Current_User/Rebuild Search Index/Selected", databases.ToString());
            JobOptions options = new JobOptions("RebuildSearchIndex", "index", Client.Site.Name, new Builder(databases.ToString()), "Build")
            {
                AfterLife   = TimeSpan.FromMinutes(1.0),
                ContextUser = Sitecore.Context.User
            };
            Job job = JobManager.Start(options);

            Sitecore.Context.ClientPage.ServerProperties["handle"] = job.Handle.ToString();
            Sitecore.Context.ClientPage.ClientResponse.Timer("CheckStatus", 500);
        }
Beispiel #7
0
        /// <summary>
        /// Builds the Checkboxes to select indexes
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="header">The header.</param>
        /// <param name="selected">The selected.</param>
        /// <param name="indexMap">The index map.</param>
        private void BuildIndexCheckbox(string name, string header, ListString selected, ListString indexMap)
        {
            Assert.ArgumentNotNull(name, "name");
            Assert.ArgumentNotNull(header, "header");
            Assert.ArgumentNotNull(selected, "selected");
            Assert.ArgumentNotNull(indexMap, "indexMap");
            var child = new Checkbox();

            this.indexes.Controls.Add(child);
            child.ID      = Control.GetUniqueID("dk_");
            child.Header  = header;
            child.Value   = name;
            child.Checked = selected.Contains(name);
            indexMap.Add(child.ID);
            indexMap.Add(name);
            this.indexes.Controls.Add(new LiteralControl("<br />"));
        }
Beispiel #8
0
        /// <summary>
        /// Formats the parameters.
        /// </summary>
        /// <param name="keyParams">The parameters.</param>
        private void FormatParameters([NotNull] IEnumerable keyParams)
        {
            Debug.ArgumentNotNull(keyParams, "keyParams");

            var list = new ListString();

            foreach (var param in keyParams)
            {
                if ((param == null) || string.IsNullOrEmpty(param.ToString()))
                {
                    list.Add("Not defined");
                    continue;
                }

                list.Add(param.ToString());
            }

            this.formattedParameters = list.ToString();
        }
Beispiel #9
0
        /// <summary>
        /// Gets the fields.
        /// </summary>
        /// <param name="fields">The fields.</param>
        /// <returns>Returns a collection of field for edit.</returns>
        protected virtual string GetFields(StringCollection fields)
        {
            ListString ls = new ListString();

            foreach (string fieldId in fields)
            {
                ls.Add(fieldId);
            }

            return(ls.ToString());
        }
        private void MakeLink(string name, string icon, Item link)
        {
            var desktoplinks = new ListString(Registry.GetString("/Current_User/Desktop/Links"), '|');
            var parameters   = new ListString('^')
            {
                Databasename, link.ID.ToString(), name, icon
            };

            desktoplinks.Add(parameters.ToString());
            Registry.SetString("/Current_User/Desktop/Links", desktoplinks.ToString());
            Sitecore.Context.ClientPage.ClientResponse.Alert(Translate.Text(ConfirmationMessage));
        }
Beispiel #11
0
 // Method to add an element to the collections.
 public void Add(Monarchy monarchy)
 {
     try
     {
         ListState.Add(monarchy.BaseState);
         ListString.Add(monarchy.BaseState.ToString());
         DictionaryState.Add(monarchy.BaseState, monarchy);
         DictionaryString.Add(monarchy.BaseState.ToString(), monarchy);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
 }
Beispiel #12
0
        public void ListString_ManageItems()
        {
            ListString list = new ListString();

            Assert.AreEqual(0, list.Count);

            list.Add("Item1");
            Assert.AreEqual(1, list.Count);

            Assert.AreEqual("Item1", list.Get(0));

            list.Remove(0);
            Assert.AreEqual(0, list.Count);
        }
Beispiel #13
0
        /// <summary>
        /// Starts the publisher.
        ///
        /// </summary>
        protected void StartPublisher()
        {
            Language[]  languages         = GetLanguages();
            List <Item> publishingTargets = GetPublishingTargets();

            Database[] publishingTargetDatabases = GetPublishingTargetDatabases();
            bool       incremental     = Context.ClientPage.ClientRequest.Form["PublishMode"] == "IncrementalPublish";
            bool       smart           = Context.ClientPage.ClientRequest.Form["PublishMode"] == "SmartPublish";
            bool       republish       = Context.ClientPage.ClientRequest.Form["PublishMode"] == "Republish";
            bool       rebuild         = this.Rebuild;
            bool       childrenChecked = this.PublishChildren.Checked;
            bool       relatedChecked  = this.PublishRelatedItems.Checked;

            if (rebuild)
            {
                Log.Audit(this, "Rebuild database, databases: {0}", new string[] { StringUtil.Join(publishingTargetDatabases, ", ") });
            }
            else
            {
                Log.Audit(this, "Publish, languages:{0}, targets:{1}, databases:{2}, incremental:{3}, smart:{4}, republish:{5}, children:{6}, related:{7}", StringUtil.Join(languages, ", "), StringUtil.Join(publishingTargets, ", ", "Name"), StringUtil.Join(publishingTargetDatabases, ", "), MainUtil.BoolToString(incremental), MainUtil.BoolToString(smart), MainUtil.BoolToString(republish), MainUtil.BoolToString(childrenChecked), MainUtil.BoolToString(relatedChecked));
            }
            var listString1 = new ListString();

            foreach (Language language in languages)
            {
                listString1.Add(language.ToString());
            }
            Registry.SetString("/Current_User/Publish/Languages", listString1.ToString());
            var listString2 = new ListString();

            foreach (Item obj in publishingTargets)
            {
                listString2.Add(obj.ID.ToString());
            }
            Registry.SetString("/Current_User/Publish/Targets", listString2.ToString());
            Registry.SetBool("/Current_User/Publish/IncrementalPublish", incremental);
            Registry.SetBool("/Current_User/Publish/SmartPublish", smart);
            Registry.SetBool("/Current_User/Publish/Republish", republish);
            Registry.SetBool("/Current_User/Publish/PublishChildren", childrenChecked);
            Registry.SetBool("/Current_User/Publish/PublishRelatedItems", relatedChecked);
            this.JobHandle = (string.IsNullOrEmpty(this.ItemID) ? (!incremental ? (!smart ? (!rebuild ? PublishManager.Republish(Sitecore.Client.ContentDatabase, publishingTargetDatabases, languages, Context.Language) : PublishManager.RebuildDatabase(Sitecore.Client.ContentDatabase, publishingTargetDatabases)) : PublishManager.PublishSmart(Sitecore.Client.ContentDatabase, publishingTargetDatabases, languages, Context.Language)) : PublishManager.PublishIncremental(Sitecore.Client.ContentDatabase, publishingTargetDatabases, languages, Context.Language)) : PublishManager.PublishItem(Sitecore.Client.GetItemNotNull(this.ItemID), publishingTargetDatabases, languages, childrenChecked, smart, relatedChecked)).ToString();
            SheerResponse.Timer("CheckStatus", Settings.Publishing.PublishDialogPollingInterval);
        }
Beispiel #14
0
        public static NameValueCollection Start(string pipelineName, ClientPipelineArgs args, Database database, Item[] items)
        {
            Assert.ArgumentNotNullOrEmpty(pipelineName, "pipelineName");
            Assert.ArgumentNotNull(args, "args");
            Assert.ArgumentNotNull(database, "database");
            Assert.ArgumentNotNull(items, "items");
            NameValueCollection values = new NameValueCollection();
            ListString          str    = new ListString('|');

            for (int i = 0; i < items.Length; i++)
            {
                str.Add(items[i].ID.ToString());
            }
            values.Add("database", database.Name);
            values.Add("items", str.ToString());
            args.Parameters = values;
            Context.ClientPage.Start(pipelineName, args);
            return(values);
        }
Beispiel #15
0
        /// <summary>
        /// Gets the value.
        ///
        /// </summary>
        ///
        /// <returns>
        /// The value of the field.
        /// </returns>
        /// <contract><ensures condition="not null"/></contract>
        public string GetValue()
        {
            var listString = new ListString();
            var listbox    = FindControl(GetViewStateString("ID") + "_selected") as Listbox;

            Assert.IsNotNull(listbox, typeof(Listbox));
            foreach (ListItem control in listbox.Items)
            {
                string[] strArray = control.Value.Split(new char[1]
                {
                    '|'
                });
                if (strArray.Length > 1)
                {
                    listString.Add(strArray[1]);
                }
            }
            return(listString.ToString());
        }
Beispiel #16
0
        /// <summary>
        /// Handles the Click event of the btnEmptyShoppingCart control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void btnEmptyShoppingCart_Click(object sender, EventArgs e)
        {
            uint       numberOfProducts    = 0;
            ListString shoppingCartContent = new ListString();

            foreach (ShoppingCartLine line in this.Cart.ShoppingCartLines)
            {
                shoppingCartContent.Add(line.Product.Code);
                numberOfProducts += line.Quantity;
            }

            AnalyticsUtil.ShoppingCartEmptied(shoppingCartContent.ToString(), numberOfProducts);

            this.Cart.ShoppingCartLines.Clear();

            ICheckOut checkOut = Sitecore.Ecommerce.Context.Entity.Resolve <ICheckOut>();

            if (checkOut is CheckOut)
            {
                ((CheckOut)checkOut).ResetCheckOut();
            }

            ItemUtil.RedirectToNavigationLink(ContinueShopping, false);
        }
Beispiel #17
0
        public override void Execute([NotNull] CommandContext context)
        {
            Assert.ArgumentNotNull(context, "context");

            var items = context.Items;

            Assert.IsNotNull(items, "items");

            if (!Settings.ItemCloning.Enabled || (items.Length <= 0))
            {
                return;
            }

            var item    = items[0];
            var itemIDs = new ListString('|');

            foreach (Item it in items)
            {
                itemIDs.Add(it.ID.ToString());
            }

            var parameters = new NameValueCollection();

            parameters.Add("database", item.Database.Name);
            parameters.Add("items", itemIDs.ToString());
            parameters.Add("language", item.Language.ToString());
            parameters.Add("mode", "smart");

            var clientPage = Context.ClientPage;

            Assert.IsNotNull(clientPage, "clientPage");

            clientPage.Start("uiCloneItems", new CopyItemsArgs {
                Parameters = parameters
            });
        }
Beispiel #18
0
        public string Execute(string itemLocators)
        {
            Assert.ArgumentNotNullOrEmpty(itemLocators, "items");

            var masterVariablesReplacer = Configuration.Factory.GetMasterVariablesReplacer();

            var result = new ListString('|');

            foreach (var itemlocator in itemLocators.Split('|'))
            {
                var separator    = itemlocator.IndexOf(':');
                var databaseName = itemlocator.Substring(0, separator);

                var database = Configuration.Factory.GetDatabase(databaseName);
                if (database == null)
                {
                    continue;
                }

                var item = database.GetItem(itemlocator.Substring(separator + 1));
                if (item != null)
                {
                    item.Fields.ReadAll();
                    var revision = item[FieldIDs.Revision];
                    using (new EditContext(item))
                    {
                        masterVariablesReplacer.ReplaceItem(item);
                    }
                    if (item[FieldIDs.Revision] != revision)
                    {
                        result.Add(string.Format("{0}:{1}", databaseName, item.ID));
                    }
                }
            }
            return(result.ToString());
        }
    /// <summary>
    /// Formats the parameters.
    /// </summary>
    /// <param name="keyParams">The parameters.</param>
    private void FormatParameters([NotNull] IEnumerable keyParams)
    {
      Debug.ArgumentNotNull(keyParams, "keyParams");

      var list = new ListString();

      foreach (var param in keyParams)
      {
        if ((param == null) || string.IsNullOrEmpty(param.ToString()))
        {
          list.Add("Not defined");
          continue;
        }

        list.Add(param.ToString());
      }

      this.formattedParameters = list.ToString();
    }
        /// <summary>
        /// Handles the grid row double click event.
        /// </summary>
        /// <param name="args">The arguments.</param>
        public virtual void AddButtonClick(GridCommandEventArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

              if (args.RowsID == null)
              {
            return;
              }

              var rowIDs = new ListString();
              var showProductGridItemDublicatedAlert = false;

              foreach (var id in args.RowsID.Cast<string>().Where(ID.IsID))
              {
            if (this.View.SelectedProducts.Contains(id))
            {
              showProductGridItemDublicatedAlert = true;
            }
            else
            {
              rowIDs.Add(id);
            }
              }

              if (rowIDs.Count > 0)
              {
            this.View.AddRowToSelectedProductsGrid(rowIDs.ToString());
              }

              if (showProductGridItemDublicatedAlert)
              {
            this.View.ShowProductGridItemDublicatedAlert();
              }
        }
		public string GetValue()
		{
			ListString str = new ListString();
			string viewStateString = base.GetViewStateString("ID");
			Listbox listbox = this.FindControl(viewStateString + "_selected") as Listbox;
			Assert.IsNotNull(listbox, typeof(Listbox));
			foreach (ListItem item in listbox.Items)
			{
				string[] strArray = item.Value.Split(new char[] { '|' });
				if (strArray.Length > 1)
				{
					str.Add(strArray[1]);
				}
			}
			return str.ToString();
		}
 /// <summary>
 /// Builds the Checkboxes to select indexes
 /// </summary>
 /// <param name="name">
 /// The name.
 /// </param>
 /// <param name="header">
 /// The header.
 /// </param>
 /// <param name="selected">
 /// The selected.
 /// </param>
 /// <param name="indexMap">
 /// The index map.
 /// </param>
 private void BuildIndexCheckbox(string name, string header, ListString selected, ListString indexMap)
 {
     Assert.ArgumentNotNull(name, "name");
     Assert.ArgumentNotNull(header, "header");
     Assert.ArgumentNotNull(selected, "selected");
     Assert.ArgumentNotNull(indexMap, "indexMap");
     var child = new Checkbox();
     this.Indexes.Controls.Add(child);
     child.ID = Control.GetUniqueID("dk_");
     child.Header = header;
     child.Value = name;
     child.Checked = true;//selected.Contains(name);
     indexMap.Add(child.ID);
     indexMap.Add(name);
     this.Indexes.Controls.Add(new LiteralControl("<br />"));
 }
Beispiel #23
0
        protected override void OnLoad(EventArgs e)
        {
            Assert.ArgumentNotNull(e, "e");

            if (!Sitecore.Context.ClientPage.IsEvent)
            {
                isEvent = false;
                Sitecore.Shell.Applications.ContentEditor.Checklist list = new Sitecore.Shell.Applications.ContentEditor.Checklist();
                this.Controls.Add(list);
                list.ID            = GetID("list");
                list.Source        = this.Source;
                list.ItemID        = ItemID;
                list.FieldName     = FieldName;
                list.TrackModified = TrackModified;
                list.Disabled      = this.Disabled;
                list.Value         = this.Value;


                Sitecore.Shell.Applications.ContentEditor.Text text = new Sitecore.Shell.Applications.ContentEditor.Text();
                this.Controls.AddAt(0, text);
                text.ID       = GetID("text");
                text.ReadOnly = true;
                text.Disabled = this.Disabled;

                Button b = new Button();
                this.Controls.Add(b);
                b.ID       = GetID("button");
                b.Disabled = this.Disabled;
                b.Click    = "checklist:selectplayer";
                b.Header   = "click me";

                this.Controls.Add(new LiteralControl(Sitecore.Resources.Images.GetSpacer(0x18, 16)));
            }
            else
            {
                Sitecore.Shell.Applications.ContentEditor.Checklist list = FindControl(GetID("list")) as Sitecore.Shell.Applications.ContentEditor.Checklist;
                if (list != null)
                {
                    ListString valueList = new ListString();
                    foreach (DataChecklistItem item in list.Items)
                    {
                        if (item.Checked)
                        {
                            valueList.Add(item.ItemID);
                        }
                    }
                    if (this.Value != valueList.ToString())
                    {
                        this.TrackModified = list.TrackModified;
                        //this.SetModified();
                    }
                    this.Value = valueList.ToString();
                }
            }
            base.OnLoad(e);

            if (!Sitecore.Web.UI.XamlSharp.Xaml.XamlControl.AjaxScriptManager.IsEvent)
            {
                SheerResponse.Alert("hey2", true);
            }
        }
        /// <summary>
        /// Handles the Click event of the btnEmptyShoppingCart control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void btnEmptyShoppingCart_Click(object sender, EventArgs e)
        {
            uint numberOfProducts = 0;
              ListString shoppingCartContent = new ListString();
              foreach (ShoppingCartLine line in this.Cart.ShoppingCartLines)
              {
            shoppingCartContent.Add(line.Product.Code);
            numberOfProducts += line.Quantity;
              }

              AnalyticsUtil.ShoppingCartEmptied(shoppingCartContent.ToString(), numberOfProducts);

              this.Cart.ShoppingCartLines.Clear();

              ICheckOut checkOut = Sitecore.Ecommerce.Context.Entity.Resolve<ICheckOut>();
              if (checkOut is CheckOut)
              {
            ((CheckOut)checkOut).ResetCheckOut();
              }

              ItemUtil.RedirectToNavigationLink(ContinueShopping, false);
        }
 protected void ToggleRibbonStrip(string id)
 {
     Assert.ArgumentNotNull(id, "id");
     ListString str = new ListString(UserOptions.ContentEditor.VisibleStrips);
     if (str.Count == 0)
     {
         Database database = Factory.GetDatabase("core", false);
         Assert.IsNotNull(database, typeof(Database));
         Item item = database.GetItem(ItemIDs.DefaultRibbon);
         Assert.IsNotNull(item, typeof(Ribbon));
         foreach (Item item2 in item.Children)
         {
             Item item3 = item2;
             if (item3.TemplateID == TemplateIDs.Reference)
             {
                 item3 = item3.Database.Items[item3["Reference"]];
             }
             if (item3["Hidden by default"] != "1")
             {
                 str.Add(item3.ID.ToString());
             }
         }
     }
     if (str.Contains(id))
     {
         if (str.Count > 1)
         {
             str.Remove(id);
         }
         else
         {
             SheerResponse.Alert("You cannot remove the last strip from the ribbon.", new string[0]);
         }
     }
     else
     {
         str.Add(id);
     }
     UserOptions.ContentEditor.VisibleStrips = str.ToString();
     this.Reload();
 }
 private void makeLink(string name, string icon, Item link)
 {
     ListString desktoplinks = new ListString(Registry.GetString("/Current_User/Desktop/Links"), '|');
     ListString parameters = new ListString('^');
     parameters.Add(databasename);
     parameters.Add(link.ID.ToString());
     parameters.Add(name);
     parameters.Add(icon);
     desktoplinks.Add(parameters.ToString());
     Registry.SetString("/Current_User/Desktop/Links", desktoplinks.ToString());
     Sitecore.Context.ClientPage.ClientResponse.Alert("Link created. It will not appear until Desktop is refreshed");
 }
        public void Execute(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            Assert.ArgumentNotNullOrEmpty(args.Parameters["database"], "args.Parameters[\"database\"]");
            Assert.ArgumentNotNullOrEmpty(args.Parameters["baseTemplateId"], "args.Parameters[\"baseTemplateId\"]");
            Assert.ArgumentNotNullOrEmpty(args.Parameters["fieldIds"], "args.Parameters[\"fieldIds\"]");
            Assert.ArgumentNotNullOrEmpty(args.Parameters["templateId"], "args.Parameters[\"templateId\"]");
            Database database = GetDatabase(args.Parameters["database"]);
            Item baseTemplate = database.GetItem(args.Parameters["baseTemplateId"]);
            SetBaseTemplateField(baseTemplate, TemplateIDs.StandardTemplate);
            IDictionary<SectionInformation, IList<Item>> sectionsWithFields = GetSectionsWithFields(database, args.Parameters["fieldIds"]);

            foreach (SectionInformation sectionInformation in sectionsWithFields.Keys)
            {
                IEnumerable<Item> fields = sectionsWithFields[sectionInformation];
                MoveFieldsToAppropriateSection(baseTemplate, sectionInformation, fields);
            }

            Item templateItem = database.GetItem(args.Parameters["templateId"]);
            ListString baseTemplateIDs = new ListString(templateItem[PullUpFieldsSettings.BaseTemplateFieldName], PullUpFieldsSettings.IDDelimiter);
            baseTemplateIDs.Add(baseTemplate.ID.ToString());
            SetBaseTemplateField(templateItem, baseTemplateIDs);
            Refresh(templateItem);
        }
Beispiel #28
0
        /// <summary>
        /// Gets the fields.
        /// </summary>
        /// <param name="fields">The fields.</param>
        /// <returns>Returns a collection of field for edit.</returns>
        protected virtual string GetFields(StringCollection fields)
        {
            ListString ls = new ListString();
              foreach (string fieldId in fields)
              {
            ls.Add(fieldId);
              }

              return ls.ToString();
        }
 private void MakeLink(string name, string icon, Item link)
 {
     var desktoplinks = new ListString(Registry.GetString("/Current_User/Desktop/Links"), '|');
     var parameters = new ListString('^') {Databasename, link.ID.ToString(), name, icon};
     desktoplinks.Add(parameters.ToString());
     Registry.SetString("/Current_User/Desktop/Links", desktoplinks.ToString());
     Sitecore.Context.ClientPage.ClientResponse.Alert(Translate.Text(ConfirmationMessage));
 }
		protected override void OnLoad(EventArgs e) {
			Assert.ArgumentNotNull(e, "e");
			
			if (!Sitecore.Context.ClientPage.IsEvent) {
				
				isEvent = false;
				Sitecore.Shell.Applications.ContentEditor.Checklist list = new Sitecore.Shell.Applications.ContentEditor.Checklist();
				this.Controls.Add(list);
				list.ID = GetID("list");
				list.Source = this.Source;
				list.ItemID = ItemID;
				list.FieldName = FieldName;
				list.TrackModified = TrackModified;
				list.Disabled = this.Disabled;
				list.Value = this.Value;


				Sitecore.Shell.Applications.ContentEditor.Text text = new Sitecore.Shell.Applications.ContentEditor.Text();
				this.Controls.AddAt(0, text);
				text.ID = GetID("text");
				text.ReadOnly = true;
				text.Disabled = this.Disabled;

				Button b = new Button();
				this.Controls.Add(b);
				b.ID = GetID("button");
				b.Disabled = this.Disabled;
				b.Click = "checklist:selectplayer";
				b.Header = "click me";

				this.Controls.Add(new LiteralControl(Sitecore.Resources.Images.GetSpacer(0x18, 16)));
			} else {
				Sitecore.Shell.Applications.ContentEditor.Checklist list = FindControl(GetID("list")) as Sitecore.Shell.Applications.ContentEditor.Checklist;
				if (list != null) {
					ListString valueList = new ListString();
					foreach (DataChecklistItem item in list.Items) {
						if (item.Checked) {
							valueList.Add(item.ItemID);
						}
					}
					if (this.Value != valueList.ToString()) {
						this.TrackModified = list.TrackModified;
						//this.SetModified();
					}
					this.Value = valueList.ToString();
				}
			}
			base.OnLoad(e);

			if (!Sitecore.Web.UI.XamlSharp.Xaml.XamlControl.AjaxScriptManager.IsEvent) {
				SheerResponse.Alert("hey2", true);
			}
		}
 protected void Validator_SuppressValidator(string markerId)
 {
     Assert.ArgumentNotNull(markerId, "markerId");
     Assert.IsTrue(UserOptions.ContentEditor.ShowValidatorBar, "Validator bar is switched off in Content Editor.");
     ValidatorCollection validators = ValidatorManager.GetValidators(ValidatorsMode.ValidatorBar, this.ValidatorsKey);
     var byMarkerID = validators.GetByMarkerID(markerId);
     if (byMarkerID != null)
     {
         Assert.IsNotNull(byMarkerID.ItemUri, "Item URI is null.");
         Item item = Database.GetItem(byMarkerID.ItemUri);
         if (item != null)
         {
             ListString str = new ListString(item["__Suppressed Validation Rules"]);
             Assert.IsNotNull(byMarkerID.ValidatorID, "Validator ID is null.");
             if (!str.Contains(byMarkerID.ValidatorID.ToString()))
             {
                 str.Add(byMarkerID.ValidatorID.ToString());
                 using (new SecurityDisabler())
                 {
                     item.Editing.BeginEdit();
                     item["__Suppressed Validation Rules"] = str.ToString();
                     item.Editing.EndEdit();
                 }
                 validators.Remove(byMarkerID);
                 WebUtil.SetSessionValue(this.ValidatorsKey + ValidatorsMode.ValidatorBar, validators);
                 SheerResponse.Eval("scContent.validate()");
             }
         }
     }
 }
        /// <summary>
        /// Starts the rebuilding.
        /// </summary>
        protected virtual void StartRebuilding()
        {
            ListString databases = new ListString();
              ListString indexMap = new ListString(this.IndexMap);
              foreach (string formKey in Sitecore.Context.ClientPage.ClientRequest.Form.Keys)
              {
            if (!string.IsNullOrEmpty(formKey) && formKey.StartsWith("dk_"))
            {
              int index = indexMap.IndexOf(formKey);
              if (index >= 0)
              {
            databases.Add(indexMap[index + 1]);
              }
            }
              }

              Registry.SetString("/Current_User/Rebuild Search Index/Selected", databases.ToString());
              JobOptions options = new JobOptions("RebuildSearchIndex", "index", Client.Site.Name, new Builder(databases.ToString()), "Build")
              {
            AfterLife = TimeSpan.FromMinutes(1.0),
            ContextUser = Sitecore.Context.User
              };
              Job job = JobManager.Start(options);
              Sitecore.Context.ClientPage.ServerProperties["handle"] = job.Handle.ToString();
              Sitecore.Context.ClientPage.ClientResponse.Timer("CheckStatus", 500);
        }
 public string GetValue()
 {
     ListString list = new ListString();
      string id = GetViewStateString("ID");
      Sitecore.Web.UI.HtmlControls.Listbox listbox = FindControl(id + "_selected") as Sitecore.Web.UI.HtmlControls.Listbox;
      Sitecore.Web.UI.HtmlControls.ListItem[] itemArray = listbox.Items;
      for (int i = 0; i < itemArray.Length; i++)
      {
     Sitecore.Web.UI.HtmlControls.ListItem item = itemArray[i];
     string[]pair  = item.Value.Split(new char[]{'|'});
     if(pair.Length <= 1)
     {
        continue;
     }
     list.Add(pair[1]);
      }
      return list.ToString();
 }
        /// <summary>
        /// Starts Building Indexes
        /// </summary>
        protected void StartRebuilding()
        {
            var str = new ListString();
            var str2 = new ListString(this.IndexMap);
            foreach (string str3 in Context.ClientPage.ClientRequest.Form.Keys)
            {
                if (!string.IsNullOrEmpty(str3) && str3.StartsWith("dk_"))
                {
                    int index = str2.IndexOf(str3);
                    if (index >= 0)
                    {
                        str.Add(str2[index + 1]);
                    }
                }
            }

            Registry.SetString("/Current_User/Rebuild Search Index/Selected", str.ToString());

                var options2 = new JobOptions("RebuildSearchIndex", "index", Client.Site.Name,
                                              new Builder(str.ToString()), "Build")
                {
                    AfterLife = TimeSpan.FromMinutes(1.0),
                    ContextUser = Context.User
                };
                var options = options2;
                var job = JobManager.Start(options);
                Context.ClientPage.ServerProperties["handle"] = job.Handle.ToString();
                Context.ClientPage.ClientResponse.Timer("CheckStatus", 500);
        }
    /// <summary>
    /// Updates the links.
    /// </summary>
    /// <param name="root">The root.</param>
    /// <param name="currentItem">The current item.</param>
    /// <param name="mapping">The mapping.</param>
    private void UpdateLinks(Item root, Item currentItem, IDictionary<ID, string> mapping)
    {
      using (new EditContext(currentItem))
      {
        foreach (Field field in currentItem.Fields)
        {
          ListString references = new ListString(field.Value);

          if (references.All(ID.IsID))
          {
            ListString updatedReferences = new ListString();
            
            foreach (string reference in references)
            {
              ID key = ID.Parse(reference);
              if (mapping.ContainsKey(key))
              {
                updatedReferences.Add(root.Axes.GetDescendant(mapping[key]).ID.ToString());
              }
              else
              {
                updatedReferences.Add(reference);
              }
            }

            field.Value = updatedReferences.ToString();
          }
        }
      }

      foreach (Item child in currentItem.Children)
      {
        this.UpdateLinks(root, child, mapping);
      }
    }
        protected override void OnOK(object sender, EventArgs args)
        {
            var selectedFields = new ListString();
            var fieldValue = "";
            foreach (var border in Fields.Controls.OfType<GridPanel>())
            {
                foreach (var checkbox in border.Controls.OfType<Checkbox>())
                {
                    if (checkbox.Checked)
                    {
                        selectedFields.Add(checkbox.Header);
                        var control = checkbox.Parent.FindControl(checkbox.ID.Replace("cb", "ta")) as HtmlTextArea;
                        if(control != null) fieldValue = control.Value;
                    }
                    
                }
            }

            if (WebUtil.GetQueryString("mode") == "rte")
            {
                if (selectedFields.Count > 0)
                {

                    var html = string.Format("<span field='{0}' itemid='{1}' style='{2}'>{3}</span>",
                            selectedFields,
                            Treeview.GetSelectionItem().ID,
                            Settings.SnippetStyle,
                            fieldValue
                        );
                    SheerResponse.Eval(
                        string.Concat(
                        "scClose(",                       
                        StringUtil.EscapeJavascriptString(html),
                        ")"
                        ));
                }
                else
                {
                    SheerResponse.Eval("scClose()");
                }
            }

            else
            {
                var fieldEditorOptions = FieldEditorOptions.Parse(WebUtil.GetQueryString("hdl"));
                var fieldField = fieldEditorOptions.Fields.SingleOrDefault(fd => fd.FieldID.Equals(new ID("{AC2FF529-BE03-439C-9EB6-E56A0D5E4123}"))); // Fields 

                if (fieldField != null)
                {
                    fieldField.ContainsStandardValue = false;

                    fieldField.Value = selectedFields.ToString();
                }

                var datasourceField = fieldEditorOptions.Fields.SingleOrDefault(fd => fd.FieldID.Equals(new ID("{0793DCFF-0EE7-48AD-B9D4-EF1DD24EB59B}"))); // Datasource
                if (datasourceField != null)
                {
                    datasourceField.ContainsStandardValue = false;
                    datasourceField.Value = Treeview.GetSelectionItem().Paths.FullPath;
                }


                SheerResponse.SetDialogValue(fieldEditorOptions.ToUrlHandle().ToHandleString());
                SheerResponse.CloseWindow();
            }



        }