/** * Display a feed of comments * * @return void */ protected function _feed() { if (!$this->params->get('comments_feeds')) { $this->action = 'view'; $this->_view(); return; } // Set the mime encoding for the document Document::setType('feed'); // Load the comments $comment = new \Plugins\Hubzero\Comments\Models\Comment(); $filters = array('parent' => 0, 'item_type' => $this->obj_type, 'item_id' => $this->obj_id); if ($this->obj instanceof \Hubzero\Base\Model) { $title = $this->obj->get('title'); } else { $title = $this->obj->title; } // Start a new feed object $doc = Document::instance(); $doc->link = Route::url($this->url); $doc->title = Config::get('sitename') . ' - ' . Lang::txt(strtoupper($this->_option)); $doc->title .= $title ? ': ' . stripslashes($title) : ''; $doc->title .= ': ' . Lang::txt('PLG_HUBZERO_COMMENTS'); $doc->description = Lang::txt('PLG_HUBZERO_COMMENTS_RSS_DESCRIPTION', Config::get('sitename'), stripslashes($title)); $doc->copyright = Lang::txt('PLG_HUBZERO_COMMENTS_RSS_COPYRIGHT', date("Y"), Config::get('sitename')); // Start outputing results if any found if ($comment->replies('list', $filters)->total() > 0) { foreach ($comment->replies() as $row) { // URL link to article $link = Route::url('index.php?option=' . $this->_option . '§ion=' . $section->alias . '&category=' . $category->alias . '&alias=' . $entry->alias . '#c' . $row->id); $author = Lang::txt('PLG_HUBZERO_COMMENTS_ANONYMOUS'); if (!$row->get('anonymous')) { $author = $row->creator('name'); } // Prepare the title $title = Lang::txt('PLG_HUBZERO_COMMENTS_COMMENT_BY', $author) . ' @ ' . $row->created('time') . ' on ' . $row->created('date'); // Strip html from feed item description text if ($row->isReported()) { $description = Lang::txt('PLG_HUBZERO_COMMENTS_REPORTED_AS_ABUSIVE'); } else { $description = $row->content('clean'); } @($date = $row->created() ? date('r', strtotime($row->created())) : ''); // Load individual item creator class $item = new \Hubzero\Document\Type\Feed\Item(); $item->title = $title; $item->link = $link; $item->description = $description; $item->date = $date; $item->category = ''; $item->author = $author; // Loads item info into rss array $doc->addItem($item); // Check for any replies if ($row->replies()->total()) { foreach ($row->replies() as $reply) { // URL link to article $link = Route::url('index.php?option=' . $this->_option . '§ion=' . $section->alias . '&category=' . $category->alias . '&alias=' . $entry->alias . '#c' . $reply->id); $author = Lang::txt('PLG_HUBZERO_COMMENTS_ANONYMOUS'); if (!$reply->anonymous) { $cuser = User::getInstance($reply->created_by); $author = $cuser->get('name'); } // Prepare the title $title = Lang::txt('PLG_HUBZERO_COMMENTS_REPLY_TO_COMMENT', $row->id, $author) . ' @ ' . Date::of($reply->created)->toLocal(Lang::txt('TIME_FORMAT_HZ1')) . ' ' . Lang::txt('PLG_HUBZERO_COMMENTS_ON') . ' ' . Date::of($reply->created)->toLocal(Lang::txt('DATE_FORMAT_HZ1')); // Strip html from feed item description text if ($reply->reports) { $description = Lang::txt('PLG_HUBZERO_COMMENTS_REPORTED_AS_ABUSIVE'); } else { $description = is_object($p) ? $p->parse(stripslashes($reply->content)) : nl2br(stripslashes($reply->content)); } $description = html_entity_decode(\Hubzero\Utility\Sanitize::clean($description)); @($date = $reply->created ? gmdate('r', strtotime($reply->created)) : ''); // Load individual item creator class $item = new \Hubzero\Document\Type\Feed\Item(); $item->title = $title; $item->link = $link; $item->description = $description; $item->date = $date; $item->category = ''; $item->author = $author; // Loads item info into rss array $doc->addItem($item); if ($reply->replies) { foreach ($reply->replies as $response) { // URL link to article $link = Route::url('index.php?option=' . $this->_option . '§ion=' . $section->alias . '&category=' . $category->alias . '&alias=' . $entry->alias . '#c' . $response->id); $author = Lang::txt('PLG_HUBZERO_COMMENTS_ANONYMOUS'); if (!$response->anonymous) { $cuser = User::getInstance($response->created_by); $author = $cuser->get('name'); } // Prepare the title $title = Lang::txt('PLG_HUBZERO_COMMENTS_REPLY_TO_COMMENT', $reply->id, $author) . ' @ ' . Date::of($response->created)->toLocal(Lang::txt('TIME_FORMAT_HZ1')) . ' ' . Lang::txt('PLG_HUBZERO_COMMENTS_ON') . ' ' . Date::of($response->created)->toLocal(Lang::txt('DATE_FORMAT_HZ1')); // Strip html from feed item description text if ($response->reports) { $description = Lang::txt('PLG_HUBZERO_COMMENTS_REPORTED_AS_ABUSIVE'); } else { $description = is_object($p) ? $p->parse(stripslashes($response->content)) : nl2br(stripslashes($response->content)); } $description = html_entity_decode(\Hubzero\Utility\Sanitize::clean($description)); @($date = $response->created ? gmdate('r', strtotime($response->created)) : ''); // Load individual item creator class $item = new \Hubzero\Document\Type\Feed\Item(); $item->title = $title; $item->link = $link; $item->description = $description; $item->date = $date; $item->category = ''; $item->author = $author; // Loads item info into rss array $doc->addItem($item); } } } } } } // Output the feed echo $doc->render(); }
if (!$comment->exists()) { $comment->set('parent', Request::getInt('commentreply', 0)); $comment->set('created_by', !User::isGuest() ? User::get('id') : 0); $comment->set('anonymous', !User::isGuest() ? 0 : 1); } ?> <img src="<?php echo $comment->creator()->getPicture($comment->get('anonymous')); ?> " alt="" /> </p> <fieldset> <?php if (!User::isGuest()) { if ($replyto = Request::getInt('commentreply', 0)) { $reply = new \Plugins\Hubzero\Comments\Models\Comment($replyto); $name = Lang::txt('COM_KB_ANONYMOUS'); if (!$reply->get('anonymous')) { $name = ($reply->creator('public') ? '<a href="' . Route::url($reply->creator()->getLink()) . '">' : '') . $this->escape(stripslashes($repy->creator('name'))) . ($reply->creator('public') ? '</a>' : ''); } ?> <blockquote cite="c<?php echo $reply->get('id'); ?> "> <p> <strong><?php echo $name; ?> </strong> <span class="comment-date-at"><?php