public function parserUser($text)
 {
     return preg_replace_callback('{
             (?<!(?:\\[|`))\\s?
                 @([\\w]{1,20})
             \\s(?!(?:\\]|`))
         }xs', function ($match) {
         if ($user = User::dispense()->where('name', $match[1])->find_one()) {
             return '[' . trim($match[0]) . '](' . Url::to('/u/' . $user->id) . ')';
         } else {
             return $match[0];
         }
     }, $text);
 }
Beispiel #2
0
 public function testToFull()
 {
     $url = Url::to('abc', array('from' => 'local'), true);
     $this->assertEquals('http://apple.com/test/abc?from=local', $url);
 }
Beispiel #3
0
 public function permalink()
 {
     return Url::to('/p/' . $this->id, null, true);
 }
Beispiel #4
0
 /**
  * Redirect the page
  *
  * @param $uri
  */
 protected function redirect($uri)
 {
     $this->output->redirect(Url::to($uri))->end();
 }
Beispiel #5
0
/**
 * Build url
 *
 * @param string $path
 * @param array  $query
 * @param bool   $full
 * @return string
 */
function url($path, array $query = null, $full = false)
{
    return Url::to($path, $query, $full);
}
Beispiel #6
0
 /**
  * Build a link
  *
  * @param string $src
  * @param string $text
  * @param array  $attributes
  * @return string
  */
 public static function a($src, $text, array $attributes = array())
 {
     return self::dom('a', $text, array('href' => Url::to($src)) + $attributes);
 }
Beispiel #7
0
 /**
  * Get permalink
  *
  * @param bool $full
  * @return string
  */
 public function permalink($full = false)
 {
     return Url::to('/posts/' . $this->id, null, $full);
 }