r104228 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104227‎ | r104228 | r104229 >
Date:08:37, 25 November 2011
Author:petrb
Status:deferred
Tags:
Comment:
Branched OnlineStatusBar to 1.18
Modified paths:
  • /branches/REL1_18/extensions/OnlineStatusBar (modified) (history)
  • /branches/REL1_18/extensions/OnlineStatusBar/OnlineStatusBar.body.php (modified) (history)
  • /branches/REL1_18/extensions/OnlineStatusBar/OnlineStatusBar.i18n.php (modified) (history)
  • /branches/REL1_18/extensions/OnlineStatusBar/OnlineStatusBar.php (modified) (history)
  • /branches/REL1_18/extensions/OnlineStatusBar/OnlineStatusBar.status.php (added) (history)
  • /branches/REL1_18/extensions/OnlineStatusBar/OnlineStatusBarClassic.css (added) (history)
  • /branches/REL1_18/extensions/OnlineStatusBar/OnlineStatusBarHooks.php (modified) (history)
  • /branches/REL1_18/extensions/OnlineStatusBar/OnlineStatusBarModern.css (added) (history)
  • /branches/REL1_18/extensions/OnlineStatusBar/OnlineStatusBarMono.css (modified) (history)
  • /branches/REL1_18/extensions/OnlineStatusBar/OnlineStatusBarNostalgia.css (modified) (history)

Diff [purge]

Index: branches/REL1_18/extensions/OnlineStatusBar/OnlineStatusBar.i18n.php
@@ -63,6 +63,7 @@
6464 */
6565 $messages['br'] = array(
6666 'onlinestatusbar-line' => '$1 zo bremañ $2 $3',
 67+ 'prefs-onlinestatus' => 'Statud enlinenn',
6768 'onlinestatusbar-status-online' => 'Kevreet',
6869 'onlinestatusbar-status-busy' => 'Soulgarget',
6970 'onlinestatusbar-status-away' => 'Er-maez',
@@ -170,8 +171,13 @@
171172 * @author Michawiki
172173 */
173174 $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',
174176 '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',
175180 '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)',
176182 'onlinestatusbar-status-online' => 'Online',
177183 'onlinestatusbar-status-busy' => 'Ma dźěło',
178184 'onlinestatusbar-status-away' => 'Preč',
@@ -226,6 +232,24 @@
227233 'onlinestatusbar-status-hidden' => 'Скриен',
228234 );
229235
 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+
