Exemplo n.º 1
0
 /**
  * prepareData
  *
  * @param \Windwalker\Data\Data $data
  *
  * @return  void
  */
 protected function prepareData($data)
 {
     $paths = $data->currentCategory->path;
     $data->breadcrumbs = BreadcrumbHelper::getBreadcrumbs($paths);
     if ($data->currentCategory->id != 1) {
         $this->setTitle($data->currentCategory->title);
     }
     // Prepare format
     foreach ($data->categories as $category) {
         $category->last_post->user_params = new Registry($category->last_post->user_params);
     }
     foreach ($data->topics as $topic) {
         $topic->last_user_params = new Registry($topic->last_user_params);
     }
     $user = User::get();
     $data->isWatch = Notification::getNotification('category', $data->currentCategory->id, $user->id)->notNull();
     if ($data->currentCategory->id != 1) {
         $desc = $data->currentCategory->description;
         $desc = Utf8String::substr(strip_tags($desc), 0, 150);
         HtmlHeader::addMetadata('description', $desc, true);
         HtmlHeader::addOpenGraph('og:title', HtmlHeader::getPageTitle(), true);
         HtmlHeader::addOpenGraph('og:description', $desc, true);
         HtmlHeader::addOpenGraph('og:image', $data->currentCategory->image, true);
     }
 }
Exemplo n.º 2
0
 /**
  * prepareData
  *
  * @param \Windwalker\Data\Data $data
  *
  * @return  void
  */
 protected function prepareData($data)
 {
     if ($this->layout == 'default') {
         $paths = $this['topic']->category->path;
         $data->breadcrumbs = BreadcrumbHelper::getBreadcrumbs($paths);
         foreach ($data->posts as $post) {
             $post->raw_body = $post->body;
             $post->body = Markdown::render($post->body);
         }
         $user = User::get();
         $data->isWatch = Notification::getNotification('topic', $this['topic']->id, $user->id)->notNull();
         $this->setTitle($data->topic->title);
     } else {
         $this->setTitle('New Topic');
     }
     $desc = $data->topic->title;
     if ($data->posts[0]) {
         $desc = $data->posts[0]->body;
         $desc = Utf8String::substr(strip_tags($desc), 0, 150);
     }
     HtmlHeader::addMetadata('description', $desc, true);
     HtmlHeader::addOpenGraph('og:title', HtmlHeader::getPageTitle(), true);
     HtmlHeader::addOpenGraph('og:description', $desc, true);
     HtmlHeader::getMetadata()->removeOpenGraph('og:image');
 }