/// <summary> /// Gets the rendered XPM markup /// </summary> /// <param name="localization">The context Localization.</param> /// <returns>The XPM markup.</returns> public override string GetXpmMarkup(Localization localization) { if (XpmMetadata == null) { return(string.Empty); } string cmsUrl; object cmsUrlValue; if (XpmMetadata.TryGetValue("CmsUrl", out cmsUrlValue)) { cmsUrl = (string)cmsUrlValue; } else { cmsUrl = localization.GetConfigValue("core.cmsurl"); } if (cmsUrl.EndsWith("/")) { // remove trailing slash from cmsUrl if present cmsUrl = cmsUrl.Remove(cmsUrl.Length - 1); } return(string.Format( _xpmPageSettingsMarkup, XpmMetadata["PageID"], XpmMetadata["PageModified"], XpmMetadata["PageTemplateID"], XpmMetadata["PageTemplateModified"] ) + string.Format(_xpmPageScript, cmsUrl)); }
/// <summary> /// Gets the rendered XPM markup /// </summary> /// <param name="localization">The context Localization.</param> /// <returns>The XPM markup.</returns> public override string GetXpmMarkup(Localization localization) { XpmRegion xpmRegion = localization.GetXpmRegionConfiguration(SchemaId ?? Name); if (xpmRegion == null) { return(string.Empty); } int minOccurs = xpmRegion.OccurrenceConstraint?.MinOccurs ?? 0; int maxOccurs = xpmRegion.OccurrenceConstraint?.MaxOccurs ?? -1; string occurrenceConstraint = ""; occurrenceConstraint = maxOccurs == -1 ? string.Format(occurenceConstraintMarkupUnlimited, minOccurs) : string.Format(occurenceConstraintMarkup, minOccurs, maxOccurs); object pathToRegion = string.Empty; if (XpmMetadata != null) { XpmMetadata.TryGetValue("FullyQualifiedName", out pathToRegion); if (pathToRegion != null) { string value = pathToRegion as string; pathToRegion = $" path: \"{value?.Replace("\\", "\\\\")}\","; } } return(string.Format( XpmRegionMarkup, Name, pathToRegion, string.Join(", ", xpmRegion.ComponentTypes.Select(ct => string.Format(XpmComponentTypeMarkup, ct.Schema, ct.Template))), occurrenceConstraint)); }