230254 /** Dutch (Nederlands)
231255 * @author SPQRobin
232256 * @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
1207 + native
Index: branches/REL1_18/extensions/OnlineStatusBar/OnlineStatusBarMono.css
@@ -20,5 +20,5 @@
2121
2222 div.onlinestatusbarbody {
2323 right:0px;
24 - margin-top:-10px;
 24+ margin-top:-2px;
2525 }
Index: branches/REL1_18/extensions/OnlineStatusBar/OnlineStatusBar.body.php
@@ -29,19 +29,20 @@
3030 * Returns image element
3131 *
3232 * @param $mode String
 33+ * @param $mode_text String
3334 * @return string
3435 */
35 - public static function GetImageHtml( $mode ) {
 36+ public static function GetImageHtml( $mode, $mode_text ) {
3637 global $wgExtensionAssetsPath, $wgOnlineStatusBarIcon;
3738 $icon = "$wgExtensionAssetsPath/OnlineStatusBar/{$wgOnlineStatusBarIcon[$mode]}";
38 - return Html::element( 'img', array( 'src' => $icon ) );
 39+ return Html::element( 'img', array( 'src' => $icon, 'alt' => $mode_text ) );
3940 }
4041
4142
4243 /**
4344 * Returns the status and User element
4445 *
45 - * @param Title $title
 46+ * @param Title $title a title of page
4647 * @return array|bool Array containing the status and User object
4748 */
4849 public static function getAnonFromTitle( Title $title ) {
@@ -50,7 +51,7 @@
5152 if ( $wgOnlineStatusBarTrackIpUsers == false ) {
5253 return false;
5354 }
54 -
 55+
5556 // checks ns
5657 if ( $title->getNamespace() != NS_USER && $title->getNamespace() != NS_USER_TALK ) {
5758 return false;
@@ -65,7 +66,7 @@
6667 return false;
6768 }
6869
69 - $status = self::getStatus( $user, true );
 70+ $status = OnlineStatusBar_StatusCheck::getStatus( $user );
7071
7172 return array( $status, $user );
7273 }
@@ -74,7 +75,7 @@
7576 /**
7677 * Returns the status and User element
7778 *
78 - * @param Title $title
 79+ * @param Title $title a title of page
7980 * @return array|bool Array containing the status and User object
8081 */
8182 public static function getUserInfoFromTitle( Title $title ) {
@@ -82,6 +83,7 @@
8384 return false;
8485 }
8586
 87+ // We create an user object using name of user parsed from title
8688 $user = User::newFromName( $title->getBaseText() );
8789 // Invalid user
8890 if ( !($user instanceof User) ) {
@@ -91,57 +93,22 @@
9294 return false;
9395 }
9496
95 - $status = self::getStatus( $user, true );
 97+ $status = OnlineStatusBar_StatusCheck::getStatus( $user );
9698
9799 return array( $status, $user );
98100 }
99101
100102 /**
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 - /**
138103 * Purge page
139104 * @return bool
140105 *
141106 */
142107 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
143110 if ( $user_type instanceof User ) {
144111 $user = $user_type;
145 - } else if ( is_string( $user_type ) ){
 112+ } elseif ( is_string( $user_type ) ){
146113 $user = User::newFromName( $user_type );
147114 } else {
148115 return false;
@@ -160,80 +127,21 @@
161128 return true;
162129 }
163130
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 - }
183131
184132 /**
185 - * Update status of user
186 - * @return bool
 133+ * @return timestamp
187134 */
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;
195140 }
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 - }
204141
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;
221142 return wfTimestamp( TS_UNIX ) - $wgOnlineStatusBar_LogoutTime;
222143 }
223144
224145 /**
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 - /**
238146 * Checks to see if the user can be tracked
239147 *
240148 * @param User $user
@@ -250,15 +158,4 @@
251159 // do we track them
252160 return $user->getOption( "OnlineStatusBar_active", $wgOnlineStatusBarDefaultEnabled );
253161 }
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 - }
265162 }
Index: branches/REL1_18/extensions/OnlineStatusBar/OnlineStatusBar.php
@@ -17,7 +17,7 @@
1818 $wgExtensionCredits[version_compare( $wgVersion, '1.17', '>=' ) ? 'userpage tools' : 'other'][] = array(
1919 'path' => __FILE__,
2020 'name' => 'Online status bar',
21 - 'version' => '1.0.2',
 21+ 'version' => '1.0.3',
2222 'author' => array( 'Petr Bena' ),
2323 'descriptionmsg' => 'onlinestatusbar-desc',
2424 'url' => 'http://www.mediawiki.org/wiki/Extension:OnlineStatusBar',
@@ -38,12 +38,24 @@
3939 'remoteExtPath' => 'OnlineStatusBar',
4040 );
4141
 42+$wgResourceModules['ext.OnlineStatusBar.modern'] = array (
 43+ 'styles' => 'OnlineStatusBarModern.css',
 44+ 'localBasePath' => dirname ( __FILE__ ),
 45+ 'remoteExtPath' => 'OnlineStatusBar',
 46+);
 47+
4248 $wgResourceModules['ext.OnlineStatusBar.chick'] = array (
4349 'styles' => 'OnlineStatusBarChick.css',
4450 'localBasePath' => dirname ( __FILE__ ),
4551 'remoteExtPath' => 'OnlineStatusBar',
4652 );
4753
 54+$wgResourceModules['ext.OnlineStatusBar.standard'] = array (
 55+ 'styles' => 'OnlineStatusBarClassic.css',
 56+ 'localBasePath' => dirname ( __FILE__ ),
 57+ 'remoteExtPath' => 'OnlineStatusBar',
 58+);
 59+
4860 $wgResourceModules['ext.OnlineStatusBar.monobook'] = array (
4961 'styles' => 'OnlineStatusBarMono.css',
5062 'localBasePath' => dirname ( __FILE__ ),
@@ -68,7 +80,9 @@
6981 'remoteExtPath' => 'OnlineStatusBar',
7082 );
7183
 84+// Load other files of extension
7285 $wgAutoloadClasses['OnlineStatusBar'] = "$dir/OnlineStatusBar.body.php";
 86+$wgAutoloadClasses['OnlineStatusBar_StatusCheck'] = "$dir/OnlineStatusBar.status.php";
7387 $wgAutoloadClasses['OnlineStatusBarHooks'] = "$dir/OnlineStatusBarHooks.php";
7488
7589 // Configuration
@@ -83,6 +97,10 @@
8498
8599 // default for anonymous and uknown users
86100 $wgOnlineStatusBarTrackIpUsers = false;
 101+// it's better to cron this for performance reasons
 102+$wgOnlineStatusBarAutoDelete = true;
 103+// delay between db updates
 104+$wgOnlineStatusBar_WriteTime = 300;
87105 // default for online
88106 $wgOnlineStatusBarDefaultOnline = "online";
89107 // 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 @@
55 */
66 div.onlinestatusbartop {
77 position: absolute;
8 - top: ;
9 - margin-right: 2px;
 8+ top: 0px;
 9+ margin-right: 261px;
1010 display: block !important;
1111 }
1212
Index: branches/REL1_18/extensions/OnlineStatusBar/OnlineStatusBarHooks.php
@@ -29,18 +29,20 @@
3030 */
3131 public static function logout( &$user, &$inject_html, $old_name ) {
3232 OnlineStatusBar::purge( $old_name );
33 - OnlineStatusBar::deleteStatus( $old_name );
 33+ OnlineStatusBar_StatusCheck::deleteStatus( $old_name );
3434 return true;
3535 }
3636
3737 /**
38 - * Called everytime on login
 38+ * Called everytime on login
3939 * @return bool
4040 */
4141 public static function updateStatus() {
4242 global $wgUser;
 43+ // Purge user page (optional)
4344 OnlineStatusBar::purge( $wgUser );
44 - OnlineStatusBar::updateStatus();
 45+ // Update status
 46+ OnlineStatusBar_StatusCheck::updateStatus();
4547 return true;
4648 }
4749
@@ -53,13 +55,24 @@
5456 */
5557 public static function renderBar( &$article, &$outputDone, &$pcache ) {
5658 $context = $article->getContext();
 59+
 60+ // Update status of each user who wants to be tracked
 61+ OnlineStatusBar_StatusCheck::updateStatus();
5762
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;
6267 }
6368
 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
