예제 #1
0
파일: Data.cs 프로젝트: harder/GraffitiCMS
        /// <summary>
        /// Gets all widgets in the specified WidgetLocation
        /// </summary>
        /// <param name="location"></param>
        /// <returns></returns>
        private static List <Widget> GetWidgets(WidgetLocation location)
        {
            List <Widget> _widgets = Widgets.FetchByLocation(location);
            List <Widget> widgets  = new List <Widget>();

            foreach (Widget w in _widgets)
            {
                if (w.IsUserValid())
                {
                    widgets.Add(w);
                }
            }

            return(widgets);
        }
예제 #2
0
        /// <summary>
        ///     Returns all Widgets for a given location. They are also sorted by O
        /// </summary>
        /// <param name="location"></param>
        /// <returns></returns>
        public static List <Widget> FetchByLocation(WidgetLocation location)
        {
            var filtered_widgets = new List <Widget>();

            foreach (Widget widget in FetchAll())
            {
                if (widget.Location == location)
                {
                    filtered_widgets.Add(widget);
                }
            }

            filtered_widgets.Sort(
                delegate(Widget wi1, Widget wi2) { return(Comparer <int> .Default.Compare(wi1.Order, wi2.Order)); });

            return(filtered_widgets);
        }
예제 #3
0
        /// <summary>
        /// Stores the results of a re-order in the the ObjectStore
        /// </summary>
        /// <param name="id">The idea of the element (lbar, rbar,qbar). This value will be used as the delimiter in the list paramater</param>
        /// <param name="list">A serialized delimited list of widget ids. It should use the pattern &amp;id[]=Guid&amp;id[]Guid</param>
        public static void ReOrder(string id, string list)
        {
            string[] saList = list.Split(new string[] { "&" }, StringSplitOptions.RemoveEmptyEntries);

            WidgetLocation wl = WidgetLocation.Right;

            if (id == "qbar")
            {
                wl = WidgetLocation.Queue;
            }
            if (id == "lbar")
            {
                wl = WidgetLocation.Left;
            }

            List <Widget> the_Widgets = FetchAll();
            int           i           = 0;

            foreach (string wid in saList)
            {
                foreach (Widget widget in the_Widgets)
                {
                    string gid = widget.Id.ToString();

                    if (gid == wid)
                    {
                        widget.Location = wl;
                        widget.Order    = i;
                        i++;
                        Save(widget, false);
                    }
                }
            }

            Reset();
        }
예제 #4
0
파일: Data.cs 프로젝트: chartek/graffiticms
        /// <summary>
        /// Gets all widgets in the specified WidgetLocation
        /// </summary>
        /// <param name="location"></param>
        /// <returns></returns>
        private static List<Widget> GetWidgets(WidgetLocation location)
        {
            List<Widget> _widgets = Widgets.FetchByLocation(location);
            List<Widget> widgets = new List<Widget>();
            foreach(Widget w in _widgets)
                if(w.IsUserValid())
                    widgets.Add(w);

            return widgets;
        }
예제 #5
0
 public WidgetAttribute(WidgetLocation location) : base(typeof(IWidget))
 {
     Location = location;
 }
예제 #6
0
        /// <summary>
        /// Renders a widget sidebar
        /// </summary>
        /// <param name="location"></param>
        /// <param name="dictionary"></param>
        /// <returns></returns>
        private static string SmartSideBar(WidgetLocation location, IDictionary dictionary)
        {
            string beforeWidget = dictionary["beforeWidget"] as string ?? "<li class=\"widget\">";
            string afterWidget = dictionary["afterWidget"] as string ?? "</li>";
            string afterTitle = dictionary["afterTitle"] as string ?? "</h2>";
            string beforeTitle = dictionary["beforeTitle"] as string ?? "<h2>";
            string beforeContent = dictionary["beforeContent"] as string;
            string afterContent = dictionary["afterContent"] as string;

            string beforeFirstWidget = dictionary["beforeFirstWidget"] as string;
            string afterFirstWidget = dictionary["afterFirstWidget"] as string;
            string beforeLastWidget = dictionary["beforeLastWidget"] as string;
            string afterLastWidget = dictionary["afterLastWidget"] as string;

            StringBuilder sb = new StringBuilder();

            List<Widget> allWidgets = Widgets.FetchByLocation(location);

            int curCount = 0;

            foreach (Widget widget in allWidgets)
            {
                if (widget.IsUserValid())
                {
                    curCount++;

                    if ((!String.IsNullOrEmpty(beforeFirstWidget) || !String.IsNullOrEmpty(afterFirstWidget)) && curCount == 1)
                    {
                        sb.Append(String.IsNullOrEmpty(beforeFirstWidget) ? beforeWidget : beforeFirstWidget);
                        sb.Append(widget.Render(beforeTitle, afterTitle, beforeContent, afterContent));
                        sb.Append(String.IsNullOrEmpty(afterFirstWidget) ? afterWidget : afterFirstWidget);
                    }
                    else if ((!String.IsNullOrEmpty(beforeLastWidget) || !String.IsNullOrEmpty(afterLastWidget)) && curCount == allWidgets.Count)
                    {
                        sb.Append(String.IsNullOrEmpty(beforeLastWidget) ? beforeWidget : beforeLastWidget);
                        sb.Append(widget.Render(beforeTitle, afterTitle, beforeContent, afterContent));
                        sb.Append(String.IsNullOrEmpty(afterLastWidget) ? afterWidget : afterLastWidget);
                    }
                    else
                    {
                        sb.Append(beforeWidget + "\n");
                        sb.Append(widget.Render(beforeTitle, afterTitle, beforeContent, afterContent));
                        sb.Append(afterWidget + "\n");
                    }
                }
            }
            return sb.ToString();
        }
예제 #7
0
        /// <summary>
        /// Returns all Widgets for a given location. They are also sorted by O
        /// </summary>
        /// <param name="location"></param>
        /// <returns></returns>
        public static List<Widget> FetchByLocation(WidgetLocation location)
        {
            List<Widget> filtered_widgets = new List<Widget>();
            foreach (Widget widget in FetchAll())
                if (widget.Location == location)
                    filtered_widgets.Add(widget);

            filtered_widgets.Sort(
                                      delegate(Widget wi1, Widget wi2)
                                      {
                                          return Comparer<int>.Default.Compare(wi1.Order, wi2.Order);
                                      });

            return filtered_widgets;
        }
예제 #8
0
 public WidgetAttribute(WidgetLocation location)
     : base(typeof(IWidget))
 {
     Location = location;
 }