Kullanıcı:E THP/Twinkle/Koruma.js
Not: Yayımladıktan sonra değişiklikleri görmek için tarayıcınızın önbelleğini temizlemeniz gerekebilir.
- Firefox / Safari: Shift tuşuna basılıyken Yeniden Yükle'ye tıklayın ya da Ctrl-F5 ya da Ctrl-R tıklayın (Mac için ⌘-R).
- Google Chrome: Ctrl-Shift-R'ye basın. (Mac için ⌘-Shift-R)
- Internet Explorer / Edge: Ctrl basılıyken Yenile'ye tıklayın ya da Ctrl-F5 yapın.
- Opera: Ctrl-F5 tıklayın.
// If TwinkleConfig aint exist.
if( typeof( TwinkleConfig ) == 'undefined' ) {
TwinkleConfig = function() {};
}
/**
TwinkleConfig.summaryAd (string)
If ad should be added or not to summary, default [[WP:TW|TWINKLE]]
*/
if( typeof( TwinkleConfig.summaryAd ) == 'undefined' ) {
TwinkleConfig.summaryAd = " ([[VP:TW|Twinkle]])";
}
if( typeof( TwinkleConfig.protectionSummaryAd ) == 'undefined' ) {
TwinkleConfig.protectionSummaryAd = " ([[VP:TW|Twinkle]])";
}
function twinkleprotect() {
if( wgNamespaceNumber < 0 ) {
return;
}
if( userIsInGroup( 'sysop' ) ) {
twAddPortletLink( "javascript:twinkleprotect.callback()", "Koruma", "tw-rpp", "Sayfayı koru", "");
} else if (twinkleConfigExists) {
twAddPortletLink( "javascript:twinkleprotect.callback()", "Skt", "tw-rpp", "Sayfanın korunmasını talep et", "");
}
else
{
twAddPortletLink( 'javascript:alert("Hesabınız Twinkle kullanmak için fazla yeni.");', 'Korunsun', 'tw-rpp', 'Sayfanın korunmasını talep et', '');
}
}
window.TwinkleInit = (window.TwinkleInit || []).concat(twinkleprotect); //schedule initializer
twinkleprotect.callback = function twinkleprotectCallback() {
var Window = new SimpleWindow( 600, 400 );
Window.setTitle( "Sayfa koruması" );
var form = new QuickForm( twinkleprotect.callback.evaluate );
if( userIsInGroup( 'sysop' ) ) {
form.append( {
type: 'checkbox',
name: 'request_only',
event: twinkleprotect.callback.disabledefaults,
list: [
{
label: 'Koruma talep et',
value: 'request_only',
tooltip: 'Sayfayı kendiniz korumaya almak yerine VP:SKT aracılığıyla koruma talebinde bulunmak istiyorsanız.'
}
]
} );
}
form.append( {
type: 'select',
name: 'category',
label: 'Koruma türü: ',
event: twinkleprotect.callback.disabledefaults,
list: [
{
label: 'Tam koruma',
list: [
{ label: 'Genel', value: 'koruma-tam' },
{ label: 'Anlaşmazlık', selected: wgCurRevisionId != false, value: 'koruma-anlaşmazlık' },
{ label: 'Vandalizm', value: 'koruma-vandalizm' },
{ label: 'Yüksek trafiğe sahip şablon', value: 'koruma-şablon' }
]
},
{
label: 'Yarı koruma',
list: [
{ label: 'Genel', value: 'koruma-yarı' },
{ label: 'Vandalizm', value: 'koruma-yarı-vandalizm' },
{ label: 'Yüksek trafiğe sahip şablon', value: 'koruma-yarı-şablon' },
{ label: 'Reklam botu hedefi', value: 'koruma-yarı-reklam' }
]
},
{
label: 'Diğer',
list: [
{ label: 'Taşıma koruması', value: 'koruma-taşıma' },
{ label: 'Oluşturma koruması', selected: wgCurRevisionId == false , value: 'koruma-oluşturma' },
{ label: 'Korumayı kaldırma', value: 'koruma-kaldırma' }
]
}
]
} );
var flags = form.append( {
type: 'field',
label: 'Seçenekler'
} );
flags.append( {
type: 'checkbox',
list: [
{
name: 'noinclude',
label: '<noinclude> etiketi',
tooltip: 'Şablonu <noinclude> etiketinin içine alacak ve böylelikle diğer sayfalarda gösterim önlenecek',
disabled:!userIsInGroup( 'sysop' ),
checked:(wgNamespaceNumber==10),
adminonly: true
},
{
name: 'small',
label: 'Simgeleştirme',
tooltip: 'Şablonun küçük simge işaretini kullanacak ve sadece bir asma kilit görülecek',
disabled:!userIsInGroup( 'sysop' ),
adminonly: true
},
{
name: 'cascade',
label: 'Kademeli koruma',
tooltip: 'Kademeli koruma, bu sayfadan bağlantı verilen tüm sayfaları korumaya alacak'
}
]
} );
if( userIsInGroup( 'sysop' ) ) {
form.append( {
type: 'select',
name: 'expiry',
label: 'Bitiş tarihi: ',
list: [
{ label: '1 saat', value: '1 hour' },
{ label: '2 saat', value: '2 hours' },
{ label: '3 saat', value: '3 hours' },
{ label: '6 saat', value: '6 hours' },
{ label: '12 saat', value: '12 hours' },
{ label: '1 gün', value: '1 day' },
{ label: '2 gün', value: '2 days' },
{ label: '3 gün', value: '3 days' },
{ label: '4 gün', value: '4 days' },
{ label: '5 gün', value: '5 days' },
{ label: '6 gün', value: '6 days' },
{ label: '1 hafta', value: '1 week' },
{ label: '2 hafta', value: '2 weeks' },
{ label: '1 ay', value: '1 month' },
{ label: '2 ay', value: '2 months' },
{ label: '3 ay', value: '3 months' },
{ label: '6 ay', value: '6 months' },
{ label: '1 yıl', value: '1 year' },
{ label: 'süresiz', selected: true, value:'indefinite' }
]
} );
} else {
form.append( {
type: 'select',
name: 'expiry',
label: 'Bitiş tarihi: ',
list: [
{ label: 'temporary', value: 'temporary' },
{ label: 'indefinite', value: 'indefinite' },
{ label: '', selected: true, value:'' }
]
} );
}
form.append( {
type: 'textarea',
name: 'reason',
label: 'Gerekçe: '
} );
form.append( { type:'submit' } );
var result = form.render();
Window.setContent( result );
Window.display();
}
twinkleprotect.callback.disabledefaults = function twinkleprotectCallbackDisableDefaults(e) {
var root = e.target.form;
if( e.target.value == 'koruma-kaldırma' ) {
root.noinclude.disabled = true;
root.cascade.disabled = true;
root.expiry.disabled = true;
root.small.disabled = true;
} else {
root.noinclude.disabled = true;
root.cascade.disabled = false;
root.expiry.disabled = false;
root.small.disabled = true;
if( userIsInGroup( 'sysop' ) && !root.request_only.checked )
{
root.small.disabled = false;
root.noinclude.disabled = false;
}
}
if( /template/.test( e.target.value ) ) {
root.noinclude.checked = true;
root.expiry.disabled = true;
} else {
root.noinclude.checked = false;
}
}
twinkleprotect.callback.evaluate = function twinkleprotectCallbackEvaluate(e) {
var form = e.target;
var params = {
noinclude: form.noinclude.checked,
cascade: form.cascade.checked,
small: form.small.checked,
reason: form.reason.value,
expiry: form.expiry.value,
type: form.category.value
}
if( userIsInGroup( 'sysop') ) {
var request_only = form.request_only.checked;
if( request_only && params.expiry != 'indefinite' ) {
params.expiry = 'temporary';
}
}
Status.init( form );
if( userIsInGroup( 'sysop' ) && ! request_only ) {
var edit, move, tag = params.type, reason, create = '';
switch( tag ) {
case 'koruma-anlaşmazlık':
edit = 'sysop';
move = 'sysop';
reason = 'Tam koruma: anlaşmazlık';
break;
case 'koruma-vandalizm':
edit = 'sysop';
move = 'sysop';
reason = 'Tam koruma: vandalizm';
break;
case 'koruma-şablon':
edit = 'sysop';
move = 'sysop';
reason = 'Tam koruma: yüksek trafiğe sahip şablon';
break;
case 'koruma-tam':
edit = 'sysop';
move = 'sysop';
if( params.reason ) {
tag += '|gerekçe=' + params.reason;
params.reason = undefined;
}
reason = 'Tam koruma';
break;
case 'koruma-yarı-vandalizm':
edit = 'autoconfirmed';
move = 'autoconfirmed';
reason = 'Yarı koruma: vandalizm';
break;
case 'koruma-yarı-şablon':
edit = 'autoconfirmed';
move = 'autoconfirmed';
reason = 'Yarı koruma: yüksek trafiğe sahip şablon';
break;
case 'koruma-yarı-reklam':
edit = 'autoconfirmed';
move = 'autoconfirmed';
reason = 'Yarı koruma: reklam botunun hedefi';
break;
case 'koruma-yarı':
edit = 'autoconfirmed';
move = 'autoconfirmed';
if( params.reason ) {
tag += '|gerekçe=' + params.reason;
params.reason = undefined;
}
reason = 'Yarı koruma';
break;
case 'koruma-taşıma':
edit = '';
move = 'sysop';
reason = 'Taşıma koruması';
break;
case 'koruma-oluşturma':
edit = '';
move = '';
create = 'sysop';
reason = 'Oluşturma koruması';
break;
case 'koruma-kaldırma':
default:
edit = '';
move = '';
reason = 'Korumayı kaldırma';
break;
}
if( params.reason ) {
reason += ', ' + params.reason;
}
if( reason != '' && reason.charAt( reason.length - 1 ) != '.' ) {
reason += '.';
}
params.reason = reason;
params.tag = tag;
params.edit = edit;
params.move = move;
params.create = create;
var query = {
'title': wgPageName,
'action': 'protect'
};
// Updating data for the action completed event
Wikipedia.actionCompleted.redirect = query['title'];
Wikipedia.actionCompleted.notice = "Tamamlandı...";
var wikipedia_wiki = new Wikipedia.wiki( 'Sayfa korumaya alınıyor', query, twinkleprotect.callbacks.sysop.protectingPage );
wikipedia_wiki.params = params;
wikipedia_wiki.get();
} else {
var typename, reason;
switch( params.type ) {
case 'koruma-anlaşmazlık':
case 'koruma-vandalizm':
case 'koruma-şablon':
case 'koruma-tam':
typename = 'tam koruma';
break;
case 'koruma-yarı-vandalizm':
case 'koruma-yarı-şablon':
case 'koruma-yarı-reklam':
case 'koruma-yarı':
typename = 'yarı koruma';
break;
case 'koruma-move':
typename = 'taşıma koruması';
break;
case 'koruma-create':
typename = 'oluşturma koruması';
break;
case 'koruma-kaldırma':
default:
typename = 'koruma kaldırma';
break;
}
switch( params.type ) {
case 'koruma-anlaşmazlık':
reason = 'anlaşmazlık';
break;
case 'koruma-vandalizm':
case 'koruma-yarı-vandalizm':
reason = 'vandalizm';
break;
case 'koruma-şablon':
case 'koruma-yarı-şablon':
reason = 'yüksek trafiğe sahip şablon';
break;
case 'koruma-yarı-reklam':
reason = 'reklam botu hedefi';
break;
case 'koruma-tam':
case 'koruma-yarı':
case 'koruma-taşıma':
case 'koruma-oluşturma':
case 'koruma-kaldırma':
default:
reason = '';
break;
}
if( reason != '' ) {
reason = " ''" + reason + "''";
}
if( params.reason ) {
reason += ', ' + params.reason;
}
if( reason != '' && reason.charAt( reason.length - 1 ) != '.' ) {
reason += '.';
}
params.reason = reason;
params.typename = typename;
var query = {
'title': 'Vikipedi:Sayfa koruma talepleri',
'action': 'submit'
};
// Updating data for the action completed event
Wikipedia.actionCompleted.redirect = query['title'];
Wikipedia.actionCompleted.notice = "Talep tamamlandı, şimdi tartışma sayfasına yönlendiriliyorsunuz";
var wikipedia_wiki = new Wikipedia.wiki( 'Sayfa koruması talep ediliyor', query, twinkleprotect.callbacks.user );
wikipedia_wiki.params = params;
wikipedia_wiki.followRedirect = true;
wikipedia_wiki.get();
}
}
twinkleprotect.callbacks = {
sysop: {
taggingPage: function( self ) {
var form = self.responseXML.getElementById( 'editform' );
var oldtag_re = /\s*(?:<noinclude>)?\s*\{\{\s*(koruma-[^{}]*?|tam|(?:t|v|s|p-|usertalk-s|sb|move)protected(?:2)?|protected template|privacy protection)\s*?\}\}\s*(?:<\/noinclude>)?\s*/gi;
var text = form.wpTextbox1.value;
text = text.replace( oldtag_re, '' );
if( self.params.type != 'koruma-kaldırma' && self.params.expiry != 'indefinite' ) {
self.params.tag += '|bitiş={' + '{subst:#time:j F Y|+' + self.params.expiry +'}}';
if( self.params.small ) {
self.params.tag += '|küçük=evet';
}
}
var summary;
if( self.params.type == 'koruma-kaldırma' ) {
summary = 'Koruma şablonu kaldırıldı. ' + TwinkleConfig.summaryAd;
} else {
if( self.params.noinclude ) {
text = "<noinclude>\{\{" + self.params.tag + "\}\}</noinclude>" + text;
} else {
text = "\{\{" + self.params.tag + "\}\}\n" + text;
}
summary = "\{\{" + self.params.tag + "\}\} şablonu eklendi. " + TwinkleConfig.summaryAd;
}
var postData = {
'wpMinoredit': form.wpMinoredit.checked ? '' : undefined,
'wpWatchthis': form.wpWatchthis.checked ? '' : undefined,
'wpStarttime': form.wpStarttime.value,
'wpEdittime': form.wpEdittime.value,
'wpAutoSummary': form.wpAutoSummary.value,
'wpEditToken': form.wpEditToken.value,
'wpSummary': summary,
'wpTextbox1': text
};
self.post( postData );
},
protectingPage: function( self ){
var form = self.responseXML.getElementById( 'mw-Protect-Form' );
var postData;
if( self.params.type == 'koruma-taşıma' ) {
postData = {
'wpEditToken': form.wpEditToken.value,
'mwProtect-level-move': self.params.move,
'wpProtectExpirySelection-move': self.params.expiry != 'indefinite' ? 'othertime' : 'indefinite',
'mwProtect-expiry-move': self.params.expiry != 'indefinite' ? self.params.expiry : undefined,
'mwProtect-cascade': self.params.cascade ? '' : undefined,
'mwProtectWatch': form.mwProtectWatch.checked ? '' : undefined,
'wpProtectReasonSelection': 'other',
'mwProtect-reason': self.params.reason + TwinkleConfig.protectionSummaryAd
};
} else if( self.params.type == 'koruma-oluşturma' ) {
postData = {
'wpEditToken': form.wpEditToken.value,
'mwProtect-level-create': self.params.create,
'wpProtectExpirySelection-create': self.params.expiry != 'indefinite' ? 'othertime' : 'indefinite',
'mwProtect-expiry-create': self.params.expiry != 'indefinite' ? self.params.expiry : undefined,
'mwProtect-cascade': self.params.cascade ? '' : undefined,
'mwProtectWatch': form.mwProtectWatch.checked ? '' : undefined,
'wpProtectReasonSelection': 'other',
'mwProtect-reason': self.params.reason + TwinkleConfig.protectionSummaryAd
};
} else if( self.params.type == 'koruma-kaldırma' ) {
postData = {
'wpEditToken': form.wpEditToken.value,
'mwProtect-level-edit': self.params.edit,
'wpProtectExpirySelection-edit': 'indefinite',
'mwProtect-level-move': self.params.move,
'wpProtectExpirySelection-move': 'indefinite',
'mwProtect-level-create': self.params.create,
'wpProtectExpirySelection-create': 'indefinite',
'mwProtect-cascade': self.params.cascade ? '' : undefined,
'mwProtectWatch': form.mwProtectWatch.checked ? '' : undefined,
'wpProtectReasonSelection': 'other',
'mwProtect-reason': self.params.reason + TwinkleConfig.protectionSummaryAd
};
} else {
postData = {
'wpEditToken': form.wpEditToken.value,
'mwProtect-level-edit': self.params.edit,
'wpProtectExpirySelection-edit': self.params.expiry != 'indefinite' ? 'othertime' : 'indefinite',
'mwProtect-expiry-edit': self.params.expiry != 'indefinite' ? self.params.expiry : undefined,
'mwProtect-level-move': self.params.move,
'wpProtectExpirySelection-move': self.params.expiry != 'indefinite' ? 'othertime' : 'indefinite',
'mwProtect-expiry-move': self.params.expiry != 'indefinite' ? self.params.expiry : undefined,
'mwProtect-cascade': self.params.cascade ? '' : undefined,
'mwProtectWatch': form.mwProtectWatch.checked ? '' : undefined,
'wpProtectReasonSelection': 'other',
'mwProtect-reason': self.params.reason + TwinkleConfig.protectionSummaryAd
};
}
self.post( postData );
var query = {
'title': wgPageName,
'action': 'submit'
};
if( self.params.create == '' ) {
var wikipedia_wiki = new Wikipedia.wiki( 'Sayfa etiketleniyor', query, twinkleprotect.callbacks.sysop.taggingPage );
wikipedia_wiki.params = self.params;
wikipedia_wiki.get();
}
}
},
user: function( self ) {
var form = self.responseXML.getElementById( 'editform' );
var text = form.wpTextbox1.value;
var ns2tag = {
'0' : 'lmad',
'1' : 'lmadt',
'2' : 'lkul',
'3' : 'lkult',
'4' : 'lvik',
'5' : 'lvikt',
'6' : 'ldos',
'7' : 'ldost',
'8' : 'lmed',
'9' : 'lmedt',
'10': 'lşab',
'11': 'lşabt',
'12': 'lyar',
'13': 'lyart',
'14': 'lkat',
'15': 'lkatt',
'100': 'lpor',
'101': 'lport'
};
var rppRe = new RegExp( '====\\s*\\{\\{\\s*' + ns2tag[ wgNamespaceNumber ] + '\\s*\\|\\s*' + RegExp.escape( wgTitle, true ) + '\\s*\\}\\}\\s*====', 'm' );
var tag = rppRe.exec( text );
if( tag ) {
self.statelem.warn( [ htmlNode( 'strong', tag[0] ) , " zaten sayfaya yerleştirilmiş." ] )
return false;
}
var newtag = '==== \{\{' + ns2tag[ wgNamespaceNumber ] + '|' + wgTitle + '\}\} ====' + "\n";
if( ( new RegExp( '^' + RegExp.escape( newtag ).replace( /\s+/g, '\\s*' ), 'm' ) ).test( text ) ) {
self.statelem.error( 'Bu sayfayla ilgili bir koruma talebi zaten var, işlem durduruluyor.' );
return;
}
var words = [];
switch( self.params.expiry ) {
case 'temporary':
words.push( "Geçici" );
break;
case 'indefinite':
words.push( "Süresiz" );
break;
}
if( self.params.cascade ) {
words.push( "cascading" );
}
words.push( self.params.typename );
newtag += "'''" + words.join( ' ' ) + "'''" + ( self.params.reason != '' ? self.params.reason : '' ) + " \~\~\~\~";
if( self.params.type == 'koruma-kaldırma' ) {
var reg = /(\n==\s*Koruma kaldırma talepleri\s*==\s*\n\s*\{\{[^\}\}]+\}\}\s*\n)/;
} else {
var reg = /(\n==\s*Koruma talepleri\s*==\s*\n\s*\{\{[^\}\}]+\}\}\s*\n)/;
}
var originalTextLength= text.length;
text = text.replace( reg, "$1" + newtag + "\n");
if (text.length==originalTextLength)
{
self.statelem.error( 'VP:SKT sayfasında koruma talebinin nereye eklenmesini gerektiğini belirleyen işaretçi bulunamadı. İşlem durduruluyor ...' );
return;
}
var postData = {
'wpMinoredit': undefined,
'wpWatchthis': form.wpWatchthis.checked ? '' : undefined,
'wpStarttime': form.wpStarttime.value,
'wpEdittime': form.wpEdittime.value,
'wpAutoSummary': form.wpAutoSummary.value,
'wpEditToken': form.wpEditToken.value,
'wpSection': '',
'wpSummary': '[[' + wgPageName.replace(/_/g, ' ') + ']] adlı sayfa için ' + self.params.typename + ' talebinde bulunuluyor.' + TwinkleConfig.summaryAd,
'wpTextbox1': text
};
self.post( postData );
}
}