MediaWiki:Gadget-twinkleprotect.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ü
****************************************
* Çağırma modu: Sekme ("Koru" veya "SKT")
* Etkin olduğu yerler: Özel ve MediaWiki sayfaları dışındaki her türlü sayfa
*/
// Not: Bu modüldeki birçok kod Batchprotect 'toplu koruma' tarafından kullanılmakta/çağrılmaktadır.
Twinkle.protect = function twinkleprotect() {
if (mw.config.get('wgNamespaceNumber') < 0 || mw.config.get('wgNamespaceNumber') === 8) {
return;
}
Twinkle.addPortletLink(Twinkle.protect.callback, Morebits.userIsSysop ? 'Koru' : 'SKT', 'tw-rpp',
Morebits.userIsSysop ? 'Sayfayı korumaya al' : 'Sayfa koruma talebinde bulun');
};
Twinkle.protect.callback = function twinkleprotectCallback() {
var Window = new Morebits.simpleWindow(620, 530);
Window.setTitle(Morebits.userIsSysop ? 'Sayfayı korumaya alın, korumaya alınmasını talep edin veya koruma etiketi ekleyin' : 'Sayfanın korumaya alınmasını talep edin veya koruma etiketi ekleyin');
Window.setScriptName('Twinkle');
Window.addFooterLink('Koruma şablonları', 'Şablon:Koruma şablonları');
Window.addFooterLink('Koruma politikası', 'VP:KP');
Window.addFooterLink('Twinkle yardım', 'VP:TW#protect');
//Window.addFooterLink('Give feedback', 'WT:TW');
var form = new Morebits.quickForm(Twinkle.protect.callback.evaluate);
var actionfield = form.append({
type: 'field',
label: 'Eylem türü'
});
if (Morebits.userIsSysop) {
actionfield.append({
type: 'radio',
name: 'actiontype',
event: Twinkle.protect.callback.changeAction,
list: [
{
label: 'Sayfayı koru',
value: 'protect',
tooltip: 'Sayfaya bir hizmetli olarak koruma uygulayın.',
checked: true
}
]
});
}
actionfield.append({
type: 'radio',
name: 'actiontype',
event: Twinkle.protect.callback.changeAction,
list: [
{
label: 'Sayfa koruması talep et',
value: 'request',
tooltip: 'Korumayı bizzat uygulamak yerine VP:SKT' + (Morebits.userIsSysop ? ' ile koruma talep etmek istiyorsanız.' : '.'),
checked: !Morebits.userIsSysop
},
{
label: 'Sayfayı koruma şablonu ile etiketle',
value: 'tag',
tooltip: 'Koruma uygulayan hizmetli bir koruma şablonu eklemeyi unuttuysa veya sayfayı etiketlemeden korumaya aldıysanız, uygun koruma etiketini eklemek için bunu kullanabilirsiniz.',
disabled: mw.config.get('wgArticleId') === 0 || mw.config.get('wgPageContentModel') === 'Scribunto'
}
]
});
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);
// get current protection level asynchronously
Twinkle.protect.fetchProtectionLevel();
};
// A list of bots who may be the protecting sysop, for whom we shouldn't
// remind the user contact before requesting unprotection (evaluate)
Twinkle.protect.trustedBots = ['Gambot', 'Gambot II'];
// Customizable namespace and FlaggedRevs settings
// In theory it'd be nice to have restrictionlevels defined here,
// but those are only available via a siteinfo query
// mw.loader.getState('ext.flaggedRevs.review') returns null if the
// FlaggedRevs extension is not registered. Previously, this was done with
// wgFlaggedRevsParams, but after 1.34-wmf4 it is no longer exported if empty
// (https://gerrit.wikimedia.org/r/c/mediawiki/extensions/FlaggedRevs/+/508427)
var hasFlaggedRevs = mw.loader.getState('ext.flaggedRevs.review') &&
// FlaggedRevs only valid in some namespaces, hardcoded until [[phab:T218479]]
(mw.config.get('wgNamespaceNumber') === 0 || mw.config.get('wgNamespaceNumber') === 4);
// Limit template editor; a Twinkle restriction, not a site setting
var isTemplate = mw.config.get('wgNamespaceNumber') === 10 || mw.config.get('wgNamespaceNumber') === 828;
// 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 = {};
// returns a jQuery Deferred object, usage:
// Twinkle.protect.fetchProtectingAdmin(apiObject, pageName, protect/stable).done(function(admin_username) { ...code... });
Twinkle.protect.fetchProtectingAdmin = function twinkleprotectFetchProtectingAdmin(api, pageName, protType, logIds) {
logIds = logIds || [];
return api.get({
format: 'json',
action: 'query',
list: 'logevents',
letitle: pageName,
letype: protType
}).then(function(data) {
// don't check log entries that have already been checked (e.g. don't go into an infinite loop!)
var event = data.query ? $.grep(data.query.logevents, function(le) {
return $.inArray(le.logid, logIds);
})[0] : null;
if (!event) {
// fail gracefully
return null;
} else if (event.action === 'move_prot' || event.action === 'move_stable') {
return twinkleprotectFetchProtectingAdmin(api, protType === 'protect' ? event.params.oldtitle_title : event.params.oldtitle, protType, logIds.concat(event.logid));
}
return event.user;
});
};
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: hasFlaggedRevs ? 'info|flagged' : 'info',
inprop: 'protection',
titles: mw.config.get('wgPageName')
});
var stableDeferred = api.get({
format: 'json',
action: 'query',
list: 'logevents',
letype: 'stable',
letitle: mw.config.get('wgPageName')
});
var earlyDecision = [protectDeferred];
if (hasFlaggedRevs) {
earlyDecision.push(stableDeferred);
}
$.when.apply($, earlyDecision).done(function(protectData, stableData) {
// $.when.apply is supposed to take an unknown number of promises
// via an array, which it does, but the type of data returned varies.
// If there are two or more deferreds, it returns an array (of objects),
// but if there's just one deferred, it retuns a simple object.
// This is annoying.
protectData = $(protectData).toArray();
var pageid = protectData[0].query.pageids[0];
var page = protectData[0].query.pages[pageid];
var current = {}, adminEditDeferred;
$.each(page.protection, function(index, protection) {
// Don't overwrite actual page protection with cascading protection
if (!protection.source) {
current[protection.type] = {
level: protection.level,
expiry: protection.expiry,
cascade: protection.cascade === ''
};
// logs report last admin who made changes to either edit/move/create protection, regardless if they only modified one of them
if (!adminEditDeferred) {
adminEditDeferred = Twinkle.protect.fetchProtectingAdmin(api, mw.config.get('wgPageName'), 'protect');
}
} else {
// Account for the page being covered by cascading protection
current.cascading = {
expiry: protection.expiry,
source: protection.source,
level: protection.level // should always be sysop, unused
};
}
});
// show the protection level and log info
Twinkle.protect.hasProtectLog = !!protectData[0].query.logevents.length;
Twinkle.protect.protectLog = Twinkle.protect.hasProtectLog && protectData[0].query.logevents;
Twinkle.protect.hasStableLog = hasFlaggedRevs ? !!stableData[0].query.logevents.length : false;
Twinkle.protect.stableLog = Twinkle.protect.hasStableLog && stableData[0].query.logevents;
Twinkle.protect.currentProtectionLevels = current;
if (adminEditDeferred) {
adminEditDeferred.done(function(admin) {
if (admin) {
$.each(['edit', 'move', 'create', 'cascading'], function(i, type) {
if (Twinkle.protect.currentProtectionLevels[type]) {
Twinkle.protect.currentProtectionLevels[type].admin = admin;
}
});
}
Twinkle.protect.callback.showLogAndCurrentProtectInfo();
});
} else {
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>'));
if (!currentlyProtected || (!Twinkle.protect.currentProtectionLevels.edit && !Twinkle.protect.currentProtectionLevels.move)) {
var lastProtectAction = Twinkle.protect.protectLog[0];
if (lastProtectAction.action === 'unprotect') {
$linkMarkup.append(' (unprotected ' + new Morebits.date(lastProtectAction.timestamp).calendar('utc') + ')');
} else { // protect or modify
$linkMarkup.append(' (bitiş ' + new Morebits.date(lastProtectAction.params.details[0].expiry).calendar('utc') + ')');
}
}
$linkMarkup.append(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'}) + '">bekleyen değişiklikler günlüğü</a>)'));
if (!currentlyProtected || !Twinkle.protect.currentProtectionLevels.stabilize) {
var lastStabilizeAction = Twinkle.protect.stableLog[0];
if (lastStabilizeAction.action === 'reset') {
$linkMarkup.append(' (reset ' + new Morebits.date(lastStabilizeAction.timestamp).calendar('utc') + ')');
} else { // config or modify
$linkMarkup.append(' (bitiş ' + new Morebits.date(lastStabilizeAction.params.expiry).calendar('utc') + ')');
}
}
}
Morebits.status.init($('div[name="hasprotectlog"] span')[0]);
Morebits.status.warn(
currentlyProtected ? 'Önceki korumalar' : 'Bu sayfa geçmişte korumaya alınmış',
$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' ? 'Bekleyen Değişiklikler' : Morebits.string.toUpperCaseFirstChar(type);
if (type === 'cascading') { // Covered by another page
label = 'Cascading protection ';
protectionNode.push($('<b>' + label + '</b>')[0]);
if (settings.source) { // Should by definition exist
var sourceLink = '<a target="_blank" href="' + mw.util.getUrl(settings.source) + '">' + settings.source + '</a>';
protectionNode.push($('<span>from ' + sourceLink + '</span>')[0]);
}
} else {
var level = settings.level;
// Make cascading protection more prominent
if (settings.cascade) {
level += ' (kademeli)';
}
protectionNode.push($('<b>' + label + ': ' + level + '</b>')[0]);
}
if (settings.expiry === 'infinity') {
protectionNode.push(' (süresiz) ');
} else {
protectionNode.push(' (' + new Morebits.date(settings.expiry).calendar('utc') + ' tarihinde sona eriyor) ');
}
if (settings.admin) {
var adminLink = '<a target="_blank" href="' + mw.util.getUrl('Kullanıcı mesaj:' + settings.admin) + '">' + settings.admin + '</a>';
protectionNode.push($('<span>korumaya alan: ' + adminLink + '</span>')[0]);
}
protectionNode.push($('<span> \u2022 </span>')[0]);
});
protectionNode = protectionNode.slice(0, -1); // remove the trailing bullet
statusLevel = 'warn';
} else {
protectionNode.push($('<b>koruma yok</b>')[0]);
}
Morebits.status[statusLevel]('Mevcut koruma düzeyi', protectionNode);
};
Twinkle.protect.callback.changeAction = function twinkleprotectCallbackChangeAction(e) {
var field_preset;
var field1;
var field2;
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ç:',
event: Twinkle.protect.callback.changePreset,
list: mw.config.get('wgArticleId') ? Twinkle.protect.protectionTypes : 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',
event: Twinkle.protect.formevents.editmodify,
list: [
{
label: 'Düzenleme korumasını değiştir',
name: 'editmodify',
tooltip: 'Bu kapatılırsa, düzenleme korumasında herhangi bir değişiklik yapılmayacaktır.',
checked: true
}
]
});
field2.append({
type: 'select',
name: 'editlevel',
label: 'Kimler değişiklik yapabilir:',
event: Twinkle.protect.formevents.editlevel,
list: Twinkle.protect.protectionLevels.filter(function(level) {
// Filter TE outside of templates and modules
return isTemplate || level.value !== 'templateeditor';
})
});
field2.append({
type: 'select',
name: 'editexpiry',
label: 'Bitiş:',
event: function(e) {
if (e.target.value === 'custom') {
Twinkle.protect.doCustomExpiry(e.target);
}
},
// default expiry selection (2 days) is conditionally set in Twinkle.protect.callback.changePreset
list: Twinkle.protect.protectionLengths
});
field2.append({
type: 'checkbox',
event: Twinkle.protect.formevents.movemodify,
list: [
{
label: 'Taşıma korumasını değiştir',
name: 'movemodify',
tooltip: 'Bu kapatılırsa, taşıma korumasında herhangi bir değişiklik yapılmayacaktır.',
checked: true
}
]
});
field2.append({
type: 'select',
name: 'movelevel',
label: 'Kimler taşıyabilir:',
event: Twinkle.protect.formevents.movelevel,
list: Twinkle.protect.protectionLevels.filter(function(level) {
// Autoconfirmed is required for a move, redundant
return level.value !== 'autoconfirmed';
})
});
field2.append({
type: 'select',
name: 'moveexpiry',
label: 'Bitiş:',
event: function(e) {
if (e.target.value === 'custom') {
Twinkle.protect.doCustomExpiry(e.target);
}
},
// default expiry selection (2 days) is conditionally set in Twinkle.protect.callback.changePreset
list: Twinkle.protect.protectionLengths
});
} else { // for non-existing pages
field2.append({
type: 'select',
name: 'createlevel',
label: 'Oluşturma koruması:',
event: Twinkle.protect.formevents.createlevel,
list: Twinkle.protect.protectionLevels.filter(function(level) {
// Filter TE always, and autoconfirmed in mainspace, redundant since WP:ACPERM
return level.value !== (mw.config.get('wgNamespaceNumber') !== 0 || level.value !== 'autoconfirmed');
})
});
field2.append({
type: 'select',
name: 'createexpiry',
label: 'Bitiş:',
event: function(e) {
if (e.target.value === 'custom') {
Twinkle.protect.doCustomExpiry(e.target);
}
},
// default expiry selection (indefinite) is conditionally set in Twinkle.protect.callback.changePreset
list: Twinkle.protect.protectionLengths
});
}
field2.append({
type: 'textarea',
name: 'protectReason',
label: 'Gerekçe (koruma günlüğü için):'
});
field2.append({
type: 'div',
name: 'protectReason_notes',
label: 'Notlar:',
style: 'display:inline-block; margin-top:4px;',
tooltip: 'Koruma günlüğüne bunun SKT\'de talep edildiğine dair bir not ekleyin.'
});
field2.append({
type: 'checkbox',
event: Twinkle.protect.callback.annotateProtectReason,
style: 'display:inline-block; margin-top:4px;',
list: [
{
label: 'SKT talebi',
name: 'protectReason_notes_rfpp',
checked: false,
value: '[[VP:SKT]]\'de talep edildi'
}
]
});
field2.append({
type: 'input',
event: Twinkle.protect.callback.annotateProtectReason,
label: 'SKT revizyon kimliği',
name: 'protectReason_notes_rfppRevid',
value: '',
tooltip: 'Korumanın talep edildiği SKT sayfasının revizyon kimliği (isteğe bağlı).'
});
if (!mw.config.get('wgArticleId') || mw.config.get('wgPageContentModel') === 'Scribunto') { // tagging isn't relevant for non-existing or module pages
break;
}
/* falls through */
case 'tag':
field1 = new Morebits.quickForm.element({ type: 'field', label: 'Şablon 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: 'Koruma şablonu seçin:',
list: Twinkle.protect.protectionTags,
event: Twinkle.protect.formevents.tagtype
});
var isTemplateNamespace = mw.config.get('wgNamespaceNumber') === 10;
var isAFD = Morebits.pageNameNorm.startsWith('Wikipedia:Articles for deletion/');
var isCode = ['javascript', 'css', 'sanitized-css'].includes(mw.config.get('wgPageContentModel'));
field1.append({
type: 'checkbox',
list: [
{
name: 'small',
label: 'Küçük simge kullanma (küçük=hayır)',
tooltip: 'Şablonda |küçük=hayır parametresi kullanılır ve şablon ileti kutusu biçiminde görünür',
checked: false
},
{
name: 'noinclude',
label: 'Koruma şablonunu <noinclude> içine al',
tooltip: 'Koruma şablonunu <noinclude> etiketinin içine alır. Böylece korumaya alınan şablonun kullanıldığı sayfalarda koruma şablonu görünmez.',
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 gerekçe:',
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', selected: true, value: 'temporary' },
{ label: 'Kalıcı', value: 'infinity' }
]
});
field1.append({
type: 'textarea',
name: 'reason',
label: 'Gerekçe: '
});
break;
default:
alert("twinkleprotect modülünde 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' });
$(e.target.form).find('fieldset[name="field2"] input[name="protectReason_notes_rfppRevid"]').parent().css({display: 'inline-block', marginLeft: '15px'}).hide();
}
// re-add protection level and log info, if it's available
Twinkle.protect.callback.showLogAndCurrentProtectInfo();
};
// NOTE: This function is used by batchprotect as well
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 = 'infinity';
}
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('Özel bir koruma süresi girin. \nGöreceli zamanları İngilizce olmak koşuluyla kullanabilirsiniz, örneğin "1 minute", "19 days" veya mutlak zaman damgaları, "yyyymmddhhmm" (örn. "200602011405", 1 Şubat 2006 14.05 (UTC) anlamına gelir).', '');
if (custom) {
var option = document.createElement('option');
option.setAttribute('value', custom);
option.textContent = custom;
target.appendChild(option);
target.value = custom;
} else {
target.selectedIndex = 0;
}
};
// NOTE: This list is used by batchprotect as well
Twinkle.protect.protectionLevels = [
{ label: 'Herkes', value: 'all' },
{ label: 'Otomatik onaylı', value: 'autoconfirmed' },
{ label: 'Hizmetli', value: 'sysop', selected: true }
];
// default expiry selection is conditionally set in Twinkle.protect.callback.changePreset
// NOTE: This list is used by batchprotect as well
Twinkle.protect.protectionLengths = [
{ 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: '6 ay', value: '6 months' },
{ label: '1 yıl', value: '1 year' },
{ label: 'süresiz', value: 'infinity' },
{ label: 'Özel...', value: 'custom' }
];
Twinkle.protect.protectionTypes = [
{ label: 'Korumayı kaldır', value: 'unprotect' },
{
label: 'Tam koruma',
list: [
{ label: 'Genel (tam)', selected: true, value: 'koruma' },
{ label: 'İçerik anlaşmazlığı/değişiklik savaşı (tam)', value: 'koruma-anlaşmazlık' },
{ label: 'Aşırı vandalizm (tam)', value: 'koruma-vandalizm' },
{ label: 'Engellenen kullanıcının mesaj sayfası (tam)', value: 'koruma-mesaj' }
]
},
{
label: 'Şablon koruması',
list: [
{ label: 'Çok sayıda sayfada kullanılan şablon', selected:true, value: 'koruma-şablon' }
]
},
{
label: 'Yarı koruma',
list: [
{ label: 'Genel (yarı)', value: 'pp-semi-protected' },
{ label: 'Aşırı vandalizm (yarı)', selected: true, value: 'pp-semi-vandalism' },
{ label: 'Zararlı düzenlemeler (yarı)', value: 'pp-semi-disruptive' },
{ label: 'Kaynaksız içerik ekleme (yarı)', value: 'pp-semi-unsourced' },
{ label: 'YİB politikası ihlali (yarı)', value: 'pp-semi-blp' },
{ label: 'Kuklacılık (yarı)', value: 'pp-semi-sock' },
{ label: 'Engellenen kullanıcının mesaj sayfası (yarı)', value: 'pp-semi-usertalk' }
]
},
{
label: 'Taşıma koruması',
list: [
{ label: 'Genel (taşıma)', value: 'koruma-taşıma' },
{ label: 'Tartışma/taşıma savaşı (taşıma)', value: 'koruma-taşıma-anlaşmazlık' },
{ label: 'Sayfa taşıma vandalizmi (taşıma)', value: 'koruma-taşıma-vandalizm' },
{ label: 'Yüksek trafikli sayfa (taşıma)', value: 'koruma-taşıma-süresiz' }
]
}
].filter(function(type) {
// Filter for templates and flaggedrevs
return (isTemplate || type.label !== 'Template protection') && (hasFlaggedRevs || type.label !== 'Pending changes');
});
Twinkle.protect.protectionTypesCreate = [
{ label: 'Korumayı kaldır', value: 'unprotect' },
{
label: 'Oluşturma koruması',
list: [
{ label: 'Genel ({{koruma-oluşturma}})', value: 'pp-create' },
{ label: 'Rahatsız edici ad', value: 'pp-create-offensive' },
{ label: 'Israrlı oluşturma', selected: true, value: 'pp-create-salt' },
{ label: 'Yakın zamanda silinmiş YİB', value: 'pp-create-blp' }
]
}
];
// A page with both regular and PC protection will be assigned its regular
// protection weight plus 2
Twinkle.protect.protectionWeight = {
sysop: 40,
autoconfirmed: 10,
all: 0,
flaggedrevs_none: 0 // just in case
};
// NOTICE: keep this synched with [[MediaWiki:Protect-dropdown]]
// Also note: stabilize = Pending Changes level
// expiry will override any defaults
Twinkle.protect.protectionPresetsInfo = {
'koruma': {
edit: 'sysop',
move: 'sysop',
expiry: '3 days',
reason: null
},
'koruma-anlaşmazlık': {
edit: 'sysop',
move: 'sysop',
expiry: '3 days',
reason: '[[Vikipedi:Koruma_politikası#İçerik_anlaşmazlıkları|İçerik anlaşmazlığı/Düzenleme savaşı]]'
},
'koruma-vandalizm': {
edit: 'sysop',
move: 'sysop',
expiry: '3 days',
reason: 'Aşırı [[Vikipedi:Vandalizm|vandalizm]]'
},
'koruma-mesaj': {
edit: 'sysop',
move: 'sysop',
expiry: 'infinity',
reason: '[[Vikipedi:Koruma politikası|Engelliyken kullanıcı mesaj sayfasının uygunsuz kullanımı]]'
},
'koruma-şablon': {
edit: 'sysop',
move: 'sysop',
expiry: 'infinity',
reason: '[[Vikipedi:Yüksek riskli şablonlar|Çok sayfada kullanılan şablon]]'
},
// 'pp-30-500-arb': {
// edit: 'autoconfirmed',
// move: 'autoconfirmed',
// expiry: 'infinity',
// reason: '[[WP:30/500|Arbitration enforcement]]',
// template: 'pp-30-500'
// },
'pp-30-500-vandalism': {
edit: 'autoconfirmed',
move: 'autoconfirmed',
reason: '(Otomatik) onaylı kullanıcıların sürekli [[Vikipedi:Vandalizm|vandalizmi]]',
template: 'pp-30-500'
},
'pp-30-500-disruptive': {
edit: 'autoconfirmed',
move: 'autoconfirmed',
reason: 'Persistent [[WP:Disruptive editing|disruptive editing]] from (auto)confirmed accounts',
template: 'pp-30-500'
},
'pp-30-500-blp': {
edit: 'autoconfirmed',
move: 'autoconfirmed',
reason: 'Persistent violations of the [[WP:BLP|biographies of living persons policy]] from (auto)confirmed accounts',
template: 'pp-30-500'
},
'pp-30-500-sock': {
edit: 'autoconfirmed',
move: 'autoconfirmed',
reason: 'Persistent [[WP:Sock puppetry|sock puppetry]]',
template: 'pp-30-500'
},
'pp-semi-vandalism': {
edit: 'autoconfirmed',
reason: 'Aşırı [[VP:V|vandalizm]]',
template: 'koruma-vandalizm'
},
'pp-semi-disruptive': {
edit: 'autoconfirmed',
reason: 'Israrlı zararlı değişiklik',
template: 'koruma'
},
'pp-semi-unsourced': {
edit: 'autoconfirmed',
reason: 'Kaynaksız veya yetersiz kaynaklı içeriğin ısrarlı olarak eklenmesi',
template: 'koruma'
},
'pp-semi-blp': {
edit: 'autoconfirmed',
reason: '[[VP:YİB|Yaşayan insan biyografileri politikası]] ihlali',
template: 'pp-blp'
},
'pp-semi-usertalk': {
edit: 'autoconfirmed',
move: 'autoconfirmed',
expiry: 'infinity',
reason: '[[Vikipedi:Koruma politikası|Engelliyken kullanıcı mesaj sayfasının uygunsuz kullanımı]]',
template: 'koruma-mesaj'
},
'pp-semi-template': { // removed for now
edit: 'autoconfirmed',
move: 'autoconfirmed',
expiry: 'infinity',
reason: '[[Vikipedi:Yüksek riskli şablonlar|Çok sayfada kullanılan şablon]]',
template: 'koruma-şablon'
},
'pp-semi-sock': {
edit: 'autoconfirmed',
reason: 'Sürekli [[Vikipedi:Kukla|kuklacılık]]',
template: 'pp-sock'
},
'pp-semi-protected': {
edit: 'autoconfirmed',
reason: null,
template: 'koruma'
},
'pp-pc-vandalism': {
reason: 'Aşırı [[VP:V|vandalizm]]',
template: 'pp-pc'
},
'pp-pc-disruptive': {
reason: 'Sürekli zararlı düzenlemeler',
template: 'pp-pc'
},
'pp-pc-unsourced': {
reason: 'Kaynaksız veya yetersiz kaynaklı içeriğin ısrarla eklenmesi',
template: 'pp-pc'
},
'pp-pc-blp': {
reason: '[[VP:YİB|Yaşayan insanların biyografileri politikasının]] ısrarlı ihlali',
template: 'pp-pc'
},
'pp-pc-protected': {
reason: null,
template: 'pp-pc'
},
'koruma-taşıma': {
move: 'sysop',
reason: null
},
'koruma-taşıma-anlaşmazlık': {
move: 'sysop',
reason: '[[VP:TAŞIMA|Taşıma savaşı]]'
},
'koruma-taşıma-vandalizm': {
move: 'sysop',
reason: '[[VP:TAŞIMA|Sayfa taşıma vandalizmi]]'
},
'koruma-taşıma-süresiz': {
move: 'sysop',
expiry: 'infinity',
reason: '[[VP:TAŞIMA|Çok sayfada kullanılan şablon]]'
},
'unprotect': {
edit: 'all',
move: 'all',
create: 'all',
reason: null,
template: 'none'
},
'pp-create-offensive': {
create: 'sysop',
reason: '[[VP:OLUŞTURMA|Rahatsız edici ad]]'
},
'pp-create-salt': {
create: 'autoconfirmed',
reason: '[[VP:OLUŞTURMA|Israrlı oluşturma]]'
},
'pp-create-blp': {
create: 'autoconfirmed',
reason: '[[Vikipedi:Yaşayan_insanların_biyografileri|Yakın zamanda silinmiş YİB]]'
},
'pp-create': {
create: 'autoconfirmed',
reason: '{{pp-create}}'
}
};
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' },
//{ label: '{{pp-blp}}: BLP violations', value: 'pp-blp' },
//{ label: '{{pp-sock}}: sockpuppetry', value: 'pp-sock' },
{ 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: '{{pp-semi-indef}}: general long-term semi-protection', value: 'pp-semi-indef' },
//{ label: '{{pp-30-500}}: extended confirmed protection', value: 'pp-30-500' }
]
},
/*{
label: 'Pending changes templates',
list: [
{ label: '{{pp-pc}}: pending changes', value: 'pp-pc' }
]
},*/
{
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' }
]
}
].filter(function(type) {
// Filter FlaggedRevs
return hasFlaggedRevs || type.label !== 'Bekleyen değişiklik şablonları';
});
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 });
} 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 });
} else {
form.movemodify.checked = false;
Twinkle.protect.formevents.movemodify({ target: form.movemodify });
}
form.editexpiry.value = form.moveexpiry.value = item.expiry || '2 days';
if (form.pcmodify) {
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 });
}
form.pcexpiry.value = item.expiry || '1 month';
}
} else {
if (item.create) {
form.createlevel.value = item.create;
Twinkle.protect.formevents.createlevel({ target: form.createlevel });
}
form.createexpiry.value = item.expiry || 'infinity';
}
var reasonField = actiontype === 'protect' ? form.protectReason : form.reason;
if (item.reason) {
reasonField.value = item.reason;
} else {
reasonField.value = '';
}
// Add any annotations
Twinkle.protect.callback.annotateProtectReason(e);
// sort out tagging options, disabled if nonexistent or lua
if (mw.config.get('wgArticleId') && mw.config.get('wgPageContentModel') !== 'Scribunto') {
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 });
// Default settings for adding <noinclude> tags to protection templates
var isTemplateEditorProtection = form.category.value === 'koruma-şablon';
var isAFD = Morebits.pageNameNorm.startsWith('Vikipedi:Silinmeye aday sayfalar/');
var isNotTemplateNamespace = mw.config.get('wgNamespaceNumber') !== 10;
if ((isTemplateEditorProtection || isAFD) && !isCode) {
form.noinclude.checked = true;
} else if (isCode || isNotTemplateNamespace) {
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 input = Morebits.quickForm.getInputData(form);
var tagparams;
if (input.actiontype === 'tag' || (input.actiontype === 'protect' && mw.config.get('wgArticleId') && mw.config.get('wgPageContentModel') !== 'Scribunto')) {
tagparams = {
tag: input.tagtype,
reason: false,
small: input.small,
noinclude: input.noinclude
};
}
switch (input.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('tamamlandı');
}
if (tagparams) {
Twinkle.protect.callbacks.taggingPageInitial(tagparams);
}
};
var protectIt = function twinkleprotectCallbackProtectIt(next) {
thispage = new Morebits.wiki.page(mw.config.get('wgPageName'), 'Sayfa korumaya alınıyor');
if (mw.config.get('wgArticleId')) {
if (input.editmodify) {
thispage.setEditProtection(input.editlevel, input.editexpiry);
}
if (input.movemodify) {
// Ensure a level has actually been chosen
if (input.movelevel) {
thispage.setMoveProtection(input.movelevel, input.moveexpiry);
} else {
alert('Bir taşıma koruma seviyesi seçmelisiniz!');
return;
}
}
thispage.setWatchlist(Twinkle.getPref('watchProtectedPages'));
} else {
thispage.setCreateProtection(input.createlevel, input.createexpiry);
thispage.setWatchlist(false);
}
if (input.protectReason) {
thispage.setEditSummary(input.protectReason);
} else {
alert('Koruma günlüğünde yer alacak bir koruma gerekçesi girmelisiniz.');
return;
}
if (input.protectReason_notes_rfppRevid && !/^\d+$/.test(input.protectReason_notes_rfppRevid)) {
alert('The provided revision ID is malformed. Please see https://en.wikipedia.org/wiki/Help:Permanent_link for information on how to find the correct ID (also called "oldid").');
return;
}
if (!statusInited) {
Morebits.simpleWindow.setButtonsEnabled(false);
Morebits.status.init(form);
statusInited = true;
}
thispage.setChangeTags(Twinkle.changeTags);
thispage.protect(next);
};
var stabilizeIt = function twinkleprotectCallbackStabilizeIt() {
if (thispage) {
thispage.getStatusElement().info('tamamlandı');
}
thispage = new Morebits.wiki.page(mw.config.get('wgPageName'), 'Bekleyen değişiklik koruması uygulanıyor');
thispage.setFlaggedRevs(input.pclevel, input.pcexpiry);
if (input.protectReason) {
thispage.setEditSummary(input.protectReason + Twinkle.summaryAd); // flaggedrevs tag support: [[phab:T247721]]
} 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.setWatchlist(Twinkle.getPref('watchProtectedPages'));
thispage.stabilize(allDone, function(error) {
if (error.errorCode === 'stabilize_denied') { // [[phab:T234743]]
thispage.getStatusElement().error('Twinkle, yüksek olasılıkla bir MediaWiki hatası nedeniyle bekleyen değişiklik ayarlarını düzenleyemedi. Diğer işlemler (etiketleme veya olağan koruma) gerçekleşmiş olabilir. Lütfen sayfayı yeniden yükleyin ve yeniden deneyin.');
}
});
};
if (input.editmodify || input.movemodify || !mw.config.get('wgArticleId')) {
if (input.pcmodify) {
protectIt(stabilizeIt);
} else {
protectIt(allDone);
}
} else if (input.pcmodify) {
stabilizeIt();
} else {
alert("Lütfen Twinkle'a yapacak bir şey verin! \nSadece sayfayı etiketlemek istiyorsanız, üst kısımdaki 'Sayfayı koruma şablonu ile etiketle' seçeneğini seçebilirsiniz.");
}
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 (input.category) {
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 'pp-30-500-arb':
case 'pp-30-500-vandalism':
case 'pp-30-500-disruptive':
case 'pp-30-500-blp':
case 'pp-30-500-sock':
typename = 'extended confirmed protection';
break;
case 'pp-semi-vandalism':
case 'pp-semi-disruptive':
case 'pp-semi-unsourced':
case 'pp-semi-usertalk':
case 'pp-semi-sock':
case 'pp-semi-blp':
case 'pp-semi-protected':
typename = 'yarı koruma';
break;
case 'pp-pc-vandalism':
case 'pp-pc-blp':
case 'pp-pc-protected':
case 'pp-pc-unsourced':
case 'pp-pc-disruptive':
typename = 'pending changes';
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 'pp-create':
case 'pp-create-offensive':
case 'pp-create-blp':
case 'pp-create-salt':
typename = 'oluşturma koruması';
break;
case 'unprotect':
var admins = $.map(Twinkle.protect.currentProtectionLevels, function(pl) {
if (!pl.admin || Twinkle.protect.trustedBots.indexOf(pl.admin) !== -1) {
return null;
}
return 'Kullanıcı:' + pl.admin;
});
if (admins.length && !confirm('Koruma uygulayan hizmetli (' + Morebits.array.uniq(admins).join(', ') + ') ile iletişim kurmayı denediniz mi?')) {
return false;
}
// otherwise falls through
default:
typename = 'koruma kaldırma';
break;
}
switch (input.category) {
case 'koruma-anlaşmazlık':
typereason = 'İçerik anlaşmazlığı/değişiklik savaşı';
break;
case 'koruma-vandalizm':
case 'pp-semi-vandalism':
case 'pp-pc-vandalism':
case 'pp-30-500-vandalism':
typereason = 'Israrlı [[VP:V|vandalizm]]';
break;
case 'pp-semi-disruptive':
case 'pp-pc-disruptive':
case 'pp-30-500-disruptive':
typereason = 'Islarlı zararlı değişiklik';
break;
case 'pp-semi-unsourced':
case 'pp-pc-unsourced':
typereason = '[[VP:KG|Kaynaksız]] ya da [[VP:GK|niteliksiz kaynaklarla]] desteklenmiş içeriğin ısrarlı eklentisi';
break;
case 'koruma-şablon':
typereason = '[[Vikipedi:Yüksek riskli şablonlar|Yüksek riskli şablon]]';
break;
case 'pp-30-500-arb':
typereason = '[[WP:30/500|Arbitration enforcement]]';
break;
case 'koruma-mesaj':
case 'pp-semi-usertalk':
typereason = 'Engelliyken kullanıcı mesaj sayfasının uygunsuz kullanımı';
break;
case 'pp-semi-sock':
case 'pp-30-500-sock':
typereason = 'Israrlı [[VP:KUKLA|kuklacılık]]';
break;
case 'pp-semi-blp':
case 'pp-pc-blp':
case 'pp-30-500-blp':
typereason = '[[VP:YİB|YİB]] politikası ihlali';
break;
case 'koruma-taşıma-anlaşmazlık':
typereason = 'Sayfa adı anlaşmazlığı/değişiklik savaşı';
break;
case 'koruma-taşıma-vandalizm':
typereason = 'Sayfa taşıma vandalizmi';
break;
case 'koruma-taşıma-süresiz':
typereason = '[[Vikipedi:Yüksek riskli şablonlar|Yüksek riskli şablon]]';
break;
case 'pp-create-offensive':
typereason = 'Rahatsız edici ad';
break;
case 'pp-create-blp':
typereason = 'Yakın zamanda silinmiş [[VP:YİB|YİB]]';
break;
case 'pp-create-salt':
typereason = 'Israrlı oluşturma';
break;
default:
typereason = '';
break;
}
var reason = typereason;
if (input.reason !== '') {
if (typereason !== '') {
reason += '\u00A0\u2013 '; // U+00A0 NO-BREAK SPACE; U+2013 EN RULE
}
reason += input.reason;
}
if (reason !== '' && reason.charAt(reason.length - 1) !== '.') {
reason += '.';
}
var rppparams = {
reason: reason,
typename: typename,
category: input.category,
expiry: input.expiry
};
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 = 'Talep tamamlandı, şimdi tartışma sayfasına yönlendiriliyor';
var rppPage = new Morebits.wiki.page(rppName, 'Sayfa koruması talep ediliyor');
rppPage.setFollowRedirect(true);
rppPage.setCallbackParameters(rppparams);
rppPage.load(Twinkle.protect.callbacks.fileRequest);
break;
default:
alert('twinkleprotect: bilinmeyen eylem türü');
break;
}
};
Twinkle.protect.protectReasonAnnotations = [];
Twinkle.protect.callback.annotateProtectReason = function twinkleprotectCallbackAnnotateProtectReason(e) {
var form = e.target.form;
var protectReason = form.protectReason.value.replace(new RegExp('(?:; )?' + mw.util.escapeRegExp(Twinkle.protect.protectReasonAnnotations.join(': '))), '');
if (this.name === 'protectReason_notes_rfpp') {
if (this.checked) {
Twinkle.protect.protectReasonAnnotations.push(this.value);
$(form.protectReason_notes_rfppRevid).parent().show();
} else {
Twinkle.protect.protectReasonAnnotations = [];
form.protectReason_notes_rfppRevid.value = '';
$(form.protectReason_notes_rfppRevid).parent().hide();
}
} else if (this.name === 'protectReason_notes_rfppRevid') {
Twinkle.protect.protectReasonAnnotations = Twinkle.protect.protectReasonAnnotations.filter(function(el) {
return el.indexOf('[[Özel:Kalıcıbağ') === -1;
});
if (e.target.value.length) {
var permalink = '[[Özel:Kalıcıbağ/' + e.target.value + '#' + Morebits.pageNameNorm + ']]';
Twinkle.protect.protectReasonAnnotations.push(permalink);
}
}
if (!Twinkle.protect.protectReasonAnnotations.length) {
form.protectReason.value = protectReason;
} else {
form.protectReason.value = (protectReason ? protectReason + '; ' : '') + Twinkle.protect.protectReasonAnnotations.join(': ');
}
};
Twinkle.protect.callbacks = {
taggingPageInitial: function(tagparams) {
if (tagparams.tag === 'noop') {
Morebits.status.info('Koruma şablonu 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*(koruma|koruma-|pp-|yarı koruma)[^{}]*?\s*?\}\}\s*(?:<\/noinclude>)?\s*(?:\*\/)?\s*/gi;
var re_result = oldtag_re.exec(text);
if (re_result) {
if (params.tag === 'none' || confirm('{{' + re_result[1] + '}} bulundu. \nKaldırmak için Tamam\'a veya bırakmak için İptal\'e tıklayın.')) {
text = text.replace(oldtag_re, '');
}
}
if (params.tag === 'none') {
summary = 'Koruma şablonu kaldırılıyor';
} else {
tag = params.tag;
if (params.reason) {
tag += '|gerekçe=' + params.reason;
}
if (params.small) {
tag += '|küçük=hayır';
}
if (/^\s*#redirect/i.test(text)) { // redirect page
// Only tag if no {{rcat shell}} is found
if (!text.match(/{{(?:redr|this is a redirect|r(?:edirect)?(?:.?cat.*)?[ _]?sh)/i)) {
text = text.replace(/#REDIRECT ?(\[\[.*?\]\])(.*)/i, '#REDIRECT $1$2\n\n{{' + tag + '}}');
} else {
Morebits.status.info('Redirect category shell present', 'nothing to do');
return;
}
} else {
var needsTagToBeCommentedOut = ['javascript', 'css', 'sanitized-css'].indexOf(protectedPage.getContentModel()) !== -1;
if (needsTagToBeCommentedOut) {
if (params.noinclude) {
tag = '/* <noinclude>{{' + tag + '}}</noinclude> */';
} else {
tag = '/* {{' + tag + '}} */\n';
}
// Prepend tag at very top
text = tag + text;
} else {
if (params.noinclude) {
tag = '<noinclude>{{' + tag + '}}</noinclude>';
} else {
tag = '{{' + tag + '}}\n';
}
// Insert tag after short description or any hatnotes
var wikipage = new Morebits.wikitext.page(text);
text = wikipage.insertAfterTemplates(tag, Twinkle.hatnoteRegex).getText();
}
}
summary = '{{' + params.tag + '}} ekleniyor';
}
protectedPage.setEditSummary(summary);
protectedPage.setChangeTags(Twinkle.changeTags);
protectedPage.setWatchlist(Twinkle.getPref('watchPPTaggedPages'));
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*' + Morebits.string.escapeRegExp(Morebits.pageNameNorm) + '\\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 bu sayfa için zaten bir koruma talebi var, iptal ediliyor.' ]);
return;
}
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 sayfa = Morebits.pageNameNorm;
regex1 = /(Tartışma|Kullanıcı|Kullanıcı mesaj|Vikipedi|Vikipedi tartışma|Dosya|Dosya tartışma|MediaWiki|MediaWiki tartışma|Şablon|Şablon tartışma|Yardım|Yardım tartışma|Kategori|Kategori tartışma|Portal|Portal tartışma)\:(.*)/;
sayfa = sayfa.replace(regex1, '$2');
var newtag = '==== {{' + ns2tag[ mw.config.get('wgNamespaceNumber') ] + '|' + sayfa + '}} ====\n';
if (new RegExp('^' + mw.util.escapeRegExp(newtag).replace(/\s+/g, '\\s*'), 'm').test(text)) {
statusElement.error([ '', rppLink, ' sayfasında bu sayfa için zaten bir koruma talebi var, iptal ediliyor.' ]);
return;
}
var words;
switch (params.expiry) {
case 'temporary':
words = 'Geçici ';
break;
case 'infinity':
words = 'Süresiz ';
break;
default:
words = '';
break;
}
words += params.typename;
newtag += "{{SKT\n| tür = " + Morebits.string.toUpperCaseFirstChar(words) + (params.reason !== '' ? "\n| gerekçe = " +
Morebits.string.formatReasonText(params.reason) : ".") + '--~~~~\n| yorum = \n| karar = \n}}';
// 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 {
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 kaldırma talepleri\s*?\=\=)/;
}
var originalTextLength = text.length;
if (increase) {
text = text.replace(reg, '\n\n' + newtag + '\n\n$1');
} else {
text += '\n\n' + newtag;
}
if (text.length === originalTextLength) {
var linknode = document.createElement('a');
linknode.setAttribute('href', mw.util.getUrl('Vikipedi:Twinkle/SKT düzeltme'));
linknode.appendChild(document.createTextNode('SKT nasıl düzeltilir'));
statusElement.error([ 'VP:SKT\'de ilgili başlık bulunamadı. Bu sorunu çözmek için lütfen ', linknode, ' sayfasına bakın.' ]);
return;
}
statusElement.status('Yeni talep ekleniyor...');
rppPage.setEditSummary('/* ' + Morebits.pageNameNorm + ' */ [[:' + Morebits.pageNameNorm + ']] sayfasında ' + params.typename +' talep ediliyor.');
rppPage.setChangeTags(Twinkle.changeTags);
rppPage.setPageText(text);
rppPage.setCreateOption('recreate');
rppPage.save(function(pageobj) {
// Watch the page being requested
var watchPref = Twinkle.getPref('watchRequestedPages');
// action=watch has no way to rely on user preferences (T262912), so we do it manually.
// The watchdefault pref appears to reliably return '1' (string),
// but that's not consistent among prefs so might as well be "correct"
var watch = watchPref !== 'no' && (watchPref !== 'default' || !!parseInt(mw.user.options.get('watchdefault'), 10));
if (watch) {
var watch_query = {
action: 'watch',
titles: mw.config.get('wgPageName'),
token: mw.user.tokens.get('watchToken')
};
// Only add the expiry if page is unwatched or already temporarily watched
if (pageobj.getWatched() !== true && watchPref !== 'default' && watchPref !== 'yes') {
watch_query.expiry = watchPref;
}
new Morebits.wiki.api('Koruma talep edilen sayfa izleme listesine ekleniyor', watch_query).post();
}
});
}
};
Twinkle.addInitCallback(Twinkle.protect, 'protect');
})(jQuery);
// </nowiki>