Пример #1
0
 /// <summary>
 /// Add a new Content Editor Tab to Content Editor so that users can search for hidden content
 /// </summary>
 /// <param name="context">Context of Call</param>
 public override void Execute(CommandContext context)
 {
     Assert.ArgumentNotNull(context, "context");
     if (context.Items.Length == 1)
     {
         var itemId = context.Parameters[0];
         if (WebUtil.GetFormValue("scEditorTabs").Contains("contenteditor:launchtab") && WebUtil.GetFormValue("scEditorTabs").Contains(itemId))
         {
             SheerResponse.Eval("scContent.onEditorTabClick(null, null, '" + itemId + "')");
         }
         else
         {
             var urlString = new UrlString("/sitecore/shell/sitecore/content/Applications/Content%20Editor.aspx");
             urlString.Add(Util.Constants.OpenItemEditorQueryStringKeyName, itemId);
             TrackOpenTab(context);
             context.Items[0].Uri.AddToUrlString(urlString);
             UIUtil.AddContentDatabaseParameter(urlString);
             urlString.Add(Util.Constants.ModeQueryStringKeyName, "preview");
             urlString.Add(Util.Constants.RibbonQueryStringKeyName, "{D3A2D76F-02E6-49DE-BE90-D23C9771DC8D}");
             var language = context.Parameters["la"].IsNull() ? Sitecore.Context.Language.CultureInfo.TwoLetterISOLanguageName : context.Parameters["la"];
             urlString.Add("la", language);
             AddLatestVersionToUrlString(urlString, itemId, language);
             SheerResponse.Eval(new ShowEditorTab { Command = "contenteditor:launchtab", Header = Translate.Text(Context.ContentDatabase.GetItem(itemId).Name), Icon = Images.GetThemedImageSource("Applications/16x16/text_view.png"), Url = urlString.ToString(), Id = itemId, Closeable = true, Activate = Util.Constants.SettingsItem.Fields[Util.Constants.OpenSearchResult].Value == "New Tab Not Selected" ? false : true }.ToString());
         }
     }
 }
		public void Edit(ClientPipelineArgs args)
		{
			if (args.IsPostBack)
			{
				if (!args.HasResult)
					return;

				Value = args.Result;
				SetModified();
				SheerResponse.Refresh(this);
			}
			else
			{
				Assert.IsNotNull(DialogUrl, "Dialog URL");

				var urlString = new UrlString(UIUtil.GetUri(DialogUrl));
				var itemUri = new ItemUri(ItemId, Sitecore.Configuration.Factory.GetDatabase("master"));
				var fieldItem = Sitecore.Context.ContentDatabase.GetItem(FieldId);


				urlString["itemUri"] = itemUri.ToString();
				urlString["fieldName"] = fieldItem.Name;

				Sitecore.Context.ClientPage.ClientResponse.ShowModalDialog(urlString.ToString(), "650px", "700px", string.Empty, true);

				args.WaitForPostBack();
			}
		}
Пример #3
0
        protected static void ShowIEModelessDialog(string url, int width, int height)
        {
            Assert.ArgumentNotNull(url, "url");
            if (!UIUtil.IsIE())
            {
                throw new InvalidOperationException("Operation can be performed only for IE browser");
            }
            string str = url;

            try
            {
                UrlString str2 = new UrlString(url);
                str2["mdls"] = "1";
                str          = str2.ToString();
            }
            catch
            {
                str = url;
            }
            SheerResponse.Eval("scForm.browser.closePopups('ShowModelessWindowCommand');");
            string str3 = "{scCalleeForm:scForm, scCalleePipeline:request.pipeline}";
            string str4 = string.Format("dialogWidth:{0}px;dialogHeight:{1}px;help:no;scroll:auto;resizable:yes;center:yes;status:no", width, height);

            SheerResponse.Eval(string.Format("window.showModelessDialog(\"{0}\", {1},\"{2}\");", str, str3, str4));
        }
Пример #4
0
        /// <summary>
        /// If CDN is enabled for this request, replace the outgoing media url with the cdn version
        /// </summary>
        /// <param name="item"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        public override string GetMediaUrl(Sitecore.Data.Items.MediaItem item, MediaUrlOptions options)
        {
            string hostname = CDNManager.GetCDNHostName();
            string url = base.GetMediaUrl(item, options);

            bool shouldReplace = !string.IsNullOrEmpty(hostname) && // cdnHostname exists for site
                Sitecore.Context.PageMode.IsNormal;  // PageMode is normal

            bool dontReplace = !CDNManager.IsMediaPubliclyAccessible(item) ||  // media is publicly accessible
                CDNManager.IsMediaAnalyticsTracked(item); // media is analytics tracked

            CDNUrlState contextState = CDNUrlSwitcher.CurrentValue;

            if (contextState == CDNUrlState.Enabled)
            {
                shouldReplace = true;
            }
            else if (contextState == CDNUrlState.Disabled)
            {
                UrlString url2 = new UrlString(url);
                url2[CDNManager.StopToken] = "1";
                url = url2.ToString();
                shouldReplace = false;
            }

            
            if (shouldReplace && !dontReplace) // media not DMS tracked
            {
                return CDNManager.ReplaceMediaUrl(url, hostname);
            }
            else
            {
                return url;
            }
        }
Пример #5
0
        public override void Execute(CommandContext context)
        {
            SheerResponse.DisableOutput();
            var subMenu = new ContextMenu();
            var menuItems = new List<Control>();
            var menuItemId = "iseSettingsDropdown"; //context.Parameters["Id"];

            if (string.IsNullOrEmpty(menuItemId))
            {
                // a bit of a hacky way to determine the caller so we can display the menu
                // in proximity to the triggering control
                var parameters = new UrlString("?" + Context.Items["SC_FORM"]);
                menuItemId = parameters.Parameters["__EVENTTARGET"];
            }

            var menuRootItem =
                Factory.GetDatabase("core")
                    .GetItem("/sitecore/content/Applications/PowerShell/PowerShellIse/Menus/Settings");
            GetMenuItems(menuItems, menuRootItem);

            foreach (var item in menuItems)
            {
                var menuItem = item as MenuItem;
                if (menuItem != null)
                {
                    var subItem = subMenu.Add(menuItem.ID, menuItem.Header, menuItem.Icon, menuItem.Hotkey,
                        menuItem.Click,
                        menuItem.Checked, menuItem.Radiogroup, menuItem.Type);
                    subItem.Disabled = menuItem.Disabled;
                }
            }
            SheerResponse.EnableOutput();
            subMenu.Visible = true;
            SheerResponse.ShowContextMenu(menuItemId, "down", subMenu);
        }
        protected void Run(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

            string dbName = args.Parameters["databasename"];
            string id = args.Parameters["id"];
            string lang = args.Parameters["language"];
            string ver = args.Parameters["version"];
            Database database = Factory.GetDatabase(dbName);

            Assert.IsNotNull(database, dbName);

            Item obj = database.Items[id, Language.Parse(lang), Version.Parse(ver)];
            if (obj == null)
            {
                SheerResponse.Alert("Item not found.");
            }
            else
            {
                if (!SheerResponse.CheckModified())
                    return;
                if (args.IsPostBack)
                {
                    return;
                }

                UrlString urlString = new UrlString(UIUtil.GetUri("control:SchedulePublish"));
                urlString.Append("id", obj.ID.ToString());
                urlString.Append("unpublish", args.Parameters["unpublish"]);
                SheerResponse.ShowModalDialog(urlString.ToString(), "600", "600", string.Empty, true);
                args.WaitForPostBack();
            }
        }
 protected virtual UrlString GetDialogUrl(string value)
 {
     var uri = UIUtil.GetUri("control:Sitecore.Shell.Applications.Dialogs.DateTimeSelectors.DateTimeSelectorEx");
     var url = new UrlString(uri);
     url["value"] = value;
     return url;
 }
Пример #8
0
        /// <summary>
        /// rewrite CDN urls from  /path/to/file!cf!a=1!b=2.ext to original form /path/to/file.ext?a=1&b=2
        /// </summary>
        /// <param name="args"></param>
        public override void Process(PreprocessRequestArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

            // rehydrate original url
            string fullPath = Sitecore.Context.RawUrl;
            var url = new UrlString(fullPath);

            // if this item is a minifiable css or js
            // rewrite for ~/minify handler
            if (CDNSettings.Enabled &&
                CDNSettings.MinifyEnabled &&
                url["min"] == "1" &&
                !url.Path.StartsWith(Settings.Media.DefaultMediaPrefix) &&
                (url.Path.EndsWith(".css") || url.Path.EndsWith(".js")))
            {
                args.Context.Items["MinifyPath"] = fullPath;   // set this for the Minifier handler
                args.Context.RewritePath("/~/minify" + url.Path, string.Empty, url.Query);  // rewrite with ~/minify to trigger custom handler
            }

            // NOTE: DOREL CHANGE: Commented to make WCF services (*.svc) workable
            //            else
            //            {
            //                args.Context.RewritePath(url.Path, string.Empty, url.Query); // rewrite proper url
            //            }
        }
Пример #9
0
        public void Process(WorkflowPipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            var processorItem = args.ProcessorItem;
            if (processorItem == null)
            {
                return;
            }
            var actionItem = processorItem.InnerItem;

            var dataItem = args.DataItem;

            if (string.IsNullOrEmpty(actionItem[ScriptItemFieldNames.Script]))
            {
                return;
            }

            var scriptItem = actionItem.Database.GetItem(new ID(actionItem[ScriptItemFieldNames.Script]));

            if (RulesUtils.EvaluateRules(actionItem[ScriptItemFieldNames.EnableRule], dataItem) &&
                RulesUtils.EvaluateRules(scriptItem[ScriptItemFieldNames.EnableRule], dataItem))
            {
                var str = new UrlString(UIUtil.GetUri("control:PowerShellRunner"));
                str.Append("id", dataItem.ID.ToString());
                str.Append("db", dataItem.Database.Name);
                str.Append("lang", dataItem.Language.Name);
                str.Append("ver", dataItem.Version.Number.ToString(CultureInfo.InvariantCulture));
                str.Append("scriptId", scriptItem.ID.ToString());
                str.Append("scriptDb", scriptItem.Database.Name);
                Context.ClientPage.ClientResponse.Broadcast(
                    SheerResponse.ShowModalDialog(str.ToString(), "400", "220", "PowerShell Script Results", false),
                    "Shell");
            }
        }
Пример #10
0
        protected override void ProcessRecord()
        {
            LogErrors(() =>
            {
                string response = null;
                if (!string.IsNullOrEmpty(Url))
                {
                    response = JobContext.ShowModalDialog(Url, WidthString, HeightString);
                }
                else if (!string.IsNullOrEmpty(Control))
                {
                    UrlString url = new UrlString(UIUtil.GetUri("control:" + Control));
                    url["te"] = Title ?? "Sitecore";

                    if (Parameters != null)
                    {
                        foreach (string key in Parameters.Keys)
                        {
                            url.Add(key, WebUtil.SafeEncode(Parameters[key].ToString()));
                        }
                    }

                    var message = new ShowModalDialogPsMessage(url.ToString(), WidthString, HeightString, HandleParameters);
                    PutMessage(message);
                    response = (string)GetSheerResult(message);

                }
                WriteObject(response);
            });
        }
 /// <summary>
 /// Add a new Content Editor Tab to Content Editor so that users can search for hidden content
 /// </summary>
 /// <param name="context">Context of Call</param>
 public override void Execute(CommandContext context)
 {
     Assert.ArgumentNotNull(context, "context");
     if (context.Items.Length == 1)
     {
         string s = context.Parameters[0];
         if (s.IsGuid())
         {
             if (WebUtil.GetFormValue("scEditorTabs").Contains("contenteditor:launchtab") && WebUtil.GetFormValue("scEditorTabs").Contains(s))
             {
                 SheerResponse.Eval("scContent.onEditorTabClick(null, null, '" + s + "')");
             }
             else
             {
                 UrlString urlString = new UrlString(Util.Constants.ContentEditorRawUrlAddress);
                 urlString.Add(Util.Constants.OpenItemEditorQueryStringKeyName, s);
                 TrackOpenTab(context);
                 context.Items[0].Uri.AddToUrlString(urlString);
                 UIUtil.AddContentDatabaseParameter(urlString);
                 urlString.Add(Util.Constants.ModeQueryStringKeyName, "preview");
                 urlString.Add("il", "0");
                 urlString.Add(Util.Constants.RibbonQueryStringKeyName, "{D3A2D76F-02E6-49DE-BE90-D23C9771DC8D}");
                 string str3 = context.Parameters["la"] ?? Context.Language.CultureInfo.TwoLetterISOLanguageName;
                 urlString.Add("la", str3);
                 AddLatestVersionToUrlString(urlString, s, str3);
                 SheerResponse.Eval(new ShowEditorTab { Command = "contenteditor:launchtab", Header = Translate.Text(Context.ContentDatabase.GetItem(s).Name), Icon = Images.GetThemedImageSource("Applications/16x16/text_view.png"), Url = urlString.ToString(), Id = s, Closeable = true, Activate = Util.Constants.SettingsItem[Util.Constants.OpenSearchResult] != "New Tab Not Selected" }.ToString());
             }
         }
     }
 }
Пример #12
0
        public override void Execute(CommandContext context)
        {
            var urlString = new UrlString(UIUtil.GetUri("control:PowerShellExternalView"));
            var keys = context.Parameters.AllKeys;

            using (var session = ScriptSessionManager.GetSession(string.Empty, ApplicationNames.Default, false))
            {
                session.ExecuteScriptPart("");
                foreach (var key in keys)
                {
                    var param =
                        context.Parameters[key]
                            .Replace("{spe}", GetType().Assembly.GetName().Version.ToString())
                            .Replace("{ps}", ScriptSession.PsVersion.Major + "." + ScriptSession.PsVersion.Minor)
                            .Replace("{sc}",
                                SitecoreVersion.Current.Major + "." +
                                SitecoreVersion.Current.Minor);
                    urlString.Add(key, param);
                }

            }

            var width = keys.Contains("spe_w", StringComparer.OrdinalIgnoreCase)
                ? context.Parameters["spe_w"]
                : keys.Contains("width", StringComparer.OrdinalIgnoreCase) ? context.Parameters["width"] : "800";

            var height = keys.Contains("spe_h", StringComparer.OrdinalIgnoreCase)
                ? context.Parameters["spe_h"]
                : keys.Contains("height", StringComparer.OrdinalIgnoreCase) ? context.Parameters["height"] : "800";

            SheerResponse.ShowModalDialog(urlString.ToString(), width, height);
        }
Пример #13
0
        public override void Execute(CommandContext context)
        {
            var scriptId = context.Parameters["script"];
            var scriptDb = context.Parameters["scriptDb"];

            var itemId = string.Empty;
            var itemDb = string.Empty;
            var itemLang = string.Empty;
            var itemVer = string.Empty;

            if (context.Items.Length > 0)
            {
                itemId = context.Items[0].ID.ToString();
                itemDb = context.Items[0].Database.Name;
                itemLang = context.Items[0].Language.Name;
                itemVer = context.Items[0].Version.Number.ToString(CultureInfo.InvariantCulture);
            }

            var str = new UrlString(UIUtil.GetUri("control:PowerShellRunner"));
            str.Append("id", itemId);
            str.Append("db", itemDb);
            str.Append("lang", itemLang);
            str.Append("ver", itemVer);
            str.Append("scriptId", scriptId);
            str.Append("scriptDb", scriptDb);
            Context.ClientPage.ClientResponse.Broadcast(
                SheerResponse.ShowModalDialog(str.ToString(), "400", "260", "PowerShell Script Results", false),
                "Shell");
        }
Пример #14
0
        protected void ShowTags(string notFoundTag)
        {
            ClientPipelineArgs args = ContinuationManager.Current.CurrentArgs as ClientPipelineArgs;

            if (args.IsPostBack)
            {
                if (args.HasResult && args.Result != "undefined")
                {
                    Database db           = Sitecore.Context.ContentDatabase ?? Sitecore.Context.Database;
                    Item     categoryItem = db.GetItem(new ID(args.Result));
                    string   tagValue     = GetCategoryName(categoryItem);
                    string   tagId        = categoryItem.ID.ToString();
                    SheerResponse.Eval("SetTag('{0}','{1}')", tagValue, tagId);
                }
            }
            else
            {
                UrlString url =
                    new UrlString(
                        ControlManager.GetControlUrl(new ControlName("Sitecore.Shell.Applications.Taxonomy.Dialogs.TagBrowser")));
                UrlHandle currentHandle = UrlHandle.Get();
                UrlHandle handle        = new UrlHandle();
                handle["tagNotFound"]      = notFoundTag;
                handle["categoriesRootId"] = currentHandle["categoriesRootId"];
                handle.Add(url);
                SheerResponse.ShowModalDialog(url.ToString(), "650px", "600px", string.Empty, true);
                args.WaitForPostBack();
            }
        }
        private void ParseParameters(string source)
        {
            if (string.IsNullOrEmpty(source))
            {
                return;
            }


            var parameters = new UrlString(source);

            ClassName = parameters.Parameters[CLASSNAME];
            ErrorType = string.IsNullOrEmpty(parameters.Parameters[ERRORTYPE])
                ? DEFAULT_ERROR
                : parameters.Parameters[ERRORTYPE];

            if (!string.IsNullOrEmpty(ErrorType))
            {
                if (!Enum.TryParse(ErrorType, out _errorType))
                {
                    _errorType = ErrorTypes.Warning;
                }
            }

            MetadataTag = parameters.Parameters[METADATATAG];

            if (string.IsNullOrEmpty(MetadataTag))
            {
                MetadataTag = Constants.DEFAULT_METADATA;
            }
        }
        public void Run(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

            string controlId = args.Parameters["controlid"];

            if (args.IsPostBack)
            {
                if (!args.HasResult) return;

                SheerResponse.SetAttribute("scHtmlValue", "value", YouTubeVideoField.FormatValueForPageEditorDisplay(args.Result));
                SheerResponse.SetAttribute("scPlainValue", "value", args.Result);

                SheerResponse.Eval("scSetHtmlValue('" + controlId + "', false, true)");
            }
            else
            {
                var urlString = new UrlString(UIUtil.GetUri(DialogUrl));
                urlString["val"] = args.Parameters.Get("fieldValue");

                Context.ClientPage.ClientResponse.ShowModalDialog(urlString.ToString(), "650px", "700px", string.Empty, true);

                args.WaitForPostBack();
            }
        }
        public void OnDoubleClick()
        {
            if (ListViewer.GetSelectedItems().Length <= 0)
            {
                return;
            }
            var clickedId     = int.Parse(ListViewer.GetSelectedItems()[0].Value);
            var firstDataItem = ListViewer.Data.Data.FirstOrDefault(p => p.Id == clickedId);

            if (firstDataItem != null)
            {
                var originalData = firstDataItem.Original;
                if (originalData is PSObject customItem)
                {
                    var id = customItem.Properties["ID"]?.Value?.ToString();
                    if (!string.IsNullOrEmpty(id) && ID.IsID(id))
                    {
                        originalData = Sitecore.Client.ContentDatabase.GetItem(id);
                    }
                }

                if (originalData is Item item)
                {
                    var urlParams = new UrlString();
                    urlParams.Add("id", item.ID.ToString());
                    urlParams.Add("fo", item.ID.ToString());
                    urlParams.Add("la", item.Language.Name);
                    urlParams.Add("vs", item.Version.Number.ToString(CultureInfo.InvariantCulture));
                    urlParams.Add("sc_content", item.Database.Name);
                    Sitecore.Shell.Framework.Windows.RunApplication("Content editor", urlParams.ToString());
                }
            }
            ListViewer.Refresh();
        }
        /// <summary>
        /// Parses the parameters supplied as Source attribute
        /// </summary>
        /// <param name="rawParameters">The raw parameters.</param>
        void ParseParameters(string rawParameters)
        {
            var parameters = new UrlString(rawParameters);

            Min      = parameters["Min"];
            Max      = parameters["Max"];
            Interval = parameters["Interval"];

            if (string.IsNullOrEmpty(Min))
            {
                Assert.IsTrue(string.IsNullOrEmpty(Max), "Must also supply 'Max' parameter");
            }

            if (string.IsNullOrEmpty(Max))
            {
                Assert.IsTrue(string.IsNullOrEmpty(Min), "Must also supply 'Min' parameter");
            }

            if (!string.IsNullOrEmpty(Interval))
            {
                Assert.IsTrue(!string.IsNullOrEmpty(Min) && !string.IsNullOrEmpty(Max), "Must supply 'Min' and 'Max' parameters when using 'Interval' parameter");
            }

            Values = parameters["Values"];
        }
        }                                       // Example "|" ... ugh this breaks the UI

        public override void Apply(T ruleContext)
        {
            Assert.ArgumentNotNull(ruleContext, "ruleContext");
            Assert.ArgumentNotNullOrEmpty(Name, "Name");
            Assert.ArgumentNotNullOrEmpty(Term, "Term");
            // Assert.ArgumentNotNullOrEmpty(Delimiter, "Delimiter");
            Delimiter = "|";

            if (string.IsNullOrWhiteSpace(ruleContext.Reference.Settings.Parameters))
            {
                return;
            }

            var urlString = new UrlString(ruleContext.Reference.Settings.Parameters);
            var rawValue  = urlString.Parameters[Name];

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

            var valueList = rawValue.Split(new string[] { Delimiter }, StringSplitOptions.RemoveEmptyEntries);
            var newList   = string.Join(Delimiter,
                                        valueList.Where(x => x != null && !HttpUtility.UrlDecode(x).Equals(HttpUtility.UrlDecode(Term), StringComparison.OrdinalIgnoreCase))
                                        );

            urlString.Append(Name, newList ?? string.Empty);
            ruleContext.Reference.Settings.Parameters = urlString.GetUrl();
        }
        public override void Execute(CommandContext context)
        {
            SheerResponse.DisableOutput();
            var subMenu    = new Sitecore.Web.UI.HtmlControls.ContextMenu();
            var menuItems  = new List <Control>();
            var menuItemId = "consoleSettingsPopup";

            if (String.IsNullOrEmpty(menuItemId))
            {
                var parameters = new UrlString("?" + Context.Items["SC_FORM"]);
                menuItemId = parameters.Parameters["__EVENTTARGET"];
            }

            var menuRootItem = Factory.GetDatabase("core").GetItem("/sitecore/content/Applications/Turbo Console/Turbo Console/Menus/Settings");

            GetMenuItems(menuItems, menuRootItem);

            foreach (MenuItem item in menuItems)
            {
                var subItem = subMenu.Add(item.ID, item.Header, item.Icon, item.Hotkey, item.Click, item.Checked, item.Radiogroup, item.Type);
                subItem.Disabled = item.Disabled;
            }
            SheerResponse.EnableOutput();
            subMenu.Visible = true;
            SheerResponse.ShowContextMenu(menuItemId, "down", subMenu);
        }