6477 if ( $result === false ) {
6578 return true;
6679 }
@@ -67,13 +80,13 @@
6881 /** @var $user User */
6982 list( $status, $user ) = $result;
7083
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
7285 if ( $user->getOption( 'OnlineStatusBar_hide' ) == true ) {
7386 return true;
7487 }
7588
7689 $modetext = wfMessage( 'onlinestatusbar-status-' . $status )->toString();
77 - $image = OnlineStatusBar::getImageHtml( $status );
 90+ $image = OnlineStatusBar::getImageHtml( $status, $modetext );
7891 $text = wfMessage( 'onlinestatusbar-line', $user->getName() )
7992 ->rawParams( $image )->params( $modetext )->escaped();
8093 $context->getOutput()->addHtml( OnlineStatusBar::getStatusBarHtml( $text ) );
@@ -124,7 +137,7 @@
125138 * @return bool
126139 */
127140 public static function magicWordVar( array &$magicWords, $ln ) {
128 - $magicWords['isonline'] = array( 0, 'isonline' );
 141+ $magicWords['ISONLINE'] = array( 1, 'ISONLINE' );
129142 return true;
130143 }
131144
@@ -138,6 +151,8 @@
139152 case 'monobook':
140153 case 'vector':
141154 case 'simple':
 155+ case 'modern':
 156+ case 'standard':
142157 case 'nostalgia':
143158 case 'chick':
144159 case 'cologneblue':
@@ -154,7 +169,7 @@
155170 * @return bool
156171 */
157172 public static function magicWordSet( &$vars ) {
158 - $vars[] = 'isonline';
 173+ $vars[] = 'ISONLINE';
159174 return true;
160175 }
161176
@@ -166,17 +181,19 @@
167182 * @return bool
168183 */
169184 public static function parserGetVariable( &$parser, &$varCache, &$index, &$ret ) {
170 - if ( $index != 'isonline' ) {
 185+ if ( $index != 'ISONLINE' ) {
171186 return true;
172187 }
173188
 189+ // get a status of user parsed from title
174190 $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 ) {
176193 $result = OnlineStatusBar::getAnonFromTitle( $parser->getTitle() );
177194 }
178195
179 - if ( $result == false ) {
180 - $ret = "unknown";
 196+ if ( $result === false ) {
 197+ $ret = 'unknown';
181198 return true;
182199 }
183200
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
127 Merged /trunk/extensions/OnlineStatusBar:r102864-104227

Status & tagging log