public function get() { if (($page = $this->input->query('page', 1)) < 1) { $page = 1; } $limit = 20; $offset = ($page - 1) * $limit; $total = Model::factory('Article')->where('status', '1')->count(); $this->data['articles'] = Model::factory('Article')->where('status', '1')->order_by_desc('point')->offset($offset)->limit($limit)->find_many(); $this->data['latest_articles'] = array(); /** * 第一页加载最新的几篇文章 */ if ($page == 1) { $this->data['latest_articles'] = Model::factory('Article')->where('status', '1')->order_by_desc('created_at')->limit(5)->find_many(); if ($this->data['latest_articles'] && !$this->input->query('force_latest')) { $exists_articles_ids = array(); foreach ($this->data['articles'] as $article) { $exists_articles_ids[] = $article->id; } $this->data['latest_articles'] = array_filter($this->data['latest_articles'], function ($article) use($exists_articles_ids) { if (in_array($article->id, $exists_articles_ids)) { return false; } return true; }); } } $this->data['page'] = Html::makePage($this->input->uri(), 'page=(:num)', $page, $total, $limit); }
public function get() { if (($page = $this->input->query('page', 1)) < 1) { $page = 1; } $limit = 20; $offset = ($page - 1) * $limit; $total = $this->user->diggs()->where('status', '1')->count(); $this->data['articles'] = $this->user->diggs()->where('status', '1')->offset($offset)->limit($limit)->order_by_desc('created_at')->find_many(); $this->data['page'] = Html::makePage($this->input->uri(), 'page=(:num)', $page, $total, $limit); }
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 get() { if (($page = $this->input->query('page', 1)) < 1) { $page = 1; } $limit = 20; $offset = ($page - 1) * $limit; $kw = $this->input->query('kw'); $total = Model::factory('Article')->where('status', '1')->where_like('title', '%' . $this->input->query('kw') . '%')->count(); $this->data['kw'] = $kw; $this->data['articles'] = Model::factory('Article')->where('status', '1')->where_like('title', '%' . $kw . '%')->order_by_desc('point')->offset($offset)->limit($limit)->find_many(); $this->data['page'] = Html::makePage($this->input->uri(), 'page=(:num)', $page, $total, $limit); }
public function get() { if (($page = $this->input->query('page', 1)) < 1) { $page = 1; } $limit = 20; $offset = ($page - 1) * $limit; $is_read = is_null($this->input->query('read')) ? 0 : 1; $this->data['is_read'] = $is_read; $type = $is_read ? Notify::READ : Notify::UNREAD; $total = $this->user->notifies()->where('status', $type)->count(); $this->data['notifies'] = $this->user->notifies()->where('status', $type)->offset($offset)->limit($limit)->order_by_desc('created_at')->find_many(); $this->data['page'] = Html::makePage($this->input->uri(), 'page=(:num)', $page, $total, $limit); }
public function get() { if (($page = $this->input->query('page', 1)) < 1) { $page = 1; } $limit = 20; $offset = ($page - 1) * $limit; $user = $this->user; if ($this->params && $this->params['id']) { $user = Model::factory('User')->find_one($this->params['id']); if (!$user) { $this->alert("User is not exists"); } $this->title = $user->name . "'s comments"; } $total = $user->comments()->count(); $this->data['comments'] = $user->comments()->offset($offset)->limit($limit)->order_by_desc('created_at')->find_many(); $this->data['page'] = Html::makePage($this->input->uri(), 'page=(:num)', $page, $total, $limit); }
echo $author->name; ?> " data-id="<?php echo $comment->id; ?> "> <div class="identical"> <a href="<?php echo url('/u/' . $author->id); ?> " class="user-<?php echo $author->isOK() ? 'ok' : 'not-ok'; ?> "> <img class="avatar" src="<?php echo \Helper\Html::gravatar($author->email, 30); ?> " /> @<?php echo $author->name; ?> </a> <a href="#comment_<?php echo $comment->id; ?> " class="identical-day"># <?php echo $comment->created_at; ?> </a> <a href="#respond" class="reply">reply</a> <?php
/** * Create a HTML page link. * * @param int $page * @param string $text * @param string $class * @return string */ protected function link($page, $text, $class) { $query = '?page=' . $page . $this->appendage($this->appends); $uri = \Yaf\Dispatcher::getInstance()->getRequest()->getRequestUri(); return Html::linkTo($text, $uri . $query, compact('class')); }
<!DOCTYPE HTML> <html> <head> <meta charset="utf-8"/> <meta name="robots" content="all"/> <title><?php echo $title . ' ' . $config['site']['title_suffix']; ?> </title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content="<?php echo \Helper\Html::makeMetaText(!empty($article) ? $article->title . ': ' . mb_substr($article->content, 0, 80) : $config['site']['default_meta']); ?> "/> <meta name="keyword" content="<?php echo $config['site']['keywords']; ?> "/> <link rel="alternate" type="application/rss+xml" title="RSS Feed" href="<?php echo url('/feed', null, true); ?> "/> <link rel="stylesheet" href="<?php echo assert_url('/static/essage.css'); ?> "/> <link rel="stylesheet" href="<?php echo assert_url('/static/style.css'); ?> "/> <link rel="icon shortcut" href="<?php
echo $article->created_at; ?> </small> </div> <script type="text/javascript" charset="utf-8"> (function(){ var img = document.querySelector('.entry .typo-p img'); var _w = 106 , _h = 58; var param = { url:location.href, type:'5', count:'1', appkey:'', title:'<?php echo \Helper\Html::makeShareText($article); ?> ', pic: img ? img.src : '', ralateUid:'', language:'zh_cn', rnd:new Date().valueOf() } var temp = []; for( var p in param ){ temp.push(p + '=' + encodeURIComponent( param[p] || '' ) ) } document.write('<iframe allowTransparency="true" style="float:right;" frameborder="0" scrolling="no" src="http://hits.sinajs.cn/A1/weiboshare.html?' + temp.join('&') + '" width="'+ _w+'" height="'+_h+'"></iframe>') })() </script>
?> </li> <li>Comments: <?php echo $author->comments()->count(); ?> </li> <li>Diggs: <?php echo $author->diggs()->count(); ?> </li> <li>Created at: <small><?php echo $author->created_at; ?> </small></li> <li>Bio: <?php echo \Helper\Html::fromMarkdown($author->bio); ?> </li> </ul> <?php if ($user && $user->id == $author->id) { ?> <a class="btn" href="<?php echo url('/account/edit'); ?> ">Edit Profile</a> <?php } ?>
<span class="stamp fontello">TOP</span> <ul class="leaders clearfix typo wrapper-padding"> <?php if ($leaders) { foreach ($leaders as $leader) { ?> <li class="leader"> <div class="identical"> <img class="avatar" src="<?php echo \Helper\Html::gravatar($leader->email, 30); ?> " /> <a href="<?php echo url('/u/' . $leader->id); ?> "><?php echo $leader->name; ?> </a> <small><?php echo $leader->posts_count; ?> posts / <?php echo $leader->digged_count; ?> points</small> </div> </li> <?php }