Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/site/app/views/reviews/display.thtml
blob: bf64b959d03aa9bf35f5c66a48042e3598d39114 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
<?php
/* ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is addons.mozilla.org site.
 *
 * The Initial Developer of the Original Code is
 * The Mozilla Foundation.
 * Portions created by the Initial Developer are Copyright (C) 2006
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *   Frederic Wenzel <fwenzel@mozilla.com> (Original Author)
 *   Wil Clouser <clouserw@mozilla.com>
 *
 * Alternatively, the contents of this file may be used under the terms of
 * either the GNU General Public License Version 2 or later (the "GPL"), or
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 * in which case the provisions of the GPL or the LGPL are applicable instead
 * of those above. If you wish to allow use of your version of this file only
 * under the terms of either the GPL or the LGPL, and not to allow others to
 * use your version of this file under the terms of the MPL, indicate your
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the MPL, the GPL or the LGPL.
 *
 * ***** END LICENSE BLOCK ***** */

if ($loggedin) {
    $_review_flag_this = ___('Report this review');
    $_review_flag_this_titletip = ___('Is this review inappropriate, inaccurate or spam? Click here to flag it for editor review.');
}
$bare = isset($_GET['bare']) ? ( $_GET['bare'] == 1 ) : FALSE;
?>
<?php if (!$bare): ?>
<?php $this->layout = 'amo2009'; ?>
<div class="secondary" role="complementary">
    <?=$this->renderElement('amo2009/categories')?>
</div>

<div id="content-main" class="primary" role="main">
    <?=$this->renderElement('amo2009/search')?>

<h2><?=sprintf(___('Reviews for %s', 'reviews_header'), $addon['Translation']['name']['string']);?></h2>
<?php else: ?>
<div class="other-reviews">
<?php endif ?>

<ul>
    <li><?=$html->link(sprintf(___('Back to %1$s...'), $addon['Translation']['name']['string']), '/addon/'.$addon['Addon']['id']); ?></li>
    <?
    if (empty($isAuthor)) {
        if (!empty($hasreview)) {
            $add_or_edit = ___('Edit your review');
        } else {
            $add_or_edit = ___('Add a review');
        }
        echo '<li>'.$html->link($add_or_edit, '/reviews/add/'.$addon['Addon']['id']).'</li>';
    }
    ?>
</ul>

<div class="clearboth"> <hr /> </div>

<?php
foreach ($reviews as $review):
    $review_id = $review['Review']['id'];
    $review['Translation'] = (array_key_exists(LANG, $review['Translation']) ?
        $review['Translation'][LANG] : current($review['Translation']));
