ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilFullnameParser Class Reference
+ Collaboration diagram for ilFullnameParser:

Public Member Functions

 __construct ($initString="")
 Constructor: Setup the object, initialise the variables, and if instantiated with a name - parse it automagically.
 __destruct ()
 Destructor public.
 getFirstName ()
 Access Method public.
 getMiddleName ()
 Access Method public.
 getLastName ()
 Access Method public.
 getTitle ()
 Access Method public.
 getSuffix ()
 Access Method public.
 getNotParseable ()
 Access Method public.
 setFullName ($newFullName)
 Mutator Method public.
 parse ()
 Extract the elements of the full name into separate parts.

Private Member Functions

 inArrayNorm ($needle, $haystack)
 Determine if the needle is in the haystack.

Private Attributes

 $titles
 $prefices
 $suffices
 $title
 $first
 $middle
 $last
 $suffix
 $fullName
 $notParseable

Detailed Description

Definition at line 11 of file class.ilFullnameParser.php.

Constructor & Destructor Documentation

ilFullnameParser::__construct (   $initString = "")

Constructor: Setup the object, initialise the variables, and if instantiated with a name - parse it automagically.

Parameters
stringThe Name String public

Definition at line 82 of file class.ilFullnameParser.php.

References parse().

{
$this->title = "";
$this->first = "";
$this->middle = "";
$this->last = "";
$this->suffix = "";
//$this->titles = array('dr','doctor','miss','misses','mr','mister','mrs','ms','judge','sir','madam','madame');
// added Military Titles
$this->titles = array('dr','doctor','miss','misses','mr','mister','mrs','ms','judge','sir','madam','madame','AB','2ndLt','Amn','1stLt','A1C','Capt','SrA','Maj','SSgt','LtCol','TSgt','Col','BrigGen','1stSgt','MajGen','SMSgt','LtGen','1stSgt','Gen','CMSgt','1stSgt','CCMSgt','CMSAF','PVT','2LT','PV2','1LT','PFC','CPT','SPC','MAJ','CPL','LTC','SGT','COL','SSG','BG','SFC','MG','MSG','LTG','1SGT','GEN','SGM','CSM','SMA','WO1','WO2','WO3','WO4','WO5','ENS','SA','LTJG','SN','LT','PO3','LCDR','PO2','CDR','PO1','CAPT','CPO','RADM(LH)','SCPO','RADM(UH)','MCPO','VADM','MCPOC','ADM','MPCO-CG','CWO-2','CWO-3','CWO-4','Pvt','2ndLt','PFC','1stLt','LCpl','Capt','Cpl','Maj','Sgt','LtCol','SSgt','Col','GySgt','BGen','MSgt','MajGen','1stSgt','LtGen','MGySgt','Gen','SgtMaj','SgtMajMC','WO-1','CWO-2','CWO-3','CWO-4','CWO-5','ENS','SA','LTJG','SN','LT','PO3','LCDR','PO2','CDR','PO1','CAPT','CPO','RDML','SCPO','RADM','MCPO','VADM','MCPON','ADM','FADM','WO1','CWO2','CWO3','CWO4','CWO5');
$this->prefices = array('bon','ben','bin','da','dal','de','del','der','de','e','la','le','san','st','ste','van','vel','von');
$this->suffices = array('esq','esquire','jr','sr','2','i','ii','iii','iv','v','clu','chfc','cfp','md','phd');
$this->fullName = "";
$this->notParseable = FALSE;
// if initialized by value, set class variable and then parse
if ( $initString != "" ) {
$this->fullName = $initString;
$this->parse();
}
}

+ Here is the call graph for this function:

ilFullnameParser::__destruct ( )

Destructor public.

Definition at line 111 of file class.ilFullnameParser.php.

{}

Member Function Documentation

ilFullnameParser::getFirstName ( )

Access Method public.

Definition at line 119 of file class.ilFullnameParser.php.

References $first.

{ return $this->first; }
ilFullnameParser::getLastName ( )

Access Method public.

Definition at line 135 of file class.ilFullnameParser.php.

References $last.

