protected void Page_Load(object sender, System.EventArgs e) { sbmt.Text = ui.Text("create"); int NodeId = int.Parse(Request["nodeID"]); int[] allowedIds = new int[0]; if (NodeId > 2) { cms.businesslogic.Content c = new cms.businesslogic.media.Media(NodeId); allowedIds = c.ContentType.AllowedChildContentTypeIDs; } foreach(cms.businesslogic.ContentType dt in cms.businesslogic.media.MediaType.GetAll) { ListItem li = new ListItem(); li.Text = dt.Text; li.Value = dt.Id.ToString(); if (NodeId > 2) { foreach (int i in allowedIds) if (i == dt.Id) nodeType.Items.Add(li); } else nodeType.Items.Add(li); } }
protected void Page_Load(object sender, System.EventArgs e) { sbmt.Text = ui.Text("create"); int NodeId = int.Parse(Request["nodeID"]); int[] allowedIds = new int[0]; if (NodeId > 2) { cms.businesslogic.Content c = new cms.businesslogic.media.Media(NodeId); allowedIds = c.ContentType.AllowedChildContentTypeIDs; } foreach (cms.businesslogic.ContentType dt in cms.businesslogic.media.MediaType.GetAll) { ListItem li = new ListItem(); li.Text = dt.Text; li.Value = dt.Id.ToString(); if (NodeId > 2) { foreach (int i in allowedIds) { if (i == dt.Id) { nodeType.Items.Add(li); } } } else { nodeType.Items.Add(li); } } }
protected override void Render(HtmlTextWriter writer) { uploadfield.DataTypeUploadField uft = new uploadfield.DataTypeUploadField(); cms.businesslogic.Content c = cms.businesslogic.media.Media.GetContentFromVersion(_data.Version); //store children array here because iterating over an Array property object is very inneficient. var children = c.Children; foreach (BusinessLogic.console.IconI cc in children) { cms.businesslogic.media.Media m = new cms.businesslogic.media.Media(cc.UniqueId); var props = m.getProperties; foreach (cms.businesslogic.property.Property p in props) { if (p.PropertyType.DataTypeDefinition.DataType.Id == uft.Id && p.Value.ToString() != "") { // Check for thumbnail! string fileNameOrg = p.Value.ToString(); string ext = fileNameOrg.Substring(fileNameOrg.LastIndexOf(".") + 1, fileNameOrg.Length - fileNameOrg.LastIndexOf(".") - 1); string fileNameThumb = fileNameOrg.Replace("." + ext, "_thumb.jpg"); if (File.Exists(IOHelper.MapPath(IOHelper.FindFile(fileNameThumb)))) { writer.WriteLine("<a href=\"?id=" + m.Id.ToString() + "\"><img src=\"" + IOHelper.ResolveUrl(fileNameThumb) + "\" alt=\"" + m.Text + "\" style=\"border: none\"/></a> "); } } } } base.Render(writer); }
override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); _media = new cms.businesslogic.media.Media(int.Parse(Request.QueryString["id"])); // Save media on first load bool exists = SqlHelper.ExecuteScalar <int>("SELECT COUNT(nodeId) FROM cmsContentXml WHERE nodeId = @nodeId", SqlHelper.CreateParameter("@nodeId", _media.Id)) > 0; if (!exists) { _media.XmlGenerate(new XmlDocument()); } tmp = new controls.ContentControl(_media, controls.ContentControl.publishModes.NoPublish, "TabView1"); tmp.Width = Unit.Pixel(666); tmp.Height = Unit.Pixel(666); plc.Controls.Add(tmp); tmp.Save += new System.EventHandler(Save); }
protected void Page_Load(object sender, System.EventArgs e) { sbmt.Text = ui.Text("create"); int NodeId = int.Parse(Request["nodeID"]); int[] allowedIds = new int[0]; if (NodeId > 2) { cms.businesslogic.Content c = new cms.businesslogic.media.Media(NodeId); allowedIds = c.ContentType.AllowedChildContentTypeIDs; } var documentTypeList = businesslogic.media.MediaType.GetAllAsList().ToList(); foreach (var dt in documentTypeList) { ListItem li = new ListItem(); li.Text = dt.Text; li.Value = dt.Id.ToString(); if (NodeId > 2) { foreach (int i in allowedIds) if (i == dt.Id) nodeType.Items.Add(li); } // The Any check is here for backwards compatibility, if none are allowed at root, then all are allowed else if (documentTypeList.Any(d => d.AllowAtRoot) == false || dt.AllowAtRoot) nodeType.Items.Add(li); } }
public string Media(string propertyAlias, string mediaPropertyAlias) { if (n != null) { IProperty prop = n.GetProperty(propertyAlias); if (prop == null && propertyAlias.Substring(0, 1).ToUpper() == propertyAlias.Substring(0, 1)) { prop = n.GetProperty(propertyAlias.Substring(0, 1).ToLower() + propertyAlias.Substring((1))); } if (prop != null) { int mediaNodeId; if (int.TryParse(prop.Value, out mediaNodeId)) { umbraco.cms.businesslogic.media.Media media = new cms.businesslogic.media.Media(mediaNodeId); if (media != null) { Property mprop = media.getProperty(mediaPropertyAlias); // check for nicer support of Pascal Casing EVEN if alias is camelCasing: if (prop == null && mediaPropertyAlias.Substring(0, 1).ToUpper() == mediaPropertyAlias.Substring(0, 1)) { mprop = media.getProperty(mediaPropertyAlias.Substring(0, 1).ToLower() + mediaPropertyAlias.Substring((1))); } if (mprop != null) { return(string.Format("{0}", mprop.Value)); } } } } } return(null); }
protected void Page_Load(object sender, System.EventArgs e) { //Response.Write(umbraco.helper.Request("id")); //Response.End(); // Put user code to initialize the page here if (Request.QueryString["id"] != null) { if (Request.QueryString["id"] != "") { //TODO: fix Nasty FAST'N'CANELINE HACK. .. int MediaId = int.Parse(Request.QueryString["id"]); image.Controls.Clear(); int fileWidth = 0; int fileHeight = 0; string fileName = "/blank.gif"; string altText = ""; try { cms.businesslogic.media.Media m = new cms.businesslogic.media.Media(MediaId); // TODO: Remove "Magic strings" from code. try { fileName = m.getProperty("fileName").Value.ToString(); } catch { try { fileName = m.getProperty("umbracoFile").Value.ToString(); } catch { fileName = m.getProperty("file").Value.ToString(); } } altText = m.Text; try { fileWidth = int.Parse(m.getProperty("umbracoWidth").Value.ToString()); fileHeight = int.Parse(m.getProperty("umbracoHeight").Value.ToString()); } catch { } string fileNameOrg = fileName; string ext = fileNameOrg.Substring(fileNameOrg.LastIndexOf(".") + 1, fileNameOrg.Length - fileNameOrg.LastIndexOf(".") - 1); string fileNameThumb = SystemDirectories.Root + fileNameOrg.Replace("." + ext, "_thumb.jpg"); image.Controls.Add(new LiteralControl("<a href=\"" + SystemDirectories.Root + fileNameOrg + "\" title=\"Zoom\"><img src=\"" + fileNameThumb + "\" border=\"0\"/></a>")); } catch { } image.Controls.Add(new LiteralControl("<script>\nparent.updateImageSource('" + SystemDirectories.Root + fileName.Replace("'", "\\'") + "','" + altText + "','" + fileWidth.ToString() + "','" + fileHeight.ToString() + "')\n</script>")); } } }
protected void Page_Load(object sender, System.EventArgs e) { _document = new cms.businesslogic.media.Media(int.Parse(Request.QueryString["id"])); tmp = new controls.ContentControl(_document, controls.ContentControl.publishModes.NoPublish, "TabView1"); tmp.Width = Unit.Pixel(666); tmp.Height = Unit.Pixel(666); plc.Controls.Add(tmp); }
protected void Page_Load(object sender, System.EventArgs e) { _document = new cms.businesslogic.media.Media(int.Parse(Request.QueryString["id"])); tmp = new controls.ContentControl(_document,controls.ContentControl.publishModes.NoPublish, "TabView1"); tmp.Width = Unit.Pixel(666); tmp.Height = Unit.Pixel(666); plc.Controls.Add(tmp); }
//protected System.Web.UI.WebControls.Literal SyncPath; override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); _media = new cms.businesslogic.media.Media(int.Parse(Request.QueryString["id"])); // Save media on first load bool exists = SqlHelper.ExecuteScalar <int>("SELECT COUNT(nodeId) FROM cmsContentXml WHERE nodeId = @nodeId", SqlHelper.CreateParameter("@nodeId", _media.Id)) > 0; if (!exists) { _media.XmlGenerate(new XmlDocument()); } tmp = new controls.ContentControl(_media, controls.ContentControl.publishModes.NoPublish, "TabView1"); tmp.Width = Unit.Pixel(666); tmp.Height = Unit.Pixel(666); plc.Controls.Add(tmp); tmp.Save += new System.EventHandler(Save); this.updateDateLiteral.ID = "updateDate"; this.updateDateLiteral.Text = _media.VersionDate.ToShortDateString() + " " + _media.VersionDate.ToShortTimeString(); this.mediaFileLinksLiteral.ID = "mediaFileLinks"; mediaPropertiesPane.addProperty(ui.Text("content", "updateDate", base.getUser()), this.updateDateLiteral); this.UpdateMediaFileLinksLiteral(); mediaPropertiesPane.addProperty(ui.Text("content", "mediaLinks"), this.mediaFileLinksLiteral); // add the property pane to the page rendering tmp.tpProp.Controls.AddAt(1, mediaPropertiesPane); }
protected override void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); _media = new cms.businesslogic.media.Media(int.Parse(Request.QueryString["id"])); // Save media on first load bool exists = SqlHelper.ExecuteScalar<int>("SELECT COUNT(nodeId) FROM cmsContentXml WHERE nodeId = @nodeId", SqlHelper.CreateParameter("@nodeId", _media.Id)) > 0; if (!exists) _media.XmlGenerate(new XmlDocument()); tmp = new controls.ContentControl(_media,controls.ContentControl.publishModes.NoPublish, "TabView1"); tmp.Width = Unit.Pixel(666); tmp.Height = Unit.Pixel(666); plc.Controls.Add(tmp); tmp.Save += new System.EventHandler(Save); }
protected void Page_Load(object sender, System.EventArgs e) { sbmt.Text = ui.Text("create"); int NodeId = int.Parse(Request["nodeID"]); int[] allowedIds = new int[0]; if (NodeId > 2) { cms.businesslogic.Content c = new cms.businesslogic.media.Media(NodeId); allowedIds = c.ContentType.AllowedChildContentTypeIDs; } var documentTypeList = businesslogic.media.MediaType.GetAllAsList().ToList(); foreach (var dt in documentTypeList) { ListItem li = new ListItem(); li.Text = dt.Text; li.Value = dt.Id.ToString(); if (NodeId > 2) { foreach (int i in allowedIds) { if (i == dt.Id) { nodeType.Items.Add(li); } } } // The Any check is here for backwards compatibility, if none are allowed at root, then all are allowed else if (documentTypeList.Any(d => d.AllowAtRoot) == false || dt.AllowAtRoot) { nodeType.Items.Add(li); } } }
//protected System.Web.UI.WebControls.Literal SyncPath; override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); _media = new cms.businesslogic.media.Media(int.Parse(Request.QueryString["id"])); // Save media on first load bool exists = SqlHelper.ExecuteScalar<int>("SELECT COUNT(nodeId) FROM cmsContentXml WHERE nodeId = @nodeId", SqlHelper.CreateParameter("@nodeId", _media.Id)) > 0; if (!exists) _media.XmlGenerate(new XmlDocument()); tmp = new controls.ContentControl(_media, controls.ContentControl.publishModes.NoPublish, "TabView1"); tmp.Width = Unit.Pixel(666); tmp.Height = Unit.Pixel(666); plc.Controls.Add(tmp); tmp.Save += new System.EventHandler(Save); this.updateDateLiteral.ID = "updateDate"; this.updateDateLiteral.Text = _media.VersionDate.ToShortDateString() + " " + _media.VersionDate.ToShortTimeString(); this.mediaFileLinksLiteral.ID = "mediaFileLinks"; mediaPropertiesPane.addProperty(ui.Text("content", "updateDate", base.getUser()), this.updateDateLiteral); this.UpdateMediaFileLinksLiteral(); mediaPropertiesPane.addProperty(ui.Text("content", "mediaLinks"), this.mediaFileLinksLiteral); // add the property pane to the page rendering tmp.tpProp.Controls.AddAt(1, mediaPropertiesPane); }
protected void Page_Load(object sender, System.EventArgs e) { //Response.Write(umbraco.helper.Request("id")); //Response.End(); // Put user code to initialize the page here if (Request.QueryString["id"] != null) { if (Request.QueryString["id"] != "") { //TODO: fix Nasty FAST'N'CANELINE HACK. .. int MediaId = int.Parse(Request.QueryString["id"]); image.Controls.Clear(); int fileWidth = 0; int fileHeight = 0; string fileName = "/blank.gif"; string altText = ""; try { cms.businesslogic.media.Media m = new cms.businesslogic.media.Media(MediaId); // TODO: Remove "Magic strings" from code. try { fileName = m.getProperty("fileName").Value.ToString(); } catch { try { fileName = m.getProperty("umbracoFile").Value.ToString(); } catch { fileName = m.getProperty("file").Value.ToString(); } } altText = m.Text; try { fileWidth = int.Parse(m.getProperty("umbracoWidth").Value.ToString()); fileHeight = int.Parse(m.getProperty("umbracoHeight").Value.ToString()); } catch { } string fileNameOrg = fileName; string ext = fileNameOrg.Substring(fileNameOrg.LastIndexOf(".")+1, fileNameOrg.Length-fileNameOrg.LastIndexOf(".")-1); string fileNameThumb = SystemDirectories.Root + fileNameOrg.Replace("."+ext, "_thumb.jpg"); image.Controls.Add(new LiteralControl("<a href=\"" + SystemDirectories.Root + fileNameOrg + "\" title=\"Zoom\"><img src=\"" + fileNameThumb + "\" border=\"0\"/></a>")); } catch { } image.Controls.Add(new LiteralControl("<script>\nparent.updateImageSource('" + SystemDirectories.Root + fileName.Replace("'", "\\'") + "','" + altText + "','" + fileWidth.ToString() + "','" + fileHeight.ToString() + "')\n</script>")); } } }
public string Media(string propertyAlias, string mediaPropertyAlias) { if (n != null) { IProperty prop = n.GetProperty(propertyAlias); if (prop == null && propertyAlias.Substring(0, 1).ToUpper() == propertyAlias.Substring(0, 1)) { prop = n.GetProperty(propertyAlias.Substring(0, 1).ToLower() + propertyAlias.Substring((1))); } if (prop != null) { int mediaNodeId; if (int.TryParse(prop.Value, out mediaNodeId)) { umbraco.cms.businesslogic.media.Media media = new cms.businesslogic.media.Media(mediaNodeId); if (media != null) { Property mprop = media.getProperty(mediaPropertyAlias); // check for nicer support of Pascal Casing EVEN if alias is camelCasing: if (prop == null && mediaPropertyAlias.Substring(0, 1).ToUpper() == mediaPropertyAlias.Substring(0, 1)) { mprop = media.getProperty(mediaPropertyAlias.Substring(0, 1).ToLower() + mediaPropertyAlias.Substring((1))); } if (mprop != null) { return string.Format("{0}", mprop.Value); } } } } } return null; }
public void UpdateSortOrder(int ParentId, string SortOrder) { //TODO: The amount of processing this method takes is HUGE. We should look at // refactoring this to use purely the new APIs and see how much faster we can make it! try { if (AuthorizeRequest() == false) return; if (SortOrder.Trim().Length <= 0) return; var ids = SortOrder.Split(','); var isContent = helper.Request("app") == "content" | helper.Request("app") == ""; var isMedia = helper.Request("app") == "media"; //ensure user is authorized for the app requested if (isContent && AuthorizeRequest(DefaultApps.content.ToString()) == false) return; if (isMedia && AuthorizeRequest(DefaultApps.media.ToString()) == false) return; for (var i = 0; i < ids.Length; i++) { if (ids[i] == "" || ids[i].Trim() == "") continue; if (isContent) { var document = new Document(int.Parse(ids[i])) { sortOrder = i }; if (document.Published) { document.Publish(BusinessLogic.User.GetCurrent()); //TODO: WE don't want to have to republish the entire document !!!! library.UpdateDocumentCache(document); } else { //we need to save it if it is not published to persist the sort order value document.Save(); } } // to update the sortorder of the media node in the XML, re-save the node.... else if (isMedia) { var media = new cms.businesslogic.media.Media(int.Parse(ids[i])) { sortOrder = i }; media.Save(); } // Refresh sort order on cached xml if (isContent) { XmlNode parentNode = ParentId == -1 ? content.Instance.XmlContent.DocumentElement : content.Instance.XmlContent.GetElementById(ParentId.ToString()); //only try to do the content sort if the the parent node is available... if (parentNode != null) content.SortNodes(ref parentNode); // Load balancing - then refresh entire cache if (UmbracoSettings.UseDistributedCalls) library.RefreshContent(); // fire actionhandler, check for content BusinessLogic.Actions.Action.RunActionHandlers(new Document(ParentId), ActionSort.Instance); } } } catch (Exception ex) { LogHelper.Error<nodeSorter>("Could not update sort order", ex); } }
public void UpdateSortOrder(int ParentId, string SortOrder) { //TODO: The amount of processing this method takes is HUGE. We should look at // refactoring this to use purely the new APIs and see how much faster we can make it! try { if (AuthorizeRequest() == false) { return; } if (SortOrder.Trim().Length <= 0) { return; } var ids = SortOrder.Split(','); var isContent = helper.Request("app") == "content" | helper.Request("app") == ""; var isMedia = helper.Request("app") == "media"; //ensure user is authorized for the app requested if (isContent && AuthorizeRequest(DefaultApps.content.ToString()) == false) { return; } if (isMedia && AuthorizeRequest(DefaultApps.media.ToString()) == false) { return; } for (var i = 0; i < ids.Length; i++) { if (ids[i] == "" || ids[i].Trim() == "") { continue; } if (isContent) { var document = new Document(int.Parse(ids[i])) { sortOrder = i }; if (document.Published) { document.Publish(BusinessLogic.User.GetCurrent()); //TODO: WE don't want to have to republish the entire document !!!! library.UpdateDocumentCache(document); } else { //we need to save it if it is not published to persist the sort order value document.Save(); } } // to update the sortorder of the media node in the XML, re-save the node.... else if (isMedia) { var media = new cms.businesslogic.media.Media(int.Parse(ids[i])) { sortOrder = i }; media.Save(); } // Refresh sort order on cached xml if (isContent) { XmlNode parentNode = ParentId == -1 ? content.Instance.XmlContent.DocumentElement : content.Instance.XmlContent.GetElementById(ParentId.ToString()); //only try to do the content sort if the the parent node is available... if (parentNode != null) { content.SortNodes(ref parentNode); } // Load balancing - then refresh entire cache if (UmbracoSettings.UseDistributedCalls) { library.RefreshContent(); } // fire actionhandler, check for content BusinessLogic.Actions.Action.RunActionHandlers(new Document(ParentId), ActionSort.Instance); } } } catch (Exception ex) { LogHelper.Error <nodeSorter>("Could not update sort order", ex); } }