Esempio n. 1
0
        /// <summary>
        /// Initialize the template if edit mode is active
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Init(object sender, EventArgs e)
        {
            if (ModeIsEdit)
                Template = Sexy.Templates.GetTemplate(TemplateID);

            var contentTypeSelectors = new[] { ctrContentType, ctrPresentationType, ctrListContentType, ctrListPresentationType };

            foreach (var contentTypeSelector in contentTypeSelectors)
            {
                contentTypeSelector.AppId = AppId.Value;
                contentTypeSelector.ZoneId = ZoneId.Value;
            }

            if (!IsContentApp)
                ddlTemplateLocations.Enabled = false;
        }
 public Template UpdateTemplate(Template Template)
 {
     SaveChanges();
     return(GetTemplate(Template.TemplateID));
 }
Esempio n. 3
0
        public IDataSource GetViewDataSource(int moduleId, bool showDrafts, Template template)
        {
            if (_viewDataSource == null)
            {
                var configurationProvider = GetConfigurationProvider(moduleId);

                // Get ModuleDataSource
                var initialSource = GetInitialDataSource(ZoneId.Value, AppId.Value, showDrafts);
                var moduleDataSource = DataSource.GetDataSource<ModuleDataSource>(ZoneId, AppId, initialSource, configurationProvider);
                moduleDataSource.ModuleId = moduleId;
                if(template != null)
                    moduleDataSource.OverrideTemplateId = template.TemplateId;
                moduleDataSource.Sexy = this;

                var viewDataSourceUpstream = moduleDataSource;

                // If the Template has a Data-Pipeline, use it instead of the ModuleDataSource created above
                if (template != null && template.Pipeline != null)
                    viewDataSourceUpstream = null;

                var viewDataSource = DataSource.GetDataSource<ViewDataSource>(ZoneId, AppId, viewDataSourceUpstream, configurationProvider);

                // Take Publish-Properties from the View-Template
                if (template != null)
                {
                    viewDataSource.Publish.Enabled = template.PublishData;
                    viewDataSource.Publish.Streams = template.StreamsToPublish;

                    // Append Streams of the Data-Pipeline (this doesn't require a change of the viewDataSource itself)
                    if (template.Pipeline != null)
                        DataPipelineFactory.GetDataSource(AppId.Value, template.Pipeline.EntityId, configurationProvider, viewDataSource);
                }

                _viewDataSource = viewDataSource;
            }

            return _viewDataSource;
        }
 /// <summary>
 /// Adds a template to the templates table
 /// </summary>
 /// <param name="NewTemplate"></param>
 /// <returns></returns>
 public Template AddTemplate(Template NewTemplate)
 {
     base.Templates.AddObject(NewTemplate);
     SaveChanges();
     return(NewTemplate);
 }