@@ -7,6 +7,7 @@ $title = 'Contributors';
7
7
$ description = 'The top contributors to BNETDocs grouped by different types of content. ' ;
8
8
$ this ->opengraph ->attach (new Pair ('url ' , '/credits ' ));
9
9
$ total_users = $ this ->getContext ()->total_users ;
10
+ $ top_contributors_by_comments = $ this ->getContext ()->top_contributors_by_comments ;
10
11
$ top_contributors_by_documents = $ this ->getContext ()->top_contributors_by_documents ;
11
12
$ top_contributors_by_news_posts = $ this ->getContext ()->top_contributors_by_news_posts ;
12
13
$ top_contributors_by_packets = $ this ->getContext ()->top_contributors_by_packets ;
@@ -18,127 +19,178 @@ require('./header.inc.phtml');
18
19
<h2>Contributors</h2>
19
20
<p>We have a total of <strong><?= number_format ($ total_users )?> users</strong>, of which the following are our top contributors grouped by content.</p>
20
21
22
+ <h3>Comments</h3>
23
+ <p>Top contributors by most comments made.</p>
24
+ <table class="table table-hover table-striped"><thead>
25
+ <tr><th>Rank</th><th>Who</th><th>Sum</th></tr>
26
+ </thead><tbody>
27
+ <? $ rank = 0 ;
28
+ foreach ($ top_contributors_by_comments as $ item )
29
+ {
30
+ ++$ rank ;
31
+ $ item_name = filter_var ($ item ->name , FILTER_SANITIZE_FULL_SPECIAL_CHARS );
32
+ $ item_sum = number_format ($ item ->comments_made );
33
+ $ item_sum_str = sprintf ('%d comment%s ' , $ item_sum , ($ item_sum != 1 ? 's ' : '' ));
34
+ if (is_null ($ item ->user_id ))
35
+ {
36
+ $ item_user = null ;
37
+ $ item_user_string = $ item_name ;
38
+ }
39
+ else
40
+ {
41
+ $ item_user = $ users [$ item ->user_id ] ?? null ;
42
+ if (!$ item_user )
43
+ {
44
+ $ users [$ item ->user_id ] = $ item_user = new User ($ item ->user_id );
45
+ }
46
+
47
+ $ item_user_string = sprintf ('<a href="%s"><img class="rounded mr-2" src="%s"/>%s</a> ' ,
48
+ $ users [$ item ->user_id ]->getURI (),
49
+ $ users [$ item ->user_id ]->getAvatarURI (22 ),
50
+ $ item_name
51
+ );
52
+ }
53
+ printf ('<tr><td>%s</td><td>%s</td><td>%s</td></tr>%s ' , $ rank , $ item_user_string , $ item_sum_str , PHP_EOL );
54
+ } ?>
55
+ </tbody></table>
56
+
21
57
<h3>Documents</h3>
22
58
<p>Top contributors by most documents authored.</p>
23
59
<table class="table table-hover table-striped"><thead>
24
- <tr>
25
- <th class="rank">Rank</th>
26
- <th class="who">Who</th>
27
- <th class="sum">Sum</th>
28
- </tr>
60
+ <tr><th>Rank</th><th>Who</th><th>Sum</th></tr>
29
61
</thead><tbody>
30
62
<? $ rank = 0 ;
31
- foreach ($ top_contributors_by_documents as $ item ) {
63
+ foreach ($ top_contributors_by_documents as $ item )
64
+ {
32
65
++$ rank ;
33
66
$ item_name = filter_var ($ item ->name , FILTER_SANITIZE_FULL_SPECIAL_CHARS );
34
67
$ item_sum = number_format ($ item ->documents_authored );
35
- $ item_sum_str = sprintf ('%d document ' , $ item_sum );
36
- if ($ item_sum != 1 ) $ item_sum_str .= 's ' ;
37
- if (is_null ($ item ->user_id )) {
38
- echo '<tr><td> ' . $ rank . '</td><td> ' . $ item_name . '</td><td> ' . $ item_sum_str . '</td></tr> ' . PHP_EOL ;
39
- } else {
40
- if (!isset ($ users [$ item ->user_id ])) $ users [$ item ->user_id ] = new User ($ item ->user_id );
41
- $ item_user = sprintf (
42
- '<a href="%s"><img src="%s"/> %s</a> ' ,
68
+ $ item_sum_str = sprintf ('%d document%s ' , $ item_sum , ($ item_sum != 1 ? 's ' : '' ));
69
+ if (is_null ($ item ->user_id ))
70
+ {
71
+ $ item_user = null ;
72
+ $ item_user_string = $ item_name ;
73
+ }
74
+ else
75
+ {
76
+ $ item_user = $ users [$ item ->user_id ] ?? null ;
77
+ if (!$ item_user )
78
+ {
79
+ $ users [$ item ->user_id ] = $ item_user = new User ($ item ->user_id );
80
+ }
81
+
82
+ $ item_user_string = sprintf ('<a href="%s"><img class="rounded mr-2" src="%s"/>%s</a> ' ,
43
83
$ users [$ item ->user_id ]->getURI (),
44
84
$ users [$ item ->user_id ]->getAvatarURI (22 ),
45
85
$ item_name
46
86
);
47
87
}
48
- echo '<tr><td> ' . $ rank . ' </td><td> ' . $ item_user . ' </td><td> ' . $ item_sum_str . ' </td></tr> ' . PHP_EOL ;
88
+ printf ( '<tr><td>%s </td><td>%s </td><td>%s </td></tr>%s ' , $ rank , $ item_user_string , $ item_sum_str , PHP_EOL ) ;
49
89
} ?>
50
90
</tbody></table>
51
91
52
92
<h3>News Posts</h3>
53
93
<p>Top contributors by most news posts created.</p>
54
94
<table class="table table-hover table-striped"><thead>
55
- <tr>
56
- <th class="rank">Rank</th>
57
- <th class="who">Who</th>
58
- <th class="sum">Sum</th>
59
- </tr>
95
+ <tr><th>Rank</th><th>Who</th><th>Sum</th></tr>
60
96
</thead><tbody>
61
97
<? $ rank = 0 ;
62
- foreach ($ top_contributors_by_news_posts as $ item ) {
98
+ foreach ($ top_contributors_by_news_posts as $ item )
99
+ {
63
100
++$ rank ;
64
101
$ item_name = filter_var ($ item ->name , FILTER_SANITIZE_FULL_SPECIAL_CHARS );
65
102
$ item_sum = number_format ($ item ->news_posts_created );
66
- $ item_sum_str = sprintf ('%d news post ' , $ item_sum );
67
- if ($ item_sum != 1 ) $ item_sum_str .= 's ' ;
68
- if (is_null ($ item ->user_id )) {
69
- echo '<tr><td> ' . $ rank . '</td><td> ' . $ item_name . '</td><td> ' . $ item_sum_str . '</td></tr> ' . PHP_EOL ;
70
- } else {
71
- if (!isset ($ users [$ item ->user_id ])) $ users [$ item ->user_id ] = new User ($ item ->user_id );
72
- $ item_user = sprintf (
73
- '<a href="%s"><img src="%s"/> %s</a> ' ,
103
+ $ item_sum_str = sprintf ('%d news post%s ' , $ item_sum , ($ item_sum != 1 ? 's ' : '' ));
104
+ if (is_null ($ item ->user_id ))
105
+ {
106
+ $ item_user = null ;
107
+ $ item_user_string = $ item_name ;
108
+ }
109
+ else
110
+ {
111
+ $ item_user = $ users [$ item ->user_id ] ?? null ;
112
+ if (!$ item_user )
113
+ {
114
+ $ users [$ item ->user_id ] = $ item_user = new User ($ item ->user_id );
115
+ }
116
+
117
+ $ item_user_string = sprintf ('<a href="%s"><img class="rounded mr-2" src="%s"/>%s</a> ' ,
74
118
$ users [$ item ->user_id ]->getURI (),
75
119
$ users [$ item ->user_id ]->getAvatarURI (22 ),
76
120
$ item_name
77
121
);
78
- echo '<tr><td> ' . $ rank . '</td><td> ' . $ item_user . '</td><td> ' . $ item_sum_str . '</td></tr> ' . PHP_EOL ;
79
122
}
123
+ printf ('<tr><td>%s</td><td>%s</td><td>%s</td></tr>%s ' , $ rank , $ item_user_string , $ item_sum_str , PHP_EOL );
80
124
} ?>
81
125
</tbody></table>
82
126
83
127
<h3>Packets</h3>
84
128
<p>Top contributors by most packets authored.</p>
85
129
<table class="table table-hover table-striped"><thead>
86
- <tr>
87
- <th class="rank">Rank</th>
88
- <th class="who">Who</th>
89
- <th class="sum">Sum</th>
90
- </tr>
130
+ <tr><th>Rank</th><th>Who</th><th>Sum</th></tr>
91
131
</thead><tbody>
92
132
<? $ rank = 0 ;
93
- foreach ($ top_contributors_by_packets as $ item ) {
133
+ foreach ($ top_contributors_by_packets as $ item )
134
+ {
94
135
++$ rank ;
95
136
$ item_name = filter_var ($ item ->name , FILTER_SANITIZE_FULL_SPECIAL_CHARS );
96
137
$ item_sum = number_format ($ item ->packets_authored );
97
- $ item_sum_str = sprintf ('%d packet ' , $ item_sum );
98
- if ($ item_sum != 1 ) $ item_sum_str .= 's ' ;
99
- if (is_null ($ item ->user_id )) {
100
- echo '<tr><td> ' . $ rank . '</td><td> ' . $ item_name . '</td><td> ' . $ item_sum_str . '</td></tr> ' . PHP_EOL ;
101
- } else {
102
- if (!isset ($ users [$ item ->user_id ])) $ users [$ item ->user_id ] = new User ($ item ->user_id );
103
- $ item_user = sprintf (
104
- '<a href="%s"><img src="%s"/> %s</a> ' ,
138
+ $ item_sum_str = sprintf ('%d packet%s ' , $ item_sum , ($ item_sum != 1 ? 's ' : '' ));
139
+ if (is_null ($ item ->user_id ))
140
+ {
141
+ $ item_user = null ;
142
+ $ item_user_string = $ item_name ;
143
+ }
144
+ else
145
+ {
146
+ $ item_user = $ users [$ item ->user_id ] ?? null ;
147
+ if (!$ item_user )
148
+ {
149
+ $ users [$ item ->user_id ] = $ item_user = new User ($ item ->user_id );
150
+ }
151
+
152
+ $ item_user_string = sprintf ('<a href="%s"><img class="rounded mr-2" src="%s"/>%s</a> ' ,
105
153
$ users [$ item ->user_id ]->getURI (),
106
154
$ users [$ item ->user_id ]->getAvatarURI (22 ),
107
155
$ item_name
108
156
);
109
- echo '<tr><td> ' . $ rank . '</td><td> ' . $ item_user . '</td><td> ' . $ item_sum_str . '</td></tr> ' . PHP_EOL ;
110
157
}
158
+ printf ('<tr><td>%s</td><td>%s</td><td>%s</td></tr>%s ' , $ rank , $ item_user_string , $ item_sum_str , PHP_EOL );
111
159
} ?>
112
160
</tbody></table>
113
161
114
162
<h3>Servers</h3>
115
163
<p>Top contributors by most servers owned.</p>
116
164
<table class="table table-hover table-striped"><thead>
117
- <tr>
118
- <th class="rank">Rank</th>
119
- <th class="who">Who</th>
120
- <th class="sum">Sum</th>
121
- </tr>
165
+ <tr><th>Rank</th><th>Who</th><th>Sum</th></tr>
122
166
</thead><tbody>
123
167
<? $ rank = 0 ;
124
- foreach ($ top_contributors_by_servers as $ item ) {
168
+ foreach ($ top_contributors_by_servers as $ item )
169
+ {
125
170
++$ rank ;
126
171
$ item_name = filter_var ($ item ->name , FILTER_SANITIZE_FULL_SPECIAL_CHARS );
127
172
$ item_sum = number_format ($ item ->servers_owned );
128
- $ item_sum_str = sprintf ('%d server ' , $ item_sum );
129
- if ($ item_sum != 1 ) $ item_sum_str .= 's ' ;
130
- if (is_null ($ item ->user_id )) {
131
- echo '<tr><td> ' . $ rank . '</td><td> ' . $ item_name . '</td><td> ' . $ item_sum_str . '</td></tr> ' . PHP_EOL ;
132
- } else {
133
- if (!isset ($ users [$ item ->user_id ])) $ users [$ item ->user_id ] = new User ($ item ->user_id );
134
- $ item_user = sprintf (
135
- '<a href="%s"><img src="%s"/> %s</a> ' ,
173
+ $ item_sum_str = sprintf ('%d server%s ' , $ item_sum , ($ item_sum != 1 ? 's ' : '' ));
174
+ if (is_null ($ item ->user_id ))
175
+ {
176
+ $ item_user = null ;
177
+ $ item_user_string = $ item_name ;
178
+ }
179
+ else
180
+ {
181
+ $ item_user = $ users [$ item ->user_id ] ?? null ;
182
+ if (!$ item_user )
183
+ {
184
+ $ users [$ item ->user_id ] = $ item_user = new User ($ item ->user_id );
185
+ }
186
+
187
+ $ item_user_string = sprintf ('<a href="%s"><img class="rounded mr-2" src="%s"/>%s</a> ' ,
136
188
$ users [$ item ->user_id ]->getURI (),
137
189
$ users [$ item ->user_id ]->getAvatarURI (22 ),
138
190
$ item_name
139
191
);
140
- echo '<tr><td> ' . $ rank . '</td><td> ' . $ item_user . '</td><td> ' . $ item_sum_str . '</td></tr> ' . PHP_EOL ;
141
192
}
193
+ printf ('<tr><td>%s</td><td>%s</td><td>%s</td></tr>%s ' , $ rank , $ item_user_string , $ item_sum_str , PHP_EOL );
142
194
} ?>
143
195
</tbody></table>
144
196
</div>
0 commit comments