public function templateData() { $uAuthor = ObjectCache::getByType('\\Kiki\\User', $this->userId); $data = array('id' => $this->id, 'url' => $this->url(), 'ctime' => strtotime($this->ctime), 'relTime' => Misc::relativeTime($this->ctime), 'title' => $this->title(), 'body' => $this->body, 'author' => $uAuthor->name(), 'publications' => array(), 'likes' => $this->likes(), 'comments' => Comments::count($this->objectId), 'html' => array('comments' => Comments::show($this->objectId))); $publications = $this->publications(); foreach ($publications as $publication) { $data['publications'][] = $publication->templateData(); } return $data; }
public function templateData() { $uAuthor = ObjectCache::getByType('\\Kiki\\User', $this->userId); $prevArticle = $this->getPrev(); $nextArticle = $this->getNext(); $data = array('id' => $this->id, 'url' => $this->url(), 'ctime' => strtotime($this->ctime), 'relTime' => Misc::relativeTime($this->ctime), 'title' => $this->title, 'body' => $this->body, 'author' => $uAuthor->name(), 'images' => array(), 'publications' => array(), 'likes' => $this->likes(), 'comments' => Comments::count($this->objectId), 'html' => array('comments' => Comments::show($this->objectId), 'editform' => $this->form(true, 'articles'))); if ($nextArticle = $this->getNext()) { $data['next'] = array('id' => $nextArticle->id(), 'url' => $nextArticle->url(), 'title' => $nextArticle->title()); } if ($prevArticle = $this->getPrev()) { $data['prev'] = array('id' => $prevArticle->id(), 'url' => $prevArticle->url(), 'title' => $prevArticle->title()); } $publications = $this->publications(); foreach ($publications as $publication) { $data['publications'][] = $publication->templateData(); } $images = $this->images(); foreach ($images as $image) { $data['images'][] = Storage::url($image); } // print_r( $data['images'] ); return $data; }
public function getStatistics() { return ['comments' => Comments::count('user_id = "' . $this->id . '"'), 'tags' => Taggables::count('user_id = "' . $this->id . '"'), 'links' => Links::count('user_id = "' . $this->id . '"'), 'favorites' => Favorites::count('user_id = "' . $this->id . '"')]; }