1: <?php if(!defined('APPLICATION')) exit();
2: 3: 4: 5: 6: 7: 8:
9: if(!function_exists('RenderReactions')) {
10:
11: 12: 13: 14: 15: 16: 17: 18: 19:
20: function RenderReactionList($ID, $Type, $Echo = TRUE) {
21: $Reactions = Yaga::ReactionModel()->GetList($ID, $Type);
22: $ShowCount = Gdn::Session()->CheckPermission('Yaga.Reactions.View');
23: $ActionsString = '';
24: foreach($Reactions as $Action) {
25: if(CheckPermission($Action->Permission)) {
26: $CountString = ($ShowCount && $Action->Count) ? $Action->Count : '';
27: $ActionsString .= Anchor(
28: Wrap(' ', 'span', array('class' => 'ReactSprite React-' . $Action->ActionID . ' ' . $Action->CssClass)) .
29: WrapIf($CountString, 'span', array('class' => 'Count')) .
30: Wrap($Action->Name, 'span', array('class' => 'ReactLabel')), 'react/' . $Type . '/' . $ID . '/' . $Action->ActionID,
31: array(
32: 'class' => 'Hijack ReactButton',
33: 'title' => $Action->Tooltip)
34: );
35: }
36: }
37:
38: $AllActionsString = Wrap($ActionsString, 'span', array('class' => 'ReactMenu'));
39:
40: if($Echo) {
41: echo $AllActionsString;
42: return true;
43: }
44: else {
45: return $AllActionsString;
46: }
47: }
48:
49: }
50:
51: if(!function_exists('RenderReactionRecord')) {
52:
53: 54: 55: 56: 57: 58:
59: function RenderReactionRecord($ID, $Type) {
60: $Reactions = Yaga::ReactionModel()->GetRecord($ID, $Type);
61: $Limit = C('Yaga.Reactions.RecordLimit');
62: $ReactionCount = count($Reactions);
63: $i = 0;
64: foreach($Reactions as $Reaction) {
65: $i++;
66:
67:
68: if($i <= $Limit || $Limit <= 0) {
69: $User = Gdn::UserModel()->GetID($Reaction->UserID);
70: $DateTitle = sprintf(
71: T('Yaga.Reactions.RecordFormat'),
72: $User->Name,
73: $Reaction->Name,
74: Gdn_Format::Date($Reaction->DateInserted, '%B %e, %Y')
75: );
76: $String = UserPhoto($User, array('Size' => 'Small', 'title' => $DateTitle));
77: $String .= '<span class="ReactSprite Reaction-' . $Reaction->ActionID . ' ' . $Reaction->CssClass . '"></span>';
78: $Wrapttributes = array(
79: 'class' => 'UserReactionWrap',
80: 'data-userid' => $User->UserID,
81: 'title' => $DateTitle
82: );
83: echo Wrap($String, 'span', $Wrapttributes);
84: }
85:
86: if($Limit > 0 && $i >= $ReactionCount && $ReactionCount > $Limit) {
87: echo Plural($ReactionCount - $Limit, 'Yaga.Reactions.RecordLimit.Single', 'Yaga.Reactions.RecordLimit.Plural');
88: }
89: }
90: }
91:
92: }
93:
94: if(!function_exists('ActionRow')) {
95:
96: 97: 98: 99: 100: 101:
102: function ActionRow($Action) {
103: return Wrap(
104: Wrap(
105: Anchor(T('Edit'), 'action/edit/' . $Action->ActionID, array('class' => 'Popup SmallButton')) . Anchor(T('Delete'), 'action/delete/' . $Action->ActionID, array('class' => 'Popup SmallButton')), 'div', array('class' => 'Tools')) .
106: Wrap(
107: Wrap($Action->Name, 'h4') .
108: Wrap(
109: Wrap($Action->Description, 'span') . ' ' .
110: Wrap(Plural($Action->AwardValue, '%s Point', '%s Points'), 'span'), 'div', array('class' => 'Meta')) .
111: Wrap(
112: Wrap(' ', 'span', array('class' => 'ReactSprite React-' . $Action->ActionID . ' ' . $Action->CssClass)) .
113: WrapIf(rand(0, 18), 'span', array('class' => 'Count')) .
114: Wrap($Action->Name, 'span', array('class' => 'ReactLabel')), 'div', array('class' => 'Preview Reactions')), 'div', array('class' => 'Action')), 'li', array('id' => 'ActionID_' . $Action->ActionID));
115: }
116: }
117:
118: if(!function_exists('RenderPerkPermissionForm')) {
119:
120: 121: 122: 123: 124: 125:
126: function RenderPerkPermissionForm($Perm, $Label) {
127: $Form = Gdn::Controller()->Form;
128: $Fieldname = 'Perm' . $Perm;
129: echo '<li>';
130: echo $Form->Label($Label, $Fieldname);
131: echo $Form->Dropdown($Fieldname, array(
132: '' => T('Default'),
133: 'grant' => T('Grant'),
134: 'revoke' => T('Revoke')
135: ));
136: echo '</li>';
137: }
138: }
139:
140: if(!function_exists('RenderPerkConfigurationForm')) {
141:
142: 143: 144: 145: 146: 147: 148:
149: function RenderPerkConfigurationForm($Config, $Label, $Options = NULL) {
150: if(is_null($Options)) {
151:
152: $Options = array(
153: '' => T('Default'),
154: 1 => T('Enabled'),
155: 0 => T('Disabled')
156: );
157: }
158:
159: $Options = $Options + array('' => T('Default'));
160: $Form = Gdn::Controller()->Form;
161: $Fieldname = 'Conf' . $Config;
162: echo '<li>';
163: echo $Form->Label($Label, $Fieldname);
164: echo $Form->Dropdown($Fieldname, $Options);
165: echo '</li>';
166: }
167: }
168:
169: