protected override void OnOK(object sender, EventArgs args) { ItemUri uri = ItemUri.ParseQueryString(); item = Database.GetItem(uri); var properties = Reflection.FindProperties.GetProperties(); IEnumerable <Control> controlsOnPage = this.GetControls(); foreach (var type in properties) { object instance = null; foreach (PropertyInfo propertyInfo in type.Value) { var attribute = propertyInfo.GetCustomAttributes(typeof(FieldNotVisibleInWebEditAttribute), true).First() as FieldNotVisibleInWebEditAttribute; if (string.IsNullOrEmpty(attribute.Fieldname) || (!string.IsNullOrEmpty(attribute.Fieldname) && IsValidField(attribute.Fieldname))) { PopulateInstance(type, ref instance); string controlId = string.Format("{0}.{1}_{2}", type.Key.Namespace, type.Key.Name, propertyInfo.Name); Control foundControl = controlsOnPage.Where(c => c.ID == controlId).DefaultIfEmpty(null).First(); Assert.IsNotNull(foundControl, "Could not find the control {0}", controlId); propertyInfo.SetValue(instance, foundControl.Value, null); } } SheerResponse.CloseWindow(); } }
/// <summary> /// Executes the command in the specified context. /// </summary> /// <param name="context">The context.</param> public override void Execute(CommandContext context) { Assert.ArgumentNotNull((object)context, "context"); if (context.Items.Length != 1) { return; } NameValueCollection parameters = new NameValueCollection(); string itemID = context.Parameters["itemid"] ?? context.Parameters["id"]; ItemUri itemUri = ItemUri.ParseQueryString(); if (string.IsNullOrEmpty(itemID) && itemUri != (ItemUri)null) { itemID = itemUri.ItemID.ToString(); } parameters["itemid"] = itemID; string language = context.Parameters["language"]; if (string.IsNullOrEmpty(language)) { language = itemUri.Language.ToString(); } Sitecore.Data.Version version = itemUri.Version; parameters["database"] = itemUri.DatabaseName; parameters["language"] = language; parameters["navigate"] = context.Parameters["navigate"]; parameters["version"] = version.ToString(); Context.ClientPage.Start((object)this, "Run", parameters); }
/// <summary> /// Gets the content of the <c>treeview</c>. /// </summary> /// <returns> /// The <see cref="T:System.String" />. /// </returns> private string GetTreeViewContent() { Response.ContentType = "text/xml"; var queryString = ItemUri.ParseQueryString(); if (queryString == null) { return(string.Empty); } var parent = Database.GetItem(queryString); if (parent == null) { return(string.Empty); } var typeInfo = ReflectionUtil.GetTypeInfo(WebUtil.GetQueryString("typ")); if (typeInfo == null) { return(string.Empty); } var treeviewSource = ReflectionUtil.CreateObject(typeInfo) as TreeviewSource; if (treeviewSource == null) { return(string.Empty); } var treeview = new TreeView(); treeviewSource.Render(treeview, parent); return(treeview.GetXml()); }
public override void Execute(CommandContext context) { Assert.ArgumentNotNull(context, "context"); ItemUri itemUri = ItemUri.ParseQueryString(); if (itemUri != null) { Item item = Database.GetItem(itemUri); if (item != null && !Sitecore.Web.WebEditUtil.CanDesignItem(item)) { SheerResponse.Alert("The action cannot be executed because of security restrictions."); return; } } NameValueCollection nameValueCollection = new NameValueCollection(); string value = context.Parameters["referenceId"]; Assert.IsNotNullOrEmpty(value, "uniqueid must not be empty"); nameValueCollection["uniqueId"] = value; string value2 = context.Parameters["renderingId"]; Assert.IsNotNullOrEmpty(value2, "rendering item id must not be empty"); nameValueCollection["renderingItemId"] = value2; string value3 = context.Parameters["id"]; if (!string.IsNullOrEmpty(value3)) { nameValueCollection["id"] = value3; } Sitecore.Context.ClientPage.Start(this, "Run", nameValueCollection); }
/// <summary> /// Runs the processor. /// </summary> /// <param name="args">The arguments.</param> public override void Process(ConfigurationPipelineArgs args) { Item item = Context.Item; if (item == null && !string.IsNullOrEmpty(Sitecore.Web.WebUtil.GetQueryString())) { ItemUri uri = ItemUri.ParseQueryString(); if (uri != null) { item = Database.GetItem(uri); } } if (item == null) { return; } args.CustomData["item"] = item; string siteName = SiteUtils.GetSiteByItemPath(item.Paths.FullPath); if (string.IsNullOrEmpty(siteName)) { return; } using (new SiteContextSwitcher(Factory.GetSite(siteName))) { using (new SiteIndependentDatabaseSwitcher(item.Database)) { base.Process(args); } } }
private static List <Item> BuildItems() { List <Item> objList = new List <Item>(); ItemUri queryString = ItemUri.ParseQueryString(); Assert.IsNotNull((object)queryString, "Item Uri not found"); Item obj = Database.GetItem(queryString); Assert.IsNotNull((object)obj, "Item \"{0}\" not found.", (object)queryString.ToString()); return(Sitecore.Data.Masters.Masters.GetMasters(obj)); }
protected void OnJobStart(Message message) { var uri = ItemUri.ParseQueryString(); if (uri != null) { var validator = new ItemValidator { ItemUri = uri, Cookies = HttpContext.Current.Request.Cookies }; Monitor.Start("Preview", "Crownpeak", new JobWorker(validator).GetPreview); } }
public static DeleteContentOptions Parse() { ItemUri uri = ItemUri.ParseQueryString(); Assert.IsNotNull(uri, "itemUri is null"); Sitecore.Data.Items.Item item = Database.GetItem(uri); Assert.IsNotNull(item, "Item \"{0}\" not found", new object[] { uri }); DeleteContentOptions options = new DeleteContentOptions(item); options.ExpandStandardValuesTokens = MainUtil.GetBool(WebUtil.GetQueryString("expandtokens"), false); return(options); }
protected void OnJobStart(Message message) { var uri = ItemUri.ParseQueryString(); if (uri != null) { var checkpointId = HttpContext.Current.Request.QueryString["checkpointId"]; var validator = new ItemValidator { ItemUri = uri, CheckpointId = checkpointId, Cookies = HttpContext.Current.Request.Cookies }; Monitor.Start("Source", "Crownpeak", new JobWorker(validator).GetSource); } }
public override void Execute(CommandContext context) { try { Assert.ArgumentNotNull((object)context, "context"); NameValueCollection parameters = new NameValueCollection(); var item = context.Items[0]; if (item == null) { return; } parameters["database"] = item.Database.Name; // Get Language var itemUri = ItemUri.ParseQueryString(); var language = context.Parameters["language"]; if (itemUri == null) { Context.ClientPage.ClientResponse.Alert(Translate.Text("The Reset of the Component Changes is FAILED!")); return; } if (String.IsNullOrEmpty(language)) { language = itemUri.Language.ToString(); } parameters["language"] = language; // Store the custom parameters parameters["referenceId"] = context.Parameters["referenceId"] ?? String.Empty; parameters["version"] = itemUri.Version.Number.ToString(); parameters["itemId"] = itemUri.ItemID.ToString(); Context.ClientPage.Start((object)this, "Run", parameters); } catch (Exception ex) { Context.ClientPage.ClientResponse.Alert(Translate.Text("The Reset of the Component Changes is FAILED!")); Log.Error(ex.Message, ex.InnerException, this); } }
public override void Execute(CommandContext context) { Assert.ArgumentNotNull((object)context, "context"); NameValueCollection parameters = new NameValueCollection(); string str = context.Parameters["itemid"] ?? context.Parameters["id"]; ItemUri queryString = ItemUri.ParseQueryString(); if (string.IsNullOrEmpty(str) && queryString != (ItemUri)null) { str = queryString.ItemID.ToString(); } parameters["itemid"] = str; string parameter = context.Parameters["language"]; if (string.IsNullOrEmpty(parameter) && queryString != (ItemUri)null) { parameter = queryString.Language.ToString(); } parameters["language"] = parameter; parameters["navigate"] = context.Parameters["navigate"]; Context.ClientPage.Start((object)this, "Run", parameters); }
/// <summary> /// Main execution point of the WebEditCommand /// </summary> public override void Execute(CommandContext context) { Assert.ArgumentNotNull((object)context, "context"); NameValueCollection parameters = new NameValueCollection(); // Get Language var itemUri = ItemUri.ParseQueryString(); var language = context.Parameters["language"]; if (String.IsNullOrEmpty(language) && itemUri != null) { language = itemUri.Language.ToString(); } // Store the custom parameters parameters["language"] = language; parameters["parentId"] = context.Parameters["parentId"]; parameters["templateId"] = context.Parameters["templateId"]; parameters["fieldId"] = context.Parameters["fieldId"] ?? String.Empty; Context.ClientPage.Start((object)this, "Run", parameters); }
/// <summary> /// Gets the command context. /// </summary> /// <returns>The command context.</returns> public virtual CommandContext GetCommandContext() { var uri = ItemUri.ParseQueryString(); var context = uri != null ? new CommandContext(Database.GetItem(uri)) : new CommandContext(); context.CustomData = this; if (this.RibbonSourceUri == null) { return(context); } context.RibbonSourceUri = this.RibbonSourceUri; context.Parameters["Ribbon.RenderTabs"] = "true"; context.Parameters["Ribbon.RenderAsContextual"] = "true"; context.Parameters["Ribbon.RenderContextualStripTitles"] = "true"; if (!this.Page.ClientScript.IsClientScriptBlockRegistered("load")) { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "load", "scCatalog.showRibbon();", true); } return(context); }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Load"/> event. /// </summary> /// <param name="e">The <see cref="T:System.EventArgs"/> object that contains the event data.</param> protected override void OnLoad(EventArgs e) { Assert.ArgumentNotNull((object)e, "e"); base.OnLoad(e); if (XamlControl.AjaxScriptManager.IsEvent) { return; } this.ImageWidth = 0; this.ImageHeight = 0; ItemUri uri = ItemUri.ParseQueryString(); if (uri == (ItemUri)null) { return; } Item obj = Database.GetItem(uri); if (obj == null) { return; } string text = obj["Dimensions"]; if (string.IsNullOrEmpty(text)) { return; } int length = text.IndexOf('x'); if (length < 0) { return; } this.ImageWidth = MainUtil.GetInt(StringUtil.Left(text, length).Trim(), 0); this.ImageHeight = MainUtil.GetInt(StringUtil.Mid(text, length + 1).Trim(), 0); if (this.ImageWidth <= 0 || this.ImageHeight <= 0) { this.Aspect.Checked = false; this.Aspect.Disabled = true; } else { this.Aspect.Checked = true; } if (this.ImageWidth > 0) { this.OriginalSize.Text = Translate.Text("Original Dimensions: {0} x {1}", (object)this.ImageWidth, (object)this.ImageHeight); } if (MainUtil.GetLong((object)obj["Size"], 0L) >= Settings.Media.MaxSizeInMemory) { this.HeightEdit.Enabled = false; this.WidthEdit.Enabled = false; this.Aspect.Disabled = true; } else { this.SizeWarning.Visible = false; } this.OriginalText.Text = StringUtil.GetString(new string[2] { obj["Alt"], Translate.Text("[none]") }); UrlHandle urlHandle = UrlHandle.Get(); XmlValue xmlValue = new XmlValue(urlHandle["xmlvalue"], "image"); this.XmlValue = xmlValue; this.Alt.Text = xmlValue.GetAttribute("alt"); this.HeightEdit.Text = xmlValue.GetAttribute("height"); this.WidthEdit.Text = xmlValue.GetAttribute("width"); this.HSpace.Text = xmlValue.GetAttribute("hspace"); this.VSpace.Text = xmlValue.GetAttribute("vspace"); this.Img.ImageUrl = this.GetMediaUrl(obj); this.Img.Height = imageHeight; this.OriginalWidth.Value = obj["Width"]; this.OriginalHeight.Value = obj["Height"]; this.X1.Text = this.GetCoordinateValue(xmlValue, "x1"); this.X2.Text = this.GetCoordinateValue(xmlValue, "x2"); this.Y1.Text = this.GetCoordinateValue(xmlValue, "y1"); this.Y2.Text = this.GetCoordinateValue(xmlValue, "y2"); this.Ratio.Value = xmlValue.GetAttribute("ratio"); if (!string.IsNullOrWhiteSpace(this.Ratio.Value)) { HeightEdit.Enabled = false; WidthEdit.Enabled = false; CroppingOptions.Visible = false; } if (MainUtil.GetBool(urlHandle["disableheight"], false)) { this.HeightEdit.Enabled = false; this.Aspect.Checked = false; this.Aspect.Disabled = true; } if (!string.IsNullOrEmpty(this.GetCoordinateValue(xmlValue, "x2"))) { var croppedWidth = Math.Round((decimal)(int.Parse(this.GetCoordinateValue(xmlValue, "x2")) - int.Parse(this.GetCoordinateValue(xmlValue, "x1")))); var croppedHeight = Math.Round((decimal)(int.Parse(this.GetCoordinateValue(xmlValue, "y2")) - int.Parse(this.GetCoordinateValue(xmlValue, "y1")))); //var str3 = xmlValue.GetAttribute("width"); //var str4 = xmlValue.GetAttribute("height"); //if (string.IsNullOrEmpty(str3) || string.IsNullOrEmpty(str4)) //{ // str3 = croppedWidth.ToString(); // str4 = croppedHeight.ToString(); //} //else //{ // str3 = Math.Round((decimal)croppedWidth * int.Parse(str4) / croppedHeight).ToString(); //} this.CroppedSize.Text = Translate.Text("Cropped Dimensions before resizing: {0} x {1}", (object)croppedWidth, (object)croppedHeight); } if (!MainUtil.GetBool(urlHandle["disablewidth"], false)) { return; } this.WidthEdit.Enabled = false; this.Aspect.Checked = false; this.Aspect.Disabled = true; }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (Context.ClientPage.IsEvent) { return; } ItemUri uri = ItemUri.ParseQueryString(); item = Database.GetItem(uri); var properties = Reflection.FindProperties.GetProperties(); foreach (var type in properties) { object instance = null; List <string> asd = new List <string>(); foreach (PropertyInfo propertyInfo in type.Value.OrderBy(t => { var attribute = t.GetCustomAttributes(typeof(FieldNotVisibleInWebEditAttribute), true).First() as FieldNotVisibleInWebEditAttribute; return(attribute.Order); })) { var attribute = propertyInfo.GetCustomAttributes(typeof(FieldNotVisibleInWebEditAttribute), true).First() as FieldNotVisibleInWebEditAttribute; if (string.IsNullOrEmpty(attribute.Fieldname) || (!string.IsNullOrEmpty(attribute.Fieldname) && IsValidField(attribute.Fieldname))) { this.PopulateInstance(type, ref instance); Control control = Activator.CreateInstance(attribute.ControlType) as Control; Assert.IsNotNull(control, "Controltype in attribute, is not a valid Sitecore.Web.UI.HtmlControls control"); string propertyResult = propertyInfo.GetValue(instance, null).ToString(); string controlId = string.Format("{0}.{1}_{2}", type.Key.Namespace, type.Key.Name, propertyInfo.Name); Label controlLabel = new Label(); string header = !string.IsNullOrEmpty(attribute.Name) ? attribute.Name : propertyInfo.Name; string description = this.GetDescription(attribute.Fieldname); if (!string.IsNullOrEmpty(description)) { header += string.Format(" - {0}", description); } controlLabel.Header = header; controlLabel.ToolTip = this.GetToolTip(attribute.Fieldname); controlLabel.For = controlId; control.Value = propertyResult; control.ID = controlId; Section section = this.GetSectionControl(attribute.Fieldname); section.Controls.Add(controlLabel); section.Controls.Add(control); } } } foreach (Section section in _sections.OrderBy(t => t.Value.Order).Select(t => t.Value)) { InputFields.Controls.Add(section); } }