По просьбе одного из пользователей форума сделал интеграцию с
JoomGallery MVC (1.5.5) BETA(не путать просто с версией 1.5 - это две разные ветки). Тестировалось на
JG MVC (1.5.5) BETA/JC 2.1(07/08/2009).
1. В админке выставляем
JoomGallery->Configuration Manager->User Access Rights->Comments->Allow Comments->Нет2. Откройте файл
\components\com_joomgallery\views\detail\tmpl\default.php3. В самом конце файла перед строкой
echo $this->loadTemplate('footer'); вставьте следующее:
?>
<div class="jg_commentsarea">
<div class="sectiontableheader">
<h4>
<?php echo JText::_('JGS_EXISTING_COMMENTS'); ?>
</h4>
</div>
<?php
$comments = JPATH_SITE.DS.'components'.DS.'com_jcomments'.DS.'jcomments.php';
if (is_file($comments)) {
require_once($comments);
echo JComments::showComments($this->image->id, 'com_joomgallery', $this->image->imgtitle);
}
?>
</div>
<?php
4. Откройте файл
\components\com_joomgallery\models\edit.php5. Найдите и закомментируйте или удалите строки:
//delete the corresponding database entries in comments
$this->_db->setQuery("DELETE
FROM
"._JOOM_TABLE_COMMENTS."
WHERE
cmtpic = ".$this->_id
);
if(!$this->_db->query())
{
JError::raiseWarning(100, JText::sprintf('JGA_COULD_NOT_DELETE_COMMENTS', $this->_id));
}
6. Вместо или после удалённого куска вставьте:
$jcomments = JPATH_SITE.DS.'components'.DS.'com_jcomments'.DS.'jcomments.php';
if (file_exists($jcomments)) {
require_once($jcomments);
JComments::deleteComments($this->_id, 'com_joomgallery');
}
7. Откройте файл
\components\com_joomgallery\models\category.php8. Найдите и закомментируйте или удалите строки:
if($this->_config->get('jg_showcatcom'))
{
$query .= ",
( SELECT
COUNT(cmtid)
FROM
"._JOOM_TABLE_COMMENTS."
WHERE
cmtpic = a.id
AND published = 1
AND approved = 1
) AS comments";
}
9. Откройте файл
\components\com_joomgallery\views\category\view.html.php10. Где-то
перед строками:
//additional icons added by plugins
$icons = $this->_mainframe->triggerEvent('onDisplayJoomIcons', array($image));
$images[$key]->icons = implode('', $icons);
...вставьте следующее:
$jcomments = JPATH_SITE.DS.'components'.DS.'com_jcomments'.DS.'jcomments.php';
if (is_file($jcomments)) {
require_once($jcomments);
$images[$key]->comments = JComments::getCommentsCount($image->id, 'com_joomgallery');
}
11. Откройте файл
\components\com_joomgallery\views\favourites\view.html.php12. Найдите и закомментируйте или удалите строки:
//TODO
$model = &$this->getModel();
$row->comments = $model->getCommentsNumber($row->id);
13. Вместо или после удалённого куска вставьте:
$jcomments = JPATH_SITE.DS.'components'.DS.'com_jcomments'.DS.'jcomments.php';
if (is_file($jcomments)) {
require_once($jcomments);
$row->comments = JComments::getCommentsCount($row->id, 'com_joomgallery');
}
14. Откройте файл
\components\com_joomgallery\views\search\view.html.php15. Найдите и закомментируйте или удалите строки:
//TODO
$model = &$this->getModel();
$rows[$key]->comments = $model->getCommentsNumber($row->id);
16. Вместо или после удалённого куска вставьте:
$jcomments = JPATH_SITE.DS.'components'.DS.'com_jcomments'.DS.'jcomments.php';
if (is_file($jcomments)) {
require_once($jcomments);
$rows[$key]->comments = JComments::getCommentsCount($row->id, 'com_joomgallery');
}
17. Откройте файл
\components\com_joomgallery\models\toplist.php18. Найдите и закомментируйте или удалите строки:
$this->_db->setQuery("SELECT
a.*,
cc.*,
ca.*,
a.owner AS owner
FROM
"._JOOM_TABLE_IMAGES." AS a,
"._JOOM_TABLE_CATEGORIES." AS ca,
"._JOOM_TABLE_COMMENTS." AS cc
WHERE
a.id = cc.cmtpic
AND a.catid = ca.cid
AND a.published = 1
AND a.approved = 1
AND cc.published = 1
AND ca.published = 1
AND cc.approved = 1
AND ca.access <= ".$this->_user->get('aid')."
ORDER BY
cc.cmtdate DESC
LIMIT ".$this->_config->get('jg_toplist')
);
19. Вместо или после удалённого куска вставьте:
$this->_db->setQuery("SELECT
a.*,
cc.*,
ca.*,
a.id AS id,
a.owner AS owner,
cc.id AS cmtid
FROM
"._JOOM_TABLE_IMAGES." AS a,
"._JOOM_TABLE_CATEGORIES." AS ca,
#__jcomments AS cc
WHERE
cc.object_group = 'com_joomgallery'
AND a.id = cc.object_id
AND a.catid = ca.cid
AND a.published = 1
AND a.approved = 1
AND cc.published = 1
AND ca.published = 1
AND ca.access <= ".$this->_user->get('aid')."
AND cc.id = (SELECT MAX(jc.id) FROM #__jcomments AS jc WHERE a.id = jc.object_id)
ORDER BY cc.date DESC
LIMIT ".$this->_config->get('jg_toplist')
);
20. Откройте файл
\components\com_joomgallery\views\toplist\view.html.php21. Найдите и закомментируйте или удалите строки:
if($row->userid)
{
$rows[$key]->cmtname = JHTML::_('joomgallery.displayname', $row->userid, false);
}
$cmttext = $row->cmttext;
$cmttext = JoomHelper::processText($cmttext);
if($this->_config->get('jg_smiliesupport'))
{
$smileys = JoomHelper::getSmileys();
foreach($smileys as $i => $sm)
{
$cmttext = str_replace($i, '<img src="'.$sm.'" border="0" alt="'.$i.'" title="'.$i.'" />', $cmttext);
}
}
$cmttext = stripslashes($cmttext);
$rows[$key]->processed_cmttext = $cmttext;
22. Вместо или после удалённого куска вставьте:
$jcomments = JPATH_SITE.DS.'components'.DS.'com_jcomments'.DS.'jcomments.php';
if (is_file($jcomments)) {
require_once($jcomments);
$rows[$key]->cmtdate = JCommentsText::formatDate($row->date, '%d.%m.%y %H:%M');
$cmttext = $row->comment;
$bbcode = & JCommentsFactory::getBBCode();
$smileys = & JCommentsFactory::getSmiles();
$cmttext = JCommentsText::censor($cmttext);
$cmttext = JCommentsText::cleanText($cmttext);
$cmttext = stripslashes($cmttext);
$cmttext = $bbcode->filter( $cmttext, true );
if($this->_config->get('jg_smiliesupport'))
{
$cmttext = $smileys->replace($cmttext);
}
$rows[$key]->processed_cmttext = $cmttext;
}
23. В том же файле найдите и удалите или закомментируйте строки:
//TODO
$model = &$this->getModel();
$rows[$key]->comments = $model->getCommentsNumber($row->id);
24. Вместо или после удалённого куска вставьте:
$jcomments = JPATH_SITE.DS.'components'.DS.'com_jcomments'.DS.'jcomments.php';
if (is_file($jcomments)) {
require_once($jcomments);
$rows[$key]->comments = JComments::getCommentsCount($row->id, 'com_joomgallery');
}
25. Откройте файл
\components\com_joomgallery\views\toplist\tmpl\default.php26. Вместо строк:
<?php echo JText::sprintf('JGS_WROTE_AT', $row->cmtname, JHTML::_('date', $row->cmtdate, JText::_('DATE_FORMAT_LC1'))); ?>
<?php echo $row->processed_cmttext; ?>
...вставьте следующее:
<?php /* -- hack */echo "<b>".$row->username."</b> написал(а): ".$row->processed_cmttext." (".$row->cmtdate.")"; ?>
В общем всё(если что забыл пишите).