Пример #1
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            calItems.StopProcessing = true;
        }
        else
        {
            calItems.ControlContext = repEvent.ControlContext = ControlContext;

            // Calendar properties
            calItems.CacheItemName = CacheItemName;

            calItems.CacheDependencies         = CacheDependencies;
            calItems.CacheMinutes              = CacheMinutes;
            calItems.CheckPermissions          = CheckPermissions;
            calItems.ClassNames                = ClassNames;
            calItems.CombineWithDefaultCulture = CombineWithDefaultCulture;

            calItems.CultureCode         = CultureCode;
            calItems.MaxRelativeLevel    = MaxRelativeLevel;
            calItems.OrderBy             = OrderBy;
            calItems.WhereCondition      = WhereCondition;
            calItems.Columns             = Columns;
            calItems.Path                = Path;
            calItems.SelectOnlyPublished = SelectOnlyPublished;
            calItems.SiteName            = SiteName;
            calItems.FilterName          = FilterName;

            calItems.RelationshipName           = RelationshipName;
            calItems.RelationshipWithNodeGuid   = RelationshipWithNodeGuid;
            calItems.RelatedNodeIsOnTheLeftSide = RelatedNodeIsOnTheLeftSide;

            calItems.TransformationName        = TransformationName;
            calItems.NoEventTransformationName = NoEventTransformationName;

            calItems.DayField             = DayField;
            calItems.EventEndField        = EventEndField;
            calItems.HideDefaultDayNumber = HideDefaultDayNumber;

            calItems.TodaysDate = CMSContext.ConvertDateTime(DateTime.Now, this);

            bool detail = false;

            // If calendar event path is defined event is loaded in accordance to the selected path
            string eventPath = QueryHelper.GetString("CalendarEventPath", null);
            if (!String.IsNullOrEmpty(eventPath))
            {
                detail        = true;
                repEvent.Path = eventPath;

                // Set selected date to specific document
                TreeNode node = TreeHelper.GetDocument(SiteName, eventPath, CultureCode, CombineWithDefaultCulture, ClassNames, SelectOnlyPublished, CheckPermissions, CMSContext.CurrentUser);
                if (node != null)
                {
                    object value = node.GetValue(DayField);
                    if (ValidationHelper.GetDateTime(value, DataHelper.DATETIME_NOT_SELECTED) != DataHelper.DATETIME_NOT_SELECTED)
                    {
                        calItems.TodaysDate = CMSContext.ConvertDateTime((DateTime)value, this);
                    }
                }
            }

            // By default select current event from current document value
            PageInfo currentPage = CMSContext.CurrentPageInfo;
            if ((currentPage != null) && (ClassNames.ToLower().Contains(currentPage.ClassName.ToLower())))
            {
                detail        = true;
                repEvent.Path = currentPage.NodeAliasPath;

                // Set selected date to current document
                object value = CMSContext.CurrentDocument.GetValue(DayField);
                if (ValidationHelper.GetDateTime(value, DataHelper.DATETIME_NOT_SELECTED) != DataHelper.DATETIME_NOT_SELECTED)
                {
                    calItems.TodaysDate = CMSContext.ConvertDateTime((DateTime)value, this);
                    // Get name of coupled class ID column
                    string idColumn = CMSContext.CurrentDocument.CoupledClassIDColumn;
                    if (!string.IsNullOrEmpty(idColumn))
                    {
                        // Set selected item ID and the ID column name so it is possible to highlight specific event in the calendar
                        calItems.SelectedItemIDColumn = idColumn;
                        calItems.SelectedItemID       = ValidationHelper.GetInteger(CMSContext.CurrentDocument.GetValue(idColumn), 0);
                    }
                }
            }

            if (detail)
            {
                // Setup the detail repeater
                repEvent.Visible        = true;
                repEvent.StopProcessing = false;

                repEvent.SelectedItemTransformationName = EventDetailTransformation;
                repEvent.ClassNames = ClassNames;
                repEvent.Columns    = Columns;

                if (!String.IsNullOrEmpty(CacheItemName))
                {
                    repEvent.CacheItemName = CacheItemName + "|detail";
                }

                repEvent.CacheDependencies         = CacheDependencies;
                repEvent.CacheMinutes              = CacheMinutes;
                repEvent.CheckPermissions          = CheckPermissions;
                repEvent.CombineWithDefaultCulture = CombineWithDefaultCulture;

                repEvent.CultureCode = CultureCode;

                repEvent.SelectOnlyPublished = SelectOnlyPublished;
                repEvent.SiteName            = SiteName;

                repEvent.WhereCondition = WhereCondition;
            }
        }
    }