r101517 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101516‎ | r101517 | r101518 >
Date:19:35, 1 November 2011
Author:petrb
Status:deferred (Comments)
Tags:
Comment:
Tagging new version
Modified paths:
  • /tags/extensions/OnlineStatusBar/REL_1_0_1/OnlineStatusBar (added) (history)

Diff [purge]

Index: tags/extensions/OnlineStatusBar/REL_1_0_1/OnlineStatusBar/OnlineStatusBar.body.php
@@ -0,0 +1,264 @@
 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+ * Main file of Online status bar extension.
 10+ *
 11+ * @file
 12+ * @ingroup Extensions
 13+ * @author Petr Bena <benapetr@gmail.com>
 14+ * @author of magic word Alexandre Emsenhuber
 15+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 16+ * @link http://www.mediawiki.org/wiki/Extension:OnlineStatusBar Documentation
 17+ */
 18+
 19+class OnlineStatusBar {
 20+
 21+ public static function getStatusBarHtml( $text ) {
 22+ return <<<HTML
 23+<div class="onlinestatusbarbody metadata onlinestatusbartop" id="status-top">
 24+<div class="onlinestatusbaricon">
 25+$text</div></div>
 26+HTML;
 27+ }
 28+
 29+ /**
 30+ * Returns image element
 31+ *
 32+ * @param $mode String
 33+ * @return string
 34+ */
 35+ public static function GetImageHtml( $mode ) {
 36+ global $wgExtensionAssetsPath, $wgOnlineStatusBarIcon;
 37+ $icon = "$wgExtensionAssetsPath/OnlineStatusBar/{$wgOnlineStatusBarIcon[$mode]}";
 38+ return Html::element( 'img', array( 'src' => $icon ) );
 39+ }
 40+
 41+
 42+ /**
 43+ * Returns the status and User element
 44+ *
 45+ * @param Title $title
 46+ * @return array|bool Array containing the status and User object
 47+ */
 48+ public static function getAnonFromTitle( Title $title ) {
 49+ global $wgOnlineStatusBarTrackIpUsers;
 50+ // if user is anon and we don't track them stop
 51+ if ( $wgOnlineStatusBarTrackIpUsers == false ) {
 52+ return false;
 53+ }
 54+
 55+ // checks ns
 56+ if ( $title->getNamespace() != NS_USER && $title->getNamespace() != NS_USER_TALK ) {
 57+ return false;
 58+ }
 59+
 60+ // we need to create temporary user object
 61+ $user = User::newFromId( 0 );
 62+ $user->setName( $title->getBaseText() );
 63+
 64+ // Check if something wrong didn't happen
 65+ if ( !($user instanceof User) ) {
 66+ return false;
 67+ }
 68+
 69+ $status = self::getStatus( $user, true );
 70+
 71+ return array( $status, $user );
 72+ }
 73+
 74+
 75+ /**
 76+ * Returns the status and User element
 77+ *
 78+ * @param Title $title
 79+ * @return array|bool Array containing the status and User object
 80+ */
 81+ public static function getUserInfoFromTitle( Title $title ) {
 82+ if ( $title->getNamespace() != NS_USER && $title->getNamespace() != NS_USER_TALK ) {
 83+ return false;
 84+ }
 85+
 86+ $user = User::newFromName( $title->getBaseText() );
 87+ // Invalid user
 88+ if ( !($user instanceof User) ) {
 89+ return false;
 90+ }
 91+ if ( !self::isValid( $user ) ) {
 92+ return false;
 93+ }
 94+
 95+ $status = self::getStatus( $user, true );
 96+
 97+ return array( $status, $user );
 98+ }
 99+
 100+ /**
 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 = 'offline';
 132+ }
 133+
 134+ return $status;
 135+ }
 136+
 137+ /**
 138+ * Purge page
 139+ * @return bool
 140+ *
 141+ */
 142+ public static function purge( $user_type ) {
 143+ if ( $user_type instanceof User ) {
 144+ $user = $user_type;
 145+ } else if ( is_string( $user_type ) ){
 146+ $user = User::newFromName( $user_type );
 147+ } else {
 148+ return false;
 149+ }
 150+
 151+ // check if something weird didn't happen
 152+ if ( $user instanceof User ) {
 153+ // purge both pages now
 154+ if ( $user->getOption('OnlineStatusBar_active', false) ) {
 155+ if ( $user->getOption('OnlineStatusBar_autoupdate', false) == true ) {
 156+ WikiPage::factory( $user->getUserPage() )->doPurge();
 157+ WikiPage::factory( $user->getTalkPage() )->doPurge();
 158+ }
 159+ }
 160+ }
 161+ return true;
 162+ }
 163+
 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+
 184+ /**
 185+ * Update status of user
 186+ * @return bool
 187+ */
 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+ }
 195+ }
 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+
 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+ return wfTimestamp( TS_UNIX ) - $wgOnlineStatusBar_LogoutTime;
 222+ }
 223+
 224+ /**
 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+ * Checks to see if the user can be tracked
 239+ *
 240+ * @param User $user
 241+ * @return bool
 242+ */
 243+ public static function isValid( User $user ) {
 244+ global $wgOnlineStatusBarTrackIpUsers, $wgOnlineStatusBarDefaultEnabled;
 245+
 246+ // checks if anon
 247+ if ( $user->isAnon() ) {
 248+ return $wgOnlineStatusBarTrackIpUsers;
 249+ }
 250+
 251+ // do we track them
 252+ return $user->getOption( "OnlineStatusBar_active", $wgOnlineStatusBarDefaultEnabled );
 253+ }
 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+}
