示例#1
0
文件: Format.php 项目: dasklney/traq
 /**
  * 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);
 }
示例#2
0
文件: common.php 项目: dasklney/traq
/**
 * 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]));
}