Пример #21
0
        /// <summary>
        /// This method runs the rotating image modal
        /// </summary>
        /// <param name="args"></param>
        public void RunEditForm(ClientPipelineArgs args)
        {
            if (!args.IsPostBack)
            {
                //get url for field type selector modal
                UrlString ustr = new UrlString(UIUtil.GetUri("control:FieldSuiteEditForm"));
                ustr.Parameters.Add(args.Parameters);

                //open field type selector
                Sitecore.Context.ClientPage.ClientResponse.ShowModalDialog(ustr.ToString(), "712", "485", "", true);

                //wait for response
                args.WaitForPostBack();
            }
            else
            {
                string itemId = args.Parameters["id"];
                if(!string.IsNullOrEmpty(itemId) && Sitecore.Context.ContentDatabase != null)
                {
                    Item item = Sitecore.Context.ContentDatabase.GetItem(itemId);
                    if(item.IsNotNull())
                    {
                        UnlockItem(item);

                        //send command to update list update's field gutter
                        if (args.Parameters["fieldid"] != null && !string.IsNullOrEmpty(args.Parameters["fieldid"]))
                        {
                            string fieldGutterHtml = GetFieldGutterHtml(new FieldGutterArgs(item, args.Parameters["fieldid"]));
                            SheerResponse.Eval("FieldSuite.Fields.UpdateItemFieldGutter(\"" + args.Parameters["fieldid"] + "\",\"" + HttpUtility.HtmlEncode(fieldGutterHtml) + "\",\"" + item.ID + "\")");
                        }
                    }
                }
            }
        }
Пример #22
0
        public override void Execute(CommandContext context)
        {
            var scriptId = context.Parameters["scriptId"];
            var scriptDb = context.Parameters["scriptDb"];

            var itemId   = string.Empty;
            var itemDb   = string.Empty;
            var itemLang = string.Empty;
            var itemVer  = string.Empty;

            if (context.Items.Length > 0)
            {
                itemId   = context.Items[0].ID.ToString();
                itemDb   = context.Items[0].Database.Name;
                itemLang = context.Items[0].Language.Name;
                itemVer  = context.Items[0].Version.Number.ToString(CultureInfo.InvariantCulture);
            }

            var str = new UrlString(UIUtil.GetUri("control:PowerShellRunner"));

            str.Append(context.Parameters);
            str.Append("id", itemId);
            str.Append("db", itemDb);
            str.Append("lang", itemLang);
            str.Append("ver", itemVer);
            str.Append("scriptId", scriptId);
            str.Append("scriptDb", scriptDb);
            SheerResponse.ShowModalDialog(str.ToString(), "400", "260", "PowerShell Script Results", false);
        }
Пример #23
0
        protected static void Run(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            if (SheerResponse.CheckModified())
            {
                if (args.IsPostBack)
                {
                    SheerResponse.Eval("window.top.location.href=window.top.location.href");
                    var itemId = ParseForAttribute(args.Result, "id");
                    Item item = Sitecore.Context.ContentDatabase.GetItem(itemId);
                    if (item.IsNotNull())
                    {
                        var url =
                            new UrlString("http://" + HttpContext.Current.Request.Url.Host +
                                          LinkManager.GetItemUrl(item).Replace("/sitecore/shell", ""));
                        WebEditCommand.Reload(url);
                    }

                }
                else
                {
                    SheerResponse.ShowModalDialog(
                        new UrlString("/sitecore/shell/Applications/Dialogs/Bucket%20link.aspx?").ToString(), "1000", "700", "", true);
                    args.WaitForPostBack();
                }
            }
        }
        private void ParseParameters(string source)
        {
            var parameters = new UrlString(source);

            if (!string.IsNullOrEmpty(parameters.Parameters[FROM_FIELD_NAME]))
            {
                From = MainUtil.GetInt(parameters.Parameters[FROM_FIELD_NAME], 0);
            }
            else
            {
                From = 1;
            }

            if (!string.IsNullOrEmpty(parameters.Parameters[TO_FIELD_NAME]))
            {
                To = MainUtil.GetInt(parameters.Parameters[TO_FIELD_NAME], 100);
            }
            else
            {
                To = 100;
            }
            // TO SHOW RAW VALUES
            if (!string.IsNullOrEmpty(parameters.Parameters[IS_DEBUG_FIELD_NAME]))
            {
                IsDebug = MainUtil.GetBool(parameters.Parameters[IS_DEBUG_FIELD_NAME], false);
            }
        }
Пример #25
0
        /// <summary>
        /// Renders an image allowing simple page editor support
        /// </summary>
        /// <typeparam name="T">The model type</typeparam>
        /// <param name="model">The model that contains the image field</param>
        /// <param name="field">A lambda expression to the image field, should be of type Glass.Mapper.Sc.Fields.Image</param>
        /// <param name="parameters">Image parameters, e.g. width, height</param>
        /// <param name="isEditable">Indicates if the field should be editable</param>
        /// <param name="outputHeightWidth">Indicates if the height and width attributes should be output when rendering the image</param>
        /// <returns></returns>
        public virtual string RenderImage <T>(T model,
                                              Expression <Func <T, object> > field,
                                              object parameters      = null,
                                              bool isEditable        = false,
                                              bool outputHeightWidth = false)
        {
            var attrs = Utilities.GetPropertiesCollection(parameters, true).ToSafeDictionary();

            if (IsInEditingMode && isEditable)
            {
                var url = new UrlString();
                foreach (var pair in attrs)
                {
                    url.Parameters.Add(pair.Key, pair.Value);
                }
                if (!outputHeightWidth)
                {
                    url.Parameters.Add("width", "-1");
                    url.Parameters.Add("height", "-1");
                }

                return(Editable(model, field, url.Query));
            }
            else
            {
                return(RenderImage(GetCompiled(field).Invoke(model) as Image, parameters == null ? null : attrs, outputHeightWidth));
            }
        }