?>
    <div class="item review" id="review-<?=$review['Review']['id']?>">
    <h3><?=$review['Translation']['title']['string']?></h3>

    <div class="reviewed-on">
        <?=$this->renderElement('amo2009/stars',array('rating' => $review['Review']['rating']))?>
        <?php
            echo sprintf(___('by %1$s on %2$s'),
                     $html->linkUserFromModel($review['User']),
                     strftime(___('%B %e, %Y'), strtotime($review['Review']['created'])));
        ?>
        <?=($isAuthor || $isAdmin) ? '['.$html->link(___('Reply', 'addon_review_author_reply_link'), "/reviews/reply/{$review['Review']['id']}").']' : '' ?>
        <?=($canDelete) ? '['.$html->link(___('Delete'), "/reviews/delete/{$review['Review']['id']}").']' : ''?>

        <?php /* Show either the review moderation form, or display a
                 thank you message if this user already has flagged this review. */ ?>
        <?php if ($loggedin): ?>
            <?php
                $review_flag_name = isset($reviews_flagged[$review_id]) ?
                    $reviews_flagged[$review_id]['flag_name'] : '';
            ?>
            <?php if ($review_flag_name): ?>

                <?php /* If there's already a flag for this review from this
                        user, re-display the thank you message without a flag
                        form. */ ?>
                <p class="flag-thanks"><?php echo ___('Thanks; this review has been flagged for editor approval.') ?></p>

            <?php else: ?>

                <?php echo $html->formTag('/reviews/flag', 'post',
                        array('id' => "flag-{$review['Review']['id']}",
                              'class' => 'flag')); ?>
                    <span class="reason">
                        <span class="error"></span>
                        <select id="data[ReviewsModerationFlag][flag_name]"
                                name="data[ReviewsModerationFlag][flag_name]">
                            <option value=""> - <?php echo ___('Report this review (select a reason)') ?> - </option>
                            <?php foreach ($review_flag_reasons as $reason=>$label): ?>
                                <option value="<?php echo $reason ?>"><?php echo $label ?></option>
                            <?php endforeach ?>
                        </select>
                    </span>
                    <?php
                        echo $html->hidden('Review/id',
                            array('value'=>$review_id, 'class'=>'ReviewId'));
                        echo $html->input('ReviewsModerationFlag/flag_notes',
                            array('type'=>'text', 'size'=>'50', 'maxsize'=>'100', 'value'=>'', 'class'=>'FlagNotes hide-with-js'));
                        echo $html->submit($_review_flag_this,
                            array('title'=>$_review_flag_this_titletip, 'class'=>'FlagSubmit hide-with-js'));
                    ?>
                </form>

            <?php endif; ?>
        <?php endif; ?>

    </div>
    <?=nl2br($review['Translation']['body']['string'])?>

    <?php if ($other_count = @($reviews_others_counts[$review['Review']['id']])): ?>
        <?php /* Construct the link to reveal previous reviews by this user. */ ?>
        <div class="others-by-user" id="others-by-user-<?=$review['Review']['id']?>">
            <?php $r_user = $review['User'] ?>
            <?=$html->link(
                sprintf(
                    n___('See %1$s previous review submitted by %2$s for this add-on.',
                        'See %1$s previous reviews submitted by %2$s for this add-on.', $other_count),
                    $other_count,
                    $r_user['nickname'] ? $r_user['nickname'] :
                        $r_user['firstname'] . ' ' . $r_user['lastname']
                ),
                '/reviews/display/'.$addon['Addon']['id'].'?user_id='.$review['User']['id']
            ) ?>
        </div>
    <?php endif ?>

    </div>

    <?php if ($other_count = @($reviews_others_counts[$review['Review']['id']])): ?>
        <div class="others-by-user-load" id="others-by-user-load-<?=$review['Review']['id']?>">
        </div>
    <?php endif ?>

    <?php // developer reply?
    if (!empty($review['Review']['reply'])):
    $reply = $review['Review']['reply'];
    $reply['Translation'] = (array_key_exists(LANG, $reply['Translation']) ?
        $reply['Translation'][LANG] : current($reply['Translation']));
    $reply_id = $reply['Review']['id'];
    ?>
        <div class="review review-reply" id="review-<?=$reply['Review']['id']?>">
        <h3><?=___('Developer Reply:') .' '. $reply['Translation']['title']['string']?></h3>

        <div class="reviewed-on">
            <?=sprintf(___('Reply by %1$s on %2$s'), $html->linkUserFromModel($reply['User']), strftime(___('%B %e, %Y'), strtotime($reply['Review']['created']))) ?>
            <?=($canDelete) ? '['.$html->link(___('Delete'), "/reviews/delete/{$reply['Review']['id']}").']' : ''?>

            <?php /* Show either the review moderation form, or display a
                     thank you message if this user already has flagged this review. */ ?>
            <?php if ($loggedin): ?>
                <?php
                    $review_flag_name = isset($reviews_flagged[$reply_id]) ?
                        $reviews_flagged[$reply_id]['flag_name'] : '';
                ?>
                <?php if ($review_flag_name): ?>

                    <?php /* If there's already a flag for this review from this
                            user, re-display the thank you message without a flag
                            form. */ ?>
                    <p class="flag-thanks"><?php echo ___('Thanks; this review has been flagged for editor approval.') ?></p>

                <?php else: ?>

                    <?php echo $html->formTag('/reviews/flag', 'post',
                            array('id' => "flag-{$reply_id}", 'class' => 'flag')); ?>
                        <span class="reason">
                            <span class="error"></span>
                            <select id="data[ReviewsModerationFlag][flag_name]"
                                    name="data[ReviewsModerationFlag][flag_name]">
                                <option value=""> - <?php echo ___('Report this review (select a reason)') ?> - </option>
                                <?php foreach ($review_flag_reasons as $reason=>$label): ?>
                                    <option value="<?php echo $reason ?>"><?php echo $label ?></option>
                                <?php endforeach ?>
                            </select>
                        </span>
                        <?php
                            echo $html->hidden('Review/id',
                                array('value'=>$reply_id, 'class'=>'ReviewId'));
                            echo $html->input('ReviewsModerationFlag/flag_notes',
                                array('type'=>'text', 'size'=>'50', 'maxsize'=>'100', 'value'=>'', 'class'=>'FlagNotes hide-with-js'));
                            echo $html->submit($_review_flag_this,
                                array('title'=>$_review_flag_this_titletip, 'class'=>'FlagSubmit hide-with-js'));
                        ?>
                    </form>

                <?php endif; ?>
            <?php endif; ?>

        </div>
        <?=nl2br($reply['Translation']['body']['string'])?>
        </div>
    <?php endif; ?>
<php? endforeach; ?>

<?php if (!$bare): ?>
<?php if (!empty($reviews)) echo $this->renderElement('amo2009/pagination');?>
<div class="clearboth"> <hr /> </div>

<ul>
    <li><?=$html->link(sprintf(___('Back to %1$s...'), $addon['Translation']['name']['string']), '/addon/'.$addon['Addon']['id']); ?></li>
    <?
    if (empty($isAuthor)) {
        if (!empty($hasreview)) {
            $add_or_edit = ___('Edit your review');
        } else {
            $add_or_edit = ___('Add a review');
        }
        echo '<li>'.$html->link($add_or_edit, '/reviews/add/'.$addon['Addon']['id']).'</li>';
    }
    ?>
</ul>

<?php /* reviews javascript for ajax actions and the like */ ?>
<script type="text/javascript">
var flagurl = '<?=$html->url('/reviews/flag')?>';
</script>
<?php echo $javascript->link('reviews')."\n"; ?>
    </div>
</div>
<?php else: ?>
</div>
<?php endif ?>