当前位置: 首页>>代码示例>>C#>>正文


C# Primitive.ParseBreadCrumbs方法代码示例

本文整理汇总了C#中BoxSocial.Internals.Primitive.ParseBreadCrumbs方法的典型用法代码示例。如果您正苦于以下问题:C# Primitive.ParseBreadCrumbs方法的具体用法?C# Primitive.ParseBreadCrumbs怎么用?C# Primitive.ParseBreadCrumbs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BoxSocial.Internals.Primitive的用法示例。


在下文中一共展示了Primitive.ParseBreadCrumbs方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Show

        public static void Show(Core core, TPage page, Primitive owner, int year, int month, int day)
        {
            core.Template.SetTemplate("Calendar", "viewcalendarday");

            // 15 year window
            if (year < DateTime.Now.Year - 10 || year > DateTime.Now.Year + 5)
            {
                core.Functions.Generate404();
            }

            if (month < 1 || month > 12)
            {
                core.Functions.Generate404();
            }

            if (day < 1 || day > DateTime.DaysInMonth(year, month))
            {
                core.Functions.Generate404();
            }

            /* pages */
            core.Display.ParsePageList(owner, true);

            core.Template.Parse("PAGE_TITLE", day.ToString() + " " + core.Functions.IntToMonth(month) + " " + year.ToString());

            core.Template.Parse("CURRENT_DAY", day.ToString());
            core.Template.Parse("CURRENT_MONTH", core.Functions.IntToMonth(month));
            core.Template.Parse("CURRENT_YEAR", year.ToString());

            long startTime = core.Tz.GetUnixTimeStamp(new DateTime(year, month, day, 0, 0, 0));
            long endTime = startTime + 60 * 60 * 24;

            Calendar cal = null;
            try
            {
                cal = new Calendar(core, owner);
            }
            catch (InvalidCalendarException)
            {
                cal = Calendar.Create(core, owner);
            }

            if (cal.Access.Can("CREATE_EVENTS"))
            {
                core.Template.Parse("U_NEW_EVENT", core.Hyperlink.BuildAccountSubModuleUri(owner, "calendar", "new-event", true,
                    string.Format("year={0}", year),
                    string.Format("month={0}", month),
                    string.Format("day={0}", day)));
            }

            List<Event> events = cal.GetEvents(core, owner, startTime, endTime);

            bool hasAllDaysEvents = false;

            foreach (Event calendarEvent in events)
            {
                if (calendarEvent.AllDay)
                {
                    hasAllDaysEvents = true;
                    VariableCollection eventVariableCollection = core.Template.CreateChild("event");

                    eventVariableCollection.Parse("TITLE", calendarEvent.Subject);
                    eventVariableCollection.Parse("URI", calendarEvent.Uri);
                }
            }

            if (hasAllDaysEvents)
            {
                core.Template.Parse("ALL_DAY_EVENTS", "TRUE");
            }

            VariableCollection[] hours = new VariableCollection[24];

            for (int hour = 0; hour < 24; hour++)
            {
                VariableCollection timeslotVariableCollection = core.Template.CreateChild("timeslot");

                DateTime hourTime = new DateTime(year, month, day, hour, 0, 0);

                timeslotVariableCollection.Parse("TIME", hourTime.ToString("h tt").ToLower());
                hours[hour] = timeslotVariableCollection;
            }

            showHourEvents(core, owner, year, month, day, hours, events);

            List<string[]> calendarPath = new List<string[]>();
            calendarPath.Add(new string[] { "calendar", core.Prose.GetString("CALENDAR") });
            calendarPath.Add(new string[] { year.ToString(), year.ToString() });
            calendarPath.Add(new string[] { month.ToString(), core.Functions.IntToMonth(month) });
            calendarPath.Add(new string[] { day.ToString(), day.ToString() });
            owner.ParseBreadCrumbs(calendarPath);
        }
开发者ID:smithydll,项目名称:boxsocial,代码行数:92,代码来源:Calendar.cs

