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); }
public function testToFull() { $url = Url::to('abc', array('from' => 'local'), true); $this->assertEquals('http://apple.com/test/abc?from=local', $url); }
public function permalink() { return Url::to('/p/' . $this->id, null, true); }
/** * Redirect the page * * @param $uri */ protected function redirect($uri) { $this->output->redirect(Url::to($uri))->end(); }
/** * 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); }
/** * 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); }
/** * Get permalink * * @param bool $full * @return string */ public function permalink($full = false) { return Url::to('/posts/' . $this->id, null, $full); }