Property changes on: tags/extensions/OnlineStatusBar/REL_1_0_1/OnlineStatusBar/OnlineStatusBar.body.php
___________________________________________________________________
Added: svn:eol-style
1266 + native
Index: tags/extensions/OnlineStatusBar/REL_1_0_1/OnlineStatusBar/OnlineStatusBar.i18n.php
@@ -0,0 +1,202 @@
 2+<?php
 3+/**
 4+ * Internationalisation file for Online status bar extension.
 5+ *
 6+ * @file
 7+ * @ingroup Extensions
 8+ */
 9+
 10+$messages = array();
 11+
 12+/**
 13+ * English
 14+ * @author Petr Bena
 15+ * @author John Du Hart
 16+ */
 17+$messages['en'] = array(
 18+ // Description
 19+ 'onlinestatusbar-desc' => 'Status bar which shows whether a user is online, based on preferences, on their user page',
 20+ // Status bar text line (User is now Offline) etc.
 21+ 'onlinestatusbar-line' => '$1 is now $2 $3',
 22+ // Message in config asking user if they want to enable it
 23+ 'onlinestatusbar-used' => 'Do you want to let others see if you are online?',
 24+ // Message in config asking what status they want to use
 25+ 'onlinestatusbar-status' => 'What is the default status you wish to use:',
 26+ // Message in config asking if user wants to purge the user page
 27+ 'onlinestatusbar-purge' => 'Purge user page everytime when you login or logout',
 28+ // Section for config
 29+ 'prefs-onlinestatus' => 'Online status',
 30+ // Message in config
 31+ 'onlinestatusbar-hide' => 'Do you want to hide the status bar in order to use just the magic word? (For advanced users)',
 32+
 33+ 'onlinestatusbar-status-online' => 'On-line',
 34+ 'onlinestatusbar-status-busy' => 'Busy',
 35+ 'onlinestatusbar-status-away' => 'Away',
 36+ 'onlinestatusbar-status-offline' => 'Offline',
 37+ 'onlinestatusbar-status-hidden' => 'Hidden',
 38+);
 39+
 40+/** Message documentation (Message documentation)
 41+ * @author John Du Hart
 42+ * @author Petr Bena
 43+ */
 44+$messages['qqq'] = array(
 45+ 'onlinestatusbar-desc' => '{{desc}}',
 46+ 'onlinestatusbar-line' => 'Status bar text line (User is now Offline), parameters:
 47+* $1 is user
 48+* $2 is a picture of status (small icon in color of status)
 49+* $3 a status, it will appear in title bar of their user space pages',
 50+ 'onlinestatusbar-used' => 'Message in config asking user if they want to enable it, checkbox',
 51+ 'onlinestatusbar-status' => 'Message in config asking what status they want to use, option box',
 52+ 'onlinestatusbar-purge' => 'Option to purge user page everytime they login so that magic word is updated',
 53+ 'prefs-onlinestatus' => 'Section for config, located in preferences - misc',
 54+ 'onlinestatusbar-hide' => 'Ask user if they want to hide status bar this is useful when they are using custom template but need to check if they are online',
 55+ 'onlinestatusbar-status-online' => 'Status for users who mark themselves as active',
 56+ 'onlinestatusbar-status-busy' => 'Status for users who mark themselves as busy',
 57+ 'onlinestatusbar-status-away' => 'Status for users who mark themselves as away',
 58+ 'onlinestatusbar-status-offline' => 'Status for users who are offline',
 59+ 'onlinestatusbar-status-hidden' => 'Status for users who mark themselves as hidden (used on preferences only)',
 60+);
 61+
 62+/** German (Deutsch)
 63+ * @author Kghbln
 64+ */
 65+$messages['de'] = array(
 66+ 'onlinestatusbar-desc' => 'Ermöglicht, abhängig von der Benutzereinstellung, die Anzeige des Onlinestatus eines Benutzers auf dessen Benutzerseite',
 67+ 'onlinestatusbar-line' => '$1 ist gerade $3 $2',
 68+ 'onlinestatusbar-used' => 'Möchtest du, dass andere Benutzer deinen Onlinestatus sehen?',
 69+ 'onlinestatusbar-status' => 'Welchen Status möchtest du standardmäßig nutzen:',
 70+ 'prefs-onlinestatus' => 'Onlinestatus',
 71+ 'onlinestatusbar-hide' => "Möchtest du die Statusleiste ausblenden, um stattdessen lediglich das ''Magic Word'' zu nutzen? (Für Fortgeschrittene)",
 72+ 'onlinestatusbar-status-online' => 'Online',
 73+ 'onlinestatusbar-status-busy' => 'Beschäftigt',
 74+ 'onlinestatusbar-status-away' => 'Abwesend',
 75+ 'onlinestatusbar-status-offline' => 'Offline',
 76+ 'onlinestatusbar-status-hidden' => 'Versteckt',
 77+);
 78+
 79+/** German (formal address) (‪Deutsch (Sie-Form)‬)
 80+ * @author Kghbln
 81+ */
 82+$messages['de-formal'] = array(
 83+ 'onlinestatusbar-used' => 'Möchten Sie, dass andere Benutzer Ihren Onlinestatus sehen?',
 84+ 'onlinestatusbar-status' => 'Welchen Status möchten Sie standardmäßig nutzen:',
 85+ 'onlinestatusbar-hide' => "Möchten Sie die Statusleiste ausblenden, um stattdessen lediglich das ''Magic Word'' zu nutzen? (Für Fortgeschrittene)",
 86+);
 87+
 88+/** French (Français)
 89+ * @author DavidL
 90+ * @author Gomoko
 91+ */
 92+$messages['fr'] = array(
 93+ 'onlinestatusbar-desc' => "Barre d'état montrant si un utilisateur est en ligne, basé sur les préférences, sur leur page utilisateur",
 94+ 'onlinestatusbar-line' => '$1 est maintenant $2 $3',
 95+ 'onlinestatusbar-used' => 'Voulez-vous permettre que les autres voient si vous êtes en ligne ?',
 96+ 'onlinestatusbar-status' => 'Quel est le statut par défaut que vous souhaitez utiliser :',
 97+ 'prefs-onlinestatus' => 'État en ligne',
 98+ 'onlinestatusbar-hide' => "Voulez-vous masquer la barre d'état afin d'utiliser le mot magique seulement ? (Pour les utilisateurs avancés)",
 99+ 'onlinestatusbar-status-online' => 'Présent',
 100+ 'onlinestatusbar-status-busy' => 'Occupé',
 101+ 'onlinestatusbar-status-away' => 'Parti',
 102+ 'onlinestatusbar-status-offline' => 'Absent',
 103+ 'onlinestatusbar-status-hidden' => 'Caché',
 104+);
 105+
 106+/** Galician (Galego)
 107+ * @author Toliño
 108+ */
 109+$messages['gl'] = array(
 110+ 'onlinestatusbar-desc' => 'Barra de estado que mostra na páxina de usuario se un usuario está conectado',
 111+ 'onlinestatusbar-line' => '$1 está $2 $3 nestes intres',
 112+ 'onlinestatusbar-used' => 'Quere deixar que os outros poidan ver se está conectado?',
 113+ 'onlinestatusbar-status' => 'Cal é o estado por defecto que quere usar:',
 114+ 'prefs-onlinestatus' => 'Conectado',
 115+ 'onlinestatusbar-hide' => 'Quere agochar a barra de estado para usar unicamente a palabra máxica? (Para usuarios avanzados)',
 116+ 'onlinestatusbar-status-online' => 'Conectado',
 117+ 'onlinestatusbar-status-busy' => 'Ocupado',
 118+ 'onlinestatusbar-status-away' => 'Non dispoñible',
 119+ 'onlinestatusbar-status-offline' => 'Desconectado',
 120+ 'onlinestatusbar-status-hidden' => 'Agochado',
 121+);
 122+
 123+/** Upper Sorbian (Hornjoserbsce)
 124+ * @author Michawiki
 125+ */
 126+$messages['hsb'] = array(
 127+ 'onlinestatusbar-line' => '$1 je nětko $3 $2',
 128+ 'prefs-onlinestatus' => 'Onlinestatus',
 129+ 'onlinestatusbar-status-online' => 'Online',
 130+ 'onlinestatusbar-status-busy' => 'Ma dźěło',
 131+ 'onlinestatusbar-status-away' => 'Preč',
 132+ 'onlinestatusbar-status-offline' => 'Offline',
 133+ 'onlinestatusbar-status-hidden' => 'Schowany',
 134+);
 135+
 136+/** Interlingua (Interlingua)
 137+ * @author McDutchie
 138+ */
 139+$messages['ia'] = array(
 140+ 'onlinestatusbar-desc' => 'Barra de stato que monstra si un usator es in linea, dependente de su preferentias, in su pagina de usator',
 141+ 'onlinestatusbar-line' => '$1 es ora $2 $3',
 142+ 'onlinestatusbar-used' => 'Vole tu permitter que alteres vide si tu es in linea?',
 143+ 'onlinestatusbar-status' => 'Qual es le stato predefinite que tu vole usar:',
 144+ 'prefs-onlinestatus' => 'Stato in linea',
 145+ 'onlinestatusbar-hide' => 'Vole tu celar le barra de stato pro usar solmente le parola magic? (Pro usatores avantiate)',
 146+ 'onlinestatusbar-status-online' => 'In linea',
 147+ 'onlinestatusbar-status-busy' => 'Occupate',
 148+ 'onlinestatusbar-status-away' => 'Absente',
 149+ 'onlinestatusbar-status-offline' => 'Foras de linea',
 150+ 'onlinestatusbar-status-hidden' => 'Celate',
 151+);
 152+
 153+/** Luxembourgish (Lëtzebuergesch)
 154+ * @author Robby
 155+ */
 156+$messages['lb'] = array(
 157+ 'onlinestatusbar-line' => '$1 ass elo $2 $3',
 158+ 'onlinestatusbar-used' => 'Wëllt dir datt Anerer kënne gesinn op Dir online sidd?',
 159+ 'onlinestatusbar-status-busy' => 'Beschäftegt',
 160+ 'onlinestatusbar-status-away' => 'Net do',
 161+ 'onlinestatusbar-status-hidden' => 'Verstoppt',
 162+);
 163+
 164+/** Macedonian (Македонски)
 165+ * @author Bjankuloski06
 166+ */
 167+$messages['mk'] = array(
 168+ 'onlinestatusbar-desc' => 'Статусник што прикажува дали корисникот е на линија, зависно од нагодувањата на корисничката страница',
 169+ 'onlinestatusbar-line' => '$1 сега е $2 $3',
 170+ 'onlinestatusbar-used' => 'Дали сакате другите да знаат кога сте на линија?',
 171+ 'onlinestatusbar-status' => 'Вашиот статус по основно:',
 172+ 'prefs-onlinestatus' => 'Вклученост',
 173+ 'onlinestatusbar-hide' => 'Дали би сакале да го скриете статусникот за да го користите само волшебниот збор (за напредни корисници)',
 174+ 'onlinestatusbar-status-online' => 'Вклучен',
 175+ 'onlinestatusbar-status-busy' => 'Зафатен',
 176+ 'onlinestatusbar-status-away' => 'Отсутен',
 177+ 'onlinestatusbar-status-offline' => 'Исклучен',
 178+ 'onlinestatusbar-status-hidden' => 'Скриен',
 179+);
 180+
 181+/** Dutch (Nederlands)
 182+ * @author Siebrand
 183+ */
 184+$messages['nl'] = array(
 185+ 'onlinestatusbar-line' => '$1 is nu $2 $3',
 186+ 'onlinestatusbar-used' => 'Wilt u andere gebruikers laten zien dat u online bent?',
 187+ 'onlinestatusbar-status' => 'Welke standaard status wilt u gebruiken:',
 188+ 'prefs-onlinestatus' => 'Onlinestatus',
 189+ 'onlinestatusbar-hide' => 'Wilt u de statusbalk verbergen en alleen het magische woord gebruiken (voor gevorderde gebruikers)?',
 190+ 'onlinestatusbar-status-online' => 'Online',
 191+ 'onlinestatusbar-status-busy' => 'Druk',
 192+ 'onlinestatusbar-status-away' => 'Weg',
 193+ 'onlinestatusbar-status-offline' => 'Offline',
 194+ 'onlinestatusbar-status-hidden' => 'Verborgen',
 195+);
 196+
 197+/** Telugu (తెలుగు)
 198+ * @author Veeven
 199+ */
 200+$messages['te'] = array(
 201+ 'onlinestatusbar-used' => 'మీరు ఆన్‌లైనులో ఉన్నట్టు ఇతరులుకు చూపించాలా?',
 202+);
 203+
