Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/site/app/views/statistics/addon.thtml
blob: ea8ff9d9c3a003d920ab272c35acc97bc43c7c0c (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
253
254
255
256
257
258
259
<?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) 2008
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *   Justin Scott <fligtar@mozilla.com> (Original Author)
 *
 * 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 ***** */ 

echo '<div id="content">';
    if ($this->controller->Config->getValue('stats_updating')) {
        echo '<div class="warning"><div>'._('statistics_notice_data_updating').'</div></div>';
    }
    if (isset($_GET['settings'])) {
        echo '<div class="notice-updated">'._('statistics_notice_settings_updated').'</div>';
    }
?>
    
    <div class="bluebox-tr"><div class="bluebox-tl">
        <div style="min-height: 32px; padding: 10px;">
            <div style="text-align: right; float: right;">
                <?php
                if (!empty($all_addons)) {
                    echo _('statistics_addon_switch').':';
                    echo $html->selectTag('Addon/id', $all_addons, $addon_id, array('onChange' => 'changeAddon(this);'), null, false).'<br>';
                }
                ?>
                <span style="font-size: 10px;">
                    <?=$html->link(_('statistics_addon_developertools_link'), '/developers')?> |
                    <?=$html->link(_('statistics_addon_dashboard_link'), '/statistics')?> |
                    <a href="#" onclick="$('#helpbox').toggle(); return false;"><?=_('statistics_help_link')?></a>
                </span>
            </div>
            <div>
                <img id="addon-icon" src="<?=$addonIcon?>" alt="<?=$addon_name?> Icon" style="padding-right: 5px; float: left;">
                <h3 style="line-height: 2;"><?=sprintf(_('statistics_title_addon_stats'), $addon_name)?></h3>
            </div>
        </div>
        
        <div id="helpbox" style="display: none;">
            <?=$localization->includeLocalPage('statistics_help')?>
            <a href="#" onclick="$('#helpbox').hide(); return false;"><?=_('statistics_help_close_link')?></a>
        </div>
        
        <?php if ($stats['totaldownloads'] > 0): ?>
        <div id="plot-options" style="display: none;">
            <div id="plot-selector-area"></div>
            <div id="plot-selection">
                <div id="summary-legend">
                    <div class="plot-legend">
                        <div class="colorbox" style="background-color: #33AAFF;"></div>
                        <div class="plot-name"><?=_('statistics_plot_legend_downloads')?></div>
                    </div>
                    <div class="plot-legend">
                        <div class="colorbox" style="background-color: #EE3322;"></div>
                        <div class="plot-name"><?=_('statistics_plot_legend_adu')?></div>
                    </div>
                </div>
            </div>
            <div id="options-area">
                <?=$html->image('stats/cog.png', array('id' => 'options-cog', 'style' => 'display: none;', 'alt' => ''));?>
                <div id="summary-options">
                    <div id="zoom-in" class="zoom-button" onclick="Plots.summary.zoomIn();" title="<?=_('statistics_plot_options_zoomin_title')?>">
                        <?=$html->image('stats/zoom_in.png', array('alt' => _('statistics_plot_options_zoomin_alt')))?>
                    </div>
                    <div id="zoom-out" class="zoom-button" onclick="Plots.summary.zoomOut();" title="<?=_('statistics_plot_options_zoomout_title')?>">
                        <?=$html->image('stats/zoom_out.png', array('alt' => _('statistics_plot_options_zoomout_alt')))?>
                    </div>
                </div>
            </div>
        </div>
        
        <div id="timeplot-container">
            <div id="not-enough-data" class="warning" style="display: none;"><div>
                <?=_('statistics_notice_data_insufficient')?>
            </div></div>
            
            <noscript>
                <div class="warning"><div>
                    <?=_('statistics_notice_nojavascript')?>
                </div></div>
            </noscript>
        </div>
        
        <?php elseif (!$this->controller->Config->getValue('stats_disabled')): ?>
            <div class="warning"><div>
                <?=_('statistics_notice_data_none')?>
            </div></div>
        <?php endif; ?>
        
        <?php if ($this->controller->Config->getValue('stats_disabled')): ?>
            <div class="warning"><div>
                <?=_('statistics_notice_disabled')?>
            </div></div>
        <?php endif; ?>
        
        <div class="bluebox-br"><div class="bluebox-bl"></div></div>
    </div></div>

<br>

