Index: trunk/phase3/includes/Credits.php |
— | — | @@ -21,30 +21,29 @@ |
22 | 22 | */ |
23 | 23 | |
24 | 24 | class Credits { |
25 | | - |
26 | 25 | /** |
27 | 26 | * This is largely cadged from PageHistory::history |
28 | 27 | * @param $article Article object |
29 | 28 | */ |
30 | 29 | public static function showPage( Article $article ) { |
31 | 30 | global $wgOut; |
32 | | - |
| 31 | + |
33 | 32 | wfProfileIn( __METHOD__ ); |
34 | | - |
| 33 | + |
35 | 34 | $wgOut->setPageTitle( $article->mTitle->getPrefixedText() ); |
36 | 35 | $wgOut->setSubtitle( wfMsg( 'creditspage' ) ); |
37 | 36 | $wgOut->setArticleFlag( false ); |
38 | 37 | $wgOut->setArticleRelated( true ); |
39 | 38 | $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
40 | | - |
41 | | - if( $article->mTitle->getArticleID() == 0 ) { |
| 39 | + |
| 40 | + if ( $article->mTitle->getArticleID() == 0 ) { |
42 | 41 | $s = wfMsg( 'nocredits' ); |
43 | 42 | } else { |
44 | 43 | $s = self::getCredits( $article, -1 ); |
45 | 44 | } |
46 | | - |
| 45 | + |
47 | 46 | $wgOut->addHTML( $s ); |
48 | | - |
| 47 | + |
49 | 48 | wfProfileOut( __METHOD__ ); |
50 | 49 | } |
51 | 50 | |
— | — | @@ -59,7 +58,7 @@ |
60 | 59 | wfProfileIn( __METHOD__ ); |
61 | 60 | $s = ''; |
62 | 61 | |
63 | | - if( isset( $cnt ) && $cnt != 0 ){ |
| 62 | + if ( isset( $cnt ) && $cnt != 0 ) { |
64 | 63 | $s = self::getAuthor( $article ); |
65 | 64 | if ( $cnt > 1 || $cnt < 0 ) { |
66 | 65 | $s .= ' ' . self::getContributors( $article, $cnt - 1, $showIfMax ); |
— | — | @@ -74,13 +73,13 @@ |
75 | 74 | * Get the last author with the last modification time |
76 | 75 | * @param $article Article object |
77 | 76 | */ |
78 | | - protected static function getAuthor( Article $article ){ |
| 77 | + protected static function getAuthor( Article $article ) { |
79 | 78 | global $wgLang; |
80 | 79 | |
81 | 80 | $user = User::newFromId( $article->getUser() ); |
82 | 81 | |
83 | 82 | $timestamp = $article->getTimestamp(); |
84 | | - if( $timestamp ){ |
| 83 | + if ( $timestamp ) { |
85 | 84 | $d = $wgLang->date( $article->getTimestamp(), true ); |
86 | 85 | $t = $wgLang->time( $article->getTimestamp(), true ); |
87 | 86 | } else { |
— | — | @@ -99,62 +98,62 @@ |
100 | 99 | */ |
101 | 100 | protected static function getContributors( Article $article, $cnt, $showIfMax ) { |
102 | 101 | global $wgLang, $wgHiddenPrefs; |
103 | | - |
| 102 | + |
104 | 103 | $contributors = $article->getContributors(); |
105 | | - |
| 104 | + |
106 | 105 | $others_link = false; |
107 | | - |
| 106 | + |
108 | 107 | # Hmm... too many to fit! |
109 | | - if( $cnt > 0 && $contributors->count() > $cnt ){ |
| 108 | + if ( $cnt > 0 && $contributors->count() > $cnt ) { |
110 | 109 | $others_link = self::othersLink( $article ); |
111 | | - if( !$showIfMax ) |
| 110 | + if ( !$showIfMax ) |
112 | 111 | return wfMsgExt( 'othercontribs', 'parsemag', $others_link, $contributors->count() ); |
113 | 112 | } |
114 | | - |
| 113 | + |
115 | 114 | $real_names = array(); |
116 | 115 | $user_names = array(); |
117 | 116 | $anon_ips = array(); |
118 | | - |
| 117 | + |
119 | 118 | # Sift for real versus user names |
120 | | - foreach( $contributors as $user ) { |
| 119 | + foreach ( $contributors as $user ) { |
121 | 120 | $cnt--; |
122 | | - if( $user->isLoggedIn() ){ |
| 121 | + if ( $user->isLoggedIn() ) { |
123 | 122 | $link = self::link( $user ); |
124 | | - if( !in_array( 'realname', $wgHiddenPrefs ) && $user->getRealName() ) |
| 123 | + if ( !in_array( 'realname', $wgHiddenPrefs ) && $user->getRealName() ) |
125 | 124 | $real_names[] = $link; |
126 | 125 | else |
127 | 126 | $user_names[] = $link; |
128 | 127 | } else { |
129 | 128 | $anon_ips[] = self::link( $user ); |
130 | 129 | } |
131 | | - if( $cnt == 0 ) break; |
| 130 | + if ( $cnt == 0 ) break; |
132 | 131 | } |
133 | | - |
| 132 | + |
134 | 133 | if ( count( $real_names ) ) { |
135 | 134 | $real = $wgLang->listToText( $real_names ); |
136 | 135 | } else { |
137 | 136 | $real = false; |
138 | 137 | } |
139 | | - |
| 138 | + |
140 | 139 | # "ThisSite user(s) A, B and C" |
141 | | - if( count( $user_names ) ){ |
| 140 | + if ( count( $user_names ) ) { |
142 | 141 | $user = wfMsgExt( 'siteusers', array( 'parsemag' ), |
143 | 142 | $wgLang->listToText( $user_names ), count( $user_names ) ); |
144 | 143 | } else { |
145 | 144 | $user = false; |
146 | 145 | } |
147 | 146 | |
148 | | - if( count( $anon_ips ) ){ |
| 147 | + if ( count( $anon_ips ) ) { |
149 | 148 | $anon = wfMsgExt( 'anonusers', array( 'parsemag' ), |
150 | 149 | $wgLang->listToText( $anon_ips ), count( $anon_ips ) ); |
151 | 150 | } else { |
152 | 151 | $anon = false; |
153 | 152 | } |
154 | | - |
| 153 | + |
155 | 154 | # This is the big list, all mooshed together. We sift for blank strings |
156 | 155 | $fulllist = array(); |
157 | | - foreach( array( $real, $user, $anon, $others_link ) as $s ){ |
158 | | - if( $s ){ |
| 156 | + foreach ( array( $real, $user, $anon, $others_link ) as $s ) { |
| 157 | + if ( $s ) { |
159 | 158 | array_push( $fulllist, $s ); |
160 | 159 | } |
161 | 160 | } |
— | — | @@ -163,7 +162,7 @@ |
164 | 163 | $creds = $wgLang->listToText( $fulllist ); |
165 | 164 | |
166 | 165 | # "Based on work by ..." |
167 | | - return strlen( $creds ) |
| 166 | + return strlen( $creds ) |
168 | 167 | ? wfMsgExt( 'othercontribs', 'parsemag', $creds, count( $fulllist ) ) |
169 | 168 | : ''; |
170 | 169 | } |
— | — | @@ -175,7 +174,7 @@ |
176 | 175 | */ |
177 | 176 | protected static function link( User $user ) { |
178 | 177 | global $wgUser, $wgHiddenPrefs; |
179 | | - if( !in_array( 'realname', $wgHiddenPrefs ) && !$user->isAnon() ) |
| 178 | + if ( !in_array( 'realname', $wgHiddenPrefs ) && !$user->isAnon() ) |
180 | 179 | $real = $user->getRealName(); |
181 | 180 | else |
182 | 181 | $real = false; |
— | — | @@ -195,13 +194,13 @@ |
196 | 195 | */ |
197 | 196 | protected static function userLink( User $user ) { |
198 | 197 | $link = self::link( $user ); |
199 | | - if( $user->isAnon() ){ |
| 198 | + if ( $user->isAnon() ) { |
200 | 199 | return wfMsgExt( 'anonuser', array( 'parseinline', 'replaceafter' ), $link ); |
201 | 200 | } else { |
202 | 201 | global $wgHiddenPrefs; |
203 | | - if( !in_array( 'realname', $wgHiddenPrefs ) && $user->getRealName() ) |
| 202 | + if ( !in_array( 'realname', $wgHiddenPrefs ) && $user->getRealName() ) |
204 | 203 | return $link; |
205 | | - else |
| 204 | + else |
206 | 205 | return wfMsgExt( 'siteuser', array( 'parseinline', 'replaceafter' ), $link ); |
207 | 206 | } |
208 | 207 | } |
— | — | @@ -214,6 +213,12 @@ |
215 | 214 | protected static function othersLink( Article $article ) { |
216 | 215 | global $wgUser; |
217 | 216 | $skin = $wgUser->getSkin(); |
218 | | - return $skin->link( $article->getTitle(), wfMsgHtml( 'others' ), array(), array( 'action' => 'credits' ), array( 'known' ) ); |
| 217 | + return $skin->link( |
| 218 | + $article->getTitle(), |
| 219 | + wfMsgHtml( 'others' ), |
| 220 | + array(), |
| 221 | + array( 'action' => 'credits' ), |
| 222 | + array( 'known' ) |
| 223 | + ); |
219 | 224 | } |
220 | 225 | } |