public virtual string PublishMultimediaComponent(string uri, BuildProperties buildProperties) { if (buildProperties.ECLEnabled) { string url = GetECLUrl(uri); if (! string.IsNullOrEmpty(url)) { return url; } } string itemName = "PublishMultimedia_" + uri; TcmUri tcmuri = new TcmUri(uri); Item mmItem = package.GetByName(itemName); if (mmItem == null) { mmItem = package.CreateMultimediaItem(tcmuri); package.PushItem(itemName, mmItem); log.Debug(string.Format("Image {0} ({1}) unique, adding to package", itemName, uri)); if (!mmItem.Properties.ContainsKey(Item.ItemPropertyPublishedPath)) { log.Debug(string.Format("Publish Image {0} ({1}).", itemName, uri)); PublishItem(mmItem, tcmuri); } } else { log.Debug(string.Format("Image {0} ({1}) already present in package, not adding again", itemName, tcmuri)); } return GetReferencePath(mmItem, uri); }
public virtual string PublishBinariesInRichTextField(string xhtml, BuildProperties buildProperties) { // rich text field is well-formed, except that it does not always have a root element // to be sure it can be parsed, we will add a root and remove it afterwards TridionXml xml = new TridionXml(); xml.LoadXml("<tmproot>" + xhtml + "</tmproot>"); foreach (XmlElement img in xml.SelectNodes("//xhtml:img[@xlink:href[starts-with(string(.),'tcm:')]]", xml.NamespaceManager)) { log.Debug("found img node " + img.OuterXml); XmlAttribute link = (XmlAttribute)img.SelectSingleNode("@xlink:href", xml.NamespaceManager); log.Debug("about to publish binary with uri " + link.Value); string path = PublishMultimediaComponent(link.Value, buildProperties); log.Debug("binary will be published to path " + path); img.SetAttribute("src", path); } return xml.DocumentElement.InnerXml; }
public virtual string PublishBinariesInRichTextField(string xhtml, BuildProperties buildProperties) { // rich text field is well-formed, except that it does not always have a root element // to be sure it can be parsed, we will add a root and remove it afterwards TridionXml xml = new TridionXml(); xml.LoadXml("<tmproot>" + xhtml + "</tmproot>"); foreach (XmlElement elmt in xml.SelectNodes("//*[@xlink:href[starts-with(string(.),'tcm:')]]", xml.NamespaceManager)) { log.Debug("found node " + elmt.OuterXml); XmlAttribute link = (XmlAttribute)elmt.SelectSingleNode("@xlink:href", xml.NamespaceManager); string uri = link.Value; Component c = (Component) engine.GetObject(uri); if (c.ComponentType != ComponentType.Multimedia) { continue; } log.Debug("about to publish binary with uri " + link.Value); string path = PublishMultimediaComponent(link.Value, buildProperties); log.Debug("binary will be published to path " + path); if (elmt.LocalName.ToLower() == "img") { elmt.SetAttribute("src", path); } else { elmt.SetAttribute("href", path); } elmt.RemoveAttributeNode(link); } return xml.DocumentElement.InnerXml; }
/// <summary> /// Create a BuildManager (can only be instantiated from an SDL Web template) /// </summary> /// <param name="package">SDL Web publishing package</param> /// <param name="engine">SDL Web publishing engine</param> public BuildManager(Package package, Engine engine) { BuildProperties = new BuildProperties(package); BinaryPublisher = new BinaryPublisher(package, engine); }
// I think this should go! (qs) //public BuildManager() //{ // BuildProperties = new BuildProperties(null); //} public BuildManager (Package package, Engine engine) { BuildProperties = new BuildProperties(package); BinaryPublisher = new BinaryPublisher(package, engine); }