public Property(int Id, propertytype.PropertyType pt) { _pt = pt; _id = Id; _data = _pt.DataTypeDefinition.DataType.Data; _data.PropertyId = Id; }
/// <summary> /// Get an true/false if the given data defined in the propertytype, should be visible on the members profile page /// </summary> /// <param name="pt">Propertytype</param> /// <returns>True if the data should be displayed on the profilepage</returns> public bool ViewOnProfile(PropertyType pt) { if(propertyTypeRegistered(pt)) { return Convert.ToBoolean(SqlHelper.ExecuteScalar<object>("Select viewOnProfile from cmsMemberType where NodeId = " + this.Id + " And propertytypeId = " + pt.Id)); } return false; }
public static interfaces.IUseTags UseTags(PropertyType categoryType) { if (typeof(interfaces.IUseTags).IsAssignableFrom(categoryType.DataTypeDefinition.DataType.DataEditor.GetType())) { interfaces.IUseTags tags = (interfaces.IUseTags)categoryType.DataTypeDefinition.DataType.DataEditor as interfaces.IUseTags; return tags; } return null; }
public Property(int Id) { _id = Id; _pt = PropertyType.GetPropertyType( SqlHelper.ExecuteScalar<int>("select propertytypeid from cmsPropertyData where id = @id", SqlHelper.CreateParameter("@id", Id))); _data = _pt.DataTypeDefinition.DataType.Data; _data.PropertyId = Id; }
/// <summary> /// Get an true/false if the Member can edit the given data defined in the propertytype /// </summary> /// <param name="pt">Propertytype to edit</param> /// <returns>True if the Member can edit the data</returns> public bool MemberCanEdit(PropertyType pt) { if (propertyTypeRegistered(pt)) { var memberCanEdit = SqlHelper.ExecuteScalar<object>("Select memberCanEdit from cmsMemberType where NodeId = " + this.Id + " And propertytypeId = " + pt.Id); return (Convert.ToBoolean(memberCanEdit)); } return false; }
/// <summary> /// Set if the member should be able to edit the data defined by its propertytype /// </summary> /// <param name="pt">PropertyType</param> /// <param name="value">True/False if Members of the type shoúld be able to edit the data</param> public void setMemberCanEdit(PropertyType pt, bool value) { int tmpval = 0; if (value) tmpval = 1; if (propertyTypeRegistered(pt)) SqlHelper.ExecuteNonQuery("Update cmsMemberType set memberCanEdit = " + tmpval + " where NodeId = " + this.Id + " And propertytypeId = " + pt.Id); else SqlHelper.ExecuteNonQuery("insert into cmsMemberType (NodeId, propertytypeid, memberCanEdit,viewOnProfile) values (" + this.Id + "," + pt.Id + ", " + tmpval + ",0)"); }
internal Property(Umbraco.Core.Models.Property property) { _id = property.Id; _property = property; _propertyType = property.PropertyType; //Just to ensure that there is a PropertyType available _pt = PropertyType.GetPropertyType(property.PropertyTypeId); _data = _pt.DataTypeDefinition.DataType.Data; _data.PropertyId = Id; }
/// <summary> /// Retrieve a Property given the alias /// </summary> /// <param name="alias">Propertyalias (defined in the documenttype)</param> /// <returns>The property with the given alias</returns> public Property getProperty(string alias) { ContentType ct = this.ContentType; if (ct == null) { return(null); } propertytype.PropertyType pt = ct.getPropertyType(alias); if (pt == null) { return(null); } return(getProperty(pt)); }
internal Property(Umbraco.Core.Models.Property property) { _id = property.Id; _property = property; _propertyType = property.PropertyType; //Just to ensure that there is a PropertyType available _pt = PropertyType.GetPropertyType(property.PropertyTypeId); _data = _pt.DataTypeDefinition.DataType.Data; _data.PropertyId = Id; //set the value so it doesn't need to go to the database var dvs = _data as IDataValueSetter; if (dvs != null) { dvs.SetValue(property.Value, property.PropertyType.DataTypeDatabaseType.ToString()); } }
public void removePropertyTypeFromTab(PropertyType pt) { pt.TabId = 0; //this will set to null in the database. if (ContentTypeItem != null) { ContentTypeItem.RemovePropertyType(pt.Alias); } // Remove from cache FlushFromCache(Id); }
public void SetTabOnPropertyType(PropertyType pt, int TabId) { // This is essentially just a wrapper for the property pt.TabId = TabId; //flush the content type cache, the the tab cache (why so much cache?! argh!) pt.FlushCacheBasedOnTab(); }
/// <summary> /// Helper method for getting the Tab id from a given PropertyType /// </summary> /// <param name="pt">The PropertyType from which to get the Tab Id</param> /// <returns>The Id of the Tab on which the PropertyType is placed</returns> public static int getTabIdFromPropertyType(PropertyType pt) { object tmp = SqlHelper.ExecuteScalar<object>("Select propertyTypeGroupId from cmsPropertyType where id = " + pt.Id.ToString()); if (tmp == DBNull.Value) return 0; return int.Parse(tmp.ToString()); }
private static void SetPropertyTypeMandatoryIfDifferent(PropertyType propertyType, bool mandatory) { if (propertyType.Mandatory == mandatory) return; propertyType.Mandatory = mandatory; }
private bool propertyTypeRegistered(PropertyType pt) { return (SqlHelper.ExecuteScalar<int>("Select count(pk) as tmp from cmsMemberType where NodeId = " + this.Id + " And propertytypeId = " + pt.Id) > 0); }
/// <summary> /// Removing a PropertyType from the associated Tab /// </summary> /// <param name="pt">The PropertyType which should be freed from its tab</param> public void removePropertyTypeFromTab(PropertyType pt) { pt.TabId = 0; //this will set to null in the database. // Remove from cache FlushFromCache(Id); }
private PropertyTypeItem BuildPropertyTypeItem(PropertyType propertyType) { var propertyTypeItem = new PropertyTypeItem(); propertyTypeItem.Alias = propertyType.Alias; propertyTypeItem.Description = propertyType.Description; propertyTypeItem.Id = propertyType.Id; propertyTypeItem.Name = propertyType.Name; propertyTypeItem.TypeId = GetDataTypeDefinitionId(propertyType); return propertyTypeItem; }
private static void UpdateExistingProperty(PropertyType propertyType, DocumentTypePropertyAttribute propertyAttribute, ContentType documentType) { SetPropertyTypeNameIfDifferent(propertyType, propertyAttribute.Name); SetPropertyTypeDescriptionIfDifferent(propertyType, propertyAttribute.Description); SetPropertyTypeMandatoryIfDifferent(propertyType, propertyAttribute.Mandatory); SetPropertyTypeValidationExpressionIfDifferent(propertyType, propertyAttribute.ValidationExpression); SetPropertyTypeSortOrderIfDifferent(propertyType, propertyAttribute.SortOrder); SetPropertyTypeTabIfDifferent(documentType, propertyType, propertyAttribute.Tab); }
private static void SetPropertyTypeValidationExpressionIfDifferent(PropertyType propertyType, string validationExpression) { if (propertyType.ValidationRegExp == validationExpression) return; propertyType.ValidationRegExp = validationExpression ?? String.Empty; }
private static void SetPropertyTypeTabIfDifferent(ContentType documentType, PropertyType propertyType, Type tab) { var propertyTabId = EnsureTab(documentType, tab); if (propertyType.TabId == propertyTabId) return; propertyType.TabId = propertyTabId; }
private static void SetPropertyTypeSortOrderIfDifferent(PropertyType propertyType, int sortOrder) { if (propertyType.SortOrder == sortOrder) return; propertyType.SortOrder = sortOrder; }
private static void SetPropertyTypeNameIfDifferent(PropertyType propertyType, string name) { if (propertyType.Name == name) return; propertyType.Name = name; }
private static EmbeddableBase GetEmbeddable(PropertyType propertyType) { var embeddablePreValueEditor = propertyType.DataTypeDefinition.DataType.PrevalueEditor; if (embeddablePreValueEditor is PrevalueEditor) { var embeddableOptions = ((PrevalueEditor)embeddablePreValueEditor).GetPreValueOptions<Options>(); var embeddableType = embeddableOptions.Type; var embeddableObject = Activator.CreateInstance(Type.GetType(embeddableType)) as EmbeddableBase; return embeddableObject; } return null; }
/// <summary> /// Retrieve a property given the propertytype /// </summary> /// <param name="pt">PropertyType</param> /// <returns>The property with the given propertytype</returns> public Property getProperty(PropertyType pt) { //object o = SqlHelper.ExecuteScalar<object>( // "select id from cmsPropertyData where versionId=@version and propertyTypeId=@propertyTypeId", // SqlHelper.CreateParameter("@version", this.Version), // SqlHelper.CreateParameter("@propertyTypeId", pt.Id)); //if (o == null) // return null; //int propertyId; //if (!int.TryParse(o.ToString(), out propertyId)) // return null; //try //{ // return new Property(propertyId, pt); //} //catch (Exception ex) //{ // Log.Add(LogTypes.Error, this.Id, "An error occurred retreiving property. EXCEPTION: " + ex.Message); // return null; //} EnsureProperties(); var prop = m_LoadedProperties .Where(x => x.PropertyType.Id == pt.Id) .SingleOrDefault(); return prop; }
private void populateMasterContentTypes(PropertyType pt, int docTypeId) { foreach (web.DocumentType docType in web.DocumentType.GetAllAsList()) { if (docType.MasterContentType == docTypeId) { populatePropertyData(pt, docType.Id); populateMasterContentTypes(pt, docType.Id); } } }
public IEnumerable <PropertyType> GetPropertyTypes() { return(PropertyType.GetPropertyTypesByGroup(Id)); }
public void DataTypeDefinition_Assign_Data_Type_To_Doc_Type_Then_Create_Doc_And_Set_Value() { //create datatype definition, assign data type var dtd = DataTypeDefinition.MakeNew(m_User, "TEST" + Guid.NewGuid().ToString("N")); Assert.IsTrue(dtd.Id > 0); Assert.IsInstanceOfType(dtd, typeof(DataTypeDefinition)); IDataType dt = new TextFieldDataType(); dtd.DataType = dt; Assert.AreEqual(dt.Id, dtd.DataType.Id); Assert.IsInstanceOfType(dtd.DataType, dt.GetType()); //create new doc type var docType = DocumentType.MakeNew(m_User, "TEST" + Guid.NewGuid().ToString("N")); //create the property with this new data type definition var alias = "TEST" + Guid.NewGuid().ToString("N"); docType.AddPropertyType(dtd, alias, alias); Assert.AreEqual<int>(1, docType.PropertyTypes.Count()); //create a new doc with the new doc type var doc = Document.MakeNew("TEST" + Guid.NewGuid().ToString("N"), docType, m_User, -1); //set the value of the property var prop = doc.getProperty(alias); var propType = prop.PropertyType; Assert.IsNotNull(prop); var val = "TEST" + Guid.NewGuid().ToString("N"); prop.Value = val; Assert.AreEqual(val, prop.Value); //ok, now that all of the data is setup, we'll just delete the data type definition. dtd.delete(); //make sure the property value is gone, check with sql Assert.AreEqual<int>(0, Application.SqlHelper.ExecuteScalar<int>( "SELECT COUNT(id) FROM cmsPropertyData WHERE propertytypeid=@propTypeId", Application.SqlHelper.CreateParameter("@propTypeId", propType.Id))); //make sure the property type is gone var hasError = false; try { var confirmPropType = new PropertyType(propType.Id); } catch (ArgumentException) { hasError = true; } Assert.IsTrue(hasError); //make sure the dtd is gone Assert.IsFalse(DataTypeDefinition.IsNode(dtd.Id)); //now cleanup the rest doc.delete(true); Assert.IsFalse(Document.IsNode(doc.Id)); docType.delete(); Assert.IsFalse(DocumentType.IsNode(docType.Id)); }
private static void PopulatePropertyData(PropertyType pt, int contentTypeId) { // NH: PropertyTypeId inserted directly into SQL instead of as a parameter for SQL CE 4 compatibility SqlHelper.ExecuteNonQuery( "insert into cmsPropertyData (contentNodeId, versionId, propertyTypeId) select contentId, versionId, " + pt.Id + " from cmsContent inner join cmsContentVersion on cmsContent.nodeId = cmsContentVersion.contentId where contentType = @contentTypeId", SqlHelper.CreateParameter("@contentTypeId", contentTypeId)); }
private int GetDataTypeDefinitionId(PropertyType propertyType) { int typeId = DataTypeHelper.GetValueTypeId(propertyType.Alias); if (typeId != 0) return typeId; return propertyType.DataTypeDefinition.Id; }
private static void SetPropertyTypeDescriptionIfDifferent(PropertyType propertyType, string description) { if (propertyType.Description == description) return; propertyType.Description = description ?? String.Empty; }
public static PropertyType MakeNew(DataTypeDefinition dt, ContentType ct, string name, string alias) { //make sure that the alias starts with a letter if (string.IsNullOrEmpty(alias)) throw new ArgumentNullException("alias"); if (string.IsNullOrEmpty(name)) throw new ArgumentNullException("name"); if (!Char.IsLetter(alias[0])) throw new ArgumentException("alias must start with a letter", "alias"); PropertyType pt; try { // The method is synchronized, but we'll still look it up with an additional parameter (alias) SqlHelper.ExecuteNonQuery( "INSERT INTO cmsPropertyType (DataTypeId, ContentTypeId, alias, name) VALUES (@DataTypeId, @ContentTypeId, @alias, @name)", SqlHelper.CreateParameter("@DataTypeId", dt.Id), SqlHelper.CreateParameter("@ContentTypeId", ct.Id), SqlHelper.CreateParameter("@alias", alias), SqlHelper.CreateParameter("@name", name)); pt = new PropertyType( SqlHelper.ExecuteScalar<int>("SELECT MAX(id) FROM cmsPropertyType WHERE alias=@alias", SqlHelper.CreateParameter("@alias", alias))); } finally { // Clear cached items Cache.ClearCacheByKeySearch(UmbracoPropertyTypeCacheKey); } return pt; }
private static void PopulateMasterContentTypes(PropertyType pt, int docTypeId) { foreach (var docType in DocumentType.GetAllAsList()) { //TODO: Check for multiple references (mixins) not causing endless loops! if (docType.MasterContentTypes.Contains(docTypeId)) { PopulatePropertyData(pt, docType.Id); PopulateMasterContentTypes(pt, docType.Id); } } }
/// <summary> /// Add a property to the Content /// </summary> /// <param name="pt">The PropertyType of the Property</param> /// <param name="versionId">The version of the document on which the property should be add'ed</param> /// <returns>The new Property</returns> public Property addProperty(PropertyType pt, Guid versionId) { ClearLoadedProperties(); return property.Property.MakeNew(pt, this, versionId); }
public IEnumerable <PropertyType> GetPropertyTypes(List <int> contentTypeIds) { return(PropertyType.GetPropertyTypesByGroup(Id, contentTypeIds)); }