Пример #26
0
        /// <summary>
        /// Parses the parameters supplied as field source.
        /// </summary>
        /// <remarks>
        /// Both "40" and "Limit=40" are supported for specifing maximum number of characters the field should accept
        /// </remarks>
        /// <param name="source">The source.</param>
        void ParseParameters(string source)
        {
            if (string.IsNullOrEmpty(source))
            {
                return;
            }

            if (!source.Contains("="))
            {
                CharacterLimit = int.Parse(source);
                return;
            }

            var parameters = new UrlString(source);

            if (!string.IsNullOrEmpty(parameters.Parameters["Limit"]))
            {
                CharacterLimit = int.Parse(parameters.Parameters["Limit"]);
            }

            if (!string.IsNullOrEmpty(parameters.Parameters["PreventTyping"]))
            {
                PreventTyping = MainUtil.GetBool(parameters.Parameters["PreventTyping"], false);
            }
        }
 protected void Process(ClientPipelineArgs args)
 {
     Assert.ArgumentNotNull(args, "args");
     if (args.IsPostBack)
     {
         Context.ClientPage.SendMessage(this, $"item:refresh(id={itemId})");
         Context.ClientPage.SendMessage(this, $"item:refreshchildren(id={itemId})");
         if (args.HasResult && !args.Result.IsNullOrEmpty())
         {
             foreach (var closeMessage in args.Result.Split('\n'))
             {
                 Context.ClientPage.ClientResponse.Timer(closeMessage, 2);
             }
         }
     }
     else
     {
         var str = new UrlString(UIUtil.GetUri("control:PowerShellRunner"));
         if (!string.IsNullOrWhiteSpace(itemId))
         {
             str.Append("id", itemId);
             str.Append("db", itemDb);
             str.Append("lang", itemLang);
             str.Append("ver", itemVer);
             if ((bool)(args.Properties["UsesBrowserWindows"] ?? false))
             {
                 str.Append("cfs", "1");
             }
         }
         str.Append("scriptId", scriptId);
         str.Append("scriptDb", scriptDb);
         SheerResponse.ShowModalDialog(str.ToString(), "400", "260", "", true);
         args.WaitForPostBack();
     }
 }
        /// <summary>
        /// Add a new Content Editor Tab to Content Editor so that users can search for hidden content
        /// </summary>
        /// <param name="context">Context of Call</param>
        public override void Execute(CommandContext context)
        {
            Assert.ArgumentNotNull(context, "context");
            if (context.Items.Length == 1)
            {
                var itemId = context.Parameters[0];
                //if (WebUtil.GetFormValue("scEditorTabs").Contains("contenteditor:launchtab") && WebUtil.GetFormValue("scEditorTabs").Contains(itemId))
                //{
                //    SheerResponse.Eval("scContent.onEditorTabClick(null, null, '" + itemId + "')");
                //}
                //else
                //{

                      var urlString = new UrlString("/sitecore%20modules/Shell/Sitecore/ItemBuckets/ShowResult.aspx");
                      urlString.Add(Util.Constants.OpenItemEditorQueryStringKeyName, itemId);

                      context.Items[0].Uri.AddToUrlString(urlString);
                      UIUtil.AddContentDatabaseParameter(urlString);
                      urlString.Add(Util.Constants.ModeQueryStringKeyName, "preview");
                      urlString.Add(Util.Constants.RibbonQueryStringKeyName, "{D3A2D76F-02E6-49DE-BE90-D23C9771DC8D}");
                      var language = context.Parameters["la"].IsNull() ? Sitecore.Context.Language.CultureInfo.TwoLetterISOLanguageName : context.Parameters["la"];
                      urlString.Add("la", language);

            //SheerResponse.Eval(new ShowEditorTab { Command = "contenteditor:launchtab", Header = "Another Search", Icon = Images.GetThemedImageSource("Applications/16x16/text_view.png"), Url = urlString.ToString(), Id = Id, Closeable = true, Activate = true }.ToString());

                    SheerResponse.Eval(new ShowEditorTab { Command = "contenteditor:launchblanktab", Header = "Search " + DateTime.Now.ToLongTimeString(), Icon = Images.GetThemedImageSource("Applications/16x16/text_view.png"), Url = urlString.ToString(), Id = new Random().Next(0, 99999999).ToString(), Closeable = true, Activate = true }.ToString());
               // }
            }
        }
Пример #29
0
        public static string GetLanguageUrl(Item item)
        {
            UrlString url = new UrlString(WebUtil.GetRawUrl());

            url["sc_lang"] = item.Name;
            return(url.ToString());
        }
Пример #30
0
        public override void HandleMessage(Message message)
        {
            Assert.ArgumentNotNull(message, "message");
            base.HandleMessage(message);

            if (message["id"] != ID)
            {
                return;
            }

            switch (message.Name)
            {
            case "contentlink:relativelink":
            {
                var url = new UrlString(UIUtil.GetUri("control:RelativePathForm"));
                Insert(url.ToString(), new NameValueCollection
                    {
                        {
                            "height",
                            "425"
                        }
                    });
                break;
            }

            default:
            {
                return;
            }
            }
        }
Пример #31
0
        public override void Execute(CommandContext context)
        {
            var urlString = new UrlString(UIUtil.GetUri("control:PowerShellExternalView"));
            var keys      = context.Parameters.AllKeys;

            using (var session = ScriptSessionManager.GetSession(string.Empty, ApplicationNames.Default, false))
            {
                session.ExecuteScriptPart("");
                foreach (var key in keys)
                {
                    var param =
                        context.Parameters[key]
                        .Replace("{spe}", CurrentVersion.SpeVersion.ToString())
                        .Replace("{ps}", ScriptSession.PsVersion.Major + "." + ScriptSession.PsVersion.Minor)
                        .Replace("{sc}",
                                 SitecoreVersion.Current.Major + "." +
                                 SitecoreVersion.Current.Minor);
                    urlString.Add(key, param);
                }
            }

            var width = keys.Contains("spe_w", StringComparer.OrdinalIgnoreCase)
                ? context.Parameters["spe_w"]
                : keys.Contains("width", StringComparer.OrdinalIgnoreCase) ? context.Parameters["width"] : "800";

            var height = keys.Contains("spe_h", StringComparer.OrdinalIgnoreCase)
                ? context.Parameters["spe_h"]
                : keys.Contains("height", StringComparer.OrdinalIgnoreCase) ? context.Parameters["height"] : "800";

            SheerResponse.ShowModalDialog(urlString.ToString(), width, height);
        }
        public virtual void Process(RenderingPropertiesFieldEditorArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            Assert.ArgumentNotNull(args.StandardValuesItem, "args.StandardValuesItem");
            Assert.ArgumentNotNullOrEmpty(args.Handle, "args.Handle");
            Assert.ArgumentNotNull(args.RenderingDefinition, "args.RenderingDefinition");

            var renderingDef = args.RenderingDefinition;
            var fieldCol = args.StandardValuesItem.Fields;

            var parameters = new UrlString();
            var options = RenderingParametersFieldEditorOptions.Parse(args.Handle);

            //
            //save the parameters that have already been set
            if (! string.IsNullOrEmpty(args.RenderingDefinition.Parameters))
            {
                var currentParams = new UrlString(args.RenderingDefinition.Parameters);
                foreach (var key in currentParams.Parameters.AllKeys)
                {
                    var name = key;
                    var value = currentParams[key];
                    SetValue(renderingDef, parameters, name, value);
                }
            }

            foreach (var field in options.Fields)
            {
                SetValue(renderingDef, parameters, fieldCol[field.FieldID].Name, field.Value);
            }
            args.RenderingDefinition.Parameters = parameters.ToString();
        }
        public void Edit(ClientPipelineArgs args)
        {
            if (args.IsPostBack)
            {
                if (!args.HasResult)
                {
                    return;
                }

                Value = args.Result;
                SetModified();
                SheerResponse.Refresh(this);
            }
            else
            {
                Assert.IsNotNull(DialogUrl, "Dialog URL");

                var urlString = new UrlString(UIUtil.GetUri(DialogUrl));
                var itemUri   = new ItemUri(ItemId, Sitecore.Configuration.Factory.GetDatabase("master"));
                var fieldItem = Sitecore.Context.ContentDatabase.GetItem(FieldId);


                urlString["itemUri"]   = itemUri.ToString();
                urlString["fieldName"] = fieldItem.Name;

                Sitecore.Context.ClientPage.ClientResponse.ShowModalDialog(urlString.ToString(), "650px", "700px", string.Empty, true);

                args.WaitForPostBack();
            }
        }
        /// <summary>
        /// Macro main entry method
        /// </summary>
        /// <param name="element">
        /// The element.
        /// </param>
        /// <param name="name">
        /// The name.
        /// </param>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        /// <param name="value">
        /// The value.
        /// </param>
        public void Execute(XElement element, string name, UrlString parameters, string value)
        {
            Assert.ArgumentNotNull(element, "element");
             Assert.ArgumentNotNull(name, "name");
             Assert.ArgumentNotNull(parameters, "parameters");
             Assert.ArgumentNotNull(value, "value");

             SelectAccountOptions options = SelectAccountOptions.Parse();
             string securityType = parameters["type"];
             if (!string.IsNullOrEmpty(securityType))
             {
            if (securityType.Equals("role", StringComparison.InvariantCultureIgnoreCase))
            {
               options.ExcludeUsers = true;
            }
            else if (securityType.Equals("user", StringComparison.InvariantCultureIgnoreCase))
            {
               options.ExcludeRoles = true;
            }
             }

             string multipleSelection = parameters["multiselect"];
             if (!string.IsNullOrEmpty(multipleSelection))
             {
            options.Multiple = multipleSelection.Equals("true", StringComparison.InvariantCultureIgnoreCase);
             }

             SheerResponse.ShowModalDialog(options.ToUrlString().ToString(), true);
        }
