Make Profile->getFancyUrl() somewhat better on fallback

It tries to get a referential identifier apart from the fullname trying
with acct: URI, profile URL and lastly URI.
This commit is contained in:
Mikael Nordfeldth 2016-03-01 23:48:32 +01:00
parent ddd60e7142
commit 4abb3f19bf

View File

@ -218,18 +218,30 @@ class Profile extends Managed_DataObject
} }
/** /**
* Gets the full name (if filled) with nickname as a parenthetical, or the nickname alone * Gets the full name (if filled) with acct URI, URL, or URI as a
* if no fullname is provided. * parenthetical (in that order, for each not found). If no full
* name is found only the second part is returned, without ()s.
* *
* @return string * @return string
*/ */
function getFancyName() function getFancyName()
{ {
if ($this->getFullname()) { $uri = null;
// TRANS: Full name of a profile or group (%1$s) followed by acct URI (%2$s) in parentheses without acct:. try {
return sprintf(_m('FANCYNAME','%1$s (%2$s)'), $this->getFullname(), $this->getAcctUri()); $uri = $this->getAcctUri();
} catch (ProfileNoAcctUriException $e) {
try {
$uri = $this->getUrl();
} catch (InvalidUrlException $e) {
$uri = $this->getUri();
}
}
if (mb_strlen($this->getFullname()) > 0) {
// TRANS: Full name of a profile or group (%1$s) followed by some URI (%2$s) in parentheses.
return sprintf(_m('FANCYNAME','%1$s (%2$s)'), $this->getFullname(), $uri);
} else { } else {
return $this->getAcctUri(false); return $uri;
} }
} }