function plgContentJCommentsLinksJ10($published, &$row, &$params, $page = 0) { global $task, $option, $my; // disable comments link in 3rd party components (except Events and AlphaContent) if ($option != 'com_content' && $option != 'com_frontpage' && $option != 'com_alphacontent' && $option != 'com_events') { return; } require_once JCOMMENTS_HELPERS . '/content.php'; require_once JCOMMENTS_LIBRARIES . '/joomlatune/language.tools.php'; if (!isset($params) || $params == null) { $params = new mosParameters(''); } $pvars = array_keys(get_object_vars($params->_params)); if (!$published || $params->get('popup') || in_array('moduleclass_sfx', $pvars)) { JCommentsContentPluginHelper::processForeignTags($row, true); JCommentsContentPluginHelper::clear($row, true); return; } /* if ($option == 'com_frontpage') { $pluginParams = JCommentsPluginHelper::getParams('jcomments', 'content'); if ((int) $pluginParams->get('show_frontpage', 1) == 0) { return; } } */ require_once JCOMMENTS_BASE . '/jcomments.config.php'; require_once JCOMMENTS_BASE . '/jcomments.class.php'; if ($task != 'view') { // replace other comment systems tags to JComments equivalents like {jcomments on} JCommentsContentPluginHelper::processForeignTags($row, false); // show link to comments only if ($row->access <= $my->gid) { $readmore_link = JCommentsObjectHelper::getLink($row->id, 'com_content'); $readmore_register = 0; } else { $readmore_link = sefRelToAbs('index.php?option=com_registration&task=register'); $readmore_register = 1; } $tmpl = JCommentsFactory::getTemplate($row->id, 'com_content', false); $tmpl->load('tpl_links'); $tmpl->addVar('tpl_links', 'comments_link_style', $readmore_register ? -1 : 1); $tmpl->addVar('tpl_links', 'link-readmore', $readmore_link); $tmpl->addVar('tpl_links', 'content-item', $row); if ($params->get('readmore') == 0 || @$row->readmore == 0) { $tmpl->addVar('tpl_links', 'readmore_link_hidden', 1); } else { if (@$row->readmore > 0) { $tmpl->addVar('tpl_links', 'readmore_link_hidden', 0); } } $config = JCommentsFactory::getConfig(); $commentsDisabled = false; if (!JCommentsContentPluginHelper::checkCategory($row->catid)) { $commentsDisabled = true; } if ($config->getInt('comments_off', 0) == 1) { $commentsDisabled = true; } else { if ($config->getInt('comments_on', 0) == 1) { $commentsDisabled = false; } } $tmpl->addVar('tpl_links', 'comments_link_hidden', intval($commentsDisabled)); $count = 0; // do not query comments count if comments disabled and link hidden if (!$commentsDisabled) { require_once JCOMMENTS_MODELS . '/jcomments.php'; require_once JCOMMENTS_LIBRARIES . '/joomlatune/language.tools.php'; $acl = JCommentsFactory::getACL(); $options = array(); $options['object_id'] = (int) $row->id; $options['object_group'] = 'com_content'; $options['published'] = $acl->canPublish() || $acl->canPublishForObject($row->id, 'com_content') ? null : 1; $count = JCommentsModel::getCommentsCount($options); $anchor = $count == 0 ? '#addcomments' : '#comments'; $link_text = $count == 0 ? JText::_('LINK_ADD_COMMENT') : JText::plural('LINK_READ_COMMENTS', $count); $tmpl->addVar('tpl_links', 'link-comment', $readmore_link . $anchor); $tmpl->addVar('tpl_links', 'link-comment-text', $link_text); $tmpl->addVar('tpl_links', 'link-comments-class', 'comments-link'); $tmpl->addVar('tpl_links', 'comments-count', $count); } if ($readmore_register == 1 && $count == 0) { $tmpl->addVar('tpl_links', 'comments_link_hidden', 1); } if ($readmore_register == 1) { $readmore_text = JText::_('LINK_REGISTER_TO_READ_MORE'); } else { $readmore_text = JText::_('LINK_READ_MORE'); } $tmpl->addVar('tpl_links', 'link-readmore-text', $readmore_text); $tmpl->addVar('tpl_links', 'link-readmore-title', $row->title); $tmpl->addVar('tpl_links', 'link-readmore-class', 'readmore-link'); JCommentsContentPluginHelper::clear($row, true); $row->text .= $tmpl->renderTemplate('tpl_links'); $GLOBALS['jcomments_params_readmore'] = $params->get('readmore'); $GLOBALS['jcomments_row_readmore'] = $row->readmore; $params->set('readmore', 0); $row->readmore = 0; } else { JCommentsContentPluginHelper::processForeignTags($row, true); JCommentsContentPluginHelper::clear($row, true); } return; }
/** * Returns a reference to the global {@link JoomlaTuneTemplateRender} object, * only creating it if it doesn't already exist. * * @param int $object_id * @param string $object_group * @param bool $needThisUrl * @return JoomlaTuneTemplateRender */ public static function getTemplate($object_id = 0, $object_group = 'com_content', $needThisUrl = true) { global $Itemid; ob_start(); $app = JCommentsFactory::getApplication(); $config = JCommentsFactory::getConfig(); $templateName = $config->get('template'); if (empty($templateName)) { $templateName = 'default'; $config->set('template', $templateName); } include_once JCOMMENTS_LIBRARIES . '/joomlatune/template.php'; $templateDefaultDirectory = JCOMMENTS_BASE . '/tpl/' . $templateName; $templateDirectory = $templateDefaultDirectory; $templateUrl = $app->getCfg('live_site') . '/components/com_jcomments/tpl/' . $templateName; if (JCOMMENTS_JVERSION != '1.0') { $templateOverride = JPATH_SITE . '/templates/' . $app->getTemplate() . '/html/com_jcomments/' . $templateName; if (is_dir($templateOverride)) { $templateDirectory = $templateOverride; $templateUrl = JURI::root() . 'templates/' . $app->getTemplate() . '/html/com_jcomments/' . $templateName; } } $tmpl = JoomlaTuneTemplateRender::getInstance(); $tmpl->setRoot($templateDirectory); $tmpl->setDefaultRoot($templateDefaultDirectory); $tmpl->setBaseURI($templateUrl); $tmpl->addGlobalVar('siteurl', $app->getCfg('live_site')); $tmpl->addGlobalVar('charset', strtolower(preg_replace('/charset=/', '', _ISO))); $tmpl->addGlobalVar('ajaxurl', JCommentsFactory::getLink('ajax', $object_id, $object_group)); $tmpl->addGlobalVar('smilesurl', JCommentsFactory::getLink('smiles', $object_id, $object_group)); if ($config->getInt('enable_rss') == 1) { $tmpl->addGlobalVar('rssurl', JCommentsFactory::getLink('rss', $object_id, $object_group)); } $tmpl->addGlobalVar('template', $templateName); $tmpl->addGlobalVar('template_url', $templateUrl); $tmpl->addGlobalVar('itemid', $Itemid ? $Itemid : 1); if (JCOMMENTS_JVERSION == '1.0') { $tmpl->addGlobalVar('direction', 'ltr'); } else { $language = JFactory::getLanguage(); $tmpl->addGlobalVar('direction', $language->isRTL() ? 'rtl' : 'ltr'); } $lang = $app->getCfg('lang'); if ($lang == 'russian' || $lang == 'ukrainian' || $lang == 'belorussian' || $lang == 'ru-RU' || $lang == 'uk-UA' || $lang == 'be-BY') { $tmpl->addGlobalVar('support', base64_decode('PGEgaHJlZj0iaHR0cDovL3d3dy5qb29tbGF0dW5lLnJ1IiB0aXRsZT0iSkNvbW1lbnRzIiB0YXJnZXQ9Il9ibGFuayI+SkNvbW1lbnRzPC9hPg==')); } else { $tmpl->addGlobalVar('support', base64_decode('PGEgaHJlZj0iaHR0cDovL3d3dy5qb29tbGF0dW5lLmNvbSIgdGl0bGU9IkpDb21tZW50cyIgdGFyZ2V0PSJfYmxhbmsiPkpDb21tZW50czwvYT4=')); } $tmpl->addGlobalVar('comment-object_id', $object_id); $tmpl->addGlobalVar('comment-object_group', $object_group); if ($needThisUrl == true) { $tmpl->addGlobalVar('thisurl', JCommentsObjectHelper::getLink($object_id, $object_group)); } ob_end_clean(); return $tmpl; }
public static function executeCmd() { $app = JFactory::getApplication('site'); $cmd = strtolower($app->input->get('cmd', '')); $hash = $app->input->get('hash', ''); $id = $app->input->getInt('id', 0); $message = ''; $link = str_replace('/administrator', '', JURI::root()) . 'index.php'; $checkHash = JCommentsFactory::getCmdHash($cmd, $id); if ($hash == $checkHash) { $config = JCommentsFactory::getConfig(); if ($config->getInt('enable_quick_moderation') == 1) { JTable::addIncludePath(JCOMMENTS_TABLES); $comment = JTable::getInstance('Comment', 'JCommentsTable'); if ($comment->load($id)) { $link = JCommentsObjectHelper::getLink($comment->object_id, $comment->object_group, $comment->lang); $link = str_replace('&', '&', $link); switch ($cmd) { case 'publish': $comment->published = 1; $comment->store(); // send notification to comment subscribers JComments::sendToSubscribers($comment, true); $link .= '#comment-' . $comment->id; break; case 'unpublish': $comment->published = 0; $comment->store(); $acl = JCommentsFactory::getACL(); if ($acl->canPublish()) { $link .= '#comment-' . $comment->id; } else { $link .= '#comments'; } break; case 'delete': if ($config->getInt('delete_mode') == 0) { $comment->delete(); $link .= '#comments'; } else { $comment->markAsDeleted(); $link .= '#comment-' . $comment->id; } break; case 'ban': if ($config->getInt('enable_blacklist') == 1) { $acl = JCommentsFactory::getACL(); // we will not ban own IP ;) if ($comment->ip != $acl->getUserIP()) { $options = array(); $options['ip'] = $comment->ip; // check if this IP already banned if (JCommentsSecurity::checkBlacklist($options)) { $blacklist = JTable::getInstance('Blacklist', 'JCommentsTable'); $blacklist->ip = $comment->ip; $blacklist->store(); $message = JText::_('SUCCESSFULLY_BANNED'); } else { $message = JText::_('ERROR_IP_ALREADY_BANNED'); } } else { $message = JText::_('ERROR_YOU_CAN_NOT_BAN_YOUR_IP'); } } break; } JCommentsNotificationHelper::send(); } else { $message = JText::_('ERROR_NOT_FOUND'); } } else { $message = JText::_('ERROR_QUICK_MODERATION_DISABLED'); } } else { $message = JText::_('ERROR_QUICK_MODERATION_INCORRECT_HASH'); } $app->redirect($link, $message); }
public static function showObjectComments() { $config = JCommentsFactory::getConfig(); if ($config->get('enable_rss') == '1') { $app = JFactory::getApplication('site'); $object_id = $app->input->getInt('object_id', 0); $object_group = JCommentsSecurity::clearObjectGroup($app->input->get('object_group', 'com_content')); $limit = $app->input->getInt('limit', $config->getInt('feed_limit', 100)); // if no group or id specified - return 404 if ($object_id == 0 || $object_group == '') { self::showNotFound(); return; } $lm = $limit != $config->getInt('feed_limit') ? '&limit=' . $limit : ''; if (JCommentsMultilingual::isEnabled()) { $language = JCommentsMultilingual::getLanguage(); $lp = '&lang=' . $language; } else { $language = null; $lp = ''; } $liveSite = trim(str_replace(JURI::root(true), '', str_replace('/administrator', '', JURI::root())), '/'); $syndicationURL = $liveSite . JRoute::_('index.php?option=com_jcomments&task=rss&object_id=' . $object_id . '&object_group=' . $object_group . $lm . $lp . '&format=raw'); $object_title = JCommentsObjectHelper::getTitle($object_id, $object_group, $language); $object_link = JCommentsObjectHelper::getLink($object_id, $object_group, $language); $object_link = str_replace('amp;', '', JCommentsFactory::getAbsLink($object_link)); $rss = new JoomlaTuneFeed(); $rss->title = $object_title; $rss->link = $object_link; $rss->syndicationURL = $syndicationURL; $rss->description = JText::sprintf('OBJECT_FEED_DESCRIPTION', $rss->title); $options = array(); $options['object_id'] = $object_id; $options['object_group'] = $object_group; $options['lang'] = $language; $options['published'] = 1; $options['filter'] = 'c.deleted = 0'; $options['orderBy'] = 'c.date DESC'; $options['limit'] = $limit; $options['limitStart'] = 0; $options['objectinfo'] = true; $rows = JCommentsModel::getCommentsList($options); $word_maxlength = $config->getInt('word_maxlength'); foreach ($rows as $row) { $comment = JCommentsText::cleanText($row->comment); $title = $row->title; $author = JComments::getCommentAuthorName($row); if ($comment != '') { // apply censor filter $title = JCommentsText::censor($title); $comment = JCommentsText::censor($comment); // fix long words problem if ($word_maxlength > 0) { $comment = JCommentsText::fixLongWords($comment, $word_maxlength, ' '); if ($title != '') { $title = JCommentsText::fixLongWords($title, $word_maxlength, ' '); } } $item = new JoomlaTuneFeedItem(); $item->title = $title != '' ? $title : JText::sprintf('OBJECT_FEED_ITEM_TITLE', $author); $item->link = $object_link . '#comment-' . $row->id; $item->description = $comment; $item->source = $object_link; $item->pubDate = $row->date; $item->author = $author; $rss->addItem($item); } } $rss->display(); unset($rows, $rss); exit; } }
/** * Comments Search method * * The sql must return the following fields that are used in a common display * routine: href, title, section, created, text, browsernav * @param string Target search string * @param string matching option, exact|any|all * @param string ordering option, newest|oldest|popular|alpha|category * @param mixed An array if restricted to areas, null if search all */ function plgSearchJComments($text, $phrase = '', $ordering = '', $areas = null) { $text = trim($text); if ($text == '') { return array(); } if (is_array($areas)) { if (!array_intersect($areas, array_keys(plgSearchJCommentsAreas()))) { return array(); } } if (file_exists(JCOMMENTS_BASE . DS . 'jcomments.php')) { require_once JCOMMENTS_BASE . DS . 'jcomments.php'; require_once JCOMMENTS_BASE . DS . 'jcomments.class.php'; require_once JCOMMENTS_HELPERS . DS . 'plugin.php'; require_once JCOMMENTS_HELPERS . DS . 'content.php'; require_once JCOMMENTS_HELPERS . DS . 'object.php'; $db =& JCommentsFactory::getDBO(); $pluginParams = JCommentsPluginHelper::getParams('jcomments', 'search'); $limit = $pluginParams->def('search_limit', 50); switch ($phrase) { case 'exact': $where = "LOWER(comment) LIKE '%{$text}%' OR LOWER(title) LIKE '%{$text}%'"; break; case 'all': case 'any': default: $words = explode(' ', $text); $wheres = array(); foreach ($words as $word) { $wheres2 = array(); $wheres2[] = "LOWER(name) LIKE '%{$word}%'"; $wheres2[] = "LOWER(comment) LIKE '%{$word}%'"; $wheres2[] = "LOWER(title) LIKE '%{$word}%'"; $wheres[] = implode(' OR ', $wheres2); } $where = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wheres) . ')'; break; } switch ($ordering) { case 'oldest': $order = 'date ASC'; break; case 'newest': default: $order = 'date DESC'; break; } $query = "SELECT " . "\n comment AS text" . "\n, date AS created" . "\n, '2' AS browsernav" . "\n, '" . JText::_('Comments') . "' AS section" . "\n, '' AS href" . "\n, id" . "\n, object_id" . "\n, object_group" . "\nFROM #__jcomments " . "\nWHERE published='1'" . (JCommentsMultilingual::isEnabled() ? "\nAND lang = '" . JCommentsMultilingual::getLanguage() . "'" : "") . "\n AND ({$where}) " . "\nORDER BY object_id, {$order}"; $db->setQuery($query, 0, $limit); $rows = $db->loadObjectList(); $result = array(); $cnt = count($rows); if ($cnt > 0) { $last_object_id = -1; $object_link = ''; $acl =& JCommentsFactory::getACL(); $lang = JCommentsMultilingual::isEnabled() ? JCommentsMultilingual::getLanguage() : null; for ($i = 0; $i < $cnt; $i++) { if ($rows[$i]->object_id != $last_object_id) { $last_object_id = $rows[$i]->object_id; $object_link = JCommentsObjectHelper::getLink($rows[$i]->object_id, $rows[$i]->object_group); $object_title = JCommentsObjectHelper::getTitle($rows[$i]->object_id, $rows[$i]->object_group, $lang); } $rows[$i]->href = $object_link . '#comment-' . $rows[$i]->id; $comment = JCommentsText::cleanText($rows[$i]->text); if ($acl->check('enable_autocensor')) { $comment = JCommentsText::censor($comment); } if ($comment != '') { $rows[$i]->title = $object_title; $rows[$i]->text = $comment; $result[] = $rows[$i]; } } } unset($rows); return $result; } return array(); }
public static function redirectToObject() { $app = JCommentsFactory::getApplication('site'); $object_id = (int) JCommentsInput::getVar('object_id', 0); $object_group = trim(strip_tags(JCommentsInput::getVar('object_group', 'com_content'))); $lang = trim(strip_tags(JCommentsInput::getVar('lang'))); if ($object_id != 0 && $object_group != '') { $link = JCommentsObjectHelper::getLink($object_id, $object_group, $lang); $link = str_replace('amp;', '', $link); if ($link == '') { $link = $app->getCfg('live_site'); } } else { $link = $app->getCfg('live_site'); } JCommentsRedirect($link); }
function feedLastCommentsGlobal() { global $mainframe; $object_group = trim(strip_tags(JCommentsInput::getVar('object_group', ''))); $object_group = preg_replace('#[^0-9A-Za-z\\-\\_\\,\\.]#is', '', $object_group); $limit = (int) JCommentsInput::getVar('limit', 100); $config =& JCommentsFactory::getConfig(); if ($config->get('enable_rss') == '1') { $iso = explode('=', _ISO); $charset = strtolower((string) $iso[1]); if (JCOMMENTS_JVERSION == '1.5') { $offset = $mainframe->getCfg('offset'); } else { $offset = $mainframe->getCfg('offset') + date('O') / 100; } $object_group = preg_replace('#[\'\\"]#ism', '', $object_group); $og = $object_group ? '&object_group=' . $object_group : ''; $lm = $limit != 100 ? '&limit=' . $limit : ''; if (JCOMMENTS_JVERSION == '1.5') { $syndicationURL = JoomlaTuneRoute::_('index.php?option=com_jcomments&task=rss_full' . $og . $lm . '&tmpl=component'); } else { $syndicationURL = $mainframe->getCfg('live_site') . '/index2.php?option=com_jcomments&task=rss_full' . $og . $lm . '&no_html=1'; } $rss = new JoomlaTuneFeed(); $rss->setOffset($offset); $rss->encoding = $charset; $rss->title = JText::_('Comments'); $rss->link = $mainframe->getCfg('live_site'); $rss->syndicationURL = $syndicationURL; $rss->description = JText::_('COMMENTS_FOR') . ' ' . $mainframe->getCfg('sitename'); if ($object_group != '') { $groups = explode(',', $object_group); } else { $groups = array(); } $db =& JCommentsFactory::getDBO(); $query = "SELECT id, title, object_id, object_group, userid, name, username, date, UNIX_TIMESTAMP(date) as date_ts, comment" . "\nFROM #__jcomments " . "\nWHERE published = '1'" . (count($groups) > 0 ? "\n AND (object_group = '" . implode("' OR object_group='", $groups) . "')" : '') . (JCommentsMultilingual::isEnabled() ? "\nAND lang = '" . JCommentsMultilingual::getLanguage() . "'" : "") . "\nORDER BY date DESC"; $db->setQuery($query, 0, $limit); $rows = $db->loadObjectList(); $word_maxlength = $config->getInt('word_maxlength'); $lang = JCommentsMultilingual::isEnabled() ? JCommentsMultilingual::getLanguage() : null; foreach ($rows as $row) { $comment = JCommentsText::cleanText($row->comment); $author = JComments::getCommentAuthorName($row); if ($comment != '') { $object_title = JCommentsObjectHelper::getTitle($row->object_id, $row->object_group, $lang); $object_link = JCommentsObjectHelper::getLink($row->object_id, $row->object_group); $object_link = str_replace('amp;', '', $object_link); $object_link = JCommentsFactory::getAbsLink($object_link); // apply censor filter $object_title = JCommentsText::censor($object_title); $comment = JCommentsText::censor($comment); // fix long words problem if ($word_maxlength > 0) { $comment = JCommentsText::fixLongWords($comment, $word_maxlength, ' '); if ($comment != '') { $comment = JCommentsText::fixLongWords($comment, $word_maxlength, ' '); } } $item = new JoomlaTuneFeedItem(); $item->title = $object_title; $item->link = $object_link . '#comment-' . $row->id; $item->description = $author . ' ' . JText::_('Wrote') . ' "' . $comment . '"'; $item->source = $object_link; if (JCOMMENTS_JVERSION == '1.5') { $item->pubDate = $row->date; } else { $date = strtotime((string) $row->date) - $offset * 3600; $item->pubDate = date('Y-m-d H:i:s', $date); } $item->author = $author; $rss->addItem($item); } } $rss->display(); unset($rows, $rss); exit; } }
/** * Returns a reference to the global {@link JoomlaTuneTemplateRender} object, only creating it if it does not already exist. * * @param int $object_id * @param string $object_group * @param bool $needThisUrl * * @return JoomlaTuneTemplateRender */ public static function getTemplate($object_id = 0, $object_group = 'com_content', $needThisUrl = true) { global $Itemid; ob_start(); $app = JFactory::getApplication(); $language = JFactory::getLanguage(); $config = JCommentsFactory::getConfig(); $templateName = $config->get('template'); if (empty($templateName)) { $templateName = 'default'; $config->set('template', $templateName); } include_once JCOMMENTS_LIBRARIES . '/joomlatune/template.php'; $templateDefaultDirectory = JCOMMENTS_SITE . '/tpl/' . $templateName; $templateDirectory = $templateDefaultDirectory; $templateUrl = JURI::root() . 'components/com_jcomments/tpl/' . $templateName; $templateOverride = JPATH_SITE . '/templates/' . $app->getTemplate() . '/html/com_jcomments/' . $templateName; if (is_dir($templateOverride)) { $templateDirectory = $templateOverride; $templateUrl = JURI::root() . 'templates/' . $app->getTemplate() . '/html/com_jcomments/' . $templateName; } $tmpl = JoomlaTuneTemplateRender::getInstance(); $tmpl->setRoot($templateDirectory); $tmpl->setDefaultRoot($templateDefaultDirectory); $tmpl->setBaseURI($templateUrl); $tmpl->addGlobalVar('siteurl', JURI::root()); $tmpl->addGlobalVar('charset', 'utf-8'); $tmpl->addGlobalVar('ajaxurl', JCommentsFactory::getLink('ajax', $object_id, $object_group)); $tmpl->addGlobalVar('smilesurl', JCommentsFactory::getLink('smilies', $object_id, $object_group)); if ($config->getInt('enable_rss') == 1) { $tmpl->addGlobalVar('rssurl', JCommentsFactory::getLink('rss', $object_id, $object_group)); } $tmpl->addGlobalVar('template', $templateName); $tmpl->addGlobalVar('template_url', $templateUrl); $tmpl->addGlobalVar('itemid', $Itemid ? $Itemid : 1); $tmpl->addGlobalVar('direction', $language->isRTL() ? 'rtl' : 'ltr'); $lang = $language->getTag(); $domain = $lang == 'ru-RU' || $lang == 'uk-UA' || $lang == 'be-BY' ? 'ru' : 'com'; $tmpl->addGlobalVar('comment-object_id', $object_id); $tmpl->addGlobalVar('comment-object_group', $object_group); if ($needThisUrl == true) { $tmpl->addGlobalVar('thisurl', JCommentsObjectHelper::getLink($object_id, $object_group, $lang)); } ob_end_clean(); return $tmpl; }
public static function showUserComments() { $config = JCommentsFactory::getConfig(); if ($config->get('enable_rss') == '1') { $app = JCommentsFactory::getApplication('site'); $acl = JCommentsFactory::getACL(); $userid = (int) JCommentsInput::getVar('userid', 0); $limit = (int) JCommentsInput::getVar('limit', $config->getInt('feed_limit', 100)); $user = JCommentsFactory::getUser($userid); if (!isset($user->id)) { self::showNotFound(); return; } if (JCOMMENTS_JVERSION == '1.0') { $offset = $app->getCfg('offset') + date('O') / 100; } else { $offset = $app->getCfg('offset'); } $lm = $limit != $config->getInt('feed_limit') ? '&limit=' . $limit : ''; if (JCommentsMultilingual::isEnabled()) { $language = JCommentsMultilingual::getLanguage(); $lp = '&lang=' . $language; } else { $language = null; $lp = ''; } if (JCOMMENTS_JVERSION == '1.0') { $syndicationURL = $app->getCfg('live_site') . '/index2.php?option=com_jcomments&task=rss_user&userid=' . $userid . $lm . $lp . '&no_html=1'; } else { $liveSite = str_replace(JURI::root(true), '', $app->getCfg('live_site')); $syndicationURL = $liveSite . JRoute::_('index.php?option=com_jcomments&task=rss_user&userid=' . $userid . $lm . $lp . '&tmpl=raw'); } $user->userid = $user->id; $username = JComments::getCommentAuthorName($user); $rss = new JoomlaTuneFeed(); $rss->setOffset($offset); $rss->encoding = JCOMMENTS_ENCODING; $rss->title = JText::sprintf('USER_FEED_TITLE', $username); $rss->link = $app->getCfg('live_site'); $rss->syndicationURL = $syndicationURL; $rss->description = JText::sprintf('USER_FEED_DESCRIPTION', $username); $options = array(); $options['lang'] = $language; $options['userid'] = $userid; $options['published'] = 1; $options['filter'] = 'c.deleted = 0'; $options['orderBy'] = 'c.date DESC'; $options['votes'] = false; $options['limit'] = $limit; $options['limitStart'] = 0; $options['objectinfo'] = true; $options['access'] = $acl->getUserAccess(); $rows = JCommentsModel::getCommentsList($options); $word_maxlength = $config->getInt('word_maxlength'); $lang = JCommentsMultilingual::isEnabled() ? JCommentsMultilingual::getLanguage() : null; foreach ($rows as $row) { $comment = JCommentsText::cleanText($row->comment); if ($comment != '') { // getting object's information (title and link) $object_title = empty($row->object_title) ? JCommentsObjectHelper::getTitle($row->object_id, $row->object_group, $lang) : $row->object_title; $object_link = empty($row->object_link) ? JCommentsObjectHelper::getLink($row->object_id, $row->object_group, $lang) : $row->object_link; $object_link = JCommentsFactory::getAbsLink(str_replace('amp;', '', $object_link)); // apply censor filter $object_title = JCommentsText::censor($object_title); $comment = JCommentsText::censor($comment); // fix long words problem if ($word_maxlength > 0) { $comment = JCommentsText::fixLongWords($comment, $word_maxlength, ' '); if ($object_title != '') { $object_title = JCommentsText::fixLongWords($object_title, $word_maxlength, ' '); } } $author = JComments::getCommentAuthorName($row); $item = new JoomlaTuneFeedItem(); $item->title = $object_title; $item->link = $object_link . '#comment-' . $row->id; $item->description = JText::sprintf('USER_FEED_ITEM_DESCRIPTION', $author, $comment); $item->source = $object_link; if (JCOMMENTS_JVERSION == '1.0') { $date = strtotime((string) $row->date) - $offset * 3600; $item->pubDate = date('Y-m-d H:i:s', $date); } else { $item->pubDate = $row->date; } $item->author = $author; $rss->addItem($item); } } $rss->display(); unset($rows, $rss); exit; } }
function redirectToObject() { global $mainframe; $object_id = (int) JCommentsInput::getVar('object_id', 0); $object_group = trim(strip_tags(JCommentsInput::getVar('object_group', 'com_content'))); if ($object_id != 0 && $object_group != '') { $link = JCommentsObjectHelper::getLink($object_id, $object_group); $link = str_replace('amp;', '', $link); if ($link == '') { $link = $mainframe->getCfg('live_site'); } } else { $link = $mainframe->getCfg('live_site'); } JCommentsRedirect($link); }