示例#1
0
function build_display_names(array $public_names, array $private_names, $isFemale)
{
    $short_last_name = build_short_last_name($public_names);
    $full_last_name = build_full_last_name($public_names, $isFemale);
    $private_last_name_end = build_private_name($private_names);
    $firstname = build_first_name($public_names);
    $display_names = array();
    $display_names['public_name'] = build_full_name($firstname, $full_last_name);
    $display_names['private_name'] = $display_names['public_name'] . $private_last_name_end;
    $display_names['directory_name'] = build_directory_name($firstname, $full_last_name);
    $display_names['short_name'] = build_full_name($firstname, $short_last_name);
    $display_names['sort_name'] = build_sort_name($firstname, $short_last_name);
    return $display_names;
}
示例#2
0
 public function value(ProfilePage $page, $field, $value, &$success)
 {
     require_once 'name.func.inc.php';
     $success = true;
     if (is_null($value)) {
         $request = NamesReq::getPublicNames($page->pid());
         if (!$request) {
             $value['public_names'] = XDB::fetchOneAssoc('SELECT  lastname_main, lastname_marital, lastname_ordinary,
                                                                  firstname_main, firstname_ordinary, pseudonym
                                                            FROM  profile_public_names
                                                           WHERE  pid = {?}', $page->pid());
         } else {
             $value['public_names'] = $request;
             Platal::page()->assign('validation', true);
         }
         $value['private_names'] = XDB::fetchAllAssoc('SELECT  type, name
                                                         FROM  profile_private_names
                                                        WHERE  pid = {?}
                                                     ORDER BY  type, id', $page->pid());
     } else {
         foreach ($value['public_names'] as $key => $name) {
             $value['public_names'][$key] = capitalize_name(trim($name));
         }
         if (isset($value['private_names'])) {
             foreach ($value['private_names'] as $key => $name) {
                 $value['private_names'][$key]['name'] = trim($name['name']);
                 if ($value['private_names'][$key]['name'] == '') {
                     unset($value['private_names'][$key]);
                 }
             }
         }
         if (S::user()->isMe($page->owner)) {
             $success = $this->prepare($page, $value['public_names']);
         }
     }
     $public_name = build_first_name($value['public_names']) . ' ' . build_full_last_name($value['public_names'], $page->profile->isFemale());
     if (isset($value['private_names'])) {
         $private_name_end = build_private_name($value['private_names']);
         $private_name = $public_name . $private_name_end;
     } else {
         $value['private_names'] = array();
         $private_name = $public_name;
     }
     Platal::page()->assign('public_name', $public_name);
     Platal::page()->assign('private_name', $private_name);
     return $value;
 }