xssbook2/web/_model/format.php

46 lines
845 B
PHP
Raw Normal View History

2024-03-30 16:14:42 +00:00
<?php /* Copyright (c) 2024 Freya Murphy */
class Format_model extends Model {
2024-03-30 16:14:42 +00:00
function __construct($load) {
parent::__construct($load);
}
/**
* Formats a users's name
* @param array $user - the $user
* @returns the user's formatted display name
*/
public function name($user) {
$name = '';
if ($user['first_name']) {
$name .= $user['first_name'];
}
if ($user['middle_name']) {
if ($name != '') {
$name .= ' ';
}
$name .= $user['middle_name'];
}
if ($user['last_name']) {
if ($name != '') {
$name .= ' ';
}
$name .= $user['last_name'];
}
if ($name == '') {
$name = '@' . $user['username'];
}
return $name;
}
/**
* Formats a date
* @param string $date - the data in RFC3999 format
* @returns the formatted date
*/
public function date($date) {
return $date;
}
}