Ejemplo n.º 1
0
        public void TestMixinExpansion()
        {
            var scssFactory = CssParserLocator.FindComponent(ContentTypeManager.GetContentType(ScssContentTypeDefinition.ScssContentType));
            var scssCode    = @"a {
                                @mixin myMixin($p) {
                                        b, code {
                                            width: $p+10+px;
                                        }
                                    }
                                    @include myMixin(1)
                                }
                            ";

            var scssDoc    = scssFactory.CreateParser().Parse(scssCode, false);
            var scssBlocks = new CssItemAggregator <RuleSet>(true)
            {
                (RuleSet rs) => rs
            }.Crawl(scssDoc).ToList();

            // Remove all but the deepest blocks
            while (0 < scssBlocks.RemoveAll(c => scssBlocks.Any(c.IsParentOf)))
            {
                ;
            }

            var literalExpansions = scssBlocks.SelectMany(rs => ScssDocument.GetSelectorNames(rs, ScssMixinAction.Literal)).ToList();

            literalExpansions.Should().Equal(new[] { "a b", "a code" });

            var skipExpansions = scssBlocks.SelectMany(rs => ScssDocument.GetSelectorNames(rs, ScssMixinAction.Skip)).ToList();

            skipExpansions.Should().BeEmpty();
        }
Ejemplo n.º 2
0
        private ContentListType ManageContentListType(Dictionary <string, FieldDescriptor> fieldInfoList, Dictionary <string, List <string> > oldBindings, bool modify, out List <FieldSetting> fieldSettings)
        {
            var attempts = 0;

            while (true)
            {
                try
                {
                    return(ManageContentListTypeOneAttempt(fieldInfoList, oldBindings, modify, out fieldSettings));
                }
                catch (Exception e)
                {
                    if (!e.Message.Contains("Storage schema is out of date") || attempts++ >= 42)
                    {
                        throw;
                    }
                }
                var timer = Stopwatch.StartNew();
                ActiveSchema.Reload();
                ContentTypeManager.Reload();
                timer.Stop();
                var d          = timer.Elapsed;
                var timeString = $"{d.Minutes}:{d.Seconds}.{d.Milliseconds}";
                SnLog.WriteInformation(
                    $"Type system is reloaded because it was out of date during managing a list type. Attempt: {attempts}, reloading time: {timeString}",
                    EventId.RepositoryRuntime);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 常规栏目信息
        /// </summary>
        /// <returns></returns>
        public ActionResult AddGeneral()
        {
            var _general = new CategoryGeneral()
            {
                ContentView = "Index", View = "Index"
            };
            List <SelectListItem> _contentTypeItems = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Value = "0", Text = "无", Selected = true
                }
            };
            ContentTypeManager _contentTypeManager = new ContentTypeManager();
            var _contentTypes = _contentTypeManager.FindList();

            foreach (var contentType in _contentTypes)
            {
                _contentTypeItems.Add(new SelectListItem()
                {
                    Value = contentType.ID.ToString(), Text = contentType.Name
                });
            }
            ViewBag.ContentTypeItems = _contentTypeItems;
            return(PartialView(_general));
        }
Ejemplo n.º 4
0
        private void InitialDataTestPrivate(Action callback, bool withSecurity)
        {
            Cache.Reset();
            ContentTypeManager.Reset();
            Providers.Instance.ResetBlobProviders();

            var builder = CreateRepositoryBuilderForTest();

            Indexing.IsOuterSearchEngineEnabled = true;

            Cache.Reset();
            ContentTypeManager.Reset();

            using (Repository.Start(builder))
            {
                using (new SystemAccount())
                {
                    if (withSecurity)
                    {
                        var sdbp = new PrivateType(typeof(MemoryDataProvider));
                        var db   = (DatabaseStorage)sdbp.GetStaticFieldOrProperty("Storage");
                        db.Aces.Clear();

                        SecurityHandler.CreateAclEditor()
                        .Allow(Identifiers.PortalRootId, Identifiers.AdministratorsGroupId, false,
                               PermissionType.BuiltInPermissionTypes)
                        .Allow(Identifiers.PortalRootId, Identifiers.AdministratorUserId, false,
                               PermissionType.BuiltInPermissionTypes)
                        .Apply();
                    }

                    callback();
                }
            }
        }
