public function save() { JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $app = JFactory::getApplication(); $base64 = $app->input->get('base64', ''); if (!empty($base64)) { $base64 = base64_decode(urldecode($base64)); parse_str($base64, $data); foreach ($data as $k => $v) { $app->input->post->set($k, $v); } } $model = $this->getModel(); $data = $app->input->post->get('jform', array(), 'array'); $language = $app->input->post->get('language', '', 'string'); $model->setState($model->getName() . '.language', $language); if ($model->save($data) === false) { $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_SAVE_FAILED', $model->getError())); $this->setMessage($this->getError(), 'error'); $this->setRedirect(JRoute::_('index.php?option=com_jcomments&view=settings', false)); return false; } if (!extension_loaded('gd') || !function_exists('imagecreatefrompng')) { $config = JCommentsFactory::getConfig(); if ($config->get('captcha_engine', 'kcaptcha') != 'recaptcha') { JFactory::getApplication()->enqueueMessage(JText::_('A_WARNINGS_PHP_GD'), 'warning'); } } $cache = JFactory::getCache('com_jcomments'); $cache->clean(); $this->setMessage(JText::_('A_SETTINGS_SAVED')); $this->setRedirect(JRoute::_('index.php?option=com_jcomments&view=settings', false)); return true; }
/** * Set Jcomments config for the actual product, and the value of $comments_enabled * * @author Florian Voutzinos * @param object $product virtuemart product object * @param array $excludedCatIds Ids of excluded category from plugin params * @return void */ public static function applyConfig($product, $excludedCatIds) { $config = JCommentsFactory::getConfig(); // {Jcomments} tag domines Excluded categories ! // and {Jcomments OFF} domines everything // if {Jcomments OFF} tag found we disable comments by force if (self::isDisabled($product)) { $config->set('comments_on', 0); $config->set('comments_off', 1); self::$comments_enabled = false; } elseif (self::isEnabled($product)) { $config->set('comments_on', 1); $config->set('comments_off', 0); self::$comments_enabled = true; } else { // we enable comments if the product category is enabled if (self::isCategoryProductEnabled($product, $excludedCatIds)) { $config->set('comments_on', 1); $config->set('comments_off', 0); self::$comments_enabled = true; } else { $config->set('comments_on', 0); $config->set('comments_off', 1); self::$comments_enabled = false; } } $config->set('comments_locked', (int) self::isLocked($product)); }
public static function getList($params) { $db = JFactory::getDBO(); $db->setQuery("SELECT * FROM #__jcomments ORDER BY date DESC", 0, $params->get('count')); $items = $db->loadObjectList(); if (!is_array($items)) { $items = array(); } if (count($items)) { $config = JCommentsFactory::getConfig(); $bbcode = JCommentsFactory::getBBCode(); $limit_comment_text = (int) $params->get('limit_comment_text', 0); foreach ($items as &$item) { $item->link = 'index.php?option=com_jcomments&&view=comment&layout=edit&id=' . $item->id; $item->author = JComments::getCommentAuthorName($item); $text = JCommentsText::censor($item->comment); $text = $bbcode->filter($text, true); $text = JCommentsText::cleanText($text); if ($limit_comment_text && JString::strlen($text) > $limit_comment_text) { $text = self::truncateText($text, $limit_comment_text - 1); } $item->comment = $text; } } return $items; }
public static function isEnabled() { static $enabled = null; if (!isset($enabled)) { $app = JFactory::getApplication(); if ($app->isSite()) { $enabled = $app->getLanguageFilter(); } else { $db = JFactory::getDBO(); $query = $db->getQuery(true); $query->select('enabled'); $query->from($db->quoteName('#__extensions')); $query->where($db->quoteName('type') . ' = ' . $db->quote('plugin')); $query->where($db->quoteName('folder') . ' = ' . $db->quote('system')); $query->where($db->quoteName('element') . ' = ' . $db->quote('languagefilter')); $db->setQuery($query); $enabled = $db->loadResult(); } JFactory::getConfig()->set('multilingual_support', $enabled); if ($enabled) { $enabled = JCommentsFactory::getConfig()->get('multilingual_support', $enabled); } } return $enabled; }
public static function check($str) { static $group = null; $str = JCommentsFactory::getConfig()->get($str); if (!empty($str)) { $user = JFactory::getUser(); $list = explode(',', $str); if ($group === null) { if ($user->id) { $db = JFactory::getDbo(); // get highest group $query = $db->getQuery(true); $query->select('a.id'); $query->from('#__user_usergroup_map AS map'); $query->leftJoin('#__usergroups AS a ON a.id = map.group_id'); $query->where('map.user_id = ' . (int) $user->id); $query->order('a.lft desc'); $db->setQuery($query, 0, 1); $group = $db->loadResult(); } else { $group = JComponentHelper::getParams('com_users')->get('guest_usergroup', 1); } } if (in_array($group, $list)) { return 1; } } return 0; }
public static function getSmiliesPath() { $config = JCommentsFactory::getConfig(); $smiliesPath = $config->get('smilies_path', 'components/com_jcomments/images/smilies/'); $smiliesPath = str_replace(array('//', '\\\\'), '/', $smiliesPath); $smiliesPath = trim($smiliesPath, '\\/') . '/'; return $smiliesPath; }
function CategoryViewsTime($name, $reason = '') { global $mainframe, $my; $config =& JCommentsFactory::getConfig(); if ($config->get('CategoryGet') != '') { $object = new stdClass(); $object->object_cat = CategoryFactory::getAbs($object->object_cat); $commentText = $comment->comment; } }
public function JCommentsPagination($object_id, $object_group) { $config = JCommentsFactory::getConfig(); $this->commentsPerPage = $config->getInt('comments_per_page'); $this->commentsPageLimit = $config->getInt('comments_page_limit'); $this->commentsOrder = $config->get('comments_order'); if ($this->commentsPerPage > 0) { $this->setCommentsCount(JComments::getCommentsCount($object_id, $object_group)); } }
public static function checkIsRegisteredEmail($email) { $config = JCommentsFactory::getConfig(); if ($config->getInt('enable_username_check') == 1) { $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('COUNT(*)'); $query->from($db->quoteName('#__users')); $query->where($db->quoteName('email') . ' = ' . $db->Quote($db->escape($email, true))); $db->setQuery($query); return $db->loadResult() == 0 ? 0 : 1; } return 0; }
/** * Triggers an event by dispatching arguments to all observers that handle * the event and returning their return values. * * @param string $event The event name * @param array $args An array of arguments * @return array An array of results from each function call */ public static function trigger($event, $args = null) { static $pluginsLoaded = false; $result = array(); $config = JCommentsFactory::getConfig(); if ($config->getInt('enable_mambots') == 1) { if (!$pluginsLoaded) { JPluginHelper::importPlugin('jcomments'); $pluginsLoaded = true; } $dispatcher = JDispatcher::getInstance(); $result = $dispatcher->trigger($event, $args); } return $result; }
function getCommentsList($object_id, $object_group = 'com_content', $limitStart = 0, $limit = 0) { $acl =& JCommentsFactory::getACL(); $db =& JCommentsFactory::getDBO(); $config =& JCommentsFactory::getConfig(); $options['object_id'] = (int) $object_id; $options['object_group'] = trim($object_group); $options['published'] = $acl->canPublish() ? null : 1; $options['orderBy'] = $config->get('template_view') == 'tree' ? 'c.parent, c.date ASC' : 'c.date ' . $config->get('comments_order'); $options['limit'] = $limit; $options['limitStart'] = $limitStart; $db->setQuery(JCommentsModel::_getCommentsQuery($options)); $rows = $db->loadObjectList(); return $rows; }
/** * Triggers an event by dispatching arguments to all observers that handle * the event and returning their return values. * * @param string $event The event name * @param array $args An array of arguments * @return array An array of results from each function call */ public static function trigger($event, $args = null) { static $initialised = false; $result = array(); if (JCommentsFactory::getConfig()->getInt('enable_plugins') == 1) { if (!$initialised) { JPluginHelper::importPlugin('jcomments'); $initialised = true; } if (version_compare(JVERSION, '3.0', 'ge')) { $dispatcher = JEventDispatcher::getInstance(); } else { $dispatcher = JDispatcher::getInstance(); } $result = $dispatcher->trigger($event, $args); } return $result; }
public static function show() { $app = JCommentsFactory::getApplication('administrator'); $config = JCommentsFactory::getConfig(); if ($config->getInt('enable_blacklist') == 0) { if (JCOMMENTS_JVERSION != '1.0') { JError::raiseWarning(500, JText::_('A_BLACKLIST_WARNING_BLACKLIST_IS_DISABLED')); } } $context = 'com_jcomments.blacklist.'; $limit = intval($app->getUserStateFromRequest($context . 'limit', 'limit', $app->getCfg('list_limit'))); $limitstart = intval($app->getUserStateFromRequest($context . 'limitstart', 'limitstart', 0)); $filter_order = $app->getUserStateFromRequest($context . 'filter_order', 'filter_order', 'bl.created'); $filter_order_Dir = $app->getUserStateFromRequest($context . 'filter_order_Dir', 'filter_order_Dir', 'desc'); $search = trim($app->getUserStateFromRequest($context . 'search', 'search', '')); if (JCOMMENTS_JVERSION == '1.0') { $search = strtolower($search); } else { $search = JString::strtolower($search); } if ($filter_order == '') { $filter_order = 'bl.created'; } if ($filter_order_Dir == '') { $filter_order_Dir = 'desc'; } $lists['order'] = $filter_order; $lists['order_Dir'] = $filter_order_Dir; $lists['search'] = $search; $db = JCommentsFactory::getDBO(); $where = array(); if ($search != '') { $where[] = '(LOWER(bl.ip) like "%' . $db->getEscaped($search, true) . '%")' . ' OR LOWER(bl.reason) like "%' . $db->getEscaped($search, true) . '%"' . ' OR LOWER(bl.notes) like "%' . $db->getEscaped($search, true) . '%"'; } $query = "SELECT COUNT(*)" . " FROM #__jcomments_blacklist AS bl" . (count($where) ? " WHERE " . implode(' AND ', $where) : ""); $db->setQuery($query); $total = $db->loadResult(); $lists['pageNav'] = JCommentsAdmin::getPagination($total, $limitstart, $limit); $query = "SELECT bl.*, u.name AS editor" . " FROM #__jcomments_blacklist AS bl" . " LEFT JOIN #__users AS u ON u.id = bl.checked_out" . (count($where) ? " WHERE " . implode(' AND ', $where) : "") . " ORDER BY " . $filter_order . ' ' . $filter_order_Dir; $db->setQuery($query, $lists['pageNav']->limitstart, $lists['pageNav']->limit); $lists['rows'] = $db->loadObjectList(); HTML_JCommentsAdminBlacklistManager::show($lists); }
public function __construct() { if (count($this->_replacements) == 0) { $config = JCommentsFactory::getConfig(); $path = JUri::root(true) . '/' . trim(str_replace('\\', '/', $config->get('smilies_path')), '/') . '/'; $smilies = $config->get('smilies'); if (!empty($smilies)) { $values = explode("\n", $smilies); foreach ($values as $value) { list($code, $image) = explode("\t", $value); $this->_smilies[$code] = $image; } } $list = $this->_smilies; uksort($list, array($this, 'compare')); foreach ($list as $code => $image) { $this->_replacements['code'][] = '#(^|\\s|\\n|\\r|\\>)(' . preg_quote($code, '#') . ')(\\s|\\n|\\r|\\<|$)#ismu'; $this->_replacements['icon'][] = '\\1 \\2 \\3'; $this->_replacements['code'][] = '#(^|\\s|\\n|\\r|\\>)(' . preg_quote($code, '#') . ')(\\s|\\n|\\r|\\<|$)#ismu'; $this->_replacements['icon'][] = '\\1<img src="' . $path . $image . '" alt="' . htmlspecialchars($code) . '" />\\3'; } } }
/** * Returns default order for comments list * * @return string */ protected static function _getDefaultOrder() { $config = JCommentsFactory::getConfig(); if ($config->get('template_view') == 'tree') { switch ($config->getInt('comments_tree_order')) { case 2: $result = 'threadDate DESC, c.date ASC'; break; case 1: $result = 'c.parent, c.date DESC'; break; default: $result = 'c.parent, c.date ASC'; break; } } else { $result = 'c.date ' . $config->get('comments_list_order'); } return $result; }
public static function isEnabled() { static $enabled = null; if (!isset($enabled)) { $app = JCommentsFactory::getApplication(); $enabled = $app->getCfg('multilingual_support') == 1; if (JCOMMENTS_JVERSION == '1.7') { if ($app->isSite()) { $enabled = $app->getLanguageFilter(); } else { $db = JFactory::getDBO(); $db->setQuery("SELECT COUNT(*) FROM `#__extensions` WHERE `element` = 'languagefilter' AND `enabled` = 1"); $enabled = $db->loadResult() > 0; } } // check if multilingual_support if ($enabled) { $config = JCommentsFactory::getConfig(); $enabled = $config->get('multilingual_support', $enabled); } } return $enabled; }
public function store($updateNulls = false) { $config = JCommentsFactory::getConfig(); $app = JFactory::getApplication(); if ($app->isAdmin()) { $language = JFactory::getLanguage(); $language->load('com_jcomments', JPATH_SITE); if ($this->id == 0 && !empty($this->source)) { $this->comment = $this->clearComment($this->comment); $this->homepage = strip_tags($this->homepage); $this->title = strip_tags($this->title); if (!$this->userid) { $this->name = $this->clearComment($this->name); $this->username = $this->clearComment($this->username); } } } if ($this->parent > 0) { $parent = new JCommentsTableComment($this->_db); if ($parent->load($this->parent)) { if (empty($this->title) && $config->getInt('comment_title') == 1) { if (!empty($parent->title)) { if (strpos($parent->title, JText::_('COMMENT_TITLE_RE')) === false) { $this->title = JText::_('COMMENT_TITLE_RE') . ' ' . $parent->title; } else { $this->title = $parent->title; } } } $this->thread_id = $parent->thread_id ? $parent->thread_id : $parent->id; $this->level = $parent->level + 1; $this->path = $parent->path . ',' . $parent->id; } } else { if (empty($this->title) && $config->getInt('comment_title') == 1) { $title = JCommentsObjectHelper::getTitle($this->object_id, $this->object_group, $this->lang); if (!empty($title)) { $this->title = JText::_('COMMENT_TITLE_RE') . ' ' . $title; } } $this->path = '0'; } if (isset($this->datetime)) { unset($this->datetime); } if (isset($this->author)) { unset($this->author); } return parent::store($updateNulls); }
function onAfterDisplayContent(&$article, &$params, $limitstart = 0) { if ($this->params->get('show_comments_event', 'onAfterDisplayContent') == 'onAfterDisplayContent') { require_once (JCOMMENTS_HELPERS . '/content.php'); $view = JRequest::getCmd('view'); // check whether plugin has been unpublished if (!JPluginHelper::isEnabled('content', 'jcomments') || ($view != 'article') || $params->get('intro_only') || $params->get('popup') || JRequest::getBool('fullview') || JRequest::getVar('print')) { JCommentsContentPluginHelper::clear($article, true); return ''; } require_once (JCOMMENTS_BASE . '/jcomments.php'); $config = JCommentsFactory::getConfig(); $isEnabled = ($config->getInt('comments_on', 0) == 1) && ($config->getInt('comments_off', 0) == 0); if ($isEnabled && $view == 'article') { JCommentsContentPluginHelper::clear($article, true); return JComments::show($article->id, 'com_content', $article->title); } } return ''; }
function getCommentsTree($object_id, $object_group = 'com_content', $search_text = '') { global $my; $object_id = (int) $object_id; $object_group = trim($object_group); $acl =& JCommentsFactory::getACL(); $dbo =& JCommentsFactory::getDBO(); $config =& JCommentsFactory::getConfig(); $canPublish = $acl->canPublish(); $canComment = $acl->canComment(); $where = ''; if ($search_text) { $words = explode(' ', $search_text); $wheres = array(); foreach ($words as $word) { $wheres2 = array(); $wheres2[] = "LOWER(name) LIKE '%{$word}%'"; $wheres2[] = "LOWER(comment) LIKE '%{$word}%'"; } if (isset($wheres2) && count($wheres2)) { $where .= ' AND ('; $where .= implode(' OR ', $wheres2); $where .= ' )'; } } if ($canComment == 0) { $total = JLMS_JComments::getCommentsCount($object_id, $object_group, $where); if ($total == 0) { return ''; } } $query = "SELECT c.id, c.parent, c.object_id, c.object_group, c.userid, c.name, c.username, c.title, c.comment" . "\n , c.email, c.homepage, c.date as datetime, c.ip, c.published, c.checked_out, c.checked_out_time" . "\n , c.isgood, c.ispoor" . "\n , v.value as voted" . "\n FROM #__jcomments AS c" . "\n LEFT JOIN #__jcomments_votes AS v ON c.id = v.commentid " . ($my->id ? " AND v.userid = " . $my->id : " AND v.ip = '" . $acl->getUserIP() . "'") . "\n WHERE c.object_id = " . $object_id . "\n AND c.object_group = '" . $object_group . "'" . (JCommentsMultilingual::isEnabled() ? "\nAND c.lang = '" . JCommentsMultilingual::getLanguage() . "'" : "") . ($canPublish == 0 ? "\nAND c.published = 1" : "") . $where . "\n ORDER BY c.parent, c.date ASC"; $dbo->setQuery($query); $rows = $dbo->loadObjectList(); $tmpl =& JCommentsFactory::getTemplate($object_id, $object_group); $tmpl->load('tpl_tree'); $tmpl->load('tpl_comment'); if (count($rows)) { $isLocked = $config->getInt('object_locked', 0) == 1; $tmpl->addVar('tpl_tree', 'comments-refresh', intval(!$isLocked)); $tmpl->addVar('tpl_tree', 'comments-rss', intval($config->getInt('enable_rss') && !$isLocked)); $tmpl->addVar('tpl_tree', 'comments-can-subscribe', intval($my->id && $acl->check('enable_subscribe') && !$isLocked)); if ($my->id && $acl->check('enable_subscribe')) { require_once JCOMMENTS_BASE . DS . 'jcomments.subscription.php'; $manager =& JCommentsSubscriptionManager::getInstance(); $isSubscribed = $manager->isSubscribed($object_id, $object_group, $my->id); $tmpl->addVar('tpl_tree', 'comments-user-subscribed', $isSubscribed); } $i = 1; if ($config->getInt('enable_mambots') == 1) { require_once JCOMMENTS_HELPERS . DS . 'plugin.php'; JCommentsPluginHelper::importPlugin('jcomments'); JCommentsPluginHelper::trigger('onBeforeDisplayCommentsList', array(&$rows)); if ($acl->check('enable_gravatar')) { JCommentsPluginHelper::trigger('onPrepareAvatars', array(&$rows)); } } require_once JCOMMENTS_LIBRARIES . DS . 'joomlatune' . DS . 'tree.php'; $tree = new JoomlaTuneTree($rows); $items = $tree->get(); foreach ($rows as $row) { if ($config->getInt('enable_mambots') == 1) { JCommentsPluginHelper::trigger('onBeforeDisplayComment', array(&$row)); } // run autocensor, replace quotes, smiles and other pre-view processing JComments::prepareComment($row); // setup toolbar if (!$acl->canModerate($row)) { $tmpl->addVar('tpl_comment', 'comments-panel-visible', 0); } else { $tmpl->addVar('tpl_comment', 'comments-panel-visible', 1); $tmpl->addVar('tpl_comment', 'button-edit', $acl->canEdit($row)); $tmpl->addVar('tpl_comment', 'button-delete', $acl->canDelete($row)); $tmpl->addVar('tpl_comment', 'button-publish', $acl->canPublish($row)); $tmpl->addVar('tpl_comment', 'button-ip', $acl->canViewIP($row)); } $tmpl->addVar('tpl_comment', 'comment-show-vote', $config->getInt('enable_voting')); $tmpl->addVar('tpl_comment', 'comment-show-email', $acl->canViewEmail($row)); $tmpl->addVar('tpl_comment', 'comment-show-homepage', $acl->canViewHomepage($row)); $tmpl->addVar('tpl_comment', 'comment-show-title', $config->getInt('comment_title')); $tmpl->addVar('tpl_comment', 'button-vote', $acl->canVote($row)); $tmpl->addVar('tpl_comment', 'button-quote', $acl->canQuote($row)); $tmpl->addVar('tpl_comment', 'button-reply', $acl->canReply($row)); $tmpl->addVar('tpl_comment', 'avatar', $acl->check('enable_gravatar')); if (isset($items[$row->id])) { $tmpl->addVar('tpl_comment', 'comment-number', ''); $tmpl->addObject('tpl_comment', 'comment', $row); $items[$row->id]->html = $tmpl->renderTemplate('tpl_comment'); $i++; } } $tmpl->addObject('tpl_tree', 'comments-items', $items); unset($rows); } return $tmpl->renderTemplate('tpl_tree'); }
function replace($str) { ob_start(); $config = JCommentsFactory::getConfig(); $patterns = array(); $replacements = array(); // B $patterns[] = '/\\[b\\](.*?)\\[\\/b\\]/iu'; $replacements[] = '<strong>\\1</strong>'; // I $patterns[] = '/\\[i\\](.*?)\\[\\/i\\]/iu'; $replacements[] = '<em>\\1</em>'; // U $patterns[] = '/\\[u\\](.*?)\\[\\/u\\]/iu'; $replacements[] = '<u>\\1</u>'; // S $patterns[] = '/\\[s\\](.*?)\\[\\/s\\]/iu'; $replacements[] = '<del>\\1</del>'; // SUP $patterns[] = '/\\[sup\\](.*?)\\[\\/sup\\]/iu'; $replacements[] = '<sup>\\1</sup>'; // SUB $patterns[] = '/\\[sub\\](.*?)\\[\\/sub\\]/iu'; $replacements[] = '<sub>\\1</sub>'; // URL (local) $liveSite = JURI::base(); $patterns[] = '#\\[url\\](' . preg_quote($liveSite, '#') . '[^\\s<\\"\']*?)\\[\\/url\\]#iu'; $replacements[] = '<a href="\\1" target="_blank">\\1</a>'; $patterns[] = '#\\[url=(' . preg_quote($liveSite, '#') . '[^\\s<\\"\'\\]]*?)\\](.*?)\\[\\/url\\]#iu'; $replacements[] = '<a href="\\1" target="_blank">\\2</a>'; $patterns[] = '/\\[url=(\\#|\\/)([^\\s<\\"\'\\]]*?)\\](.*?)\\[\\/url\\]/iu'; $replacements[] = '<a href="\\1\\2" target="_blank">\\3</a>'; // URL (external) $patterns[] = '#\\[url\\](http:\\/\\/)?([^\\s<\\"\']*?)\\[\\/url\\]#iu'; $replacements[] = '<a href="http://\\2" rel="external nofollow" target="_blank">\\2</a>'; $patterns[] = '/\\[url=([a-z]*\\:\\/\\/)([^\\s<\\"\'\\]]*?)\\](.*?)\\[\\/url\\]/iu'; $replacements[] = '<a href="\\1\\2" rel="external nofollow" target="_blank">\\3</a>'; $patterns[] = '/\\[url=([^\\s<\\"\'\\]]*?)\\](.*?)\\[\\/url\\]/iu'; $replacements[] = '<a href="http://\\1" rel="external nofollow" target="_blank">\\2</a>'; $patterns[] = '#\\[url\\](.*?)\\[\\/url\\]#iu'; $replacements[] = '\\1'; // EMAIL $patterns[] = '#\\[email\\]([^\\s\\<\\>\\(\\)\\"\'\\[\\]]*?)\\[\\/email\\]#iu'; $replacements[] = '\\1'; // IMG $patterns[] = '#\\[img\\](http:\\/\\/)?([^\\s\\<\\>\\(\\)\\"\']*?)\\[\\/img\\]#iu'; $replacements[] = '<img class="img" src="http://\\2" alt="" border="0" />'; $patterns[] = '#\\[img\\](.*?)\\[\\/img\\]#iu'; $replacements[] = '\\1'; // HIDE $patterns[] = '/\\[hide\\](.*?)\\[\\/hide\\]/iu'; $user = JFactory::getUser(); if ($user->id) { $replacements[] = '\\1'; } else { $replacements[] = '<span class="hidden">' . JText::_('BBCODE_MESSAGE_HIDDEN_TEXT') . '</span>'; } // CODE $geshiEnabled = $config->getInt('enable_geshi', 0); $codePattern = '#\\[code\\=?([a-z0-9]*?)\\](.*?)\\[\\/code\\]#ismu'; $geshiLibrary = JPATH_SITE . '/plugins/content/geshi/geshi/geshi.php'; $geshiEnabled = $geshiEnabled && is_file($geshiLibrary); if ($geshiEnabled) { require_once $geshiLibrary; if (!function_exists('jcommentsProcessGeSHi')) { function jcommentsProcessGeSHi($matches) { $lang = $matches[1] != '' ? $matches[1] : 'php'; $text = $matches[2]; $html_entities_match = array('#\\<br \\/\\>#', "#<#", "#>#", "|'|", '#"#', '# #'); $html_entities_replace = array("\n", '<', '>', "'", '"', ' '); $text = preg_replace($html_entities_match, $html_entities_replace, $text); $text = preg_replace('#(\\r|\\n)*?$#ism', '', $text); $text = str_replace('<', '<', $text); $text = str_replace('>', '>', $text); $geshi = new GeSHi($text, $lang); $text = $geshi->parse_code(); return '[code]' . $text . '[/code]'; } } $patterns[] = $codePattern; $replacements[] = '<span class="code">' . JText::_('COMMENT_TEXT_CODE') . '</span>\\2'; $str = preg_replace_callback($codePattern, 'jcommentsProcessGeSHi', $str); } else { $patterns[] = $codePattern; $replacements[] = '<span class="code">' . JText::_('COMMENT_TEXT_CODE') . '</span><code>\\2</code>'; if (!function_exists('jcommentsProcessCode')) { function jcommentsProcessCode($matches) { $text = htmlspecialchars(trim($matches[0])); $text = str_replace("\r", '', $text); $text = str_replace("\n", '<br />', $text); return $text; } } $str = preg_replace_callback($codePattern, 'jcommentsProcessCode', $str); } $str = preg_replace($patterns, $replacements, $str); // QUOTE $quotePattern = '#\\[quote\\s?name=\\"([^\\"\'\\<\\>\\(\\)]*?)\\"\\](<br\\s?\\/?\\>)*?(.*?)(<br\\s?\\/?\\>)*\\[\\/quote\\](<br\\s?\\/?\\>)*?#ismu'; $quoteReplace = '<span class="quote">' . JText::sprintf('COMMENT_TEXT_QUOTE_EXTENDED', '\\1') . '</span><blockquote><div>\\3</div></blockquote>'; while (preg_match($quotePattern, $str)) { $str = preg_replace($quotePattern, $quoteReplace, $str); } $quotePattern = '#\\[quote[^\\]]*?\\](<br\\s?\\/?\\>)*([^\\[]+)(<br\\s?\\/?\\>)*\\[\\/quote\\](<br\\s?\\/?\\>)*?#ismUu'; $quoteReplace = '<span class="quote">' . JText::_('COMMENT_TEXT_QUOTE') . '</span><blockquote><div>\\2</div></blockquote>'; while (preg_match($quotePattern, $str)) { $str = preg_replace($quotePattern, $quoteReplace, $str); } // LIST $matches = array(); $matchCount = preg_match_all('#\\[list\\](<br\\s?\\/?\\>)*(.*?)(<br\\s?\\/?\\>)*\\[\\/list\\]#iu', $str, $matches); for ($i = 0; $i < $matchCount; $i++) { $textBefore = preg_quote($matches[2][$i]); $textAfter = preg_replace('#(<br\\s?\\/?\\>)*\\[\\*\\](<br\\s?\\/?\\>)*#isu', "</li><li>", $matches[2][$i]); $textAfter = preg_replace('#^</?li>#u', '', $textAfter); $textAfter = str_replace("\n</li>", "</li>", $textAfter . "</li>"); $str = preg_replace('#\\[list\\](<br\\s?\\/?\\>)*' . $textBefore . '(<br\\s?\\/?\\>)*\\[/list\\]#isu', "<ul>{$textAfter}</ul>", $str); } $matches = array(); $matchCount = preg_match_all('#\\[list=(a|A|i|I|1)\\](<br\\s?\\/?\\>)*(.*?)(<br\\s?\\/?\\>)*\\[\\/list\\]#isu', $str, $matches); for ($i = 0; $i < $matchCount; $i++) { $textBefore = preg_quote($matches[3][$i]); $textAfter = preg_replace('#(<br\\s?\\/?\\>)*\\[\\*\\](<br\\s?\\/?\\>)*#isu', "</li><li>", $matches[3][$i]); $textAfter = preg_replace('#^</?li>#u', '', $textAfter); $textAfter = str_replace("\n</li>", "</li>", $textAfter . "</li>"); $str = preg_replace('#\\[list=(a|A|i|I|1)\\](<br\\s?\\/?\\>)*' . $textBefore . '(<br\\s?\\/?\\>)*\\[/list\\]#isu', "<ol type=\\1>{$textAfter}</ol>", $str); } $str = preg_replace('#\\[\\/?(b|i|u|s|sup|sub|url|img|list|quote|code|hide)\\]#iu', '', $str); ob_end_clean(); return $str; }
public static function check($str, $isName = true) { //+ FT 2015.05.09 static $groups = null; //+ FT 2015.05.09 if ($isName) { $str = JCommentsFactory::getConfig()->get($str); // felteszem: str lista azon groupokról akik a "str" akcióra jogosultak } if (!empty($str)) { $user = JFactory::getUser(); $list = explode(',', $str); // list egy tömb azon groupokról akik az adott müveletre jogosultak. //+ FT 2015.05.09 if ($groups === null) { if ($user->id) { $db = JFactory::getDbo(); // get highest group $query = $db->getQuery(true); $query->select('a.id'); $query->from('#__user_usergroup_map AS map'); $query->leftJoin('#__usergroups AS a ON a.id = map.group_id'); $query->where('map.user_id = ' . (int) $user->id); $query->order('a.lft desc'); $db->setQuery($query); // $group = $db->loadResult(); // most group egy szám a user legngyobb usergroup_id -je ÉS EZ NEM JÓ! $groups = $db->loadObjectList(); // most $groups egy tömb elmeiben $groups[$i]->id azon groupok amikbenuser tag } else { $groups = array(); $groups[0] = JComponentHelper::getParams('com_users')->get('guest_usergroup', 1); } } //if (in_array($group, $list)) { // return 1; //} $result = 0; foreach ($groups as $group) { if (in_array($group->id, $list)) { $result = 1; } } return $result; //- FT 2015.05.09 } return 0; }
public static function BanIP($id) { if (JCommentsSecurity::badRequest() == 1) { JCommentsSecurity::notAuth(); } $acl = JCommentsFactory::getACL(); $response = JCommentsFactory::getAjaxResponse(); if ($acl->canBan()) { $config = JCommentsFactory::getConfig(); if ($config->getInt('enable_blacklist') == 1) { $id = (int) $id; $db = JCommentsFactory::getDBO(); $comment = new JCommentsTableComment($db); if ($comment->load($id)) { // 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)) { $result = JCommentsEvent::trigger('onJCommentsUserBeforeBan', array(&$comment, &$options)); if (!in_array(false, $result, true)) { require_once JCOMMENTS_TABLES . '/blacklist.php'; $blacklist = new JCommentsTableBlacklist($db); $blacklist->ip = $comment->ip; $blacklist->created = JCommentsFactory::getDate(); $blacklist->created_by = $acl->getUserId(); if ($blacklist->store()) { JCommentsEvent::trigger('onJCommentsUserAfterBan', array(&$comment, $options)); self::showInfoMessage(JText::_('SUCCESSFULLY_BANNED'), 'comment-item-' . $id); } } } else { self::showErrorMessage(JText::_('ERROR_IP_ALREADY_BANNED'), '', 'comment-item-' . $id); } } else { self::showErrorMessage(JText::_('ERROR_YOU_CAN_NOT_BAN_YOUR_IP'), '', 'comment-item-' . $id); } } } } return $response; }
/** * Comments Search method * * @param string $text Target search string * @param string $phrase mathcing option, exact|any|all * @param string $ordering ordering option, newest|oldest|popular|alpha|category * @param mixed $areas An array if the search it to be restricted to areas, null if search all * @return array */ function onContentSearch($text, $phrase = '', $ordering = '', $areas = null) { $text = JString::strtolower(trim($text)); $result = array(); if ($text == '' || !defined('JCOMMENTS_JVERSION')) { return $result; } if (is_array($areas)) { if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) { return $result; } } if (file_exists(JCOMMENTS_BASE . '/jcomments.php')) { require_once JCOMMENTS_BASE . '/jcomments.php'; $db = JFactory::getDBO(); $limit = $this->params->def('search_limit', 50); switch ($phrase) { case 'exact': $text = $db->Quote('%' . $db->getEscaped($text, true) . '%', false); $wheres2[] = "LOWER(c.name) LIKE " . $text; $wheres2[] = "LOWER(c.comment) LIKE " . $text; $wheres2[] = "LOWER(c.title) LIKE " . $text; $where = '(' . implode(') OR (', $wheres2) . ')'; break; case 'all': case 'any': default: $words = explode(' ', $text); $wheres = array(); foreach ($words as $word) { $word = $db->Quote('%' . $db->getEscaped($word, true) . '%', false); $wheres2 = array(); $wheres2[] = "LOWER(c.name) LIKE " . $word; $wheres2[] = "LOWER(c.comment) LIKE " . $word; $wheres2[] = "LOWER(c.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; } $acl = JCommentsFactory::getACL(); $access = $acl->getUserAccess(); if (is_array($access)) { $accessCondition = "AND jo.access IN (" . implode(',', $access) . ")"; } else { $accessCondition = "AND jo.access <= " . (int) $access; } $query = "SELECT " . " c.comment AS text" . ", c.date AS created" . ", '2' AS browsernav" . ", '" . JText::_('PLG_SEARCH_JCOMMENTS_COMMENTS') . "' AS section" . ", '' AS href" . ", c.id" . ", jo.title AS object_title, jo.link AS object_link" . " FROM #__jcomments AS c" . " INNER JOIN #__jcomments_objects AS jo ON jo.object_id = c.object_id AND jo.object_group = c.object_group and jo.lang=c.lang" . " WHERE c.published=1" . " AND c.deleted=0" . " AND jo.link <> ''" . (JCommentsMultilingual::isEnabled() ? " AND c.lang = '" . JCommentsMultilingual::getLanguage() . "'" : "") . " AND ({$where}) " . $accessCondition . " ORDER BY c.object_id, {$order}"; $db->setQuery($query, 0, $limit); $rows = $db->loadObjectList(); $cnt = count($rows); if ($cnt > 0) { $config = JCommentsFactory::getConfig(); $enableCensor = $acl->check('enable_autocensor'); $word_maxlength = $config->getInt('word_maxlength'); for ($i = 0; $i < $cnt; $i++) { $text = JCommentsText::cleanText($rows[$i]->text); if ($enableCensor) { $text = JCommentsText::censor($text); } if ($word_maxlength > 0) { $text = JCommentsText::fixLongWords($text, $word_maxlength); } if ($text != '') { $rows[$i]->title = $rows[$i]->object_title; $rows[$i]->text = $text; $rows[$i]->href = $rows[$i]->object_link . '#comment-' . $rows[$i]->id; $result[] = $rows[$i]; } } } unset($rows); } return $result; }
function reportComment() { if (JCommentsSecurity::badRequest() == 1) { JCommentsSecurity::notAuth(); } $acl =& JCommentsFactory::getACL(); $db =& JCommentsFactory::getDBO(); $config =& JCommentsFactory::getConfig(); $response =& JCommentsFactory::getAjaxResponse(); $values = JCommentsAJAX::prepareValues($_POST); $id = (int) $values['commentid']; $reason = trim(strip_tags($values['reason'])); $name = trim(strip_tags($values['name'])); $ip = $acl->getUserIP(); if ($reason == '') { JCommentsAJAX::showErrorMessage(JText::_('Please enter the reason for your report!'), '', 'comments-report-form'); return $response; } $query = 'SELECT COUNT(*) FROM `#__jcomments_reports` WHERE commentid = ' . $id; if ($acl->getUserId()) { $query .= ' AND userid = ' . $acl->getUserId(); } else { $query .= ' AND ip = "' . $ip . '"'; } $db->setQuery($query); $reported = $db->loadResult(); if (!$reported) { $query = 'SELECT COUNT(*) FROM `#__jcomments_reports` WHERE commentid = ' . $id; $db->setQuery($query); $reported = $db->loadResult(); if (!$reported) { $comment = new JCommentsDB($db); if ($comment->load($id)) { if ($acl->canReport($comment)) { $allowed = true; if ($config->getInt('enable_mambots') == 1) { require_once JCOMMENTS_HELPERS . DS . 'plugin.php'; JCommentsPluginHelper::importPlugin('jcomments'); JCommentsPluginHelper::trigger('onReportComment', array(&$comment, &$response, &$allowed, &$value)); } if ($allowed !== false) { if ($acl->getUserId()) { $user = JCommentsFactory::getUser(); $name = $user->name; } else { if ($name == '') { $name = JText::_('Guest'); } } $query = "INSERT INTO `#__jcomments_reports`(`commentid`,`userid`, `name`,`ip`,`date`,`reason`)" . "VALUES('" . $comment->id . "', '" . $acl->getUserId() . "', '" . $db->getEscaped($name) . "', '" . $db->getEscaped($ip) . "', now(), '" . $db->getEscaped($reason) . "')"; $db->setQuery($query); $db->query(); if ($config->getInt('enable_notification') == 1) { if ($config->check('notification_type', 2)) { $comment->datetime = $comment->date; if (is_string($comment->datetime)) { $comment->datetime = strtotime($comment->datetime); } JComments::sendReport($comment, $name, $reason); } } $html = JText::_('Report successfully sent!'); $html = str_replace("\n", '\\n', $html); $html = str_replace('\\n', '<br />', $html); $html = JCommentsText::jsEscape($html); $response->addScript("jcomments.closeReport('{$html}');"); } } else { JCommentsAJAX::showErrorMessage(JText::_('You have no rights to report comment!'), '', 'comments-report-form'); } } else { $response->addAlert(JText::_('ERROR_NOT_FOUND')); } unset($comment); } else { JCommentsAJAX::showErrorMessage(JText::_('Comment already reported to the site administrator'), '', 'comments-report-form'); } } else { JCommentsAJAX::showErrorMessage(JText::_('You can\'t report the same comment more than once!'), '', 'comments-report-form'); } return $response; }
protected function populateState($ordering = null, $direction = null) { $app = JFactory::getApplication('administrator'); $config = JCommentsFactory::getConfig(); $search = $app->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); $this->setState('filter.search', $search); $state = $app->getUserStateFromRequest($this->context . '.filter.state', 'filter_state', '', 'string'); $this->setState('filter.state', $state); $object_group = $app->getUserStateFromRequest($this->context . '.filter.object_group', 'filter_object_group', ''); $this->setState('filter.object_group', $object_group); $language = $app->getUserStateFromRequest($this->context . '.filter.language', 'filter_language', ''); $this->setState('filter.language', $language); $this->setState('config.comment_title', $config->getInt('comment_title')); parent::populateState('jc.date', 'desc'); }
public static function showUserComments() { $config = JCommentsFactory::getConfig(); if ($config->get('enable_rss') == '1') { $app = JFactory::getApplication('site'); $acl = JCommentsFactory::getACL(); $userid = $app->input->getInt('userid', 0); $limit = $app->input->getInt('limit', $config->getInt('feed_limit', 100)); $user = JFactory::getUser($userid); if (!isset($user->id)) { 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_user&userid=' . $userid . $lm . $lp . '&tmpl=raw'); $user->userid = $user->id; $username = JComments::getCommentAuthorName($user); $rss = new JoomlaTuneFeed(); $rss->title = JText::sprintf('USER_FEED_TITLE', $username); $rss->link = str_replace('/administrator', '', JURI::root()); $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'); foreach ($rows as $row) { $comment = JCommentsText::cleanText($row->comment); if ($comment != '') { // getting object's information (title and link) $object_title = $row->object_title; $object_link = JCommentsFactory::getAbsLink(str_replace('amp;', '', $row->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; $item->pubDate = $row->date; $item->author = $author; $rss->addItem($item); } } $rss->display(); unset($rows, $rss); exit; } }
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 showSmiles() { $app = JCommentsFactory::getApplication('administrator'); $config = JCommentsFactory::getConfig(); require_once JCOMMENTS_LIBRARIES . '/joomlatune/filesystem.php'; $smilesPath = $config->get('smiles_path', 'components' . DS . 'com_jcomments' . DS . 'images' . DS . 'smiles' . DS); $smilesAbsPath = $app->getCfg('absolute_path') . DS . $smilesPath; $smilesAbsPath = str_replace(DS . DS, DS, $smilesAbsPath); $imageFiles = JoomlaTuneFS::readDirectory($smilesAbsPath); $lists['images'] = array(); foreach ($imageFiles as $file) { if (preg_match("/(gif|jpg|png)/i", (string) $file)) { $lists['images'][] = $file; } } $config = JCommentsFactory::getConfig(); $lists['smiles'] = $config->get('smiles'); $lists['smiles_path'] = $app->getCfg('live_site') . str_replace('//', '/', str_replace(DS, '/', $smilesPath) . '/'); HTML_JComments::showSmiles($lists); }
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; }
public function store($updateNulls = false) { $config = JCommentsFactory::getConfig(); if ($this->parent > 0) { $parent = new JCommentsTableComment($this->_db); if ($parent->load($this->parent)) { if (empty($this->title) && $config->getInt('comment_title') == 1) { if (!empty($parent->title)) { if (strpos($parent->title, JText::_('COMMENT_TITLE_RE')) === false) { $this->title = JText::_('COMMENT_TITLE_RE') . ' ' . $parent->title; } else { $this->title = $parent->title; } } } $this->thread_id = $parent->thread_id ? $parent->thread_id : $parent->id; $this->level = $parent->level + 1; $this->path = $parent->path . ',' . $parent->id; } } else { if (empty($this->title) && $config->getInt('comment_title') == 1) { $title = JCommentsObjectHelper::getTitle($this->object_id, $this->object_group, $this->lang); if (!empty($title)) { $this->title = JText::_('COMMENT_TITLE_RE') . ' ' . $title; } } $this->path = '0'; } if (isset($this->datetime)) { unset($this->datetime); } if (isset($this->author)) { unset($this->author); } return parent::store($updateNulls); }