Ejemplo n.º 1
0
        /// <summary>
        /// Undoes the addStringToHtml Execute() method, by removing the same string from the same template.
        /// </summary>
        /// <param name="packageName">Name of the package.</param>
        /// <param name="xmlData">The XML data.</param>
        /// <returns></returns>
        public bool Undo(string packageName, XmlNode xmlData)
        {
            string templateAlias = xmlData.Attributes["templateAlias"].Value;
            string htmlElementId = xmlData.Attributes["htmlElementId"].Value;
            string value         = xmlHelper.GetNodeValue(xmlData);

            template.Template tmp = template.Template.GetByAlias(templateAlias);

            if (UmbracoSettings.UseAspNetMasterPages)
            {
                value = tmp.EnsureMasterPageSyntax(value);
            }

            _removeStringFromHtmlElement(tmp, value, templateAlias, htmlElementId);
            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Executes the specified package action.
        /// </summary>
        /// <param name="packageName">Name of the package.</param>
        /// <param name="xmlData">The XML data.</param>
        /// <example><code><code>
        ///     <Action runat="install" alias="addStringToHtmlElement" templateAlias="news" htmlElementId="newsSection" position="[beginning/end"><![CDATA[hello world!]]></action>
        /// </code></code></example>
        /// <returns>True if executed successfully</returns>
        public bool Execute(string packageName, XmlNode xmlData)
        {
            string templateAlias = xmlData.Attributes["templateAlias"].Value;
            string htmlElementId = xmlData.Attributes["htmlElementId"].Value;
            string position      = xmlData.Attributes["position"].Value;
            string value         = xmlHelper.GetNodeValue(xmlData);

            template.Template tmp = template.Template.GetByAlias(templateAlias);

            if (UmbracoConfig.For.UmbracoSettings().Templates.UseAspNetMasterPages)
            {
                value = tmp.EnsureMasterPageSyntax(value);
            }

            _addStringToHtmlElement(tmp, value, templateAlias, htmlElementId, position);

            return(true);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Executes the specified package action.
        /// </summary>
        /// <param name="packageName">Name of the package.</param>
        /// <param name="xmlData">The XML data.</param>
        /// <example><code><code>
        ///     <Action runat="install" alias="addStringToHtmlElement" templateAlias="news" htmlElementId="newsSection" position="[beginning/end"><![CDATA[hello world!]]></action>
        /// </code></code></example>
        /// <returns>True if executed successfully</returns>
        public bool Execute(string packageName, XmlNode xmlData)
        {
            BusinessLogic.Log.Add(BusinessLogic.LogTypes.Error, BusinessLogic.User.GetUser(0), -1, "executing addStringToHtmlElement");

            string templateAlias = xmlData.Attributes["templateAlias"].Value;
            string htmlElementId = xmlData.Attributes["htmlElementId"].Value;
            string position      = xmlData.Attributes["position"].Value;
            string value         = xmlHelper.GetNodeValue(xmlData);

            template.Template tmp = template.Template.GetByAlias(templateAlias);

            if (UmbracoSettings.UseAspNetMasterPages)
            {
                value = tmp.EnsureMasterPageSyntax(value);
            }

            _addStringToHtmlElement(tmp, value, templateAlias, htmlElementId, position);

            return(true);
        }