Skip to content

Commit

Permalink
Add a new inserttag for the comments count
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasisaak committed Jan 27, 2014
1 parent d4093f5 commit fd7101b
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions system/modules/x-editors/mawExtendedInsertTags.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* Contao Open Source CMS
*
* @copyright MEN AT WORK 2013
* @copyright MEN AT WORK 2014
* @package extendedEditors
* @license GNU/LGPL
* @filesource
Expand All @@ -12,7 +12,7 @@
/**
* Class mawExtendedInsertTags
*
* @copyright MEN AT WORK 2013
* @copyright MEN AT WORK 2014
* @package Frontend
*/
class mawExtendedInsertTags extends Controller
Expand Down Expand Up @@ -64,6 +64,9 @@ public function mawReplaceInsertTags($strTag)
case 'anchor_close':
return '</a>';
break;
case 'comments':
return $this->countComments($arrSplit[1], $arrSplit[2]);
break;
case 'download':
$objFile = \FilesModel::findByUuid($arrSplit[1]);
return '<a title="' . $arrSplit[2] . '" href="' . $objFile->path . '" >' . $arrSplit[2] . '</a>';
Expand All @@ -74,6 +77,20 @@ public function mawReplaceInsertTags($strTag)
return false;
}

protected function countComments($strParentTable, $intParentId)
{
if (empty($strParentTable) || empty($intParentId))
{
return false;
}

$objResult = \Database::getInstance()
->prepare('SELECT COUNT(*) as mycount FROM tl_comments WHERE source=? AND parent=?')
->execute($strParentTable, $intParentId);

return $objResult->mycount;
}

public function mawReplaceLanguageTags($strTag)
{
if ($strTag == 'actlang')
Expand Down

0 comments on commit fd7101b

Please sign in to comment.