/**
  * Execute the controller.
  *
  * @return  mixed Return executed result.
  *
  * @throws  \LogicException
  * @throws  \RuntimeException
  */
 public function doExecute()
 {
     $format = $this->input->get('format', 'html');
     $model = new PostsModel();
     if ($format == 'feed') {
         $this->app->response->setMimeType('application/rss+xml');
         $view = new PostsFeedView($this->data);
         $limit = 50;
     } else {
         $view = new PostsHtmlView($this->data);
         $limit = 10;
     }
     $model['blog.id'] = $view['blog']->id;
     $model['blog.published'] = $view['user']->isNull();
     $model['list.page'] = $page = $this->input->getInt('page', 1);
     $model['list.limit'] = $limit;
     $model['list.start'] = ($model['list.page'] - 1) * $model['list.limit'];
     $model['list.ordering'] = 'id desc';
     $view['posts'] = $model->getItems();
     $view['pagination'] = $model->getPagination()->build();
     $view['page'] = $page;
     $view['type'] = $this->input->get('type', 'home');
     return $view->render();
 }
 /**
  * Execute the controller.
  *
  * @return  mixed Return executed result.
  *
  * @throws  \LogicException
  * @throws  \RuntimeException
  */
 public function execute()
 {
     $model = new PostsModel();
     $blog = Ioc::get('current.blog', 'front');
     $author = (new DataMapper('authors'))->findOne(['blog' => $blog->id, 'owner' => 1]);
     $user = (new DataMapper('users'))->findOne(['id' => $author->user]);
     $this->data['blog'] = $blog;
     $this->data['ownerUser'] = $user;
     $this->data['ownerAuthor'] = $author;
     $this->data['user'] = User::get();
     $this->data['author'] = Author::get($user->id, $blog->id);
     // Statics
     $model['blog.id'] = $blog->id;
     $model['list.start'] = null;
     $model['list.limit'] = null;
     $model['blog.published'] = true;
     $model['post.type'] = 'static';
     $model['post.ordering'] = 'id asc';
     $this->data['statics'] = $model->getItems();
     $this->data['blog']->link = 'http://' . $this->data['blog']->alias . '.windspeaker.co';
     $this->data['blog']->params = new Registry($this->data['blog']->params);
     $this->data['meta'] = new Data();
     return $this->doExecute();
 }