Ejemplo n.º 5
0
        private T ExecuteTest <T>(bool useCurrentUser, Action <RepositoryBuilder> initialize, Func <T> callback)
        {
            DistributedApplication.Cache.Reset();
            ContentTypeManager.Reset();

            var builder = CreateRepositoryBuilderForTest();

            initialize?.Invoke(builder);

            Indexing.IsOuterSearchEngineEnabled = true;

            if (!_prototypesCreated)
            {
                SnTrace.Test.Write("Start repository.");
            }

            using (Repository.Start(builder))
            {
                if (useCurrentUser)
                {
                    return(callback());
                }
                using (new SystemAccount())
                    return(callback());
            }
        }
Ejemplo n.º 6
0
        private void ExecuteTest(bool useCurrentUser, Action <RepositoryBuilder> initialize, Action callback)
        {
            DistributedApplication.Cache.Reset();
            ContentTypeManager.Reset();
            var portalContextAcc = new PrivateType(typeof(PortalContext));

            portalContextAcc.SetStaticField("_sites", new Dictionary <string, Site>());

            var builder = CreateRepositoryBuilderForTest();

            initialize?.Invoke(builder);

            Indexing.IsOuterSearchEngineEnabled = true;

            if (!_prototypesCreated)
            {
                SnTrace.Test.Write("Start repository.");
            }

            using (Repository.Start(builder))
            {
                if (useCurrentUser)
                {
                    callback();
                }
                else
                {
                    using (new SystemAccount())
                        callback();
                }
            }
        }
Ejemplo n.º 7
0
 public void SetUp()
 {
     IAssemblyFinder assemblyFinder = new AssemblyFinder();
     ITypeFinder typeFinder = new TypeFinder(assemblyFinder);
     ContentTypeBuilder contentTypeBuilder = new ContentTypeBuilder(typeFinder, null, null, null, null, null);
     _definitionManager = new ContentTypeManager(contentTypeBuilder, null);
 }
Ejemplo n.º 8
0
        public void ContentType_MorePermissiveLoad_MissingContentHandler_Load()
        {
            Test(() =>
            {
                var ctd0 = @"<ContentType name=""MyType1"" parentType=""GenericContent"" handler=""SenseNet.ContentRepository.GenericContent"" xmlns=""http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition"">
  <Fields>
    <Field name=""Field1"" type=""ShortText""></Field>
  </Fields>
</ContentType>";
                var ctd1 = @"<ContentType name=""MyType1"" parentType=""GenericContent"" handler=""MyType"" xmlns=""http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition"">
  <Fields>
    <Field name=""Field1"" type=""ShortText""></Field>
  </Fields>
</ContentType>";

                // ARRANGE
                ContentTypeInstaller.InstallContentType(ctd0);

                var myType = ContentType.GetByName("MyType1");
                Assert.IsNotNull(myType);
                Assert.IsNotNull(myType.FieldSettings.FirstOrDefault(x => x.Name == "Field1"));

                HackDatabaseForMorePermissiveLoadTest("MyType1", ctd0, ctd1);

                // ACTION: Reload schema from the database.
                Cache.Reset();
                ContentTypeManager.Reload();

                // ASSERT: the ContentType is loaded but invalid.
                var myType1 = ContentType.GetByName("MyType1");
                Assert.AreEqual(ctd1, myType1.ToXml());
                Assert.IsTrue(myType1.IsInvalid);
            });
        }
Ejemplo n.º 9
0
        public static void InitializeRepositoryInstance(TestContext context)
        {
            Cache.Reset();
            ContentTypeManager.Reset();
            var portalContextAcc = new PrivateType(typeof(PortalContext));

            portalContextAcc.SetStaticField("_sites", new Dictionary <string, Site>());

            var builder = CreateRepositoryBuilderForTest();

            Indexing.IsOuterSearchEngineEnabled = true;

            _repository = Repository.Start(builder);

            Cache.Reset();
            ContentTypeManager.Reset();

            using (new SystemAccount())
            {
                SecurityHandler.CreateAclEditor()
                .Allow(Identifiers.PortalRootId, Identifiers.AdministratorsGroupId, false, PermissionType.BuiltInPermissionTypes)
                .Allow(Identifiers.PortalRootId, Identifiers.AdministratorUserId, false, PermissionType.BuiltInPermissionTypes)
                .Apply();
            }
        }
