protected void Run(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            var id   = args.Parameters["id"];
            var lang = args.Parameters["language"];
            var ver  = args.Parameters["version"];
            var item = Context.ContentDatabase.Items[id, Language.Parse(lang), Data.Version.Parse(ver)];

            if (Context.IsAdministrator || (item.Access.CanWrite() && (item.Locking.CanLock() || item.Locking.HasLock())))
            {
                if (item == null)
                {
                    SheerResponse.Alert("Item not found.", new string[0]);
                }
                else if (SheerResponse.CheckModified())
                {
                    SetupFallback(item);
                }
            }
        }
        /// <summary>
        /// Called when the active page changing.
        /// </summary>
        /// <param name="pageFrom">The page from.</param>
        /// <param name="pageTo">The page to.</param>
        /// <returns></returns>
        protected override bool ActivePageChanging(string pageFrom, ref string pageTo)
        {
            if ((pageFrom == "SelectPollName") && (pageTo == "PollOptions") && DMSPollIsExists)
            {
                SheerResponse.Alert(Translate.Text("Poll name duplicate"));
                return(false);
            }

            if ((pageFrom == "PollOptions") && (pageTo == "PollOptionsSettings") && (Results.Count == 0))
            {
                SheerResponse.Alert(Translate.Text("Enter dms poll options validator"));
                return(false);
            }
            if ((pageFrom == "PollOptionsSettings") && (pageTo == "PollPlaceholderSelect") && !ShowPageEditorFunctionality)
            {
                pageTo = "LastPage";
            }

            return(base.ActivePageChanging(pageTo, ref pageFrom));
        }
 protected void FieldChanged()
 {
     if (this.FieldsSection.Controls.Count >= 1)
     {
         System.Web.UI.Control control = this.FieldsSection.Controls[0];
         for (int i = control.Controls.Count - 1; i >= 0; i--)
         {
             TraceableCombobox combobox = control.Controls[i] as TraceableCombobox;
             if ((combobox != null) && combobox.ID.StartsWith("Field"))
             {
                 if ((combobox.GetList().Count > 0) && (combobox.Value[0] != '<'))
                 {
                     this.AddRow(combobox.ID.Substring("Field".Length));
                     SheerResponse.Refresh(this.FieldsSection);
                 }
                 break;
             }
         }
     }
 }
 /// <summary>
 /// Run Field Command
 /// </summary>
 /// <param name="args">
 /// The args.
 /// </param>
 protected void Run(ClientPipelineArgs args)
 {
     Assert.ArgumentNotNull(args, "args");
     if (SheerResponse.CheckModified())
     {
         var items = DeserializeItems(args.Parameters["items"]);
         var item  = items[0];
         if (item.TemplateID == TemplateIDs.TemplateField)
         {
             using (new EditContext(item, SecurityCheck.Disable))
             {
                 if (item.Fields[Util.Constants.IsTag].IsNotNull())
                 {
                     ((CheckboxField)item.Fields[Util.Constants.IsTag]).Checked = !((CheckboxField)item.Fields[Util.Constants.IsTag]).Checked;
                     Log.Info(item + " Field has been marked as a tag and will show up in Facet Results", this);
                 }
             }
         }
     }
 }
        /// <summary>
        /// Removes the selected item.
        ///
        /// </summary>
        protected void Remove()
        {
            if (Disabled)
            {
                return;
            }
            var viewStateString = GetViewStateString("ID");
            var listbox         = FindControl(viewStateString + "_selected") as Listbox;

            Assert.IsNotNull(listbox, typeof(Listbox));
            SheerResponse.Eval("scForm.browser.getControl('" + viewStateString + "_all').selectedIndex=-1");
            SheerResponse.Eval("scForm.browser.getControl('" + viewStateString + "_help').innerHTML=''");
            foreach (var listItem in listbox.Selected)
            {
                SheerResponse.Remove(listItem.ID);
                listbox.Controls.Remove(listItem);
            }
            SheerResponse.Refresh(listbox);
            SetModified();
        }