{ return $this->last; }
ilFullnameParser::getMiddleName ( )

Access Method public.

Definition at line 127 of file class.ilFullnameParser.php.

References $middle.

{ return $this->middle; }
ilFullnameParser::getNotParseable ( )

Access Method public.

Definition at line 159 of file class.ilFullnameParser.php.

References $notParseable.

ilFullnameParser::getSuffix ( )

Access Method public.

Definition at line 151 of file class.ilFullnameParser.php.

References $suffix.

{ return $this->suffix; }
ilFullnameParser::getTitle ( )

Access Method public.

Definition at line 143 of file class.ilFullnameParser.php.

References $title.

{ return $this->title; }
ilFullnameParser::inArrayNorm (   $needle,
  $haystack 
)
private

Determine if the needle is in the haystack.

Parameters
needlethe needle to look for
haystackthe haystack from which to look into private

Definition at line 179 of file class.ilFullnameParser.php.

Referenced by parse().

{
$needle = trim( strtolower( str_replace( '.', '', $needle ) ) );
return in_array( $needle, $haystack );
}

+ Here is the caller graph for this function:

ilFullnameParser::parse ( )

Extract the elements of the full name into separate parts.

public

Definition at line 191 of file class.ilFullnameParser.php.

References inArrayNorm().

Referenced by __construct().