示例2: ShowAll

        public static void ShowAll(Core core, TPage page, Primitive owner)
        {
            core.Template.SetTemplate("Calendar", "viewcalendartasks");

            long startTime = core.Tz.GetUnixTimeStamp(new DateTime(core.Tz.Now.Year, core.Tz.Now.Month, core.Tz.Now.Day, 0, 0, 0)) - 60 * 60 * 24 * 7; // show tasks completed over the last week
            long endTime = startTime + 60 * 60 * 24 * 7 * (8 + 1); // skip ahead eight weeks into the future

            Calendar cal = null;
            try
            {
                cal = new Calendar(core, owner);
            }
            catch (InvalidCalendarException)
            {
                cal = Calendar.Create(core, owner);
            }

            if (cal.Access.Can("CREATE_TASKS"))
            {
                core.Template.Parse("U_NEW_TASK", core.Hyperlink.BuildAccountSubModuleUri(owner, "calendar", "new-task", true,
                    string.Format("year={0}", core.Tz.Now.Year),
                    string.Format("month={0}", core.Tz.Now.Month),
                    string.Format("day={0}", core.Tz.Now.Day)));
            }

            List<Task> tasks = cal.GetTasks(core, owner, startTime, endTime, true);

            /* pages */
            core.Display.ParsePageList(owner, true);

            core.Template.Parse("PAGE_TITLE", core.Prose.GetString("TASKS"));

            VariableCollection taskDaysVariableCollection = null;
            string lastDay = core.Tz.ToStringPast(core.Tz.Now);

            if (tasks.Count > 0)
            {
                core.Template.Parse("HAS_TASKS", "TRUE");
            }

            foreach (Task calendarTask in tasks)
            {
                DateTime taskDue = calendarTask.GetDueTime(core.Tz);

                if (taskDaysVariableCollection == null || lastDay != core.Tz.ToStringPast(taskDue))
                {
                    lastDay = core.Tz.ToStringPast(taskDue);
                    taskDaysVariableCollection = core.Template.CreateChild("task_days");

                    taskDaysVariableCollection.Parse("DAY", lastDay);
                }

                VariableCollection taskVariableCollection = taskDaysVariableCollection.CreateChild("task_list");

                taskVariableCollection.Parse("DATE", taskDue.ToShortDateString() + " (" + taskDue.ToShortTimeString() + ")");
                taskVariableCollection.Parse("TOPIC", calendarTask.Topic);
                taskVariableCollection.Parse("ID", calendarTask.Id.ToString());
                taskVariableCollection.Parse("URI", Task.BuildTaskUri(core, calendarTask));
                taskVariableCollection.Parse("U_MARK_COMPLETE", Task.BuildTaskMarkCompleteUri(core, calendarTask));

                if (calendarTask.Status == TaskStatus.Overdue)
                {
                    taskVariableCollection.Parse("OVERDUE", "TRUE");
                    taskVariableCollection.Parse("CLASS", "overdue-task");
                }
                else if (calendarTask.Status == TaskStatus.Completed)
                {
                    taskVariableCollection.Parse("COMPLETE", "TRUE");
                    taskVariableCollection.Parse("CLASS", "complete-task");
                }
                else
                {
                    taskVariableCollection.Parse("CLASS", "task");
                }

                // TODO: fix this
                if (calendarTask.Priority == TaskPriority.High)
                {
                    taskDaysVariableCollection.ParseRaw("PRIORITY", "[<span class=\"high-priority\" title=\"High Priority\">H</span>]");
                }
                else if (calendarTask.Priority == TaskPriority.Low)
                {
                    taskDaysVariableCollection.ParseRaw("PRIORITY", "[<span class=\"low-priority\" title=\"Low Priority\">L</span>]");
                }
            }

            List<string[]> calendarPath = new List<string[]>();
            calendarPath.Add(new string[] { "calendar", core.Prose.GetString("CALENDAR") });
            calendarPath.Add(new string[] { "*tasks", core.Prose.GetString("TASKS") });
            owner.ParseBreadCrumbs(calendarPath);
        }
开发者ID:smithydll,项目名称:boxsocial,代码行数:91,代码来源:Task.cs

示例3: Show

        public static void Show(Core core, TPage page, Primitive owner, long taskId)
        {
            core.Template.SetTemplate("Calendar", "viewcalendartask");

            try
            {
                Task calendarTask = new Task(core, owner, taskId);

                if (!calendarTask.Access.Can("VIEW"))
                {
                    core.Functions.Generate403();
                    return;
                }

                if (calendarTask.Calendar.Access.Can("CREATE_TASKS"))
                {
                    core.Template.Parse("U_NEW_TASK", core.Hyperlink.BuildAccountSubModuleUri(owner, "calendar", "new-task", true,
                        string.Format("year={0}", core.Tz.Now.Year),
                        string.Format("month={0}", core.Tz.Now.Month),
                        string.Format("day={0}", core.Tz.Now.Day)));
                }

                if (calendarTask.Access.Can("EDIT"))
                {
                    core.Template.Parse("U_EDIT_TASK", core.Hyperlink.BuildAccountSubModuleUri(owner, "calendar", "new-task", "edit", taskId, true));
                }

                /* pages */
                core.Display.ParsePageList(owner, true);

                core.Template.Parse("PAGE_TITLE", calendarTask.Topic);

                core.Template.Parse("TOPIC", calendarTask.Topic);
                core.Template.Parse("DESCRIPTION", calendarTask.Description);
                core.Template.Parse("DUE_DATE", calendarTask.GetDueTime(core.Tz).ToString());

                List<string[]> calendarPath = new List<string[]>();

                calendarPath.Add(new string[] { "calendar", core.Prose.GetString("CALENDAR") });
                calendarPath.Add(new string[] { "*tasks", core.Prose.GetString("TASKS") });
                calendarPath.Add(new string[] { "task/" + calendarTask.TaskId.ToString(), calendarTask.Topic });

                owner.ParseBreadCrumbs(calendarPath);
            }
            catch (InvalidTaskException)
            {
                core.Display.ShowMessage("Invalid submission", "You have made an invalid form submission.");
            }
        }