Esempio n. 6
0
        protected void OkClick()
        {
            var validateUser = true;
            var tokenAction  = SessionElevationManager.GetToken(AppName).Action;

            if (tokenAction == SessionElevationManager.TokenDefinition.ElevationAction.Confirm)
            {
                validateUser = false;
            }

            if (!validateUser || Membership.ValidateUser(Sitecore.Context.User?.Name ?? string.Empty, PasswordBox.Value))
            {
                SessionElevationManager.ElevateSessionToken(AppName);
                SheerResponse.CloseWindow();
            }
            else
            {
                SheerResponse.Alert(Texts.PowerShellSessionElevation_Could_not_validate);
            }
        }
 /// <summary>Sets the upload button availability.</summary>
 private void SetUploadButtonAvailability()
 {
     if (this.Tabs.Active == 1)
     {
         SheerResponse.Eval("document.getElementById('BtnUpload').style.display='';");
         Item selectionItem = this.MediaTreeview.GetSelectionItem();
         if (selectionItem != null && selectionItem.Access.CanCreate())
         {
             SheerResponse.Eval("document.getElementById('BtnUpload').disabled = false;");
         }
         else
         {
             SheerResponse.Eval("document.getElementById('BtnUpload').disabled = true;");
         }
     }
     else
     {
         SheerResponse.Eval("document.getElementById('BtnUpload').style.display='none';");
     }
 }
        protected void Run(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

            if (args.IsPostBack)
            {
                if (args.Result == "yes")
                {
                    Repository.DeleteAll();
                    AjaxScriptManager.Current.Dispatch("redirectmanager:redirectdeleted");
                }
            }
            else
            {
                SheerResponse.Confirm(
                    "WARNING: This will delete all redirects in the database. Do you want to continue?");

                args.WaitForPostBack();
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Executes the validation actions during changing the active page in the Wizard.
        /// </summary>
        /// <param name="page">The page that is being left.</param>
        /// <param name="newPage">The new page that is being entered.</param>
        private void PageChangingValidation(string page, ref string newPage)
        {
            if (page != "Options")
            {
                return;
            }

            if (this.CleanFilteredCustomButton.Checked && newPage == "Ready" &&
                string.IsNullOrEmpty(this.CleanFilteredCustomColumnEdit.Value))
            {
                SheerResponse.ShowError("Please, select a column to use filtering by custom rule!", string.Empty);
                newPage = page;
            }
            else if (this.BackupDatabaseButton.Checked && newPage == "Ready" &&
                     !Directory.Exists(Path.GetDirectoryName(this.BackupDatabaseLocationEdit.Value) ?? string.Empty))
            {
                SheerResponse.ShowError("Directory of the specified backup file does not exist!", string.Empty);
                newPage = page;
            }
        }
Esempio n. 10
0
        /// <summary>Called when this instance has queued.</summary>
        /// <param name="filename">The filename.</param>
        /// <param name="lengthString">The length string.</param>
        protected void OnQueued(string filename, string lengthString)
        {
            Assert.IsNotNullOrEmpty(filename, "filename");
            Assert.IsNotNullOrEmpty(lengthString, "lengthString");
            int  num = int.Parse(lengthString);
            long databaseUploadSize = Settings.Upload.MaximumDatabaseUploadSize;

            if ((long)num > databaseUploadSize)
            {
                string text = Translate.Text("The file \"{0}\" is too big to be uploaded.\n\nThe maximum size of a file that can be uploaded is {1}.", (object)filename, (object)MainUtil.FormatSize(databaseUploadSize));
                this.WarningMessage = text;
                SheerResponse.Alert(text);
            }
            else
            {
                SheerResponse.SetInnerHtml("FilenameText", filename + " (" + MainUtil.FormatSize((long)num) + ")");
                this.WarningMessage = string.Empty;
                SheerResponse.Eval("scUpload.start()");
            }
        }
Esempio n. 11
0
 protected override void ActivePageChanged(string page, string oldPage)
 {
     base.ActivePageChanged(page, oldPage);
     if (page == "Processing")
     {
         base.NextButton.Disabled   = true;
         base.BackButton.Disabled   = true;
         base.CancelButton.Disabled = true;
         this.SetLastRefreshDate();
         SheerResponse.Timer("StartJob", 10);
     }
     if (page == "Settings")
     {
         base.NextButton.Header = "Run";
     }
     else
     {
         base.NextButton.Header = "Next >";
     }
 }
Esempio n. 12
0
        /// <summary>
        /// Handles the message.
        /// </summary>
        /// <param name="message">The message.</param>
        public override void HandleMessage(Message message)
        {
            Assert.ArgumentNotNull(message, "message");
            base.HandleMessage(message);
            if (message["id"] != this.ID)
            {
                return;
            }

            switch (message.Name)
            {
            case "contentmultilist:selectall":
                SheerResponse.Eval("SortableMultilistSelectAll('" + this.ID + "')");
                break;

            case "contentmultilist:unselectall":
                SheerResponse.Eval("SortableMultilistDeselectAll('" + this.ID + "', true)");
                break;
            }
        }
        protected void StartImport()
        {
            var dataSyncItem = GetDataSyncItem();

            var               dataSyncManager = new DataSyncManager();
            LevelLogger       logger          = Manager.CreateLogger(dataSyncItem);
            OutputHandlerBase exporter        = Manager.CreateOutputHandler(dataSyncItem, logger);

            logger.AddKey(Utility.Constants.DataSyncItemId, dataSyncItem.ID.ToString());
            logger.AddData(Utility.Constants.DataSyncItem, dataSyncItem);
            var map = dataSyncManager.InstantiateDataMap(dataSyncItem, ref logger);

            if (map != null)
            {
                if (!String.IsNullOrEmpty(DataValue))
                {
                    map.Data = DataValue;
                }
                var options = new JobOptions("FromFileDataSyncWizard", "Job category name", Context.Site.Name, new FromFileDataSyncWizard(), "Run", new object[] { map, map.Logger, exporter });
                var job     = JobManager.Start(options);
                job.Options.CustomData = map.Logger;
                JobHandle = job.Handle.ToString();
                SheerResponse.Timer("CheckStatus", 5);
            }
            else
            {
                Active = "LastPage";
                BackButton.Disabled = true;
                if (logger.HasErrorsOrInfos())
                {
                    if (exporter != null)
                    {
                        ResultText.Value = exporter.Export();
                    }
                    else
                    {
                        ResultText.Value = "The Exporter class was null. Therefor the log was not written out.";
                    }
                }
            }
        }
        /// <summary>
        /// Handles a click on the OK button. Creates a task for publishing the selected item.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="args">The arguments.</param>
        protected override void OnOK(object sender, EventArgs args)
        {
            Assert.ArgumentNotNull(sender, "sender");
            Assert.ArgumentNotNull(args, "args");

            using (new LanguageSwitcher(LanguageManager.DefaultLanguage))
            {
                PublishSchedule publishSchedule = new PublishSchedule
                {
                    ItemToPublish       = InnerItem,
                    PublishDate         = SelectedPublishDate,
                    SourceDatabase      = _database,
                    TargetDatabases     = SelectedTargets,
                    TargetLanguages     = SelectedLanguages,
                    Unpublish           = Unpublish,
                    PublishMode         = SmartPublish.Checked ? PublishMode.Smart : PublishMode.Full,
                    PublishChildren     = PublishChildren.Checked,
                    PublishRelatedItems = PublishRelatedItems.Checked,
                    SchedulerUsername   = Context.User.Name,
                    RecurrenceType      = RecurrenceType,
                    HoursToNextPublish  = HoursToNextPublishValue,
                    IsPublished         = false
                };

                if (Unpublish)
                {
                    publishSchedule.TargetLanguages = LanguageManager.GetLanguages(_database);
                }

                ValidationResult validationResult = ScheduledPublishValidator.Validate(publishSchedule);
                if (!validationResult.IsValid)
                {
                    SheerResponse.Alert(string.Join(Environment.NewLine, validationResult.ValidationErrors));
                    return;
                }

                _scheduledPublishRepo.CreatePublishSchedule(publishSchedule);
            }

            base.OnOK(sender, args);
        }
Esempio n. 15
0
        protected void Run(ClientPipelineArgs args)
        {
            var db          = ContentHelper.GetContentDatabase();
            var currentItem = db.GetItem(args.Parameters["currentid"]);

            if (args.IsPostBack)
            {
                if (args.HasResult)
                {
                    string itemTitle = args.Result;

                    var blogItem = ManagerFactory.BlogManagerInstance.GetCurrentBlog(currentItem);

                    if (blogItem == null)
                    {
                        SheerResponse.Alert("Failed to locate the blog item to add the category to.", true);
                        return;
                    }

                    var template   = new TemplateID(blogItem.BlogSettings.CategoryTemplateID);
                    var categories = ManagerFactory.CategoryManagerInstance.GetCategoryRoot(currentItem);
                    ItemManager.AddFromTemplate(itemTitle, template, categories);

                    SheerResponse.Eval("scForm.browser.getParentWindow(scForm.browser.getFrameElement(window).ownerDocument).location.reload(true)");

                    args.WaitForPostBack(true);
                }
            }
            else
            {
                if (!currentItem.TemplateIsOrBasedOn(Settings.BlogTemplateID) && !currentItem.TemplateIsOrBasedOn(Settings.EntryTemplateID))
                {
                    Context.ClientPage.ClientResponse.Alert("Please create or select a blog first");
                }
                else
                {
                    SheerResponse.Input("Enter the name of your new category:", "", Sitecore.Configuration.Settings.ItemNameValidation, Translator.Text("'$Input' is not a valid name."), 100);
                    args.WaitForPostBack(true);
                }
            }
        }
Esempio n. 16
0
        protected void Edit(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

            if (Enabled)
            {
                if (args.IsPostBack)
                {
                    if (((args.Result != null) && (args.Result.Length > 0)) && (args.Result != "undefined"))
                    {
                        XmlDocument doc = XmlUtil.LoadXml(WebUtil.GetSessionString("ASR_COLUMNEDITOR"));
                        WebUtil.SetSessionValue("ASR_COLUMNEDITOR", null);

                        Value = doc.OuterXml;
                        SetModified();
                        Refresh();
                    }
                }
                else
                {
                    XmlDocument document = GetDocument();
                    WebUtil.SetSessionValue("ASR_COLUMNEDITOR", document.OuterXml);
                    UrlString urlString = new UrlString(UIUtil.GetUri("control:ColumnEditor"));
                    UrlHandle handle    = new UrlHandle();
                    string    value     = Value;
                    if (value == "__#!$No value$!#__")
                    {
                        value = string.Empty;
                    }
                    handle["value"] = value;
                    var item           = Sitecore.Context.Database.GetItem(Sitecore.Data.ID.Parse(ItemID));
                    var currentVersion = item.Versions.GetVersionNumbers().First(x => x.Number == ItemVersion);
                    handle["id"] =
                        new ItemUri(Sitecore.Data.ID.Parse(ItemID), Language.Parse(ItemLanguage), currentVersion,
                                    Sitecore.Context.ContentDatabase).ToString(ItemUriFormat.Uri);
                    handle.Add(urlString);
                    SheerResponse.ShowModalDialog(urlString.ToString(), "800px", "500px", string.Empty, true);
                    args.WaitForPostBack();
                }
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Edit Text Button
        /// </summary>
        /// <param name="args">
        /// The args.
        /// </param>
        private new void EditText(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            if (!this.Disabled)
            {
                if (args.IsPostBack)
                {
                    if ((args.Result != null) && (args.Result != "undefined"))
                    {
                        this.UpdateHtml(args);
                    }
                }
                else
                {
                    var url2 = new RichTextEditorUrl
                    {
                        Conversion = RichTextEditorUrl.HtmlConversion.DoNotConvert,
                        Disabled   = this.Disabled,
                        FieldID    = this.FieldID,
                        ID         = this.ID,
                        ItemID     = this.ItemID,
                        Language   = this.ItemLanguage,
                        Mode       = string.Empty,
                        Source     = this.Source,
                        Url        = "/sitecore/shell/Controls/Rich Text Editor/EditorPage.aspx",
                        Value      = this.Value,
                        Version    = this.ItemVersion
                    };
                    var urlReturn = url2.GetUrl().ToString();
                    if (this.GetViewStateString("Source").Contains("&"))
                    {
                        urlReturn = this.GetViewStateString("Source").Split('&').Aggregate(urlReturn, (current, queryString) => current + "&" + queryString);
                    }

                    this.handle = url2.Handle;
                    var id = MainUtil.GetMD5Hash(this.Source + this.ItemLanguage);
                    SheerResponse.Eval(string.Concat(new object[] { "scContent.editRichText(\"", urlReturn, "\", \"", id.ToShortID(), "\", ", StringUtil.EscapeJavascriptString(this.Value), ")" }));
                    args.WaitForPostBack();
                }
            }
        }
        protected void PrefabCreate(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            int selectedIndex = this.SelectedIndex;

            if (selectedIndex < 0)
            {
                return;
            }
            LayoutDefinition layoutDefinition = GetLayoutDefinition_exposed();
            var deviceRenderings = layoutDefinition.GetDevice(this.DeviceID);

            if (deviceRenderings?.Renderings == null)
            {
                return;
            }
            if (selectedIndex < 0 || selectedIndex >= deviceRenderings.Renderings.Count)
            {
                return;
            }

            if (!args.IsPostBack)
            {
                SheerResponse.Input("Name: ", "New Prefab", "New Prefab");
                args.WaitForPostBack();
            }
            else if (args.HasResult)
            {
                var name = args.Result;

                var item = UIUtil.GetItemFromQueryString(Client.ContentDatabase);

                // manipulate layoutDefinition via device reference
                var prefab = _prefabService.CreatePrefab(name, deviceRenderings, this.SelectedIndex, item);

                SheerResponse.Alert("Prefab Created");

                // TODO: Go Edit Prefab?
                return;
            }
        }
Esempio n. 19
0
        protected void Add()
        {
            if (this.Disabled)
            {
                return;
            }

            string viewStateString  = base.GetViewStateString("ID");
            FieldSuiteTreeviewEx ex = this.FindControl(viewStateString + "_all") as FieldSuiteTreeviewEx;
            Listbox listbox         = this.FindControl(viewStateString + "_selected") as Listbox;
            Item    selectionItem   = ex.GetSelectionItem();

            if (selectionItem == null)
            {
                SheerResponse.Alert("Select an item in the Content Tree.", new string[0]);
                return;
            }

            if (this.HasExcludeTemplateForSelection(selectionItem))
            {
                return;
            }

            if (this.IsDeniedMultipleSelection(selectionItem, listbox))
            {
                SheerResponse.Alert("You cannot select the same item twice.", new string[0]);
            }
            else if (this.HasIncludeTemplateForSelection(selectionItem))
            {
                SheerResponse.Eval("scForm.browser.getControl('" + viewStateString + "_selected').selectedIndex=-1");
                ListItem control = new ListItem
                {
                    ID = Sitecore.Web.UI.HtmlControls.Control.GetUniqueID("L")
                };
                Sitecore.Context.ClientPage.AddControl(listbox, control);
                control.Header = selectionItem.DisplayName;
                control.Value  = control.ID + "|" + selectionItem.ID;
                SheerResponse.Refresh(listbox);
                SetModified();
            }
        }
        /// <summary>
        /// Uploads the selected image to media-library and set value to image-field.
        /// </summary>
        /// <param name="args">ClientPipeline</param>
        protected void Run(ClientPipelineArgs args)
        {
            if (args.IsPostBack)
            {
                if (!(args.Result != "undefined"))
                {
                    return;
                }

                SelectedImageModel selectedImage = null;
                if (args.Result == "Finished")
                {
                    var selectedImageJson = args.Parameters[Templates.ImportImageClientPipeline.Parameters.SelectedImageJson];
                    selectedImage = _selectedImageModelMapper.MapJsonStringToSelectedImageModel(selectedImageJson);
                }
                else
                {
                    selectedImage = _selectedImageModelMapper.MapJsonStringToSelectedImageModel(args.Result);
                    args.Parameters.Add(Templates.ImportImageClientPipeline.Parameters.SelectedImageJson, args.Result);
                }

                if (selectedImage != null)
                {
                    _fotoWareImageJob.StartJob(selectedImage, args, this.ImportImageFinished);
                }
                else
                {
                    //image has to be exported to upload
                    FotoWareFieldsLog.WriteToLog("--- SelectImageImageFieldCommand: Selected image has to be exported before ---");
                    SheerResponse.Alert(_statusMessageService.GetImageMustBeExportedMessage());
                }
            }
            else
            {
                _fotoWareImageJob.ResetStatus();
                string url = UIUtil.GetUri("control:SelectImageFromFotoWareDialog");
                url = string.Format("{0}", (object)url);
                SheerResponse.ShowModalDialog(url, "1200", "750", "", true, "1200", "750", false);
                args.WaitForPostBack();
            }
        }
Esempio n. 21
0
        protected void Open(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            if (args.IsPostBack)
            {
                if (!args.HasResult)
                {
                    return;
                }
                var path = args.Result.Split(':');
                LoadItem(path[0], path[1]);
                UpdateRibbon();
            }
            else
            {
                const string icon     = "powershell/48x48/script.png";
                const string root     = ApplicationSettings.ScriptLibraryPath;
                const string selected = ApplicationSettings.ScriptLibraryPath;

                var str = selected;
                if (selected.EndsWith("/"))
                {
                    var obj = Context.ContentDatabase.Items[StringUtil.Left(selected, selected.Length - 1)];
                    if (obj != null)
                    {
                        str = obj.ID.ToString();
                    }
                }
                var urlString = new UrlString(UIUtil.GetUri("control:PowerShellScriptBrowser"));
                urlString.Append("id", selected);
                urlString.Append("fo", str);
                urlString.Append("ro", root);
                urlString.Append("he", Texts.PowerShellIse_Open_Open_Script);
                urlString.Append("txt", Texts.PowerShellIse_Open_Select_the_script_item_that_you_want_to_open_);
                urlString.Append("ic", icon);
                urlString.Append("btn", Sitecore.Texts.OPEN);
                urlString.Append("opn", "1");
                SheerResponse.ShowModalDialog(urlString.ToString(), true);
                args.WaitForPostBack();
            }
        }
Esempio n. 22
0
        protected override void OnOK(object sender, EventArgs args)
        {
            // Sitecore
            Assert.ArgumentNotNull(sender, "sender");
            Assert.ArgumentNotNull(args, "args");
            string mail = this.GetMail();

            if (mail == "__Canceled")
            {
                SheerResponse.Alert("The e-mail address is invalid.", Array.Empty <string>());
                return;
            }
            Packet packet = new Packet("link", Array.Empty <string>());

            LinkForm.SetAttribute(packet, "text", this.Text);
            LinkForm.SetAttribute(packet, "linktype", "mailto");
            LinkForm.SetAttribute(packet, "url", mail);
            LinkForm.SetAttribute(packet, "anchor", string.Empty);
            LinkForm.SetAttribute(packet, "title", this.Title);
            LinkForm.SetAttribute(packet, "class", this.Class);

            // Custom
            this.TrimComboboxControl(this.Goal);
            //LinkForm.SetAttribute(packet, LinkTrackerConstants.GoalTriggerAttName, this.TriggerGoal);
            LinkForm.SetAttribute(packet, LinkTrackerConstants.GoalAttributeName, this.Goal);
            //LinkForm.SetAttribute(packet, LinkTrackerConstants.GoalDataAttName, this.GoalData);

            this.TrimComboboxControl(this.PageEvent);
            //LinkForm.SetAttribute(packet, LinkTrackerConstants.PageEventTriggerAttName, this.TriggerPageEvent);
            LinkForm.SetAttribute(packet, LinkTrackerConstants.PageEventAttributeName, this.PageEvent);
            //LinkForm.SetAttribute(packet, LinkTrackerConstants.PageEventDataAttName, this.PageEventData);

            //this.TrimComboboxControl(this.Campaign);
            //LinkForm.SetAttribute(packet, LinkTrackerConstants.CampaignTriggerAttName, this.TriggerCampaign);
            //LinkForm.SetAttribute(packet, LinkTrackerConstants.CampaignAttributeName, this.Campaign);
            //LinkForm.SetAttribute(packet, LinkTrackerConstants.CampaignDataAttName, this.CampaignData);

            // Sitecore
            SheerResponse.SetDialogValue(packet.OuterXml);
            SheerResponse.CloseWindow();
        }
        protected new void Run(ClientPipelineArgs args)
        {
            Sitecore.Diagnostics.Assert.ArgumentNotNull(args, "args");
            Sitecore.Diagnostics.Assert.ArgumentNotNull(args.Parameters["id"], "id");
            Sitecore.Diagnostics.Assert.ArgumentNotNull(args.Parameters["language"], "language");
            Sitecore.Diagnostics.Assert.ArgumentNotNull(args.Parameters["version"], "version");

            if (!SheerResponse.CheckModified())
            {
                return;
            }

            Item item = Context.ContentDatabase.GetItem(
                args.Parameters["id"],
                Language.Parse(args.Parameters["language"]),
                Version.Parse(args.Parameters["version"]));

            if (item == null ||
                PublishingHelper.CanPublishItem(item, Sitecore.Context.User))
            {
                base.Run(args);
                return;
            }

            if (args.IsPostBack)
            {
                if (args.Result == "yes")
                {
                    base.Run(args);
                }

                return;
            }
            else
            {
                string msg = "You cannot publish this item.\n\nDo you want to publish any descendants that you can publish?";
                SheerResponse.Confirm(Translate.Text(msg));
                args.WaitForPostBack();
                return;
            }
        }
Esempio n. 24
0
        /// <summary>
        /// Insert Media
        /// </summary>
        protected override void InsertMedia()
        {
            // Check validation.
            if (!this.IsValid())
            {
                return;
            }

            //TODO:var item = this.GetItem();
            //IPlayerMarkupGenerator generator = MediaFrameworkContext.GetPlayerMarkupGenerator(item);

            var playerProperties = new PlayerProperties
            {
                ItemId = this.SourceItemID,
                //TODO:Template = item.TemplateID,
                //MediaId = generator.GetMediaId(item),
                PlayerId = new ID(this.PlayersList.Value),
                Width    = MainUtil.GetInt(this.WidthInput.Value, MediaFrameworkContext.DefaultPlayerSize.Width),
                Height   = MainUtil.GetInt(this.HeightInput.Value, MediaFrameworkContext.DefaultPlayerSize.Height)
            };

            var args = new MediaGenerateMarkupArgs
            {
                MarkupType = MarkupType.Link,
                Properties = playerProperties,
                LinkTitle  = this.LinkInput.Value
            };

            MediaGenerateMarkupPipeline.Run(args);
            switch (this.Mode)
            {
            case "webedit":
                SheerResponse.SetDialogValue(args.Result.Html);
                this.EndWizard();
                break;

            default:
                SheerResponse.Eval("scClose(" + StringUtil.EscapeJavascriptString(args.Result.Html) + ")");
                break;
            }
        }
Esempio n. 25
0
        /// <summary>
        /// Sitecore UI method that confirms to process
        /// </summary>
        public void Confirm(ClientPipelineArgs args)
        {
            if (!args.IsPostBack)
            {
                // Prompt the user to confirm they want to perform the action.
                SheerResponse.Confirm(
                    string.Format("Execute \"{0}\" on\r\n\r\n{1}\r\n\r\nand all descendants?",
                                  CommandName,
                                  _selectedItem.Paths.FullPath
                                  )
                    );

                // Pause the UI to force user to respond to the confirmation modal.
                args.WaitForPostBack();
            }
            else
            {
                // Current request is a post back
                if (!args.Result.Equals("yes", StringComparison.InvariantCultureIgnoreCase))
                {
                    // User did not click OK / Yes, so do nothing.
                    return;
                }

                // Validate the user selection.
                string message = string.Empty;
                if (!ValidateInput(_selectedItem, out message))
                {
                    // Selected sitecore item was not valid, show an alert.
                    ShowAlert(message);
                }
                else
                {
                    // Trigger the process method in the implementing / concrete command class.
                    int changeCount = Process(_selectedItem);

                    // Notify the user in the UI that the processing has completed.
                    ShowAlert(BuildCompletionMessage(changeCount));
                }
            }
        }
Esempio n. 26
0
        protected void EditPlaceholderPipeline(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            LayoutDefinition      definition  = LayoutDefinition.Parse(this.GetDoc().OuterXml);
            PlaceholderDefinition placeholder = definition.GetDevice(args.Parameters["deviceid"]).GetPlaceholder(args.Parameters["uniqueid"]);

            if (placeholder != null)
            {
                if (args.IsPostBack)
                {
                    if (!string.IsNullOrEmpty(args.Result) && (args.Result != "undefined"))
                    {
                        string str;
                        Item   item = SelectPlaceholderSettingsOptions.ParseDialogResult(args.Result, Client.ContentDatabase, out str);
                        if (item != null)
                        {
                            placeholder.MetaDataItemId = item.Paths.FullPath;
                        }
                        if (!string.IsNullOrEmpty(str))
                        {
                            placeholder.Key = str;
                        }
                        this.SetActiveLayout(definition.ToXml());
                        this.Refresh();
                    }
                }
                else
                {
                    Item item2 = string.IsNullOrEmpty(placeholder.MetaDataItemId) ? null : Client.ContentDatabase.GetItem(placeholder.MetaDataItemId);
                    SelectPlaceholderSettingsOptions options = new SelectPlaceholderSettingsOptions {
                        TemplateForCreating      = null,
                        PlaceholderKey           = placeholder.Key,
                        CurrentSettingsItem      = item2,
                        SelectedItem             = item2,
                        IsPlaceholderKeyEditable = true
                    };
                    SheerResponse.ShowModalDialog(options.ToUrlString().ToString(), "460px", "460px", string.Empty, true);
                    args.WaitForPostBack();
                }
            }
        }
 protected void Run(ClientPipelineArgs args)
 {
     Assert.ArgumentNotNull(args, "args");
     if (args.IsPostBack)
     {
         if (args.HasResult)
         {
             Database database = Factory.GetDatabase(args.Parameters["database"]);
             Assert.IsNotNull(database, "Database \"" + args.Parameters["database"] + "\" not found.");
             Item item = database.Items[args.Parameters["id"], Language.Parse(args.Parameters["language"]), Version.Parse(args.Parameters["version"])];
             var  searchStringModel = ExtractSearchQuery(args.Parameters["searchString"]);
             var  hitsCount         = 0;
             var  listOfItems       = item.Search(searchStringModel, out hitsCount).ToList();
             Assert.IsNotNull(item, "item");
             var result = args.Result;
             foreach (var item1 in listOfItems.Select(sitecoreItem => sitecoreItem.GetItem()))
             {
                 item1.Editing.BeginEdit();
                 if (item1.Name != "__Standard Values")
                 {
                     LayoutField.SetFieldValue(item1.Fields[FieldIDs.LayoutField], result);
                 }
                 else
                 {
                     item1[FieldIDs.LayoutField] = result;
                 }
                 item1.Editing.EndEdit();
                 Log.Audit(this, "Set layout details: {0}, layout: {1}", new [] { AuditFormatter.FormatItem(item1), result });
             }
         }
     }
     else
     {
         var str2 = new UrlString(UIUtil.GetUri("control:LayoutDetails"));
         str2.Append("id", args.Parameters["id"]);
         str2.Append("la", args.Parameters["language"]);
         str2.Append("vs", args.Parameters["version"]);
         SheerResponse.ShowModalDialog(str2.ToString(), true);
         args.WaitForPostBack();
     }
 }
Esempio n. 28
0
        private void RenderLayoutGridBuilder(string layoutValue, Control renderingContainer)
        {
            string str = renderingContainer.ID + "LayoutGrid";
            FriendlyLayoutGridBuilder builder = new FriendlyLayoutGridBuilder
            {
                ID    = str,
                Value = layoutValue,
                EditRenderingClick   = "EditRendering(\"$Device\", \"$Index\")",
                EditPlaceholderClick = "EditPlaceholder(\"$Device\", \"$UniqueID\")",
                OpenDeviceClick      = "OpenDevice(\"$Device\")",
                CopyToClick          = "CopyDevice(\"$Device\")"
            };

            renderingContainer.Controls.Clear();
            builder.BuildGrid(renderingContainer);
            if (Context.ClientPage.IsEvent)
            {
                SheerResponse.SetOuterHtml(renderingContainer.ID, renderingContainer);
                SheerResponse.Eval("if (!scForm.browser.isIE) { scForm.browser.initializeFixsizeElements(); }");
            }
        }
Esempio n. 29
0
        private void MonitorOnJobFinished(object sender, EventArgs eventArgs)
        {
            var args   = eventArgs as SessionCompleteEventArgs;
            var result = args.RunnerOutput;

            if (result != null)
            {
                PrintSessionUpdate(result.Output);
            }

            if (result?.Exception != null)
            {
                var error = ScriptSession.GetExceptionString(result.Exception, ScriptSession.ExceptionStringFormat.Html);
                PrintSessionUpdate($"<pre style='background:red;'>{error}</pre>");
            }
            SheerResponse.SetInnerHtml("PleaseWait", "");
            ProgressOverlay.Visible = false;
            ScriptRunning           = false;
            UpdateRibbon();
            SheerResponse.Eval("cognifide.powershell.scriptExecutionEnded()");
        }
Esempio n. 30
0
        // Delete select products using event of method
        protected void DeleteProducts()
        {
            if (ProductList.SelectedItems.Length > 0)
            {
                foreach (ListviewItem productItem in ProductList.SelectedItems)
                {
                    Item product = Factory.GetDatabase("master").GetItem(new ID(productItem.ColumnValues["Id"].ToString()));
                    product.Recycle();
                }

                ProductList.Controls.Clear();
                LoadProducts();
                ProductList.Refresh();

                SheerResponse.Alert("Selected products are deleted!");
            }
            else
            {
                SheerResponse.Alert("No product selected!");
            }
        }