Ejemplo n.º 10
0
 public static IEnumerable <IContentType> GetChainCompilationContentTypes()
 {
     return(new[] {
         ContentTypeManager.GetContentType("LESS"),
         ContentTypeManager.GetContentType("SCSS")
     });
 }
Ejemplo n.º 11
0
        /// <summary>
        /// 常规栏目
        /// </summary>
        /// <param name="id">栏目ID</param>
        /// <returns></returns>
        public ActionResult ModifyGeneral(int id)
        {
            List <SelectListItem> _contentTypeItems = new List <SelectListItem>()
            {
                new SelectListItem {
                    Text = "无", Value = "0"
                }
            };
            ContentTypeManager _contentTypeManager = new ContentTypeManager();
            var _contentTypes = _contentTypeManager.FindList();

            foreach (var contentType in _contentTypes)
            {
                _contentTypeItems.Add(new SelectListItem()
                {
                    Value = contentType.ID.ToString(), Text = contentType.Name
                });
            }
            ViewBag.ContentTypeItems = _contentTypeItems;
            var _generalManager = new CategoryGeneralManager();
            var _general        = _generalManager.Find(g => g.CategoryID == id);

            if (_general == null)
            {
                _general = new CategoryGeneral()
                {
                    ContentView = "index", View = "index"
                }
            }
            ;
            return(PartialView(_general));
        }
Ejemplo n.º 12
0
        public void TestCreateGetsContentTypes()
        {
            FileInfo targetFile = OpenXml4NetTestDataSamples.GetOutputFile("TestCreatePackageTMP.docx");

            // Zap the target file, in case of an earlier run
            if (File.Exists(targetFile.FullName))
            {
                File.Delete(targetFile.FullName);
                Assert.IsFalse(File.Exists(targetFile.FullName));
            }


            OPCPackage pkg = OPCPackage.Create(targetFile.FullName);

            // Check it has content types for rels and xml
            ContentTypeManager ctm = GetContentTypeManager(pkg);

            Assert.AreEqual(
                "application/xml",
                ctm.GetContentType(
                    PackagingUriHelper.CreatePartName("/foo.xml")
                    )
                );
            Assert.AreEqual(
                ContentTypes.RELATIONSHIPS_PART,
                ctm.GetContentType(
                    PackagingUriHelper.CreatePartName("/foo.rels")
                    )
                );
            Assert.IsNull(
                ctm.GetContentType(
                    PackagingUriHelper.CreatePartName("/foo.txt")
                    )
                );
        }
Ejemplo n.º 13
0
        public void ContentType_FullInstall_InheritedClass_ChangeHandlers2()
        {
            //-- Step 1: Install TestNode10 and TestNode11 content types with TestNode10 and TestNode11 handlers

            string contentTypeADef = @"<?xml version='1.0' encoding='utf-8'?>
							<ContentType name='TestNode10' handler='SenseNet.ContentRepository.Tests.ContentHandlers.TestNode10' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'>
								<Fields>
									<Field name='X' type='Integer' />
								</Fields>
							</ContentType>"                            ;

            string contentTypeBDef = @"<?xml version='1.0' encoding='utf-8'?>
							<ContentType name='TestNode11' parentType='TestNode10' handler='SenseNet.ContentRepository.Tests.ContentHandlers.TestNode11' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'>
								<Fields>
									<Field name='Y' type='Integer' />
								</Fields>
							</ContentType>"                            ;

            ContentTypeInstaller installer = ContentTypeInstaller.CreateBatchContentTypeInstaller();

            installer.AddContentType(contentTypeADef);
            installer.AddContentType(contentTypeBDef);
            installer.ExecuteBatch();

            //-- Step 2: change handler of TestNode10 to unknown in the database directly

            ContentTypeManager.Reset();

            Content content = Content.CreateNew("TestNode10", this.TestRoot, "TestNode10unknown");
        }
