![]() |
Xataface 2.0
Xataface Application Framework
|
00001 <?php 00014 class Dataface_Ontology_Person extends Dataface_Ontology { 00015 function buildAttributes(){ 00016 $this->fieldnames = array(); 00017 $this->attributes = array(); 00018 00019 $email = null; 00020 // First let's find the email field. 00021 00022 // First we'll check to see if any fields have been explicitly 00023 // flagged as email address fields. 00024 foreach ( $this->table->fields(false,true) as $field ){ 00025 if ( @$field['email'] ){ 00026 $email = $field['name']; 00027 break; 00028 } 00029 } 00030 if ( !isset($email) ){ 00031 // Next lets see if any of the fields actually contain the word 00032 // email in the name 00033 $candidates = preg_grep('/(email)/i', array_keys($this->table->fields())); 00034 foreach ( $candidates as $candidate ){ 00035 if ( $this->table->isChar($candidate) ){ 00036 $email = $candidate; 00037 break; 00038 } 00039 } 00040 } 00041 00042 if ( isset($email) ){ 00043 $field =& $this->table->getField($email); 00044 $this->attributes['email'] =& $field; 00045 unset($field); 00046 $this->fieldnames['email'] = $email; 00047 } 00048 00049 return true; 00050 00051 } 00052 00053 function validate_email($value, $allowBlanks=true){ 00054 if ( !$allowBlanks and !trim($value) ) return false; 00055 00056 return preg_match('/^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i', $value); 00057 } 00058 00059 }