Пример #35
0
 protected void Run(ClientPipelineArgs args)
 {
     try
     {
         string str  = args.Parameters["id"];
         string name = args.Parameters["language"];
         string str3 = args.Parameters["version"];
         Item   item = Context.ContentDatabase.Items[str, Language.Parse(name), Sitecore.Data.Version.Parse(str3)];
         Error.AssertItemFound(item);
         if (SheerResponse.CheckModified())
         {
             if (args.IsPostBack)
             {
                 if (args.Result == "yes")
                 {
                     Context.ClientPage.SendMessage(this, "item:load(id=" + str + ",language=" + name + ",version=" + str3 + ")");
                 }
             }
             else
             {
                 UrlString str4 = new UrlString(UIUtil.GetUri("control:AddVersionAndCopy"));
                 str4.Add("id", item.ID.ToString());
                 str4.Add("la", item.Language.ToString());
                 str4.Add("vs", item.Version.ToString());
                 str4.Add("ci", item.Language.ToString());
                 SheerResponse.ShowModalDialog(str4.ToString(), true);
                 args.WaitForPostBack();
             }
         }
     }
     catch (Exception exception)
     {
         Sitecore.Diagnostics.Log.Error(exception.Message, this);
     }
 }
Пример #36
0
        public void Execute()
        {
            var resultSig = Guid.NewGuid().ToString();

            HttpContext.Current.Cache[resultSig] = this;

            if (!Modal)
            {
                var urlString = new UrlString();
                urlString.Add("sid", resultSig);
                var appItem = Database.GetDatabase("core").GetItem("/sitecore/content/Applications/PowerShell/PowerShellListView");
                var icon    = Icon ?? appItem.Appearance.Icon;
                Sitecore.Shell.Framework.Windows.RunApplication(appItem, icon, Title, urlString.Query);
            }
            else
            {
                var urlString = new UrlString(UIUtil.GetUri("control:PowerShellResultViewerList"));
                urlString.Add("sid", resultSig);

                var options = new ModalDialogOptions(urlString.ToString())
                {
                    Width  = Width,
                    Height = Height,
                    Header = Title
                };
                SheerResponse.ShowModalDialog(options);
            }
        }
Пример #37
0
        /// <summary>
        /// Returns a <see cref="System.String" /> that represents this instance.
        /// </summary>
        /// <returns>A <see cref="System.String" /> that represents this instance.</returns>
        public override string ToString()
        {
            var url = new UrlString();

            url.Parameters.Add(Parameters);
            return(url.Query);
        }
Пример #38
0
        protected override void OnOK(object sender, EventArgs args)
        {
            Assert.ArgumentNotNull(sender, "sender");
            Assert.ArgumentNotNull(args, "args");

            if (string.IsNullOrEmpty(ItemPicker.Value))
            {
                Context.ClientPage.ClientResponse.Alert("Please Select a Target Item");
                return;
            }

            if (string.IsNullOrEmpty(OldUrlEdit.Value))
            {
                Context.ClientPage.ClientResponse.Alert("Please enter an old Url for redirection");
                return;
            }

            UrlString results = new UrlString();

            results["itemid"]      = ItemPicker.Value;
            results["oldpath"]     = OldUrlEdit.Value;
            results["querystring"] = QueryStringEdit.Value;
            results["site"]        = SiteCombobox.Value;
            SheerResponse.SetDialogValue(results.ToString());
            base.OnOK(sender, args);
        }
Пример #39
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            var settings = ApplicationSettings.GetInstance(ApplicationNames.Context, false);
            var title    = WebUtil.GetQueryString("spe_t");

            if (!string.IsNullOrEmpty(title))
            {
                DialogHeader.Text = title;
            }
            var url = WebUtil.GetQueryString("spe_url");

            if (string.IsNullOrEmpty(url))
            {
                url = "http://blog.najmanowicz.com/sitecore-powershell-console/";
            }

            var urlStr    = new UrlString(url);
            var urlParams = WebUtil.ParseQueryString(WebUtil.GetRawUrl());

            foreach (var key in urlParams.Keys)
            {
                if (!key.StartsWith("spe_", StringComparison.OrdinalIgnoreCase) &&
                    !key.Equals("xmlcontrol", StringComparison.OrdinalIgnoreCase))
                {
                    urlStr.Parameters.Add(key, urlParams[key]);
                }
            }
            Result.Text = $"<iframe class='externalViewer' src='{urlStr}'></iframe>";
        }
Пример #40
0
        protected virtual void Run(ClientPipelineArgs args)
        {
            string databaseName = args.Parameters["databasename"];
             string id = args.Parameters["id"];

             Database database = Factory.GetDatabase(databaseName);
             Assert.IsNotNull(database, typeof (Database), "Database \"" + database + "\" not found.", new object[0]);
             Item item = database.Items[id];

             if (item != null)
             {
                     if (item.Fields[FieldIDs.LayoutField] != null && item.Fields[FieldIDs.LayoutField].Value != string.Empty)
            {
                  if (!args.IsPostBack)
                  {
                     UrlString url = new UrlString(UIUtil.GetUri("control:Calendar.ConfigureControls"));
                     url.Append("id", item.ID.ToString());
                     url.Append("db", item.Database.Name);

                     Windows.RunApplication("Calendar ConfigureControls", url.GetUrl());
                  }
            }
            else
            {
               Context.ClientPage.ClientResponse.Alert(ResourceManager.Localize("ITEM_HAS_NO_LAYOUT"));
            }
             }
             else
             {
            SheerResponse.Alert("Item not found.", new string[0]);
             }
        }
