/** * Creates an HTML anchor to a users profile * * @param int $userId * @param string $name * @param string $url * @return string */ public function link($userId, $name = null, $url = null) { try { $user = $this->_ugmanager->getUser($userId); if (trim($url)) { $format = '<a href="%1$s" title="%1$s" rel="nofollow">%3$s</a>'; $url = zula_htmlspecialchars(zula_url_add_scheme($url)); } else { if ($user['id'] == Ugmanager::_GUEST_ID) { $format = '%3$s'; $url = ''; } else { $format = '<a href="%1$s" title="%2$s">%3$s</a>'; $url = $this->_router->makeUrl('users', 'profile', $user['id']); } } return sprintf($format, $url, t('View Users Profile', I18n::_DTD), zula_htmlspecialchars(trim($name) ? $name : $user['username'])); } catch (Ugmanager_UserNoExist $e) { return t('Unknown User', I18n::_DTD); } }
/** * Makes a full URL instead of just a relative one. This means it will * include the http:// or what ever is needed to create a full/external link * * @param string $separator * @param string $type * @param bool $useHttps Force use of HTTPS protocol * @return string */ public function makeFull($separator = '&', $type = null, $useHttps = null) { if (empty($_SERVER['HTTP_HOST'])) { return $this->make($separator, $type); } else { $host = $_SERVER['HTTP_HOST']; if (is_bool($useHttps)) { $host = preg_replace('#^(https?://)?#i', $useHttps ? 'https://' : 'http://', $host); } else { $host = zula_url_add_scheme($host, $this->_router->getDefaultScheme()); } return trim($host, '/') . $this->make($separator, $type); } }