Property changes on: tags/extensions/OnlineStatusBar/REL_1_0_1/OnlineStatusBar/OnlineStatusBar.i18n.php
___________________________________________________________________
Added: svn:eol-style
1204 + native
Index: tags/extensions/OnlineStatusBar/REL_1_0_1/OnlineStatusBar/statusred.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: tags/extensions/OnlineStatusBar/REL_1_0_1/OnlineStatusBar/statusred.png
___________________________________________________________________
Added: svn:mime-type
2205 + image/png
Index: tags/extensions/OnlineStatusBar/REL_1_0_1/OnlineStatusBar/statusorange.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: tags/extensions/OnlineStatusBar/REL_1_0_1/OnlineStatusBar/statusorange.png
___________________________________________________________________
Added: svn:mime-type
3206 + image/png
Index: tags/extensions/OnlineStatusBar/REL_1_0_1/OnlineStatusBar/OnlineStatusBar.php
@@ -0,0 +1,68 @@
 2+<?php
 3+/**
 4+ * Insert a special box on user page showing their status.
 5+ *
 6+ * @file
 7+ * @ingroup Extensions
 8+ * @author Petr Bena <benapetr@gmail.com>
 9+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 10+ * @link http://www.mediawiki.org/wiki/Extension:OnlineStatusBar Documentation
 11+ */
 12+
 13+if ( !defined( 'MEDIAWIKI' ) ) {
 14+ echo "This is a part of mediawiki and can't be started separately";
 15+ die();
 16+}
 17+
 18+$wgExtensionCredits[version_compare( $wgVersion, '1.17', '>=' ) ? 'userpage tools' : 'other'][] = array(
 19+ 'path' => __FILE__,
 20+ 'name' => 'Online status bar',
 21+ 'version' => '1.0.1',
 22+ 'author' => array( 'Petr Bena' ),
 23+ 'descriptionmsg' => 'onlinestatusbar-desc',
 24+ 'url' => 'http://www.mediawiki.org/wiki/Extension:OnlineStatusBar',
 25+);
 26+
 27+$dir = dirname( __FILE__ );
 28+$wgExtensionMessagesFiles['OnlineStatusBar'] = "$dir/OnlineStatusBar.i18n.php";
 29+
 30+$wgResourceModules['ext.OnlineStatusBar'] = array (
 31+ 'styles' => 'OnlineStatusBar.css',
 32+ 'localBasePath' => dirname ( __FILE__ ),
 33+ 'remoteExtPath' => 'OnlineStatusBar',
 34+);
 35+
 36+$wgAutoloadClasses['OnlineStatusBar'] = "$dir/OnlineStatusBar.body.php";
 37+$wgAutoloadClasses['OnlineStatusBarHooks'] = "$dir/OnlineStatusBarHooks.php";
 38+
 39+// Configuration
 40+// Those values can be overriden in LocalSettings, do not change it here
 41+$wgOnlineStatusBarIcon = array(
 42+ 'online' => "statusgreen.png",
 43+ 'busy' => "statusorange.png",
 44+ 'away' => "statusorange.png",
 45+ 'hidden' => "statusred.png",
 46+ 'offline' => "statusred.png",
 47+);
 48+
 49+// default for anonymous and uknown users
 50+$wgOnlineStatusBarTrackIpUsers = false;
 51+// default for online
 52+$wgOnlineStatusBarDefaultOnline = "online";
 53+// default for offline
 54+$wgOnlineStatusBarDefaultOffline = "offline";
 55+// if users have this feature enabled by default
 56+$wgOnlineStatusBarDefaultEnabled = false;
 57+// how long to wait until user is considered as offline
 58+$wgOnlineStatusBar_LogoutTime = 3600;
 59+
 60+$wgHooks['LoadExtensionSchemaUpdates'][] = 'OnlineStatusBarHooks::ckSchema';
 61+$wgHooks['UserLogoutComplete'][] = 'OnlineStatusBarHooks::logout';
 62+$wgHooks['ArticleViewHeader'][] = 'OnlineStatusBarHooks::renderBar';
 63+$wgHooks['UserLoginComplete'][] = 'OnlineStatusBarHooks::updateStatus';
 64+$wgHooks['GetPreferences'][] = 'OnlineStatusBarHooks::preferencesHook';
 65+$wgHooks['UserGetDefaultOptions'][] = 'OnlineStatusBarHooks::setDefaultOptions';
 66+$wgHooks['LanguageGetMagic'][] = 'OnlineStatusBarHooks::magicWordVar';
 67+$wgHooks['BeforePageDisplay'][] = 'OnlineStatusBarHooks::stylePage';
 68+$wgHooks['MagicWordwgVariableIDs'][] = 'OnlineStatusBarHooks::magicWordSet';
 69+$wgHooks['ParserGetVariableValueSwitch'][] = 'OnlineStatusBarHooks::parserGetVariable';
