/// <summary>
        /// returns a string "Property '[propertyAlias]' with RelationType '[relationTypeName]"
        /// </summary>
        /// <returns></returns>
        private string GetMappingDetails()
        {
            string mappingDetails = string.Empty;

            UmbracoContent currentContentNode = new UmbracoContent(this.CurrentContentId);
            Property       pickerProperty     = currentContentNode.getProperty(this.options.PropertyAlias);

            if (pickerProperty != null)
            {
                RelationType relationType = new RelationType(this.options.RelationTypeId); // Does it still exist ? TODO: check

                if (this.IsContextUmbracoObjectTypeValid(this.CurrentContextObjectType, relationType))
                {
                    mappingDetails = "Property '<strong>" + pickerProperty.PropertyType.Name + "</strong>' with " +
                                     "Relation Type '<strong>" + relationType.Name + "</strong>'";

                    if (this.options.ReverseIndexing)
                    {
                        mappingDetails += " <i>(Reverse Index)</i>";
                    }
                }
                else
                {
                    throw new Exception("Conflict with this Content Object Type and that expected by the Relation Type '" + relationType.Name + "'");
                }
            }
            else
            {
                throw new Exception("Can't find a Property with the Alias '" + this.options.PropertyAlias + "'");
            }

            return(mappingDetails);
        }
        /// <summary>
        /// Converts a content node to Xml
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        private static XDocument ToXDocument(Content node)
        {
            if (TypeHelper.IsTypeAssignableFrom <Document>(node))
            {
                return(new XDocument(((Document)node).ContentEntity.ToXml()));
            }

            if (TypeHelper.IsTypeAssignableFrom <global::umbraco.cms.businesslogic.media.Media>(node))
            {
                return(new XDocument(((global::umbraco.cms.businesslogic.media.Media)node).MediaItem.ToXml()));
            }

            var xDoc  = new XmlDocument();
            var xNode = xDoc.CreateNode(XmlNodeType.Element, "node", "");

            node.XmlPopulate(xDoc, ref xNode, false);

            if (xNode.Attributes["nodeTypeAlias"] == null)
            {
                //we'll add the nodeTypeAlias ourselves
                XmlAttribute d = xDoc.CreateAttribute("nodeTypeAlias");
                d.Value = node.ContentType.Alias;
                xNode.Attributes.Append(d);
            }

            return(new XDocument(ExamineXmlExtensions.ToXElement(xNode)));
        }