Пример #41
0
        protected void LoadImage()
        {
            string attribute = this.XmlValue.GetAttribute("mediaid");

            if (string.IsNullOrEmpty(attribute))
            {
                SheerResponse.Alert("Select an image from the Media Library first.", new string[0]);
                return;
            }
            if (!UserOptions.View.ShowEntireTree)
            {
                Item item = Client.CoreDatabase.GetItem("/sitecore/content/Applications/Content Editor/Applications/MediaLibraryForm");
                if (item != null)
                {
                    Item item1 = Client.ContentDatabase.GetItem(attribute);
                    if (item1 != null)
                    {
                        UrlString urlString = new UrlString(item["Source"]);
                        urlString["pa"]  = "1";
                        urlString["pa0"] = WebUtil.GetQueryString("pa0", string.Empty);
                        urlString["la"]  = WebUtil.GetQueryString("la", string.Empty);
                        urlString["pa1"] = HttpUtility.UrlEncode(item1.Uri.ToString());
                        SheerResponse.SetLocation(urlString.ToString());
                        return;
                    }
                }
            }
            Language   language   = Language.Parse(this.ItemLanguage);
            ClientPage clientPage = Sitecore.Context.ClientPage;

            string[] name = new string[] { "item:load(id=", attribute, ",language=", language.Name, ")" };
            clientPage.SendMessage(this, string.Concat(name));
        }
Пример #42
0
        /// <summary>
        /// Copied without replacing the '-' with '_' and with URL encode.
        /// </summary>
        public void LoadValue(NameValueCollection formCollection)
        {
            if (this.ReadOnly || this.Disabled)
            {
                return;
            }

            var collection = formCollection ?? new NameValueCollection();
            var urlString  = new UrlString();

            foreach (string key in collection.Keys)
            {
                if (!string.IsNullOrEmpty(key) && key.StartsWith(this.ID + "_Param", StringComparison.InvariantCulture) && !key.EndsWith("_value", StringComparison.InvariantCulture))
                {
                    var resultKey   = collection[key];
                    var resultValue = collection[key + "_value"];
                    if (!string.IsNullOrEmpty(resultKey))
                    {
                        urlString[HttpUtility.UrlEncode(resultKey)] = HttpUtility.UrlEncode(resultValue) ?? string.Empty;
                    }
                }
            }

            this.Value = urlString.ToString();
        }
Пример #43
0
        private void DetermineSpeakVersion()
        {
            var renderingContainer = LayoutDesignerView.GetRenderingContainer();

            if (renderingContainer == null)
            {
                return;
            }

            foreach (var rendering in renderingContainer.Renderings)
            {
                if (rendering.ItemId != "{DAFAFFB8-74AF-4141-A96A-70B16834CEC6}")
                {
                    continue;
                }

                var parameter = new UrlString(rendering.Parameters);
                var version   = HttpUtility.UrlDecode(parameter.Parameters["SpeakCoreVersion"] ?? string.Empty);

                if (!string.IsNullOrEmpty(version))
                {
                    SpeakCoreVersionId = version;

                    var property = rendering.DynamicProperties.FirstOrDefault(p => p.Name == "SpeakCoreVersion");
                    if (property != null)
                    {
                        SpeakCoreVersion = property.Value != null?property.Value.ToString() : string.Empty;
                    }
                }

                return;
            }
        }
Пример #44
0
        private static void ShowModal(ClientPipelineArgs args)
        {
            var sheerUrl = new UrlString("/sitecore/shell/~/xaml/Sitecore.SitecoreModule.Shell.Redirect.NewRedirect.aspx");

            SheerResponse.ShowModalDialog(sheerUrl.ToString(), "780", "350", string.Empty, true);
            args.WaitForPostBack();
        }
Пример #45
0
        public override void Execute(CommandContext context)
        {
            string scriptId = context.Parameters["script"];
            string scriptDb = context.Parameters["scriptDb"];
            Item scriptItem = Factory.GetDatabase(scriptDb).GetItem(new ID(scriptId));

            string showResults = scriptItem[ScriptItemFieldNames.ShowResults];
            string itemId = string.Empty;
            string itemDb = string.Empty;

            if (context.Items.Length > 0)
            {
                itemId = context.Items[0].ID.ToString();
                itemDb = context.Items[0].Database.Name;
            }

            var str = new UrlString(UIUtil.GetUri("control:PowerShellRunner"));
            str.Append("id", itemId);
            str.Append("db", itemDb);
            str.Append("scriptId", scriptId);
            str.Append("scriptDb", scriptDb);
            str.Append("autoClose", showResults);
            Context.ClientPage.ClientResponse.Broadcast(
                SheerResponse.ShowModalDialog(str.ToString(), "400", "220", "PowerShell Script Results", false),
                "Shell");
        }
Пример #46
0
        /// <summary>
        ///     Shows a confirmation dialog.
        /// </summary>
        protected virtual void ShowUI()
        {
            if (AdvancedDialog)
            {
                var urlString =
                    new UrlString("/sitecore/shell/Applications/Media/UploadManager/UploadManager.aspx");
                var item = Context.ContentDatabase.GetItem(Path);
                item.Uri.AddToUrlString(urlString);
                SheerResponse.ShowModalDialog(urlString.ToString(), true);
            }
            else
            {
                var urlString = new UrlString("/sitecore modules/Shell/PowerShell/UploadFile/PowerShellUploadFile.aspx");
                var handle    = new UrlHandle();
                handle["te"]        = Title ?? string.Empty;
                handle["ds"]        = Description ?? string.Empty;
                handle["ic"]        = "powershell/32x32/powershell8.png";
                handle["ok"]        = OkButtonName ?? string.Empty;
                handle["cancel"]    = CancelButtonName ?? string.Empty;
                handle["path"]      = Path;
                handle["mask"]      = "*.*";
                handle["de"]        = "txt";
                handle["versioned"] = Versioned ? "1" : string.Empty;
                handle["language"]  = Language ?? string.Empty;
                handle["overwrite"] = Overwrite ? "1" : string.Empty;
                handle["unpack"]    = Unpack ? "1" : string.Empty;

                handle.Add(urlString);
                SheerResponse.ShowModalDialog(urlString.ToString(), Width, Height, "", true);
            }
        }
        /// <summary>
        /// Executes the command in the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        public override void Execute(CommandContext context)
        {
            // updated to publish the site configuration nodes. flushing will be handled by publish end events
            UrlString str = new UrlString(UIUtil.GetUri("control:MultisitesManager.FlushSites"));

            SheerResponse.ShowModalDialog(str.ToString());
        }
 protected virtual void Run(ClientPipelineArgs args)
 {
     Assert.ArgumentNotNull((object)args, "args");
     if (!SheerResponse.CheckModified())
     {
         return;
     }
     if (args.IsPostBack)
     {
         if (!args.HasResult)
         {
             return;
         }
         WebEditCommand.Reload();
     }
     else
     {
         //SheerResponse.ShowModalDialog(this.GetOptions(args).ToUrlString().ToString(), true);
         SortContentOptions sco = this.GetOptions(args);
         Assert.IsNotNull((object)Context.Site, "context site");
         UrlString urlString = new UrlString(Context.Site.XmlControlPage);
         urlString["xmlcontrol"] = "Sitecore.Shell.Applications.Dialogs.FacDirSort";
         sco.Item.Uri.AddToUrlString(urlString);
         SheerResponse.ShowModalDialog(urlString.ToString(), true);
         args.WaitForPostBack(true);
     }
 }
        public static string GetAssetUrlHash(string url)
        {
            UrlString imgUrl = new UrlString(url.ToLowerInvariant());
            string    path   = imgUrl.Path;

            if (!MediaItemCache.ContainsKey(path))
            {
                Item mediaItem = CurrentDatabase.GetItem(GetMediaPath(path));
                if (mediaItem == null)
                {
                    return(url);
                }
                MediaItemCache.Add(path, mediaItem.ID.ToString());
            }
            if (MediaItemCache.ContainsKey(path))
            {
                string width     = imgUrl.Parameters["w"];
                string height    = imgUrl.Parameters["h"];
                string maxWidth  = imgUrl.Parameters["mh"];
                string maxHeight = imgUrl.Parameters["mw"];
                string scale     = imgUrl.Parameters["sc"];
                return
                    (ComputeHash(string.Format("{0}?w={1}&h={2}&sc={3}&mw={4}&mh={5}",
                                               new object[] { MediaItemCache[path], width, height, scale, maxHeight, maxWidth })));
            }
            return(url);
        }