<?php if (!$this->controller->Config->getValue('stats_disabled') || $this->controller->SimpleAcl->actionAllowed('*', '*', $this->controller->Session->read('User'))): ?>
<div class="greenbox-tr"><div class="greenbox-tl">
    <div id="stats-table-container">
        <table width="100%" cellpadding="5" id="stats_overview">
            <tr>
                <td class="biglabel" valign="middle" style="width: 30%;">
                    <?=_('statistics_summary_downloads_total')?>
                    <div class="date"><?=sprintf(_('statistics_summary_downloads_total_sincedate'), strftime(_('statistics_date_shortmonthwithyear'), strtotime($addon['Addon']['created'])))?></div>
                </td>
                <td class="bigvalue" style="width: 19%;"><?=(!empty($stats['totaldownloads']) ? $html->number_format($stats['totaldownloads'], 0) : 0)?></td>
                <td class="spacer" style="width: 2%;"></td>
                <td class="biglabel" valign="middle" style="width: 30%;">
                    <?=_('statistics_summary_updatepings_total')?>
                    <div class="date">
                        <?php
                        if (!empty($stats['last_updatepings_date']))
                            echo sprintf(_('statistics_summary_updatepings_total_ondate'), strftime(_('statistics_date_weekdayshortmonth'), strtotime($stats['last_updatepings_date'])));
                        else
                            echo _('statistics_summary_nodata');
                        ?>
                    </div>
                </td>
                <td class="bigvalue" style="width: 19%;"><?=(!empty($stats['last_updatepings']) ? $html->number_format($stats['last_updatepings'], 0) : 0)?></td>
            </tr>
            <tr>
                <td class="label">
                    <?=_('statistics_summary_downloads_lastcount')?>
                    <div class="date"><?=(!empty($stats['last_downloads_date']) ? strftime(_('statistics_date_weekdayshortmonth'), strtotime($stats['last_downloads_date'])) : '')?></div>
                </td>
                <td class="value"><?=(!empty($stats['last_downloads']) ? $html->number_format($stats['last_downloads'], 0) : 0)?></td>
                <td class="spacer"></td>
                <td class="label">
                    <?=_('statistics_summary_updatepings_changefromprevious')?>
                    <div class="date">
                        <?php
                        if (!empty($stats['previous_updatepings']))
                            echo sprintf(_('statistics_summary_updatepings_changefromprevious_ondate'), $html->number_format($stats['previous_updatepings'], 0), strftime(_('statistics_date_shortmonth'), strtotime($stats['previous_updatepings_date'])));
                        else
                            echo _('statistics_summary_nodata');
                        ?>
                    </div>
                </td>
                <td class="value">
                    <?php
                    if (!empty($stats['updateping_change'])) {
                        if ($stats['updateping_change'] > 0)
                            echo '<span style="color: green;">+';
                        elseif ($stats['updateping_change'] < 0)
                            echo '<span style="color: red;">';
                        else
                            echo '<span style="color: blue;">';
                        echo round($stats['updateping_change'], 2).'%</span>';
                    }
                    else
                        echo '0';
                    ?>
                </td>
            </tr>
            <tr>
                <td class="label"><?=_('statistics_summary_downloads_average')?></td>
                <td class="value"><?=(!empty($stats['avg_downloads']) ? $html->number_format($stats['avg_downloads'], 0) : 0)?></td>
                <td class="spacer"></td>
                <td class="label"><?=_('statistics_summary_updatepings_average')?></td>
                <td class="value"><?=(!empty($stats['avg_updatepings']) ? $html->number_format($stats['avg_updatepings'], 0) : 0)?></td>
            </tr>
            <tr>
                <td class="label"><?=_('statistics_summary_downloads_lastweek')?></td>
                <td class="value"><?=(!empty($stats['weeklydownloads']) ? $html->number_format($stats['weeklydownloads'], 0) : 0)?></td>
                <td class="spacer"></td>
                <td colspan="2" style="text-align: right; vertical-align: baseline;"><?=$html->link($html->image('stats/rss16x16.png'), "/statistics/addon/{$addon['Addon']['id']}/format:rss{$key}", array('title' => _('statistics_rss_icon_title')))?></td>
            </tr>
        </table>
    </div>
    <div class="greenbox-br"><div class="greenbox-bl"></div></div>
</div></div>
<?php endif; ?>

<div id="stats-table">

    <a href="#" class="download"><? echo ___('statistics_js_download_csv', 'View this table in CSV format') ?></a>

    <table class="template">
        <thead>
            <tr class="header">
                <th>--</th>
            </tr>
        </thead>
        <tbody>
            <tr class="row">
                <td class="col"></td>
            </tr>
        </tbody>
    </table>
</div>

    <div id="settings">
    <?php
        if ($addon['Addon']['publicstats'] == 1) {
            echo _('statistics_settings_currently_public');
            echo '&nbsp;'.$html->image('stats/lock_open.png', array('alt' => _('statistics_settings_unlocked_alt')));
        }
        else {
            echo _('statistics_settings_currently_private');
            echo '&nbsp;'.$html->image('stats/lock.png', array('alt' => _('statistics_settings_locked_alt')));
        }
        
        echo '<br>';
        if ($this->controller->Amo->checkOwnership($addon_id, null, true))
            echo $html->link(_('statistics_settings_change_link'), '/statistics/settings/'.$addon_id);
        elseif ($addon['Addon']['publicstats'] != 1)
            echo '<span class="confidential">'._('statistics_settings_confidential').'</span>';
    ?>
    </div>

</div>
<script type="text/javascript">
    var addonID = '<?=$addon_id?>';
    var addonName = '<?=$addon_name?>';
    var statsURL = '<?=$html->url('/statistics/')?>';

    <?php if ($stats['totaldownloads'] > 0): ?>
    $(document).ready(function() {
        $('#plot-options').show();
        plotSelection.loadSummary();
        plotSelection.addPlotSelector();
        plotSelection.addGroupBySelector();
    });
    <?php endif; ?>
</script>