Ejemplo n.º 1
0
 /// <summary>
 /// Loads the widget container (either the one located in the theme folder, or the default one if
 /// a theme widget container is missing), and adds the Widget to the widget container.
 /// </summary>
 public static WidgetContainer GetWidgetContainer(
     WidgetBase widgetControl)
 {
     return(GetWidgetContainer(widgetControl, DoesThemeWidgetContainerExist(true), GetThemeWidgetContainerVirtualPath(false)));
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Loads the widget container (either the one located in the theme folder, or the default one if
        /// a theme widget container is missing), and adds the Widget to the widget container.
        /// </summary>
        public static WidgetContainer GetWidgetContainer(
            WidgetBase widgetControl, bool widgetContainerExists,
            string widgetContainerVirtualPath)
        {
            // If a custom WidgetContainer can't be found, create a new DefaultWidgetContainer instance as it
            // provides backwards compatibility with existing themes that may have depended on WidgetBase's
            // old rendering method.
            var widgetContainer = widgetContainerExists ? (WidgetContainer)widgetControl.Page.LoadControl(widgetContainerVirtualPath) : new DefaultWidgetContainer();

            widgetContainer.ID = "widgetContainer" + widgetControl.ID;
            widgetContainer.Widget = widgetControl;

            return widgetContainer;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Loads the widget container (either the one located in the theme folder, or the default one if
 /// a theme widget container is missing), and adds the Widget to the widget container.
 /// </summary>
 public static WidgetContainer GetWidgetContainer(
     WidgetBase widgetControl)
 {
     return GetWidgetContainer(widgetControl, DoesThemeWidgetContainerExist(true), GetThemeWidgetContainerVirtualPath(false));
 }
        /// <summary>
        /// Saves the new widget to the XML file.
        /// </summary>
        /// <param name="widget">
        /// The widget to add.
        /// </param>
        /// <param name="zone">
        /// The zone a widget is being added to.
        /// </param>
        private void SaveNewWidget(WidgetBase widget, string zone)
        {
            var doc = this.GetXmlDocument(zone);
            XmlNode node = doc.CreateElement("widget");
            node.InnerText = widget.Name;

            var id = doc.CreateAttribute("id");
            id.InnerText = widget.WidgetId.ToString();
            if (node.Attributes != null)
            {
                node.Attributes.Append(id);
            }

            var title = doc.CreateAttribute("title");
            title.InnerText = widget.Title;
            if (node.Attributes != null)
            {
                node.Attributes.Append(title);
            }

            var show = doc.CreateAttribute("showTitle");
            show.InnerText = "True";
            if (node.Attributes != null)
            {
                node.Attributes.Append(show);
            }

            var widgets = doc.SelectSingleNode("widgets");
            if (widgets != null)
            {
                widgets.AppendChild(node);
            }

            this.SaveXmlDocument(doc, zone);
        }