Property changes on: tags/extensions/OnlineStatusBar/REL_1_0_1/OnlineStatusBar/OnlineStatusBar.php
___________________________________________________________________
Added: svn:eol-style
170 + native
Index: tags/extensions/OnlineStatusBar/REL_1_0_1/OnlineStatusBar/OnlineStatusBar.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: -2em;
 9+ margin-right: -10px;
 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:-10px;
 25+}
Property changes on: tags/extensions/OnlineStatusBar/REL_1_0_1/OnlineStatusBar/OnlineStatusBar.css
___________________________________________________________________
Added: svn:eol-style
126 + native
Index: tags/extensions/OnlineStatusBar/REL_1_0_1/OnlineStatusBar/OnlineStatusBarHooks.php
@@ -0,0 +1,175 @@
 2+<?php
 3+
 4+/**
 5+ * Hooks for OnlineStatusBar
 6+ *
 7+ * @group Extensions
 8+ */
 9+class OnlineStatusBarHooks {
 10+ /**
 11+ * @param DatabaseUpdater|null $updater
 12+ * @return bool
 13+ */
 14+ public static function ckSchema( $updater = null ) {
 15+ if ( $updater !== null ) {
 16+ $updater->addExtensionUpdate( array( 'addtable', 'online_status', dirname( __FILE__ ) . '/OnlineStatusBar.sql', true ) );
 17+ } else {
 18+ global $wgExtNewTables;
 19+ $wgExtNewTables[] = array(
 20+ 'online_status', dirname( __FILE__ ) . '/OnlineStatusBar.sql' );
 21+ }
 22+ return true;
 23+ }
 24+
 25+ /**
 26+ * @param $user User
 27+ * @param $inject_html string
 28+ * @param $old_name string
 29+ * @return bool
 30+ */
 31+ public static function logout( &$user, &$inject_html, $old_name ) {
 32+ OnlineStatusBar::purge( $old_name );
 33+ OnlineStatusBar::deleteStatus( $old_name );
 34+ return true;
 35+ }
 36+
 37+ /**
 38+ * Called everytime on login
 39+ * @return bool
 40+ */
 41+ public static function updateStatus() {
 42+ global $wgUser;
 43+ OnlineStatusBar::purge( $wgUser );
 44+ OnlineStatusBar::updateStatus();
 45+ return true;
 46+ }
 47+
 48+ /**
 49+ * Creates a bar
 50+ * @param $article Article
 51+ * @param $outputDone bool
 52+ * @param $pcache string
 53+ * @return bool
 54+ */
 55+ public static function renderBar( &$article, &$outputDone, &$pcache ) {
 56+ $context = $article->getContext();
 57+
 58+ OnlineStatusBar::updateStatus();
 59+ $result = OnlineStatusBar::getUserInfoFromTitle( $article->getTitle() );
 60+ if ( $result === false && User::isIP ( $article->getTitle()->getBaseText() ) ) {
 61+ $result = OnlineStatusBar::getAnonFromTitle( $article->getTitle() );
 62+ }
 63+
 64+ if ( $result === false ) {
 65+ return true;
 66+ }
 67+
 68+ /** @var $user User */
 69+ list( $status, $user ) = $result;
 70+
 71+ // Don't display status of those who have opted out
 72+ if ( $user->getOption( 'OnlineStatusBar_hide' ) == true ) {
 73+ return true;
 74+ }
 75+
 76+ $modetext = wfMessage( 'onlinestatusbar-status-' . $status )->toString();
 77+ $image = OnlineStatusBar::getImageHtml( $status );
 78+ $text = wfMessage( 'onlinestatusbar-line', $user->getName() )
 79+ ->rawParams( $image )->params( $modetext )->escaped();
 80+ $context->getOutput()->addHtml( OnlineStatusBar::getStatusBarHtml( $text ) );
 81+
 82+ return true;
 83+ }
 84+
 85+ /**
 86+ * Insert user options
 87+ * @param $user User
 88+ * @param $preferences array
 89+ * @return bool
 90+ */
 91+ public static function preferencesHook( User $user, array &$preferences ) {
 92+ global $wgOnlineStatusBarDefaultOnline, $wgOnlineStatusBarDefaultEnabled, $wgOnlineStatusBarModes;
 93+ $preferences['OnlineStatusBar_active'] = array( 'type' => 'toggle', 'label-message' => 'onlinestatusbar-used', 'section' => 'misc/onlinestatus' );
 94+ $preferences['OnlineStatusBar_hide'] = array( 'type' => 'toggle', 'label-message' => 'onlinestatusbar-hide', 'section' => 'misc/onlinestatus' );
 95+ $preferences['OnlineStatusBar_autoupdate'] = array( 'type' => 'toggle', 'label-message' => 'onlinestatusbar-purge', 'section' => 'misc/onlinestatus' );
 96+ $preferences['OnlineStatusBar_status'] = array( 'type' => 'radio', 'label-message' => 'onlinestatusbar-status', 'section' => 'misc/onlinestatus',
 97+ 'options' => array(
 98+ wfMessage( 'onlinestatusbar-status-online' )->escaped() => 'online',
 99+ wfMessage( 'onlinestatusbar-status-busy' )->escaped() => 'busy',
 100+ wfMessage( 'onlinestatusbar-status-away' )->escaped() => 'away',
 101+ wfMessage( 'onlinestatusbar-status-hidden' )->escaped() => 'hidden'
 102+ ),
 103+ );
 104+ return true;
 105+ }
 106+
 107+ /**
 108+ * @param $defaultOptions array
 109+ * @return bool
 110+ */
 111+ public static function setDefaultOptions( &$defaultOptions ) {
 112+ global $wgOnlineStatusBarDefaultOnline, $wgOnlineStatusBarDefaultEnabled;
 113+ // set defaults
 114+ $defaultOptions['OnlineStatusBar_autoupdate'] = false;
 115+ $defaultOptions['OnlineStatusBar_status'] = $wgOnlineStatusBarDefaultOnline;
 116+ $defaultOptions['OnlineStatusBar_active'] = $wgOnlineStatusBarDefaultEnabled;
 117+ $defaultOptions['OnlineStatusBar_hide'] = false;
 118+ // quit
 119+ return true;
 120+ }
 121+
 122+ /**
 123+ * @param $magicWords array
 124+ * @param $ln string (language)
 125+ * @return bool
 126+ */
 127+ public static function magicWordVar( array &$magicWords, $ln ) {
 128+ $magicWords['isonline'] = array( 0, 'isonline' );
 129+ return true;
 130+ }
 131+
 132+ /**
 133+ * @param $out OutputPage
 134+ * @param $skin Skin
 135+ * @return bool
 136+ */
 137+ public static function stylePage( &$out, &$skin ) {
 138+ $out->addModules( 'ext.OnlineStatusBar' );
 139+ return true;
 140+ }
 141+
 142+ /**
 143+ * @param $vars array
 144+ * @return bool
 145+ */
 146+ public static function magicWordSet( &$vars ) {
 147+ $vars[] = 'isonline';
 148+ return true;
 149+ }
 150+
 151+ /**
 152+ * @param $parser Parser
 153+ * @param $varCache ??
 154+ * @param $index ??
 155+ * @param $ret string?
 156+ * @return bool
 157+ */
 158+ public static function parserGetVariable( &$parser, &$varCache, &$index, &$ret ) {
 159+ if ( $index != 'isonline' ) {
 160+ return true;
 161+ }
 162+
 163+ $result = OnlineStatusBar::getUserInfoFromTitle( $parser->getTitle() );
 164+ if ( User::isIP( $parser->getTitle()->getBaseText() ) && $result == null ) {
 165+ $result = OnlineStatusBar::getAnonFromTitle( $parser->getTitle() );
 166+ }
 167+
 168+ if ( $result == false ) {
 169+ $ret = "unknown";
 170+ return true;
 171+ }
 172+
 173+ $ret = $result[0];
 174+ return true;
 175+ }
 176+}
