Merge branch 'bleistivt-Patch-ReactionRecord'
This commit is contained in:
commit
4a396e1ca6
@ -70,7 +70,7 @@ class ReactController extends Gdn_Controller {
|
||||
$Item = $Model->GetID($ID);
|
||||
|
||||
if($Item) {
|
||||
$Anchor = $AnchorID . $ID . ' .ReactMenu';
|
||||
$Anchor = $AnchorID . $ID;
|
||||
}
|
||||
else {
|
||||
throw new Gdn_UserException(T('Yaga.Action.InvalidTargetID'));
|
||||
@ -98,7 +98,8 @@ class ReactController extends Gdn_Controller {
|
||||
// It has passed through the gauntlet
|
||||
$this->ReactionModel->Set($ID, $Type, $ItemOwnerID, $UserID, $ActionID);
|
||||
|
||||
$this->JsonTarget($Anchor, RenderReactionList($ID, $Type), 'ReplaceWith');
|
||||
$this->JsonTarget($Anchor . ' .ReactMenu', RenderReactionList($ID, $Type), 'ReplaceWith');
|
||||
$this->JsonTarget($Anchor . ' .ReactionRecord', RenderReactionRecord($ID, $Type, FALSE), 'ReplaceWith');
|
||||
|
||||
// Don't render anything
|
||||
$this->Render('Blank', 'Utility', 'Dashboard');
|
||||
|
@ -46,11 +46,14 @@ if(!function_exists('RenderReactionRecord')) {
|
||||
*
|
||||
* @param int $ID
|
||||
* @param string $Type 'discussion', 'activity', or 'comment'
|
||||
* @param bool $Echo Should it be echoed?
|
||||
* @return mixed String if $Echo is false, TRUE otherwise
|
||||
*/
|
||||
function RenderReactionRecord($ID, $Type) {
|
||||
function RenderReactionRecord($ID, $Type, $Echo = TRUE) {
|
||||
$Reactions = Yaga::ReactionModel()->GetRecord($ID, $Type);
|
||||
$Limit = C('Yaga.Reactions.RecordLimit');
|
||||
$ReactionCount = count($Reactions);
|
||||
$RecordsString = '';
|
||||
$i = 0;
|
||||
foreach($Reactions as $Reaction) {
|
||||
$i++;
|
||||
@ -71,13 +74,23 @@ if(!function_exists('RenderReactionRecord')) {
|
||||
'data-userid' => $User->UserID,
|
||||
'title' => $DateTitle
|
||||
);
|
||||
echo Wrap($String, 'span', $Wrapttributes);
|
||||
$RecordsString .= Wrap($String, 'span', $Wrapttributes);
|
||||
}
|
||||
|
||||
if($Limit > 0 && $i >= $ReactionCount && $ReactionCount > $Limit) {
|
||||
echo Plural($ReactionCount - $Limit, 'Yaga.Reactions.RecordLimit.Single', 'Yaga.Reactions.RecordLimit.Plural');
|
||||
$RecordsString .= Plural($ReactionCount - $Limit, 'Yaga.Reactions.RecordLimit.Single', 'Yaga.Reactions.RecordLimit.Plural');
|
||||
}
|
||||
}
|
||||
|
||||
$AllRecordsString = Wrap($RecordsString, 'div', array('class' => 'ReactionRecord'));
|
||||
|
||||
if($Echo) {
|
||||
echo $AllRecordsString;
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return $AllRecordsString;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user