Exemple #1
0
	function onContentBeforeDisplay($context, &$article, &$params, $page = 0)
	{
		if ($context == 'com_content.article') {
			$view = JRequest::getCmd('view');
			if ($view == 'featured') {
				if ($this->params->get('show_frontpage', 1) == 0) {
					return;
				}
			}
			
			// do not display comments in modules
			$data = $params->toArray();
			if (isset($data['moduleclass_sfx'])) {
				return;
			}

			$originalText = isset($article->text) ? $article->text : '';
			$article->text = '';
			$this->onPrepareContent($article, $params, $page);

			if (isset($article->text)) {
				if (($view == 'article') && strpos($originalText, '{jcomments}') !== false) {
					$originalText = str_replace('{jcomments}', $article->text, $originalText);
				} else {
					$article->introtext = str_replace('{jcomments}', '', $article->introtext);

					if ($this->params->get('links_position', 1) == 1) {
						$article->introtext = $article->introtext . $article->text;
					} else {
						$article->introtext = $article->text . $article->introtext;
					}
				}
			}
			
			$article->text = $originalText;
			JCommentsContentPluginHelper::clear($article);
		}
	}
Exemple #2
0
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&amp;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;
}
Exemple #3
0
 function onAfterDisplayContent(&$article, &$params, $limitstart = 0)
 {
     if ($this->params->get('show_comments_event', 'onAfterDisplayContent') == 'onAfterDisplayContent') {
         require_once JCOMMENTS_HELPERS . DS . 'content.php';
         $application =& JFactory::getApplication('site');
         $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 . DS . '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 '';
 }