Ejemplo n.º 14
0
        private static void CreateContentTypesFromFile(ClientContext context, string filePath)
        {
            var contentTypePersister = new FilePersistanceProvider <List <ShContentType> >(filePath);
            var contentTypeManager   = new ContentTypeManager(context, contentTypePersister.Load());

            contentTypeManager.EnsureContentTypes();
        }
Ejemplo n.º 15
0
        public void TestMixinExpansion()
        {
            var lessFactory = CssParserLocator.FindComponent(ContentTypeManager.GetContentType(LessContentTypeDefinition.LessContentType));
            var lessCode    = @"a {
                                .myMixin(@p) {
                                    b, code {
                                    }
                                }
                            }";

            var lessDoc    = lessFactory.CreateParser().Parse(lessCode, false);
            var lessBlocks = new CssItemAggregator <RuleSet>(true)
            {
                (RuleSet rs) => rs
            }.Crawl(lessDoc).ToList();

            // Remove all but the deepest blocks
            while (0 < lessBlocks.RemoveAll(c => lessBlocks.Any(c.IsParentOf)))
            {
                ;
            }

            var literalExpansions = lessBlocks.SelectMany(rs => LessDocument.GetSelectorNames(rs, LessMixinAction.Literal)).ToList();

            literalExpansions.Should().Equal(new[] { "a .myMixin(@p) b", "a .myMixin(@p) code" });

            var skipExpansions = lessBlocks.SelectMany(rs => LessDocument.GetSelectorNames(rs, LessMixinAction.Skip)).ToList();

            skipExpansions.Should().BeEmpty();

            var nestedExpansions = lessBlocks.SelectMany(rs => LessDocument.GetSelectorNames(rs, LessMixinAction.NestedOnly)).ToList();

            nestedExpansions.Should().Equal(new[] { "«mixin .myMixin» b", "«mixin .myMixin» code" });
        }
Ejemplo n.º 16
0
        private void InitialDataTestPrivate(Action callback, bool withSecurity)
        {
            Cache.Reset();
            ContentTypeManager.Reset();

            var builder = CreateRepositoryBuilderForTest();

            Indexing.IsOuterSearchEngineEnabled = true;

            Cache.Reset();
            ContentTypeManager.Reset();

            using (Repository.Start(builder))
            {
                using (new SystemAccount())
                {
                    if (withSecurity)
                    {
                        SecurityHandler.CreateAclEditor()
                        .Allow(Identifiers.PortalRootId, Identifiers.AdministratorsGroupId, false,
                               PermissionType.BuiltInPermissionTypes)
                        .Allow(Identifiers.PortalRootId, Identifiers.AdministratorUserId, false,
                               PermissionType.BuiltInPermissionTypes)
                        .Apply();
                    }

                    new SnMaintenance().Shutdown();

                    callback();
                }
            }
        }
Ejemplo n.º 17
0
        public string SortScss(string scss)
        {
            ICssParser parser     = CssParserLocator.FindComponent(ContentTypeManager.GetContentType(ScssContentTypeDefinition.ScssContentType)).CreateParser();
            StyleSheet stylesheet = parser.Parse(scss.Trim(), true);

            return(PreprocessorSorting(stylesheet));
        }
    protected void btnUploadFile_Click(object sender, EventArgs e)
    {
        //check if a file is selected
        if (uploadAttachment.HasFile)
        {
            uploadAttachment.SaveAs(Server.MapPath("/UploadedXml/")
            + uploadAttachment.FileName.Split('.')[0]
            + Path.GetExtension(uploadAttachment.FileName));
            XElement document = XElement.Load(Server.MapPath("/UploadedXml/") + uploadAttachment.FileName);
            ContentTypeManager<Holiday> contentTypeManagerHoliday = new ContentTypeManager<Holiday>();
            foreach (var booking in document.Elements())
            {
                Holiday holiday = new Holiday();
                holiday.FirstName = booking.Element("customer").Element("firstname").Value;
                holiday.LastName = booking.Element("customer").Element("lastname").Value;
                holiday.Email = booking.Element("customer").Element("email").Value;
                holiday.Phone = booking.Element("customer").Element("phone").Value;
                holiday.HolidayType = booking.Element("holiday").Element("type").Value;
                holiday.HolidayCountry = booking.Element("holiday").Element("destination").Value;
                holiday.HolidayDate = booking.Element("holiday").Element("date").Value;
                holiday.Comments = booking.Element("holiday").Element("comments").Value;

                ContentType<Holiday> holidayContent = new ContentType<Holiday>();
                holidayContent.Content = new Ektron.Cms.ContentData();
                holidayContent.Content.FolderId = 102;
                holidayContent.Content.Title = booking.Attribute("name").Value;
                holidayContent.SmartForm = holiday;

                contentTypeManagerHoliday.Add(holidayContent);

            }
            litMessage.Text = "Successfully added " + document.Elements().ToArray().Length + " items to the CMS";
        }
    }