Пример #50
0
        /// <summary>
        ///     Shows a confirmation dialog.
        /// </summary>
        protected override void ShowUI()
        {
            var urlString = new UrlString(Url);

            if (HandleParams != null && HandleParams.Count > 0)
            {
                var handle = new UrlHandle();
                foreach (string key in HandleParams.Keys)
                {
                    var value = HandleParams[key];
                    if ((value is string) &&
                        ((string)value).StartsWith("packPath:", StringComparison.OrdinalIgnoreCase))
                    {
                        string strValue = (string)value;
                        strValue    = strValue.Substring(9);
                        handle[key] = ApplicationContext.StoreObject(strValue);
                    }
                    else
                    {
                        handle[key] = value?.ToString() ?? string.Empty;
                    }
                }
                handle.Add(urlString);
            }

            Context.ClientPage.ClientResponse.ShowModalDialog(urlString.ToString(), Width, Height, string.Empty, ReceiveResults);
        }
 public void SelectFields(ClientPipelineArgs args)
 {
     Assert.ArgumentNotNull(args, "args");
     if (!args.IsPostBack)
     {
         UrlString urlString = new UrlString(UIUtil.GetUri("control:TreeListExEditor"));
         UrlHandle urlHandle = new UrlHandle();
         urlHandle["title"] = PullUpFieldsSettings.SelectFieldsDialogTitle;
         urlHandle["text"] = PullUpFieldsSettings.SelectFieldsDialogText;
         urlHandle["source"] = GetSelectFieldsDialogSource(args);
         urlHandle.Add(urlString);
         SheerResponse.ShowModalDialog
         (
             urlString.ToString(), 
             PullUpFieldsSettings.SelectFieldsDialogWidth, 
             PullUpFieldsSettings.SelectFieldsDialogHeight, 
             string.Empty, 
             true
         );
         args.WaitForPostBack();
     }
     else if (args.HasResult)
     {
         args.Parameters["fieldIds"] = args.Result;
         args.IsPostBack = false;
     }
     else
     {
         CancelOperation(args);
     }
 }
Пример #52
0
        public void Execute(XElement element, string name, UrlString parameters, string value)
        {
            Assert.ArgumentNotNull((object)element, "element");
            Assert.ArgumentNotNull((object)name, "name");
            Assert.ArgumentNotNull((object)parameters, "parameters");
            Assert.ArgumentNotNull((object)value, "value");

            var selectItemOptions = new SelectItemOptions();
            var obj1 = (Item)null;

            if (!string.IsNullOrEmpty(value))
            {
                obj1 = Client.ContentDatabase.GetItem(value);
            }
            var path = XElement.Parse(element.ToString()).FirstAttribute.Value;

            if (!string.IsNullOrEmpty(path))
            {
                var obj2 = Client.ContentDatabase.GetItem(path);
                if (obj2 != null)
                {
                    selectItemOptions.FilterItem = obj2;
                }
            }
            selectItemOptions.Root         = Client.ContentDatabase.GetItem(new ID(WellKnownIdentifiers.ProfilesContainerId));
            selectItemOptions.SelectedItem = obj1 ?? (selectItemOptions.Root != null ? selectItemOptions.Root.Children.FirstOrDefault <Item>() : (Item)null);
            selectItemOptions.IncludeTemplatesForSelection = SelectItemOptions.GetTemplateList("{0FC09EA4-8D87-4B0E-A5C9-8076AE863D9C}");
            selectItemOptions.Title    = "Select Profile Card";
            selectItemOptions.Text     = "Select the profile card to use in this rule.";
            selectItemOptions.Icon     = "Business/16x16/chart.png";
            selectItemOptions.ShowRoot = false;
            SheerResponse.ShowModalDialog(selectItemOptions.ToUrlString().ToString(), "1200px", "700px", string.Empty, true);
        }
Пример #53
0
 /// <summary>
 ///     Shows a confirmation dialog.
 /// </summary>
 protected override void ShowUI()
 {
     var resultSig = Guid.NewGuid().ToString();
     HttpContext.Current.Session[resultSig] = Html;
     var urlString = new UrlString(UIUtil.GetUri("control:PowerShellResultViewerText"));
     urlString.Add("sid", resultSig);
     SheerResponse.ShowModalDialog(urlString.ToString(), Width, Height);
 }
 private void OpenNewWindow(ID id, string name)
 {
     Assert.ArgumentNotNull(id, "id");
     UrlString url = new UrlString(Constants.Url.ExportFromDataPage);
     url.Append(Constants.QueryString.Name.ItemId, HttpContext.Current.Server.UrlEncode(id.ToString()));
     url.Append(Constants.QueryString.Name.ItemName, HttpContext.Current.Server.UrlEncode(name));
     SheerResponse.Eval(string.Format("window.open('{0}');", url));
 }
        internal virtual UrlString AddCurrentBaseLayout(UrlString urlString)
        {
            if (!ID.IsNullOrEmpty(CurrentBaseLayoutId))
            {
                urlString[CurrentBaseLayoutQueryKey] = CurrentBaseLayoutId.ToShortID().ToString();
            }

            return urlString;
        }
 // Methods
 public override void Execute(CommandContext context)
 {
     Assert.ArgumentNotNull(context, "context");
     UrlString str = new UrlString("/sitecore/shell/Applications/Content Manager/default.aspx");
     str["fo"] = context.Parameters["id"];
     str["mo"] = "preview";
     string features = GetFeatures();
     SheerResponse.Eval(string.Concat(new object[] { "window.open('", str, "', 'SitecoreWebEditEditor', '", features, "')" }));
 }
Пример #57
0
        protected void LoadContentEditor(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

            var parameters = new UrlString();
            parameters.Add("id", args.Parameters["id"]);
            parameters.Add("fo", args.Parameters["id"]);
            Windows.RunApplication("Content Editor", parameters.ToString());
        }
 /// <summary>
 /// Shows the video.
 /// </summary>
 /// <param name="args">The arguments.</param>
 protected virtual void ShowVideo(ClientPipelineArgs args)
 {
     var urlString = new UrlString(Sitecore.UIUtil.GetUri("control:ShowVideo"));
     UrlHandle handle = new UrlHandle();
     handle["value"] = this.Value;
     handle.Add(urlString);
     SheerResponse.ShowModalDialog(urlString.ToString(), "420px", "500px", string.Empty, true);
     args.WaitForPostBack();
 }
 public override void Execute(XElement element, string name, UrlString parameters, string value)
 {
     var macro = AdaptiveManager.Provider.GetTreeMacro(element, name, parameters);
     if (macro != null)
     {
         macro.Execute(element, name, parameters, value);
         return;
     }
     SheerResponse.Alert("No tree macro could be resolved.");
 }
Пример #60
0
        /// <summary>
        /// Runs the specified args.
        /// </summary>
        /// <param name="args">The args.</param>
        protected void Run(ClientPipelineArgs args)
        {
            UrlString str = new UrlString(UIUtil.GetUri("control:GlassTypedRazor", "id={AE723732-6D09-4DBA-B553-A1B399EB077D}&locationId=" + args.Parameters["id"]));

            if (!args.IsPostBack)
            {
                SheerResponse.ShowModalDialog(str.ToString(), true);
                args.WaitForPostBack();
            }
        }