Property changes on: tags/extensions/OnlineStatusBar/REL_1_0_1/OnlineStatusBar/OnlineStatusBarHooks.php
___________________________________________________________________
Added: svn:eol-style
1177 + native
Index: tags/extensions/OnlineStatusBar/REL_1_0_1/OnlineStatusBar/statusgreen.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: tags/extensions/OnlineStatusBar/REL_1_0_1/OnlineStatusBar/statusgreen.png
___________________________________________________________________
Added: svn:mime-type
2178 + image/png
Index: tags/extensions/OnlineStatusBar/REL_1_0_1/OnlineStatusBar/OnlineStatusBar.sql
@@ -0,0 +1,6 @@
 2+CREATE TABLE /*$wgDBprefix*/online_status (
 3+ `username` varchar(255) NOT NULL default '',
 4+ `timestamp` char(14) NOT NULL default '',
 5+ PRIMARY KEY USING HASH (`username`)
 6+) ENGINE=MEMORY;
 7+
Property changes on: tags/extensions/OnlineStatusBar/REL_1_0_1/OnlineStatusBar/OnlineStatusBar.sql
___________________________________________________________________
Added: svn:eol-style
18 + native

Comments

#Comment by Reedy (talk | contribs)   19:48, 1 November 2011

I think you're creating a nesting level too deep.

You've already distinguished what extension it is, so you could just tag it on the REL_X_Y_Z folder, rather than creating that folder AND THEN svn tagging to another subdir

#Comment by Petrb (talk | contribs)   19:50, 1 November 2011

Yes, I have noticed, I seriously have troubles with svn sometimes, now reading a manual trying to find how update the branched version now (in branches/REL1_17/extensions/OnlineStatusBar) for instance, svn merge is making a lot of conflicts

Status & tagging log