Ejemplo n.º 19
0
        internal static void RemoveNodesAndType(string contentTypeName)
        {
            var query = new NodeQuery();
            var nt    = ActiveSchema.NodeTypes[contentTypeName];

            if (nt != null)
            {
                query.Add(new TypeExpression(nt));
                foreach (var nodeId in query.Execute().Identifiers)
                {
                    try
                    {
                        Node.ForceDelete(nodeId);
                    }
                    catch
                    {
                        //suppress the exception that occurs
                        //when node doesn't exist with the given id
                    }
                }
            }
            var ct = ContentType.GetByName(contentTypeName);

            if (ct != null)
            {
                ct.Delete();
                ContentTypeManager.Reset();
            }
        }
        public void ContentType_Inheritance_T2addT4addT1addT2del()
        {
            //  Index   Type  OwnerIndex  ParentIndex
            //  0:      T1	  0			  -
            //  1:      T2	  0           -
            //  2:      T3    0           -
            //  3:      T4    3           0
            //  4:      T5    3           -

            ContentTypeInstaller.InstallContentType(CreateCtd(2, true, true),                //T2+
                                                    CreateCtd(4, true, true),                //T4+
                                                    CreateCtd(1, true, false));              //T1+
            ContentTypeManager.Reset();
            ContentTypeInstaller.InstallContentType(CreateCtd(2, false, false));             //T2-

            FieldSetting[] fields;
            ContentType[]  types = GetTestContentTypes(out fields);

            Assert.IsNotNull(fields[0], "#01");
            Assert.IsNotNull(fields[1], "#02");
            Assert.IsNotNull(fields[2], "#03");
            Assert.IsNotNull(fields[3], "#04");
            Assert.IsNotNull(fields[4], "#05");

            Assert.IsTrue(ReferenceEquals(fields[0].Owner, types[0]), "#10");
            Assert.IsTrue(ReferenceEquals(fields[3].Owner, types[3]), "#11");

            Assert.IsTrue(ReferenceEquals(fields[1], fields[0]), "#20");
            Assert.IsTrue(ReferenceEquals(fields[2], fields[0]), "#21");
            Assert.IsTrue(ReferenceEquals(fields[3].ParentFieldSetting, fields[0]), "#22");
            Assert.IsTrue(ReferenceEquals(fields[4], fields[3]), "#23");
        }
Ejemplo n.º 21
0
 /// <summary>
 /// Default private constructor.
 /// </summary>
 private App()
 {
     fields       = new AppFieldList();
     modules      = new AppModuleList();
     mediaTypes   = new MediaManager();
     serializers  = new SerializerManager();
     contentTypes = new ContentTypeManager();
 }
Ejemplo n.º 22
0
        private static void DeleteContentTypesSpecifiedInFile(ClientContext context, string file)
        {
            Log.Info("Deleting all content types with the same group as the ones in the file " + file);
            var contentTypePersister = new FilePersistanceProvider <List <ShContentType> >(file);
            var contentTypeManager   = new ContentTypeManager(context, contentTypePersister.Load());

            contentTypeManager.DeleteAllCustomContentTypes();
        }
Ejemplo n.º 23
0
        private void AddHtmlFiles()
        {
            var paths       = ProjectHelpers.GetSelectedItemPaths(_dte);
            var contentType = ContentTypeManager.GetContentType("Markdown");
            var compiler    = Mef.GetImport <ICompilerRunnerProvider>(contentType).GetCompiler(contentType);

            Parallel.ForEach(paths, f => compiler.CompileToDefaultOutputAsync(f).DoNotWait("compiling " + f));
        }
