From: Mikael Nordfeldth Date: Tue, 1 Mar 2016 22:48:32 +0000 (+0100) Subject: Make Profile->getFancyUrl() somewhat better on fallback X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=4abb3f19bfa76a9434d1e44e7b4ebbd6e5e65192;p=quix0rs-gnu-social.git 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. --- diff --git a/classes/Profile.php b/classes/Profile.php index 4fa20d7cd4..2bcd1858fe 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -218,18 +218,30 @@ class Profile extends Managed_DataObject } /** - * Gets the full name (if filled) with nickname as a parenthetical, or the nickname alone - * if no fullname is provided. + * Gets the full name (if filled) with acct URI, URL, or URI as a + * parenthetical (in that order, for each not found). If no full + * name is found only the second part is returned, without ()s. * * @return string */ function getFancyName() { - if ($this->getFullname()) { - // TRANS: Full name of a profile or group (%1$s) followed by acct URI (%2$s) in parentheses without acct:. - return sprintf(_m('FANCYNAME','%1$s (%2$s)'), $this->getFullname(), $this->getAcctUri()); + $uri = null; + try { + $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 { - return $this->getAcctUri(false); + return $uri; } }