modifier.buglink.php 629 B

1234567891011121314151617181920212223
  1. <?php
  2. /**
  3. * Modifier to turn bug references into links
  4. *
  5. * @author Christopher Han <xiphux@gmail.com>
  6. * @copyright Copyright (c) 2010 Christopher Han
  7. * @package GitPHP
  8. * @subpackage Smarty
  9. *
  10. * @param string $text text to find bug references in
  11. * @param string $pattern search pattern
  12. * @param string $link link pattern
  13. * @return string text with bug references linked
  14. */
  15. function smarty_modifier_buglink($text, $pattern = null, $link = null)
  16. {
  17. if (empty($text) || empty($pattern) || empty($link))
  18. return $text;
  19. $fullLink = '<a href="' . $link . '">${0}</a>';
  20. return preg_replace($pattern, $fullLink, $text);
  21. }