Ejemplo n.º 24
0
        private void AddHtmlFiles()
        {
            var paths    = ProjectHelpers.GetSelectedItemPaths(_dte);
            var compiler = WebEditor.ExportProvider.GetExport <ICompilerRunnerProvider>()
                           .Value.GetCompiler(ContentTypeManager.GetContentType("Markdown"));

            Parallel.ForEach(paths, f => compiler.CompileToDefaultOutputAsync(f).DontWait("compiling " + f));
        }
Ejemplo n.º 25
0
        public void ContentType_MorePermissiveLoad_MissingBinding_Create()
        {
            Test(() =>
            {
                var ctd0 = @"<ContentType name=""MyType1"" parentType=""GenericContent"" handler=""SenseNet.ContentRepository.GenericContent"" xmlns=""http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition"">
  <Fields>
    <Field name=""Image2"" type=""Image""></Field>
  </Fields>
</ContentType>";
                var ctd1 = @"<ContentType name=""MyType1"" parentType=""GenericContent"" handler=""SenseNet.ContentRepository.GenericContent"" xmlns=""http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition"">
  <Fields>
    <Field name=""ImageRef"" type=""Reference""></Field>
    <Field name=""ImageData"" type=""Binary""></Field>
    <Field name=""Image2"" type=""Image"">
      <Bind property=""ImageRef"" />
      <Bind property=""ImageData"" />
    </Field>
  </Fields>
</ContentType>";

                // ACTION-1: Try install an invalid CTD.
                try
                {
                    //ContentTypeInstaller.InstallContentType(ctd0);
                    var binaryData      = new BinaryData();
                    binaryData.FileName = "MyType1";
                    binaryData.SetStream(RepositoryTools.GetStreamFromString(ctd0));
                    var contentType = new ContentType(ContentType.GetByName("GenericContent"))
                    {
                        Name   = "MyType1",
                        Binary = binaryData
                    };
                    contentType.Save();

                    Assert.Fail("The expected exception was not thrown.");
                }
                catch (ContentRegistrationException e)
                {
                    // do nothing
                }

                // ACTION-2: reinstall without any problem.
                ContentTypeInstaller.InstallContentType(ctd1);


                // ACTION-3: Reload schema from the database.
                Cache.Reset();
                ContentTypeManager.Reload();

                // ASSERT: the ContentType is loaded and valid.
                var myType1 = ContentType.GetByName("MyType1");
                Assert.AreEqual(ctd1, myType1.ToXml());
                Assert.IsFalse(myType1.IsInvalid);
                Assert.IsNotNull(myType1.FieldSettings.FirstOrDefault(x => x.Name == "Image2"));
            });
        }
Ejemplo n.º 26
0
 private void GetNewsList()
 {
     ContentTypeManager<NewDevTraining.News> newsManager = new ContentTypeManager<NewDevTraining.News>();
     ContentManager cMgr = new ContentManager();
     ContentTaxonomyCriteria criteria = new ContentTaxonomyCriteria();
     criteria.AddFilter(ContentTaxonomyProperty.Id, CriteriaFilterOperator.EqualTo, 91);
     List<ContentType<NewDevTraining.News>> contentDataList = newsManager.GetList(criteria);
     lstNews.DataSource = contentDataList;
     lstNews.DataBind();
 }
Ejemplo n.º 27
0
        internal static SnQueryPredicate GetPathPredicate(string path, bool inTree)
        {
            if (path == null)
            {
                return(null);
            }
            var fieldName = inTree ? IndexFieldName.InTree : IndexFieldName.InFolder;
            var converter = ContentTypeManager.GetPerFieldIndexingInfo(fieldName).IndexFieldHandler;

            return(new SimplePredicate(fieldName, converter.ConvertToTermValue(path)));
        }
Ejemplo n.º 28
0
 /// <summary>
 /// Default private constructor.
 /// </summary>
 private App()
 {
     blocks       = new AppBlockList();
     fields       = new AppFieldList();
     modules      = new AppModuleList();
     mediaTypes   = new MediaManager();
     serializers  = new SerializerManager();
     contentTypes = new ContentTypeManager();
     hooks        = new HookManager();
     permissions  = new PermissionManager();
 }
Ejemplo n.º 29
0
        private Analyzer GetAnalyzer(string fieldName)
        {
            // Hard-code the _Text field
            if (fieldName == "_Text")
            {
                return(_analyzers[typeof(StandardAnalyzer).FullName]);
            }

            // For everything else, ask the ContentTypeManager
            var pfii = ContentTypeManager.GetPerFieldIndexingInfo(fieldName);

            // Return the default analyzer if indexing info was not found.
            if (pfii == null)
            {
                return(_defaultAnalyzer);
            }

            // Get analyzername by IndexFieldHandler
            string analyzerName = pfii.Analyzer;

            if (string.IsNullOrEmpty(analyzerName))
            {
                analyzerName = pfii.IndexFieldHandler.GetDefaultAnalyzerName();
            }

            // Return the default analyzer if it is not specified any way.
            if (string.IsNullOrEmpty(analyzerName))
            {
                return(_defaultAnalyzer);
            }

            Analyzer analyzer;

            if (_analyzers.TryGetValue(analyzerName, out analyzer))
            {
                return(analyzer);
            }

            // Find the type
            var analyzerType = TypeHandler.GetType(analyzerName);

            // If it doesn't exist, return the default analyzer
            if (analyzerType == null)
            {
                return(_defaultAnalyzer);
            }

            // Store the instance in cache
            analyzer = (Analyzer)Activator.CreateInstance(analyzerType);
            _analyzers[analyzerName] = analyzer;

            // Return analyzer
            return(analyzer);
        }
Ejemplo n.º 30
0
        private static void SetContentHandlerAndResetManagers(string handlerName, Action action)
        {
            // set the handler of the Folder type to an unknown value
            SetContentHandler("Folder", handlerName);

            Cache.Reset();
            NodeTypeManager.Restart();
            ContentTypeManager.Reload();

            action();
        }
Ejemplo n.º 31
0
 /// <summary>
 /// Default private constructor.
 /// </summary>
 private App()
 {
     _blocks       = new AppBlockList();
     _fields       = new AppFieldList();
     _modules      = new AppModuleList();
     _mediaTypes   = new MediaManager();
     _serializers  = new SerializerManager();
     _contentTypes = new ContentTypeManager();
     _hooks        = new HookManager();
     _permissions  = new PermissionManager();
 }
Ejemplo n.º 32
0
 public void UnknownHandler_GetNameByType()
 {
     Test(() =>
     {
         SetContentHandlerAndResetManagers("UnknownGetNameByType", () =>
         {
             // This should not throw an exception. The returned type is irrelevant:
             // it will be one of the descendants of the Folder content type.
             var _ = ContentTypeManager.GetContentTypeNameByType(typeof(Folder));
         });
     });
 }
    private void FillCarousel(long carouselContentId)
    {
        ContentTypeManager<Carousel> carouselManager = new ContentTypeManager<Carousel>();
        ContentType<Carousel> carouselItem = carouselManager.GetItem(carouselContentId, false);
        if (carouselItem != null) {
            lstThumbnailIcon.DataSource = carouselItem.SmartForm.CarouselItem;
            lstThumbnailIcon.DataBind();

            lstSliderFigure.DataSource = carouselItem.SmartForm.CarouselItem;
            lstSliderFigure.DataBind();
        }
    }
