Ejemplo n.º 1
0
 protected void Bootstrapper_Initialized(object sender, Telerik.Sitefinity.Data.ExecutedEventArgs args)
 {
     if (args.CommandName == "Bootstrapped")
     {
         SampleUtilities.CreateUsersAndRoles();
     }
 }
        private void CreateSampleWorker(object[] args)
        {
            SampleUtilities.CreateUsersAndRoles();
            SampleUtilities.RegisterToolboxWidget("NewsRotator Widget", typeof(Rotator), "Samples");
            SampleUtilities.RegisterTheme(SamplesThemeName, SamplesThemePath);
            SampleUtilities.RegisterTemplate(new Guid(SamplesTemplateId), SamplesTemplateName, SamplesTemplateName, SamplesTemplatePath, SamplesThemeName);

            SampleUtilities.UploadImages(HttpRuntime.AppDomainAppPath + "Images", "Thumbnails");
            this.CreateNewsItems();

            var result = SampleUtilities.CreatePage(new Guid(NewsPageId), "News");

            if (result)
            {
                SampleUtilities.SetTemplateToPage(new Guid(NewsPageId), new Guid(SamplesTemplateId));

                NewsView newsView = new NewsView();
                SampleUtilities.AddControlToPage(new Guid(NewsPageId), newsView, "Content", "News");
            }

            result = SampleUtilities.CreatePage(new Guid(NewsRotatorWidgetPageId), NewsRotatorWidgetPageName, true);

            if (result)
            {
                SampleUtilities.SetTemplateToPage(new Guid(NewsRotatorWidgetPageId), new Guid(SamplesTemplateId));

                Rotator newsRotator = new Rotator();
                SampleUtilities.AddControlToPage(new Guid(NewsRotatorWidgetPageId), newsRotator, "Content", "NewsRotator Widget");
            }
        }
        private void CreateSampleWorker(object[] args)
        {
            SampleUtilities.CreateUsersAndRoles();
            SampleUtilities.RegisterTheme(SamplesThemeName, SamplesThemePath);
            SampleUtilities.RegisterTemplate(new Guid(SamplesTemplateId), SamplesTemplateName, SamplesTemplateName, SamplesTemplatePath, SamplesThemeName);

            var result = SampleUtilities.CreatePage(new Guid(JobApplicationPageId), JobApplicationPageName, true);

            if (result)
            {
                SampleUtilities.SetTemplateToPage(new Guid(JobApplicationPageId), new Guid(SamplesTemplateId));

                var jobApplicationUpload = new JobApplicationUpload();
                SampleUtilities.AddControlToPage(new Guid(JobApplicationPageId), jobApplicationUpload, "Content", "UploadJobsWidget");
            }
        }
Ejemplo n.º 4
0
        private void CreateSampleWorker(object[] args)
        {
            SampleUtilities.CreateUsersAndRoles();
            SampleUtilities.RegisterTheme(SamplesThemeName, SamplesThemePath);
            SampleUtilities.RegisterTemplate(new Guid(SamplesTemplateId), SamplesTemplateName, SamplesTemplateName, SamplesTemplatePath, SamplesThemeName);

            // Create Testimonials home page
            var result = SampleUtilities.CreatePage(new Guid(HomePageID), "Home", true);

            if (result)
            {
                SampleUtilities.SetTemplateToPage(new Guid(HomePageID), new Guid(SamplesTemplateId));

                // add welcome and instructions to page
                var generalInformationBlock = new ContentBlock();
                generalInformationBlock.Html = @"<h1>Testimonials Intra-Site Module Example</h1><p>This is the home page for the Testimonials Intra-Site module. Below is the Testimonials View Widget. It has a property to set a <a href=""testimonials"">separate page</a> for the details view.</p><p>On <a href=""testimonials"">the testimonials page</a> is a separate Testimonials View Widget that uses its own page as the details page.</p><p>This allows you to have multiple instances of the same content lists, all pointing to the same details page.</p>";

                SampleUtilities.AddControlToPage(new Guid(HomePageID), generalInformationBlock, "Content", "Content block");

                // create Testimonials View
                var mgr  = PageManager.GetManager();
                var ctrl = mgr.CreateControl <PageControl>("~/Modules/Testimonials/TestimonialsView.ascx", "Content");
                ctrl.Caption = "TestimonialsView";

                // set details page to Testimonials Page
                var prop = ctrl.Properties.FirstOrDefault(p => p.Name == "DetailsPageID");
                if (prop == null)
                {
                    prop      = new ControlProperty();
                    prop.Id   = Guid.NewGuid();
                    prop.Name = "DetailsPageID";
                    ctrl.Properties.Add(prop);
                }

                // the ID is needed for the control to be duplicated
                var idProp = ctrl.Properties.FirstOrDefault(p => p.Name == "ID");
                if (idProp == null)
                {
                    idProp      = new ControlProperty();
                    idProp.Id   = Guid.NewGuid();
                    idProp.Name = "ID";
                    ctrl.Properties.Add(idProp);
                }

                prop.Value   = TestimonialsPageID;
                idProp.Value = "TestimonialsView";

                SampleUtilities.AddControlToPage(new Guid(HomePageID), ctrl, "Content");
            }

            // Create Testimonials list/details page
            result = SampleUtilities.CreatePage(new Guid(TestimonialsPageID), "Testimonials", false);
            if (result)
            {
                SampleUtilities.SetTemplateToPage(new Guid(TestimonialsPageID), new Guid(SamplesTemplateId));
                SampleUtilities.AddControlToPage(new Guid(TestimonialsPageID), "~/Modules/Testimonials/TestimonialsView.ascx", "Content", "TestimonialsView");
            }

            // "Submit Testimonial" page
            result = SampleUtilities.CreatePage(new Guid(SubmitTestimonialPageID), "Submit", false);
            if (result)
            {
                SampleUtilities.SetTemplateToPage(new Guid(SubmitTestimonialPageID), new Guid(SamplesTemplateId));
                SampleUtilities.AddControlToPage(new Guid(SubmitTestimonialPageID), "~/Modules/Testimonials/SubmitTestimonial.ascx", "Content", "SubmitTestimonial");
            }

            // create sample testimonials
            var context = TestimonialsContext.Get();

            if (context.Testimonials.Count() > 0)
            {
                return;
            }

            context.Add(new Testimonial()
            {
                Name       = "John Doe",
                Rating     = 5,
                Summary    = "What a great product!",
                Text       = TESIMONIAL_TEXT,
                DatePosted = DateTime.Now,
                Published  = true,
                UrlName    = "john-doe"
            });
            context.Add(new Testimonial()
            {
                Name       = "Jane Doe",
                Rating     = 4,
                Summary    = "A solid product, almost perfect!",
                Text       = TESIMONIAL_TEXT,
                DatePosted = DateTime.Now,
                Published  = true,
                UrlName    = "jane-doe"
            });
            context.Add(new Testimonial()
            {
                Name       = "Jim Doe",
                Rating     = 3,
                Summary    = "Not bad; worth my time but could use a few more features.",
                Text       = TESIMONIAL_TEXT,
                DatePosted = DateTime.Now,
                Published  = true,
                UrlName    = "jim-doe"
            });
            context.SaveChanges();
        }