Index: trunk/extensions/CentralNotice/CentralNotice.php |
— | — | @@ -102,13 +102,13 @@ |
103 | 103 | $dir = dirname( __FILE__ ) . '/'; |
104 | 104 | |
105 | 105 | $wgExtensionMessagesFiles['CentralNotice'] = $dir . 'CentralNotice.i18n.php'; |
| 106 | +$wgExtensionAliasesFiles['CentralNotice'] = $dir . 'CentralNotice.alias.php'; |
106 | 107 | |
107 | 108 | $wgAvailableRights[] = 'centralnotice-admin'; |
108 | 109 | $wgAvailableRights[] = 'centralnotice-translate'; |
109 | 110 | $wgGroupPermissions['sysop']['centralnotice-admin'] = true; // Only sysops can make change |
110 | 111 | $wgGroupPermissions['sysop']['centralnotice-translate'] = true; // Only sysops can make change |
111 | 112 | |
112 | | - |
113 | 113 | function efCentralNoticeSetup() { |
114 | 114 | global $wgHooks, $wgNoticeInfrastructure, $wgAutoloadClasses, $wgSpecialPages; |
115 | 115 | global $wgCentralNoticeLoader; |
Index: trunk/extensions/CentralNotice/SpecialNoticeLocal.php |
— | — | @@ -1,7 +1,6 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | class SpecialNoticeLocal extends NoticePage { |
5 | | - |
6 | 5 | function __construct() { |
7 | 6 | parent::__construct( "NoticeLocal" ); |
8 | 7 | } |
Index: trunk/extensions/CentralNotice/rebuildTemplates.php |
— | — | @@ -16,14 +16,14 @@ |
17 | 17 | // Hack for parser to avoid barfing from no $wgTitle |
18 | 18 | $wgTitle = Title::newFromText( wfMsg( 'mainpage' ) ); |
19 | 19 | |
20 | | - if ( isset( $options['n'] ) ) { |
21 | | - $notice = explode( "/", $args[0] ); |
22 | | - $projects = array( $notice[0] ); |
23 | | - $langs = array( $notice[1] ); |
24 | | - } else { |
25 | | - $projects = $wgNoticeProjects; |
26 | | - $langs = array_keys( Language::getLanguageNames() ); |
27 | | - } |
| 20 | + if ( isset( $options['n'] ) ) { |
| 21 | + $notice = explode( "/", $args[0] ); |
| 22 | + $projects = array( $notice[0] ); |
| 23 | + $langs = array( $notice[1] ); |
| 24 | + } else { |
| 25 | + $projects = $wgNoticeProjects; |
| 26 | + $langs = array_keys( Language::getLanguageNames() ); |
| 27 | + } |
28 | 28 | foreach ( $projects as $project ) { |
29 | 29 | foreach ( $langs as $lang ) { |
30 | 30 | $key = "$project/$lang"; |
— | — | @@ -32,20 +32,20 @@ |
33 | 33 | $builder = new SpecialNoticeText(); |
34 | 34 | $js = $builder->getJsOutput( $key ); |
35 | 35 | |
36 | | - if ( isset( $options['o'] ) ) { |
37 | | - $outputDir = "$wgNoticeCentralDirectory/$project/$lang"; |
38 | | - if ( wfMkDirParents( $outputDir ) ) { |
39 | | - $outputFile = "$outputDir/centralnotice.js"; |
40 | | - $ok = file_put_contents( $outputFile, $js ); |
41 | | - if ( !$ok ) { |
42 | | - echo "FAILED to write $outputFile!\n"; |
43 | | - } |
44 | | - } else { |
45 | | - echo "FAILED to create $outputDir!\n"; |
46 | | - } |
47 | | - } else { |
48 | | - echo $js; |
49 | | - } |
| 36 | + if ( isset( $options['o'] ) ) { |
| 37 | + $outputDir = "$wgNoticeCentralDirectory/$project/$lang"; |
| 38 | + if ( wfMkDirParents( $outputDir ) ) { |
| 39 | + $outputFile = "$outputDir/centralnotice.js"; |
| 40 | + $ok = file_put_contents( $outputFile, $js ); |
| 41 | + if ( !$ok ) { |
| 42 | + echo "FAILED to write $outputFile!\n"; |
| 43 | + } |
| 44 | + } else { |
| 45 | + echo "FAILED to create $outputDir!\n"; |
| 46 | + } |
| 47 | + } else { |
| 48 | + echo $js; |
| 49 | + } |
50 | 50 | } |
51 | 51 | } |
52 | 52 | } |
Index: trunk/extensions/CentralNotice/CentralNotice.i18n.php |
— | — | @@ -1111,7 +1111,7 @@ |
1112 | 1112 | 'centralnotice-weight' => 'Pwys', |
1113 | 1113 | 'centralnotice-locked' => 'Ar glo', |
1114 | 1114 | 'centralnotice-notices' => 'Hysbysiadau', |
1115 | | - 'centralnotice-notice-exists' => "Mae'r hysbysiad eisoes ar gael. |
| 1115 | + 'centralnotice-notice-exists' => "Mae'r hysbysiad eisoes ar gael. |
1116 | 1116 | Ni chaiff ei ychwanegu", |
1117 | 1117 | 'centralnotice-notice-doesnt-exist' => "Nid yw'r hysbysiad ar gael. |
1118 | 1118 | Dim i gael gwared ohono", |
— | — | @@ -1126,7 +1126,7 @@ |
1127 | 1127 | 'centralnotice-start-time' => 'Amser cychwyn (UTC)', |
1128 | 1128 | 'centralnotice-start-hour' => 'Amser dechrau', |
1129 | 1129 | 'centralnotice-weights' => 'Pwysau', |
1130 | | - 'centralnotice-notice-is-locked' => "Mae'r hysbysiad wedi ei gloi. |
| 1130 | + 'centralnotice-notice-is-locked' => "Mae'r hysbysiad wedi ei gloi. |
1131 | 1131 | Ni chaiff ei dynnu i ffwrdd", |
1132 | 1132 | 'centralnotice-no-notices-exist' => 'Does dim hysbysiadau i gael. |
1133 | 1133 | Gallwch ychwanegu un isod.', |
— | — | @@ -1514,7 +1514,7 @@ |
1515 | 1515 | 'centralnotice-no-templates-assigned' => 'Κανένα πρότυπο δεν έχει ανατεθεί σε σημείωση. |
1516 | 1516 | Προσθέστε κάποια!', |
1517 | 1517 | 'centralnotice-available-templates' => 'Διαθέσιμα πρότυπα', |
1518 | | - 'centralnotice-template-already-exists' => 'Το πρότυπο είναι ακόμη συνδεδεμένο με μία καμπάνια. |
| 1518 | + 'centralnotice-template-already-exists' => 'Το πρότυπο είναι ακόμη συνδεδεμένο με μία καμπάνια. |
1519 | 1519 | Δεν έχει προστεθεί', |
1520 | 1520 | 'centralnotice-preview-template' => 'Πρότυπο προεπισκόπησης', |
1521 | 1521 | 'centralnotice-start-hour' => 'Χρόνος εκκίνησης', |
— | — | @@ -1522,7 +1522,7 @@ |
1523 | 1523 | 'centralnotice-weights' => 'Βάρη', |
1524 | 1524 | 'centralnotice-notice-is-locked' => 'Η σημείωση είναι κλειδωμένη. |
1525 | 1525 | Δεν θα αφαιρεθεί', |
1526 | | - 'centralnotice-overlap' => 'Το σημείωμα επικαλύπτεται με τον χρόνο ενός άλλου σημειώματος. |
| 1526 | + 'centralnotice-overlap' => 'Το σημείωμα επικαλύπτεται με τον χρόνο ενός άλλου σημειώματος. |
1527 | 1527 | Δεν έχει προστεθεί', |
1528 | 1528 | 'centralnotice-invalid-date-range' => 'Άκυρο εύρος ημερομηνιών. |
1529 | 1529 | Δεν είναι ενημερωμένο', |
— | — | @@ -1925,7 +1925,7 @@ |
1926 | 1926 | 'centralnotice-start-date' => 'تاریخ آغاز', |
1927 | 1927 | 'centralnotice-start-time' => 'زمان آغاز', |
1928 | 1928 | 'centralnotice-assigned-templates' => 'الگوهای متصل شده', |
1929 | | - 'centralnotice-no-templates' => 'در این سیستم هیچ الگویی نیست. |
| 1929 | + 'centralnotice-no-templates' => 'در این سیستم هیچ الگویی نیست. |
1930 | 1930 | چندتا بسازید.', |
1931 | 1931 | 'centralnotice-no-templates-assigned' => 'الگویی به این اعلان متصل نیست. |
1932 | 1932 | اضافه کنید!', |
— | — | @@ -4390,7 +4390,7 @@ |
4391 | 4391 | 'centralnotice-overlap' => 'Merknaden overlappar tida til ein annan merknad. Legg han ikkje til', |
4392 | 4392 | 'centralnotice-invalid-date-range' => 'Ugyldig tidsrom. Oppdaterer ikkje', |
4393 | 4393 | 'centralnotice-null-string' => 'Kan ikkje leggja til ein nullstreng. Legg ikkje til', |
4394 | | - 'centralnotice-confirm-delete' => 'Er du sikker på at du vil sletta? |
| 4394 | + 'centralnotice-confirm-delete' => 'Er du sikker på at du vil sletta? |
4395 | 4395 | Denne handlinga kan ikkje bli omgjort.', |
4396 | 4396 | 'centralnotice-no-notices-exist' => 'Ingen merknader finst. Legg til ein under', |
4397 | 4397 | 'centralnotice-no-templates-translate' => 'Det finst ingen malar å endra omsetjingar for', |
— | — | @@ -5410,7 +5410,7 @@ |
5411 | 5411 | 'centralnotice-change-lang' => 'Cancia la lingua dâ traduzzioni', |
5412 | 5412 | 'centralnotice-weights' => 'Pisa', |
5413 | 5413 | 'centralnotice-notice-is-locked' => "L'avvisu è bliccatu. Avvisu nun livatu", |
5414 | | - 'centralnotice-overlap' => "L'avvisu si camìna ntê pèdi di n'àutru avvisu a causa dû tempu. |
| 5414 | + 'centralnotice-overlap' => "L'avvisu si camìna ntê pèdi di n'àutru avvisu a causa dû tempu. |
5415 | 5415 | Nun junciutu", |
5416 | 5416 | 'centralnotice-invalid-date-range' => 'Ntirvaddu di tempu nun vàlidu. |
5417 | 5417 | Nun fu canciatu', |
— | — | @@ -6207,7 +6207,7 @@ |
6208 | 6208 | 'centralnotice' => 'Merkezi uwedomleniýe admini', |
6209 | 6209 | 'noticetemplate' => 'Merkezi uwedomleniýe şablony', |
6210 | 6210 | 'centralnotice-desc' => 'Merkezi uwedomleniýe goşýar', |
6211 | | - 'centralnotice-summary' => 'Bu modul size bar bolan gurulgy merkezi uwedomleniýeleri üýtgetmäge rugsat berýär. |
| 6211 | + 'centralnotice-summary' => 'Bu modul size bar bolan gurulgy merkezi uwedomleniýeleri üýtgetmäge rugsat berýär. |
6212 | 6212 | Ony köne uwedomleniýeleri goşmak ýa-da aýyrmak üçin hem ulanmak bolýar.', |
6213 | 6213 | 'centralnotice-query' => 'Häzirki uwedomleniýeleri üýtget', |
6214 | 6214 | 'centralnotice-notice-name' => 'Uwedomleniýe ady', |
— | — | @@ -6296,7 +6296,7 @@ |
6297 | 6297 | 'centralnotice' => 'Tagapangasiwa ng pangunahing pabatid', |
6298 | 6298 | 'noticetemplate' => 'Suleras ng pangunahing pabatid', |
6299 | 6299 | 'centralnotice-desc' => 'Nagdaragdag ng pangunahing pahayag ng sayt/sityo', |
6300 | | - 'centralnotice-summary' => 'Nagbibigay ang bahaging-panggampaning ito ng pahintulot na mabago mo ang iyong pangkasulukyang naitakdang mga pangunahing pahayag. |
| 6300 | + 'centralnotice-summary' => 'Nagbibigay ang bahaging-panggampaning ito ng pahintulot na mabago mo ang iyong pangkasulukyang naitakdang mga pangunahing pahayag. |
6301 | 6301 | Maaari rin itong gamitin upang makapagdagdag o magtanggal ng mga lumang pahayag.', |
6302 | 6302 | 'centralnotice-query' => 'Baguhin ang pangkasalukuyang mga pabatid', |
6303 | 6303 | 'centralnotice-notice-name' => 'Pangalan ng pabatid', |
— | — | @@ -6485,7 +6485,7 @@ |
6486 | 6486 | 'centralnotice' => 'Управління централізованими сповіщеннями', |
6487 | 6487 | 'noticetemplate' => 'Шаблон централізованого повідомлення', |
6488 | 6488 | 'centralnotice-desc' => 'Додає загальне повідомлення сайту', |
6489 | | - 'centralnotice-summary' => 'Цей модуль дозволяє вам змінювати ваші поточні централізовані повідомлення. |
| 6489 | + 'centralnotice-summary' => 'Цей модуль дозволяє вам змінювати ваші поточні централізовані повідомлення. |
6490 | 6490 | Він також може використовуватися для додавання нових і видалення старих повідомлень.', |
6491 | 6491 | 'centralnotice-query' => 'Змінити поточне повідомлення', |
6492 | 6492 | 'centralnotice-notice-name' => 'Назва повідомлення', |
— | — | @@ -6511,13 +6511,13 @@ |
6512 | 6512 | 'centralnotice-weight' => 'Ширина', |
6513 | 6513 | 'centralnotice-locked' => 'Заблокований', |
6514 | 6514 | 'centralnotice-notices' => 'повідомлення', |
6515 | | - 'centralnotice-notice-exists' => 'Повідомлення вже існує. |
| 6515 | + 'centralnotice-notice-exists' => 'Повідомлення вже існує. |
6516 | 6516 | Не додається', |
6517 | | - 'centralnotice-template-exists' => 'Шаблон вже існує. |
| 6517 | + 'centralnotice-template-exists' => 'Шаблон вже існує. |
6518 | 6518 | Не додається', |
6519 | | - 'centralnotice-notice-doesnt-exist' => 'Повідомлення не існує. |
| 6519 | + 'centralnotice-notice-doesnt-exist' => 'Повідомлення не існує. |
6520 | 6520 | Нема чого видаляти', |
6521 | | - 'centralnotice-template-still-bound' => "Шаблон, як і раніше, пов'язаний з повідомленням. |
| 6521 | + 'centralnotice-template-still-bound' => "Шаблон, як і раніше, пов'язаний з повідомленням. |
6522 | 6522 | Не видаляється.", |
6523 | 6523 | 'centralnotice-template-body' => 'Тіло шаблону:', |
6524 | 6524 | 'centralnotice-day' => 'День', |
— | — | @@ -6530,28 +6530,28 @@ |
6531 | 6531 | 'centralnotice-start-date' => 'Дата початку', |
6532 | 6532 | 'centralnotice-start-time' => 'Час початку (UTC)', |
6533 | 6533 | 'centralnotice-assigned-templates' => 'Встановлені шаблони', |
6534 | | - 'centralnotice-no-templates' => 'Не знайдено шаблонів. |
| 6534 | + 'centralnotice-no-templates' => 'Не знайдено шаблонів. |
6535 | 6535 | Додайте що-небудь!', |
6536 | | - 'centralnotice-no-templates-assigned' => "Не має пов'язаних з повідомленням шаблонів. |
| 6536 | + 'centralnotice-no-templates-assigned' => "Не має пов'язаних з повідомленням шаблонів. |
6537 | 6537 | Додайте який-небудь!", |
6538 | 6538 | 'centralnotice-available-templates' => 'Доступні шаблони', |
6539 | | - 'centralnotice-template-already-exists' => "Шаблон вже прив'язаний. |
| 6539 | + 'centralnotice-template-already-exists' => "Шаблон вже прив'язаний. |
6540 | 6540 | Не доданий", |
6541 | 6541 | 'centralnotice-preview-template' => 'Попередній перегляд шаблону', |
6542 | 6542 | 'centralnotice-start-hour' => 'Час початку', |
6543 | 6543 | 'centralnotice-change-lang' => 'Змінити мову перекладу', |
6544 | 6544 | 'centralnotice-weights' => 'Ваги', |
6545 | | - 'centralnotice-notice-is-locked' => 'Повідомлення заблоковано. |
| 6545 | + 'centralnotice-notice-is-locked' => 'Повідомлення заблоковано. |
6546 | 6546 | Не вилучається', |
6547 | | - 'centralnotice-overlap' => 'Повідомлення перекривається за часом з іншим повідомленням. |
| 6547 | + 'centralnotice-overlap' => 'Повідомлення перекривається за часом з іншим повідомленням. |
6548 | 6548 | Не додається', |
6549 | | - 'centralnotice-invalid-date-range' => 'Хибний діапазон дат. |
| 6549 | + 'centralnotice-invalid-date-range' => 'Хибний діапазон дат. |
6550 | 6550 | Не оновлюється', |
6551 | | - 'centralnotice-null-string' => 'Не вдається додати порожній рядок. |
| 6551 | + 'centralnotice-null-string' => 'Не вдається додати порожній рядок. |
6552 | 6552 | Не додається', |
6553 | | - 'centralnotice-confirm-delete' => 'Ви впевнені у вирішенні вилучити цей елемент? |
| 6553 | + 'centralnotice-confirm-delete' => 'Ви впевнені у вирішенні вилучити цей елемент? |
6554 | 6554 | Цю дію не можна буде скасувати.', |
6555 | | - 'centralnotice-no-notices-exist' => 'Немає повідомлень. |
| 6555 | + 'centralnotice-no-notices-exist' => 'Немає повідомлень. |
6556 | 6556 | Можна додати', |
6557 | 6557 | 'centralnotice-no-templates-translate' => 'Не має ні одного шаблону для редагування перекладу', |
6558 | 6558 | 'centralnotice-number-uses' => 'Використовуються', |
— | — | @@ -6601,13 +6601,13 @@ |
6602 | 6602 | 'centralnotice-weight' => 'Peso', |
6603 | 6603 | 'centralnotice-locked' => 'Blocà', |
6604 | 6604 | 'centralnotice-notices' => 'Notifiche', |
6605 | | - 'centralnotice-notice-exists' => 'Notifica zà esistente. |
| 6605 | + 'centralnotice-notice-exists' => 'Notifica zà esistente. |
6606 | 6606 | Inserimento mia fato', |
6607 | | - 'centralnotice-template-exists' => 'Modèl zà esistente. |
| 6607 | + 'centralnotice-template-exists' => 'Modèl zà esistente. |
6608 | 6608 | Inserimento mia fato', |
6609 | | - 'centralnotice-notice-doesnt-exist' => 'Notifica mia esistente. |
| 6609 | + 'centralnotice-notice-doesnt-exist' => 'Notifica mia esistente. |
6610 | 6610 | Rimozion mia fata', |
6611 | | - 'centralnotice-template-still-bound' => 'Modèl ancora ligà a na notifica. |
| 6611 | + 'centralnotice-template-still-bound' => 'Modèl ancora ligà a na notifica. |
6612 | 6612 | Rimozion mia fata.', |
6613 | 6613 | 'centralnotice-template-body' => 'Corpo del modèl:', |
6614 | 6614 | 'centralnotice-day' => 'Zorno', |
— | — | @@ -6625,7 +6625,7 @@ |
6626 | 6626 | 'centralnotice-no-templates-assigned' => 'Nissun modèl assegnà a la notifica |
6627 | 6627 | Zónteghene qualchedun!', |
6628 | 6628 | 'centralnotice-available-templates' => 'Modèi disponibili', |
6629 | | - 'centralnotice-template-already-exists' => 'Sto modèl el xe zà ligà a na campagna. |
| 6629 | + 'centralnotice-template-already-exists' => 'Sto modèl el xe zà ligà a na campagna. |
6630 | 6630 | Inserimento mia fato', |
6631 | 6631 | 'centralnotice-preview-template' => 'Anteprima modèl', |
6632 | 6632 | 'centralnotice-start-hour' => 'Ora de scominsio', |
Index: trunk/extensions/CentralNotice/patch-add-preferred.sql |
— | — | @@ -1,4 +1,6 @@ |
2 | | -# Support for one notice to supercede all others. This allows one notice to cancel out all the templates that a non preffered notice might have if they overlap. |
3 | | -# Use case is to be able to use one all language and projects notice and have it superceded by a specific one for en wikipedia |
| 2 | +# Support for one notice to supercede all others. This allows one notice to |
| 3 | +# cancel out all the templates that a non preffered notice might have if they |
| 4 | +# overlap. Use case is to be able to use one all language and projects notice |
| 5 | +# and have it superceded by a specific one for en wikipedia. |
4 | 6 | |
5 | | -ALTER TABLE cn_notices ADD COLUMN not_preferred bool NOT NULL default '0'; |
| 7 | +ALTER TABLE cn_notices ADD COLUMN not_preferred bool NOT NULL default '0'; |
Index: trunk/extensions/CentralNotice/SpecialNoticeTemplate.php |
— | — | @@ -6,7 +6,6 @@ |
7 | 7 | } |
8 | 8 | |
9 | 9 | class SpecialNoticeTemplate extends UnlistedSpecialPage { |
10 | | - |
11 | 10 | /* Functions */ |
12 | 11 | |
13 | 12 | function __construct() { |
— | — | @@ -38,7 +37,7 @@ |
39 | 38 | if ( $this->editable ) { |
40 | 39 | // Handle forms |
41 | 40 | if ( $wgRequest->wasPosted() ) { |
42 | | - |
| 41 | + |
43 | 42 | // Handle removing |
44 | 43 | $toRemove = $wgRequest->getArray( 'removeTemplates' ); |
45 | 44 | if ( isset( $toRemove ) ) { |
— | — | @@ -47,7 +46,7 @@ |
48 | 47 | $this->removeTemplate( $template ); |
49 | 48 | } |
50 | 49 | } |
51 | | - |
| 50 | + |
52 | 51 | // Handle translation message update |
53 | 52 | $update = $wgRequest->getArray( 'updateText' ); |
54 | 53 | $token = $wgRequest->getArray( 'token' ); |
— | — | @@ -62,7 +61,7 @@ |
63 | 62 | } |
64 | 63 | } |
65 | 64 | } |
66 | | - |
| 65 | + |
67 | 66 | // Handle adding |
68 | 67 | // FIXME: getText()? weak comparison |
69 | 68 | if ( $wgRequest->getVal( 'wpMethod' ) == 'addTemplate' ) { |
— | — | @@ -100,14 +99,15 @@ |
101 | 100 | $this->showAdd(); |
102 | 101 | return; |
103 | 102 | } |
104 | | - if ( $sub == 'clone' ) { |
105 | | - $oldTemplate = $wgRequest->getVal( 'oldTemplate' ); |
106 | | - $newTemplate = $wgRequest->getVal( 'newTemplate' ); |
107 | | - // We use the returned name in case any special characters had to be removed |
108 | | - $template = $this->cloneTemplate( $oldTemplate, $newTemplate ); |
109 | | - $wgOut->redirect( SpecialPage::getTitleFor( 'NoticeTemplate', 'view' )->getLocalUrl( "template=$template" ) ); |
110 | | - return; |
111 | | - } |
| 103 | + |
| 104 | + if ( $sub == 'clone' ) { |
| 105 | + $oldTemplate = $wgRequest->getVal( 'oldTemplate' ); |
| 106 | + $newTemplate = $wgRequest->getVal( 'newTemplate' ); |
| 107 | + // We use the returned name in case any special characters had to be removed |
| 108 | + $template = $this->cloneTemplate( $oldTemplate, $newTemplate ); |
| 109 | + $wgOut->redirect( SpecialPage::getTitleFor( 'NoticeTemplate', 'view' )->getLocalUrl( "template=$template" ) ); |
| 110 | + return; |
| 111 | + } |
112 | 112 | } |
113 | 113 | |
114 | 114 | // Show list by default |
— | — | @@ -123,7 +123,7 @@ |
124 | 124 | $templates = $this->queryTemplates(); |
125 | 125 | if ( count( $templates ) > 0 ) { |
126 | 126 | $htmlOut = ''; |
127 | | - |
| 127 | + |
128 | 128 | if ( $this->editable ) { |
129 | 129 | $htmlOut .= Xml::openElement( 'form', |
130 | 130 | array( |
— | — | @@ -286,7 +286,7 @@ |
287 | 287 | $bodyPage = Title::newFromText( "Centralnotice-template-{$currentTemplate}", NS_MEDIAWIKI ); |
288 | 288 | $curRev = Revision::newFromTitle( $bodyPage ); |
289 | 289 | $body = $curRev ? $curRev->getText() : ''; |
290 | | - |
| 290 | + |
291 | 291 | $fields = array(); |
292 | 292 | preg_match_all( '/\{\{\{([A-Za-z0-9\_\-}]+)\}\}\}/', $body, $fields ); |
293 | 293 | |
— | — | @@ -353,8 +353,10 @@ |
354 | 354 | ); |
355 | 355 | $htmlOut .= Xml::closeElement( 'tr' ); |
356 | 356 | } |
| 357 | + |
357 | 358 | $htmlOut .= Xml::closeElement( 'table' ); |
358 | 359 | $htmlOut .= Xml::closeElement( 'fieldset' ); |
| 360 | + |
359 | 361 | if ( $this->editable ) { |
360 | 362 | $htmlOut .= Xml::closeElement( 'form' ); |
361 | 363 | } |
— | — | @@ -368,18 +370,18 @@ |
369 | 371 | list( $lsLabel, $lsSelect ) = Xml::languageSelector( $wpUserLang ); |
370 | 372 | |
371 | 373 | $newPage = SpecialPage::getTitleFor( 'NoticeTemplate', 'view' ); |
372 | | - |
| 374 | + |
373 | 375 | $htmlOut .= Xml::tags( 'tr', null, |
374 | 376 | Xml::tags( 'td', null, $lsLabel ) . |
375 | 377 | Xml::tags( 'td', null, $lsSelect ) . |
376 | 378 | Xml::tags( 'td', array( 'colspan' => 2 ), |
377 | 379 | Xml::submitButton( wfMsg( 'centralnotice-modify' ) ) |
378 | 380 | ) |
379 | | - ); |
380 | | - $htmlOut .= Xml::tags( 'tr', null, |
381 | | - Xml::tags( 'td', null, '' ) . |
382 | | - Xml::tags( 'td', null, $sk->makeLinkObj( $newPage, wfMsgHtml( 'centralnotice-preview-all-template-translations' ), "template=$currentTemplate&wpUserLanguage=all" ) ) |
383 | 381 | ); |
| 382 | + $htmlOut .= Xml::tags( 'tr', null, |
| 383 | + Xml::tags( 'td', null, '' ) . |
| 384 | + Xml::tags( 'td', null, $sk->makeLinkObj( $newPage, wfMsgHtml( 'centralnotice-preview-all-template-translations' ), "template=$currentTemplate&wpUserLanguage=all" ) ) |
| 385 | + ); |
384 | 386 | $htmlOut .= Xml::closeElement( 'table' ); |
385 | 387 | $htmlOut .= Xml::closeElement( 'fieldset' ); |
386 | 388 | $htmlOut .= Xml::closeElement( 'form' ); |
— | — | @@ -452,7 +454,7 @@ |
453 | 455 | // Pull all available text for a template |
454 | 456 | $langs = array_keys( $this->getTranslations( $template ) ); |
455 | 457 | $htmlOut = ''; |
456 | | - |
| 458 | + |
457 | 459 | foreach ( $langs as $lang ) { |
458 | 460 | // Link and Preview all available translations |
459 | 461 | $viewPage = SpecialPage::getTitleFor( 'NoticeTemplate', 'view' ); |
— | — | @@ -470,7 +472,7 @@ |
471 | 473 | } |
472 | 474 | return $wgOut->addHtml( $htmlOut ); |
473 | 475 | } |
474 | | - |
| 476 | + |
475 | 477 | private function updateMessage( $text, $translation, $lang, $token = false ) { |
476 | 478 | global $wgUser; |
477 | 479 | |
— | — | @@ -560,7 +562,9 @@ |
561 | 563 | $name = ereg_replace( '[^A-Za-z0-9\_]', '', $name ); |
562 | 564 | |
563 | 565 | $dbr = wfGetDB( DB_SLAVE ); |
564 | | - $res = $dbr->select( 'cn_templates', 'tmp_name', |
| 566 | + $res = $dbr->select( |
| 567 | + 'cn_templates', |
| 568 | + 'tmp_name', |
565 | 569 | array( 'tmp_name' => $name ), |
566 | 570 | __METHOD__ |
567 | 571 | ); |
— | — | @@ -571,7 +575,8 @@ |
572 | 576 | } else { |
573 | 577 | $dbw = wfGetDB( DB_MASTER ); |
574 | 578 | $dbw->begin(); |
575 | | - $res = $dbw->insert( 'cn_templates', |
| 579 | + $res = $dbw->insert( |
| 580 | + 'cn_templates', |
576 | 581 | array( 'tmp_name' => $name ), |
577 | 582 | __METHOD__ |
578 | 583 | ); |
— | — | @@ -614,79 +619,80 @@ |
615 | 620 | } |
616 | 621 | } |
617 | 622 | |
618 | | - /* |
619 | | - * Copy all the data from one template to another |
620 | | - */ |
621 | | - public function cloneTemplate( $source, $dest ) { |
622 | | - // Reset the timer as updates on meta take a long time |
623 | | - set_time_limit( 300 ); |
624 | | - // Pull all possible langs |
625 | | - $langs = $this->getTranslations( $source ); |
626 | | - |
627 | | - // Normalize name |
628 | | - $dest = ereg_replace( '[^A-Za-z0-9\_]', '', $dest ); |
629 | | - |
630 | | - // Pull text and respect any inc: markup |
631 | | - $bodyPage = Title::newFromText( "Centralnotice-template-{$source}", NS_MEDIAWIKI ); |
632 | | - $template_body = Revision::newFromTitle( $bodyPage )->getText(); |
| 623 | + /* |
| 624 | + * Copy all the data from one template to another |
| 625 | + */ |
| 626 | + public function cloneTemplate( $source, $dest ) { |
| 627 | + // Reset the timer as updates on meta take a long time |
| 628 | + set_time_limit( 300 ); |
| 629 | + // Pull all possible langs |
| 630 | + $langs = $this->getTranslations( $source ); |
633 | 631 | |
634 | | - if ( $this->addTemplate( $dest, $template_body ) ) { |
| 632 | + // Normalize name |
| 633 | + $dest = ereg_replace( '[^A-Za-z0-9\_]', '', $dest ); |
635 | 634 | |
636 | | - // Populate the fields |
637 | | - foreach ( $langs as $lang => $fields ) { |
638 | | - foreach ( $fields as $field => $text ) { |
639 | | - $this->updateMessage( "$dest-$field", $text, $lang ); |
640 | | - } |
641 | | - } |
642 | | - return $dest; |
643 | | - } |
644 | | - } |
| 635 | + // Pull text and respect any inc: markup |
| 636 | + $bodyPage = Title::newFromText( "Centralnotice-template-{$source}", NS_MEDIAWIKI ); |
| 637 | + $template_body = Revision::newFromTitle( $bodyPage )->getText(); |
645 | 638 | |
646 | | - /* |
647 | | - * Find all fields set for a template |
648 | | - */ |
649 | | - private function findFields( $template ) { |
650 | | - $messages = array(); |
651 | | - $body = wfMsg( "Centralnotice-template-{$template}" ); |
652 | | - |
653 | | - // Generate fields from parsing the body |
654 | | - $fields = array(); |
655 | | - preg_match_all( '/\{\{\{([A-Za-z0-9\_\-}]+)\}\}\}/', $body, $fields ); |
656 | | - |
657 | | - // Remove duplicates |
658 | | - $filteredFields = array(); |
659 | | - foreach ( $fields[1] as $field ) { |
660 | | - $filteredFields[$field] = array_key_exists( $field, $filteredFields ) ? $filteredFields[$field] + 1 : |
661 | | -1; |
662 | | - } |
663 | | - return $filteredFields; |
664 | | - } |
| 639 | + if ( $this->addTemplate( $dest, $template_body ) ) { |
665 | 640 | |
666 | | - /* |
667 | | - * Given a template return a list of every set field in every language |
668 | | - */ |
669 | | - public function getTranslations( $template ) { |
670 | | - $translations = array(); |
| 641 | + // Populate the fields |
| 642 | + foreach ( $langs as $lang => $fields ) { |
| 643 | + foreach ( $fields as $field => $text ) { |
| 644 | + $this->updateMessage( "$dest-$field", $text, $lang ); |
| 645 | + } |
| 646 | + } |
| 647 | + return $dest; |
| 648 | + } |
| 649 | + } |
671 | 650 | |
672 | | - // Pull all language codes to enumerate |
673 | | - $allLangs = array_keys( Language::getLanguageNames() ); |
674 | | - |
675 | | - // Lookup all the possible fields for a template |
676 | | - $fields = $this->findFields( $template ); |
| 651 | + /* |
| 652 | + * Find all fields set for a template |
| 653 | + */ |
| 654 | + private function findFields( $template ) { |
| 655 | + $messages = array(); |
| 656 | + $body = wfMsg( "Centralnotice-template-{$template}" ); |
677 | 657 | |
678 | | - // Iterate through all possible languages to find matches |
679 | | - foreach ( $allLangs as $lang ) { |
680 | | - // Iterate through all possible fields |
681 | | - foreach ( $fields as $field => $count ) { |
682 | | - // Put all fields together for a lookup |
683 | | - $message = ( $lang == 'en' ) ? "Centralnotice-{$template}-{$field}" : "Centralnotice-{$template}-{$field}/{$lang}"; |
684 | | - if ( Title::newFromText( $message, NS_MEDIAWIKI )->exists() ) { |
685 | | - $translations[$lang][$field] = wfMsgExt( "Centralnotice-{$template}-{$field}", |
686 | | - array( 'language' => $lang ) |
687 | | - ); |
688 | | - } |
689 | | - } |
690 | | - } |
691 | | - return $translations; |
692 | | - } |
| 658 | + // Generate fields from parsing the body |
| 659 | + $fields = array(); |
| 660 | + preg_match_all( '/\{\{\{([A-Za-z0-9\_\-}]+)\}\}\}/', $body, $fields ); |
| 661 | + |
| 662 | + // Remove duplicates |
| 663 | + $filteredFields = array(); |
| 664 | + foreach ( $fields[1] as $field ) { |
| 665 | + $filteredFields[$field] = array_key_exists( $field, $filteredFields ) ? $filteredFields[$field] + 1 : |
| 666 | + 1; |
| 667 | + } |
| 668 | + return $filteredFields; |
| 669 | + } |
| 670 | + |
| 671 | + /* |
| 672 | + * Given a template return a list of every set field in every language |
| 673 | + */ |
| 674 | + public function getTranslations( $template ) { |
| 675 | + $translations = array(); |
| 676 | + |
| 677 | + // Pull all language codes to enumerate |
| 678 | + $allLangs = array_keys( Language::getLanguageNames() ); |
| 679 | + |
| 680 | + // Lookup all the possible fields for a template |
| 681 | + $fields = $this->findFields( $template ); |
| 682 | + |
| 683 | + // Iterate through all possible languages to find matches |
| 684 | + foreach ( $allLangs as $lang ) { |
| 685 | + // Iterate through all possible fields |
| 686 | + foreach ( $fields as $field => $count ) { |
| 687 | + // Put all fields together for a lookup |
| 688 | + $message = ( $lang == 'en' ) ? "Centralnotice-{$template}-{$field}" : "Centralnotice-{$template}-{$field}/{$lang}"; |
| 689 | + if ( Title::newFromText( $message, NS_MEDIAWIKI )->exists() ) { |
| 690 | + $translations[$lang][$field] = wfMsgExt( |
| 691 | + "Centralnotice-{$template}-{$field}", |
| 692 | + array( 'language' => $lang ) |
| 693 | + ); |
| 694 | + } |
| 695 | + } |
| 696 | + } |
| 697 | + return $translations; |
| 698 | + } |
693 | 699 | } |
Index: trunk/extensions/CentralNotice/CentralNotice.alias.php |
— | — | @@ -0,0 +1,12 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Aliases for special pages of CentralNotice extension. |
| 5 | + */ |
| 6 | + |
| 7 | +$aliases = array(); |
| 8 | + |
| 9 | +$aliases['en'] = array( |
| 10 | + 'CentralNotice' => array( 'CentralNotice' ), |
| 11 | + 'NoticeText' => array( 'NoticeText' ), |
| 12 | + 'NoticeTemplate' => array( 'NoticeTemplate' ), |
| 13 | +); |
Property changes on: trunk/extensions/CentralNotice/CentralNotice.alias.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 14 | + native |
Name: svn:keywords |
2 | 15 | + Id |
Index: trunk/extensions/CentralNotice/SpecialNoticeText.php |
— | — | @@ -21,24 +21,24 @@ |
22 | 22 | function getJsOutput( $par ) { |
23 | 23 | $this->setLanguage( $par ); |
24 | 24 | |
25 | | - // Quick short circuit to be able to show preferred notices |
26 | | - $templates = array(); |
| 25 | + // Quick short circuit to be able to show preferred notices |
| 26 | + $templates = array(); |
27 | 27 | |
28 | | - if ( $this->language == 'en' && $this->project != null ) { |
29 | | - // See if we have any preferred notices for all of en |
30 | | - $notices = CentralNoticeDB::getNotices( '', 'en', '', '', 1 ); |
| 28 | + if ( $this->language == 'en' && $this->project != null ) { |
| 29 | + // See if we have any preferred notices for all of en |
| 30 | + $notices = CentralNoticeDB::getNotices( '', 'en', '', '', 1 ); |
31 | 31 | |
32 | | - if ( $notices ) { |
33 | | - // Pull out values |
34 | | - foreach ( $notices as $notice => $val ) { |
35 | | - // Either match against ALL project or a specific project |
36 | | - if ( $val['project'] == '' || $val['project'] == $this->project ) { |
37 | | - $templates = CentralNoticeDB::selectTemplatesAssigned( $notice ); |
38 | | - break; |
39 | | - } |
40 | | - } |
41 | | - } |
42 | | - } |
| 32 | + if ( $notices ) { |
| 33 | + // Pull out values |
| 34 | + foreach ( $notices as $notice => $val ) { |
| 35 | + // Either match against ALL project or a specific project |
| 36 | + if ( $val['project'] == '' || $val['project'] == $this->project ) { |
| 37 | + $templates = CentralNoticeDB::selectTemplatesAssigned( $notice ); |
| 38 | + break; |
| 39 | + } |
| 40 | + } |
| 41 | + } |
| 42 | + } |
43 | 43 | |
44 | 44 | if ( !$templates && $this->project == 'wikipedia' ) { |
45 | 45 | $notices = CentralNoticeDB::getNotices( 'wikipedia', '', '', '', 1 ); |
— | — | @@ -53,9 +53,9 @@ |
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
57 | | - // Didn't find any preferred matches so do an old style lookup |
| 57 | + // Didn't find any preferred matches so do an old style lookup |
58 | 58 | if ( !$templates ) { |
59 | | - $templates = CentralNotice::selectNoticeTemplates( $this->project, $this->language ); |
| 59 | + $templates = CentralNotice::selectNoticeTemplates( $this->project, $this->language ); |
60 | 60 | } |
61 | 61 | |
62 | 62 | $templateNames = array_keys( $templates ); |
— | — | @@ -64,12 +64,12 @@ |
65 | 65 | array( $this, 'getHtmlNotice' ), |
66 | 66 | $templateNames ); |
67 | 67 | |
68 | | - if ( preg_grep( "/<centralnotice-template-\w{1,}>\z/", $templateTexts ) ) { |
69 | | - return false; // Bailing out if we have a failed cache lookup |
70 | | - } |
| 68 | + if ( preg_grep( "/<centralnotice-template-\w{1,}>\z/", $templateTexts ) ) { |
| 69 | + return false; // Bailing out if we have a failed cache lookup |
| 70 | + } |
71 | 71 | |
72 | 72 | $weights = array_values( $templates ); |
73 | | - |
| 73 | + |
74 | 74 | return |
75 | 75 | $this->getScriptFunctions() . |
76 | 76 | $this->getToggleScripts() . |
— | — | @@ -155,7 +155,7 @@ |
156 | 156 | } |
157 | 157 | currentTemplate++; |
158 | 158 | } |
159 | | - |
| 159 | + |
160 | 160 | if (totalWeight == 0) |
161 | 161 | return ''; |
162 | 162 | |
— | — | @@ -168,7 +168,7 @@ |
169 | 169 | private function formatNum( $num ) { |
170 | 170 | $num = sprintf( "%.1f", $num / 1e6 ); |
171 | 171 | if ( substr( $num, - 2 ) == '.0' ) { |
172 | | - $num = substr( $num, 0, - 2 ); |
| 172 | + $num = substr( $num, 0, - 2 ); |
173 | 173 | } |
174 | 174 | $lang = Language::factory( $this->language ); |
175 | 175 | return $lang->formatNum( $num ); |
— | — | @@ -207,7 +207,7 @@ |
208 | 208 | $old = array(); |
209 | 209 | $old['wgSitename'] = $GLOBALS['wgSitename']; |
210 | 210 | $old['wgLang'] = $GLOBALS['wgLang']; |
211 | | - |
| 211 | + |
212 | 212 | $GLOBALS['wgSitename'] = $this->projectName(); |
213 | 213 | $GLOBALS['wgLang'] = Language::factory( $this->language ); // hack for {{int:...}} |
214 | 214 | |
Index: trunk/extensions/Translate/groups/mediawiki-defines.txt |
— | — | @@ -107,6 +107,7 @@ |
108 | 108 | ignored = centralauth-editset-item-ro |
109 | 109 | |
110 | 110 | Central Notice |
| 111 | +aliasfile = CentralNotice/CentralNotice.alias.php |
111 | 112 | |
112 | 113 | Change Author |
113 | 114 | aliasfile = ChangeAuthor/ChangeAuthor.alias.php |