Exemple #1
0
 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);
 }
Exemple #2
0
        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)
		{
			//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;
 }