Example #1
0
 /**
  * Converts the wiki [[page]] and [[text|page]] to HTML links.
  *
  * @param string $text
  *
  * @return string
  */
 public static function wikiLinks($text)
 {
     return preg_replace_callback("|\\[\\[(?P<page>[\\w\\d\\-_]+)(\\|(?P<text>[\\s\\w\\d\\-_]+))?\\]\\]|", function ($matches) {
         $project = current_project();
         if (!$project) {
             return $matches[0];
         }
         if (!isset($matches['text'])) {
             $matches['text'] = $matches['page'];
         }
         return HTML::link($matches['text'], routePath('wiki_page', ['slug' => $matches['page']]));
     }, $text);
 }
Example #2
0
/**
 * Get a profile link with the users gravatar.
 *
 * @param  string  $userEmail
 * @param  string  $userName
 * @param  integer $userId
 * @param  integer $size
 *
 * @return string
 */
function gravatar_profile_link($userEmail, $userName, $userId, $size = null)
{
    return HTML::link(Gravatar::withString($userEmail, $userName, $size), routePath('user', ['id' => $userId]));
}