src/snac/server/database/SQL.php
/**
     * Temporary function to brute force order name components.
     *
     * Sort $orig to put it in the order we want, not the order it exists in the database. Could have added
     * another column to the db (or created a second table for vocabulary structure), but that would require a
     * db rebuild as well as altering the vocabulary initialization SQL. That might have been less work that
     * this (or more elegant) but this fix is totally localized right here.
     *
     * This also removes NameAddition from family by not including it in the $dest list.
     *
     * @param string[][] $orig A list of list with keys 'id','value'.
     *
     * @return string[][] Sorted copy of the $orig list.
     */
Temporary function to brute force order name components.
Sort $orig to put it in the order we want, not the order it exists in the database. Could have added
another column to the db (or created a second table for vocabulary structure), but that would require a
db rebuild as well as altering the vocabulary initialization SQL. That might have been less work that
this (or more elegant) but this fix is totally localized right here.

This also removes NameAddition from family by not including it in the $dest list.

@param string[][] $orig A list of list with keys 'id','value'.

@return string[][] Sorted copy of the $orig list.
Temporary function to brute force order name components . Sort $orig to put it in the order we want not the order it exists in the database . Could have added another column to the db ( or created a second table for vocabulary structure ) but that would require a db rebuild as well as altering the vocabulary initialization SQL . That might have been less work that this ( or more elegant ) but this fix is totally localized right here . This also removes NameAddition from family by not including it in the $dest list . @param string [] [] $orig A list of list with keys ' id ' ' value ' . @return string [] [] Sorted copy of the $orig list .
private function specialSort($orig)
    {
        $personList = array('Surname' => 0,
                            'Forename' => 1,
                            'NameAddition' => 2,
                            'RomanNumeral' => 3,
                            'Date' => 4,
                            'NameExpansion' => 5,
                            'UnspecifiedName' => 6);
        $corpList = array('Name' => 0,
                          'JurisdictionName' => 1,
                          'SubdivisionName' => 2,
                          'NameAddition' => 3,
                          'Number' => 4,
                          'Location' => 5,
                          'Date' => 6);
        $familyList = array('FamilyName' => 0,
                            'FamilyType' => 1,
                            'Place' => 2,
                            'Date' => 3,
                            'NameAddition' => -1);
        if ('Forename' == $orig[1]['value'])
        {
            $useList = $personList;
        }
        else if ('JurisdictionName' == $orig[1]['value'])
        {
            $useList = $corpList;
        }
        else
        {
            $useList = $familyList;
        }
        $dest = array();
        foreach($orig as $record)
        {
            if ($useList[$record['value']] >= 0)
            {
                $dest[$useList[$record['value']]] = $record;
            }
        }
        ksort($dest);
        return $dest;
    }
private function specialSort ( $ orig ) { $ personList = array ( 'Surname' => 0 , 'Forename' => 1 , 'NameAddition' => 2 , 'RomanNumeral' => 3 , 'Date' => 4 , 'NameExpansion' => 5 , 'UnspecifiedName' => 6 ) ; $ corpList = array ( 'Name' => 0 , 'JurisdictionName' => 1 , 'SubdivisionName' => 2 , 'NameAddition' => 3 , 'Number' => 4 , 'Location' => 5 , 'Date' => 6 ) ; $ familyList = array ( 'FamilyName' => 0 , 'FamilyType' => 1 , 'Place' => 2 , 'Date' => 3 , 'NameAddition' => - 1 ) ; if ( 'Forename' == $ orig [ 1 ] [ 'value' ] ) { $ useList = $ personList ; } else if ( 'JurisdictionName' == $ orig [ 1 ] [ 'value' ] ) { $ useList = $ corpList ; } else { $ useList = $ familyList ; } $ dest = array ( ) ; foreach ( $ orig as $ record ) { if ( $ useList [ $ record [ 'value' ] ] >= 0 ) { $ dest [ $ useList [ $ record [ 'value' ] ] ] = $ record ; } } ksort ( $ dest ) ; return $ dest ; }
Temporary function to brute force order name components.
Temporary function to brute force order name components .
/*
         * List of keys and the order in which they should appear.
         */ /*
             * Throw out anything with a negative index because that was never supposed to be in the list.
             * Specifically 'NameAddition' for family.
             */ /*
         * PHP gets the integer keys right, but treats the list as an associative list with numeric keys out
         * of order. ksort() fixes that.
         */