Ejemplo n.º 34
0
 private void ProvisionContentTypes(AppManifestBase manifest)
 {
     if (manifest.ContentTypeCreators != null && manifest.ContentTypeCreators.Count > 0)
     {
         var cm = new ContentTypeManager {
             Creators = manifest.ContentTypeCreators
         };
         cm.Notify += Provisioner_Notify;
         //ContentTypes should always be provisioned into the root or app web
         cm.CreateAll(_ctx);
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (ContentId != 0)
     {
         ContentTypeManager<NewDevTraining.News> newsManager = new ContentTypeManager<News>();
         ContentType<News> newsContent = newsManager.GetItem(ContentId, false);
         if (newsContent != null)
         {
             NewsTitle = newsContent.SmartForm.Title;
             NewsDate = newsContent.SmartForm.Date;
             NewsBodyText = newsContent.SmartForm.FullDescription.ToString();
         }
     }
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (ContentId != 0)
        {
            ContentTypeManager<HolidayOffers> offerManager = new ContentTypeManager<HolidayOffers>();
            ContentType<HolidayOffers> holidayContent = offerManager.GetItem(ContentId, false);

            if (holidayContent != null)
            {
                Title = holidayContent.SmartForm.Title;
                Date = holidayContent.Content.DateCreated.ToLongDateString();
                BodyText = holidayContent.SmartForm.BodyText.ToString();
                ImgSource = holidayContent.SmartForm.ImgSource;
            }
        }
    }
    private void GetHolidayList()
    {
        ContentTypeManager<HolidayOffers> holidayOfferManager = new ContentTypeManager<HolidayOffers>();
        string folderid = Resources.ID.HolidayOfferFolderId;
        long holidayFolderId = 0;
        bool isFolderId = long.TryParse(folderid, out holidayFolderId);
        if (isFolderId)
        {
            ContentCriteria criteria = new ContentCriteria();
            criteria.AddFilter(ContentProperty.FolderId, CriteriaFilterOperator.EqualTo, holidayFolderId);

            List<ContentType<HolidayOffers>> holidayOffers = holidayOfferManager.GetList(criteria);
            lstOffers.DataSource = holidayOffers;
            lstOffers.DataBind();
        }
    }
Ejemplo n.º 38
0
        public void Can_Query_Detail()
        {
            IAssemblyFinder assemblyFinder = new AssemblyFinder();
            ITypeFinder typeFinder = new TypeFinder(assemblyFinder);
            IContentTypeBuilder contentTypeBuilder = new ContentTypeBuilder(typeFinder, null, null, null, null, null);
            IItemNotifier itemNotifier = new ItemNotifier();
            IContentTypeManager contentTypeManager = new ContentTypeManager(contentTypeBuilder, itemNotifier);
            IConfigurationBuilder configurationBuilder = new ConfigurationBuilder(contentTypeManager, ConfigurationManager.GetSection("zeus/database") as DatabaseSection);
            ISessionProvider sessionProvider = new SessionProvider(configurationBuilder, new NotifyingInterceptor(new ItemNotifier()), new ThreadContext());

            /*var results = itemFinder.Find<NewsContainer>(
                //ci => ci.Details.Values.OfType<StringDetail>().Any(cd => cd.Name == "Text" && cd.StringValue == "sdfds")
                //ci => ci.Details.OfType<StringDetail>().Where(cd => cd.Name == "DetailName").SingleOrDefault().StringValue == "Hello"
                ci => ci.Text == "sdfds" //&& ci.MyProperty.StartsWith("Hell")
            );
            Assert.GreaterThanOrEqualTo(Enumerable.Count(results), 1);*/
        }
    public void btnBookHoliday_Click(object sender, EventArgs e)
    {
        Page.Validate();
        Holiday holiday = new Holiday();
        holiday.FirstName = txtFirstName.Text;
        holiday.LastName = txtLastName.Text;
        holiday.Email = txtEmail.Text;
        holiday.Phone = txtPhone.Text;
        holiday.HolidayType = RadioHolidayType.SelectedValue;
        holiday.HolidayCountry = ddlCountries.SelectedValue;
        holiday.HolidayDate = clndrHolidayDate.SelectedDate.ToString();
        holiday.Comments = tbComments.Text;

        ContentTypeManager<Holiday> contentTypeManager = new ContentTypeManager<Holiday>();
        ContentType<Holiday> newHoliday = new ContentType<Holiday>();
        newHoliday.Content = new ContentData();
        newHoliday.Content.FolderId = 102;
        newHoliday.Content.Title = holiday.FirstName + "-" + holiday.HolidayCountry + "-" + holiday.HolidayDate;
        newHoliday.SmartForm = holiday;
        // adds content to the CMS
        contentTypeManager.Add(newHoliday);
        Response.Redirect("/Source/Wireframes/Pagination.aspx");
    }