Index: branches/REL1_18/extensions/OnlineStatusBar/OnlineStatusBar.i18n.php |
— | — | @@ -63,6 +63,7 @@ |
64 | 64 | */ |
65 | 65 | $messages['br'] = array( |
66 | 66 | 'onlinestatusbar-line' => '$1 zo bremañ $2 $3', |
| 67 | + 'prefs-onlinestatus' => 'Statud enlinenn', |
67 | 68 | 'onlinestatusbar-status-online' => 'Kevreet', |
68 | 69 | 'onlinestatusbar-status-busy' => 'Soulgarget', |
69 | 70 | 'onlinestatusbar-status-away' => 'Er-maez', |
— | — | @@ -170,8 +171,13 @@ |
171 | 172 | * @author Michawiki |
172 | 173 | */ |
173 | 174 | $messages['hsb'] = array( |
| 175 | + 'onlinestatusbar-desc' => 'Statusowa lajsta, kotraž na zakładźe nastajenjow pokazuje, hač wužiwar je na swojej wužiwarskej stronje online', |
174 | 176 | 'onlinestatusbar-line' => '$1 je nětko $3 $2', |
| 177 | + 'onlinestatusbar-used' => 'Chceće druhich widźeć dać, zo wy sće online?', |
| 178 | + 'onlinestatusbar-status' => 'Što je standardny status, kotryž chceće wužiwać:', |
| 179 | + 'onlinestatusbar-purge' => 'Pufrowak wužiwarskeje strony kóždy raz wuprózdnić, hdyž so přizjewjeće abo wotzjewjeće', |
175 | 180 | 'prefs-onlinestatus' => 'Onlinestatus', |
| 181 | + 'onlinestatusbar-hide' => 'Chceće statusowu lajstu schować, zo byšće jenož magiske słowo wužiwał? (Za pokročenych wužiwarjow)', |
176 | 182 | 'onlinestatusbar-status-online' => 'Online', |
177 | 183 | 'onlinestatusbar-status-busy' => 'Ma dźěło', |
178 | 184 | 'onlinestatusbar-status-away' => 'Preč', |
— | — | @@ -226,6 +232,24 @@ |
227 | 233 | 'onlinestatusbar-status-hidden' => 'Скриен', |
228 | 234 | ); |
229 | 235 | |
| 236 | +/** Malay (Bahasa Melayu) |
| 237 | + * @author Anakmalaysia |
| 238 | + */ |
| 239 | +$messages['ms'] = array( |
| 240 | + 'onlinestatusbar-desc' => 'Palang status yang menunjukkan sama pengguna berada dalam talian atau tidak, berasaskan keutamaan pada laman penggunanya', |
| 241 | + 'onlinestatusbar-line' => '$1 kini $2 $3', |
| 242 | + 'onlinestatusbar-used' => 'Adakah anda ingin orang lain tahu sama ada anda berada dalam talian atau tidak?', |
| 243 | + 'onlinestatusbar-status' => 'Yang manakah status asali yang ingin anda gunakan:', |
| 244 | + 'onlinestatusbar-purge' => 'Singkirkan isi laman pengguna setiap kali ketika log masuk/keluar', |
| 245 | + 'prefs-onlinestatus' => 'Status dalam talian', |
| 246 | + 'onlinestatusbar-hide' => 'Adakah anda ingin menyorokkan palang status demi menggunakan kata sakti sahaja? (Untuk pengguna lebih berpengalaman)', |
| 247 | + 'onlinestatusbar-status-online' => 'Dalam talian', |
| 248 | + 'onlinestatusbar-status-busy' => 'Sibuk', |
| 249 | + 'onlinestatusbar-status-away' => 'Tiada', |
| 250 | + 'onlinestatusbar-status-offline' => 'Luar talian', |
| 251 | + 'onlinestatusbar-status-hidden' => 'Tersorok', |
| 252 | +); |
| 253 | + |
230 | 254 | /** Dutch (Nederlands) |
231 | 255 | * @author SPQRobin |
232 | 256 | * @author Siebrand |
Index: branches/REL1_18/extensions/OnlineStatusBar/OnlineStatusBar.status.php |
— | — | @@ -0,0 +1,205 @@ |
| 2 | +<? |
| 3 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 4 | + echo "This is a part of mediawiki and can't be started separately"; |
| 5 | + die(); |
| 6 | +} |
| 7 | + |
| 8 | +/** |
| 9 | + * File which contains status check for Online status bar extension. |
| 10 | + * |
| 11 | + * @file |
| 12 | + * @ingroup Extensions |
| 13 | + * @author Petr Bena <benapetr@gmail.com> |
| 14 | + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
| 15 | + * @link http://www.mediawiki.org/wiki/Extension:OnlineStatusBar Documentation |
| 16 | + */ |
| 17 | + |
| 18 | +class OnlineStatusBar_StatusCheck { |
| 19 | + /** |
| 20 | + * Return cache key |
| 21 | + * @param $user String |
| 22 | + * @param $type String |
| 23 | + */ |
| 24 | + private static function getCacheKey( $user, $type ) { |
| 25 | + // get a key for cache |
| 26 | + return wfMemcKey( 'onlinestatusbar_cache', $type, $user ); |
| 27 | + } |
| 28 | + |
| 29 | + /** |
| 30 | + * Create a cache |
| 31 | + * @param $user |
| 32 | + * @param $values |
| 33 | + * @return true |
| 34 | + */ |
| 35 | + public static function setCache( $user, $values, $type ) { |
| 36 | + global $wgOnlineStatusBarWriteTime, $wgMemc; |
| 37 | + // get a key |
| 38 | + $cache_key = self::getCacheKey( $user, $type ); |
| 39 | + $wgMemc->set( $cache_key, $values, $wgOnlineStatusBarWriteTime ); |
| 40 | + return true; |
| 41 | + } |
| 42 | + |
| 43 | + /** |
| 44 | + * Return cache value |
| 45 | + */ |
| 46 | + public static function getCache( $user, $type ) { |
| 47 | + global $wgMemc; |
| 48 | + // get a key |
| 49 | + $cache_key = self::getCacheKey( $user, $type ); |
| 50 | + // get a value |
| 51 | + return $wgMemc->get( $cache_key ); |
| 52 | + } |
| 53 | + |
| 54 | + |
| 55 | + /** |
| 56 | + * @param $user User |
| 57 | + * @return String |
| 58 | + */ |
| 59 | + public static function getStatus( $user, $delayed_check = false ) { |
| 60 | + global $wgOnlineStatusBarDefaultOffline, $wgOnlineStatusBarDefaultOnline; |
| 61 | + |
| 62 | + // instead of delete every time just select the records which are not that old |
| 63 | + if ( !$delayed_check ) { |
| 64 | + $t_time = OnlineStatusBar::getTimeoutDate(); |
| 65 | + // first try to use cache |
| 66 | + $result = self::getCache( $user->getName(), "n" ); |
| 67 | + |
| 68 | + if ( $result == '' ) { |
| 69 | + $dbr = wfGetDB( DB_SLAVE ); |
| 70 | + $result = $dbr->selectField( 'online_status', 'timestamp', array( 'username' => $user->getName(), |
| 71 | + "timestamp > " . $dbr->addQuotes( $dbr->timestamp( $t_time ) ) ), |
| 72 | + __METHOD__, array( 'LIMIT 1', 'ORDER BY timestamp DESC' ) ); |
| 73 | + // cache it |
| 74 | + self::setCache( $user->getName(), $result, "n" ); |
| 75 | + } |
| 76 | + } |
| 77 | + else { |
| 78 | + $result = self::getCache( $user->getName(), "d" ); |
| 79 | + |
| 80 | + if ( $result == '' ) { |
| 81 | + $dbr = wfGetDB( DB_SLAVE ); |
| 82 | + $result = $dbr->selectField( 'online_status', 'timestamp', array( 'username' => $user->getName() ), |
| 83 | + __METHOD__, array( 'LIMIT 1', 'ORDER BY timestamp DESC' ) ); |
| 84 | + $w_time = OnlineStatusBar::getTimeoutDate( true ); |
| 85 | + // cache it |
| 86 | + self::setCache( $user->getName(), $result, "d" ); |
| 87 | + } |
| 88 | + } |
| 89 | + |
| 90 | + if ( $result === false ) { |
| 91 | + $status = $wgOnlineStatusBarDefaultOffline; |
| 92 | + } else { |
| 93 | + // let's check if it isn't anon |
| 94 | + if ( $user->isLoggedIn() ) { |
| 95 | + $status = $user->getOption( 'OnlineStatusBar_status', $wgOnlineStatusBarDefaultOnline ); |
| 96 | + if ( $delayed_check ) { |
| 97 | + if ( $result < wfTimestamp( TS_MW, $w_time ) ) { |
| 98 | + $status = 'write'; |
| 99 | + } |
| 100 | + } |
| 101 | + } else { |
| 102 | + $status = $wgOnlineStatusBarDefaultOnline; |
| 103 | + } |
| 104 | + } |
| 105 | + |
| 106 | + if ( $status == 'hidden' && !($delayed_check) ) { |
| 107 | + $status = $wgOnlineStatusBarDefaultOffline; |
| 108 | + } |
| 109 | + |
| 110 | + return $status; |
| 111 | + } |
| 112 | + |
| 113 | + /** |
| 114 | + * Insert to the database |
| 115 | + * @return bool |
| 116 | + */ |
| 117 | + public static function updateDb() { |
| 118 | + global $wgUser; |
| 119 | + // Skip users we don't track |
| 120 | + if ( OnlineStatusBar::isValid ( $wgUser ) != true ) { |
| 121 | + return false; |
| 122 | + } |
| 123 | + // If we track them, let's insert it to the table |
| 124 | + $dbw = wfGetDB( DB_MASTER ); |
| 125 | + $row = array( |
| 126 | + 'username' => $wgUser->getName(), |
| 127 | + 'timestamp' => $dbw->timestamp(), |
| 128 | + ); |
| 129 | + $dbw->insert( 'online_status', $row, __METHOD__ ); |
| 130 | + return false; |
| 131 | + } |
| 132 | + |
| 133 | + /** |
| 134 | + * Delete user who logged out |
| 135 | + * @param $userName string |
| 136 | + * @return bool |
| 137 | + */ |
| 138 | + static function deleteStatus( $userName ) { |
| 139 | + $dbw = wfGetDB( DB_MASTER ); |
| 140 | + $dbw->delete( 'online_status', array( 'username' => $userName ), __METHOD__ ); // delete user |
| 141 | + // remove from cache |
| 142 | + self::setCache( $userName, '', 'd' ); |
| 143 | + self::setCache( $userName, '', 'n' ); |
| 144 | + return true; |
| 145 | + } |
| 146 | + |
| 147 | + /** |
| 148 | + * Update status of user |
| 149 | + * @return bool |
| 150 | + */ |
| 151 | + public static function updateStatus() { |
| 152 | + global $wgUser, $wgOnlineStatusBarDefaultOffline, $wgOnlineStatusBarTrackIpUsers, $wgOnlineStatusBarDefaultEnabled; |
| 153 | + // if anon users are not tracked and user is anon leave it |
| 154 | + if ( !$wgOnlineStatusBarTrackIpUsers ) { |
| 155 | + if ( !$wgUser->isLoggedIn() ) { |
| 156 | + return false; |
| 157 | + } |
| 158 | + } |
| 159 | + // if user doesn't want to be tracked leave it as well for privacy reasons |
| 160 | + if ( $wgUser->isLoggedIn() && !$wgUser->getOption ( "OnlineStatusBar_active", $wgOnlineStatusBarDefaultEnabled ) ) { |
| 161 | + return false; |
| 162 | + } |
| 163 | + $user_status = self::getStatus( $wgUser, true ); |
| 164 | + if ( $user_status == $wgOnlineStatusBarDefaultOffline ) { |
| 165 | + self::updateDb(); |
| 166 | + return true; |
| 167 | + } |
| 168 | + |
| 169 | + if ( $user_status == 'write' ) { |
| 170 | + $dbw = wfGetDB( DB_MASTER ); |
| 171 | + $dbw->update( |
| 172 | + 'online_status', |
| 173 | + array( 'timestamp' => $dbw->timestamp() ), |
| 174 | + array( 'username' => $wgUser->getName() ), |
| 175 | + __METHOD__ |
| 176 | + ); |
| 177 | + self::deleteOld(); |
| 178 | + } |
| 179 | + |
| 180 | + return true; |
| 181 | + } |
| 182 | + |
| 183 | + /** |
| 184 | + * Delete old records from the table, this function is called frequently too keep it as small as possible |
| 185 | + * @return int |
| 186 | + */ |
| 187 | + public static function deleteOld() { |
| 188 | + global $wgOnlineStatusBarAutoDelete; |
| 189 | + if ( !$wgOnlineStatusBarAutoDelete ) { |
| 190 | + return 0; |
| 191 | + } |
| 192 | + $dbw = wfGetDB( DB_MASTER ); |
| 193 | + $t_time = OnlineStatusBar::getTimeoutDate(); |
| 194 | + $result = $dbw->selectField( 'online_status', 'timestamp', array( "timestamp < " . $dbw->addQuotes( $dbw->timestamp( $t_time ) ) ), |
| 195 | + __METHOD__, array( 'LIMIT 1' ) ); |
| 196 | + if ( $result === false ) { |
| 197 | + // no need for delete |
| 198 | + return 0; |
| 199 | + } |
| 200 | + |
| 201 | + // calculate time and convert it back to mediawiki format |
| 202 | + $time = OnlineStatusBar::getTimeoutDate(); |
| 203 | + $dbw->delete( 'online_status', array( "timestamp < " . $dbw->addQuotes( $dbw->timestamp( $time ) ) ), __METHOD__ ); |
| 204 | + return 0; |
| 205 | + } |
| 206 | +} |
Property changes on: branches/REL1_18/extensions/OnlineStatusBar/OnlineStatusBar.status.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 207 | + native |
Index: branches/REL1_18/extensions/OnlineStatusBar/OnlineStatusBarMono.css |
— | — | @@ -20,5 +20,5 @@ |
21 | 21 | |
22 | 22 | div.onlinestatusbarbody { |
23 | 23 | right:0px; |
24 | | - margin-top:-10px; |
| 24 | + margin-top:-2px; |
25 | 25 | } |
Index: branches/REL1_18/extensions/OnlineStatusBar/OnlineStatusBar.body.php |
— | — | @@ -29,19 +29,20 @@ |
30 | 30 | * Returns image element |
31 | 31 | * |
32 | 32 | * @param $mode String |
| 33 | + * @param $mode_text String |
33 | 34 | * @return string |
34 | 35 | */ |
35 | | - public static function GetImageHtml( $mode ) { |
| 36 | + public static function GetImageHtml( $mode, $mode_text ) { |
36 | 37 | global $wgExtensionAssetsPath, $wgOnlineStatusBarIcon; |
37 | 38 | $icon = "$wgExtensionAssetsPath/OnlineStatusBar/{$wgOnlineStatusBarIcon[$mode]}"; |
38 | | - return Html::element( 'img', array( 'src' => $icon ) ); |
| 39 | + return Html::element( 'img', array( 'src' => $icon, 'alt' => $mode_text ) ); |
39 | 40 | } |
40 | 41 | |
41 | 42 | |
42 | 43 | /** |
43 | 44 | * Returns the status and User element |
44 | 45 | * |
45 | | - * @param Title $title |
| 46 | + * @param Title $title a title of page |
46 | 47 | * @return array|bool Array containing the status and User object |
47 | 48 | */ |
48 | 49 | public static function getAnonFromTitle( Title $title ) { |
— | — | @@ -50,7 +51,7 @@ |
51 | 52 | if ( $wgOnlineStatusBarTrackIpUsers == false ) { |
52 | 53 | return false; |
53 | 54 | } |
54 | | - |
| 55 | + |
55 | 56 | // checks ns |
56 | 57 | if ( $title->getNamespace() != NS_USER && $title->getNamespace() != NS_USER_TALK ) { |
57 | 58 | return false; |
— | — | @@ -65,7 +66,7 @@ |
66 | 67 | return false; |
67 | 68 | } |
68 | 69 | |
69 | | - $status = self::getStatus( $user, true ); |
| 70 | + $status = OnlineStatusBar_StatusCheck::getStatus( $user ); |
70 | 71 | |
71 | 72 | return array( $status, $user ); |
72 | 73 | } |
— | — | @@ -74,7 +75,7 @@ |
75 | 76 | /** |
76 | 77 | * Returns the status and User element |
77 | 78 | * |
78 | | - * @param Title $title |
| 79 | + * @param Title $title a title of page |
79 | 80 | * @return array|bool Array containing the status and User object |
80 | 81 | */ |
81 | 82 | public static function getUserInfoFromTitle( Title $title ) { |
— | — | @@ -82,6 +83,7 @@ |
83 | 84 | return false; |
84 | 85 | } |
85 | 86 | |
| 87 | + // We create an user object using name of user parsed from title |
86 | 88 | $user = User::newFromName( $title->getBaseText() ); |
87 | 89 | // Invalid user |
88 | 90 | if ( !($user instanceof User) ) { |
— | — | @@ -91,57 +93,22 @@ |
92 | 94 | return false; |
93 | 95 | } |
94 | 96 | |
95 | | - $status = self::getStatus( $user, true ); |
| 97 | + $status = OnlineStatusBar_StatusCheck::getStatus( $user ); |
96 | 98 | |
97 | 99 | return array( $status, $user ); |
98 | 100 | } |
99 | 101 | |
100 | 102 | /** |
101 | | - * @param $user User |
102 | | - * @return String |
103 | | - */ |
104 | | - public static function getStatus( $user, $update = false ) { |
105 | | - global $wgOnlineStatusBarDefaultOffline, $wgOnlineStatusBarDefaultOnline; |
106 | | - // remove old entries |
107 | | - if ( $update ) |
108 | | - { |
109 | | - self::deleteOld(); |
110 | | - } |
111 | | - |
112 | | - // instead of delete every time just select the records which are not that old |
113 | | - $t_time = self::getTimeoutDate(); |
114 | | - $dbr = wfGetDB( DB_SLAVE ); |
115 | | - $result = $dbr->selectField( 'online_status', 'username', array( 'username' => $user->getName(), |
116 | | - "timestamp > " . $dbr->addQuotes( $dbr->timestamp( $t_time ) ) ), |
117 | | - __METHOD__, array( 'LIMIT 1', 'ORDER BY timestamp DESC' ) ); |
118 | | - |
119 | | - if ( $result === false ) { |
120 | | - $status = $wgOnlineStatusBarDefaultOffline; |
121 | | - } else { |
122 | | - // let's check if it isn't anon |
123 | | - if ( $user->isLoggedIn() ) { |
124 | | - $status = $user->getOption( 'OnlineStatusBar_status', $wgOnlineStatusBarDefaultOnline ); |
125 | | - } else { |
126 | | - $status = $wgOnlineStatusBarDefaultOnline; |
127 | | - } |
128 | | - } |
129 | | - |
130 | | - if ( $status == 'hidden' ) { |
131 | | - $status = $wgOnlineStatusBarDefaultOffline; |
132 | | - } |
133 | | - |
134 | | - return $status; |
135 | | - } |
136 | | - |
137 | | - /** |
138 | 103 | * Purge page |
139 | 104 | * @return bool |
140 | 105 | * |
141 | 106 | */ |
142 | 107 | public static function purge( $user_type ) { |
| 108 | + // First of all we need to know if we already have user object or just a name |
| 109 | + // if so let's create new object |
143 | 110 | if ( $user_type instanceof User ) { |
144 | 111 | $user = $user_type; |
145 | | - } else if ( is_string( $user_type ) ){ |
| 112 | + } elseif ( is_string( $user_type ) ){ |
146 | 113 | $user = User::newFromName( $user_type ); |
147 | 114 | } else { |
148 | 115 | return false; |
— | — | @@ -160,80 +127,21 @@ |
161 | 128 | return true; |
162 | 129 | } |
163 | 130 | |
164 | | - /** |
165 | | - * Insert to the database |
166 | | - * @return bool |
167 | | - */ |
168 | | - public static function updateDb() { |
169 | | - global $wgUser; |
170 | | - // Skip users we don't track |
171 | | - if ( self::isValid ( $wgUser ) != true ) { |
172 | | - return false; |
173 | | - } |
174 | | - // If we track them, let's insert it to the table |
175 | | - $dbw = wfGetDB( DB_MASTER ); |
176 | | - $row = array( |
177 | | - 'username' => $wgUser->getName(), |
178 | | - 'timestamp' => $dbw->timestamp(), |
179 | | - ); |
180 | | - $dbw->insert( 'online_status', $row, __METHOD__, 'DELAYED' ); |
181 | | - return false; |
182 | | - } |
183 | 131 | |
184 | 132 | /** |
185 | | - * Update status of user |
186 | | - * @return bool |
| 133 | + * @return timestamp |
187 | 134 | */ |
188 | | - public static function updateStatus() { |
189 | | - global $wgUser, $wgOnlineStatusBarDefaultOffline, $wgOnlineStatusBarTrackIpUsers, $wgOnlineStatusBarDefaultEnabled; |
190 | | - // if anon users are not tracked and user is anon leave it |
191 | | - if ( !$wgOnlineStatusBarTrackIpUsers ) { |
192 | | - if ( !$wgUser->isLoggedIn() ) { |
193 | | - return false; |
194 | | - } |
| 135 | + public static function getTimeoutDate( $delayed = false ) { |
| 136 | + global $wgOnlineStatusBar_WriteTime, $wgOnlineStatusBar_LogoutTime; |
| 137 | + |
| 138 | + if ($delayed) { |
| 139 | + return wfTimestamp( TS_UNIX ) - $wgOnlineStatusBar_WriteTime; |
195 | 140 | } |
196 | | - // if user doesn't want to be tracked leave it as well for privacy reasons |
197 | | - if ( $wgUser->isLoggedIn() && !$wgUser->getOption ( "OnlineStatusBar_active", $wgOnlineStatusBarDefaultEnabled ) ) { |
198 | | - return false; |
199 | | - } |
200 | | - if ( OnlineStatusBar::getStatus( $wgUser ) == $wgOnlineStatusBarDefaultOffline ) { |
201 | | - OnlineStatusBar::updateDb(); |
202 | | - return true; |
203 | | - } |
204 | 141 | |
205 | | - $dbw = wfGetDB( DB_MASTER ); |
206 | | - $dbw->update( |
207 | | - 'online_status', |
208 | | - array( 'timestamp' => $dbw->timestamp() ), |
209 | | - array( 'username' => $wgUser->getName() ), |
210 | | - __METHOD__ |
211 | | - ); |
212 | | - |
213 | | - return true; |
214 | | - } |
215 | | - |
216 | | - /** |
217 | | - * @return timestamp |
218 | | - */ |
219 | | - private static function getTimeoutDate() { |
220 | | - global $wgOnlineStatusBar_LogoutTime; |
221 | 142 | return wfTimestamp( TS_UNIX ) - $wgOnlineStatusBar_LogoutTime; |
222 | 143 | } |
223 | 144 | |
224 | 145 | /** |
225 | | - * Delete old records from the table, this function is called frequently too keep it as small as possible |
226 | | - * @return int |
227 | | - */ |
228 | | - public static function deleteOld() { |
229 | | - $dbw = wfGetDB( DB_MASTER ); |
230 | | - // calculate time and convert it back to mediawiki format |
231 | | - $time = self::getTimeoutDate(); |
232 | | - $dbw->delete( 'online_status', array( "timestamp < " . $dbw->addQuotes( $dbw->timestamp( $time ) ) ), __METHOD__ ); |
233 | | - return 0; |
234 | | - } |
235 | | - |
236 | | - |
237 | | - /** |
238 | 146 | * Checks to see if the user can be tracked |
239 | 147 | * |
240 | 148 | * @param User $user |
— | — | @@ -250,15 +158,4 @@ |
251 | 159 | // do we track them |
252 | 160 | return $user->getOption( "OnlineStatusBar_active", $wgOnlineStatusBarDefaultEnabled ); |
253 | 161 | } |
254 | | - |
255 | | - /** |
256 | | - * Delete user who logged out |
257 | | - * @param $userName string |
258 | | - * @return bool |
259 | | - */ |
260 | | - static function deleteStatus( $userName ) { |
261 | | - $dbw = wfGetDB( DB_MASTER ); |
262 | | - $dbw->delete( 'online_status', array( 'username' => $userName ), __METHOD__ ); // delete user |
263 | | - return true; |
264 | | - } |
265 | 162 | } |
Index: branches/REL1_18/extensions/OnlineStatusBar/OnlineStatusBar.php |
— | — | @@ -17,7 +17,7 @@ |
18 | 18 | $wgExtensionCredits[version_compare( $wgVersion, '1.17', '>=' ) ? 'userpage tools' : 'other'][] = array( |
19 | 19 | 'path' => __FILE__, |
20 | 20 | 'name' => 'Online status bar', |
21 | | - 'version' => '1.0.2', |
| 21 | + 'version' => '1.0.3', |
22 | 22 | 'author' => array( 'Petr Bena' ), |
23 | 23 | 'descriptionmsg' => 'onlinestatusbar-desc', |
24 | 24 | 'url' => 'http://www.mediawiki.org/wiki/Extension:OnlineStatusBar', |
— | — | @@ -38,12 +38,24 @@ |
39 | 39 | 'remoteExtPath' => 'OnlineStatusBar', |
40 | 40 | ); |
41 | 41 | |
| 42 | +$wgResourceModules['ext.OnlineStatusBar.modern'] = array ( |
| 43 | + 'styles' => 'OnlineStatusBarModern.css', |
| 44 | + 'localBasePath' => dirname ( __FILE__ ), |
| 45 | + 'remoteExtPath' => 'OnlineStatusBar', |
| 46 | +); |
| 47 | + |
42 | 48 | $wgResourceModules['ext.OnlineStatusBar.chick'] = array ( |
43 | 49 | 'styles' => 'OnlineStatusBarChick.css', |
44 | 50 | 'localBasePath' => dirname ( __FILE__ ), |
45 | 51 | 'remoteExtPath' => 'OnlineStatusBar', |
46 | 52 | ); |
47 | 53 | |
| 54 | +$wgResourceModules['ext.OnlineStatusBar.standard'] = array ( |
| 55 | + 'styles' => 'OnlineStatusBarClassic.css', |
| 56 | + 'localBasePath' => dirname ( __FILE__ ), |
| 57 | + 'remoteExtPath' => 'OnlineStatusBar', |
| 58 | +); |
| 59 | + |
48 | 60 | $wgResourceModules['ext.OnlineStatusBar.monobook'] = array ( |
49 | 61 | 'styles' => 'OnlineStatusBarMono.css', |
50 | 62 | 'localBasePath' => dirname ( __FILE__ ), |
— | — | @@ -68,7 +80,9 @@ |
69 | 81 | 'remoteExtPath' => 'OnlineStatusBar', |
70 | 82 | ); |
71 | 83 | |
| 84 | +// Load other files of extension |
72 | 85 | $wgAutoloadClasses['OnlineStatusBar'] = "$dir/OnlineStatusBar.body.php"; |
| 86 | +$wgAutoloadClasses['OnlineStatusBar_StatusCheck'] = "$dir/OnlineStatusBar.status.php"; |
73 | 87 | $wgAutoloadClasses['OnlineStatusBarHooks'] = "$dir/OnlineStatusBarHooks.php"; |
74 | 88 | |
75 | 89 | // Configuration |
— | — | @@ -83,6 +97,10 @@ |
84 | 98 | |
85 | 99 | // default for anonymous and uknown users |
86 | 100 | $wgOnlineStatusBarTrackIpUsers = false; |
| 101 | +// it's better to cron this for performance reasons |
| 102 | +$wgOnlineStatusBarAutoDelete = true; |
| 103 | +// delay between db updates |
| 104 | +$wgOnlineStatusBar_WriteTime = 300; |
87 | 105 | // default for online |
88 | 106 | $wgOnlineStatusBarDefaultOnline = "online"; |
89 | 107 | // default for offline |
Index: branches/REL1_18/extensions/OnlineStatusBar/OnlineStatusBarClassic.css |
— | — | @@ -0,0 +1,24 @@ |
| 2 | +/* |
| 3 | +This is a part of css used on english wp, it's needed for wikis |
| 4 | +where topicon isn't defined |
| 5 | +*/ |
| 6 | +div.onlinestatusbartop { |
| 7 | + position: absolute; |
| 8 | + top: 4em; |
| 9 | + margin-right: 4px; |
| 10 | + display: block !important; |
| 11 | +} |
| 12 | + |
| 13 | +div.onlinestatusbaricon { |
| 14 | + border: 0px solid black; |
| 15 | + background: transparent; |
| 16 | + float: right; |
| 17 | + position: relative; |
| 18 | + top: 0px; |
| 19 | + padding: 5px; |
| 20 | +} |
| 21 | + |
| 22 | +div.onlinestatusbarbody { |
| 23 | + right:0px; |
| 24 | + margin-top:6px; |
| 25 | +} |
Index: branches/REL1_18/extensions/OnlineStatusBar/OnlineStatusBarNostalgia.css |
— | — | @@ -4,8 +4,8 @@ |
5 | 5 | */ |
6 | 6 | div.onlinestatusbartop { |
7 | 7 | position: absolute; |
8 | | - top: ; |
9 | | - margin-right: 2px; |
| 8 | + top: 0px; |
| 9 | + margin-right: 261px; |
10 | 10 | display: block !important; |
11 | 11 | } |
12 | 12 | |
Index: branches/REL1_18/extensions/OnlineStatusBar/OnlineStatusBarHooks.php |
— | — | @@ -29,18 +29,20 @@ |
30 | 30 | */ |
31 | 31 | public static function logout( &$user, &$inject_html, $old_name ) { |
32 | 32 | OnlineStatusBar::purge( $old_name ); |
33 | | - OnlineStatusBar::deleteStatus( $old_name ); |
| 33 | + OnlineStatusBar_StatusCheck::deleteStatus( $old_name ); |
34 | 34 | return true; |
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
38 | | - * Called everytime on login |
| 38 | + * Called everytime on login |
39 | 39 | * @return bool |
40 | 40 | */ |
41 | 41 | public static function updateStatus() { |
42 | 42 | global $wgUser; |
| 43 | + // Purge user page (optional) |
43 | 44 | OnlineStatusBar::purge( $wgUser ); |
44 | | - OnlineStatusBar::updateStatus(); |
| 45 | + // Update status |
| 46 | + OnlineStatusBar_StatusCheck::updateStatus(); |
45 | 47 | return true; |
46 | 48 | } |
47 | 49 | |
— | — | @@ -53,13 +55,24 @@ |
54 | 56 | */ |
55 | 57 | public static function renderBar( &$article, &$outputDone, &$pcache ) { |
56 | 58 | $context = $article->getContext(); |
| 59 | + |
| 60 | + // Update status of each user who wants to be tracked |
| 61 | + OnlineStatusBar_StatusCheck::updateStatus(); |
57 | 62 | |
58 | | - OnlineStatusBar::updateStatus(); |
59 | | - $result = OnlineStatusBar::getUserInfoFromTitle( $article->getTitle() ); |
60 | | - if ( $result === false && User::isIP ( $article->getTitle()->getBaseText() ) ) { |
61 | | - $result = OnlineStatusBar::getAnonFromTitle( $article->getTitle() ); |
| 63 | + // Performace fix |
| 64 | + $title = $article->getTitle(); |
| 65 | + if ( $title->getNamespace() != NS_USER && $title->getNamespace() != NS_USER_TALK ) { |
| 66 | + return true; |
62 | 67 | } |
63 | 68 | |
| 69 | + // Retrieve status of user parsed from title |
| 70 | + $result = OnlineStatusBar::getUserInfoFromTitle( $title ); |
| 71 | + // In case that status can't be parsed we check if it isn't anon |
| 72 | + if ( $result === false && User::isIP ( $title->getBaseText() ) ) { |
| 73 | + $result = OnlineStatusBar::getAnonFromTitle( $title ); |
| 74 | + } |
| 75 | + |
| 76 | + // In case we were unable to get a status let's quit |
64 | 77 | if ( $result === false ) { |
65 | 78 | return true; |
66 | 79 | } |
— | — | @@ -67,13 +80,13 @@ |
68 | 81 | /** @var $user User */ |
69 | 82 | list( $status, $user ) = $result; |
70 | 83 | |
71 | | - // Don't display status of those who have opted out |
| 84 | + // Don't display status of those who don't want to show bar but only use magic |
72 | 85 | if ( $user->getOption( 'OnlineStatusBar_hide' ) == true ) { |
73 | 86 | return true; |
74 | 87 | } |
75 | 88 | |
76 | 89 | $modetext = wfMessage( 'onlinestatusbar-status-' . $status )->toString(); |
77 | | - $image = OnlineStatusBar::getImageHtml( $status ); |
| 90 | + $image = OnlineStatusBar::getImageHtml( $status, $modetext ); |
78 | 91 | $text = wfMessage( 'onlinestatusbar-line', $user->getName() ) |
79 | 92 | ->rawParams( $image )->params( $modetext )->escaped(); |
80 | 93 | $context->getOutput()->addHtml( OnlineStatusBar::getStatusBarHtml( $text ) ); |
— | — | @@ -124,7 +137,7 @@ |
125 | 138 | * @return bool |
126 | 139 | */ |
127 | 140 | public static function magicWordVar( array &$magicWords, $ln ) { |
128 | | - $magicWords['isonline'] = array( 0, 'isonline' ); |
| 141 | + $magicWords['ISONLINE'] = array( 1, 'ISONLINE' ); |
129 | 142 | return true; |
130 | 143 | } |
131 | 144 | |
— | — | @@ -138,6 +151,8 @@ |
139 | 152 | case 'monobook': |
140 | 153 | case 'vector': |
141 | 154 | case 'simple': |
| 155 | + case 'modern': |
| 156 | + case 'standard': |
142 | 157 | case 'nostalgia': |
143 | 158 | case 'chick': |
144 | 159 | case 'cologneblue': |
— | — | @@ -154,7 +169,7 @@ |
155 | 170 | * @return bool |
156 | 171 | */ |
157 | 172 | public static function magicWordSet( &$vars ) { |
158 | | - $vars[] = 'isonline'; |
| 173 | + $vars[] = 'ISONLINE'; |
159 | 174 | return true; |
160 | 175 | } |
161 | 176 | |
— | — | @@ -166,17 +181,19 @@ |
167 | 182 | * @return bool |
168 | 183 | */ |
169 | 184 | public static function parserGetVariable( &$parser, &$varCache, &$index, &$ret ) { |
170 | | - if ( $index != 'isonline' ) { |
| 185 | + if ( $index != 'ISONLINE' ) { |
171 | 186 | return true; |
172 | 187 | } |
173 | 188 | |
| 189 | + // get a status of user parsed from title |
174 | 190 | $result = OnlineStatusBar::getUserInfoFromTitle( $parser->getTitle() ); |
175 | | - if ( User::isIP( $parser->getTitle()->getBaseText() ) && $result == null ) { |
| 191 | + // if user is IP and we track them |
| 192 | + if ( User::isIP( $parser->getTitle()->getBaseText() ) && $result === false ) { |
176 | 193 | $result = OnlineStatusBar::getAnonFromTitle( $parser->getTitle() ); |
177 | 194 | } |
178 | 195 | |
179 | | - if ( $result == false ) { |
180 | | - $ret = "unknown"; |
| 196 | + if ( $result === false ) { |
| 197 | + $ret = 'unknown'; |
181 | 198 | return true; |
182 | 199 | } |
183 | 200 | |
Index: branches/REL1_18/extensions/OnlineStatusBar/OnlineStatusBarModern.css |
— | — | @@ -0,0 +1,25 @@ |
| 2 | +/* |
| 3 | +This is a part of css used on english wp, it's needed for wikis |
| 4 | +where topicon isn't defined |
| 5 | +*/ |
| 6 | +div.onlinestatusbartop { |
| 7 | + position: absolute; |
| 8 | + top: 0px; |
| 9 | + margin-right: 2px; |
| 10 | + color: white; |
| 11 | + display: block !important; |
| 12 | +} |
| 13 | + |
| 14 | +div.onlinestatusbaricon { |
| 15 | + border: 0px solid black; |
| 16 | + background: transparent; |
| 17 | + float: right; |
| 18 | + position: relative; |
| 19 | + top: 0px; |
| 20 | + padding: 5px; |
| 21 | +} |
| 22 | + |
| 23 | +div.onlinestatusbarbody { |
| 24 | + right:0px; |
| 25 | + margin-top:-3px; |
| 26 | +} |
Property changes on: branches/REL1_18/extensions/OnlineStatusBar |
___________________________________________________________________ |
Modified: svn:mergeinfo |
1 | 27 | Merged /trunk/extensions/OnlineStatusBar:r102864-104227 |