private void Init(BaseItem settings_item, string site_settings_path)
        {
            if (settings_item == null)
             {
            Log.Warn("Calendar Module: progress bar settings item isn't exist", this);
            settings_item = new ModuleSettings(site_settings_path).ProgressBarSettings;
             }

             _image = settings_item.Fields[ImageField];
             _text = settings_item[TextField];
        }
        public Calendar()
        {
            ViewMode = ViewModeOption.Month;
              SecurityManager.Init();
              SiteSettingsPath = new ModuleSettings(SiteSettingsPath).ModuleSettingsItemPath;

              if ((HttpContext.Current.Request.UserLanguages != null) &&
              (!String.IsNullOrEmpty(HttpContext.Current.Request.UserLanguages[0])))
              {
            Utilities.SetCurrentCulture(HttpContext.Current.Request.UserLanguages[0]);
              }
        }
        public bool IsDefaultSettingsItem(Item settings, string sitepath)
        {
            ModuleSettings moduleSettings = new ModuleSettings(sitepath);
             ExtendStandartViewSettings exSettings = new ExtendStandartViewSettings();

             exSettings.Init(settings, sitepath);

             return
            (exSettings.ID == moduleSettings.DayViewSettings.ID.ToString() ||
             exSettings.ID == moduleSettings.WeekViewSettings.ID.ToString()) &&
            !(exSettings.SwitchViewMode ||
              (exSettings.ShowHeader && exSettings.ID == moduleSettings.WeekViewSettings.ID.ToString()));
        }
        private void Init(BaseItem settings_item, string site_settings_path)
        {
            if (settings_item == null)
             {
            Log.Warn("Calendar Module: mini calendar settings item isn't exist", this);
            settings_item = new ModuleSettings(site_settings_path).MiniCalendarSettings;
             }

             _siteSpecificSettings = new ModuleSettings(site_settings_path);

             LinkBehavior = settings_item[LinkBehaviorField];
             LinkField redirect_field = settings_item.Fields[RedirectToField];

             Item target_item = redirect_field.TargetItem;

             if (target_item != null)
             {
            if (redirect_field.IsMediaLink)
            {
               MediaItem media = new MediaItem(target_item);
               RedirectTo = "~/" + MediaManager.GetMediaUrl(media);
            }
            else if (redirect_field.IsInternal)
            {
               RedirectTo = LinkManager.GetItemUrl(target_item);
            }
            else
            {
               RedirectTo = redirect_field.Url;
            }
             }
             else
             {
            RedirectTo = redirect_field.Url;
             }

             Margin = settings_item[MarginField];
             Title = settings_item[TitleField];

             Item[] event_lists;
             if (MainUtil.GetBool(settings_item[ShowAllCalendarsField], false))
             {
            event_lists = new Item[1];
            event_lists[0] = _siteSpecificSettings.CalendarEventsRoot;
             }
             else
             {
            MultilistField calendarListFld = settings_item.Fields[CalendarListField];
            event_lists = calendarListFld.GetItems();
             }
             EventLists = event_lists;
        }
        protected virtual void InitView()
        {
            Item settingsItem = null;

              var moduleSettings = new ModuleSettings(SiteSettingsPath);

              if (!string.IsNullOrEmpty(ViewSettingsPath))
              {
            settingsItem = moduleSettings.GetActiveDatabase().GetItem(ViewSettingsPath);
              }

              if (!string.IsNullOrEmpty(CustomView))
              {
            view = (BaseView)ReflectionUtil.CreateObject(CustomView,
                                       new object[] { _idCalendar, settingsItem, SiteSettingsPath });
              }

              if (view == null)
              {

            if (settingsItem != null)
            {
              if (settingsItem.TemplateID == CalendarIDs.AgendaViewTemplate)
              {
            ViewMode = ViewModeOption.Agenda;
            view = new AgendaView(_idCalendar, settingsItem, SiteSettingsPath);
              }
              else if (settingsItem.TemplateID == CalendarIDs.DayViewTemplate)
              {
            ViewMode = ViewModeOption.Day;
            view = new DayView(_idCalendar, settingsItem, SiteSettingsPath);
              }
              else if (settingsItem.TemplateID == CalendarIDs.MonthViewTemplate)
              {
            ViewMode = ViewModeOption.Month;
            view = new MonthView(_idCalendar, settingsItem, SiteSettingsPath);
              }
              else if (settingsItem.TemplateID == CalendarIDs.WeekViewTemplate)
              {
            ViewMode = ViewModeOption.Week;
            view = new WeekView(_idCalendar, settingsItem, SiteSettingsPath);
              }
            }
            else
            {
              switch (ViewMode)
              {
            case ViewModeOption.Week:
              settingsItem = moduleSettings.WeekViewSettings;
              view = new WeekView(_idCalendar, settingsItem, SiteSettingsPath);
              break;
            case ViewModeOption.Day:
              settingsItem = moduleSettings.DayViewSettings;
              view = new DayView(_idCalendar, settingsItem, SiteSettingsPath);
              break;
            case ViewModeOption.Agenda:
              settingsItem = moduleSettings.AgendaViewSettings;
              view = new AgendaView(_idCalendar, settingsItem, SiteSettingsPath);
              break;
            default:
              settingsItem = moduleSettings.MonthViewSettings;
              view = new MonthView(_idCalendar, settingsItem, SiteSettingsPath);
              break;
              }
            }
              }

              if (view != null)
              {
            view.CurrentDate = _currentDate;
            Controls.Add(view);
            _currentView = view;
              }
              else
              {
            Log.Error("Calendar: CalendarView provided settings item of incorrect type!", this);
            Log.Error("Calendar: Settings item path: " + settingsItem.Paths.Path, this);
            Log.Error("Calendar: Settings item type: " + settingsItem.TemplateName, this);
              }
        }
        private void Initialize()
        {
            initAjax();

                if ((HttpContext.Current.Request.UserLanguages != null) &&
                     (!String.IsNullOrEmpty(HttpContext.Current.Request.UserLanguages[0])))
                {
                    Utilities.SetCurrentCulture(HttpContext.Current.Request.UserLanguages[0]);
                }
                ModuleSettings module = new ModuleSettings(SiteSettingsPath);
                SiteSettingsPath = module.ModuleSettingsItemPath;
                Item settings_item = module.MiniCalendarSettings;
                MiniCalendarSettings settings = new MiniCalendarSettings(settings_item, SiteSettingsPath);

                EventListMgr = new EventListManager(settings.EventLists, SiteSettingsPath);
                LinkBehavior = settings.LinkBehavior;
                RedirectTo = settings.RedirectTo;
                Margin = settings.Margin;
                Title = settings.Title;

                navCalendar.Width = Unit.Pixel(152);
                navCalendar.Height = Unit.Pixel(89);
                navCalendar.DayNameFormat = DayNameFormat.FirstTwoLetters;

                navCalendar.BorderStyle = BorderStyle.Solid;
                navCalendar.BorderWidth = Unit.Pixel(1);
                navCalendar.CellPadding = 0;
                navCalendar.EnableTheming = true;
                navCalendar.EnableViewState = false;
                navCalendar.CssClass = "navCalendar";
                navCalendar.ID = "calendar" + ID;

                navCalendar.DayRender += navCalendar_DayRender;
                navCalendar.SelectionChanged += navCalendar_SelectionChanged;

                navCalendar.SelectedDayStyle.CssClass = "navDaySelected";

                navCalendar.DayStyle.CssClass = "navCalendarText";

                navCalendar.WeekendDayStyle.CssClass = "navWeekdays";

                navCalendar.OtherMonthDayStyle.CssClass = "navOtherMonth";

                navCalendar.NextPrevStyle.CssClass = "navNextPrev";
                navCalendar.NextPrevStyle.ForeColor = Color.White;

                navCalendar.DayHeaderStyle.CssClass = "navDayHeader";
                navCalendar.TitleStyle.CssClass = "navHeader";
                navCalendar.TitleStyle.BackColor = Color.White;

                updatePanel.ID = "UpdatePanel" + ID;

            if (!VirtualPreviewUtil.IsVirtualPreview(this.Page))
            {
              Controls.Add(updatePanel);
              updatePanel.ContentTemplateContainer.Controls.Add(navCalendar);
            }
            else
            {
              Controls.Add(navCalendar);
            }
        }
        private void LoadMapping(string modulePath)
        {
            if (siteSettingsPathDefault != modulePath)
             {
            siteSettingsPathDefault = modulePath;
            module = new ModuleSettings(siteSettingsPathDefault);

            mappingRenderings.Clear();
            mappingRenderings.Add(AgendaViewRenderingID, module.AgendaViewSettings.ID.ToString());
            mappingRenderings.Add(MonthViewRenderingID, module.MonthViewSettings.ID.ToString());
            mappingRenderings.Add(WeekViewRenderingID, module.WeekViewSettings.ID.ToString());
            mappingRenderings.Add(DayViewRenderingID, module.DayViewSettings.ID.ToString());
            mappingRenderings.Add(CalendarSelectorRenderingID, module.CalendarSelectorSettings.ID.ToString());
            mappingRenderings.Add(DateSelectorRenderingID, module.DateSelectorSettings.ID.ToString());
            mappingRenderings.Add(HtmlHeaderRenderingID, string.Empty);
            mappingRenderings.Add(MiniCalendarRenderingID, module.MiniCalendarSettings.ID.ToString());
            mappingRenderings.Add(ProgressBarRenderingID, module.ProgressBarSettings.ID.ToString());
             }
        }
        private void Init(Item settings_item, string site_settings_path)
        {
            if (settings_item == null)
             {
            Log.Warn("Calendar Module: agenda view settings item isn't exist", this);
            settings_item = new ModuleSettings(site_settings_path).AgendaViewSettings;
             }
             settings = settings_item;

             string limit = settings_item[EventLimitField];
             if (limit.Length > 0)
             {
            try
            {
               EventLimit = int.Parse(limit);
            }
            catch (Exception e)
            {
               Log.Warn("Calendar Module Agenda View Settings: Exception trying to parse Event Limit Field!", this);
               Log.Warn(e.Message, this);
               EventLimit = 0;
            }
             }

             Margin = settings_item[MarginField];
             ShowEventDate = MainUtil.GetBool(settings_item[ShowEventDateField], false);
             ShowEventTime = MainUtil.GetBool(settings_item[ShowEventTimeField], false);
             _dateFormat = settings_item[DateFormatField];
             if (string.IsNullOrEmpty(_dateFormat))
             {
            _dateFormat = "MM/dd/yyyy";
             }
             string date_option = settings_item[StartDateField];
             switch (date_option)
             {
            case TodayOption:
               StartDate = StartDateOption.Today;
               break;
            case SelectedDateOption:
               StartDate = StartDateOption.SelectedDate;
               break;
             }
             Title = settings_item[TitleField];

             EventLists = Utilities.GetEventListForView(settings_item, site_settings_path);
        }
 private void Initialize()
 {
     var moduleSettings = new ModuleSettings(SiteSettingsPath);
       SiteSettingsPath = moduleSettings.ModuleSettingsItemPath;
       Item settings_item = moduleSettings.ProgressBarSettings;
       settings = new ProgressBarSettings(settings_item, SiteSettingsPath);
       Image = settings.Image;
       Text = settings.Text;
 }
        public string GetViewHTML(int num, int startHour, string viewName, string currentView,
                                int hour, Options options)
        {
            if ((HttpContext.Current.Request.UserLanguages != null) &&
                     (!String.IsNullOrEmpty(HttpContext.Current.Request.UserLanguages[0])))
                {
                    Utilities.SetCurrentCulture(HttpContext.Current.Request.UserLanguages[0]);
                }

             var stringWriter = new StringWriter();
             var writer = new HtmlTextWriter(stringWriter);
             if (num > -1)
             {
            writer.Write(string.Format("<calendarNum>{0}</calendarNum>", num));
             }

             var moduleSettings = new ModuleSettings(options.SiteSettingsPath);
             Item site_settings = moduleSettings.GetSettingsItem();
             Item settingsItem = moduleSettings.GetActiveDatabase().GetItem(options.ControlSettingsPath);

             if (viewName == "day")
             {
            if (HttpContext.Current.Session[options.CalendarID] == null)
            {
               HttpContext.Current.Session.Add(options.CalendarID, currentView);
            }

            DayView view;
            if (Utilities.IsTemplateSettingsEqual(settingsItem, site_settings,
                                                  ModuleSettings.DayViewField))
            {
               view = new DayView(options.CalendarID, settingsItem, options.SiteSettingsPath);
            }
            else
            {
               view = new DayView(options.CalendarID, moduleSettings.DayViewSettings,
                                  options.SiteSettingsPath);
               view.SetSettings(settingsItem, options.SiteSettingsPath);
            }
            view.IsReinitNeed = true;

            view.CurrentDate = Utilities.StringToDate(options.Date);
            if (startHour > -1)
            {
               view.NumHoursDisplayed = hour;
               view.StartHour = startHour;
            }
            view.RenderControl(writer);
             }
             else
             {
            if (HttpContext.Current.Session[options.CalendarID] != null)
            {
               HttpContext.Current.Session.Remove(options.CalendarID);
            }

            if (viewName == "week")
            {
               WeekView view;
               if (Utilities.IsTemplateSettingsEqual(settingsItem, site_settings,
                                                     ModuleSettings.WeekViewField))
               {
                  view = new WeekView(options.CalendarID, settingsItem, options.SiteSettingsPath);
               }
               else
               {
                  view = new WeekView(options.CalendarID, moduleSettings.WeekViewSettings,
                                      options.SiteSettingsPath);
                  view.SetSettings(settingsItem, options.SiteSettingsPath);
               }
               view.IsReinitNeed = true;
               view.CurrentDate = Utilities.StringToDate(options.Date);
               if (startHour > -1)
               {
                  view.NumHoursDisplayed = hour;
                  view.StartHour = startHour;
               }
               view.RenderControl(writer);
            }
            else if (viewName == "month")
            {
               MonthView view;
               if (Utilities.IsTemplateSettingsEqual(settingsItem, site_settings,
                                                     ModuleSettings.MonthViewField))
               {
                  view = new MonthView(options.CalendarID, settingsItem, options.SiteSettingsPath);
               }
               else
               {
                  view = new MonthView(options.CalendarID, moduleSettings.MonthViewSettings,
                                       options.SiteSettingsPath);
                  view.SetSettings(settingsItem, options.SiteSettingsPath);
               }
               view.IsReinitNeed = true;
               view.CurrentDate = Utilities.StringToDate(options.Date);
               view.Attributes["startHour"] = startHour.ToString();
               view.Attributes["numHours"] = hour.ToString();
               view.RenderControl(writer);
            }
            else if (viewName == "agenda")
            {
               settingsItem = (viewName == currentView)
                                 ? settingsItem : moduleSettings.AgendaViewSettings;
               var view = new AgendaView(options.CalendarID, settingsItem, options.SiteSettingsPath);
               view.CurrentDate = Utilities.StringToDate(options.Date);
               view.RenderControl(writer);
            }
             }

             return stringWriter.ToString();
        }
 public EventListManager(Item[] eventlist_root_items, string site_settings_path)
 {
     SiteSettings = new ModuleSettings(site_settings_path);
      _eventLists = ExtractEventLists(eventlist_root_items);
 }
        public void Init(Item settings_item, string site_settings_path)
        {
            _siteSpecificSettings = new ModuleSettings(site_settings_path);

             RecurrentEventPrefix = settings_item[RecurrentEventPrefixField];
             RecurrentEventSuffix = settings_item[RecurrentEventSuffixField];
             ShowHeader = MainUtil.GetBool(settings_item[ShowHeaderField], false);
             SwitchViewMode = MainUtil.GetBool(settings_item[SwitchViewModeField], false);

             EventLists = Utilities.GetEventListForView(settings_item, site_settings_path);
        }
        private void Initialize()
        {
            ModuleSettings module = new ModuleSettings(SiteSettingsPath);

                SiteSettingsPath = module.ModuleSettingsItemPath;
                Item settings_item = module.DateSelectorSettings;
                DateSelectorSettings settings = new DateSelectorSettings(settings_item, SiteSettingsPath);

                Format = settings.Format;
                LinkText = settings.LinkText;
                Margin = settings.Margin;
                Title = settings.Title;
                TodayLinkText = settings.TodayLinkText;

                _selectorYear.EnableViewState = false;
                _selectorMonth.EnableViewState = false;
                _selectorDay.EnableViewState = false;

                _selectorYear.Attributes["id"] = "idSelectorYear";
                _selectorMonth.Attributes["id"] = "idSelectorMonth";
                _selectorDay.Attributes["id"] = "idSelectorDay";
                _selectorYear.Attributes["onclick"] = "UpdateDateSelector();";
                _selectorMonth.Attributes["onclick"] = "UpdateDateSelector();";

                initYearSelector();
                initMonthSelector();
                initDaySelector();

                setSelectedDate(CurrentDate);

                _selectDate.Text = LinkText;
                _selectDate.CssClass = "selectorButton";
                _selectDate.Click += onSelectDate;
                Controls.Add(_selectDate);

                _setTodayDate.Text = TodayLinkText;
                _setTodayDate.CssClass = "selectorButton";
                _setTodayDate.Click += onSetToday;

                Controls.Add(_setTodayDate);
        }
        public static void CreateEvents()
        {
            var module = new ModuleSettings(null);

             var eventManager = new EventListManager(new Item[1] {module.CalendarEventsRoot}, null);

             using (new SecurityDisabler())
             {
            CreateDeveloperTrainingEvents(eventManager);
            CreateEndUserTrainingEvents(eventManager);
            CreatePartiesEvents(eventManager);
            CreateLunchEvents(eventManager);
             }
        }
        public string GetHTMLDayInMonthView(string date, Options options, int startHour, int hour)
        {
            if ((HttpContext.Current.Request.UserLanguages != null) &&
                     (!String.IsNullOrEmpty(HttpContext.Current.Request.UserLanguages[0])))
                {
                    Utilities.SetCurrentCulture(HttpContext.Current.Request.UserLanguages[0]);
                }

             var moduleSettings = new ModuleSettings(options.SiteSettingsPath);
             Item site_settings = moduleSettings.GetSettingsItem();

             Item settingsItem = moduleSettings.GetActiveDatabase().GetItem(options.ControlSettingsPath);

             var stringWriter = new StringWriter();
             var writer = new HtmlTextWriter(stringWriter);

             MonthView view;
             if (Utilities.IsTemplateSettingsEqual(settingsItem, site_settings,
                                               ModuleSettings.MonthViewField))
             {
            view = new MonthView(options.CalendarID, settingsItem, options.SiteSettingsPath);
             }
             else
             {
            view = new MonthView(options.CalendarID, moduleSettings.MonthViewSettings,
                                 options.SiteSettingsPath);
            view.SetSettings(settingsItem, options.SiteSettingsPath);
             }

             view.IsReinitNeed = true;
             view.Attributes["startHour"] = startHour.ToString();
             view.Attributes["numHours"] = hour.ToString();
             view.CurrentDate = Utilities.StringToDate(options.Date);

             view.RenderDayCell(writer, Utilities.StringToDate(date));
             return stringWriter.ToString();
        }
        private new void Init(Item settings_item, string site_settings_path)
        {
            if (settings_item == null)
             {
            Log.Warn("Calendar Module: week view settings item isn't exist", this);
            settings_item = new ModuleSettings(site_settings_path).WeekViewSettings;
             }

             HeaderFormat = settings_item[HeaderFormatField];
             if (string.IsNullOrEmpty(HeaderFormat))
             {
            HeaderFormat = "MM/dd/yyyy";
             }
             Margin = settings_item[MarginField];
             string num_hours = settings_item[NumHoursDisplayedField];
             if (num_hours.Length > 0)
             {
            try
            {
               NumberHoursDisplayed = int.Parse(num_hours);
            }
            catch (Exception e)
            {
               Log.Warn("Calendar Module Week View Settings: Exception trying to parse Num Hours Displayed Field!", this);
               Log.Warn(e.Message, this);
            }
             }
             startHour = int.Parse(settings_item[StartHourField]);
             base.Init(settings_item, site_settings_path);
        }
        private void Init(BaseItem settings_item, string site_settings_path)
        {
            _siteSpecificSettings = new ModuleSettings(site_settings_path);

             if (settings_item == null)
             {
            Log.Warn("Calendar Module: calendar selector settings item isn't exist", this);
            settings_item = new ModuleSettings(site_settings_path).CalendarSelectorSettings;
             }

             Format = settings_item[FormatField];
             LinkText = settings_item[LinkTextField];
             Margin = settings_item[MarginField];
             Title = settings_item[TitleField];

             Item[] event_lists;
             if (MainUtil.GetBool(settings_item[ShowAllCalendarsField], false))
             {
            event_lists = new Item[1];
            event_lists[0] = _siteSpecificSettings.CalendarEventsRoot;
             }
             else
             {
            MultilistField calendarListFld = settings_item.Fields[CalendarListField];
            event_lists = calendarListFld.GetItems();
             }
             EventLists = event_lists;
        }
        private void initList()
        {
            var module = new ModuleSettings(SiteSettingsPath);
             SiteSettingsPath = module.ModuleSettingsItemPath;

             Item settings_item = null;
             if (!string.IsNullOrEmpty(SelectorSettingsPath))
             {
            settings_item = module.GetActiveDatabase().GetItem(SelectorSettingsPath);
             }

             var settings =
            new CalendarSelectorSettings(settings_item ?? module.CalendarSelectorSettings,
                                         SiteSettingsPath);

             EventListMgr = new EventListManager(settings.EventLists, SiteSettingsPath);
             Format = settings.Format;
             LinkText = settings.LinkText;
             Margin = settings.Margin;
             Title = settings.Title;

             if (ShowAsDropDownList)
             {
            _calsCtrl = new DropDownList();
             }
             else
             {
            _calsCtrl = new CheckBoxList();
             }

             _calsCtrl.EnableViewState = false;
        }
        public static Item[] GetEventListForView(Item settingsItem, string siteSettings)
        {
            ModuleSettings moduleSettings = new ModuleSettings(siteSettings);

             if (MainUtil.GetBool(settingsItem[StandardViewSettings.ShowAllCalendarsField], false))
             {
            return new Item[1] {moduleSettings.CalendarEventsRoot};
             }

             MultilistField calendarListFld = settingsItem.Fields[StandardViewSettings.CalendarListField];
             return calendarListFld.GetItems();
        }
        private void Init(BaseItem settings_item, string site_settings_path)
        {
            if (settings_item == null)
             {
            Log.Warn("Calendar Module: date selector settings item isn't exist", this);
            settings_item = new ModuleSettings(site_settings_path).CalendarSelectorSettings;
             }

             Format = settings_item[FormatField];
             LinkText = settings_item[LinkTextField];
             Margin = settings_item[MarginField];
             Title = settings_item[TitleField];
             TodayLinkText = settings_item[TodayLinkTextField];
        }
        private new void Init(Item settings_item, string site_settings_path)
        {
            if (settings_item == null)
             {
            Log.Warn("Calendar Module: month view settings item isn't exist", this);
            settings_item = new ModuleSettings(site_settings_path).MonthViewSettings;
             }

             ImageField addIcon = settings_item.Fields[AddEventIconField];
             AddEventIcon = "~/media" + addIcon.MediaPath + ".ashx";

             ImageField altIcon = settings_item.Fields[AltAddEventIconField];
             AltAddEventIcon = "~/media" + altIcon.MediaPath + ".ashx";

             string limit = settings_item[EventLimitField];
             if (limit.Length > 0)
             {
            try
            {
               EventLimit = int.Parse(limit);
            }
            catch (Exception e)
            {
               Log.Warn("Calendar Module Month View Settings: Exception trying to parse Event Limit Field!", this);
               Log.Warn(e.Message, this);
               EventLimit = 0;
            }
             }

             EventOverflowLinkText = settings_item[EventOverflowLinkTextField];

             HighlightWeekends = MainUtil.GetBool(settings_item[HighlightWeekendsField], false);

             Margin = settings_item[MarginField];

             ShowEventTime = MainUtil.GetBool(settings_item[ShowEventTimeField], false);

             base.Init(settings_item, site_settings_path);
        }