MediaWiki:Gadget-twinkleprotect1.js
Not: Sayfayı kaydettikten sonra değişiklikleri görebilmek için tarayıcınızın önbelleğinizi temizlemeniz gerekir. Google Chrome, Firefox, Microsoft Edge ve Safari: ⇧ Shift tuşuna basılı tutun ve Yeniden Yükle araç çubuğu düğmesine tıklayın. Ayrıntılar ve diğer tarayıcılara yönelik yönergeler için Vikipedi:Önbelleğinizi atlayın sayfasını inceleyin.
//<nowiki>
(function($){
/*
****************************************
*** twinkleprotect.js: Koruma Modülü
****************************************
* Mode of invocation: Tab ("PP"/"RPP")
* Active on: Non-special pages
* Config directives in: TwinkleConfig
*/
// Note: a lot of code in this module is re-used/called by batchprotect.
Twinkle.protect = function twinkleprotect() {
if ( mw.config.get('wgNamespaceNumber') < 0 ) {
return;
}
Twinkle.addPortletLink(Twinkle.protect.callback, Morebits.userIsInGroup('sysop') ? "Koru" : "Koru", "tw-rpp",
Morebits.userIsInGroup('sysop') ? "Sayfayı koru" : "Sayfanın koruması iste" );
};
Twinkle.protect.callback = function twinkleprotectCallback() {
var Window = new Morebits.simpleWindow( 620, 530 );
Window.setTitle( Morebits.userIsInGroup( 'sysop' ) ? "Sayfayı koru, korunmasını iste veya etiketle" : "Sayfanın korunmasını iste veya etiketle" );
Window.setScriptName( "Twinkle" );
Window.addFooterLink( "Koruma Şablonları", "Kategori:Koruma şablonları" );
Window.addFooterLink( "Koruma Politikası", "Vikipedi:Koruma politikası" );
Window.addFooterLink( "Geri Bildirim", "Vikipedi tartışma:Twinkle" );
var form = new Morebits.quickForm( Twinkle.protect.callback.evaluate );
var actionfield = form.append( {
type: 'field',
label: 'Eylem türü'
} );
if( Morebits.userIsInGroup( 'sysop' ) ) {
actionfield.append( {
type: 'radio',
name: 'actiontype',
event: Twinkle.protect.callback.changeAction,
list: [
{
label: 'Sayfayı koru',
value: 'protect',
tooltip: 'Sayfaya koruma uygulayın.',
checked: true
}
]
} );
}
actionfield.append( {
type: 'radio',
name: 'actiontype',
event: Twinkle.protect.callback.changeAction,
list: [
{
label: 'Koruma şablonu ile etiketle',
value: 'tag',
tooltip: 'Bir hizmetli, sayfayı korumaya aldıysa lakin koruma şablonu eklemeyi unuttuysa veya sayfayı korurken etiketlemeyi unuttuysanız, uygun koruma etiketini eklemek için bunu kullanabilirsiniz.',
disabled: mw.config.get('wgArticleId') === 0
}
]
} );
form.append({ type: 'field', label: 'Ön ayar', name: 'field_preset' });
form.append({ type: 'field', label: '1', name: 'field1' });
form.append({ type: 'field', label: '2', name: 'field2' });
form.append( { type:'submit' } );
var result = form.render();
Window.setContent( result );
Window.display();
// We must init the controls
var evt = document.createEvent( "Event" );
evt.initEvent( 'change', true, true );
result.actiontype[0].dispatchEvent( evt );
Morebits.wiki.actionCompleted.postfix = false; // avoid Action: completed notice
// get current protection level asynchronously
Twinkle.protect.fetchProtectionLevel();
};
// Contains the current protection level in an object
// Once filled, it will look something like:
// { edit: { level: "sysop", expiry: <some date>, cascade: true }, ... }
Twinkle.protect.currentProtectionLevels = {};
Twinkle.protect.fetchProtectionLevel = function twinkleprotectFetchProtectionLevel() {
var api = new mw.Api();
var protectDeferred = api.get({
format: 'json',
indexpageids: true,
action: 'query',
list: 'logevents',
letype: 'protect',
letitle: mw.config.get('wgPageName'),
prop: 'info|flagged',
inprop: 'protection',
titles: mw.config.get('wgPageName')
});
var stableDeferred = api.get({
format: 'json',
action: 'query',
list: 'logevents',
letype: 'stable',
letitle: mw.config.get('wgPageName')
});
$.when.apply($, [protectDeferred, stableDeferred]).done(function(protectData, stableData){
var pageid = protectData[0].query.pageids[0];
var page = protectData[0].query.pages[pageid];
var current = {};
$.each(page.protection, function( index, protection ) {
if (protection.type !== "aft") {
current[protection.type] = {
level: protection.level,
expiry: protection.expiry,
cascade: protection.cascade === ''
};
}
});
if (page.flagged) {
current.stabilize = {
level: page.flagged.protection_level,
expiry: page.flagged.protection_expiry
};
}
// show the protection level and log info
Twinkle.protect.hasProtectLog = !!protectData[0].query.logevents.length;
Twinkle.protect.hasStableLog = !!stableData[0].query.logevents.length;
Twinkle.protect.currentProtectionLevels = current;
Twinkle.protect.callback.showLogAndCurrentProtectInfo();
});
};
Twinkle.protect.callback.showLogAndCurrentProtectInfo = function twinkleprotectCallbackShowLogAndCurrentProtectInfo() {
var currentlyProtected = !$.isEmptyObject(Twinkle.protect.currentProtectionLevels);
if (Twinkle.protect.hasProtectLog || Twinkle.protect.hasStableLog) {
var $linkMarkup = $("<span>");
if (Twinkle.protect.hasProtectLog)
$linkMarkup.append(
$( '<a target="_blank" href="' + mw.util.getUrl('Special:Log', {action: 'view', page: mw.config.get('wgPageName'), type: 'protect'}) + '">koruma günlüğü</a>' ),
Twinkle.protect.hasStableLog ? $("<span> • </span>") : null
);
if (Twinkle.protect.hasStableLog)
$linkMarkup.append($( '<a target="_blank" href="' + mw.util.getUrl('Special:Log', {action: 'view', page: mw.config.get('wgPageName'), type: 'stable'}) + '">pending changes log</a>)' ));
Morebits.status.init($('div[name="hasprotectlog"] span')[0]);
Morebits.status.warn(
currentlyProtected ? 'Önceki korumalar' : 'Bu sayfa geçmişte korundu',
$linkMarkup[0]
);
}
Morebits.status.init($('div[name="currentprot"] span')[0]);
var protectionNode = [], statusLevel = 'info';
if (currentlyProtected) {
$.each(Twinkle.protect.currentProtectionLevels, function(type, settings) {
var label = type === 'stabilize' ? 'Pending Changes' : Morebits.string.toUpperCaseFirstChar(type);
protectionNode.push($("<b>" + label + ": " + settings.level + "</b>")[0]);
if (settings.expiry === 'infinity') {
protectionNode.push(" (sonsuz) ");
} else {
protectionNode.push(" (bitiyor: " + new Date(settings.expiry).toUTCString() + ") ");
}
if (settings.cascade) {
protectionNode.push("(basamaklı) ");
}
});
statusLevel = 'warn';
} else {
protectionNode.push($("<b>koruma yok</b>")[0]);
}
Morebits.status[statusLevel]("Geçerli koruma düzeyi", protectionNode);
};
Twinkle.protect.callback.changeAction = function twinkleprotectCallbackChangeAction(e) {
var field_preset;
var field1;
var field2;
var isTemplate = mw.config.get("wgNamespaceNumber") === 10 || mw.config.get("wgNamespaceNumber") === 828;
switch (e.target.values) {
case 'protect':
field_preset = new Morebits.quickForm.element({ type: 'field', label: 'Ön ayar', name: 'field_preset' });
field_preset.append({
type: 'select',
name: 'category',
label: 'Bir ön ayar seçin:',
event: Twinkle.protect.callback.changePreset,
list: (mw.config.get('wgArticleId') ?
Twinkle.protect.protectionTypes.filter(function(v) {
return isTemplate || v.label !== 'Template protection';
}) :
Twinkle.protect.protectionTypesCreate)
});
field2 = new Morebits.quickForm.element({ type: 'field', label: 'Koruma ayarları', name: 'field2' });
field2.append({ type: 'div', name: 'currentprot', label: ' ' }); // holds the current protection level, as filled out by the async callback
field2.append({ type: 'div', name: 'hasprotectlog', label: ' ' });
// for existing pages
if (mw.config.get('wgArticleId')) {
field2.append({
type: 'checkbox',
name: 'editmodify',
event: Twinkle.protect.formevents.editmodify,
list: [
{
label: 'Düzenleme koruması',
value: 'editmodify',
tooltip: 'Bu kapalıysa, düzenleme koruması değiştirilmeden olduğu gibi bırakılır.',
checked: true
}
]
});
var editlevel = field2.append({
type: 'select',
name: 'editlevel',
label: 'Düzenleme koruması:',
event: Twinkle.protect.formevents.editlevel
});
editlevel.append({
type: 'option',
label: 'Herkes',
value: 'all'
});
editlevel.append({
type: 'option',
label: 'Kayıtlı kullanıcılar',
value: 'autoconfirmed'
});
editlevel.append({
type: 'option',
label: 'Bunu seçme, bozuk',
value: 'extendedconfirmed'
});
if (isTemplate) {
editlevel.append({
type: 'option',
label: 'Bunu seçme, bozuk',
value: 'templateeditor'
});
}
editlevel.append({
type: 'option',
label: 'Hizmetli',
value: 'sysop',
selected: true
});
field2.append({
type: 'select',
name: 'editexpiry',
label: 'Bitiş:',
event: function(e) {
if (e.target.value === 'custom') {
Twinkle.protect.doCustomExpiry(e.target);
}
},
// default expiry selection is conditionally set in Twinkle.protect.callback.changePreset
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: '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: '1 yıl', value: '1 year' },
{ label: 'Sınırsız', value:'indefinite' },
{ label: 'Özel...', value: 'custom' }
]
});
field2.append({
type: 'checkbox',
name: 'movemodify',
event: Twinkle.protect.formevents.movemodify,
list: [
{
label: 'Taşıma koruması',
value: 'movemodify',
tooltip: 'Bu kapalıysa, düzenleme koruması değiştirilmeden olduğu gibi bırakılır.',
checked: true
}
]
});
var movelevel = field2.append({
type: 'select',
name: 'movelevel',
label: 'Taşıma koruması:',
event: Twinkle.protect.formevents.movelevel
});
movelevel.append({
type: 'option',
label: 'Herkes',
value: 'all'
});
movelevel.append({
type: 'option',
label: 'Kayıtlı kullanıcılar',
value: 'autoconfirmed'
});
movelevel.append({
type: 'option',
label: 'Bunu seçme, bozuk',
value: 'extendedconfirmed'
});
if (isTemplate) {
movelevel.append({
type: 'option',
label: 'Bunu seçme, bozuk',
value: 'templateeditor'
});
}
movelevel.append({
type: 'option',
label: 'Hizmetli',
value: 'sysop',
selected: true
});
field2.append({
type: 'select',
name: 'moveexpiry',
label: 'Bitiş:',
event: function(e) {
if (e.target.value === 'custom') {
Twinkle.protect.doCustomExpiry(e.target);
}
},
// default expiry selection is conditionally set in Twinkle.protect.callback.changePreset
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: '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: '1 yıl', value: '1 year' },
{ label: 'Sınırsız', value: 'indefinite' },
{ label: 'Özel...', value: 'custom' }
]
});
field2.append({
type: 'checkbox',
name: 'pcmodify',
event: Twinkle.protect.formevents.pcmodify,
list: [
{
label: 'Lütfen bu seçeneği kapalı tutun.',
value: 'pcmodify',
tooltip: 'Kapalı tutun, Türkçe Vikipedi ye uyumlu değildir.',
checked: true
}
]
});
var pclevel = field2.append({
type: 'select',
name: 'pclevel',
label: '',
event: Twinkle.protect.formevents.pclevel
});
pclevel.append({
type: 'option',
label: 'None',
value: 'none'
});
field2.append({
type: 'select',
name: 'pcexpiry',
label: 'Bitiş:',
event: function(e) {
if (e.target.value === 'custom') {
Twinkle.protect.doCustomExpiry(e.target);
}
},
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: '1 hafta', value: '1 week' },
{ label: '2 hafta', value: '2 weeks' },
{ label: '1 ay', selected: true, value: '1 month' },
{ label: '2 ay', value: '2 months' },
{ label: '3 ay', value: '3 months' },
{ label: '1 yıl', value: '1 year' },
{ label: 'Sınırsız', value:'indefinite' },
{ label: 'Özel...', value: 'custom' }
]
});
} else { // for non-existing pages
var createlevel = field2.append({
type: 'select',
name: 'createlevel',
label: 'Oluşturma koruması:',
event: Twinkle.protect.formevents.createlevel
});
createlevel.append({
type: 'option',
label: 'Herkes',
value: 'all'
});
createlevel.append({
type: 'option',
label: 'Kayıtlı kullanıcılar',
value: 'autoconfirmed'
});
if (isTemplate) {
createlevel.append({
type: 'option',
label: 'Bunu seçme, bozuk',
value: 'templateeditor'
});
}
createlevel.append({
type: 'option',
label: 'Bunu seçme, bozuk',
value: 'extendedconfirmed',
selected: true
});
createlevel.append({
type: 'option',
label: 'Hizmetli',
value: 'sysop'
});
field2.append({
type: 'select',
name: 'createexpiry',
label: 'Bitiş:',
event: function(e) {
if (e.target.value === 'custom') {
Twinkle.protect.doCustomExpiry(e.target);
}
},
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: '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: '1 yıl', value: '1 year' },
{ label: 'Sınırsız', selected: true, value: 'indefinite' },
{ label: 'Özel...', value: 'custom' }
]
});
}
field2.append({
type: 'textarea',
name: 'protectReason',
label: 'Sebep (koruma günlüğü için):'
});
if (!mw.config.get('wgArticleId')) { // tagging isn't relevant for non-existing pages
break;
}
/* falls through */
case 'tag':
field1 = new Morebits.quickForm.element({ type: 'field', label: 'Etiketleme ayarları', name: 'field1' });
field1.append({ type: 'div', name: 'currentprot', label: ' ' }); // holds the current protection level, as filled out by the async callback
field1.append({ type: 'div', name: 'hasprotectlog', label: ' ' });
field1.append( {
type: 'select',
name: 'tagtype',
label: 'Bir koruma şablonu seçin:',
list: Twinkle.protect.protectionTags,
event: Twinkle.protect.formevents.tagtype
} );
field1.append( {
type: 'checkbox',
list: [
{
name: 'small',
label: 'İkon hâlinde ekle (küçük=evet)',
tooltip: 'Şablonu |küçük=evet ile oluşturur ve böylece şablon sadece ikon olarak gözükür',
checked: true
},
{
name: 'noinclude',
label: 'Şablonu <noinclude> ile ekleyin',
tooltip: 'Koruma şablonunu <noinclude> etiketine sarar, böylece bir şablonu koruduğunuzda; koruma şablonu, korunan şablonun kullanıldığı sayfalarda gözükmez.',
checked: (mw.config.get('wgNamespaceNumber') === 10)
}
]
} );
break;
case 'request':
field_preset = new Morebits.quickForm.element({ type: 'field', label: 'Koruma türü', name: 'field_preset' });
field_preset.append({
type: 'select',
name: 'category',
label: 'Tür ve sebep:',
event: Twinkle.protect.callback.changePreset,
list: (mw.config.get('wgArticleId') ? Twinkle.protect.protectionTypes : Twinkle.protect.protectionTypesCreate)
});
field1 = new Morebits.quickForm.element({ type: 'field', label: 'Ayarlar', name: 'field1' });
field1.append({ type: 'div', name: 'currentprot', label: ' ' }); // holds the current protection level, as filled out by the async callback
field1.append({ type: 'div', name: 'hasprotectlog', label: ' ' });
field1.append( {
type: 'select',
name: 'expiry',
label: 'Süre: ',
list: [
{ label: 'Geçici', value: 'temporary' },
{ label: 'Sonsuz', value: 'indefinite' },
{ label: '', selected: true, value: '' }
]
} );
field1.append({
type: 'textarea',
name: 'reason',
label: 'Sebep: '
});
break;
default:
alert("twinkleprotect'te bir sorun var");
break;
}
var oldfield;
if (field_preset) {
oldfield = $(e.target.form).find('fieldset[name="field_preset"]')[0];
oldfield.parentNode.replaceChild(field_preset.render(), oldfield);
} else {
$(e.target.form).find('fieldset[name="field_preset"]').css('display', 'none');
}
if (field1) {
oldfield = $(e.target.form).find('fieldset[name="field1"]')[0];
oldfield.parentNode.replaceChild(field1.render(), oldfield);
} else {
$(e.target.form).find('fieldset[name="field1"]').css('display', 'none');
}
if (field2) {
oldfield = $(e.target.form).find('fieldset[name="field2"]')[0];
oldfield.parentNode.replaceChild(field2.render(), oldfield);
} else {
$(e.target.form).find('fieldset[name="field2"]').css('display', 'none');
}
if (e.target.values === 'protect') {
// fake a change event on the preset dropdown
var evt = document.createEvent( "Event" );
evt.initEvent( 'change', true, true );
e.target.form.category.dispatchEvent( evt );
// reduce vertical height of dialog
$(e.target.form).find('fieldset[name="field2"] select').parent().css({ display: 'inline-block', marginRight: '0.5em' });
}
// re-add protection level and log info, if it's available
Twinkle.protect.callback.showLogAndCurrentProtectInfo();
};
Twinkle.protect.formevents = {
editmodify: function twinkleprotectFormEditmodifyEvent(e) {
e.target.form.editlevel.disabled = !e.target.checked;
e.target.form.editexpiry.disabled = !e.target.checked || (e.target.form.editlevel.value === 'all');
e.target.form.editlevel.style.color = e.target.form.editexpiry.style.color = (e.target.checked ? "" : "transparent");
},
editlevel: function twinkleprotectFormEditlevelEvent(e) {
e.target.form.editexpiry.disabled = (e.target.value === 'all');
},
movemodify: function twinkleprotectFormMovemodifyEvent(e) {
// sync move settings with edit settings if applicable
if (e.target.form.movelevel.disabled && !e.target.form.editlevel.disabled) {
e.target.form.movelevel.value = e.target.form.editlevel.value;
e.target.form.moveexpiry.value = e.target.form.editexpiry.value;
} else if (e.target.form.editlevel.disabled) {
e.target.form.movelevel.value = 'sysop';
e.target.form.moveexpiry.value = 'indefinite';
}
e.target.form.movelevel.disabled = !e.target.checked;
e.target.form.moveexpiry.disabled = !e.target.checked || (e.target.form.movelevel.value === 'all');
e.target.form.movelevel.style.color = e.target.form.moveexpiry.style.color = (e.target.checked ? "" : "transparent");
},
movelevel: function twinkleprotectFormMovelevelEvent(e) {
e.target.form.moveexpiry.disabled = (e.target.value === 'all');
},
pcmodify: function twinkleprotectFormPcmodifyEvent(e) {
e.target.form.pclevel.disabled = !e.target.checked;
e.target.form.pcexpiry.disabled = !e.target.checked || (e.target.form.pclevel.value === 'none');
e.target.form.pclevel.style.color = e.target.form.pcexpiry.style.color = (e.target.checked ? "" : "transparent");
},
pclevel: function twinkleprotectFormPclevelEvent(e) {
e.target.form.pcexpiry.disabled = (e.target.value === 'none');
},
createlevel: function twinkleprotectFormCreatelevelEvent(e) {
e.target.form.createexpiry.disabled = (e.target.value === 'all');
},
tagtype: function twinkleprotectFormTagtypeEvent(e) {
e.target.form.small.disabled = e.target.form.noinclude.disabled = (e.target.value === 'none') || (e.target.value === 'noop');
}
};
Twinkle.protect.doCustomExpiry = function twinkleprotectDoCustomExpiry(target) {
var custom = prompt('Enter a custom expiry time. \nYou can use relative times, like "1 minute" or "19 days", or absolute timestamps, "yyyymmddhhmm" (e.g. "200602011405" is Feb 1, 2006, at 14:05 UTC).', '');
if (custom) {
var option = document.createElement('option');
option.setAttribute('value', custom);
option.textContent = custom;
target.appendChild(option);
target.value = custom;
} else {
target.selectedIndex = 0;
}
};
Twinkle.protect.protectionTypes = [
{ label: 'Korumayı kaldır', value: 'unprotect' },
{
label: 'Tam koruma',
list: [
{ label: 'Genel (tam)', value: 'koruma' },
{ label: 'İçerik anlaşmazlığı / değişiklik savaşı (tam)', value: 'koruma-anlaşmazlık' },
{ label: 'Sürekli vandalizm (tam)', value: 'koruma-vandalizm' },
{ label: 'Engellenen kullanıcının mesaj sayfası (tam)', value: 'koruma-mesaj' }
]
},
{
label: 'Şablon koruması',
list: [
{ label: 'Çok sayfada kullanılan şablon', value: 'koruma-şablon' }
]
},
{
label: 'Yarı Koruma',
list: [
{ label: 'Genel (yarı)', value: 'pp-semi-protected' },
{ label: 'Sürekli vandalizm (yarı)', selected: true, value: 'koruma-yarı-vandalizm' },
{ label: 'Zararlı düzenlemeler (yarı)', value: 'pp-semi-disruptive' },
{ label: 'Kaynaksız içerik ekleme (yarı)', value: 'pp-semi-unsourced' },
{ label: '3GD politikası ihlali (yarı)', value: 'koruma-yarı-yib' },
{ label: 'Kuklacılık (yarı)', value: 'pp-semi-sock' },
{ label: 'Engellenen kullanıcının mesaj sayfası (yarı)', value: 'koruma-yarı-mesaj' }
]
},
{
label: 'Taşıma koruması',
list: [
{ label: 'Genel (taşı)', value: 'koruma-taşıma' },
{ label: 'Tartışma/taşıma savaşı (taşı)', value: 'koruma-taşıma-anlaşmazlık' },
{ label: 'Sayfa taşıma vandalizmi (move)', value: 'koruma-taşıma-vandalizm' },
{ label: 'Yüksek trafikli sayfa (taşı)', value: 'koruma-taşıma-süresiz' }
]
}
];
Twinkle.protect.protectionTypesCreate = [
{ label: 'Korumayı kaldır', value: 'unprotect' },
{
label: 'Oluşturma koruması',
list: [
{ label: 'Genel ({{koruma-oluşturma}})', value: 'koruma-oluşturma' },
{ label: 'Rahatsız edici isim', value: 'pp-create-offensive' },
{ label: 'Israrla oluşturma', selected: true, value: 'pp-create-salt' },
]
}
];
// A page with both regular and PC protection will be assigned its regular
// protection weight plus 2 (for PC1) or 7 (for PC2)
Twinkle.protect.protectionWeight = {
sysop: 40,
templateeditor: 30,
extendedconfirmed: 20,
flaggedrevs_review: 15, // Pending Changes level 2 protection alone
autoconfirmed: 10,
flaggedrevs_autoconfirmed: 5, // Pending Changes level 1 protection alone
all: 0,
flaggedrevs_none: 0 // just in case
};
// NOTICE: keep this synched with [[MediaWiki:Protect-dropdown]]
// Also note: stabilize = Pending Changes level
Twinkle.protect.protectionPresetsInfo = {
'koruma': {
edit: 'sysop',
move: 'sysop',
reason: null
},
'koruma-anlaşmazlık': {
edit: 'sysop',
move: 'sysop',
reason: '[[Vikipedi:Değişiklik savaşı|Değişiklik savaşı]]'
},
'koruma-vandalizm': {
edit: 'sysop',
move: 'sysop',
reason: 'Devamlı [[Vikipedi:Vandalizm|Vandalizm]]'
},
'koruma-mesaj': {
edit: 'sysop',
move: 'sysop',
reason: 'Engelliyken kullanıcı mesaj sayfasının uygunsuz kullanımı'
},
'koruma-şablon': {
edit: 'autoconfirmed',
move: 'autoconfirmed',
reason: '[[Vikipedi:Yüksek riskli şablonlar|Yüksek riskli şablon]]'
},
'koruma-yarı-vandalizm': {
edit: 'autoconfirmed',
reason: 'Devamlı [[Vikipedi:Vandalizm|Vandalizm]]',
template: 'koruma-vandalizm'
},
'pp-semi-disruptive': {
edit: 'autoconfirmed',
reason: 'Sürekli zararlı değişiklikler',
template: 'koruma'
},
'pp-semi-unsourced': {
edit: 'autoconfirmed',
reason: 'Sürekli kaynaksız veya yetersiz kaynaklı içeriğin eklenmesi',
template: 'koruma'
},
'koruma-yarı-yib': {
edit: 'autoconfirmed',
reason: '[[VP:YİB|VP:YİB]] ihlali',
template: 'koruma-yarı-yib'
},
'koruma-yarı-mesaj': {
edit: 'autoconfirmed',
move: 'autoconfirmed',
reason: 'Engelliyken kullanıcı mesaj sayfasının uygunsuz kullanımı',
template: 'koruma-mesaj'
},
'koruma-yarı-şablon': { // removed for now
edit: 'autoconfirmed',
move: 'autoconfirmed',
reason: '[[Vikipedi:Yüksek riskli şablonlar|Yüksek riskli şablon]]',
template: 'koruma-şablon'
},
'pp-semi-sock': {
edit: 'autoconfirmed',
reason: 'Sürekli [[Vikipedi:Kukla|kukla]] kullanımı',
template: 'koruma'
},
'koruma-yarı': {
edit: 'autoconfirmed',
reason: null,
template: 'koruma'
},
'koruma-taşıma': {
move: 'sysop',
reason: null
},
'koruma-taşıma-anlaşmazlık': {
move: 'sysop',
reason: null
},
'koruma-taşıma-vandalizm': {
move: 'sysop',
reason: 'sayfa taşıma vandalizmi'
},
'koruma-taşıma-süresiz': {
move: 'sysop',
reason: 'Yüksek trafiğe sahip sayfa'
},
'unprotect': {
edit: 'all',
move: 'all',
stabilize: 'none',
create: 'all',
reason: null,
template: 'none'
},
'pp-create-offensive': {
create: 'sysop',
reason: 'Rahatsızlık verici ad'
},
'pp-create-salt': {
create: 'autoconfirmed',
reason: 'Sürekli yenden oluşturma'
},
'koruma-oluşturma': {
create: 'autoconfirmed',
reason: '{{koruma-oluşturma}}'
}
};
Twinkle.protect.protectionTags = [
{
label: 'Yok (mevcut koruma şablonlarını kaldırın)',
value: 'none'
},
{
label: 'Yok (mevcut koruma şablonlarını kaldırmayın)',
value: 'noop'
},
{
label: 'Değişiklik Koruma Şablonları',
list: [
{ label: '{{koruma-vandalizm}}: vandalizm', value: 'koruma-vandalizm' },
{ label: '{{koruma-anlaşmazlık}}: düzenleme savaşı', value: 'koruma-anlaşmazlık', selected: true },
{ label: '{{koruma-şablon}}: yüksek trafiğe sahip şablon', value: 'koruma-şablon' },
{ label: '{{koruma-mesaj}}: engellenmiş kullanıcının mesaj sayfası', value: 'koruma-mesaj' },
{ label: '{{koruma}}: genel koruma', value: 'koruma' }
]
},
{
label: 'Taşıma Koruma Şablonları',
list: [
{ label: '{{koruma-taşıma-anlaşmazlık}}: düzenleme savaşı', value: 'koruma-taşıma-anlaşmazlık' },
{ label: '{{koruma-taşıma-vandalizm}}: sayfa taşıma vandalizmi', value: 'koruma-taşıma-vandalizm' },
{ label: '{{koruma-taşıma-süresiz}}: süresiz genel taşıma', value: 'koruma-taşıma-süresiz' },
{ label: '{{koruma-taşıma}}: diğer', value: 'koruma-taşıma' }
]
}
];
Twinkle.protect.callback.changePreset = function twinkleprotectCallbackChangePreset(e) {
var form = e.target.form;
var actiontypes = form.actiontype;
var actiontype;
for( var i = 0; i < actiontypes.length; i++ )
{
if( !actiontypes[i].checked ) {
continue;
}
actiontype = actiontypes[i].values;
break;
}
if (actiontype === 'protect') { // actually protecting the page
var item = Twinkle.protect.protectionPresetsInfo[form.category.value];
if (mw.config.get('wgArticleId')) {
if (item.edit) {
form.editmodify.checked = true;
Twinkle.protect.formevents.editmodify({ target: form.editmodify });
form.editlevel.value = item.edit;
Twinkle.protect.formevents.editlevel({ target: form.editlevel });
form.editexpiry.value = '2 days';
} else {
form.editmodify.checked = false;
Twinkle.protect.formevents.editmodify({ target: form.editmodify });
}
if (item.move) {
form.movemodify.checked = true;
Twinkle.protect.formevents.movemodify({ target: form.movemodify });
form.movelevel.value = item.move;
Twinkle.protect.formevents.movelevel({ target: form.movelevel });
form.moveexpiry.value = '2 days';
} else {
form.movemodify.checked = false;
Twinkle.protect.formevents.movemodify({ target: form.movemodify });
}
if (item.stabilize) {
form.pcmodify.checked = true;
Twinkle.protect.formevents.pcmodify({ target: form.pcmodify });
form.pclevel.value = item.stabilize;
Twinkle.protect.formevents.pclevel({ target: form.pclevel });
} else {
form.pcmodify.checked = false;
Twinkle.protect.formevents.pcmodify({ target: form.pcmodify });
}
} else {
if (item.create) {
form.createlevel.value = item.create;
Twinkle.protect.formevents.createlevel({ target: form.createlevel });
}
}
var reasonField = (actiontype === "protect" ? form.protectReason : form.reason);
if (item.reason) {
reasonField.value = item.reason;
} else {
reasonField.value = '';
}
// sort out tagging options
if (mw.config.get('wgArticleId')) {
if( form.category.value === 'unprotect' ) {
form.tagtype.value = 'none';
} else {
form.tagtype.value = (item.template ? item.template : form.category.value);
}
Twinkle.protect.formevents.tagtype({ target: form.tagtype });
if( /template/.test( form.category.value ) ) {
form.noinclude.checked = true;
form.editexpiry.value = form.moveexpiry.value = form.pcexpiry.value = "indefinite";
} else if( mw.config.get('wgNamespaceNumber') !== 10 ) {
form.noinclude.checked = false;
}
}
} else { // RPP request
if( form.category.value === 'unprotect' ) {
form.expiry.value = '';
form.expiry.disabled = true;
} else {
form.expiry.value = '';
form.expiry.disabled = false;
}
}
};
Twinkle.protect.callback.evaluate = function twinkleprotectCallbackEvaluate(e) {
var form = e.target;
var actiontypes = form.actiontype;
var actiontype;
for( var i = 0; i < actiontypes.length; i++ )
{
if( !actiontypes[i].checked ) {
continue;
}
actiontype = actiontypes[i].values;
break;
}
var tagparams;
if( actiontype === 'tag' || (actiontype === 'protect' && mw.config.get('wgArticleId')) ) {
tagparams = {
tag: form.tagtype.value,
reason: ((form.tagtype.value === 'koruma' || form.tagtype.value === 'koruma-yarı' || form.tagtype.value === 'koruma-taşıma') && form.protectReason) ? form.protectReason.value : null,
expiry: (actiontype === 'protect') ?
(form.editmodify.checked ? form.editexpiry.value :
(form.movemodify.checked ? form.moveexpiry.value :
(form.pcmodify.checked ? form.pcexpiry.value : null)
)
) : null,
small: form.small.checked,
noinclude: form.noinclude.checked
};
}
switch (actiontype) {
case 'protect':
// protect the page
Morebits.wiki.actionCompleted.redirect = mw.config.get('wgPageName');
Morebits.wiki.actionCompleted.notice = "Koruma tamamlandı";
var statusInited = false;
var thispage;
var allDone = function twinkleprotectCallbackAllDone() {
if (thispage) {
thispage.getStatusElement().info("done");
}
if (tagparams) {
Twinkle.protect.callbacks.taggingPageInitial(tagparams);
}
};
var stabilizeValues = {};
if (form.pclevel) {
stabilizeValues = {
pclevel: form.pclevel.value,
pcexpiry: form.pcexpiry.value,
protectReason: form.protectReason.value
};
}
var protectIt = function twinkleprotectCallbackProtectIt(next) {
thispage = new Morebits.wiki.page(mw.config.get('wgPageName'), "Sayfa korunuyor");
if (mw.config.get('wgArticleId')) {
if (form.editmodify.checked) {
thispage.setEditProtection(form.editlevel.value, form.editexpiry.value);
}
if (form.movemodify.checked) {
thispage.setMoveProtection(form.movelevel.value, form.moveexpiry.value);
}
} else {
thispage.setCreateProtection(form.createlevel.value, form.createexpiry.value);
thispage.setWatchlist(false);
}
if (form.protectReason.value) {
thispage.setEditSummary(form.protectReason.value);
} else {
alert("Koruma günlüğüne yazılması için bir koruma nedeni girmelisiniz.");
return;
}
if (!statusInited) {
Morebits.simpleWindow.setButtonsEnabled( false );
Morebits.status.init( form );
statusInited = true;
}
thispage.protect(next);
};
var stabilizeIt = function twinkleprotectCallbackStabilizeIt() {
if (thispage) {
thispage.getStatusElement().info("done");
}
thispage = new Morebits.wiki.page(mw.config.get('wgPageName'), "Applying pending changes protection");
thispage.setFlaggedRevs(stabilizeValues.pclevel, stabilizeValues.pcexpiry);
if (stabilizeValues.protectReason) {
thispage.setEditSummary(stabilizeValues.protectReason);
} else {
alert("Koruma günlüğüne yazılması için bir koruma nedeni girmelisiniz.");
return;
}
if (!statusInited) {
Morebits.simpleWindow.setButtonsEnabled(false);
Morebits.status.init(form);
statusInited = true;
}
thispage.stabilize(allDone);
};
if ((form.editmodify && form.editmodify.checked) || (form.movemodify && form.movemodify.checked) ||
!mw.config.get('wgArticleId')) {
if (form.pcmodify && form.pcmodify.checked) {
protectIt(stabilizeIt);
} else {
protectIt(allDone);
}
} else if (form.pcmodify && form.pcmodify.checked) {
stabilizeIt();
} else {
alert("Lütfen Twinkle'a bir şeyler verin! Yalnızca sayfayı etiketlemek istiyorsanız, üst kısımdaki 'Koruma şablonu ile etiketle' seçeneğini belirleyebilirsiniz.");
}
break;
case 'tag':
// apply a protection template
Morebits.simpleWindow.setButtonsEnabled( false );
Morebits.status.init( form );
Morebits.wiki.actionCompleted.redirect = mw.config.get('wgPageName');
Morebits.wiki.actionCompleted.followRedirect = false;
Morebits.wiki.actionCompleted.notice = "Etiketleme tamamlandı";
Twinkle.protect.callbacks.taggingPageInitial(tagparams);
break;
case 'request':
// file request at RFPP
var typename, typereason;
switch( form.category.value ) {
case 'koruma-anlaşmazlık':
case 'koruma-vandalizm':
case 'koruma-mesaj':
case 'koruma':
typename = 'tam koruma';
break;
case 'koruma-şablon':
typename = 'şablon koruması';
break;
case 'koruma-yarı-vandalizm':
case 'pp-semi-disruptive':
case 'pp-semi-unsourced':
case 'koruma-yarı-mesaj':
case 'pp-semi-sock':
case 'koruma-yarı-yib':
case 'koruma-yarı':
typename = 'yarı koruma';
break;
case 'koruma-taşıma':
case 'koruma-taşıma-anlaşmazlık':
case 'koruma-taşıma-süresiz':
case 'koruma-taşıma-vandalizm':
typename = 'taşıma koruması';
break;
case 'koruma-oluşturma':
case 'pp-create-offensive':
case 'pp-create-salt':
typename = 'oluşturma koruması';
break;
case 'unprotect':
/* falls through */
default:
typename = 'koruma kaldırma';
break;
}
switch (form.category.value) {
case 'koruma-anlaşmazlık':
typereason = 'İçerik anlaşmazlığı/düzenleme savaşı';
break;
case 'koruma-vandalizm':
case 'koruma-yarı-vandalizm':
typereason = 'Israrlı [[VP:Vandal]]';
break;
case 'pp-semi-disruptive':
typereason = 'Israrlı zarar verici düzenleme';
break;
case 'pp-semi-unsourced':
typereason = 'Kaynaksız veya yetersiz kaynaklı içeriğin eklenmesi';
break;
case 'koruma-şablon':
typereason = '[[Vikipedi:Yüksek riskli şablonlar|Yüksek riskli şablon]]';
break;
case 'koruma-mesaj':
case 'koruma-yarı-mesaj':
typereason = 'Engelliyken kullanıcı konuşma sayfasının uygunsuz kullanımı';
break;
case 'pp-semi-sock':
typereason = 'Israrlı kukla kullanımı';
break;
case 'koruma-yarı-yib':
typereason = '[[VP:YİB]] ihlali';
break;
case 'koruma-taşıma-anlaşmazlık':
typereason = 'Sayfa başlığı anlaşmazlığı/taşıma savaşı';
break;
case 'koruma-taşıma-vandalizm':
typereason = 'Sayfa taşıma vandalizmi';
break;
case 'koruma-taşıma-süresiz':
typereason = 'Yüksek trafiğe sahip sayfa';
break;
case 'pp-create-offensive':
typereason = 'Rahatsız edici ad';
break;
case 'pp-create-salt':
typereason = 'Defalarca tekrar oluşturma';
break;
default:
typereason = '';
break;
}
var reason = typereason;
if( form.reason.value !== '') {
if ( typereason !== '' ) {
reason += "\u00A0\u2013 "; // U+00A0 NO-BREAK SPACE; U+2013 EN RULE
}
reason += form.reason.value;
}
if( reason !== '' && reason.charAt( reason.length - 1 ) !== '.' ) {
reason += '.';
}
var rppparams = {
reason: reason,
typename: typename,
category: form.category.value,
expiry: form.expiry.value
};
Morebits.simpleWindow.setButtonsEnabled( false );
Morebits.status.init( form );
var rppName = 'Vikipedi:Sayfa koruma talepleri';
// Updating data for the action completed event
Morebits.wiki.actionCompleted.redirect = rppName;
Morebits.wiki.actionCompleted.notice = "Adaylık tamamlandı, şimdi tartışma sayfasına yönlendiriliyor";
var rppPage = new Morebits.wiki.page( rppName, 'Sayfa koruması isteniyor');
rppPage.setFollowRedirect( true );
rppPage.setCallbackParameters( rppparams );
rppPage.load( Twinkle.protect.callbacks.fileRequest );
break;
default:
alert("twinkleprotect: bilinmeyen bir eylem türü");
break;
}
};
Twinkle.protect.callbacks = {
taggingPageInitial: function( tagparams ) {
if (tagparams.tag === 'noop') {
Morebits.status.info("Koruma şablonunu uygulanıyor", "yapacak bir şey yok");
return;
}
var protectedPage = new Morebits.wiki.page( mw.config.get('wgPageName'), 'Sayfa etiketleniyor');
protectedPage.setCallbackParameters( tagparams );
protectedPage.load( Twinkle.protect.callbacks.taggingPage );
},
taggingPage: function( protectedPage ) {
var params = protectedPage.getCallbackParameters();
var text = protectedPage.getPageText();
var tag, summary;
var oldtag_re = /\s*(?:<noinclude>)?\s*\{\{\s*(pp-[^{}]*?|protected|(?:t|v|s|p-|usertalk-v|usertalk-s|sb|move)protected(?:2)?|protected template|privacy protection)\s*?\}\}\s*(?:<\/noinclude>)?\s*/gi;
var re_result = oldtag_re.exec(text);
if (re_result) {
if (confirm("{{" + re_result[1] + "}} sayfada bulundu. \nKaldırmak için Tamama veya orada bırakmak için İptale tıklayın.")) {
text = text.replace( oldtag_re, '' );
}
}
if ( params.tag !== 'none' ) {
tag = params.tag;
if( params.reason ) {
tag += '|reason=' + params.reason;
}
if( ['indefinite', 'infinite', 'never', null].indexOf(params.expiry) === -1 ) {
tag += '|bitiş={{subst:#time:H:i, j F Y|' + (/^\s*\d+\s*$/.exec(params.expiry) ? params.expiry : '+' + params.expiry) + '}}';
}
if( params.small ) {
tag += '|küçük=evet';
}
}
if( params.tag === 'none' ) {
summary = 'Koruma şablonunu kaldırılıyor' + Twinkle.getPref('summaryAd');
} else {
if( params.noinclude ) {
text = "<noinclude>{{" + tag + "}}</noinclude>" + text;
} else if( Morebits.wiki.isPageRedirect() ) {
text = text + "\n{{" + tag + "}}";
} else {
text = "{{" + tag + "}}\n" + text;
}
summary = "{{" + params.tag + "}} ekleniyor" + Twinkle.getPref('summaryAd');
}
protectedPage.setEditSummary( summary );
protectedPage.setPageText( text );
protectedPage.setCreateOption( 'nocreate' );
protectedPage.suppressProtectWarning(); // no need to let admins know they are editing through protection
protectedPage.save();
},
fileRequest: function( rppPage ) {
var params = rppPage.getCallbackParameters();
var text = rppPage.getPageText();
var statusElement = rppPage.getStatusElement();
var rppRe = new RegExp( '===\\s*(\\[\\[)?\\s*:?\\s*' + RegExp.escape( Morebits.pageNameNorm, true ) + '\\s*(\\]\\])?\\s*===', 'm' );
var tag = rppRe.exec( text );
var rppLink = document.createElement('a');
rppLink.setAttribute('href', mw.util.getUrl(rppPage.getPageName()) );
rppLink.appendChild(document.createTextNode(rppPage.getPageName()));
if ( tag ) {
statusElement.error( [ '', rppLink, ' sayfasında zaten bu sayfa için bir koruma isteği var.' ] );
return;
}
var newtag = '=== [[:' + Morebits.pageNameNorm + ']] ===\n';
if( ( new RegExp( '^' + RegExp.escape( newtag ).replace( /\s+/g, '\\s*' ), 'm' ) ).test( text ) ) {
statusElement.error( [ '', rppLink, ' sayfasında zaten bu sayfa için bir koruma isteği var.' ] );
return;
}
newtag += '* {{SayfaBağlantı|' + Morebits.pageNameNorm + '}}\n\n';
var words;
switch( params.expiry ) {
case 'temporary':
words = "Geçici ";
break;
case 'indefinite':
words = "Kalıcı ";
break;
default:
words = "";
break;
}
words += params.typename;
newtag += "'''" + Morebits.string.toUpperCaseFirstChar(words) + ( params.reason !== '' ? ( ":''' " +
Morebits.string.formatReasonText(params.reason) ) : ".'''" ) + " ~~~~";
// If either protection type results in a increased status, then post it under increase
// else we post it under decrease
var increase = false;
var protInfo = Twinkle.protect.protectionPresetsInfo[params.category];
// function to compute protection weights (see comment at Twinkle.protect.protectionWeight)
var computeWeight = function(mainLevel, stabilizeLevel) {
var result = Twinkle.protect.protectionWeight[mainLevel || 'all'];
if (stabilizeLevel) {
if (result) {
if (stabilizeLevel.level === "autoconfirmed") {
result += 2;
} else if (stabilizeLevel.level === "review") {
result += 7;
}
} else {
result = Twinkle.protect.protectionWeight["flaggedrevs_" + stabilizeLevel];
}
}
return result;
};
// compare the page's current protection weights with the protection we are requesting
var editWeight = computeWeight(Twinkle.protect.currentProtectionLevels.edit &&
Twinkle.protect.currentProtectionLevels.edit.level,
Twinkle.protect.currentProtectionLevels.stabilize &&
Twinkle.protect.currentProtectionLevels.stabilize.level);
if (computeWeight(protInfo.edit, protInfo.stabilize) > editWeight ||
computeWeight(protInfo.move) > computeWeight(Twinkle.protect.currentProtectionLevels.move &&
Twinkle.protect.currentProtectionLevels.move.level) ||
computeWeight(protInfo.create) > computeWeight(Twinkle.protect.currentProtectionLevels.create &&
Twinkle.protect.currentProtectionLevels.create.level)) {
increase = true;
}
var reg;
if ( increase ) {
reg = /(\n==\s*Koruma talepleri\s*==)/;
} else {
reg = /(\n==\s*Koruma talepleri\s*==)/;
}
var originalTextLength = text.length;
text = text.replace( reg, "\n" + newtag + "\n$1");
if (text.length === originalTextLength)
{
var linknode = document.createElement('a');
linknode.setAttribute("href", mw.util.getUrl("en:w:Wikipedia:Twinkle/Fixing RPP") );
linknode.appendChild(document.createTextNode('RPP Nasıl Düzeltilir'));
statusElement.error( [ 'VP:SKT sayfasında ilgili başlık bulunamadı. Bu sorunu çözmek için ', linknode, ' sayfasına bakabilirsiniz.' ] );
return;
}
statusElement.status( 'Yeni istek ekleniyor...' );
rppPage.setEditSummary( "İsteniyor " + params.typename + (params.typename === "pending changes" ? ' on [[:' : ' of [[:') +
Morebits.pageNameNorm + ']].' + Twinkle.getPref('summaryAd') );
rppPage.setPageText( text );
rppPage.setCreateOption( 'recreate' );
rppPage.save();
}
};
})(jQuery);
//</nowiki>