public function get() { $posts = Model::factory('Article')->where('status', '1')->order_by_desc('point')->limit(10)->find_many(); $feed = new FeedFactory(); $channel = new Channel(); $channel->title(config('site.title'))->description(config('site.default_meta'))->url(Url::site())->appendTo($feed); foreach ($posts as $post) { $item = new Item(); /** @var $post \Model\Article */ $item->title($post->title)->description(Html::fromMarkdown($post->content))->url($post->permalink())->pubDate(strtotime($post->created_at))->appendTo($channel); } $this->data = substr($feed, 0, -1); }
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 testCurrentFull() { $url = Url::current(null, true); $this->assertEquals('http://apple.com/test', $url); }
/** * Create the Paginator with the Url::current. It's a shortcut to quickly build it with the request URI * * @param string $pattern - a regex pattern that will match the url and extract the page number * @param int $total - Total items found * @param int $size - Total items per page * @param int $displays - The displays size * @return Paginator */ public static function create($pattern = "/page/(:num)", $total = 0, $size = 10, $displays = 10) { return new self(Url::current(), $pattern, $total, $size, $displays); }
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(); }
/** * Base url * * @return mixed */ function base_url() { return Url::base(); }
/** * Build a image * * @param string $src * @param array $attributes * @return string */ public static function img($src, array $attributes = array()) { return self::dom('img', array('src' => Url::asset($src)) + $attributes); }
/** * Get permalink * * @param bool $full * @return string */ public function permalink($full = false) { return Url::to('/posts/' . $this->id, null, $full); }