{
// reset values
$this->title = "";
$this->first = "";
$this->middle = "";
$this->last = "";
$this->suffix = "";
$this->notParseable = FALSE;
// break up name based on number of commas
$pieces = explode( ',', preg_replace('/\s+/', ' ', trim( $this->fullName ) ) );
$numPieces = count( $pieces );
switch ( $numPieces ) {
// array(title first middle last suffix)
case 1:
$subPieces = explode(' ', trim( $pieces[0] ) );
$numSubPieces = count( $subPieces );
for ( $i = 0; $i < $numSubPieces; $i++ ) {
$current = trim( $subPieces[$i] );
if ( $i < ($numSubPieces-1) ) {
$next = trim( $subPieces[$i+1] );
} else {
$next = "";
}
if ( $i == 0 && $this->inArrayNorm( $current, $this->titles ) ) {
$this->title = $current;
continue;
}
if ( $this->first == "" ) {
$this->first = $current;
continue;
}
if ( $i == $numSubPieces-2 && ($next != "") && $this->inArrayNorm( $next, $this->suffices ) ) {
if ( $this->last != "") {
$this->last .= " ".$current;
} else {
$this->last = $current;
}
$this->suffix = $next;
break;
}
if ( $i == $numSubPieces-1 ) {
if ( $this->last != "" ) {
$this->last .= " ".$current;
} else {
$this->last = $current;
}
continue;
}
if ( $this->inArrayNorm( $current, $this->prefices ) ) {
if ( $this->last != "" ) {
$this->last .= " ".$current;
} else {
$this->last = $current;
}
continue;
}
if ( $next == 'y' || $next == 'Y' ) {
if ( $this->last != "" ) {
$this->last .= " ".$current;
} else {
$this->last = $current;
}
continue;
}
if ( $this->last != "" ) {
$this->last .= " ".$current;
continue;
}
if( $this->middle != "" ) {
$this->middle .= " ".$current;
} else {
$this->middle = $current;
}
}
break;
default:
switch( $this->inArrayNorm( $pieces[1], $this->suffices ) ) {
// array(title first middle last, suffix [, suffix])
case TRUE:
$subPieces = explode(' ', trim( $pieces[0] ) );
$numSubPieces = count( $subPieces );
for ( $i = 0; $i < $numSubPieces; $i++ ) {
$current = trim( $subPieces[$i] );
if ( $i < ($numSubPieces-1) ) {
$next = trim( $subPieces[$i+1] );
} else {
$next = "";
}
if ( $i == 0 && $this->inArrayNorm( $current, $this->titles ) ) {
$this->title = $current;
continue;
}
if ( $this->first == "" ) {
$this->first = $current;
continue;
}
if ( $i == $numSubPieces-1 ) {
if ( $this->last != "" ) {
$this->last .= " ".$current;
} else {
$this->last = $current;
}
continue;
}
if ( $this->inArrayNorm( $current, $this->prefices ) ) {
if ( $this->last != "" ) {
$this->last .= " ".$current;
} else {
$this->last = $current;
}
continue;
}
if ( $next == 'y' || $next == 'Y' ) {
if ( $this->last != "" ) {
$this->last .= " ".$current;
} else {
$this->last = $current;
}
continue;
}
if ( $this->last != "" ) {
$this->last .= " ".$current;
continue;
}
if ( $this->middle != "" ) {
$this->middle .= " ".$current;
} else {
$this->middle = $current;
}
}
$this->suffix = trim($pieces[1]);
for ( $i = 2; $i < $numPieces; $i++ ) {
$this->suffix .= ", ". trim( $pieces[$i] );
}
break;
// array(last, title first middles[,] suffix [,suffix])
case FALSE:
$subPieces = explode( ' ', trim( $pieces[1] ) );
$numSubPieces = count( $subPieces );
for ( $i = 0; $i < $numSubPieces; $i++ ) {
$current = trim( $subPieces[$i] );
if ( $i < ($numSubPieces-1) ) {
$next = trim( $subPieces[$i+1] );
} else {
$next = "";
}
if ( $i == 0 && $this->inArrayNorm( $current, $this->titles ) ) {
$this->title = $current;
continue;
}
if ( $this->first == "" ) {
$this->first = $current;
continue;
}
if ( $i == $numSubPieces-2 && ($next != "") && $this->inArrayNorm( $next, $this->suffices ) ) {
if ( $this->middle != "" ) {
$this->middle .= " ".$current;
} else {
$this->middle = $current;
}
$this->suffix = $next;
break;
}
if ( $i == $numSubPieces-1 && $this->inArrayNorm( $current, $this->suffices ) ) {
$this->suffix = $current;
continue;
}
if ( $this->middle != "" ) {
$this->middle .= " ".$current;
} else {
$this->middle = $current;
}
}
if( isset($pieces[2]) && $pieces[2] ) {
if ( $this->last == "" ) {
$this->suffix = trim( $pieces[2] );
for ($s = 3; $s < $numPieces; $s++) {
$this->suffix .= ", ". trim( $pieces[$s] );
}
} else {
for ($s = 2; $s < $numPieces; $s++) {
$this->suffix .= ", ". trim( $pieces[$s] );
}
}
}
$this->last = $pieces[0];
break;
}
unset( $pieces );
break;
}
if ( $this->first == "" && $this->middle == "" && $this->last == "" ) {
$this->notParseable = TRUE;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilFullnameParser::setFullName (   $newFullName)

Mutator Method public.

Parameters
newFullNamethe new value to set fullName to

Definition at line 168 of file class.ilFullnameParser.php.

{ $this->fullName = $newFullName; }

Field Documentation

ilFullnameParser::$first
private

Definition at line 42 of file class.ilFullnameParser.php.

Referenced by getFirstName().

ilFullnameParser::$fullName
private

Definition at line 66 of file class.ilFullnameParser.php.

ilFullnameParser::$last
private

Definition at line 54 of file class.ilFullnameParser.php.

Referenced by getLastName().

ilFullnameParser::$middle
private

Definition at line 48 of file class.ilFullnameParser.php.

Referenced by getMiddleName().

ilFullnameParser::$notParseable
private

Definition at line 72 of file class.ilFullnameParser.php.

Referenced by getNotParseable().

ilFullnameParser::$prefices
private

Definition at line 24 of file class.ilFullnameParser.php.

ilFullnameParser::$suffices
private

Definition at line 30 of file class.ilFullnameParser.php.

ilFullnameParser::$suffix
private

Definition at line 60 of file class.ilFullnameParser.php.

Referenced by getSuffix().

ilFullnameParser::$title
private

Definition at line 36 of file class.ilFullnameParser.php.

Referenced by getTitle().

ilFullnameParser::$titles
private

Definition at line 18 of file class.ilFullnameParser.php.


The documentation for this class was generated from the following file: