Exemple #1
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 #2
0
 public static function getCommentsCount($object_id, $object_group = 'com_content', $filter = '')
 {
     $acl = JCommentsFactory::getACL();
     $options = array();
     $options['object_id'] = (int) $object_id;
     $options['object_group'] = trim($object_group);
     $options['published'] = $acl->canPublish() || $acl->canPublishForObject($object_id, $object_group) ? null : 1;
     $options['filter'] = $filter;
     return JCommentsModel::getCommentsCount($options);
 }
 function deleteComment($id)
 {
     if (JCommentsSecurity::badRequest() == 1) {
         JCommentsSecurity::notAuth();
     }
     $acl =& JCommentsFactory::getACL();
     $db =& JCommentsFactory::getDBO();
     $config =& JCommentsFactory::getConfig();
     $response =& JCommentsFactory::getAjaxResponse();
     $comment = new JCommentsDB($db);
     if ($comment->load((int) $id)) {
         if ($acl->isLocked($comment)) {
             $response->addAlert(JText::_('ERROR_BEING_EDITTED'));
         } else {
             if ($acl->canDelete($comment)) {
                 $object_id = $comment->object_id;
                 $object_group = $comment->object_group;
                 if ($config->getInt('enable_mambots') == 1) {
                     $allowed = true;
                     require_once JCOMMENTS_HELPERS . DS . 'plugin.php';
                     JCommentsPluginHelper::importPlugin('jcomments');
                     JCommentsPluginHelper::trigger('onBeforeCommentDeleted', array(&$comment, &$response, &$allowed));
                     if ($allowed === false) {
                         return $response;
                     }
                     $comment->delete();
                     JCommentsPluginHelper::trigger('onAfterCommentDeleted', array(&$comment, &$response));
                 } else {
                     $comment->delete();
                 }
                 $count = JCommentsModel::getCommentsCount($object_id, $object_group);
                 if ($count > 0) {
                     $response->addScript("jcomments.updateComment('{$id}','');");
                 } else {
                     if ($config->get('template_view') == 'tree') {
                         $response->addScript("jcomments.updateTree('',null);");
                     } else {
                         $response->addScript("jcomments.updateList('','r');");
                     }
                 }
             } else {
                 $response->addAlert(JText::_('ERROR_CANT_DELETE'));
             }
         }
     }
     unset($comment);
     return $response;
 }
 if ($separate_comments) {
     // Comments integration trigger when separate_comments in plugin is set to yes/1
     if (isset($match->team1_result)) {
         $joomleage_comments_object_group = 'com_joomleague_matchreport';
     } else {
         $joomleage_comments_object_group = 'com_joomleague_nextmatch';
     }
 } else {
     // Comments integration trigger when separate_comments in plugin is set to no/0
     $joomleage_comments_object_group = 'com_joomleague';
 }
 $options = array();
 $options['object_id'] = (int) $match->id;
 $options['object_group'] = $joomleage_comments_object_group;
 $options['published'] = 1;
 $count = JCommentsModel::getCommentsCount($options);
 if ($count == 1) {
     $imgTitle = $count . ' ' . JText::_('COM_JOOMLEAGUE_TEAMPLAN_COMMENTS_COUNT_SINGULAR');
     if ($this->config['show_comments_count'] == 1) {
         $href_text = JHTML::image(JURI::root() . 'media/com_joomleague/jl_images/discuss_active.gif', $imgTitle, array(' title' => $imgTitle, ' border' => 0, ' style' => 'vertical-align: middle'));
     } elseif ($this->config['show_comments_count'] == 2) {
         $href_text = '<span title="' . $imgTitle . '">(' . $count . ')</span>';
     }
     //Link
     if (isset($match->team1_result)) {
         $link = JoomleagueHelperRoute::getMatchReportRoute($this->project->slug, $match->id) . '#comments';
     } else {
         $link = JoomleagueHelperRoute::getNextMatchRoute($this->project->slug, $match->id) . '#comments';
     }
     $viewComment = JHTML::link($link, $href_text);
     echo $viewComment;
Exemple #5
0
	function onPrepareContent(&$article, &$params, $limitstart = 0)
	{
		require_once (JCOMMENTS_HELPERS . '/content.php');

		// check whether plugin has been unpublished
		if (!JPluginHelper::isEnabled('content', 'jcomments')) {
			JCommentsContentPluginHelper::clear($article, true);
			return '';
		}

		$app = JFactory::getApplication('site');
		$option = JRequest::getCmd('option');
		$view = JRequest::getCmd('view');

		if (!isset($article->id) || ($option != 'com_content' && $option != 'com_alphacontent' && $option != 'com_multicategories')) {
			return '';
		}

		if (!isset($params) || $params == null) {
			jimport('joomla.html.parameter');
			$params = new JParameter('');
		} else if (isset($params->_raw) && strpos($params->_raw, 'moduleclass_sfx') !== false) {
			return '';
		}

		if ($view == 'frontpage' || $view == 'featured') {
			if ($this->params->get('show_frontpage', 1) == 0) {
				return '';
			}
		}

		require_once (JCOMMENTS_BASE . '/jcomments.config.php');
		require_once (JCOMMENTS_BASE . '/jcomments.class.php');

		JCommentsContentPluginHelper::processForeignTags($article);

		$config = JCommentsFactory::getConfig();

		$categoryEnabled = JCommentsContentPluginHelper::checkCategory($article->catid);
		$commentsEnabled = JCommentsContentPluginHelper::isEnabled($article) || $categoryEnabled;
		$commentsDisabled = JCommentsContentPluginHelper::isDisabled($article) || !$commentsEnabled;
		$commentsLocked = JCommentsContentPluginHelper::isLocked($article);

		if ($article->state == -1 && $this->params->get('enable_for_archived', 0) == 0) {
			$commentsLocked = true;
		}

		$config->set('comments_on', intval($commentsEnabled));
		$config->set('comments_off', intval($commentsDisabled));
		$config->set('comments_locked', intval($commentsLocked));

		if ($view != 'article') {
			$user = JFactory::getUser();

			if (JCOMMENTS_JVERSION == '1.5') {
				$checkAccess = $article->access <= $user->get('aid', 0);
			} else {
				$authorised = JAccess::getAuthorisedViewLevels($user->get('id'));
				$checkAccess = in_array($article->access, $authorised);
			}

			if ($checkAccess) {
				require_once(JPATH_ROOT . '/components/com_content/helpers/route.php');
				if (JCOMMENTS_JVERSION == '1.5') {
					$readmore_link = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catslug, $article->sectionid));
				} else {
					$readmore_link = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catid));
				}
				$readmore_register = 0;
			} else {
				if (JCOMMENTS_JVERSION == '1.5') {
					$readmore_link = JRoute::_('index.php?option=com_user&task=register');
				} else {
					$returnURL = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug));

					$menu = JFactory::getApplication()->getMenu();
					$active = $menu->getActive();
					$itemId = $active->id;
					$link1 = JRoute::_('index.php?option=com_users&view=login&Itemid=' . $itemId);
					$link = new JURI($link1);
					$link->setVar('return', base64_encode($returnURL));
					$readmore_link = $link;
				}
				$readmore_register = 1;
			}

			// load template for comments & readmore links
			$tmpl = JCommentsFactory::getTemplate($article->id, 'com_content', false);
			$tmpl->load('tpl_links');

			$tmpl->addVar('tpl_links', 'comments_link_style', ($readmore_register ? -1 : 1));
			$tmpl->addVar('tpl_links', 'content-item', $article);
			$tmpl->addVar('tpl_links', 'show_hits', intval($this->params->get('show_hits', 0) && $params->get('show_hits', 0)));

			$readmoreDisabled = false;

			if (($params->get('show_readmore') == 0) || (@$article->readmore == 0)) {
				$readmoreDisabled = true;
			} else if (@$article->readmore > 0) {
				$readmoreDisabled = false;
			}

			if ($this->params->get('readmore_link', 1) == 0) {
				$readmoreDisabled = true;
			}

			$tmpl->addVar('tpl_links', 'readmore_link_hidden', intval($readmoreDisabled));

			// don't fill any readmore variable if it disabled
			if (!$readmoreDisabled) {
				if ($readmore_register == 1) {
					$readmore_text = JText::_('LINK_REGISTER_TO_READ_MORE');
				} else if (isset($params) && $readmore = $params->get('readmore')) {
					$readmore_text = $readmore;
				} else {
					$readmore_text = JText::_('LINK_READ_MORE');
				}
				$tmpl->addVar('tpl_links', 'link-readmore', $readmore_link);
				$tmpl->addVar('tpl_links', 'link-readmore-text', $readmore_text);
				$tmpl->addVar('tpl_links', 'link-readmore-title', $article->title);
				$tmpl->addVar('tpl_links', 'link-readmore-class', $this->params->get('readmore_css_class', 'readmore-link'));
			}

			$commentsDisabled = false;

			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');

				$anchor = "";

				if ($this->params->get('comments_count', 1) != 0) {

					$acl = JCommentsFactory::getACL();

					$options = array();
					$options['object_id'] = (int) $article->id;
					$options['object_group'] = 'com_content';
					$options['published'] = $acl->canPublish() || $acl->canPublishForObject($article->id, 'com_content') ? null : 1;

					$count = JCommentsModel::getCommentsCount($options);

					$tmpl->addVar('tpl_links', 'comments-count', $count);
					$anchor = $count == 0 ? '#addcomment' : '#comments';

					if ($count == 0) {
						$link_text = JText::_('LINK_ADD_COMMENT');
					} else {
						if (JCOMMENTS_JVERSION == '1.5') {
							require_once (JCOMMENTS_LIBRARIES.'/joomlatune/language.tools.php');
							$lang = JFactory::getLanguage();
							$suffix = JoomlaTuneLanguageTools::getPluralSuffix($lang->getTag(), $count);
							$string = 'LINK_READ_COMMENTS';
							$key = $string . '_' . $suffix;
							if (!$lang->hasKey($key)) {
								$key = $string;
							}
							$link_text = JText::sprintf($key, $count);

						} else {
							$link_text = JText::plural('LINK_READ_COMMENTS', $count);
						}
					}
				} else {
					$link_text = JText::_('LINK_ADD_COMMENT');
				}

				$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', $this->params->get('comments_css_class', 'comments-link'));
			}

			JCommentsContentPluginHelper::clear($article, true);

			// hide comments link if comments enabled but link disabled in plugin params
			if ((($this->params->get('comments_count', 1) == 0)
					|| ($count == 0 && $this->params->get('add_comments', 1) == 0)
					|| ($count == 0 && $readmore_register == 1))
					&& !$commentsDisabled) {
				$tmpl->addVar('tpl_links', 'comments_link_hidden', 1);
			}

			//links_position
			if ($this->params->get('links_position', 1) == 1) {
				$article->text .= $tmpl->renderTemplate('tpl_links');
			} else {
				$article->text = $tmpl->renderTemplate('tpl_links') . $article->text;
			}

			$tmpl->freeTemplate('tpl_links');

			if ($this->params->get('readmore_link', 1) == 1) {
				$article->readmore = 0;
				$article->readmore_link = '';
				$article->readmore_register = false;
			}
		} else {
			if ($this->params->get('show_comments_event') == 'onPrepareContent') {
				$isEnabled = ($config->getInt('comments_on', 0) == 1) && ($config->getInt('comments_off', 0) == 0);
				if ($isEnabled && $view == 'article') {
					require_once (JCOMMENTS_BASE . '/jcomments.php');

					$comments = JComments::show($article->id, 'com_content', $article->title);

					if (strpos($article->text, '{jcomments}') !== false) {
						$article->text = str_replace('{jcomments}', $comments, $article->text);
					} else {
						$article->text .= $comments;
					}
				}
			}
			JCommentsContentPluginHelper::clear($article, true);
		}
		return '';
	}
Exemple #6
0
 function getCommentsCount($object_id, $object_group = 'com_content', $filter = '')
 {
     return JCommentsModel::getCommentsCount($object_id, $object_group, $filter);
 }
Exemple #7
0
 function onPrepareContent(&$article, &$params, $limitstart = 0)
 {
     require_once JPATH_ROOT . '/components/com_jcomments/helpers/content.php';
     // check whether plugin has been unpublished
     if (!JPluginHelper::isEnabled('content', 'jcomments')) {
         JCommentsContentPluginHelper::clear($article, true);
         return '';
     }
     $app = JFactory::getApplication('site');
     $option = $app->input->get('option');
     $view = $app->input->get('view');
     if (!isset($article->id) || $option != 'com_content' && $option != 'com_alphacontent' && $option != 'com_multicategories') {
         return '';
     }
     if (!isset($params) || $params == null) {
         $params = new JRegistry('');
     } else {
         if (isset($params->_raw) && strpos($params->_raw, 'moduleclass_sfx') !== false) {
             return '';
         }
     }
     if ($view == 'frontpage' || $view == 'featured') {
         if ($this->params->get('show_frontpage', 1) == 0) {
             return '';
         }
     }
     require_once JPATH_ROOT . '/components/com_jcomments/jcomments.class.php';
     JCommentsContentPluginHelper::processForeignTags($article);
     $config = JCommentsFactory::getConfig();
     $categoryEnabled = JCommentsContentPluginHelper::checkCategory($article->catid);
     $commentsEnabled = JCommentsContentPluginHelper::isEnabled($article) || $categoryEnabled;
     $commentsDisabled = JCommentsContentPluginHelper::isDisabled($article) || !$commentsEnabled;
     $commentsLocked = JCommentsContentPluginHelper::isLocked($article);
     $archivesState = 2;
     if (isset($article->state) && $article->state == $archivesState && $this->params->get('enable_for_archived', 0) == 0) {
         $commentsLocked = true;
     }
     $config->set('comments_on', intval($commentsEnabled));
     $config->set('comments_off', intval($commentsDisabled));
     $config->set('comments_locked', intval($commentsLocked));
     if ($view != 'article') {
         $user = JFactory::getUser();
         $authorised = JAccess::getAuthorisedViewLevels($user->get('id'));
         $checkAccess = in_array($article->access, $authorised);
         $slug = isset($article->slug) ? $article->slug : $article->id;
         $language = isset($article->language) ? $article->language : 0;
         require_once JPATH_ROOT . '/components/com_content/helpers/route.php';
         if ($checkAccess) {
             $readmore_link = JRoute::_(ContentHelperRoute::getArticleRoute($slug, $article->catid, $language));
             $readmore_register = 0;
         } else {
             $returnURL = JRoute::_(ContentHelperRoute::getArticleRoute($slug, $article->catid, $language));
             $menu = JFactory::getApplication()->getMenu();
             $active = $menu->getActive();
             $itemId = $active->id;
             $link1 = JRoute::_('index.php?option=com_users&view=login&Itemid=' . $itemId);
             $link = new JURI($link1);
             $link->setVar('return', base64_encode($returnURL));
             $readmore_link = $link;
             $readmore_register = 1;
         }
         // load template for comments & readmore links
         $tmpl = JCommentsFactory::getTemplate($article->id, 'com_content', false);
         $tmpl->load('tpl_links');
         $tmpl->addVar('tpl_links', 'comments_link_style', $readmore_register ? -1 : 1);
         $tmpl->addVar('tpl_links', 'content-item', $article);
         $tmpl->addVar('tpl_links', 'show_hits', intval($this->params->get('show_hits', 0) && $params->get('show_hits', 0)));
         $readmoreDisabled = false;
         if ($params->get('show_readmore') == 0 || @$article->readmore == 0) {
             $readmoreDisabled = true;
         } else {
             if (@$article->readmore > 0) {
                 $readmoreDisabled = false;
             }
         }
         if ($this->params->get('readmore_link', 1) == 0) {
             $readmoreDisabled = true;
         }
         $tmpl->addVar('tpl_links', 'readmore_link_hidden', intval($readmoreDisabled));
         // don't fill any readmore variable if it disabled
         if (!$readmoreDisabled) {
             if ($readmore_register == 1) {
                 $readmore_text = JText::_('COM_CONTENT_REGISTER_TO_READ_MORE');
             } else {
                 if (isset($params) && ($readmore = $params->get('readmore'))) {
                     $readmore_text = $readmore;
                 } else {
                     if ($alternative_readmore = $article->alternative_readmore) {
                         $readmore_text = trim($alternative_readmore);
                         if ($params->get('show_readmore_title', 0) != 0) {
                             $readmore_text .= ' ' . JHtml::_('string.truncate', $article->title, $params->get('readmore_limit'));
                         }
                     } else {
                         $readmore_text = JText::_('COM_CONTENT_READ_MORE_TITLE');
                         if ($params->get('show_readmore_title', 0) == 1) {
                             $readmore_text = JText::_('COM_CONTENT_READ_MORE') . JHtml::_('string.truncate', $article->title, $params->get('readmore_limit'));
                         }
                     }
                 }
             }
             $tmpl->addVar('tpl_links', 'link-readmore', $readmore_link);
             $tmpl->addVar('tpl_links', 'link-readmore-text', $readmore_text);
             $tmpl->addVar('tpl_links', 'link-readmore-title', $article->title);
             $tmpl->addVar('tpl_links', 'link-readmore-class', $this->params->get('readmore_css_class', 'readmore-link'));
         }
         $commentsDisabled = false;
         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 JPATH_ROOT . '/components/com_jcomments/models/jcomments.php';
             $anchor = "";
             if ($this->params->get('comments_count', 1) != 0) {
                 $acl = JCommentsFactory::getACL();
                 $options = array();
                 $options['object_id'] = (int) $article->id;
                 $options['object_group'] = 'com_content';
                 $options['published'] = $acl->canPublish() || $acl->canPublishForObject($article->id, 'com_content') ? null : 1;
                 $count = JCommentsModel::getCommentsCount($options);
                 $tmpl->addVar('tpl_links', 'comments-count', $count);
                 $anchor = $count == 0 ? '#addcomments' : '#comments';
                 if ($count == 0) {
                     $link_text = JText::_('LINK_ADD_COMMENT');
                 } else {
                     $link_text = JText::plural('LINK_READ_COMMENTS', $count);
                 }
             } else {
                 $link_text = JText::_('LINK_ADD_COMMENT');
             }
             $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', $this->params->get('comments_css_class', 'comments-link'));
         }
         JCommentsContentPluginHelper::clear($article, true);
         // hide comments link if comments enabled but link disabled in plugin params
         if (($this->params->get('comments_count', 1) == 0 || $count == 0 && $this->params->get('add_comments', 1) == 0 || $count == 0 && $readmore_register == 1) && !$commentsDisabled) {
             $tmpl->addVar('tpl_links', 'comments_link_hidden', 1);
         }
         //links_position
         if ($this->params->get('links_position', 1) == 1) {
             $article->text .= $tmpl->renderTemplate('tpl_links');
         } else {
             $article->text = $tmpl->renderTemplate('tpl_links') . $article->text;
         }
         $tmpl->freeTemplate('tpl_links');
         if ($this->params->get('readmore_link', 1) == 1) {
             $article->readmore = 0;
             $article->readmore_link = '';
             $article->readmore_register = false;
         }
     } else {
         if ($this->params->get('show_comments_event') == 'onPrepareContent') {
             $isEnabled = $config->getInt('comments_on', 0) == 1 && $config->getInt('comments_off', 0) == 0;
             if ($isEnabled && $view == 'article') {
                 require_once JPATH_ROOT . '/components/com_jcomments/jcomments.php';
                 $comments = JComments::show($article->id, 'com_content', $article->title);
                 if (strpos($article->text, '{jcomments}') !== false) {
                     $article->text = str_replace('{jcomments}', $comments, $article->text);
                 } else {
                     $article->text .= $comments;
                 }
             }
         }
         JCommentsContentPluginHelper::clear($article, true);
     }
     return '';
 }
Exemple #8
0
 function onPrepareContent(&$article, &$params, $limitstart = 0)
 {
     require_once JCOMMENTS_HELPERS . DS . 'content.php';
     // check whether plugin has been unpublished
     if (!JPluginHelper::isEnabled('content', 'jcomments')) {
         JCommentsContentPluginHelper::clear($article, true);
         return;
     }
     $application =& JFactory::getApplication('site');
     $option = JRequest::getCmd('option');
     $view = JRequest::getCmd('view');
     if (!isset($article->id) || $option != 'com_content' && $option != 'com_alphacontent' && $option != 'com_customproperties') {
         return;
     }
     if (!isset($params) || $params == null) {
         $params = new JParameter('');
     } else {
         if (strpos($params->_raw, 'moduleclass_sfx') !== false) {
             return '';
         }
     }
     if ($view == 'frontpage') {
         if ($this->params->get('show_frontpage', 1) == 0) {
             return;
         }
     }
     require_once JCOMMENTS_BASE . DS . 'jcomments.config.php';
     require_once JCOMMENTS_BASE . DS . 'jcomments.class.php';
     JCommentsContentPluginHelper::processForeignTags($article);
     $config =& JCommentsFactory::getConfig();
     $categoryEnabled = JCommentsContentPluginHelper::checkCategory($article->catid);
     $commentsEnabled = JCommentsContentPluginHelper::isEnabled($article) || $categoryEnabled;
     $commentsDisabled = JCommentsContentPluginHelper::isDisabled($article) || !$commentsEnabled;
     $commentsLocked = JCommentsContentPluginHelper::isLocked($article);
     if ($article->state == -1 && $config->getInt('enable_for_archived') == 0) {
         $commentsLocked = true;
     }
     $config->set('comments_on', intval($commentsEnabled));
     $config->set('comments_off', intval($commentsDisabled));
     $config->set('comments_locked', intval($commentsLocked));
     if ($view != 'article') {
         $user =& JFactory::getUser();
         if ($article->access <= $user->get('aid', 0)) {
             $readmore_link = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catslug, $article->sectionid));
             $readmore_register = 0;
         } else {
             $readmore_link = JRoute::_('index.php?option=com_user&task=register');
             $readmore_register = 1;
         }
         // load template for comments & readmore links
         $tmpl =& JCommentsFactory::getTemplate($article->id, 'com_content', false);
         $tmpl->load('tpl_links');
         $tmpl->addVar('tpl_links', 'comments_link_style', $readmore_register ? -1 : 1);
         $tmpl->addVar('tpl_links', 'content-item', $article);
         $tmpl->addVar('tpl_links', 'show_hits', intval($this->params->get('show_hits', 0) && $params->get('show_hits', 0)));
         $tmpl->addVar('tpl_links', 'link-comment', $readmore_link);
         $tmpl->addVar('tpl_links', 'link-comments-class', $this->params->get('comments_css_class', 'comments-link'));
         $readmoreDisabled = false;
         if ($params->get('show_readmore') == 0 || @$article->readmore == 0) {
             $readmoreDisabled = true;
         } else {
             if (@$article->readmore > 0) {
                 $readmoreDisabled = false;
             }
         }
         if ($this->params->get('readmore_link', 1) == 0) {
             $readmoreDisabled = true;
         }
         $tmpl->addVar('tpl_links', 'readmore_link_hidden', intval($readmoreDisabled));
         // don't fill any readmore variable if it disabled
         if (!$readmoreDisabled) {
             if ($readmore_register == 1) {
                 $readmore_text = JText::_('Register to read more...');
             } else {
                 if (isset($params) && ($readmore = $params->get('readmore'))) {
                     $readmore_text = $readmore;
                 } else {
                     $readmore_text = JText::_('Read more...');
                 }
             }
             $tmpl->addVar('tpl_links', 'link-readmore', $readmore_link);
             $tmpl->addVar('tpl_links', 'link-readmore-text', $readmore_text);
             $tmpl->addVar('tpl_links', 'link-readmore-title', $article->title);
             $tmpl->addVar('tpl_links', 'link-readmore-class', $this->params->get('readmore_css_class', 'readmore-link'));
         }
         $commentsDisabled = false;
         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 && $this->params->get('comments_count', 1) != 0) {
             require_once JCOMMENTS_BASE . DS . 'model' . DS . 'jcomments.php';
             $count = JCommentsModel::getCommentsCount($article->id, 'com_content');
             $tmpl->addVar('tpl_links', 'comments-count', $count);
             if ($config->getInt('use_plural_forms', 0)) {
                 require_once JCOMMENTS_LIBRARIES . DS . 'joomlatune' . DS . 'language.tools.php';
                 $tmpl->addVar('tpl_links', 'use-plural-forms', $config->getInt('use_plural_forms', 0));
             }
         }
         JCommentsContentPluginHelper::clear($article, true);
         // hide comments link if comments enabled but link disabled in plugin params
         if (($this->params->get('comments_count', 1) == 0 || $count == 0 && $this->params->get('add_comments', 1) == 0 || $count == 0 && $readmore_register == 1) && !$commentsDisabled) {
             $tmpl->addVar('tpl_links', 'comments_link_hidden', 1);
         }
         //links_position
         if ($this->params->get('links_position', 1) == 1) {
             $article->text .= $tmpl->renderTemplate('tpl_links');
         } else {
             $article->text = $tmpl->renderTemplate('tpl_links') . $article->text;
         }
         $tmpl->freeTemplate('tpl_links');
         if ($this->params->get('readmore_link', 1) == 1) {
             $article->readmore = 0;
             if (isset($params)) {
                 $params->set('show_readmore', 0);
             }
             $article->readmore_link = '';
             $article->readmore_register = false;
         }
     } else {
         if ($this->params->get('show_comments_event') == 'onPrepareContent') {
             $isEnabled = $config->getInt('comments_on', 0) == 1 && $config->getInt('comments_off', 0) == 0;
             if ($isEnabled && $view == 'article') {
                 require_once JCOMMENTS_BASE . DS . 'jcomments.php';
                 $article->text .= JComments::show($article->id, 'com_content', $article->title);
             }
         } else {
             $user = JFactory::getUser();
             if ($user->usertype == 'Super Administrator') {
                 $application =& JFactory::getApplication('site');
                 $template = $application->getTemplate();
                 $articleTemplate = DS . 'templates' . DS . $template . DS . 'html' . DS . 'com_content' . DS . 'article' . DS . 'default.php';
                 if (is_file(JPATH_SITE . $articleTemplate)) {
                     $tmpl = implode('', file(JPATH_SITE . $articleTemplate));
                     if (strpos($tmpl, 'afterDisplayContent') === false) {
                         JError::raiseWarning(500, JText::sprintf('The article template (%s) doesn\'t have afterDisplayContent event!', $articleTemplate));
                     }
                 }
             }
         }
         JCommentsContentPluginHelper::clear($article, true);
     }
     return;
 }