Example #1
0
 /// <summary>
 /// 
 /// </summary>
 /// <param Name="ct"></param>
 /// <returns></returns>
 private static bool usesUmbracoDataOnly(ContentType ct)
 {
     bool retVal = true;
     foreach (PropertyType pt in ct.PropertyTypes)
     {
         if (!DataTypeDefinition.IsDefaultData(pt.DataTypeDefinition.DataType.Data))
         {
             retVal = false;
             break;
         }
     }
     return retVal;
 }
Example #2
0
        protected void AnalyzeContentTypes(Guid ObjectType, bool ForceUpdate)
        {
            if (!_analyzedContentTypes.ContainsKey(ObjectType) || ForceUpdate)
            {
                using (SqlDataReader dr = Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteReader(_ConnString, CommandType.Text,
                                                                  "select id from umbracoNode where nodeObjectType = @objectType",
                                                                  new SqlParameter("@objectType", ObjectType)))
                {
                    while (dr.Read())
                    {
                        ContentType ct = new ContentType(dr.GetInt32(0));
                        if (!_optimziedContentTypes.ContainsKey(ct.UniqueId))
                            _optimziedContentTypes.Add(ct.UniqueId, false);

                        _optimziedContentTypes[ct.UniqueId] = usesUmbracoDataOnly(ct);
                    }
                }
            }
        }
Example #3
0
            /// <summary>
            /// 
            /// </summary>
            /// <param Name="id"></param>
            /// <param Name="caption"></param>
            /// <param Name="cType"></param>
            public Tab(int id, string caption, ContentType cType)
            {
                _id = id;
                _caption = caption;
                _contenttype = cType;

                string cacheKey = CacheKey + _id;
                _propertytypes =
                    Cache.GetCacheItem<PropertyType[]>(cacheKey, propertyTypesCacheSyncLock, TimeSpan.FromMinutes(10),
                                                       delegate
                                                           {
                                                               List<PropertyType> tmp = new List<PropertyType>();

                                                               using (
                                                                   SqlDataReader dr =
                                                                       Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteReader(_ConnString,
                                                                                               CommandType.Text,
                                                                                               string.Format(
                                                                                                   "Select id from cmsPropertyType where tabid = {0} order by sortOrder",
                                                                                                   _id)))
                                                               {
                                                                   while (dr.Read())
                                                                   {
                                                                       tmp.Add(
                                                                           PropertyType.GetPropertyType(
                                                                               int.Parse(dr["id"].ToString())));
                                                                   }
                                                               }
                                                               return tmp.ToArray();
                                                           });
            }
Example #4
0
 public static ContentType GetContentType(int id)
 {
     if (HttpRuntime.Cache[string.Format("UmbracoContentType{0}", id.ToString())] == null)
     {
         ContentType ct = new ContentType(id);
         HttpRuntime.Cache.Insert(string.Format("UmbracoContentType{0}", id.ToString()), ct);
     }
     return (ContentType) HttpRuntime.Cache[string.Format("UmbracoContentType{0}", id.ToString())];
 }
Example #5
0
        /// <summary>
        /// Retrieve a list of all ContentTypes
        /// </summary>
        /// <returns>The list of all ContentTypes</returns>
        public ContentType[] GetAll()
        {
            // Fetch contenttypes current objectType
            Guid[] Ids = getAllUniquesFromObjectType(base.nodeObjectType);
            SortedList initRetVal = new SortedList();
            for (int i = 0; i < Ids.Length; i++)
            {
                ContentType dt = new ContentType(Ids[i]);
                initRetVal.Add(dt.Text + dt.UniqueId, dt);
            }

            ContentType[] retVal = new ContentType[Ids.Length];

            IDictionaryEnumerator ide = initRetVal.GetEnumerator();

            int count = 0;
            while (ide.MoveNext())
            {
                retVal[count] = (ContentType) ide.Value;
                count++;
            }

            return retVal;
        }