Index: trunk/extensions/AdManager/AdManager.i18n.php |
— | — | @@ -1,29 +1,29 @@ |
2 | | -<?php
|
3 | | -$messages = array();
|
4 | | -
|
5 | | -$messages['en'] = array(
|
6 | | - 'admanager' => 'Ad Manager',
|
7 | | - 'admanagerzones' => 'Ad Manager Zones',
|
8 | | - 'admanager-desc' => 'Provides a [[Special:AdManager|special page]] which allows sysops to set the zone for pages or categories',
|
9 | | - 'admanager_docu' => 'To add or remove the ad zone of a page or entire category, add or remove its title below.',
|
10 | | - 'admanagerzones_docu' => 'Enter each ad zone number on its own line.',
|
11 | | - 'admanager_invalidtargetpage' => 'No page found with title "$1".',
|
12 | | - 'admanager_invalidtargetcategory' => 'No category found with title "$1".',
|
13 | | - 'admanager_notable' => 'Error! A required database table was not found! Run update.php first.',
|
14 | | - 'admanager_noAdManagerZones' => 'Error! You must add some ad zones. Enter them at [[Special:AdManagerZones]].',
|
15 | | - 'admanager_labelPage' => 'Page titles',
|
16 | | - 'admanager_labelCategory' => 'Category names',
|
17 | | - 'admanager_submit' => 'Submit',
|
18 | | - 'admanager_noads' => 'Display no ads',
|
19 | | - 'admanager_Page' => 'Pages',
|
20 | | - 'admanager_Category' => 'Categories',
|
21 | | - 'admanager_added' => 'Your changes have been saved',
|
22 | | - 'admanager_noadsset' => '$1 has been set to show no ads',
|
23 | | - 'admanager_addedzone' => 'Added zone',
|
24 | | - 'admanager_zonenum' => 'Zone #:',
|
25 | | - 'admanager_zonenotnumber' => 'Error! $1 is not a number.',
|
26 | | - 'admanager_return' => 'Return to [[Special:AdManager]]',
|
27 | | - 'admanager_gotoads' => '[[Special:AdManager|Edit ad placement]]',
|
28 | | - 'admanager_gotozones' => '[[Special:AdManagerZones|Edit ad zones]]'
|
29 | | -
|
30 | | -);
|
| 2 | +<?php |
| 3 | +$messages = array(); |
| 4 | + |
| 5 | +$messages['en'] = array( |
| 6 | + 'admanager' => 'Ad Manager', |
| 7 | + 'admanagerzones' => 'Ad Manager Zones', |
| 8 | + 'admanager-desc' => 'Provides a [[Special:AdManager|special page]] which allows sysops to set the zone for pages or categories', |
| 9 | + 'admanager_docu' => 'To add or remove the ad zone of a page or entire category, add or remove its title below.', |
| 10 | + 'admanagerzones_docu' => 'Enter each ad zone number on its own line.', |
| 11 | + 'admanager_invalidtargetpage' => 'No page found with title "$1".', |
| 12 | + 'admanager_invalidtargetcategory' => 'No category found with title "$1".', |
| 13 | + 'admanager_notable' => 'Error! A required database table was not found! Run update.php first.', |
| 14 | + 'admanager_noAdManagerZones' => 'Error! You must add some ad zones. Enter them at [[Special:AdManagerZones]].', |
| 15 | + 'admanager_labelPage' => 'Page titles', |
| 16 | + 'admanager_labelCategory' => 'Category names', |
| 17 | + 'admanager_submit' => 'Submit', |
| 18 | + 'admanager_noads' => 'Display no ads', |
| 19 | + 'admanager_Page' => 'Pages', |
| 20 | + 'admanager_Category' => 'Categories', |
| 21 | + 'admanager_added' => 'Your changes have been saved', |
| 22 | + 'admanager_noadsset' => '$1 has been set to show no ads', |
| 23 | + 'admanager_addedzone' => 'Added zone', |
| 24 | + 'admanager_zonenum' => 'Zone #:', |
| 25 | + 'admanager_zonenotnumber' => 'Error! $1 is not a number.', |
| 26 | + 'admanager_return' => 'Return to [[Special:AdManager]]', |
| 27 | + 'admanager_gotoads' => '[[Special:AdManager|Edit ad placement]]', |
| 28 | + 'admanager_gotozones' => '[[Special:AdManagerZones|Edit ad zones]]' |
| 29 | + |
| 30 | +); |
Property changes on: trunk/extensions/AdManager/AdManager.i18n.php |
___________________________________________________________________ |
Added: svn:eol-style |
31 | 31 | + native |
Index: trunk/extensions/AdManager/AdManager.utils.php |
— | — | @@ -1,32 +1,32 @@ |
2 | | -<?php
-/**
- * Helper functions for the Ad Manager extension.
- */
-
-class AdManagerUtils {
-
- #Displays an error box message. Returns true if error found
- public static function checkForAndDisplayError( $condition, $wikiMsg = 'admanager_error') {
- global $wgOut;
-
- if (!$condition) {
- $wgOut->addHtml('<div class="errorbox">');
- $wgOut->addWikiMsg( $wikiMsg );
- $wgOut->addHtml('</div>');
- return true;
- }
- return false;
- }
-
- /**
- * Helper function to display a hidden field for different versions
- * of MediaWiki.
- */
- static function hiddenField( $name, $value ) {
- if ( class_exists( 'Html' ) ) {
- return "\t" . Html::hidden( $name, $value ) . "\n";
- } else {
- return "\t" . Xml::hidden( $name, $value ) . "\n";
- }
- }
+<?php |
| 2 | +/** |
| 3 | + * Helper functions for the Ad Manager extension. |
| 4 | + */ |
| 5 | + |
| 6 | +class AdManagerUtils { |
| 7 | + |
| 8 | + #Displays an error box message. Returns true if error found |
| 9 | + public static function checkForAndDisplayError( $condition, $wikiMsg = 'admanager_error') { |
| 10 | + global $wgOut; |
| 11 | + |
| 12 | + if (!$condition) { |
| 13 | + $wgOut->addHtml('<div class="errorbox">'); |
| 14 | + $wgOut->addWikiMsg( $wikiMsg ); |
| 15 | + $wgOut->addHtml('</div>'); |
| 16 | + return true; |
| 17 | + } |
| 18 | + return false; |
| 19 | + } |
| 20 | + |
| 21 | + /** |
| 22 | + * Helper function to display a hidden field for different versions |
| 23 | + * of MediaWiki. |
| 24 | + */ |
| 25 | + static function hiddenField( $name, $value ) { |
| 26 | + if ( class_exists( 'Html' ) ) { |
| 27 | + return "\t" . Html::hidden( $name, $value ) . "\n"; |
| 28 | + } else { |
| 29 | + return "\t" . Xml::hidden( $name, $value ) . "\n"; |
| 30 | + } |
| 31 | + } |
3 | 32 | } |
\ No newline at end of file |
Property changes on: trunk/extensions/AdManager/AdManager.utils.php |
___________________________________________________________________ |
Added: svn:eol-style |
4 | 33 | + native |
Index: trunk/extensions/AdManager/AdManager.php |
— | — | @@ -1,42 +1,42 @@ |
2 | | -<?php
|
3 | | -/**
|
4 | | - * AdManager - a Mediawiki extension that allows setting an ad zone for indiviual pages or categories
|
5 | | - *
|
6 | | - * The special page created is 'Special:AdManager', which allows sysops to set the zone for the
|
7 | | - * pages or categories. The correct ad code for adding the zone is automatically added to the correct page.
|
8 | | - */
|
9 | | -
|
10 | | -if ( !defined( 'MEDIAWIKI' ) ) die( 'Not an entry point.' );
|
11 | | -
|
12 | | -define( 'AD_TABLE', 'ad' );
|
13 | | -define( 'AD_ZONES_TABLE', 'adzones' );
|
14 | | -
|
15 | | -// credits
|
16 | | -$wgExtensionCredits['specialpage'][] = array(
|
17 | | - 'path' => __FILE__,
|
18 | | - 'name' => 'AdManager',
|
19 | | - 'version' => '0.1',
|
20 | | - 'author' => 'Ike Hecht for WikiWorks',
|
21 | | - 'url' => 'http://www.mediawiki.org/wiki/Extension:AdManager',
|
22 | | - 'descriptionmsg' => 'admanager-desc',
|
23 | | -);
|
24 | | -
|
25 | | -$dir = dirname( __FILE__ ) . '/';
|
26 | | -$wgExtensionMessagesFiles['AdManager'] = $dir . 'AdManager.i18n.php';
|
27 | | -
|
28 | | -// This extension uses its own permission type, 'admanager'
|
29 | | -$wgAvailableRights[] = 'admanager';
|
30 | | -$wgGroupPermissions['sysop']['admanager'] = true;
|
31 | | -
|
32 | | -$wgSpecialPages['AdManagerZones'] = 'SpecialAdManagerZones';
|
33 | | -$wgSpecialPages['AdManager'] = 'SpecialAdManager';
|
34 | | -$wgSpecialPageGroups['AdManagerZones'] = 'other';
|
35 | | -$wgSpecialPageGroups['AdManager'] = 'other';
|
36 | | -$wgAutoloadClasses['SpecialAdManagerZones'] = $dir . 'SpecialAdManagerZones.php';
|
37 | | -$wgAutoloadClasses['SpecialAdManager'] = $dir . 'SpecialAdManager.php';
|
38 | | -
|
39 | | -$wgAutoloadClasses['AdManagerHooks'] = $dir . '/AdManager.hooks.php';
|
40 | | -$wgHooks['LoadExtensionSchemaUpdates'][] = 'AdManagerHooks::onSchemaUpdate';
|
41 | | -$wgHooks['SkinBuildSidebar'][] = 'AdManagerHooks::SkinBuildSidebar';
|
42 | | -
|
| 2 | +<?php |
| 3 | +/** |
| 4 | + * AdManager - a Mediawiki extension that allows setting an ad zone for indiviual pages or categories |
| 5 | + * |
| 6 | + * The special page created is 'Special:AdManager', which allows sysops to set the zone for the |
| 7 | + * pages or categories. The correct ad code for adding the zone is automatically added to the correct page. |
| 8 | + */ |
| 9 | + |
| 10 | +if ( !defined( 'MEDIAWIKI' ) ) die( 'Not an entry point.' ); |
| 11 | + |
| 12 | +define( 'AD_TABLE', 'ad' ); |
| 13 | +define( 'AD_ZONES_TABLE', 'adzones' ); |
| 14 | + |
| 15 | +// credits |
| 16 | +$wgExtensionCredits['specialpage'][] = array( |
| 17 | + 'path' => __FILE__, |
| 18 | + 'name' => 'AdManager', |
| 19 | + 'version' => '0.1', |
| 20 | + 'author' => 'Ike Hecht for WikiWorks', |
| 21 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:AdManager', |
| 22 | + 'descriptionmsg' => 'admanager-desc', |
| 23 | +); |
| 24 | + |
| 25 | +$dir = dirname( __FILE__ ) . '/'; |
| 26 | +$wgExtensionMessagesFiles['AdManager'] = $dir . 'AdManager.i18n.php'; |
| 27 | + |
| 28 | +// This extension uses its own permission type, 'admanager' |
| 29 | +$wgAvailableRights[] = 'admanager'; |
| 30 | +$wgGroupPermissions['sysop']['admanager'] = true; |
| 31 | + |
| 32 | +$wgSpecialPages['AdManagerZones'] = 'SpecialAdManagerZones'; |
| 33 | +$wgSpecialPages['AdManager'] = 'SpecialAdManager'; |
| 34 | +$wgSpecialPageGroups['AdManagerZones'] = 'other'; |
| 35 | +$wgSpecialPageGroups['AdManager'] = 'other'; |
| 36 | +$wgAutoloadClasses['SpecialAdManagerZones'] = $dir . 'SpecialAdManagerZones.php'; |
| 37 | +$wgAutoloadClasses['SpecialAdManager'] = $dir . 'SpecialAdManager.php'; |
| 38 | + |
| 39 | +$wgAutoloadClasses['AdManagerHooks'] = $dir . '/AdManager.hooks.php'; |
| 40 | +$wgHooks['LoadExtensionSchemaUpdates'][] = 'AdManagerHooks::onSchemaUpdate'; |
| 41 | +$wgHooks['SkinBuildSidebar'][] = 'AdManagerHooks::SkinBuildSidebar'; |
| 42 | + |
43 | 43 | $wgAutoloadClasses['AdManagerUtils'] = $dir . '/AdManager.utils.php'; |
\ No newline at end of file |
Property changes on: trunk/extensions/AdManager/AdManager.php |
___________________________________________________________________ |
Added: svn:eol-style |
44 | 44 | + native |
Index: trunk/extensions/AdManager/SpecialAdManagerZones.php |
— | — | @@ -1,122 +1,122 @@ |
2 | | -<?php
|
3 | | -class SpecialAdManagerZones extends SpecialPage {
|
4 | | -
|
5 | | - function __construct() {
|
6 | | - global $wgVersion;
|
7 | | - parent::__construct( 'AdManagerZones' );
|
8 | | - if ( version_compare( $wgVersion, '1.16', '<' ) ) {
|
9 | | - wfLoadExtensionMessages( 'AdManager' );
|
10 | | - }
|
11 | | - }
|
12 | | -
|
13 | | - function execute( $query ) {
|
14 | | - global $wgUser, $wgOut, $wgDBprefix;
|
15 | | - if ( ! $wgUser->isAllowed( 'admanager' ) ) {
|
16 | | - $wgOut->permissionRequired( 'admanager' );
|
17 | | - return;
|
18 | | - }
|
19 | | -
|
20 | | - $this->setHeaders();
|
21 | | - if ( method_exists( $wgOut, 'addModuleStyles' ) &&
|
22 | | - !is_null( $wgOut->getResourceLoader()->getModule( 'mediawiki.special' ) ) ) {
|
23 | | - $wgOut->addModuleStyles( 'mediawiki.special' );
|
24 | | - }
|
25 | | -
|
26 | | - $fullTableName = $wgDBprefix . AD_ZONES_TABLE;
|
27 | | - $dbr = wfGetDB( DB_SLAVE );
|
28 | | - if ( AdManagerUtils::checkForAndDisplayError( $dbr->tableExists( $fullTableName ), 'admanager_notable' ) ) {
|
29 | | - return;
|
30 | | - }
|
31 | | -
|
32 | | - $this->doSpecialAdManagerZones();
|
33 | | - }
|
34 | | -
|
35 | | - function doSpecialAdManagerZones() {
|
36 | | - global $wgRequest;
|
37 | | - $errors = array();
|
38 | | -
|
39 | | - if ( $wgRequest->getCheck( 'submitted' ) ) {
|
40 | | - $this->zones = explode( "\n", trim( $wgRequest->getVal( 'zones' ) ) );
|
41 | | - foreach ($this->zones as $zone) {
|
42 | | - $zone = trim( $zone );
|
43 | | - if ( !is_numeric( $zone ) ) {
|
44 | | - $errors['admanager_zonenotnumber'][] = $zone;
|
45 | | - }
|
46 | | - }
|
47 | | - if ( empty( $errors ) ) {
|
48 | | - $this->addZones();
|
49 | | - }
|
50 | | - }
|
51 | | -
|
52 | | - $this->showForm( $errors );
|
53 | | - }
|
54 | | - function addZones() {
|
55 | | - global $wgOut, $wgRequest, $wgDBprefix;
|
56 | | -
|
57 | | - $zones = $this->zones;
|
58 | | -
|
59 | | - $dbw = wfGetDB( DB_MASTER );
|
60 | | - $fullTableName = $wgDBprefix . AD_ZONES_TABLE;
|
61 | | -
|
62 | | - $dbw->delete( $fullTableName, '*');
|
63 | | - $text = "<div class=\"successbox\">\n";
|
64 | | - foreach ( $zones as $zone ) {
|
65 | | - if ( $zone ) {
|
66 | | - $dbw->insert(
|
67 | | - $fullTableName, array( 'ad_zone_id' => $zone )
|
68 | | - );
|
69 | | - $text .= "* " . wfmsg('admanager_addedzone') . " $zone";
|
70 | | - }
|
71 | | - }
|
72 | | - $text .= "</div><br clear=\"both\" />";
|
73 | | - $wgOut->addWikiText( $text );
|
74 | | - }
|
75 | | -
|
76 | | - function showForm( array $errors ) {
|
77 | | - global $wgOut, $wgDBprefix;
|
78 | | -
|
79 | | - if ( empty( $errors ) ) {
|
80 | | - $wgOut->addWikiMsg( 'admanagerzones_docu' );
|
81 | | - } else {
|
82 | | - $text = "<div class=\"errorbox\">\n";
|
83 | | - foreach ( $errors as $message => $pageTitles ) {
|
84 | | - foreach ( $pageTitles as $pageTitle) {
|
85 | | - $text .= wfMsg( $message, $pageTitle ) . "<br />";
|
86 | | - }
|
87 | | - }
|
88 | | - $text .= "</div><br clear=\"both\" />";
|
89 | | - $wgOut->addWikiText( $text );
|
90 | | - }
|
91 | | -
|
92 | | - $fullTableName = $wgDBprefix . AD_ZONES_TABLE;
|
93 | | - $dbr = wfGetDB( DB_SLAVE );
|
94 | | - $current = $dbr->select(
|
95 | | - $fullTableName,
|
96 | | - array( '*' )
|
97 | | - );
|
98 | | -
|
99 | | - //Fetch current table into array
|
100 | | - $currentArray = Array();
|
101 | | - while ( $currentRow = $current->fetchObject() ) {
|
102 | | - $currentArray[] = $currentRow->ad_zone_id;
|
103 | | - }
|
104 | | -
|
105 | | - $display = '';
|
106 | | - foreach ($currentArray as $zone) {
|
107 | | - $display .= "$zone\n";
|
108 | | - }
|
109 | | -
|
110 | | - $text = Xml::openElement( 'form', array( 'id' => 'admanagerzones', 'action' => $this->getTitle()->getFullUrl(), 'method' => 'post' ) ) . "\n" .
|
111 | | - AdManagerUtils::hiddenField( 'title', $this->getTitle()->getPrefixedText() ) .
|
112 | | - AdManagerUtils::hiddenField( 'submitted', 1 );
|
113 | | - $text .= Xml::textarea( 'zones' , $display, 25, 20, array( 'style' => 'width: auto; margin-bottom: 1em;' ) );
|
114 | | - $text .= Xml::element('br');
|
115 | | - $text .= Xml::submitButton( wfMsg( 'admanager_submit' ) );
|
116 | | - $text .= Xml::closeElement( 'form' );
|
117 | | - $text .= Xml::element('br');
|
118 | | -
|
119 | | - $wgOut->addHTML( $text );
|
120 | | -
|
121 | | - $wgOut->addWikiMsg( 'admanager_gotoads' );
|
122 | | - }
|
| 2 | +<?php |
| 3 | +class SpecialAdManagerZones extends SpecialPage { |
| 4 | + |
| 5 | + function __construct() { |
| 6 | + global $wgVersion; |
| 7 | + parent::__construct( 'AdManagerZones' ); |
| 8 | + if ( version_compare( $wgVersion, '1.16', '<' ) ) { |
| 9 | + wfLoadExtensionMessages( 'AdManager' ); |
| 10 | + } |
| 11 | + } |
| 12 | + |
| 13 | + function execute( $query ) { |
| 14 | + global $wgUser, $wgOut, $wgDBprefix; |
| 15 | + if ( ! $wgUser->isAllowed( 'admanager' ) ) { |
| 16 | + $wgOut->permissionRequired( 'admanager' ); |
| 17 | + return; |
| 18 | + } |
| 19 | + |
| 20 | + $this->setHeaders(); |
| 21 | + if ( method_exists( $wgOut, 'addModuleStyles' ) && |
| 22 | + !is_null( $wgOut->getResourceLoader()->getModule( 'mediawiki.special' ) ) ) { |
| 23 | + $wgOut->addModuleStyles( 'mediawiki.special' ); |
| 24 | + } |
| 25 | + |
| 26 | + $fullTableName = $wgDBprefix . AD_ZONES_TABLE; |
| 27 | + $dbr = wfGetDB( DB_SLAVE ); |
| 28 | + if ( AdManagerUtils::checkForAndDisplayError( $dbr->tableExists( $fullTableName ), 'admanager_notable' ) ) { |
| 29 | + return; |
| 30 | + } |
| 31 | + |
| 32 | + $this->doSpecialAdManagerZones(); |
| 33 | + } |
| 34 | + |
| 35 | + function doSpecialAdManagerZones() { |
| 36 | + global $wgRequest; |
| 37 | + $errors = array(); |
| 38 | + |
| 39 | + if ( $wgRequest->getCheck( 'submitted' ) ) { |
| 40 | + $this->zones = explode( "\n", trim( $wgRequest->getVal( 'zones' ) ) ); |
| 41 | + foreach ($this->zones as $zone) { |
| 42 | + $zone = trim( $zone ); |
| 43 | + if ( !is_numeric( $zone ) ) { |
| 44 | + $errors['admanager_zonenotnumber'][] = $zone; |
| 45 | + } |
| 46 | + } |
| 47 | + if ( empty( $errors ) ) { |
| 48 | + $this->addZones(); |
| 49 | + } |
| 50 | + } |
| 51 | + |
| 52 | + $this->showForm( $errors ); |
| 53 | + } |
| 54 | + function addZones() { |
| 55 | + global $wgOut, $wgRequest, $wgDBprefix; |
| 56 | + |
| 57 | + $zones = $this->zones; |
| 58 | + |
| 59 | + $dbw = wfGetDB( DB_MASTER ); |
| 60 | + $fullTableName = $wgDBprefix . AD_ZONES_TABLE; |
| 61 | + |
| 62 | + $dbw->delete( $fullTableName, '*'); |
| 63 | + $text = "<div class=\"successbox\">\n"; |
| 64 | + foreach ( $zones as $zone ) { |
| 65 | + if ( $zone ) { |
| 66 | + $dbw->insert( |
| 67 | + $fullTableName, array( 'ad_zone_id' => $zone ) |
| 68 | + ); |
| 69 | + $text .= "* " . wfmsg('admanager_addedzone') . " $zone"; |
| 70 | + } |
| 71 | + } |
| 72 | + $text .= "</div><br clear=\"both\" />"; |
| 73 | + $wgOut->addWikiText( $text ); |
| 74 | + } |
| 75 | + |
| 76 | + function showForm( array $errors ) { |
| 77 | + global $wgOut, $wgDBprefix; |
| 78 | + |
| 79 | + if ( empty( $errors ) ) { |
| 80 | + $wgOut->addWikiMsg( 'admanagerzones_docu' ); |
| 81 | + } else { |
| 82 | + $text = "<div class=\"errorbox\">\n"; |
| 83 | + foreach ( $errors as $message => $pageTitles ) { |
| 84 | + foreach ( $pageTitles as $pageTitle) { |
| 85 | + $text .= wfMsg( $message, $pageTitle ) . "<br />"; |
| 86 | + } |
| 87 | + } |
| 88 | + $text .= "</div><br clear=\"both\" />"; |
| 89 | + $wgOut->addWikiText( $text ); |
| 90 | + } |
| 91 | + |
| 92 | + $fullTableName = $wgDBprefix . AD_ZONES_TABLE; |
| 93 | + $dbr = wfGetDB( DB_SLAVE ); |
| 94 | + $current = $dbr->select( |
| 95 | + $fullTableName, |
| 96 | + array( '*' ) |
| 97 | + ); |
| 98 | + |
| 99 | + //Fetch current table into array |
| 100 | + $currentArray = Array(); |
| 101 | + while ( $currentRow = $current->fetchObject() ) { |
| 102 | + $currentArray[] = $currentRow->ad_zone_id; |
| 103 | + } |
| 104 | + |
| 105 | + $display = ''; |
| 106 | + foreach ($currentArray as $zone) { |
| 107 | + $display .= "$zone\n"; |
| 108 | + } |
| 109 | + |
| 110 | + $text = Xml::openElement( 'form', array( 'id' => 'admanagerzones', 'action' => $this->getTitle()->getFullUrl(), 'method' => 'post' ) ) . "\n" . |
| 111 | + AdManagerUtils::hiddenField( 'title', $this->getTitle()->getPrefixedText() ) . |
| 112 | + AdManagerUtils::hiddenField( 'submitted', 1 ); |
| 113 | + $text .= Xml::textarea( 'zones' , $display, 25, 20, array( 'style' => 'width: auto; margin-bottom: 1em;' ) ); |
| 114 | + $text .= Xml::element('br'); |
| 115 | + $text .= Xml::submitButton( wfMsg( 'admanager_submit' ) ); |
| 116 | + $text .= Xml::closeElement( 'form' ); |
| 117 | + $text .= Xml::element('br'); |
| 118 | + |
| 119 | + $wgOut->addHTML( $text ); |
| 120 | + |
| 121 | + $wgOut->addWikiMsg( 'admanager_gotoads' ); |
| 122 | + } |
123 | 123 | } |
\ No newline at end of file |
Property changes on: trunk/extensions/AdManager/SpecialAdManagerZones.php |
___________________________________________________________________ |
Added: svn:eol-style |
124 | 124 | + native |
Index: trunk/extensions/AdManager/SpecialAdManager.php |
— | — | @@ -1,226 +1,226 @@ |
2 | | -<?php
|
3 | | -class SpecialAdManager extends SpecialPage {
|
4 | | - const NUM_BLANK_ROWS = 5;
|
5 | | - const BLANK = '----';
|
6 | | -
|
7 | | - function __construct() {
|
8 | | - global $wgVersion;
|
9 | | - parent::__construct( 'AdManager' );
|
10 | | - if ( version_compare( $wgVersion, '1.16', '<' ) ) {
|
11 | | - wfLoadExtensionMessages( 'AdManager' );
|
12 | | - }
|
13 | | - }
|
14 | | -
|
15 | | - function execute( $query ) {
|
16 | | - global $wgUser, $wgOut, $wgDBprefix;
|
17 | | -
|
18 | | - if ( ! $wgUser->isAllowed( 'admanager' ) ) {
|
19 | | - $wgOut->permissionRequired( 'admanager' );
|
20 | | - return;
|
21 | | - }
|
22 | | -
|
23 | | - $this->setHeaders();
|
24 | | - if ( method_exists( $wgOut, 'addModuleStyles' ) &&
|
25 | | - !is_null( $wgOut->getResourceLoader()->getModule( 'mediawiki.special' ) ) ) {
|
26 | | - $wgOut->addModuleStyles( 'mediawiki.special' );
|
27 | | - }
|
28 | | -
|
29 | | - $dbr = wfGetDB( DB_SLAVE );
|
30 | | - $fullTableName = $wgDBprefix . AD_TABLE;
|
31 | | - $fullTableNameZones = $wgDBprefix . AD_ZONES_TABLE;
|
32 | | - if ( AdManagerUtils::checkForAndDisplayError( $dbr->tableExists( $fullTableName ) && $dbr->tableExists( $fullTableNameZones ), 'admanager_notable' ) ) {
|
33 | | - return;
|
34 | | - }
|
35 | | -
|
36 | | -
|
37 | | - $currentZones = $dbr->select(
|
38 | | - $fullTableNameZones,
|
39 | | - array( '*' )
|
40 | | - );
|
41 | | - if ( AdManagerUtils::checkForAndDisplayError( $currentZones->numRows() > 0 , 'admanager_noAdManagerZones' ) ) {
|
42 | | - return;
|
43 | | - }
|
44 | | - //Fetch current zones table into array
|
45 | | - $this->adManagerZones = Array();
|
46 | | - while ( $currentRow = $currentZones->fetchObject() ) {
|
47 | | - $this->adManagerZones[] = $currentRow->ad_zone_id;
|
48 | | - }
|
49 | | -
|
50 | | - $this->adManagerZones[] = wfmsg('admanager_noads');
|
51 | | -
|
52 | | - $this->doSpecialAdManager();
|
53 | | - }
|
54 | | -
|
55 | | - function doSpecialAdManager() {
|
56 | | - global $wgRequest;
|
57 | | - $errors = array();
|
58 | | -
|
59 | | - $this->target['Page'] = array();
|
60 | | - $this->target['Category'] = array();
|
61 | | - if ( $wgRequest->getCheck( 'submitted' ) ) {
|
62 | | - //Load user input and do error checking
|
63 | | - $tableTypes = array ('Page', 'Category');
|
64 | | - foreach ( $this->adManagerZones as $zone ) {
|
65 | | - foreach ( $tableTypes as $tableType ) {
|
66 | | - $titles = explode( "\n", trim( $wgRequest->getVal( "textarea_{$zone}_{$tableType}" ) ) );
|
67 | | -
|
68 | | - foreach ($titles as $title) {
|
69 | | - $title = trim( $title );
|
70 | | - if ( !$title ) continue;
|
71 | | -
|
72 | | - /*if ( $zone == wfmsg('admanager_noads') ) {
|
73 | | - continue;
|
74 | | - }*/
|
75 | | -
|
76 | | - if ( $tableType == 'Page' ) {
|
77 | | - $pageObject = Title::newFromText( trim($title) );
|
78 | | - if ( !$pageObject->exists() ) {
|
79 | | - $errors['admanager_invalidtargetpage'][] = $title;
|
80 | | - }
|
81 | | - else {
|
82 | | - $this->target['Page'][$zone][] = $title;
|
83 | | - }
|
84 | | - }
|
85 | | - else {
|
86 | | - $categoryObject = Category::newFromName( $title );
|
87 | | - if ( !$categoryObject->getID() ) {
|
88 | | - $errors['admanager_invalidtargetcategory'][] = $title;
|
89 | | - }
|
90 | | - else {
|
91 | | - $this->target['Category'][$zone][] = $title;
|
92 | | - }
|
93 | | - }
|
94 | | - }
|
95 | | - }
|
96 | | - }
|
97 | | - if ( empty( $errors ) ) {
|
98 | | - $this->addZoneToTitle();
|
99 | | - return;
|
100 | | - }
|
101 | | - }
|
102 | | - $this->showForm( $errors );
|
103 | | - }
|
104 | | -
|
105 | | - function addZoneToTitle() {
|
106 | | - global $wgOut, $wgDBprefix;
|
107 | | -
|
108 | | - $dbw = wfGetDB( DB_MASTER );
|
109 | | - $fullTableName = $wgDBprefix . AD_TABLE;
|
110 | | -
|
111 | | - $dbw->delete( $fullTableName, '*');
|
112 | | -
|
113 | | - $tableTypes = array ('Page', 'Category');
|
114 | | - foreach ( $tableTypes as $tableType ) {
|
115 | | - foreach ( $this->target[$tableType] as $targetZoneID => $titlesArray ) {
|
116 | | - if ( $targetZoneID == wfmsg('admanager_noads') ) {
|
117 | | - $targetZoneID = "NULL";
|
118 | | - }
|
119 | | - foreach ( $titlesArray as $title ) {
|
120 | | - //Depending on fields being processed, lookup either the text's Page ID or Category ID
|
121 | | - $targetPageID = ( $tableType == 'Page' ? Title::newFromText( $title )->getArticleID() : Category::newFromName( $title )->getID() );
|
122 | | - $dbw->insert(
|
123 | | - $fullTableName, array( 'ad_page_id' => $targetPageID, 'ad_zone' => $targetZoneID, 'ad_page_is_category' => ( $tableType == 'Category' ? TRUE : FALSE ) )
|
124 | | - );
|
125 | | - }
|
126 | | - }
|
127 | | - }
|
128 | | - $wgOut->wrapWikiMsg( "<div class=\"successbox\" style=\"margin-right:3em;\">$1</div>", 'admanager_added' );
|
129 | | - $wgOut->addWikiText( "<br clear=\"both\" />" . wfmsg('admanager_return') );
|
130 | | - }
|
131 | | -
|
132 | | - function showForm( array $errors ) {
|
133 | | - global $wgOut, $wgRequest;
|
134 | | -
|
135 | | - if ( empty( $errors ) ) {
|
136 | | - $wgOut->addWikiMsg( 'admanager_docu' );
|
137 | | - } else {
|
138 | | - $text = "<div class=\"errorbox\">\n";
|
139 | | - foreach ( $errors as $message => $pageTitles ) {
|
140 | | - foreach ( $pageTitles as $pageTitle) {
|
141 | | - $text .= wfMsg( $message, $pageTitle ) . "<br />";
|
142 | | - }
|
143 | | - }
|
144 | | - $text .= "</div><br clear=\"both\" />";
|
145 | | - $wgOut->addWikiText( $text );
|
146 | | - }
|
147 | | -
|
148 | | - $text = Xml::openElement( 'form', array( 'id' => 'admanager', 'action' => $this->getTitle()->getFullUrl(), 'method' => 'post' ) ) . "\n" .
|
149 | | - AdManagerUtils::hiddenField( 'title', $this->getTitle()->getPrefixedText() ) .
|
150 | | - AdManagerUtils::hiddenField( 'submitted', 1 );
|
151 | | -
|
152 | | - $this->currentData['Page'] = $this->getCurrentData('Page');
|
153 | | - $this->currentData['Category'] = $this->getCurrentData('Category');
|
154 | | -
|
155 | | - foreach ( $this->adManagerZones as $zone ) {
|
156 | | - $text .= '<h2> ' . wfMsg( 'admanager_zonenum' ) . " $zone" . " </h2>";
|
157 | | - $text .= '<div style = "float:left; margin-right: 6em;">';
|
158 | | - $text .= $this->drawTable('Page', $zone);
|
159 | | - $text .= '</div><div style="float: left;">';
|
160 | | - $text .= $this->drawTable('Category', $zone);
|
161 | | - $text .= '</div> <br clear="all">';
|
162 | | - }
|
163 | | - $text .= Xml::element('br');
|
164 | | - $text .= Xml::submitButton( wfMsg( 'admanager_submit' ) );
|
165 | | - $text .= Xml::closeElement( 'form' );
|
166 | | - $text .= Xml::element('br');
|
167 | | - $wgOut->addHTML( $text );
|
168 | | -
|
169 | | -
|
170 | | - $wgOut->addWikiMsg( 'admanager_gotozones' );
|
171 | | - }
|
172 | | -
|
173 | | - function getCurrentData ( $tableType ) {
|
174 | | - global $wgDBprefix;
|
175 | | -
|
176 | | - $fullTableName = $wgDBprefix . AD_TABLE;
|
177 | | - $dbr = wfGetDB( DB_SLAVE );
|
178 | | - $current = $dbr->select(
|
179 | | - $fullTableName,
|
180 | | - array( 'ad_id', 'ad_page_id', 'ad_zone', 'ad_page_is_category' ),
|
181 | | - 'ad_page_is_category IS '. ( $tableType == 'Page' ? 'NOT ' : '' ) . 'TRUE'
|
182 | | - );
|
183 | | -
|
184 | | - //Fetch current table into array
|
185 | | - $currentArray = Array();
|
186 | | - while ( $currentRow = $current->fetchObject() ) {
|
187 | | - $currentArray[] = array(
|
188 | | - //Depending on if we're fetching pages or categories, match the ID to the appropriate Title
|
189 | | - 'ad_page_name' => ( $tableType == 'Page' ? Title::newFromID($currentRow->ad_page_id)->getFullText() : Category::newFromID( $currentRow->ad_page_id )->getName() ),
|
190 | | - 'ad_zone' => $currentRow->ad_zone
|
191 | | - );
|
192 | | - }
|
193 | | -
|
194 | | - return $currentArray;
|
195 | | - }
|
196 | | -
|
197 | | - function drawTable ($tableType, $currentZone) {
|
198 | | - global $wgRequest;
|
199 | | -
|
200 | | - $page_label = wfMsg( "admanager_label$tableType" );
|
201 | | -
|
202 | | - $text = <<<END
|
203 | | - <table id="table$tableType">
|
204 | | - <tr>
|
205 | | - <th>$page_label</th>
|
206 | | - </tr>
|
207 | | -
|
208 | | -END;
|
209 | | -
|
210 | | - $display = '';
|
211 | | - if ( $wgRequest->getCheck( 'submitted' ) ) {
|
212 | | - $display = $wgRequest->getVal( "textarea_{$currentZone}_{$tableType}" );
|
213 | | - }
|
214 | | - else {
|
215 | | - foreach ( $this->currentData[$tableType] as $entry ) {
|
216 | | - if ( $entry['ad_zone'] == $currentZone ) {
|
217 | | - $display .= $entry['ad_page_name']. "\n";
|
218 | | - }
|
219 | | - }
|
220 | | - }
|
221 | | -
|
222 | | - $text .= '<tr><td>' . Xml::textarea( "textarea_{$currentZone}_{$tableType}" , $display, 30, 12, array( 'style' => 'width: auto;' ) );
|
223 | | - $text .= '</td></tr></table>';
|
224 | | -
|
225 | | - return $text;
|
226 | | - }
|
| 2 | +<?php |
| 3 | +class SpecialAdManager extends SpecialPage { |
| 4 | + const NUM_BLANK_ROWS = 5; |
| 5 | + const BLANK = '----'; |
| 6 | + |
| 7 | + function __construct() { |
| 8 | + global $wgVersion; |
| 9 | + parent::__construct( 'AdManager' ); |
| 10 | + if ( version_compare( $wgVersion, '1.16', '<' ) ) { |
| 11 | + wfLoadExtensionMessages( 'AdManager' ); |
| 12 | + } |
| 13 | + } |
| 14 | + |
| 15 | + function execute( $query ) { |
| 16 | + global $wgUser, $wgOut, $wgDBprefix; |
| 17 | + |
| 18 | + if ( ! $wgUser->isAllowed( 'admanager' ) ) { |
| 19 | + $wgOut->permissionRequired( 'admanager' ); |
| 20 | + return; |
| 21 | + } |
| 22 | + |
| 23 | + $this->setHeaders(); |
| 24 | + if ( method_exists( $wgOut, 'addModuleStyles' ) && |
| 25 | + !is_null( $wgOut->getResourceLoader()->getModule( 'mediawiki.special' ) ) ) { |
| 26 | + $wgOut->addModuleStyles( 'mediawiki.special' ); |
| 27 | + } |
| 28 | + |
| 29 | + $dbr = wfGetDB( DB_SLAVE ); |
| 30 | + $fullTableName = $wgDBprefix . AD_TABLE; |
| 31 | + $fullTableNameZones = $wgDBprefix . AD_ZONES_TABLE; |
| 32 | + if ( AdManagerUtils::checkForAndDisplayError( $dbr->tableExists( $fullTableName ) && $dbr->tableExists( $fullTableNameZones ), 'admanager_notable' ) ) { |
| 33 | + return; |
| 34 | + } |
| 35 | + |
| 36 | + |
| 37 | + $currentZones = $dbr->select( |
| 38 | + $fullTableNameZones, |
| 39 | + array( '*' ) |
| 40 | + ); |
| 41 | + if ( AdManagerUtils::checkForAndDisplayError( $currentZones->numRows() > 0 , 'admanager_noAdManagerZones' ) ) { |
| 42 | + return; |
| 43 | + } |
| 44 | + //Fetch current zones table into array |
| 45 | + $this->adManagerZones = Array(); |
| 46 | + while ( $currentRow = $currentZones->fetchObject() ) { |
| 47 | + $this->adManagerZones[] = $currentRow->ad_zone_id; |
| 48 | + } |
| 49 | + |
| 50 | + $this->adManagerZones[] = wfmsg('admanager_noads'); |
| 51 | + |
| 52 | + $this->doSpecialAdManager(); |
| 53 | + } |
| 54 | + |
| 55 | + function doSpecialAdManager() { |
| 56 | + global $wgRequest; |
| 57 | + $errors = array(); |
| 58 | + |
| 59 | + $this->target['Page'] = array(); |
| 60 | + $this->target['Category'] = array(); |
| 61 | + if ( $wgRequest->getCheck( 'submitted' ) ) { |
| 62 | + //Load user input and do error checking |
| 63 | + $tableTypes = array ('Page', 'Category'); |
| 64 | + foreach ( $this->adManagerZones as $zone ) { |
| 65 | + foreach ( $tableTypes as $tableType ) { |
| 66 | + $titles = explode( "\n", trim( $wgRequest->getVal( "textarea_{$zone}_{$tableType}" ) ) ); |
| 67 | + |
| 68 | + foreach ($titles as $title) { |
| 69 | + $title = trim( $title ); |
| 70 | + if ( !$title ) continue; |
| 71 | + |
| 72 | + /*if ( $zone == wfmsg('admanager_noads') ) { |
| 73 | + continue; |
| 74 | + }*/ |
| 75 | + |
| 76 | + if ( $tableType == 'Page' ) { |
| 77 | + $pageObject = Title::newFromText( trim($title) ); |
| 78 | + if ( !$pageObject->exists() ) { |
| 79 | + $errors['admanager_invalidtargetpage'][] = $title; |
| 80 | + } |
| 81 | + else { |
| 82 | + $this->target['Page'][$zone][] = $title; |
| 83 | + } |
| 84 | + } |
| 85 | + else { |
| 86 | + $categoryObject = Category::newFromName( $title ); |
| 87 | + if ( !$categoryObject->getID() ) { |
| 88 | + $errors['admanager_invalidtargetcategory'][] = $title; |
| 89 | + } |
| 90 | + else { |
| 91 | + $this->target['Category'][$zone][] = $title; |
| 92 | + } |
| 93 | + } |
| 94 | + } |
| 95 | + } |
| 96 | + } |
| 97 | + if ( empty( $errors ) ) { |
| 98 | + $this->addZoneToTitle(); |
| 99 | + return; |
| 100 | + } |
| 101 | + } |
| 102 | + $this->showForm( $errors ); |
| 103 | + } |
| 104 | + |
| 105 | + function addZoneToTitle() { |
| 106 | + global $wgOut, $wgDBprefix; |
| 107 | + |
| 108 | + $dbw = wfGetDB( DB_MASTER ); |
| 109 | + $fullTableName = $wgDBprefix . AD_TABLE; |
| 110 | + |
| 111 | + $dbw->delete( $fullTableName, '*'); |
| 112 | + |
| 113 | + $tableTypes = array ('Page', 'Category'); |
| 114 | + foreach ( $tableTypes as $tableType ) { |
| 115 | + foreach ( $this->target[$tableType] as $targetZoneID => $titlesArray ) { |
| 116 | + if ( $targetZoneID == wfmsg('admanager_noads') ) { |
| 117 | + $targetZoneID = "NULL"; |
| 118 | + } |
| 119 | + foreach ( $titlesArray as $title ) { |
| 120 | + //Depending on fields being processed, lookup either the text's Page ID or Category ID |
| 121 | + $targetPageID = ( $tableType == 'Page' ? Title::newFromText( $title )->getArticleID() : Category::newFromName( $title )->getID() ); |
| 122 | + $dbw->insert( |
| 123 | + $fullTableName, array( 'ad_page_id' => $targetPageID, 'ad_zone' => $targetZoneID, 'ad_page_is_category' => ( $tableType == 'Category' ? TRUE : FALSE ) ) |
| 124 | + ); |
| 125 | + } |
| 126 | + } |
| 127 | + } |
| 128 | + $wgOut->wrapWikiMsg( "<div class=\"successbox\" style=\"margin-right:3em;\">$1</div>", 'admanager_added' ); |
| 129 | + $wgOut->addWikiText( "<br clear=\"both\" />" . wfmsg('admanager_return') ); |
| 130 | + } |
| 131 | + |
| 132 | + function showForm( array $errors ) { |
| 133 | + global $wgOut, $wgRequest; |
| 134 | + |
| 135 | + if ( empty( $errors ) ) { |
| 136 | + $wgOut->addWikiMsg( 'admanager_docu' ); |
| 137 | + } else { |
| 138 | + $text = "<div class=\"errorbox\">\n"; |
| 139 | + foreach ( $errors as $message => $pageTitles ) { |
| 140 | + foreach ( $pageTitles as $pageTitle) { |
| 141 | + $text .= wfMsg( $message, $pageTitle ) . "<br />"; |
| 142 | + } |
| 143 | + } |
| 144 | + $text .= "</div><br clear=\"both\" />"; |
| 145 | + $wgOut->addWikiText( $text ); |
| 146 | + } |
| 147 | + |
| 148 | + $text = Xml::openElement( 'form', array( 'id' => 'admanager', 'action' => $this->getTitle()->getFullUrl(), 'method' => 'post' ) ) . "\n" . |
| 149 | + AdManagerUtils::hiddenField( 'title', $this->getTitle()->getPrefixedText() ) . |
| 150 | + AdManagerUtils::hiddenField( 'submitted', 1 ); |
| 151 | + |
| 152 | + $this->currentData['Page'] = $this->getCurrentData('Page'); |
| 153 | + $this->currentData['Category'] = $this->getCurrentData('Category'); |
| 154 | + |
| 155 | + foreach ( $this->adManagerZones as $zone ) { |
| 156 | + $text .= '<h2> ' . wfMsg( 'admanager_zonenum' ) . " $zone" . " </h2>"; |
| 157 | + $text .= '<div style = "float:left; margin-right: 6em;">'; |
| 158 | + $text .= $this->drawTable('Page', $zone); |
| 159 | + $text .= '</div><div style="float: left;">'; |
| 160 | + $text .= $this->drawTable('Category', $zone); |
| 161 | + $text .= '</div> <br clear="all">'; |
| 162 | + } |
| 163 | + $text .= Xml::element('br'); |
| 164 | + $text .= Xml::submitButton( wfMsg( 'admanager_submit' ) ); |
| 165 | + $text .= Xml::closeElement( 'form' ); |
| 166 | + $text .= Xml::element('br'); |
| 167 | + $wgOut->addHTML( $text ); |
| 168 | + |
| 169 | + |
| 170 | + $wgOut->addWikiMsg( 'admanager_gotozones' ); |
| 171 | + } |
| 172 | + |
| 173 | + function getCurrentData ( $tableType ) { |
| 174 | + global $wgDBprefix; |
| 175 | + |
| 176 | + $fullTableName = $wgDBprefix . AD_TABLE; |
| 177 | + $dbr = wfGetDB( DB_SLAVE ); |
| 178 | + $current = $dbr->select( |
| 179 | + $fullTableName, |
| 180 | + array( 'ad_id', 'ad_page_id', 'ad_zone', 'ad_page_is_category' ), |
| 181 | + 'ad_page_is_category IS '. ( $tableType == 'Page' ? 'NOT ' : '' ) . 'TRUE' |
| 182 | + ); |
| 183 | + |
| 184 | + //Fetch current table into array |
| 185 | + $currentArray = Array(); |
| 186 | + while ( $currentRow = $current->fetchObject() ) { |
| 187 | + $currentArray[] = array( |
| 188 | + //Depending on if we're fetching pages or categories, match the ID to the appropriate Title |
| 189 | + 'ad_page_name' => ( $tableType == 'Page' ? Title::newFromID($currentRow->ad_page_id)->getFullText() : Category::newFromID( $currentRow->ad_page_id )->getName() ), |
| 190 | + 'ad_zone' => $currentRow->ad_zone |
| 191 | + ); |
| 192 | + } |
| 193 | + |
| 194 | + return $currentArray; |
| 195 | + } |
| 196 | + |
| 197 | + function drawTable ($tableType, $currentZone) { |
| 198 | + global $wgRequest; |
| 199 | + |
| 200 | + $page_label = wfMsg( "admanager_label$tableType" ); |
| 201 | + |
| 202 | + $text = <<<END |
| 203 | + <table id="table$tableType"> |
| 204 | + <tr> |
| 205 | + <th>$page_label</th> |
| 206 | + </tr> |
| 207 | + |
| 208 | +END; |
| 209 | + |
| 210 | + $display = ''; |
| 211 | + if ( $wgRequest->getCheck( 'submitted' ) ) { |
| 212 | + $display = $wgRequest->getVal( "textarea_{$currentZone}_{$tableType}" ); |
| 213 | + } |
| 214 | + else { |
| 215 | + foreach ( $this->currentData[$tableType] as $entry ) { |
| 216 | + if ( $entry['ad_zone'] == $currentZone ) { |
| 217 | + $display .= $entry['ad_page_name']. "\n"; |
| 218 | + } |
| 219 | + } |
| 220 | + } |
| 221 | + |
| 222 | + $text .= '<tr><td>' . Xml::textarea( "textarea_{$currentZone}_{$tableType}" , $display, 30, 12, array( 'style' => 'width: auto;' ) ); |
| 223 | + $text .= '</td></tr></table>'; |
| 224 | + |
| 225 | + return $text; |
| 226 | + } |
227 | 227 | } |
\ No newline at end of file |
Property changes on: trunk/extensions/AdManager/SpecialAdManager.php |
___________________________________________________________________ |
Added: svn:eol-style |
228 | 228 | + native |
Index: trunk/extensions/AdManager/AdManager.hooks.php |
— | — | @@ -1,193 +1,193 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -final class AdManagerHooks {
|
5 | | -
|
6 | | - static $catList = Array();
|
7 | | -
|
8 | | - /**
|
9 | | - * Schema update to set up the needed database tables.
|
10 | | - */
|
11 | | - public static function onSchemaUpdate( /* DatabaseUpdater */ $updater = null ) {
|
12 | | - global $wgDBtype;
|
13 | | -
|
14 | | - if ( $wgDBtype == 'mysql' ) {
|
15 | | - // Set up the current schema.
|
16 | | - if ( $updater === null ) {
|
17 | | - // <= 1.16 support
|
18 | | - global $wgExtNewTables, $wgExtNewIndexes;
|
19 | | -
|
20 | | - $wgExtNewTables[] = array(
|
21 | | - AD_TABLE,
|
22 | | - dirname( __FILE__ ) . '/AdManager.sql',
|
23 | | - true
|
24 | | - );
|
25 | | -
|
26 | | - $wgExtNewTables[] = array(
|
27 | | - AD_ZONE_TABLE,
|
28 | | - dirname( __FILE__ ) . '/AdManager.sql',
|
29 | | - true
|
30 | | - );
|
31 | | -
|
32 | | - /*TODO: Do we need an index?*/
|
33 | | - }
|
34 | | - else {
|
35 | | - // >= 1.17 support
|
36 | | - $updater->addExtensionUpdate( array(
|
37 | | - 'addTable',
|
38 | | - AD_TABLE,
|
39 | | - dirname( __FILE__ ) . '/AdManager.sql',
|
40 | | - true
|
41 | | - ) );
|
42 | | - $updater->addExtensionUpdate( array(
|
43 | | - 'addTable',
|
44 | | - AD_ZONE_TABLE,
|
45 | | - dirname( __FILE__ ) . '/AdManager.sql',
|
46 | | - true
|
47 | | - ) );
|
48 | | - }
|
49 | | -
|
50 | | - }
|
51 | | -
|
52 | | - return true;
|
53 | | - }
|
54 | | -
|
55 | | - //Recursively walks through tree array. Creates array containing each input's level. (array_walk_recursive doesn't like when the value is an array)
|
56 | | - //A lower count indicates a closer ancestor to the page, that is supercategories are assigned higher numbers than subcategories
|
57 | | - private static function assignLevel($value, $catName, $count = 0) {
|
58 | | - $count++;
|
59 | | -
|
60 | | - if(!empty($value)) {
|
61 | | - array_walk ( $value , 'self::assignLevel', $count);
|
62 | | -
|
63 | | - }
|
64 | | - self::$catList[$catName] = $count;
|
65 | | - }
|
66 | | -
|
67 | | - //Pop some ads at the bottom of the sidebar
|
68 | | - public static function SkinBuildSidebar( $skin, &$sidebar ) {
|
69 | | - global $wgOut, $wgDBprefix, $wgTitle, $wgAdManagerService, $wgAdManagerCode;
|
70 | | -
|
71 | | - $fullTableName = $wgDBprefix . AD_TABLE;
|
72 | | - $dbr = wfGetDB( DB_SLAVE );
|
73 | | - if ( !$dbr->tableExists( $fullTableName ) ) {
|
74 | | - return $sidebar;
|
75 | | - }
|
76 | | -
|
77 | | - //check if an ad zone was set for this page.
|
78 | | - $thisPageID = $wgTitle->getArticleID();
|
79 | | - $thisPageAdZonesDB = $dbr->select(
|
80 | | - $fullTableName,
|
81 | | - array( 'ad_zone' ),
|
82 | | - "ad_page_id = $thisPageID AND ad_page_is_category IS NOT TRUE"
|
83 | | - );
|
84 | | -
|
85 | | - $thisPageAdZones = array();
|
86 | | - if ( $thisPageAdZonesDB->numRows() !== 0 ) { //If there's a page zone set, it gets precedence.
|
87 | | - while ( $row = $thisPageAdZonesDB->fetchObject() ) {
|
88 | | - $thisPageAdZones[] = $row->ad_zone;
|
89 | | - }
|
90 | | - }
|
91 | | - else {
|
92 | | - //check if an ad zone was set for any of this page's categories
|
93 | | - $allCategories = $dbr->select(
|
94 | | - $fullTableName,
|
95 | | - array( 'ad_page_id', 'ad_zone' ),
|
96 | | - "ad_page_is_category IS TRUE"
|
97 | | - );
|
98 | | -
|
99 | | - $thisCategoryIDS = $wgTitle->getParentCategoryTree();
|
100 | | - array_walk ( $thisCategoryIDS , 'self::assignLevel' );
|
101 | | - asort ( self::$catList ); //give precedence to the closest ancestors
|
102 | | -
|
103 | | - if ( !empty(self::$catList) ) {
|
104 | | - //find first match in this page's catlist that exists in the database
|
105 | | - foreach (self::$catList as $catName => $level) {
|
106 | | - $catName = substr($catName, 9); //strips Category: prefix
|
107 | | - $catID = Category::newFromName($catName)->getID();
|
108 | | - $firstMatch = $dbr->select(
|
109 | | - $fullTableName,
|
110 | | - array( 'ad_zone' ),
|
111 | | - "ad_page_id = $catID AND ad_page_is_category IS TRUE"
|
112 | | - );
|
113 | | - if ($firstMatch->numRows() !== 0) {
|
114 | | - break;
|
115 | | - }
|
116 | | - }
|
117 | | -
|
118 | | - while ( $row = $firstMatch->fetchObject() ) {
|
119 | | - $thisPageAdZones[] = $row->ad_zone;
|
120 | | - }
|
121 | | - }
|
122 | | - }
|
123 | | -
|
124 | | - //And finally, pop those ads in
|
125 | | - if ( empty( $thisPageAdZones ) ) { //No zone set for this page or its categories
|
126 | | - return true;
|
127 | | - }
|
128 | | -
|
129 | | - if ( in_array( null, $thisPageAdZones ) ) { //An entry in this array was set to "None" so show no ads
|
130 | | - return true;
|
131 | | - }
|
132 | | -
|
133 | | - if ( $wgAdManagerService == 'openx' ) {
|
134 | | - $wgAdManagerCode = "<a href='http://d1.openx.org/ck.php?cb=91238047' target='_blank'><img src='http://d1.openx.org/avw.php?zoneid=$1&cb=1378957897235' border='0' alt='' /></a>";
|
135 | | - }
|
136 | | -
|
137 | | - if ( $wgAdManagerService == 'banman' ) {
|
138 | | - $wgAdManagerCode = <<<END
|
139 | | - <!-- Begin - Site: AAO Zone: /eyewiki -->
|
140 | | - <script language="javascript" type="text/javascript">
|
141 | | - <!--
|
142 | | - var browName = navigator.appName;
|
143 | | - var SiteID = 1;
|
144 | | - var ZoneID = $1;
|
145 | | - var browDateTime = (new Date()).getTime();
|
146 | | - if (browName=='Netscape')
|
147 | | - {
|
148 | | - document.write('<s'+'cript lang' + 'uage="jav' + 'ascript" src="http://aaoads.enforme.com/a.aspx?ZoneID=' + ZoneID + '&Task=Get&IFR=False&Browser=NETSCAPE4&SiteID=' + SiteID + '&Random=' + browDateTime + '">'); document.write('</'+'scr'+'ipt>');
|
149 | | - }
|
150 | | - if (browName!='Netscape')
|
151 | | - {
|
152 | | - document.write('<s'+'cript lang' + 'uage="jav' + 'ascript" src="http://aaoads.enforme.com/a.aspx?ZoneID=' + ZoneID + '&Task=Get&IFR=False&SiteID=' + SiteID + '&Random=' + browDateTime + '">'); document.write('</'+'scr'+'ipt>');
|
153 | | - }
|
154 | | - // -->
|
155 | | - </script>
|
156 | | - <noscript>
|
157 | | - <a href="http://aaoads.enforme.com/a.aspx?ZoneID=$1&Task=Click&Mode=HTML&SiteID=1" target="_blank">
|
158 | | - <img src="http://aaoads.enforme.com/a.aspx?ZoneID=$1&Task=Get&Mode=HTML&SiteID=1" border="0" alt=""></a>
|
159 | | - </noscript>
|
160 | | - <!-- End - Site: AAO Zone: /eyewiki_0 -->
|
161 | | -END;
|
162 | | - }
|
163 | | -
|
164 | | - //Other ad services can be added here, with the same format as above
|
165 | | -
|
166 | | - if ( !isSet( $wgAdManagerCode ) ) {
|
167 | | - return true; //TODO: show error
|
168 | | - }
|
169 | | -
|
170 | | - //Adds some CSS, but puts it in <body>
|
171 | | - $wgOut->addHTML( <<<EOT
|
172 | | -<style type="text/css">
|
173 | | -div[id*='AdManager'] h5 {
|
174 | | - display: none;
|
175 | | -}
|
176 | | -div[id*='AdManager'] .pBody {
|
177 | | - border: none;
|
178 | | - padding-left: 0;
|
179 | | -}
|
180 | | -</style>
|
181 | | -EOT
|
182 | | - );
|
183 | | -
|
184 | | - $adNumber = 0;
|
185 | | - foreach ( $thisPageAdZones as $thisPageAdZone ) {
|
186 | | - $adNumber++;
|
187 | | - //Allows admins to use any ad service or inclusion code they desire by inserting in LocalSettings
|
188 | | - $out = str_replace( '$1', $thisPageAdZone, $wgAdManagerCode );
|
189 | | - $sidebar["AdManager$adNumber"] = $out;
|
190 | | - }
|
191 | | -
|
192 | | - return true;
|
193 | | - }
|
194 | | -}
|
| 2 | +<?php |
| 3 | + |
| 4 | +final class AdManagerHooks { |
| 5 | + |
| 6 | + static $catList = Array(); |
| 7 | + |
| 8 | + /** |
| 9 | + * Schema update to set up the needed database tables. |
| 10 | + */ |
| 11 | + public static function onSchemaUpdate( /* DatabaseUpdater */ $updater = null ) { |
| 12 | + global $wgDBtype; |
| 13 | + |
| 14 | + if ( $wgDBtype == 'mysql' ) { |
| 15 | + // Set up the current schema. |
| 16 | + if ( $updater === null ) { |
| 17 | + // <= 1.16 support |
| 18 | + global $wgExtNewTables, $wgExtNewIndexes; |
| 19 | + |
| 20 | + $wgExtNewTables[] = array( |
| 21 | + AD_TABLE, |
| 22 | + dirname( __FILE__ ) . '/AdManager.sql', |
| 23 | + true |
| 24 | + ); |
| 25 | + |
| 26 | + $wgExtNewTables[] = array( |
| 27 | + AD_ZONE_TABLE, |
| 28 | + dirname( __FILE__ ) . '/AdManager.sql', |
| 29 | + true |
| 30 | + ); |
| 31 | + |
| 32 | + /*TODO: Do we need an index?*/ |
| 33 | + } |
| 34 | + else { |
| 35 | + // >= 1.17 support |
| 36 | + $updater->addExtensionUpdate( array( |
| 37 | + 'addTable', |
| 38 | + AD_TABLE, |
| 39 | + dirname( __FILE__ ) . '/AdManager.sql', |
| 40 | + true |
| 41 | + ) ); |
| 42 | + $updater->addExtensionUpdate( array( |
| 43 | + 'addTable', |
| 44 | + AD_ZONE_TABLE, |
| 45 | + dirname( __FILE__ ) . '/AdManager.sql', |
| 46 | + true |
| 47 | + ) ); |
| 48 | + } |
| 49 | + |
| 50 | + } |
| 51 | + |
| 52 | + return true; |
| 53 | + } |
| 54 | + |
| 55 | + //Recursively walks through tree array. Creates array containing each input's level. (array_walk_recursive doesn't like when the value is an array) |
| 56 | + //A lower count indicates a closer ancestor to the page, that is supercategories are assigned higher numbers than subcategories |
| 57 | + private static function assignLevel($value, $catName, $count = 0) { |
| 58 | + $count++; |
| 59 | + |
| 60 | + if(!empty($value)) { |
| 61 | + array_walk ( $value , 'self::assignLevel', $count); |
| 62 | + |
| 63 | + } |
| 64 | + self::$catList[$catName] = $count; |
| 65 | + } |
| 66 | + |
| 67 | + //Pop some ads at the bottom of the sidebar |
| 68 | + public static function SkinBuildSidebar( $skin, &$sidebar ) { |
| 69 | + global $wgOut, $wgDBprefix, $wgTitle, $wgAdManagerService, $wgAdManagerCode; |
| 70 | + |
| 71 | + $fullTableName = $wgDBprefix . AD_TABLE; |
| 72 | + $dbr = wfGetDB( DB_SLAVE ); |
| 73 | + if ( !$dbr->tableExists( $fullTableName ) ) { |
| 74 | + return $sidebar; |
| 75 | + } |
| 76 | + |
| 77 | + //check if an ad zone was set for this page. |
| 78 | + $thisPageID = $wgTitle->getArticleID(); |
| 79 | + $thisPageAdZonesDB = $dbr->select( |
| 80 | + $fullTableName, |
| 81 | + array( 'ad_zone' ), |
| 82 | + "ad_page_id = $thisPageID AND ad_page_is_category IS NOT TRUE" |
| 83 | + ); |
| 84 | + |
| 85 | + $thisPageAdZones = array(); |
| 86 | + if ( $thisPageAdZonesDB->numRows() !== 0 ) { //If there's a page zone set, it gets precedence. |
| 87 | + while ( $row = $thisPageAdZonesDB->fetchObject() ) { |
| 88 | + $thisPageAdZones[] = $row->ad_zone; |
| 89 | + } |
| 90 | + } |
| 91 | + else { |
| 92 | + //check if an ad zone was set for any of this page's categories |
| 93 | + $allCategories = $dbr->select( |
| 94 | + $fullTableName, |
| 95 | + array( 'ad_page_id', 'ad_zone' ), |
| 96 | + "ad_page_is_category IS TRUE" |
| 97 | + ); |
| 98 | + |
| 99 | + $thisCategoryIDS = $wgTitle->getParentCategoryTree(); |
| 100 | + array_walk ( $thisCategoryIDS , 'self::assignLevel' ); |
| 101 | + asort ( self::$catList ); //give precedence to the closest ancestors |
| 102 | + |
| 103 | + if ( !empty(self::$catList) ) { |
| 104 | + //find first match in this page's catlist that exists in the database |
| 105 | + foreach (self::$catList as $catName => $level) { |
| 106 | + $catName = substr($catName, 9); //strips Category: prefix |
| 107 | + $catID = Category::newFromName($catName)->getID(); |
| 108 | + $firstMatch = $dbr->select( |
| 109 | + $fullTableName, |
| 110 | + array( 'ad_zone' ), |
| 111 | + "ad_page_id = $catID AND ad_page_is_category IS TRUE" |
| 112 | + ); |
| 113 | + if ($firstMatch->numRows() !== 0) { |
| 114 | + break; |
| 115 | + } |
| 116 | + } |
| 117 | + |
| 118 | + while ( $row = $firstMatch->fetchObject() ) { |
| 119 | + $thisPageAdZones[] = $row->ad_zone; |
| 120 | + } |
| 121 | + } |
| 122 | + } |
| 123 | + |
| 124 | + //And finally, pop those ads in |
| 125 | + if ( empty( $thisPageAdZones ) ) { //No zone set for this page or its categories |
| 126 | + return true; |
| 127 | + } |
| 128 | + |
| 129 | + if ( in_array( null, $thisPageAdZones ) ) { //An entry in this array was set to "None" so show no ads |
| 130 | + return true; |
| 131 | + } |
| 132 | + |
| 133 | + if ( $wgAdManagerService == 'openx' ) { |
| 134 | + $wgAdManagerCode = "<a href='http://d1.openx.org/ck.php?cb=91238047' target='_blank'><img src='http://d1.openx.org/avw.php?zoneid=$1&cb=1378957897235' border='0' alt='' /></a>"; |
| 135 | + } |
| 136 | + |
| 137 | + if ( $wgAdManagerService == 'banman' ) { |
| 138 | + $wgAdManagerCode = <<<END |
| 139 | + <!-- Begin - Site: AAO Zone: /eyewiki --> |
| 140 | + <script language="javascript" type="text/javascript"> |
| 141 | + <!-- |
| 142 | + var browName = navigator.appName; |
| 143 | + var SiteID = 1; |
| 144 | + var ZoneID = $1; |
| 145 | + var browDateTime = (new Date()).getTime(); |
| 146 | + if (browName=='Netscape') |
| 147 | + { |
| 148 | + document.write('<s'+'cript lang' + 'uage="jav' + 'ascript" src="http://aaoads.enforme.com/a.aspx?ZoneID=' + ZoneID + '&Task=Get&IFR=False&Browser=NETSCAPE4&SiteID=' + SiteID + '&Random=' + browDateTime + '">'); document.write('</'+'scr'+'ipt>'); |
| 149 | + } |
| 150 | + if (browName!='Netscape') |
| 151 | + { |
| 152 | + document.write('<s'+'cript lang' + 'uage="jav' + 'ascript" src="http://aaoads.enforme.com/a.aspx?ZoneID=' + ZoneID + '&Task=Get&IFR=False&SiteID=' + SiteID + '&Random=' + browDateTime + '">'); document.write('</'+'scr'+'ipt>'); |
| 153 | + } |
| 154 | + // --> |
| 155 | + </script> |
| 156 | + <noscript> |
| 157 | + <a href="http://aaoads.enforme.com/a.aspx?ZoneID=$1&Task=Click&Mode=HTML&SiteID=1" target="_blank"> |
| 158 | + <img src="http://aaoads.enforme.com/a.aspx?ZoneID=$1&Task=Get&Mode=HTML&SiteID=1" border="0" alt=""></a> |
| 159 | + </noscript> |
| 160 | + <!-- End - Site: AAO Zone: /eyewiki_0 --> |
| 161 | +END; |
| 162 | + } |
| 163 | + |
| 164 | + //Other ad services can be added here, with the same format as above |
| 165 | + |
| 166 | + if ( !isSet( $wgAdManagerCode ) ) { |
| 167 | + return true; //TODO: show error |
| 168 | + } |
| 169 | + |
| 170 | + //Adds some CSS, but puts it in <body> |
| 171 | + $wgOut->addHTML( <<<EOT |
| 172 | +<style type="text/css"> |
| 173 | +div[id*='AdManager'] h5 { |
| 174 | + display: none; |
| 175 | +} |
| 176 | +div[id*='AdManager'] .pBody { |
| 177 | + border: none; |
| 178 | + padding-left: 0; |
| 179 | +} |
| 180 | +</style> |
| 181 | +EOT |
| 182 | + ); |
| 183 | + |
| 184 | + $adNumber = 0; |
| 185 | + foreach ( $thisPageAdZones as $thisPageAdZone ) { |
| 186 | + $adNumber++; |
| 187 | + //Allows admins to use any ad service or inclusion code they desire by inserting in LocalSettings |
| 188 | + $out = str_replace( '$1', $thisPageAdZone, $wgAdManagerCode ); |
| 189 | + $sidebar["AdManager$adNumber"] = $out; |
| 190 | + } |
| 191 | + |
| 192 | + return true; |
| 193 | + } |
| 194 | +} |
Property changes on: trunk/extensions/AdManager/AdManager.hooks.php |
___________________________________________________________________ |
Added: svn:eol-style |
195 | 195 | + native |
Property changes on: trunk/extensions/AdManager/jquery-1.4.2.min.js |
___________________________________________________________________ |
Added: svn:eol-style |
196 | 196 | + native |
Index: trunk/extensions/AdManager/AdManager.sql |
— | — | @@ -1,11 +1,11 @@ |
2 | | -CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/ad (
|
3 | | - ad_id INT unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
4 | | - ad_page_id INT(10) unsigned NOT NULL,
|
5 | | - ad_zone INT(4) unsigned,
|
6 | | - ad_page_is_category BOOLEAN
|
7 | | -) /*$wgDBTableOptions*/;
|
8 | | -
|
9 | | -CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/adzones (
|
10 | | - ad_zone_id INT(4) unsigned NOT NULL PRIMARY KEY
|
| 2 | +-- MySQL version of the database schema for the AdManager extension. |
| 3 | +CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/ad ( |
| 4 | + ad_id INT unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY, |
| 5 | + ad_page_id INT(10) unsigned NOT NULL, |
| 6 | + ad_zone INT(4) unsigned, |
| 7 | + ad_page_is_category BOOLEAN |
| 8 | +) /*$wgDBTableOptions*/; |
| 9 | + |
| 10 | +CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/adzones ( |
| 11 | + ad_zone_id INT(4) unsigned NOT NULL PRIMARY KEY |
11 | 12 | ) /*$wgDBTableOptions*/; |
\ No newline at end of file |
Property changes on: trunk/extensions/AdManager/AdManager.sql |
___________________________________________________________________ |
Added: svn:eol-style |
12 | 13 | + native |
Property changes on: trunk/extensions/PictureGame/picturegame/.picturegame.js.marks |
___________________________________________________________________ |
Added: svn:eol-style |
13 | 14 | + native |
Property changes on: trunk/extensions/DonationInterface/payflowpro_gateway/forms/rapidhtml/html/webitects_1.html |
___________________________________________________________________ |
Added: svn:eol-style |
14 | 15 | + native |
Property changes on: trunk/extensions/DonationInterface/payflowpro_gateway/forms/rapidhtml/html/webitects_1a.html |
___________________________________________________________________ |
Added: svn:eol-style |
15 | 16 | + native |
Property changes on: trunk/extensions/DonationInterface/payflowpro_gateway/forms/rapidhtml/html/webitects_2.html |
___________________________________________________________________ |
Added: svn:eol-style |
16 | 17 | + native |