/** * Prepares the row for output * * @param string $mode The mode for preparing data. 'site' for fron-end data, 'admin' for administrator operations. * * @return void */ public function prepare($mode = null) { // Prepare generic properties like dates and authors parent::prepare($mode); // Prepare specific properties $this->editLink = JURI::base(true) . '/index.php?option=com_k2#comments/edit/' . $this->id; // Created date $this->createdOn = JHtml::_('date', $this->date, JText::_('K2_DATE_FORMAT')); // Get application $application = JFactory::getApplication(); // Front-end only if ($application->isSite()) { // Get user $this->user = $this->getUser(); // Edit permission $this->canEdit = K2Comments::getPermissions()->canEdit; // Report permission $user = JFactory::getUser(); $this->canReport = K2Comments::getPermissions()->canReport && $user->id != $this->userId; // Report user permission $this->canReportUser = K2Comments::getPermissions()->canReportUser && $this->userId > 0 && $user->id != $this->userId; // Apply no-follow to all links $document = new DOMDocument(); $document->loadHTML('<?xml encoding="UTF-8"><html><body>' . $this->text . '</body></html>'); $links = $document->getElementsByTagName('a'); foreach ($links as $link) { $link->setAttribute('rel', 'nofollow'); } $this->text = $document->saveHTML($document->getElementsByTagName('body')->item(0)); $this->text = str_replace(array('<body>', '</body>'), '', $this->text); // Item link $this->itemLink = $this->getItemLink(); // Category link $this->categoryLink = $this->getCategoryLink(); // Is Author response? $this->isAuthorResponse = $this->getIsAuthorResponse(); // Unset sensitive data if user is not authorised to edit the comment if (!$this->canEdit) { unset($this->email); unset($this->ip); unset($this->hostname); } } }