Exemple #3
0
        private string formatMedia(string html)
        {
            // Local media path
            string localMediaPath = getLocalMediaPath();

            // Find all media images
            string pattern = "<img [^>]*src=\"(?<mediaString>/media[^\"]*)\" [^>]*>";

            MatchCollection tags =
                Regex.Matches(html, pattern, RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);

            foreach (Match tag in tags)
            {
                if (tag.Groups.Count > 0)
                {
                    // Replace /> to ensure we're in old-school html mode
                    string tempTag = "<img";
                    string orgSrc  = tag.Groups["mediaString"].Value;

                    // gather all attributes
                    // TODO: This should be replaced with a general helper method - but for now we'll wanna leave Umbraco.dll alone for this patch
                    Hashtable       ht = new Hashtable();
                    MatchCollection m  =
                        Regex.Matches(tag.Value.Replace(">", " >"),
                                      "(?<attributeName>\\S*)=\"(?<attributeValue>[^\"]*)\"|(?<attributeName>\\S*)=(?<attributeValue>[^\"|\\s]*)\\s",
                                      RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
                    foreach (Match attributeSet in m)
                    {
                        if (attributeSet.Groups["attributeName"].Value.ToString().ToLower() != "src")
                        {
                            ht.Add(attributeSet.Groups["attributeName"].Value.ToString(),
                                   attributeSet.Groups["attributeValue"].Value.ToString());
                        }
                    }

                    // build the element
                    // Build image tag
                    IDictionaryEnumerator ide = ht.GetEnumerator();
                    while (ide.MoveNext())
                    {
                        tempTag += " " + ide.Key.ToString() + "=\"" + ide.Value.ToString() + "\"";
                    }

                    // Find the original filename, by removing the might added width and height
                    orgSrc =
                        orgSrc.Replace(
                            "_" + helper.FindAttribute(ht, "width") + "x" + helper.FindAttribute(ht, "height"), "").
                        Replace("%20", " ");

                    // Check for either id or guid from media
                    string mediaId = getIdFromSource(orgSrc, localMediaPath);

                    Media imageMedia = null;

                    try
                    {
                        int      mId = int.Parse(mediaId);
                        Property p   = new Property(mId);
                        imageMedia = new Media(Content.GetContentFromVersion(p.VersionId).Id);
                    }
                    catch
                    {
                        try
                        {
                            imageMedia = new Media(Content.GetContentFromVersion(new Guid(mediaId)).Id);
                        }
                        catch
                        {
                        }
                    }

                    // Check with the database if any media matches this url
                    if (imageMedia != null)
                    {
                        try
                        {
                            // Check extention
                            if (imageMedia.getProperty("umbracoExtension").Value.ToString() != orgSrc.Substring(orgSrc.LastIndexOf(".") + 1, orgSrc.Length - orgSrc.LastIndexOf(".") - 1))
                            {
                                orgSrc = orgSrc.Substring(0, orgSrc.LastIndexOf(".") + 1) +
                                         imageMedia.getProperty("umbracoExtension").Value.ToString();
                            }

                            // Format the tag
                            tempTag = tempTag + " rel=\"" +
                                      imageMedia.getProperty("umbracoWidth").Value.ToString() + "," +
                                      imageMedia.getProperty("umbracoHeight").Value.ToString() + "\" src=\"" + orgSrc +
                                      "\"";
                            tempTag += "/>";

                            // Replace the tag
                            html = html.Replace(tag.Value, tempTag);
                        }
                        catch (Exception ee)
                        {
                            Log.Add(LogTypes.Error, User.GetUser(0), -1,
                                    "Error reading size data from media: " + imageMedia.Id.ToString() + ", " +
                                    ee.ToString());
                        }
                    }
                    else
                    {
                        Log.Add(LogTypes.Error, User.GetUser(0), -1,
                                "Error reading size data from media (not found): " + orgSrc);
                    }
                }
            }
            return(html);
        }
Exemple #4
0
		/// <summary>
		/// Event handler for the selected node repeater. 
		/// This will fill in all of the text values, icons, etc.. for nodes based on their ID.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		void SelectedValues_ItemDataBound(object sender, RepeaterItemEventArgs e)
		{
			var liSelectNode = (HtmlGenericControl)e.Item.FindControl("SelectedNodeListItem");
			var lnkSelectNode = (HtmlAnchor)e.Item.FindControl("SelectedNodeLink");
			var litSelectNodeName = (Literal)e.Item.FindControl("SelectedNodeText");
			var infoButton = (HtmlAnchor)e.Item.FindControl("InfoButton");

			//hide the info button if tooltips are hidden
			if (!ShowToolTips)
			{
				infoButton.Style.Add(HtmlTextWriterStyle.Display, "none");
			}

			var thisNode = (XElement)e.Item.DataItem;
			int thisNodeId;
			if (int.TryParse(thisNode.Value, out thisNodeId))
			{
				umbraco.cms.businesslogic.Content loadedNode;

				try
				{
					loadedNode = new umbraco.cms.businesslogic.Content(thisNodeId);

					//add the node id
					liSelectNode.Attributes["rel"] = thisNodeId.ToString();
					//add the path to be referenced
					liSelectNode.Attributes["umb:nodedata"] = loadedNode.Path;
					lnkSelectNode.HRef = "javascript:void(0);";
					litSelectNodeName.Text = loadedNode.Text;

					if (loadedNode.IsTrashed)
					{
						//need to flag this to be removed which will be done after all items are data bound
						liSelectNode.Attributes["rel"] = "trashed";
					}
					else
					{
						//we need to set the icon
						if (loadedNode.ContentTypeIcon.StartsWith(".spr"))
							lnkSelectNode.Attributes["class"] += " " + loadedNode.ContentTypeIcon.TrimStart('.');
						else
						{
							//it's a real icon, so make it a background image
							lnkSelectNode.Style.Add(HtmlTextWriterStyle.BackgroundImage,
								string.Format("url('{0}')", IconPath + loadedNode.ContentTypeIcon));
							//set the nospr class since it's not a sprite
							lnkSelectNode.Attributes["class"] += " noSpr";
						}

						//show the media preview if media and allowed                    
						if (TreeToRender == "media" && ShowThumbnailsForMedia)
						{
							var imgPreview = (ImageViewer)e.Item.FindControl("ImgPreview");
							//show the thubmnail controls
							imgPreview.Visible = true;

							//add the item class
							var item = (HtmlGenericControl)e.Item.FindControl("Item");
							item.Attributes["class"] += " thumb-item";

							//item.Style.Add(HtmlTextWriterStyle.Height, "50px");
							////make the content sit beside the item
							//var inner = (HtmlGenericControl)e.Item.FindControl("InnerItem");
							//inner.Style.Add(HtmlTextWriterStyle.Width, "224px");

							//check if it's a thumbnail type element, we need to check both schemas                        
							if (MediaTypesWithThumbnails.Select(x => x.ToUpper())
								.Contains(loadedNode.ContentType.Alias.ToUpper()))
							{
								imgPreview.MediaId = thisNodeId;
								imgPreview.DataBind();
							}
						}
					}

				}
				catch (ArgumentException)
				{
					//the node no longer exists, so we display a msg
					litSelectNodeName.Text = "<i>NODE NO LONGER EXISTS</i>";
				}
			}
		}
 public static XDocument ToXDocument(Content node, bool cacheOnly)
 {
     return(ToXDocument(node));
 }
Exemple #6
0
        public Control parseStringBuilder(StringBuilder tempOutput, page umbPage)
        {

            Control pageContent = new Control();

            bool stop = false;
            bool debugMode = umbraco.presentation.UmbracoContext.Current.Request.IsDebug;

            while (!stop)
            {
                System.Web.HttpContext.Current.Trace.Write("template", "Begining of parsing rutine...");
                int tagIndex = tempOutput.ToString().ToLower().IndexOf("<?umbraco");
                if (tagIndex > -1)
                {
                    String tempElementContent = "";
                    pageContent.Controls.Add(new LiteralControl(tempOutput.ToString().Substring(0, tagIndex)));

                    tempOutput.Remove(0, tagIndex);

                    String tag = tempOutput.ToString().Substring(0, tempOutput.ToString().IndexOf(">") + 1);
                    Hashtable attributes = helper.ReturnAttributes(tag);

                    // Check whether it's a single tag (<?.../>) or a tag with children (<?..>...</?...>)
                    if (tag.Substring(tag.Length - 2, 1) != "/" && tag.IndexOf(" ") > -1)
                    {
                        String closingTag = "</" + (tag.Substring(1, tag.IndexOf(" ") - 1)) + ">";
                        // Tag with children are only used when a macro is inserted by the umbraco-editor, in the
                        // following format: "<?UMBRACO_MACRO ...><IMG SRC="..."..></?UMBRACO_MACRO>", so we
                        // need to delete extra information inserted which is the image-tag and the closing
                        // umbraco_macro tag
                        if (tempOutput.ToString().IndexOf(closingTag) > -1)
                        {
                            tempOutput.Remove(0, tempOutput.ToString().IndexOf(closingTag));
                        }
                    }



                    System.Web.HttpContext.Current.Trace.Write("umbTemplate", "Outputting item: " + tag);

                    // Handle umbraco macro tags
                    if (tag.ToString().ToLower().IndexOf("umbraco_macro") > -1)
                    {
                        if (debugMode)
                            pageContent.Controls.Add(new LiteralControl("<div title=\"Macro Tag: '" + System.Web.HttpContext.Current.Server.HtmlEncode(tag) + "'\" style=\"border: 1px solid #009;\">"));

                        // NH: Switching to custom controls for macros
                        if (UmbracoSettings.UseAspNetMasterPages)
                        {
                            umbraco.presentation.templateControls.Macro macroControl = new umbraco.presentation.templateControls.Macro();
                            macroControl.Alias = helper.FindAttribute(attributes, "macroalias");
                            IDictionaryEnumerator ide = attributes.GetEnumerator();
                            while (ide.MoveNext())
                                if (macroControl.Attributes[ide.Key.ToString()] == null)
                                    macroControl.Attributes.Add(ide.Key.ToString(), ide.Value.ToString());
                            pageContent.Controls.Add(macroControl);
                        }
                        else
                        {
                            macro tempMacro;
                            String macroID = helper.FindAttribute(attributes, "macroid");
                            if (macroID != String.Empty)
                                tempMacro = getMacro(macroID);
                            else
                                tempMacro = macro.GetMacro(helper.FindAttribute(attributes, "macroalias"));

                            if (tempMacro != null)
                            {

                                try
                                {
                                    Control c = tempMacro.renderMacro(attributes, umbPage.Elements, umbPage.PageID);
                                    if (c != null)
                                        pageContent.Controls.Add(c);
                                    else
                                        System.Web.HttpContext.Current.Trace.Warn("Template", "Result of macro " + tempMacro.Name + " is null");

                                }
                                catch (Exception e)
                                {
                                    System.Web.HttpContext.Current.Trace.Warn("Template", "Error adding macro " + tempMacro.Name, e);
                                }
                            }
                        }
                        if (debugMode)
                            pageContent.Controls.Add(new LiteralControl("</div>"));
                    }
                    else
                    {
                        if (tag.ToLower().IndexOf("umbraco_getitem") > -1)
                        {

                            // NH: Switching to custom controls for items
                            if (UmbracoSettings.UseAspNetMasterPages)
                            {
                                umbraco.presentation.templateControls.Item itemControl = new umbraco.presentation.templateControls.Item();
                                itemControl.Field = helper.FindAttribute(attributes, "field");
                                IDictionaryEnumerator ide = attributes.GetEnumerator();
                                while (ide.MoveNext())
                                    if (itemControl.Attributes[ide.Key.ToString()] == null)
                                        itemControl.Attributes.Add(ide.Key.ToString(), ide.Value.ToString());
                                pageContent.Controls.Add(itemControl);
                            }
                            else
                            {
                                try
                                {
                                    if (helper.FindAttribute(attributes, "nodeId") != "" && int.Parse(helper.FindAttribute(attributes, "nodeId")) != 0)
                                    {
                                        cms.businesslogic.Content c = new umbraco.cms.businesslogic.Content(int.Parse(helper.FindAttribute(attributes, "nodeId")));
                                        item umbItem = new item(c.getProperty(helper.FindAttribute(attributes, "field")).Value.ToString(), attributes);
                                        tempElementContent = umbItem.FieldContent;

                                        // Check if the content is published
                                        if (c.nodeObjectType == cms.businesslogic.web.Document._objectType)
                                        {
                                            try
                                            {
                                                cms.businesslogic.web.Document d = (cms.businesslogic.web.Document)c;
                                                if (!d.Published)
                                                    tempElementContent = "";
                                            }
                                            catch { }
                                        }

                                    }
                                    else
                                    {
                                        // NH adds Live Editing test stuff
                                        item umbItem = new item(umbPage.Elements, attributes);
                                        //								item umbItem = new item(umbPage.PageElements[helper.FindAttribute(attributes, "field")].ToString(), attributes);
                                        tempElementContent = umbItem.FieldContent;
                                    }

                                    if (debugMode)
                                        tempElementContent =
                                            "<div title=\"Field Tag: '" + System.Web.HttpContext.Current.Server.HtmlEncode(tag) + "'\" style=\"border: 1px solid #fc6;\">" + tempElementContent + "</div>";
                                }
                                catch (Exception e)
                                {
                                    System.Web.HttpContext.Current.Trace.Warn("umbracoTemplate", "Error reading element (" + helper.FindAttribute(attributes, "field") + ")", e);
                                }
                            }
                        }
                    }
                    tempOutput.Remove(0, tempOutput.ToString().IndexOf(">") + 1);
                    tempOutput.Insert(0, tempElementContent);
                }
                else
                {
                    pageContent.Controls.Add(new LiteralControl(tempOutput.ToString()));
                    break;
                }

            }

            return pageContent;

        }
Exemple #7
0
        private static void UpdateLabelValue(string propAlias, string controlId, Page controlPage, Content content)
        {
            var extensionControl = controlPage.FindControlRecursive <noEdit>(controlId);

            if (extensionControl != null)
            {
                if (content.getProperty(propAlias) != null && content.getProperty(propAlias).Value != null)
                {
                    extensionControl.RefreshLabel(content.getProperty(propAlias).Value.ToString());
                }
            }
        }
Exemple #8
0
        private void addMacroXmlNode(XmlDocument umbracoXML, XmlDocument macroXML, String macroPropertyAlias, String macroPropertyType, String macroPropertyValue)
        {
            XmlNode macroXmlNode = macroXML.CreateNode(XmlNodeType.Element, macroPropertyAlias, string.Empty);
            var     x            = new XmlDocument();

            int currentID = -1;

            // If no value is passed, then use the current pageID as value
            if (macroPropertyValue == string.Empty)
            {
                var umbPage = (page)HttpContext.Current.Items["umbPageObject"];
                if (umbPage == null)
                {
                    return;
                }
                currentID = umbPage.PageID;
            }

            TraceInfo("umbracoMacro", "Xslt node adding search start (" + macroPropertyAlias + ",'" + macroPropertyValue + "')");
            switch (macroPropertyType)
            {
            case "contentTree":
                XmlAttribute nodeID = macroXML.CreateAttribute("nodeID");
                if (macroPropertyValue != string.Empty)
                {
                    nodeID.Value = macroPropertyValue;
                }
                else
                {
                    nodeID.Value = currentID.ToString();
                }
                macroXmlNode.Attributes.SetNamedItem(nodeID);

                // Get subs
                try
                {
                    macroXmlNode.AppendChild(macroXML.ImportNode(umbracoXML.GetElementById(nodeID.Value), true));
                }
                catch
                {
                }
                break;

            case "contentCurrent":
                x.LoadXml("<nodes/>");
                XmlNode currentNode;
                if (macroPropertyValue != string.Empty)
                {
                    currentNode = macroXML.ImportNode(umbracoXML.GetElementById(macroPropertyValue), true);
                }
                else
                {
                    currentNode = macroXML.ImportNode(umbracoXML.GetElementById(currentID.ToString()), true);
                }

                // remove all sub content nodes
                foreach (XmlNode n in currentNode.SelectNodes("node|*[@isDoc]"))
                {
                    currentNode.RemoveChild(n);
                }

                macroXmlNode.AppendChild(currentNode);

                break;

            case "contentSubs":
                x.LoadXml("<nodes/>");
                if (macroPropertyValue != string.Empty)
                {
                    x.FirstChild.AppendChild(x.ImportNode(umbracoXML.GetElementById(macroPropertyValue), true));
                }
                else
                {
                    x.FirstChild.AppendChild(x.ImportNode(umbracoXML.GetElementById(currentID.ToString()), true));
                }
                macroXmlNode.InnerXml = transformMacroXML(x, "macroGetSubs.xsl");
                break;

            case "contentAll":
                x.ImportNode(umbracoXML.DocumentElement.LastChild, true);
                break;

            case "contentRandom":
                XmlNode source = umbracoXML.GetElementById(macroPropertyValue);
                if (source != null)
                {
                    XmlNodeList sourceList = source.SelectNodes("node|*[@isDoc]");
                    if (sourceList.Count > 0)
                    {
                        int    rndNumber;
                        Random r = library.GetRandom();
                        lock (r)
                        {
                            rndNumber = r.Next(sourceList.Count);
                        }
                        XmlNode node = macroXML.ImportNode(sourceList[rndNumber], true);
                        // remove all sub content nodes
                        foreach (XmlNode n in node.SelectNodes("node|*[@isDoc]"))
                        {
                            node.RemoveChild(n);
                        }

                        macroXmlNode.AppendChild(node);
                        break;
                    }
                    else
                    {
                        TraceWarn("umbracoMacro", "Error adding random node - parent (" + macroPropertyValue + ") doesn't have children!");
                    }
                }
                else
                {
                    TraceWarn("umbracoMacro", "Error adding random node - parent (" + macroPropertyValue + ") doesn't exists!");
                }
                break;

            case "mediaCurrent":
                var c = new umbraco.cms.businesslogic.Content(int.Parse(macroPropertyValue));
                macroXmlNode.AppendChild(macroXML.ImportNode(c.ToXml(content.Instance.XmlContent, false), true));
                break;

            default:
                macroXmlNode.InnerText = HttpContext.Current.Server.HtmlDecode(macroPropertyValue);
                break;
            }
            macroXML.FirstChild.AppendChild(macroXmlNode);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            var moduleNodeTypeAliases =
                ConfigurationManager.AppSettings["ModuleNodeTypeAliases"].Split(',')
                .ToList()
                .ConvertAll(x => x.ToLower());


            var id = Convert.ToInt32(Request["id"]);

            _workflowInstance = TheWorkflowInstanceService.GetInstance(id);

            var nodes = ((UmbracoWorkflowInstance)_workflowInstance).CmsNodes;

            if (!Page.IsPostBack)
            {
                var nodeDetails = new List <NodeInfo>();

                foreach (var nodeId in nodes)
                {
                    var node = new Content(nodeId);

                    if (!moduleNodeTypeAliases.Contains(node.ContentType.Alias.ToLower()))
                    {
                        var url = umbraco.library.NiceUrl(nodeId);

                        nodeDetails.Add(new NodeInfo
                        {
                            Id            = nodeId,
                            PreviewNodeId = nodeId,
                            Name          = node.Text,
                            Url           = umbraco.library.NiceUrl(nodeId),
                            Approved      = true,
                            Comment       = string.Empty
                        });
                    }
                    else
                    {
                        var ids = FindReferencesToModule(nodeId, 1050).Distinct();

                        var url = ids.Any() ? umbraco.library.NiceUrl(ids.First()) : "#";

                        nodeDetails.Add(new NodeInfo
                        {
                            Id            = nodeId,
                            PreviewNodeId = ids.Any() ? ids.First() : nodeId,
                            Name          = "Module " + node.Text,
                            Url           = url,
                            Approved      = true,
                            Comment       = string.Empty,
                            References    = string.Join(",", ids)
                        });
                    }
                }

                var json = JsonConvert.SerializeObject(nodeDetails, Formatting.Indented);
                JsonLiteral.Text = json;

                NodeRepeater.DataSource = nodeDetails;
                NodeRepeater.DataBind();
            }
        }
Exemple #10
0
        private void addMacroXmlNode(XmlDocument umbracoXML, XmlDocument macroXML, String macroPropertyAlias,
            String macroPropertyType, String macroPropertyValue)
        {
            XmlNode macroXmlNode = macroXML.CreateNode(XmlNodeType.Element, macroPropertyAlias, string.Empty);
            var x = new XmlDocument();

            int currentID = -1;
            // If no value is passed, then use the current pageID as value
            if (macroPropertyValue == string.Empty)
            {
                var umbPage = (page)HttpContext.Current.Items["umbPageObject"];
                if (umbPage == null)
                    return;
                currentID = umbPage.PageID;
            }

            HttpContext.Current.Trace.Write("umbracoMacro",
                                            "Xslt node adding search start (" + macroPropertyAlias + ",'" +
                                            macroPropertyValue + "')");
            switch (macroPropertyType)
            {
                case "contentTree":
                    XmlAttribute nodeID = macroXML.CreateAttribute("nodeID");
                    if (macroPropertyValue != string.Empty)
                        nodeID.Value = macroPropertyValue;
                    else
                        nodeID.Value = currentID.ToString();
                    macroXmlNode.Attributes.SetNamedItem(nodeID);

                    // Get subs
                    try
                    {
                        macroXmlNode.AppendChild(macroXML.ImportNode(umbracoXML.GetElementById(nodeID.Value), true));
                    }
                    catch
                    {
                        break;
                    }
                    break;
                case "contentCurrent":
                    x.LoadXml("<nodes/>");
                    XmlNode currentNode;
                    if (macroPropertyValue != string.Empty)
                        currentNode = macroXML.ImportNode(umbracoXML.GetElementById(macroPropertyValue), true);
                    else
                        currentNode = macroXML.ImportNode(umbracoXML.GetElementById(currentID.ToString()), true);

                    // remove all sub content nodes
                    foreach (XmlNode n in currentNode.SelectNodes("./node"))
                        currentNode.RemoveChild(n);

                    macroXmlNode.AppendChild(currentNode);

                    break;
                case "contentSubs":
                    x.LoadXml("<nodes/>");
                    if (macroPropertyValue != string.Empty)
                        x.FirstChild.AppendChild(x.ImportNode(umbracoXML.GetElementById(macroPropertyValue), true));
                    else
                        x.FirstChild.AppendChild(x.ImportNode(umbracoXML.GetElementById(currentID.ToString()), true));
                    macroXmlNode.InnerXml = transformMacroXML(x, "macroGetSubs.xsl");
                    break;
                case "contentAll":
                    x.ImportNode(umbracoXML.DocumentElement.LastChild, true);
                    break;
                case "contentRandom":
                    XmlNode source = umbracoXML.GetElementById(macroPropertyValue);
                    if (source != null)
                    {
                        XmlNodeList sourceList = source.SelectNodes("node");
                        if (sourceList.Count > 0)
                        {
                            int rndNumber;
                            Random r = library.GetRandom();
                            lock (r)
                            {
                                rndNumber = r.Next(sourceList.Count);
                            }
                            XmlNode node = macroXML.ImportNode(sourceList[rndNumber], true);
                            // remove all sub content nodes
                            foreach (XmlNode n in node.SelectNodes("./node"))
                                node.RemoveChild(n);

                            macroXmlNode.AppendChild(node);
                            break;
                        }
                        else
                            HttpContext.Current.Trace.Warn("umbracoMacro",
                                                           "Error adding random node - parent (" + macroPropertyValue +
                                                           ") doesn't have children!");
                    }
                    else
                        HttpContext.Current.Trace.Warn("umbracoMacro",
                                                       "Error adding random node - parent (" + macroPropertyValue +
                                                       ") doesn't exists!");
                    break;
                case "mediaCurrent":
                    var c = new Content(int.Parse(macroPropertyValue));
                    macroXmlNode.AppendChild(macroXML.ImportNode(c.ToXml(content.Instance.XmlContent, false), true));
                    break;
                default:
                    macroXmlNode.InnerText = HttpContext.Current.Server.HtmlDecode(macroPropertyValue);
                    break;
            }
            macroXML.FirstChild.AppendChild(macroXmlNode);
        }
Exemple #11
0
        public void Save()
        {
            // Clear data
            if (helper.Request(ClientID + "clear") == "1")
            {
                // delete file
                deleteFile(_text);

                // set filename in db to nothing
                _text       = "";
                _data.Value = _text;


                foreach (string prop in "umbracoExtension,umbracoBytes,umbracoWidth,umbracoHeight".Split(','))
                {
                    try
                    {
                        var bytesControl = FindControlRecursive <noEdit>(Page, "prop_" + prop);
                        if (bytesControl != null)
                        {
                            bytesControl.RefreshLabel(string.Empty);
                        }
                    }
                    catch
                    {
                        //if first one fails we can assume that props don't exist
                        break;
                    }
                }
            }

            if (PostedFile != null && PostedFile.FileName != String.Empty)
            {
                _data.Value = PostedFile;

                // we update additional properties post image upload
                if (_data.Value != DBNull.Value && !string.IsNullOrEmpty(_data.Value.ToString()))
                {
                    Content content = Content.GetContentFromVersion(_data.Version);

                    // update extension in UI
                    try
                    {
                        var extensionControl = FindControlRecursive <noEdit>(Page, "prop_umbracoExtension");
                        if (extensionControl != null)
                        {
                            extensionControl.RefreshLabel(content.getProperty("umbracoExtension").Value.ToString());
                        }
                    }
                    catch
                    {
                    }


                    // update file size in UI
                    try
                    {
                        var bytesControl = FindControlRecursive <noEdit>(Page, "prop_umbracoBytes");
                        if (bytesControl != null)
                        {
                            bytesControl.RefreshLabel(content.getProperty("umbracoBytes").Value.ToString());
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        var widthControl = FindControlRecursive <noEdit>(Page, "prop_umbracoWidth");
                        if (widthControl != null)
                        {
                            widthControl.RefreshLabel(content.getProperty("umbracoWidth").Value.ToString());
                        }
                        var heightControl = FindControlRecursive <noEdit>(Page, "prop_umbracoHeight");
                        if (heightControl != null)
                        {
                            heightControl.RefreshLabel(content.getProperty("umbracoHeight").Value.ToString());
                        }
                    }
                    catch
                    {
                    }
                }
                Text = _data.Value.ToString();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {

            var moduleNodeTypeAliases =
                ConfigurationManager.AppSettings["ModuleNodeTypeAliases"].Split(',')
                    .ToList()
                    .ConvertAll(x => x.ToLower());


            var id = Convert.ToInt32(Request["id"]);
            _workflowInstance = TheWorkflowInstanceService.GetInstance(id);

            var nodes = ((UmbracoWorkflowInstance)_workflowInstance).CmsNodes;

            if (!Page.IsPostBack)
            {
                var nodeDetails = new List<NodeInfo>();

                foreach (var nodeId in nodes)
                {
                    var node = new Content(nodeId);

                    if (!moduleNodeTypeAliases.Contains(node.ContentType.Alias.ToLower()))
                    {
                        var url = umbraco.library.NiceUrl(nodeId);

                        nodeDetails.Add(new NodeInfo
                        {
                            Id = nodeId,
                            PreviewNodeId = nodeId,
                            Name = node.Text,
                            Url = umbraco.library.NiceUrl(nodeId),
                            Approved = true,
                            Comment = string.Empty
                        });
                    }
                    else
                    {
                        var ids = FindReferencesToModule(nodeId, 1050).Distinct();

                        var url = ids.Any() ? umbraco.library.NiceUrl(ids.First()) : "#";

                        nodeDetails.Add(new NodeInfo
                        {
                            Id = nodeId,
                            PreviewNodeId = ids.Any() ? ids.First() : nodeId,
                            Name = "Module " + node.Text,
                            Url = url,
                            Approved = true,
                            Comment = string.Empty,
                            References = string.Join(",", ids)
                        });
                    }
                }

                var json = JsonConvert.SerializeObject(nodeDetails, Formatting.Indented);
                JsonLiteral.Text = json;

                NodeRepeater.DataSource = nodeDetails;
                NodeRepeater.DataBind();
            }
        }
Exemple #13
0
        // add elements to the <macro> root node, corresponding to parameters
        private void AddMacroXmlNode(XmlDocument umbracoXml, XmlDocument macroXml,
            string macroPropertyAlias, string macroPropertyType, string macroPropertyValue)
        {
            XmlNode macroXmlNode = macroXml.CreateNode(XmlNodeType.Element, macroPropertyAlias, string.Empty);
            var x = new XmlDocument();

            // if no value is passed, then use the current "pageID" as value
            var contentId = macroPropertyValue == string.Empty ? UmbracoContext.Current.PageId.ToString() : macroPropertyValue;

	        TraceInfo("umbracoMacro",
	                  "Xslt node adding search start (" + macroPropertyAlias + ",'" +
	                  macroPropertyValue + "')");
            
            //TODO: WE need to fix this so that we give control of this stuff over to the actual parameter editors!
            
            switch (macroPropertyType)
            {
                case "contentTree":
                    var nodeId = macroXml.CreateAttribute("nodeID");
                    nodeId.Value = contentId;
                    macroXmlNode.Attributes.SetNamedItem(nodeId);

                    // Get subs
                    try
                    {
                        macroXmlNode.AppendChild(macroXml.ImportNode(umbracoXml.GetElementById(contentId), true));
                    }
                    catch
                    { }
                    break;

                case "contentCurrent":
                    var importNode = macroPropertyValue == string.Empty
                        ? umbracoXml.GetElementById(contentId)
                        : umbracoXml.GetElementById(macroPropertyValue);

                    var currentNode = macroXml.ImportNode(importNode, true);

                    // remove all sub content nodes
                    foreach (XmlNode n in currentNode.SelectNodes("node|*[@isDoc]"))
                        currentNode.RemoveChild(n);

                    macroXmlNode.AppendChild(currentNode);

                    break;                    

                case "contentAll":
                    macroXmlNode.AppendChild(macroXml.ImportNode(umbracoXml.DocumentElement, true));
                    break;

                case "contentRandom":
                    XmlNode source = umbracoXml.GetElementById(contentId);
					if (source != null)
					{
						var sourceList = source.SelectNodes("node|*[@isDoc]");
						if (sourceList.Count > 0)
						{
							int rndNumber;
							var r = library.GetRandom();
							lock (r)
							{
								rndNumber = r.Next(sourceList.Count);
							}
							var node = macroXml.ImportNode(sourceList[rndNumber], true);
							// remove all sub content nodes
							foreach (XmlNode n in node.SelectNodes("node|*[@isDoc]"))
								node.RemoveChild(n);

							macroXmlNode.AppendChild(node);
						}
						else
							TraceWarn("umbracoMacro",
									  "Error adding random node - parent (" + macroPropertyValue +
									  ") doesn't have children!");
					}
					else
						TraceWarn("umbracoMacro",
						          "Error adding random node - parent (" + macroPropertyValue +
						          ") doesn't exists!");
                    break;

                case "mediaCurrent":
                    if (string.IsNullOrEmpty(macroPropertyValue) == false)
                    {
                        var c = new Content(int.Parse(macroPropertyValue));
                        macroXmlNode.AppendChild(macroXml.ImportNode(c.ToXml(umbraco.content.Instance.XmlContent, false), true));
                    }
                    break;

                default:
                    macroXmlNode.InnerText = HttpContext.Current.Server.HtmlDecode(macroPropertyValue);
                    break;
            }
            macroXml.FirstChild.AppendChild(macroXmlNode);
        }
        /// <summary>
        /// returns a string "Property '[propertyAlias]' with RelationType '[relationTypeName]"
        /// </summary>
        /// <returns></returns>
        private string GetMappingDetails()
        {
            string mappingDetails = string.Empty;

            UmbracoContent currentContentNode = new UmbracoContent(this.CurrentContentId);
            Property pickerProperty = currentContentNode.getProperty(this.options.PropertyAlias);

            if (pickerProperty != null)
            {
                RelationType relationType = new RelationType(this.options.RelationTypeId); // Does it still exist ? TODO: check

                if (this.IsContextUmbracoObjectTypeValid(this.CurrentContextObjectType, relationType))
                {
                    mappingDetails = "Property '<strong>" + pickerProperty.PropertyType.Name + "</strong>' with " + 
                                     "Relation Type '<strong>" + relationType.Name + "</strong>'";

                    if(this.options.ReverseIndexing)
                    {
                        mappingDetails += " <i>(Reverse Index)</i>";
                    }
                }
                else
                {
                    throw new Exception("Conflict with this Content Object Type and that expected by the Relation Type '" + relationType.Name  + "'");
                }
            }
            else
            {
                throw new Exception("Can't find a Property with the Alias '" + this.options.PropertyAlias + "'");
            }

            return mappingDetails;
        }
Exemple #15
0
        /// <summary>
        /// Event handler for the selected node repeater.
        /// This will fill in all of the text values, icons, etc.. for nodes based on their ID.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void SelectedValues_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            var liSelectNode      = (HtmlGenericControl)e.Item.FindControl("SelectedNodeListItem");
            var lnkSelectNode     = (HtmlAnchor)e.Item.FindControl("SelectedNodeLink");
            var litSelectNodeName = (Literal)e.Item.FindControl("SelectedNodeText");
            var infoButton        = (HtmlAnchor)e.Item.FindControl("InfoButton");

            //hide the info button if tooltips are hidden
            if (!ShowToolTips)
            {
                infoButton.Style.Add(HtmlTextWriterStyle.Display, "none");
            }

            var thisNode = (XElement)e.Item.DataItem;
            int thisNodeId;

            if (int.TryParse(thisNode.Value, out thisNodeId))
            {
                umbraco.cms.businesslogic.Content loadedNode;

                try
                {
                    loadedNode = new umbraco.cms.businesslogic.Content(thisNodeId);

                    //add the node id
                    liSelectNode.Attributes["rel"] = thisNodeId.ToString();
                    //add the path to be referenced
                    liSelectNode.Attributes["umb:nodedata"] = loadedNode.Path;
                    lnkSelectNode.HRef     = "javascript:void(0);";
                    litSelectNodeName.Text = loadedNode.Text;

                    if (loadedNode.IsTrashed)
                    {
                        //need to flag this to be removed which will be done after all items are data bound
                        liSelectNode.Attributes["rel"] = "trashed";
                    }
                    else
                    {
                        //we need to set the icon
                        if (loadedNode.ContentTypeIcon.StartsWith(".spr"))
                        {
                            lnkSelectNode.Attributes["class"] += " " + loadedNode.ContentTypeIcon.TrimStart('.');
                        }
                        else
                        {
                            //it's a real icon, so make it a background image
                            lnkSelectNode.Style.Add(HtmlTextWriterStyle.BackgroundImage,
                                                    string.Format("url('{0}')", IconPath + loadedNode.ContentTypeIcon));
                            //set the nospr class since it's not a sprite
                            lnkSelectNode.Attributes["class"] += " noSpr";
                        }

                        //show the media preview if media and allowed
                        if (TreeToRender == Umbraco.Core.Constants.Applications.Media && ShowThumbnailsForMedia)
                        {
                            var imgPreview = (ImageViewer)e.Item.FindControl("ImgPreview");
                            //show the thubmnail controls
                            imgPreview.Visible = true;

                            //add the item class
                            var item = (HtmlGenericControl)e.Item.FindControl("Item");
                            item.Attributes["class"] += " thumb-item";

                            //item.Style.Add(HtmlTextWriterStyle.Height, "50px");
                            ////make the content sit beside the item
                            //var inner = (HtmlGenericControl)e.Item.FindControl("InnerItem");
                            //inner.Style.Add(HtmlTextWriterStyle.Width, "224px");

                            //check if it's a thumbnail type element, we need to check both schemas
                            if (MediaTypesWithThumbnails.Select(x => x.ToUpper())
                                .Contains(loadedNode.ContentType.Alias.ToUpper()))
                            {
                                imgPreview.MediaId = thisNodeId;
                                imgPreview.DataBind();
                            }
                        }
                    }
                }
                catch (ArgumentException)
                {
                    //the node no longer exists, so we display a msg
                    litSelectNodeName.Text = "<i>NODE NO LONGER EXISTS</i>";
                }
            }
        }
Exemple #16
0
        public Control parseStringBuilder(StringBuilder tempOutput, page umbPage)
        {
            Control pageContent = new Control();

            bool stop      = false;
            bool debugMode = umbraco.presentation.UmbracoContext.Current.Request.IsDebug;

            while (!stop)
            {
                System.Web.HttpContext.Current.Trace.Write("template", "Begining of parsing rutine...");
                int tagIndex = tempOutput.ToString().ToLower().IndexOf("<?umbraco");
                if (tagIndex > -1)
                {
                    String tempElementContent = "";
                    pageContent.Controls.Add(new LiteralControl(tempOutput.ToString().Substring(0, tagIndex)));

                    tempOutput.Remove(0, tagIndex);

                    String    tag        = tempOutput.ToString().Substring(0, tempOutput.ToString().IndexOf(">") + 1);
                    Hashtable attributes = helper.ReturnAttributes(tag);

                    // Check whether it's a single tag (<?.../>) or a tag with children (<?..>...</?...>)
                    if (tag.Substring(tag.Length - 2, 1) != "/" && tag.IndexOf(" ") > -1)
                    {
                        String closingTag = "</" + (tag.Substring(1, tag.IndexOf(" ") - 1)) + ">";
                        // Tag with children are only used when a macro is inserted by the umbraco-editor, in the
                        // following format: "<?UMBRACO_MACRO ...><IMG SRC="..."..></?UMBRACO_MACRO>", so we
                        // need to delete extra information inserted which is the image-tag and the closing
                        // umbraco_macro tag
                        if (tempOutput.ToString().IndexOf(closingTag) > -1)
                        {
                            tempOutput.Remove(0, tempOutput.ToString().IndexOf(closingTag));
                        }
                    }



                    System.Web.HttpContext.Current.Trace.Write("umbTemplate", "Outputting item: " + tag);

                    // Handle umbraco macro tags
                    if (tag.ToString().ToLower().IndexOf("umbraco_macro") > -1)
                    {
                        if (debugMode)
                        {
                            pageContent.Controls.Add(new LiteralControl("<div title=\"Macro Tag: '" + System.Web.HttpContext.Current.Server.HtmlEncode(tag) + "'\" style=\"border: 1px solid #009;\">"));
                        }

                        // NH: Switching to custom controls for macros
                        if (UmbracoConfig.For.UmbracoSettings().Templates.UseAspNetMasterPages)
                        {
                            umbraco.presentation.templateControls.Macro macroControl = new umbraco.presentation.templateControls.Macro();
                            macroControl.Alias = helper.FindAttribute(attributes, "macroalias");
                            IDictionaryEnumerator ide = attributes.GetEnumerator();
                            while (ide.MoveNext())
                            {
                                if (macroControl.Attributes[ide.Key.ToString()] == null)
                                {
                                    macroControl.Attributes.Add(ide.Key.ToString(), ide.Value.ToString());
                                }
                            }
                            pageContent.Controls.Add(macroControl);
                        }
                        else
                        {
                            macro  tempMacro;
                            String macroID = helper.FindAttribute(attributes, "macroid");
                            if (macroID != String.Empty)
                            {
                                tempMacro = getMacro(macroID);
                            }
                            else
                            {
                                tempMacro = macro.GetMacro(helper.FindAttribute(attributes, "macroalias"));
                            }

                            if (tempMacro != null)
                            {
                                try
                                {
                                    Control c = tempMacro.renderMacro(attributes, umbPage.Elements, umbPage.PageID);
                                    if (c != null)
                                    {
                                        pageContent.Controls.Add(c);
                                    }
                                    else
                                    {
                                        System.Web.HttpContext.Current.Trace.Warn("Template", "Result of macro " + tempMacro.Name + " is null");
                                    }
                                }
                                catch (Exception e)
                                {
                                    System.Web.HttpContext.Current.Trace.Warn("Template", "Error adding macro " + tempMacro.Name, e);
                                }
                            }
                        }
                        if (debugMode)
                        {
                            pageContent.Controls.Add(new LiteralControl("</div>"));
                        }
                    }
                    else
                    {
                        if (tag.ToLower().IndexOf("umbraco_getitem") > -1)
                        {
                            // NH: Switching to custom controls for items
                            if (UmbracoConfig.For.UmbracoSettings().Templates.UseAspNetMasterPages)
                            {
                                umbraco.presentation.templateControls.Item itemControl = new umbraco.presentation.templateControls.Item();
                                itemControl.Field = helper.FindAttribute(attributes, "field");
                                IDictionaryEnumerator ide = attributes.GetEnumerator();
                                while (ide.MoveNext())
                                {
                                    if (itemControl.Attributes[ide.Key.ToString()] == null)
                                    {
                                        itemControl.Attributes.Add(ide.Key.ToString(), ide.Value.ToString());
                                    }
                                }
                                pageContent.Controls.Add(itemControl);
                            }
                            else
                            {
                                try
                                {
                                    if (helper.FindAttribute(attributes, "nodeId") != "" && int.Parse(helper.FindAttribute(attributes, "nodeId")) != 0)
                                    {
                                        cms.businesslogic.Content c = new umbraco.cms.businesslogic.Content(int.Parse(helper.FindAttribute(attributes, "nodeId")));
                                        item umbItem = new item(c.getProperty(helper.FindAttribute(attributes, "field")).Value.ToString(), attributes);
                                        tempElementContent = umbItem.FieldContent;

                                        // Check if the content is published
                                        if (c.nodeObjectType == cms.businesslogic.web.Document._objectType)
                                        {
                                            try
                                            {
                                                cms.businesslogic.web.Document d = (cms.businesslogic.web.Document)c;
                                                if (!d.Published)
                                                {
                                                    tempElementContent = "";
                                                }
                                            }
                                            catch { }
                                        }
                                    }
                                    else
                                    {
                                        // NH adds Live Editing test stuff
                                        item umbItem = new item(umbPage.Elements, attributes);
                                        //								item umbItem = new item(umbPage.PageElements[helper.FindAttribute(attributes, "field")].ToString(), attributes);
                                        tempElementContent = umbItem.FieldContent;
                                    }

                                    if (debugMode)
                                    {
                                        tempElementContent =
                                            "<div title=\"Field Tag: '" + System.Web.HttpContext.Current.Server.HtmlEncode(tag) + "'\" style=\"border: 1px solid #fc6;\">" + tempElementContent + "</div>";
                                    }
                                }
                                catch (Exception e)
                                {
                                    System.Web.HttpContext.Current.Trace.Warn("umbracoTemplate", "Error reading element (" + helper.FindAttribute(attributes, "field") + ")", e);
                                }
                            }
                        }
                    }
                    tempOutput.Remove(0, tempOutput.ToString().IndexOf(">") + 1);
                    tempOutput.Insert(0, tempElementContent);
                }
                else
                {
                    pageContent.Controls.Add(new LiteralControl(tempOutput.ToString()));
                    break;
                }
            }

            return(pageContent);
        }
Exemple #17
0
        private string formatMedia(string html)
        {
            // root media url
            var rootMediaUrl = _fs.GetUrl("");

            // Find all media images
            var pattern = String.Format("<img [^>]*src=\"(?<mediaString>{0}[^\"]*)\" [^>]*>", rootMediaUrl);

            MatchCollection tags =
                Regex.Matches(html, pattern, RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);

            foreach (Match tag in tags)
            {
                if (tag.Groups.Count > 0)
                {
                    // Replace /> to ensure we're in old-school html mode
                    string tempTag = "<img";
                    string orgSrc  = tag.Groups["mediaString"].Value;

                    // gather all attributes
                    // TODO: This should be replaced with a general helper method - but for now we'll wanna leave umbraco.dll alone for this patch
                    Hashtable       ht = new Hashtable();
                    MatchCollection m  =
                        Regex.Matches(tag.Value.Replace(">", " >"),
                                      "(?<attributeName>\\S*)=\"(?<attributeValue>[^\"]*)\"|(?<attributeName>\\S*)=(?<attributeValue>[^\"|\\s]*)\\s",
                                      RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);

                    //GE: Add ContainsKey check and expand the ifs for readability
                    foreach (Match attributeSet in m)
                    {
                        if (attributeSet.Groups["attributeName"].Value.ToString().ToLower() != "src")
                        {
                            if (!ht.ContainsKey(attributeSet.Groups["attributeName"].Value.ToString()))
                            {
                                ht.Add(attributeSet.Groups["attributeName"].Value.ToString(), attributeSet.Groups["attributeValue"].Value.ToString());
                            }
                        }
                    }

                    // build the element
                    // Build image tag
                    IDictionaryEnumerator ide = ht.GetEnumerator();
                    while (ide.MoveNext())
                    {
                        tempTag += " " + ide.Key.ToString() + "=\"" + ide.Value.ToString() + "\"";
                    }

                    // Find the original filename, by removing the might added width and height
                    // NH, 4.8.1 - above replaced by loading the right media file from the db later!
                    orgSrc =
                        global::Umbraco.Core.IO.IOHelper.ResolveUrl(orgSrc.Replace("%20", " "));

                    // Check for either id or guid from media
                    string mediaId = getIdFromSource(orgSrc, rootMediaUrl);

                    Media imageMedia = null;

                    try
                    {
                        int      mId = int.Parse(mediaId);
                        Property p   = new Property(mId);
                        imageMedia = new Media(Content.GetContentFromVersion(p.VersionId).Id);
                    }
                    catch
                    {
                        try
                        {
                            imageMedia = new Media(Content.GetContentFromVersion(new Guid(mediaId)).Id);
                        }
                        catch
                        {
                        }
                    }

                    // Check with the database if any media matches this url
                    if (imageMedia != null)
                    {
                        try
                        {
                            // Format the tag
                            tempTag = tempTag + " rel=\"" +
                                      imageMedia.getProperty("umbracoWidth").Value.ToString() + "," +
                                      imageMedia.getProperty("umbracoHeight").Value.ToString() + "\" src=\"" + global::Umbraco.Core.IO.IOHelper.ResolveUrl(imageMedia.getProperty("umbracoFile").Value.ToString()) +
                                      "\"";
                            tempTag += "/>";

                            // Replace the tag
                            html = html.Replace(tag.Value, tempTag);
                        }
                        catch (Exception ee)
                        {
                            Log.Add(LogTypes.Error, User.GetUser(0), -1,
                                    "Error reading size data from media: " + imageMedia.Id.ToString() + ", " +
                                    ee.ToString());
                        }
                    }
                    else
                    {
                        Log.Add(LogTypes.Error, User.GetUser(0), -1,
                                "Error reading size data from media (not found): " + orgSrc);
                    }
                }
            }
            return(html);
        }