开发者ID:smithydll,项目名称:boxsocial,代码行数:49,代码来源:Task.cs

示例4: Show

        private static void Show(Core core, Primitive owner, Page thePage)
        {
            core.Template.SetTemplate("Pages", "viewpage");

            core.Display.ParsePageList(owner, true, thePage);

            if (!thePage.Access.Can("VIEW"))
            {
                core.Functions.Generate403();
                return;
            }

            BoxSocial.Internals.Classification.ApplyRestrictions(core, thePage.Classification);

            core.Template.Parse("PAGE_TITLE", thePage.Title);

            if (!string.IsNullOrEmpty(thePage.BodyCache))
            {
                core.Display.ParseBbcodeCache("PAGE_BODY", thePage.BodyCache);
            }
            else
            {
                core.Display.ParseBbcode(core.Template, "PAGE_BODY", thePage.Body, thePage.Owner, true, null, null);
            }

            if (core.Session.LoggedInMember != null)
            {
                if (owner is User && owner.Id != core.Session.LoggedInMember.UserId)
                {
                    core.Db.UpdateQuery(string.Format("UPDATE user_pages SET page_views = page_views + 1 WHERE page_item_id = {0} AND page_item_type_id = {1} AND page_id = '{2}';",
                        owner.Id, owner.TypeId, thePage.PageId));
                }
                else
                {
                    core.Db.UpdateQuery(string.Format("UPDATE user_pages SET page_views = page_views + 1 WHERE page_item_id = {0} AND page_item_type_id = {1} AND page_id = '{2}';",
                        owner.Id, owner.TypeId, thePage.PageId));
                }
            }

            ItemView.LogView(core, thePage);

            if (thePage.License != null)
            {
                if (!string.IsNullOrEmpty(thePage.License.Title))
                {
                    core.Template.Parse("PAGE_LICENSE", thePage.License.Title);
                }
                if (!string.IsNullOrEmpty(thePage.License.Icon))
                {
                    core.Template.Parse("I_PAGE_LICENSE", thePage.License.Icon);
                }
                if (!string.IsNullOrEmpty(thePage.License.Link))
                {
                    core.Template.Parse("U_PAGE_LICENSE", thePage.License.Link);
                }
            }

            switch (thePage.Classification)
            {
                case Classifications.Everyone:
                    core.Template.Parse("PAGE_CLASSIFICATION", "Suitable for Everyone");
                    core.Template.Parse("I_PAGE_CLASSIFICATION", "rating_e.png");
                    break;
                case Classifications.Mature:
                    core.Template.Parse("PAGE_CLASSIFICATION", "Suitable for Mature Audiences 15+");
                    core.Template.Parse("I_PAGE_CLASSIFICATION", "rating_15.png");
                    break;
                case Classifications.Restricted:
                    core.Template.Parse("PAGE_CLASSIFICATION", "Retricted to Audiences 18+");
                    core.Template.Parse("I_PAGE_CLASSIFICATION", "rating_18.png");
                    break;
            }

            DateTime pageDateTime = thePage.GetModifiedDate(core.Tz);
            core.Template.Parse("PAGE_LAST_MODIFIED", core.Tz.DateTimeToString(pageDateTime));
            core.Template.Parse("PAGE_VIEWS", thePage.Views.ToString());
            core.Template.Parse("LAST_MODIFIED_PAGE_VIEWS", string.Format(core.Prose.GetString("LAST_MODIFIED_PAGE_VIEWS"), core.Tz.DateTimeToString(pageDateTime), thePage.Views.ToString()));

            List<string[]> breadCrumbParts = new List<string[]>();
            if (thePage.Parents != null)
            {
                foreach (ParentTreeNode ptn in thePage.Parents.Nodes)
                {
                    breadCrumbParts.Add(new string[] { ptn.ParentSlug, ptn.ParentTitle });
                }
            }

            if (thePage.Id > 0)
            {
                breadCrumbParts.Add(new string[] { thePage.Slug, thePage.Title });
            }

            owner.ParseBreadCrumbs(breadCrumbParts);

            if (thePage.Access.Can("EDIT"))
            {
                core.Template.Parse("U_EDIT", core.Hyperlink.BuildAccountSubModuleUri(owner, "pages", "write", "edit", thePage.PageId, true));
            }
        }
开发者ID:smithydll,项目名称:boxsocial,代码行数:99,代码来源:Default.cs


注:本文中的BoxSocial.Internals.Primitive.ParseBreadCrumbs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。