Index: trunk/extensions/NumberOfWikis/NumberOfWikis.i18n.magic.php |
— | — | @@ -0,0 +1,44 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Internationalization file for NumberOfWikis extension. |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + */ |
| 9 | + |
| 10 | +$magicWords = array(); |
| 11 | + |
| 12 | +/** English (English) */ |
| 13 | +$magicWords['en'] = array( |
| 14 | + 'numberofwikis' => array( 0, 'NUMBEROFWIKIS' ), |
| 15 | +); |
| 16 | + |
| 17 | +/** Finnish (Suomi) */ |
| 18 | +$magicWords['fi'] = array( |
| 19 | + 'numberofwikis' => array( 0, 'WIKIENLUKUMÄÄRÄ' ), |
| 20 | +); |
| 21 | + |
| 22 | +/** French (Français) */ |
| 23 | +$magicWords['fr'] = array( |
| 24 | + 'numberofwikis' => array( 0, 'NOMBREWIKIS' ), |
| 25 | +); |
| 26 | + |
| 27 | +/** Dutch (Nederlands) */ |
| 28 | +$magicWords['nl'] = array( |
| 29 | + 'numberofwikis' => array( 0, 'AANTALWIKIS' ), |
| 30 | +); |
| 31 | + |
| 32 | +/** Polish (Polski) */ |
| 33 | +$magicWords['pl'] = array( |
| 34 | + 'numberofwikis' => array( 0, 'LICZBAWIKI' ), |
| 35 | +); |
| 36 | + |
| 37 | +/** Portuguese (Português) */ |
| 38 | +$magicWords['pt'] = array( |
| 39 | + 'numberofwikis' => array( 0, 'NUMERODEWIKIS' ), |
| 40 | +); |
| 41 | + |
| 42 | +/** Swedish (Svenska) */ |
| 43 | +$magicWords['sv'] = array( |
| 44 | + 'numberofwikis' => array( 0, 'ANTALWIKIS' ), |
| 45 | +); |
\ No newline at end of file |
Property changes on: trunk/extensions/NumberOfWikis/NumberOfWikis.i18n.magic.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 46 | + native |
Index: trunk/extensions/NumberOfWikis/NumberOfWikis.php |
— | — | @@ -0,0 +1,80 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Number of wikis -- a magic word to show the number of wikis on ShoutWiki |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + * @version 0.1 |
| 9 | + * @date November 6, 2010 |
| 10 | + * @author Jack Phoenix <jack@shoutwiki.com> |
| 11 | + * @license http://en.wikipedia.org/wiki/Public_domain Public domain |
| 12 | + */ |
| 13 | + |
| 14 | +if( !defined( 'MEDIAWIKI' ) ) { |
| 15 | + die( "This is not a valid entry point.\n" ); |
| 16 | +} |
| 17 | + |
| 18 | +// Extension credits that will show up on Special:Version |
| 19 | +$wgExtensionCredits['variable'][] = array( |
| 20 | + 'name' => 'Number of wikis', |
| 21 | + 'version' => '0.1', |
| 22 | + 'author' => 'Jack Phoenix', |
| 23 | + 'description' => 'Adds <nowiki>{{NUMBEROFWIKIS}}</nowiki> magic word to show the number of wikis on ShoutWiki', |
| 24 | +); |
| 25 | + |
| 26 | +// Translations for {{NUMBEROFWIKIS}} |
| 27 | +$dir = dirname( __FILE__ ) . '/'; |
| 28 | +$wgExtensionMessagesFiles['NumberOfWikis'] = $dir . 'NumberOfWikis.i18n.magic.php'; |
| 29 | + |
| 30 | +$wgHooks['LanguageGetMagic'][] = 'wfNumberOfWikisMagicWord'; |
| 31 | +function wfNumberOfWikisMagicWord( &$magicWords, $langID ) { |
| 32 | + // tell MediaWiki that {{NUMBEROFWIKIS}} and all case variants found in |
| 33 | + // wiki text should be mapped to magic ID 'NUMBEROFWIKIS' |
| 34 | + // (0 means case-insensitive) |
| 35 | + $magicWords['NUMBEROFWIKIS'] = array( 0, 'NUMBEROFWIKIS' ); |
| 36 | + return true; |
| 37 | +} |
| 38 | + |
| 39 | +$wgHooks['ParserGetVariableValueSwitch'][] = 'wfNumberOfWikisAssignValue'; |
| 40 | +function wfNumberOfWikisAssignValue( &$parser, &$cache, &$magicWordId, &$ret ) { |
| 41 | + global $wgMemc; |
| 42 | + |
| 43 | + if ( $magicWordId == 'NUMBEROFWIKIS' ) { |
| 44 | + $key = wfMemcKey( 'shoutwiki', 'numberofwikis' ); |
| 45 | + $data = $wgMemc->get( $key ); |
| 46 | + if ( $data != '' ) { |
| 47 | + // We have it in cache? Oh goody, let's just use the cached value! |
| 48 | + wfDebugLog( |
| 49 | + 'NumberOfWikis', |
| 50 | + 'Got the amount of wikis from memcached' |
| 51 | + ); |
| 52 | + // return value |
| 53 | + $ret = $data; |
| 54 | + } else { |
| 55 | + // Not cached → have to fetch it from the database |
| 56 | + global $wgSharedDB; |
| 57 | + $dbr = wfGetDB( DB_SLAVE, array(), $wgSharedDB ); |
| 58 | + $res = $dbr->select( |
| 59 | + 'wiki_list', |
| 60 | + 'COUNT(*) AS count', |
| 61 | + array(), |
| 62 | + __METHOD__ |
| 63 | + ); |
| 64 | + wfDebugLog( 'NumberOfWikis', 'Got the amount of wikis from DB' ); |
| 65 | + foreach( $res as $row ) { |
| 66 | + // Store the count in cache... |
| 67 | + // (86400 = seconds in a day) |
| 68 | + $wgMemc->set( $key, $row->count, 86400 ); |
| 69 | + // ...and return the value to the user |
| 70 | + $ret = $row->count; |
| 71 | + } |
| 72 | + } |
| 73 | + } |
| 74 | + return true; |
| 75 | +} |
| 76 | + |
| 77 | +$wgHooks['MagicWordwgVariableIDs'][] = 'wfNumberOfWikisVariableIds'; |
| 78 | +function wfNumberOfWikisVariableIds( &$variableIds ) { |
| 79 | + $variableIds[] = 'NUMBEROFWIKIS'; |
| 80 | + return true; |
| 81 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/NumberOfWikis/NumberOfWikis.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 82 | + native |
Index: trunk/extensions/ShoutWikiAds/ShoutWikiAds.php |
— | — | @@ -0,0 +1,58 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * ShoutWiki Ads -- display Google AdSense ads on skins |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + * @version 0.1 |
| 9 | + * @date 24 April 2011 |
| 10 | + * @author Jack Phoenix <jack@countervandalism.net> |
| 11 | + * @license http://en.wikipedia.org/wiki/Public_domain Public domain |
| 12 | + * @link http://www.mediawiki.org/wiki/Extension:ShoutWiki_Ads Documentation |
| 13 | + */ |
| 14 | + |
| 15 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 16 | + die( 'Go away.' ); |
| 17 | +} |
| 18 | + |
| 19 | +// Extension credits that will show up on Special:Version |
| 20 | +$wgExtensionCredits['other'][] = array( |
| 21 | + 'name' => 'ShoutWiki Ads', |
| 22 | + 'version' => '0.1', |
| 23 | + 'author' => 'Jack Phoenix', |
| 24 | + 'description' => 'Delicious advertisements for everyone!', |
| 25 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:ShoutWiki_Ads', |
| 26 | +); |
| 27 | + |
| 28 | +// Autoload the class so that we can actually use its functions |
| 29 | +$wgAutoloadClasses['ShoutWikiAds'] = dirname( __FILE__ ) . '/ShoutWikiAds.class.php'; |
| 30 | + |
| 31 | +// BlueCloud was designed by StrategyWiki with ads in mind, so removing them |
| 32 | +// from it will mess up the display, which is exactly why we don't handle |
| 33 | +// BlueCloud ads here |
| 34 | + |
| 35 | +// Monaco |
| 36 | +$wgHooks['MonacoSetupSkinUserCss'][] = 'ShoutWikiAds::setupAdCSS'; |
| 37 | +$wgHooks['MonacoSidebar'][] = 'ShoutWikiAds::onMonacoSidebar'; |
| 38 | +$wgHooks['MonacoFooter'][] = 'ShoutWikiAds::onMonacoFooter'; |
| 39 | + |
| 40 | +// MonoBook |
| 41 | +$wgHooks['BeforePageDisplay'][] = 'ShoutWikiAds::setupAdCSS'; |
| 42 | +$wgHooks['MonoBookAfterContent'][] = 'ShoutWikiAds::onMonoBookAfterContent'; |
| 43 | +$wgHooks['MonoBookAfterToolbox'][] = 'ShoutWikiAds::onMonoBookAfterToolbox'; |
| 44 | + |
| 45 | +// Truglass |
| 46 | +$wgHooks['TruglassInContent'][] = 'ShoutWikiAds::renderTruglassAd'; |
| 47 | + |
| 48 | +/* Configuration |
| 49 | +$wgAdConfig = array( |
| 50 | + 'enabled' => true, // enabled or not? :P |
| 51 | + 'adsense-client' => '', // provider number w/o the "pub-" part |
| 52 | + 'namespaces' => array( NS_MAIN, NS_TALK ), // array of enabled namespaces |
| 53 | + 'right-column' => true, // do we want a skyscraper ad column (Monobook)? |
| 54 | + 'toolbox-button' => true, // or a "button" ad below the toolbox (Monobook)? |
| 55 | + 'monaco-sidebar' => true, // 200x200 sidebar ad in the sidebar on Monaco skin |
| 56 | + 'monaco-leaderboard' => true, // leaderboard (728x90) ad in the footer on Monaco skin |
| 57 | + 'truglass-leaderboard' => true, // leaderboard ad for Truglass skin |
| 58 | +); |
| 59 | +*/ |
\ No newline at end of file |
Property changes on: trunk/extensions/ShoutWikiAds/ShoutWikiAds.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 60 | + native |
Index: trunk/extensions/ShoutWikiAds/ShoutWikiAds.class.php |
— | — | @@ -0,0 +1,451 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * ShoutWikiAds class -- contains the hooked functions and some other crap for |
| 5 | + * displaying the advertisements. |
| 6 | + * Route all requests through loadAd( $type ) to ensure correct processing. |
| 7 | + * |
| 8 | + * We allow wiki admins to configure some things because our "sane defaults" |
| 9 | + * may clash with certain CSS styles (dark wikis, for example). |
| 10 | + * wfMsgForContent() is used because CSS is "global" (doesn't vary depending on |
| 11 | + * the user's language). |
| 12 | + * |
| 13 | + * All class methods are public and static. |
| 14 | + * |
| 15 | + * @file |
| 16 | + * @ingroup Extensions |
| 17 | + */ |
| 18 | + |
| 19 | +class ShoutWikiAds { |
| 20 | + |
| 21 | + /** |
| 22 | + * Can we show ads on the current page? |
| 23 | + * |
| 24 | + * @return Boolean: false if ads aren't enabled or the current page is |
| 25 | + * Special:UserLogin (login page) or if the user is |
| 26 | + * autoconfirmed and the forceads parameter is NOT in the |
| 27 | + * URL, otherwise true |
| 28 | + */ |
| 29 | + public static function canShowAds() { |
| 30 | + global $wgAdConfig, $wgTitle, $wgUser, $wgRequest; |
| 31 | + |
| 32 | + if( !$wgAdConfig['enabled'] ) { |
| 33 | + return false; |
| 34 | + } |
| 35 | + |
| 36 | + if( $wgTitle instanceof Title && |
| 37 | + SpecialPage::resolveAlias( $wgTitle->getDBkey() ) == 'Userlogin' || |
| 38 | + $wgUser->isAllowed( 'autoconfirmed' ) && !$wgRequest->getVal( 'forceads' ) |
| 39 | + ) |
| 40 | + { |
| 41 | + return false; |
| 42 | + } |
| 43 | + |
| 44 | + return true; |
| 45 | + } |
| 46 | + |
| 47 | + /** |
| 48 | + * Check if the current wiki's language is supported by the ad provider |
| 49 | + * (currently checks against Google's list). |
| 50 | + * |
| 51 | + * @return Boolean: true if the language is supported, otherwise false |
| 52 | + */ |
| 53 | + public static function isSupportedLanguage() { |
| 54 | + global $wgLanguageCode; |
| 55 | + |
| 56 | + // "Publishers are also not permitted to place AdSense code on pages |
| 57 | + // with content primarily in an unsupported language" |
| 58 | + // @see https://www.google.com/adsense/support/bin/answer.py?answer=9727 |
| 59 | + $supportedAdLanguages = array( |
| 60 | + // Arabic -> Dutch (+some Chinese variants) |
| 61 | + 'ar', 'bg', 'zh', 'zh-hans', 'zh-hant', 'hr', 'cs', 'da', 'nl', |
| 62 | + // English and its variants |
| 63 | + 'en', 'en-gb', 'en-lolcat', 'en-piglatin', |
| 64 | + // Finnish -> Polish |
| 65 | + 'fi', 'fr', 'de', 'el', 'he', 'hu', 'it', 'ja', 'ko', 'no', 'pl', |
| 66 | + // Portuguese -> Turkish |
| 67 | + 'pt', 'ro', 'ru', 'sr', 'sr-ec', 'sk', 'es', 'sv', 'th', 'tr', |
| 68 | + // http://adsense.blogspot.com/2009/08/adsense-launched-in-lithuanian.html |
| 69 | + 'lt', 'lv', 'uk' |
| 70 | + ); |
| 71 | + |
| 72 | + if( in_array( $wgLanguageCode, $supportedAdLanguages ) ) { |
| 73 | + return true; |
| 74 | + } else { |
| 75 | + return false; |
| 76 | + } |
| 77 | + } |
| 78 | + |
| 79 | + /** |
| 80 | + * Check if the current namespace is allowed to show ads. |
| 81 | + * |
| 82 | + * @return Boolean: true if the namespace is supported, otherwise false |
| 83 | + */ |
| 84 | + public static function isEnabledNamespace() { |
| 85 | + global $wgAdConfig, $wgTitle; |
| 86 | + $namespace = $wgTitle->getNamespace(); |
| 87 | + if( in_array( $namespace, $wgAdConfig['namespaces'] ) ) { |
| 88 | + return true; |
| 89 | + } else { |
| 90 | + return false; |
| 91 | + } |
| 92 | + } |
| 93 | + |
| 94 | + /** |
| 95 | + * Skin-agnostic way of getting the HTML for a Google AdSense sidebar |
| 96 | + * ad. |
| 97 | + * |
| 98 | + * @return String: HTML code |
| 99 | + */ |
| 100 | + public static function getSidebarHTML() { |
| 101 | + global $wgAdConfig, $wgUser; |
| 102 | + |
| 103 | + $skinName = 'monaco'; |
| 104 | + $id = "{$skinName}-sidebar-ad"; |
| 105 | + $classes = "{$skinName}-ad noprint"; |
| 106 | + // The code below might be useful, but it's not necessary currently |
| 107 | + // as Monobook cannot support this type of ad (Monobook has right |
| 108 | + // column and toolbox ads only) |
| 109 | + /* |
| 110 | + $skinObj = $wgUser->getSkin(); |
| 111 | + $skinName = 'monobook'; // sane default |
| 112 | + if ( get_class( $skinObj ) == 'SkinMonaco' ) { |
| 113 | + $skinName = 'monaco'; |
| 114 | + } elseif ( get_class( $skinObj ) == 'SkinMonoBook' ) { |
| 115 | + $skinName = 'monobook'; |
| 116 | + } |
| 117 | + |
| 118 | + $id = "{$skinName}-sidebar-ad"; |
| 119 | + $classes = "{$skinName}-ad noprint"; |
| 120 | + // Different IDs and classes for Monaco and Monobook |
| 121 | + if ( $skinName == 'monobook' ) { |
| 122 | + $id = 'column-google'; |
| 123 | + $classes = 'noprint'; |
| 124 | + } elseif ( $skinName == 'monaco' ) { |
| 125 | + $id = "{$skinName}-sidebar-ad"; |
| 126 | + $classes = "{$skinName}-ad noprint"; |
| 127 | + } |
| 128 | + */ |
| 129 | + |
| 130 | + return '<!-- Begin sidebar ad (ShoutWikiAds) --> |
| 131 | + <div id="' . $id . '" class="' . $classes . '"> |
| 132 | +<script type="text/javascript"><!-- |
| 133 | +google_ad_client = "pub-' . $wgAdConfig['adsense-client'] . '"; |
| 134 | +google_ad_width = 200; |
| 135 | +google_ad_height = 200; |
| 136 | +google_ad_format = "200x200_as"; |
| 137 | +google_ad_type = "text"; |
| 138 | +google_ad_channel = ""; |
| 139 | +google_color_border = "' . ( !wfEmptyMsg( 'shoutwiki-' . $skinName . '-sidebar-ad-color-border', wfMsgForContent( 'shoutwiki-' . $skinName . '-sidebar-ad-color-border' ) ) ? wfMsgForContent( 'shoutwiki-' . $skinName . '-sidebar-ad-color-border' ) : 'F6F4C4' ) . '"; |
| 140 | +google_color_bg = "' . ( !wfEmptyMsg( 'shoutwiki-' . $skinName . '-sidebar-ad-color-bg', wfMsgForContent( 'shoutwiki-' . $skinName . '-sidebar-ad-color-bg' ) ) ? wfMsgForContent( 'shoutwiki-' . $skinName . '-sidebar-ad-color-bg' ) : 'FFFFE0' ) . '"; |
| 141 | +google_color_link = "' . ( !wfEmptyMsg( 'shoutwiki-' . $skinName . '-sidebar-ad-color-link', wfMsgForContent( 'shoutwiki-' . $skinName . '-sidebar-ad-color-link' ) ) ? wfMsgForContent( 'shoutwiki-' . $skinName . '-sidebar-ad-color-link' ) : '000000' ) . '"; |
| 142 | +google_color_text = "' . ( !wfEmptyMsg( 'shoutwiki-' . $skinName . '-sidebar-ad-color-text', wfMsgForContent( 'shoutwiki-' . $skinName . '-sidebar-ad-color-text' ) ) ? wfMsgForContent( 'shoutwiki-' . $skinName . '-sidebar-ad-color-text' ) : '000000' ) . '"; |
| 143 | +google_color_url = "' . ( !wfEmptyMsg( 'shoutwiki-' . $skinName . '-sidebar-ad-color-url', wfMsgForContent( 'shoutwiki-' . $skinName . '-sidebar-ad-color-url' ) ) ? wfMsgForContent( 'shoutwiki-' . $skinName . '-sidebar-ad-color-url' ) : '002BB8' ) . '"; |
| 144 | +//--></script> |
| 145 | +<script type="text/javascript" |
| 146 | + src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> |
| 147 | +</script> |
| 148 | + |
| 149 | +</div> |
| 150 | +<!-- End sidebar ad (ShoutWikiAds) -->' . "\n"; |
| 151 | + } |
| 152 | + |
| 153 | + /** |
| 154 | + * Skin-agnostic way of getting the HTML for a Google AdSense leaderboard |
| 155 | + * ad. |
| 156 | + * |
| 157 | + * @return String: HTML code |
| 158 | + */ |
| 159 | + public static function getLeaderboardHTML() { |
| 160 | + global $wgAdConfig, $wgUser; |
| 161 | + |
| 162 | + $skinName = 'monaco'; // sane default |
| 163 | + /* |
| 164 | + $skinObj = $wgUser->getSkin(); |
| 165 | + if ( get_class( $skinObj ) == 'SkinMonaco' ) { |
| 166 | + $skinName = 'monaco'; |
| 167 | + } elseif ( get_class( $skinObj ) == 'SkinMonoBook' ) { |
| 168 | + $skinName = 'monobook'; |
| 169 | + } |
| 170 | + */ |
| 171 | + |
| 172 | + $adSlot = ''; |
| 173 | + if ( isset( $wgAdConfig['ad-slot'] ) ) { |
| 174 | + $adSlot = $wgAdConfig['ad-slot']; |
| 175 | + } |
| 176 | + |
| 177 | + return '<!-- Begin leaderboard ad (ShoutWikiAds) --> |
| 178 | + <div id="' . $skinName . '-leaderboard-ad" class="' . $skinName . '-ad noprint"> |
| 179 | +<script type="text/javascript"><!-- |
| 180 | +google_ad_client = "pub-' . $wgAdConfig['adsense-client'] . '"; |
| 181 | +google_ad_slot = "' . $adSlot . '"; |
| 182 | +google_ad_width = 728; |
| 183 | +google_ad_height = 90; |
| 184 | +google_ad_format = "728x90_as"; |
| 185 | +google_ad_type = "text"; |
| 186 | +google_ad_channel = ""; |
| 187 | +google_color_border = "' . ( !wfEmptyMsg( 'shoutwiki-' . $skinName . '-leaderboard-ad-color-border', wfMsgForContent( 'shoutwiki-' . $skinName . '-leaderboard-ad-color-border' ) ) ? wfMsgForContent( 'shoutwiki-' . $skinName . '-leaderboard-ad-color-border' ) : 'F6F4C4' ) . '"; |
| 188 | +google_color_bg = "' . ( !wfEmptyMsg( 'shoutwiki-' . $skinName . '-leaderboard-ad-color-bg', wfMsgForContent( 'shoutwiki-' . $skinName . '-leaderboard-ad-color-bg' ) ) ? wfMsgForContent( 'shoutwiki-' . $skinName . '-leaderboard-ad-color-bg' ) : 'FFFFE0' ) . '"; |
| 189 | +google_color_link = "' . ( !wfEmptyMsg( 'shoutwiki-' . $skinName . '-leaderboard-ad-color-link', wfMsgForContent( 'shoutwiki-' . $skinName . '-leaderboard-ad-color-link' ) ) ? wfMsgForContent( 'shoutwiki-' . $skinName . '-leaderboard-ad-color-link' ) : '000000' ) . '"; |
| 190 | +google_color_text = "' . ( !wfEmptyMsg( 'shoutwiki-' . $skinName . '-leaderboard-ad-color-text', wfMsgForContent( 'shoutwiki-' . $skinName . '-leaderboard-ad-color-text' ) ) ? wfMsgForContent( 'shoutwiki-' . $skinName . '-leaderboard-ad-color-text' ) : '000000' ) . '"; |
| 191 | +google_color_url = "' . ( !wfEmptyMsg( 'shoutwiki-' . $skinName . '-leaderboard-ad-color-url', wfMsgForContent( 'shoutwiki-' . $skinName . '-leaderboard-ad-color-url' ) ) ? wfMsgForContent( 'shoutwiki-' . $skinName . '-leaderboard-ad-color-url' ) : '002BB8' ) . '"; |
| 192 | +//--></script> |
| 193 | +<script type="text/javascript" |
| 194 | + src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> |
| 195 | +</script> |
| 196 | + |
| 197 | +</div> |
| 198 | +<!-- End leaderboard ad (ShoutWikiAds) -->' . "\n"; |
| 199 | + } |
| 200 | + |
| 201 | + /** |
| 202 | + * Get the HTML for Monobook toolbox ad (125x125). |
| 203 | + * @return HTML |
| 204 | + */ |
| 205 | + public static function getToolboxHTML() { |
| 206 | + global $wgAdConfig; |
| 207 | + return '<!-- Begin toolbox ad (ShoutWikiAds) --> |
| 208 | +<div id="p-ads-left" class="noprint"> |
| 209 | +<script type="text/javascript"><!-- |
| 210 | +google_ad_client = "pub-' . $wgAdConfig['adsense-client'] . '"; |
| 211 | +google_ad_width = 125; |
| 212 | +google_ad_height = 125; |
| 213 | +google_ad_format = "125x125_as"; |
| 214 | +google_ad_type = "text"; |
| 215 | +google_ad_channel = ""; |
| 216 | +google_color_border = "' . ( !wfEmptyMsg( 'shoutwiki-monobook-toolbox-ad-color-border', wfMsgForContent( 'shoutwiki-monobook-toolbox-ad-color-border' ) ) ? wfMsgForContent( 'shoutwiki-monobook-toolbox-ad-color-border' ) : 'F6F4C4' ) . '"; |
| 217 | +google_color_bg = "' . ( !wfEmptyMsg( 'shoutwiki-monobook-toolbox-ad-color-bg', wfMsgForContent( 'shoutwiki-monobook-toolbox-ad-color-bg' ) ) ? wfMsgForContent( 'shoutwiki-monobook-toolbox-ad-color-bg' ) : 'FFFFE0' ) . '"; |
| 218 | +google_color_link = "' . ( !wfEmptyMsg( 'shoutwiki-monobook-toolbox-ad-color-link', wfMsgForContent( 'shoutwiki-monobook-toolbox-ad-color-link' ) ) ? wfMsgForContent( 'shoutwiki-monobook-toolbox-ad-color-link' ) : '000000' ) . '"; |
| 219 | +google_color_text = "' . ( !wfEmptyMsg( 'shoutwiki-monobook-toolbox-ad-color-text', wfMsgForContent( 'shoutwiki-monobook-toolbox-ad-color-text' ) ) ? wfMsgForContent( 'shoutwiki-monobook-toolbox-ad-color-text' ) : '000000' ) . '"; |
| 220 | +google_color_url = "' . ( !wfEmptyMsg( 'shoutwiki-monobook-toolbox-ad-color-url', wfMsgForContent( 'shoutwiki-monobook-toolbox-ad-color-url' ) ) ? wfMsgForContent( 'shoutwiki-monobook-toolbox-ad-color-url' ) : '002BB8' ) . '"; |
| 221 | +//--></script> |
| 222 | +<script type="text/javascript" |
| 223 | + src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> |
| 224 | +</script> |
| 225 | + |
| 226 | +</div> |
| 227 | +<!-- End toolbox ad (ShoutWikiAds) -->' . "\n"; |
| 228 | + } |
| 229 | + |
| 230 | + /** |
| 231 | + * Get a skyscraper ad (currently only for Monobook skin). |
| 232 | + * @return HTML |
| 233 | + */ |
| 234 | + public static function getSkyscraperHTML() { |
| 235 | + global $wgAdConfig; |
| 236 | + return "\n" . '<!-- Begin skyscraper ad (ShoutWikiAds) --> |
| 237 | +<div id="column-google" class="noprint"> |
| 238 | +<script type="text/javascript"><!-- |
| 239 | +google_ad_client = "pub-' . $wgAdConfig['adsense-client'] . '"; |
| 240 | +google_ad_slot = "' . $wgAdConfig['ad-slot'] . '"; |
| 241 | +google_ad_width = 120; |
| 242 | +google_ad_height = 600; |
| 243 | +google_ad_format = "120x600_as"; |
| 244 | +google_ad_type = "text"; |
| 245 | +google_ad_channel = ""; |
| 246 | +google_color_border = "' . ( !wfEmptyMsg( 'shoutwiki-monobook-rightcolumn-ad-color-border', wfMsgForContent( 'shoutwiki-monobook-rightcolumn-ad-color-border' ) ) ? wfMsgForContent( 'shoutwiki-monobook-rightcolumn-ad-color-border' ) : 'F6F4C4' ) . '"; |
| 247 | +google_color_bg = "' . ( !wfEmptyMsg( 'shoutwiki-monobook-rightcolumn-ad-color-bg', wfMsgForContent( 'shoutwiki-monobook-rightcolumn-ad-color-bg' ) ) ? wfMsgForContent( 'shoutwiki-monobook-rightcolumn-ad-color-bg' ) : 'FFFFE0' ) . '"; |
| 248 | +google_color_link = "' . ( !wfEmptyMsg( 'shoutwiki-monobook-rightcolumn-ad-color-link', wfMsgForContent( 'shoutwiki-monobook-rightcolumn-ad-color-link' ) ) ? wfMsgForContent( 'shoutwiki-monobook-rightcolumn-ad-color-link' ) : '000000' ) . '"; |
| 249 | +google_color_text = "' . ( !wfEmptyMsg( 'shoutwiki-monobook-rightcolumn-ad-color-text', wfMsgForContent( 'shoutwiki-monobook-rightcolumn-ad-color-text' ) ) ? wfMsgForContent( 'shoutwiki-monobook-rightcolumn-ad-color-text' ) : '000000' ) . '"; |
| 250 | +google_color_url = "' . ( !wfEmptyMsg( 'shoutwiki-monobook-rightcolumn-ad-color-url', wfMsgForContent( 'shoutwiki-monobook-rightcolumn-ad-color-url' ) ) ? wfMsgForContent( 'shoutwiki-monobook-rightcolumn-ad-color-url' ) : '002BB8' ) . '"; |
| 251 | +//--></script> |
| 252 | +<script type="text/javascript" |
| 253 | + src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> |
| 254 | +</script> |
| 255 | + |
| 256 | +</div> |
| 257 | +<!-- End skyscraper ad (ShoutWikiAds) -->' . "\n"; |
| 258 | + } |
| 259 | + |
| 260 | + /** |
| 261 | + * This just adds the relevant ad CSS file under certain conditions. |
| 262 | + * The actual logic is elsewhere. |
| 263 | + * |
| 264 | + * @param $out Object: OutputPage instance |
| 265 | + * @param $sk Object: instance of Skin or one of its child classes |
| 266 | + * @return Boolean: true |
| 267 | + */ |
| 268 | + public static function setupAdCSS( &$out, &$sk ) { |
| 269 | + global $wgAdConfig, $wgRequest, $wgUser; |
| 270 | + |
| 271 | + if( !$wgAdConfig['enabled'] ) { |
| 272 | + return true; |
| 273 | + } |
| 274 | + |
| 275 | + // In order for us to load ad-related CSS, the user must either be very |
| 276 | + // new (=not autoconfirmed) or have supplied the forceads parameter in |
| 277 | + // the URL |
| 278 | + if( |
| 279 | + !$wgUser->isAllowed( 'autoconfirmed' ) || |
| 280 | + $wgRequest->getVal( 'forceads' ) |
| 281 | + ) |
| 282 | + { |
| 283 | + $title = $out->getTitle(); |
| 284 | + $namespace = $title->getNamespace(); |
| 285 | + // Okay, the variable name sucks but anyway...normal page != not login page |
| 286 | + $isNormalPage = $title instanceof Title && |
| 287 | + SpecialPage::resolveAlias( $title->getDBkey() ) !== 'Userlogin'; |
| 288 | + // Load ad CSS file when ads are enabled |
| 289 | + if( |
| 290 | + $isNormalPage && |
| 291 | + in_array( $namespace, $wgAdConfig['namespaces'] ) |
| 292 | + ) |
| 293 | + { |
| 294 | + global $wgScriptPath; |
| 295 | + $cssPath = $wgScriptPath . '/extensions/ShoutWikiAds/css/'; |
| 296 | + if ( get_class( $sk ) == 'SkinMonaco' ) { // Monaco |
| 297 | + $out->addExtensionStyle( $cssPath . 'monaco-ads.css' ); |
| 298 | + } elseif( get_class( $sk ) == 'SkinMonoBook' ) { // Monobook |
| 299 | + if ( $wgAdConfig['right-column'] ) { |
| 300 | + $out->addExtensionStyle( $cssPath . 'monobook-skyscraper-ad.css' ); |
| 301 | + } |
| 302 | + if ( $wgAdConfig['toolbox-button'] ) { |
| 303 | + $out->addExtensionStyle( $cssPath . 'monobook-button-ad.css' ); |
| 304 | + } |
| 305 | + } elseif ( get_class( $sk ) == 'SkinTruglass' ) { // Truglass |
| 306 | + $out->addExtensionStyle( $cssPath . 'truglass-ads.css' ); |
| 307 | + } |
| 308 | + } |
| 309 | + } |
| 310 | + |
| 311 | + return true; |
| 312 | + } |
| 313 | + |
| 314 | + /** |
| 315 | + * Load toolbox ad for Monobook skin. |
| 316 | + * @return Boolean: true |
| 317 | + */ |
| 318 | + public static function onMonoBookAfterToolbox() { |
| 319 | + global $wgAdConfig; |
| 320 | + if ( $wgAdConfig['toolbox-button'] ) { |
| 321 | + echo self::loadAd( 'toolbox-button' ); |
| 322 | + } |
| 323 | + return true; |
| 324 | + } |
| 325 | + |
| 326 | + /** |
| 327 | + * Load skyscraper ad for Monobook skin. |
| 328 | + * @return Boolean: true |
| 329 | + */ |
| 330 | + public static function onMonoBookAfterContent() { |
| 331 | + global $wgAdConfig; |
| 332 | + if ( $wgAdConfig['right-column'] ) { |
| 333 | + echo self::loadAd( 'right-column' ); |
| 334 | + } |
| 335 | + return true; |
| 336 | + } |
| 337 | + |
| 338 | + /** |
| 339 | + * Load sidebar ad for Monaco skin. |
| 340 | + * @return Boolean: true |
| 341 | + */ |
| 342 | + public static function onMonacoSidebar() { |
| 343 | + global $wgAdConfig; |
| 344 | + if ( $wgAdConfig['monaco-sidebar'] ) { |
| 345 | + echo self::loadAd( 'sidebar' ); |
| 346 | + } |
| 347 | + return true; |
| 348 | + } |
| 349 | + |
| 350 | + /** |
| 351 | + * Load leaderboard ad in Monaco skin's footer. |
| 352 | + * @return Boolean: true |
| 353 | + */ |
| 354 | + public static function onMonacoFooter() { |
| 355 | + global $wgAdConfig; |
| 356 | + if ( $wgAdConfig['monaco-leaderboard'] ) { |
| 357 | + echo self::loadAd( 'leaderboard' ); |
| 358 | + } |
| 359 | + return true; |
| 360 | + } |
| 361 | + |
| 362 | + /** |
| 363 | + * Called *only* by Truglass skin. |
| 364 | + * |
| 365 | + * @todo FIXME: use self::getLeaderboardHTML() or something for getting the |
| 366 | + * ad code... |
| 367 | + * @return Boolean: true |
| 368 | + */ |
| 369 | + public static function renderTruglassAd() { |
| 370 | + global $wgAdConfig; |
| 371 | + if ( $wgAdConfig['truglass-leaderboard'] ) { |
| 372 | + echo '<!-- Begin Truglass ad (ShoutWikiAds) --> |
| 373 | + <table border="0" cellpadding="0" cellspacing="0" width="100%"> |
| 374 | + <tbody> |
| 375 | + <tr> |
| 376 | + <td valign="top" id="contentBox"> |
| 377 | + <div id="contentCont"> |
| 378 | + <table id="topsector" width="100%"> |
| 379 | + <tr> |
| 380 | + <td> |
| 381 | + <div id="topadsleft" class="noprint"> |
| 382 | + <script type="text/javascript"><!-- |
| 383 | + google_ad_client = "pub-' . $wgAdConfig['adsense-client'] . '"; |
| 384 | + google_alternate_color = "eeeeee"; |
| 385 | + google_ad_width = 728; |
| 386 | + google_ad_height = 90; |
| 387 | + google_ad_format = "728x90_as"; |
| 388 | + google_ad_type = "text"; |
| 389 | + google_color_border = "CDCDCD"; |
| 390 | + google_color_bg = "FFFFFF"; |
| 391 | + google_color_link = "0066FF"; |
| 392 | + google_color_url = "00A000"; |
| 393 | + google_color_text = "000000"; |
| 394 | + //--> |
| 395 | + </script> |
| 396 | + <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> |
| 397 | + </script> |
| 398 | + </div> |
| 399 | + </td> |
| 400 | + </tr> |
| 401 | + </table> |
| 402 | + </div> |
| 403 | + </td> |
| 404 | + </tr> |
| 405 | + </tbody> |
| 406 | + </table> |
| 407 | + <!-- End Truglass ad (ShoutWikiAds) -->' . "\n"; |
| 408 | + } |
| 409 | + return true; |
| 410 | + } |
| 411 | + |
| 412 | + /** |
| 413 | + * Load ads for a defined "slot" |
| 414 | + * Ad code (div element + JS) is echoed back and no value is returned |
| 415 | + * except in special cases we return true (early return cases/unrecognized slot) |
| 416 | + * |
| 417 | + * @param $type String: what kind of ads to load |
| 418 | + * @return Mixed: HTML (on success) or boolean true (on failure) |
| 419 | + */ |
| 420 | + public static function loadAd( $type ) { |
| 421 | + // Early return cases: |
| 422 | + // ** if we can't show ads on the current page (i.e. if it's the login |
| 423 | + // page or something) |
| 424 | + // ** if the wiki's language code isn't supported by Google AdSense |
| 425 | + // ** if ads aren't enabled for the current namespace |
| 426 | + if ( !self::canShowAds() ) { |
| 427 | + return ''; |
| 428 | + } |
| 429 | + |
| 430 | + if ( !self::isSupportedLanguage() ) { |
| 431 | + return ''; |
| 432 | + } |
| 433 | + |
| 434 | + if ( !self::isEnabledNamespace() ) { |
| 435 | + return ''; |
| 436 | + } |
| 437 | + |
| 438 | + // Main ad logic starts here |
| 439 | + if( $type === 'leaderboard' ) { |
| 440 | + return self::getLeaderboardHTML(); |
| 441 | + } elseif( $type === 'sidebar' ) { |
| 442 | + return self::getSidebarHTML(); |
| 443 | + } elseif ( $type === 'toolbox-button' ) { |
| 444 | + return self::getToolboxHTML(); |
| 445 | + } elseif ( $type === 'right-column' ) { |
| 446 | + return self::getSkyscraperHTML(); |
| 447 | + } else { // invalid type/these ads not enabled in $wgAdConfig |
| 448 | + return ''; |
| 449 | + } |
| 450 | + } |
| 451 | + |
| 452 | +} |
Property changes on: trunk/extensions/ShoutWikiAds/ShoutWikiAds.class.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 453 | + native |
Index: trunk/extensions/ShoutWikiAds/css/monobook-skyscraper-ad.css |
— | — | @@ -0,0 +1,45 @@ |
| 2 | +/** |
| 3 | + * Skyscraper ad styling for Monobook skin |
| 4 | + */ |
| 5 | +#content { |
| 6 | + margin: 2.8em 125px 0 12.2em !important; |
| 7 | +} |
| 8 | + |
| 9 | +#content { |
| 10 | + border-right: solid 1px rgb(170,170,170); |
| 11 | +} |
| 12 | + |
| 13 | +#column-google { |
| 14 | + width: 120px; |
| 15 | + clear: left; |
| 16 | + position: absolute; |
| 17 | + padding: 35px 0px 0px 3px; |
| 18 | + float: right; |
| 19 | + right: 0px; |
| 20 | + top: 10px; |
| 21 | + z-index: 1; |
| 22 | +} |
| 23 | + |
| 24 | +#footer { |
| 25 | + width: 91%; |
| 26 | +} |
| 27 | + |
| 28 | +/* RTL rules */ |
| 29 | +body.rtl #content { |
| 30 | + margin: 2.8em 12.2em 0 125px !important; |
| 31 | +} |
| 32 | + |
| 33 | +body.rtl #content { |
| 34 | + border-left: solid 1px rgb(170,170,170); |
| 35 | +} |
| 36 | + |
| 37 | +body.rtl #column-google { |
| 38 | + width: 120px; |
| 39 | + clear: right; |
| 40 | + position: absolute; |
| 41 | + padding: 35px 3px 0px 0px; |
| 42 | + float: left; |
| 43 | + left: 0px; |
| 44 | + top: 10px; |
| 45 | + z-index: 1; |
| 46 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/ShoutWikiAds/css/monobook-skyscraper-ad.css |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 47 | + native |
Index: trunk/extensions/ShoutWikiAds/css/truglass-ads.css |
— | — | @@ -0,0 +1,6 @@ |
| 2 | +/** |
| 3 | + * Ad CSS for Truglass skin |
| 4 | + */ |
| 5 | +#topadsleft { |
| 6 | + text-align: center; |
| 7 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/ShoutWikiAds/css/truglass-ads.css |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 8 | + native |
Index: trunk/extensions/ShoutWikiAds/css/monobook-button-ad.css |
— | — | @@ -0,0 +1,17 @@ |
| 2 | +/** |
| 3 | + * Button ad styling for Monobook skin |
| 4 | + */ |
| 5 | +#p-ads-left { |
| 6 | + right: 0px; |
| 7 | + top: 10px; |
| 8 | + width: 150px; |
| 9 | + z-index: 1; |
| 10 | +} |
| 11 | + |
| 12 | +/* RTL rules */ |
| 13 | +body.rtl #p-ads-left { |
| 14 | + left: 0px; |
| 15 | + top: 10px; |
| 16 | + width: 150px; |
| 17 | + z-index: 1; |
| 18 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/ShoutWikiAds/css/monobook-button-ad.css |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 19 | + native |
Index: trunk/extensions/ShoutWikiAds/css/monaco-ads.css |
— | — | @@ -0,0 +1,21 @@ |
| 2 | +/** |
| 3 | + * Ad CSS for Monaco skin |
| 4 | + * |
| 5 | + * @see http://www.ianhoar.com/2008/03/08/how-to-center-google-adsense-ads/ |
| 6 | + * @note The !importants are really needed, don't remove them! |
| 7 | + */ |
| 8 | +.monaco-ad { |
| 9 | + position: relative !important; |
| 10 | + margin: auto !important; |
| 11 | + padding-bottom: 5px !important; |
| 12 | +} |
| 13 | + |
| 14 | +/* Leaderboard ad */ |
| 15 | +#monaco-leaderboard-ad { |
| 16 | + width: 728px; |
| 17 | +} |
| 18 | + |
| 19 | +/* Sidebar ad (small square) */ |
| 20 | +#monaco-sidebar-ad { |
| 21 | + width: 200px; |
| 22 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/ShoutWikiAds/css/monaco-ads.css |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 23 | + native |
Index: trunk/extensions/GoogleDocs4MW/GoogleDocs4MW.php |
— | — | @@ -0,0 +1,49 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * GoogleDocs4MW parser extension - adds <googlespreadsheet> tag for displaying |
| 5 | + * Google Docs' spreadsheets |
| 6 | + * |
| 7 | + * @file |
| 8 | + * @ingroup Extensions |
| 9 | + * @version 1.0 |
| 10 | + * @author Jack Phoenix <jack@shoutwiki.com> |
| 11 | + * @copyright © 2008-2010 Jack Phoenix |
| 12 | + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
| 13 | + */ |
| 14 | + |
| 15 | +if( !defined( 'MEDIAWIKI' ) ) { |
| 16 | + die( "This file is an extension to the MediaWiki software and is not a valid access point.\n" ); |
| 17 | +} |
| 18 | + |
| 19 | +// Add extension credits that show up on Special:Version |
| 20 | +$wgExtensionCredits['parserhook'][] = array( |
| 21 | + 'name' => 'GoogleDocs4MW', |
| 22 | + 'version' => '1.0', |
| 23 | + 'author' => 'Jack Phoenix', |
| 24 | + 'description' => 'Adds <tt><googlespreadsheet></tt> tag for Google Docs\' spreadsheets display', |
| 25 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:GoogleDocs4MW' |
| 26 | +); |
| 27 | + |
| 28 | +// Set up the parser hook |
| 29 | +$wgHooks['ParserFirstCallInit'][] = 'wfGoogleDocs'; |
| 30 | +function wfGoogleDocs( &$parser ) { |
| 31 | + $parser->setHook( 'googlespreadsheet', 'renderGoogleSpreadsheet' ); |
| 32 | + return true; |
| 33 | +} |
| 34 | + |
| 35 | +// The callback function for converting the input to HTML output |
| 36 | +function renderGoogleSpreadsheet( $input, $argv ) { |
| 37 | + $width = isset( $argv['width'] ) ? $argv['width'] : 500; |
| 38 | + $height = isset( $argv['height'] ) ? $argv['height'] : 300; |
| 39 | + $style = isset( $argv['style'] ) ? $argv['style'] : 'width:100%'; |
| 40 | + $key = htmlspecialchars( $input ); |
| 41 | + |
| 42 | + $output = '<iframe class="googlespreadsheetframe" width="' . |
| 43 | + htmlspecialchars( $width ) . '" height="' . |
| 44 | + htmlspecialchars( $height ) . '" style="' . |
| 45 | + htmlspecialchars( $style ) . |
| 46 | + '" src="http://spreadsheets.google.com/pub?key=' . $key . |
| 47 | + '&output=html&widget=true"></iframe>'; |
| 48 | + |
| 49 | + return $output; |
| 50 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/GoogleDocs4MW/GoogleDocs4MW.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 51 | + native |