Modül:Ototaksonkutu

Page korumaya alındı
Vikipedi, özgür ansiklopedi
Modül belgelemesi[gör] [değiştir] [geçmiş] [temizle]
Otomatik taksonkutu sistemi belgelemesi

Şablonlar

Modüller

Bu modül {{otomatik taksonkutu}} şablonunu çalıştırmaya yarayan Modül:Ototaksonkutu/şablon arayüzü modülünün ana fonksiyonlarını barındıran bir Lua modülüdür. Direkt bu modül üzerinden kullanabileceğiniz belli başlı fonksiyonlar mevcuttur. bilimsel sınıflandırmaya göre alt cins ve üzerinde bulunan tüm kademeler için bu modül kullanılabilir durumdadır. Alt cins'in alt kademelerinde bulunan tür gibi kademeler için ise, Modül:Ototaksonkutu/şablon arayüzü modülünde özelleştirmeler mevcuttur. Bunlar da yalnızca {{otomatik taksonkutu}} şablonu için geçerlidir.

{{Taksonomi/Felis}} tarzındaki sayfalarda tutulan verileri kullanarak size herhangi bir takson hakkında bilgi vermek için kullanılan fonksiyonları burada bulabilirsiniz. Tüm taksonomi veritabanını görmek için Taksonomi şablonları sayfasına bakabilirsiniz.

taksonBilgi()

Şablon:Taksonomi/TAKSON sayfasına erişip istenilen verileri size verir, eğer 'aynısı' bağlantısı mevcutsa 'aynısı' olan taksonun bilgilerini verir.

Kullanımı:

{{#invoke:Ototaksonkutu|taksonBilgi|TAKSON|GİRDİ}}
GİRDİ şunlardan biridir
'ebeveyn', 'sıra', 'bağ_sayfa', 'bağ_yazı', 'tükenmiş', 'hep_görüntüle', 'kaynak', 'aynısı' veya 'hepsi'.

Eğer GİRDİ belirlenmediyse, varsayılan değer 'hepsi' olur - tüm bilgiler tek bir satırda '$' ile ayrılarak yazılır.

taksonkutuListe()

Girilen taksonun hiyeraşisini en üste kadar bulup, bunu otomatik taksonkutuya yansıtmada yardımcı olur.

Kullanımı
{{#invoke:Ototaksonkutu|taksonkutuListe|TAKSON
|taks_üst_sayısı = gösterilecek *üst* seviye takson sayısı
|sıralama = mevcut TAKSON için yazar adı ve tarihi
|üst_sıralama = mevcut TAKSON'un ebeveyni için yazar adı ve tarihi
|büst_sıralama = mevcut TAKSON'un ebeveyninin ebeveyni için yazar adı ve tarihi
|bbüst_sıralama = mevcut TAKSON'un ebeveyninin ebeveyninin ebeveyni için yazar adı ve tarihi
|bbbüst_sıralama = mevcut TAKSON'un ebeveyninin ebeveyninin ebeveyninin ebeveyni için yazar adı ve tarihi
|seçili_kalın = TAKSON'un yazısının satırda kalın gözükmesi için 'kalın' yazın
|virüs = virüs italik standartlarını kullanmak için 'evet' yazın
}}

{{Taksonomi/Felis}} için bir deneme yapılacak olursa şu şekilde olur:

{| class="wikitable"
{{#invoke:Ototaksonkutu|taksonkutuListe|Felis}}
|}
Âlem: Animalia
Şube: Chordata
Sınıf: Mammalia
Takım: Carnivora
Alt takım: Feliformia
Familya: Felidae
Alt familya: Felinae
Cins: Felis

esasSira()

Bu fonksiyon Otomatik taksonkutu sisteminde kullanılan konfigürasyon fonksiyonlarından bir tanesidir. Modül:Ototaksonkutu|taksonkutuListe() tarafından kullanılmaktadır.

{{#invoke:Ototaksonkutu|esasSira|SIRA}}

Girilen parametrenin, yani Latincedeki sıralamanın, bir 'esas' Linnaean sıralaması olup olmadığını kontrol eder, 'evet' veya 'hayır' çıktısı verir. Bu şablonu düzenleyerek hangi sıralamaların esas olarak değerlendirileceği ve otomatik taksonkutuda o şekilde görüntüleneceği belirlenebilir.

Şu anda esas sıralama olarak değerlendirilenler: alem, şube, bölüm, sınıf, takım, familya, cins ve tür. Ayrıca bunların ichno- ile oo- halleri.

ceviriSira()

Bu fonksiyon Otomatik taksonkutu sisteminde kullanılan konfigürasyon fonksiyonlarından bir tanesidir. Modül:Ototaksonkutu|taksonkutuListe() tarafından kullanılmaktadır.

{{#invoke:Ototaksonkutu|ceviriSira|SIRA|kontrol=KONTROL}}

Latincede yazılmış bir takson adının, Türkçe karşılığını verir.

Eğer girilen sıralama bu şablonda ekli değilse, bu sırayı barındıran taksonomi şablonu Kategori:Tanınmayan sıra kullanan taksonomi şablonları kategorisine yerleştirilecektir.

altSira()

Bu fonksiyon, belirtilmiş sıralamanın bir alt sırasını (asil olan) bize verir. Asıl kullanımı Şablon:Otomatik taksonkutu içerisindedir; bahsi geçen taksonun sırası girildiğinde, bir sonraki alt sıralamanın getirilmesini sağlar. Mesela, "cins" girildiğinde "Tür" olarak; "altşube" girildiğinde "Sınıf" ("Üstsınıf" veya "Classis" değil) olarak çıktı verir.

{{#invoke:Ototaksonkutu|altSira|SIRA}}

Eğer bir sıralama bu listede yoksa, bir hata mesajı yansıtılacaktır. Bu hatayı düzeltmek için, şablonu düzenleyin, var olmayan takson sıralamasını bulunması gereken bir alt sıralamasını verecek şekilde ekleyin. Şablonun içeriğine girdiğinizde zaten kendisini anlatmaktadır.

Alt- ve üst- şeklindeki sıralamalar çıktıya alınmaz; bu sıralamaların büyük çoğunlukla bahsi geçen taksonun yanına dizilmesi beklenir, örnek olarak Dinozor.

italikTakson()

Bu fonksiyon Otomatik taksonkutu sisteminde kullanılan konfigürasyon fonksiyonlarından bir tanesidir. Modül:Ototaksonkutu|taksonkutuListe() tarafından kullanılmaktadır.

{{#invoke:Ototaksonkutu|italikTakson|TAKSON|VİRÜS}}

Bir taksonun italik yazılıp yazılmaması gerektiğine karar verir, virüs olup olmamasına veya sıralamasına bakarak. Yeni bir tip sisteme eklendiğinde güncellemenmesi gereken şablonlardan biri.

Kullanım

{{#invoke:Ototaksonkutu|italikTakson|takson-sıra|evet veya hayır (virüs)}} – mevcut değer |2=hayır (virüs)

  • {{#invoke:Ototaksonkutu|italikTakson|tür}} → evet
  • {{#invoke:Ototaksonkutu|italikTakson|cins}} → evet
  • {{#invoke:Ototaksonkutu|italikTakson|familya}} → hayır
  • {{#invoke:Ototaksonkutu|italikTakson|familya|evet}} → evet
  • {{#invoke:Ototaksonkutu|italikTakson|strain|evet}} → hayır

taksonkutuRengi()

Modül Düzenleyicilerine not: Bu fonksiyon, taksonomi (takson) terimlerini içeren, takson sıralamasına göre renk belirleyen {{Otomatik taksonkutu}} şablonunun taksonkutu renginin değiştirilmesine dayanmaktadır, yani değişime uğrayabilirler. Renkler, rgb(..,..,..) biçimi kullanılarak belirlenmelidir.

{{#invoke:Ototaksonkutu|taksonkutuRengi|TAKSON}}

Amaç

Bu fonksiyon taksonkutusu sisteminde kullanılan konfigürasyon fonksiyonlarından bir tanesidir, otomatik taksonkutu sisteminde kullanılmaktadır.

Bir taksonkutusunun uygun rengini oluşturmaktadır.

Yalnızca diğer taksonkutusu şablonları tarafından kullanılmalıdır.

Taksonomi şablonları tarafından kullanımı

Otomatik taksonkutuları, Modül:Ototaksonkutu modülündeki bir fonksiyonu kullanmaktadır, ki bu da taksonun renkle eşleşmesini taksonomi şablonlarında kodlanmış olan taksonomi hiyerarşisini arayarak (örn. "Taksonomi/takson-adı" biçiminde başlayan şablon adlarını tarayarak).

Bir taksonkutu içerisindeki eşleşmiş renk

Otomatik taksonkutuları genellikle renklerini otomatik oluşturur. Eğer oluşturamazsa ya da birtakım bilinmeyen nedenlerden dolayı otomatik rengi görmezden gelirse, |renk_benzeri= parametresi uygulanan takson için girilebilir. Sonuçta:

| renk_benzeri = Animalia

kodu bir taksonkutusu içerisindeyse rengin eşleşmesini uygun hayvanlar alemindeki renk ile değiştirir. Girilen |renk_benzeri= parametresi bu şablonun kullandığı switch parametrelerinden biri olmalıdır. Yani |renk_benzeri=Felis işe yaramaz ve hata rengine yönlendirir.

Taksonkutu renk şeması

Virüsler rgb(250,250,190) ayrıca Viroidler
Bakteri rgb(220,235,245)
Arkea rgb(195,245,250) ayrıca Nanoarchaeota (Nanarchaeota), Korarchaeota, Thaumarchaeota, Crenarchaeota ve Euryarchaeota
Ökaryotlar rgb(245,215,255) Excavata, Amoebozoa ve Opisthokonta da dahil olmak üzere ökaryotların tek bir rengi mevcut
Hayvanlar rgb(235,235,210)
Mantarlar rgb(145,250,250)
Archaeplastida rgb(180,250,180) ayrıca Bitkiler ve Viridiplantae
SAR rgb(200,250,80) ayrıca Chromalveolata
incertae sedis rgb(250,240,230)
İknotaksonlar rgb(230,222,214)
Ootaxa rgb(250,250,220)

İzleyici kategoriler

--[[*************************************************************************
Bu modül Otomatik Taksonkutu sisteminin ana modülüdür.
{{Otomatik taksonkutu}} tarafından kullanılmaktadır.

Özellikle sağladığı şey, taksonomi hiyeraşisini otomatik olarak
taksonomi şablonlarında listelemektir ("Şablon:Taksonomi/TAKSON_ADI"
biçimindeki şablonları kullanarak), şablon genişletme hatalarına sebep
olmadan.sayfasına bağlanır
*****************************************************************************]]

require('Modül:No globals')
local veri = require("Modül:Ototaksonkutu/veri")
local TaksonItalik = require('Modül:Taksonİtalik') -- Modül:Taksonİtalik'ten takson adını italik göstermek için bir fonksiyon
local TabloSatiri = '|-\n'
local TabloSonu = '|}\n'
local p = {} -- dışarıdan erişilebilen fonksiyonlar
local l = {} -- modül içinde kullanılan fonksiyonlar, ayrıştırmak için
local colour = '' -- taksonkutu ve toksan listelemeleri için renk

--[[=========================================================================
Bir taksonomi hiyeraşisinin çıkabileceği en yüksek takson derinliğini
belirler; işlem yapma süresini azaltır ve yanlış belirlenmiş hiyeraşilere
karşı koruma sağlar, örneğin döngüler.
Bu değer dışarıdan şu şekilde çağırılabilir:
{{#invoke:Ototaksonkutu|getirMaksAramaSeviyesi}}
=============================================================================]]
local MaksAramaSeviyesi = 100

function p.getirMaksAramaSeviyesi()
	return MaksAramaSeviyesi
end

--[[========================= taksonkutuRengi ===============================
Bir taksonkutu için gösterilen rengi belirler, taksonomi hiyeraşisindeki en
üst taksona çıkarak en baş taksonun rengini getirir ('incertae sedis' bir
istisnadır, bu direk kendi rengini belirler). Geçerli bir taksonkutu renginin
CSS rgb() biçimini kullandığı kabul edilmiştir, tüm renkler bu biçimdedir.
Eğer taksonkutu için hiçbir renk bulunamadıysa, 'transparent' (yani renksiz)
görünür ama taksonomi hiyeraşisi çok yukarı gidiyorsa, hata rengi görünür.
Kullanımı: {{#invoke:Ototaksonkutu|taksonkutuRengi|TAKSON}}
=============================================================================]]
function p.taksonkutuRengi(frame, taxon)
	return p.getirTaksonkutuRengi(frame, taxon or frame.args[1] or '')
end

function p.getirTaksonkutuRengi(frame, currTaxon, cats)
	-- renkler bu fonksiyon için küreseldir; varsayılan değeri ise string türündedir
	local i = 1 -- sayma işlemi başlatılıyor
	local searching = currTaxon ~= '' -- hala renk aranıyor mu?
	local foundICTaxon = false -- bir 'incertae sedis' var mı diye kontrol et
	while searching and i <= MaksAramaSeviyesi do
		local plainCurrTaxon, dummy = l.kirpFazlaliklar(currTaxon) -- gereksiz yazıları soyutla /
		if string.lower(plainCurrTaxon) == 'incertae sedis' then
			foundICTaxon = true
		else
			local possibleColour = veri.getirTabloyaGore(plainCurrTaxon, "renkler")
			if possibleColour and string.sub(possibleColour,1,3) == 'rgb' then
				colour = possibleColour
				searching = false
			end
		end
		if searching then
			local ok, parent = p.getirTaksonBilgiOgesi(frame, currTaxon, 'ebeveyn')
			if ok and parent ~= '' then
				currTaxon = parent
				i = i + 1
			else
				searching = false -- hiyeraşinin en üst katmanına çık veya var olmayan taksonomi şablonlarını kullanmaya çalış
			end
		end
	end
	if colour == '' then
		if foundICTaxon then
			colour = veri.getirTabloyaGore("incertae sedis", "renkler")
			table.insert(cats, "[[Kategori:Incertae sedis rengine sahip taksonkutular]]")
		elseif searching then
			-- MaksAramaSeviyesi'ni aşan hiyeraşi seviyeleri
			colour = "transparent; text-align:center; border: 2px solid red; error:colour"
			table.insert(cats, "[[Kategori:Hata rengine sahip taksonkutular]]")
		else
			colour = 'transparent'
			table.insert(cats, "[[Kategori:Rengi olmayan taksonkutular]]")
		end
	end
	return colour
end

--[[= = = = = = = = = = = = =  ustSeviyeTakson  = = = = = = = = = = = = = = = 
Burası herhangi bir takson hiyeraşisinde en üste gelebilecek takson
gruplarını belirler.
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =]]
function l.ustSeviyeTakson(taxon)
	return  taxon == 'Life' or taxon == 'Veterovata' or taxon == 'Ichnos'
end

--[[========================= taksonkutuListe ===============================
Girilen taksonun hiyeraşisini en üste kadar bulup, bunu otomatik
taksonkutuya yansıtmada yardımcı olur.
Kullanım:
{{#invoke:Ototaksonkutu|taksonkutuListe|TAKSON
|taks_üst_sayısı = gösterilecek *üst* seviye takson sayısı
|sıralama = mevcut TAKSON için yazar adı ve tarihi
|üst_sıralama = mevcut TAKSON'un ebeveyni için yazar adı ve tarihi
|büst_sıralama = mevcut TAKSON'un ebeveyninin ebeveyni için yazar adı ve tarihi
|bbüst_sıralama = mevcut TAKSON'un ebeveyninin ebeveyninin ebeveyni için yazar adı ve tarihi
|bbbüst_sıralama = mevcut TAKSON'un ebeveyninin ebeveyninin ebeveyninin ebeveyni için yazar adı ve tarihi
|seçili_kalın = TAKSON'un yazısının satırda kalın gözükmesi için 'kalın' yazın
|virüs = virüs italik standartlarını kullanmak için 'evet' yazın
}}
=============================================================================]]
function p.taksonkutuListe(frame, moduleTable)
	if moduleTable then
		frame.args = moduleTable
	end
	local currTaxon = frame.args[1] or ''
	if currTaxon == '' then return '' end
	local displayN = (tonumber(frame.args['taks_üst_sayısı']) or 1) + 1
	local authTable = {}
	authTable[1] = frame.args['sıralama'] or ''
	authTable[2] = frame.args['üst_sıralama'] or ''
	authTable[3] = frame.args['büst_sıralama'] or ''
	authTable[4] = frame.args['bbüst_sıralama'] or ''
	authTable[5] = frame.args['bbbüst_sıralama'] or ''
	local boldFirst = frame.args['seçili_kalın'] or 'link' -- değeri 'link' veya 'kalın'
	local virus = frame.args['virüs'] or 'hayır' -- değeri 'evet' veya 'hayır'
	local offset = tonumber(frame.args['offset'] or 0)
	-- eğer 'sıralama' parametresi bahsi geçen taksondan daha alt seviyedeki
	-- bir takson içinse, sıralamaların hepsini kaydır
	if offset ~= 0 then
		for i = 1, 5 do
			local j = i + offset
			if j <= 5 then
				authTable[i] = authTable[j]
			else
				authTable[i] = ''
			end
		end
	end
	local taxonTable, taxonRankTable = l.yapTablo(frame, currTaxon)
	local res = ''
	local topTaxonN = taxonTable.n
	-- eğer mümkünse büyük büyük büyük ebeveynin üstündeki tüm taksonları
	-- sıralamasız (sıralamasını belirleyen yazar olmadan) göster
	for i = topTaxonN, 6, -1 do
		res = res .. p.gosterTakson(frame, taxonTable[i], taxonRankTable[i], topTaxonN==i, '', displayN >= i, '', virus)
	end
	-- ebeveynin üstündeki tüm taksonları eğer
	-- sıralamaları (sıralamasını belirleyen yazarlar) ile birlikte göster
	for i = math.min(topTaxonN, 5), 2, -1 do
		res = res .. p.gosterTakson(frame, taxonTable[i], taxonRankTable[i], topTaxonN==i, authTable[i], displayN >= i, '', virus)
	end
	-- hedef taksonu göster, her daim kalın ve gösterilir
	res = res .. p.gosterTakson(frame, taxonTable[1], taxonRankTable[1], topTaxonN==1, authTable[1], true, boldFirst, virus)
	return res
end

--[[= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Bir taksonkutudaki tek bir takson satırını oluştur.
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =]]
function p.gosterTakson(frame, taxon, rank, isTopTaxon, auth, force, boldFirst, virus)
	-- eğer bir üst seviye taksonda değilsek (mesela "Life" değilse) ve ebeyevn yoksa bu bir hatadır
	if isTopTaxon then
		if l.ustSeviyeTakson(taxon) then
			return '' -- bir üst seviye takson gösterme
		elseif mw.title.new('Taksonomi/'..taxon, 'Şablon').exists then
			-- bu taksonomi şablonunda bir ebeveyn tanımlanmamış
			return l.taksonomiOlustur(taxon, 'Taksonomi şablonunda bir ebeveyn belirtilmemiş') .. '\n' .. TabloSatiri
		else
			-- bu taksonun bir taksonomi şablonu mevcut değil
			return l.taksonomiOlustur(taxon, 'Eksik taksonomi şablonu') .. '\n' .. TabloSatiri
		end
	else
		-- if showing is not already forced, force if it's a principal rank or an authority is specified
		force = force or l.getirEsasSira(rank) == 'evet' or
		        auth ~= ''
		if not force then
			-- if showing is still not already forced, force if the taxonomy template has 'always_display' set
			local ok, alwaysDisplay = p.getirTaksonBilgiOgesi(frame, taxon, 'hep_görüntüle')
			force = alwaysDisplay == 'evet' or  alwaysDisplay == 'true'
		end
		if force then
			local res = l.tabloHucresi("<span style='white-space: nowrap;'>"..l.getirCeviriSira(rank) .. ':</span>')
			local bold = 'hayır'
			if boldFirst == 'kalın' then bold = 'evet' end
			if auth ~= '' then
				auth = '<br><small>' .. auth .. l.taksonKaynak(frame, taxon) .. '</small>'
			elseif bold == "evet" then
				auth = '<br><small>' .. l.taksonKaynak(frame, taxon) .. '</small>'
			end
			local res = res .. l.tabloHucresi(l.getirTaksonBag(frame, taxon, rank, bold, '', '', virus) .. auth) -- italic, abbreviated
			return res .. TabloSatiri
		else
			return ''
		end
	end
end

function l.taksonKaynak(frame, taxon)
	-- taksonun kaynağı belirtilmişse onu çağır
	local ok, taksonKaynak = p.getirTaksonBilgiOgesi(frame, taxon, 'kaynak')
	if ok and taksonKaynak ~= "" then
		taksonKaynak = frame:extensionTag{ name = 'ref', content = taksonKaynak, args = { name = taxon..'-kaynak' } }
	end

	return taksonKaynak
end

--[[========================= taksonomiListe ================================
Returns the cells of the taxonomy table displayed on the right hand side of
"Template:Taxonomy...." pages.
Kullanımı: {{#invoke:Ototaksonkutu|taksonomiListe|TAKSON}}
=============================================================================]]
function p.taksonomiListe(frame)
	return l._taksonomiListe(frame, frame.args[1] or '')
end

function l._taksonomiListe(frame, currTaxon)
	local cats = {}
	if currTaxon == '' then
		return '{|class="infobox biota"\n' .. TabloSatiri .. l.tabloHucresi('') .. l.tabloHucresi('HATA: hiçbir takson girilmedi') .. TabloSonu
	end
	local taxonTable, taxonRankTable = l.yapTablo(frame, currTaxon)
	local rankValTable = l.getirSiraTablosu()
	local lastRankVal = 1000000
	local orderOk = true
	-- check whether the taxonomy is for viruses; use already determined taxon colour if possible
	local virus = 'hayır'
	local taxoColour = colour
	if taxoColour == '' then
		if  taxonTable[taxonTable.n] == 'Ichnos' or taxonTable[taxonTable.n] == 'Veterovata' then
			taxoColour = p.getirTaksonkutuRengi(frame, taxonTable[taxonTable.n], cats)
		else
			taxoColour = p.getirTaksonkutuRengi(frame, taxonTable[taxonTable.n - 1], cats)
		end
	end
	if taxoColour == p.getirTaksonkutuRengi(frame, "virüs", cats) then
		virus = 'evet'
	end
	-- add information message
	local res = '<p style="text-align:right">Tabloda kalın olarak görünenler taksonkutularda görünür;<br>ya asil bir sıradır ya da <code>hep_görüntüle=evet</code> değerindedir.</p>\n'

	-- start table
	res =  res .. '{| class="infobox biota" style="text-align: left; font-size:100%"\n' .. TabloSatiri .. '! colspan=4 style="text-align: center; background-color: '
	            .. taxoColour .. '"|Ata taksonlar\n'
	-- deal first with the top level taxon; if there are no errors, it should be Life/Veterovata/Ichnos, which are 
	-- not displayed
	local taxon = taxonTable[taxonTable.n]
	if not l.ustSeviyeTakson(taxon) then
		local msg = 'Taksonomi şablonu eksik'
		if mw.title.new('Taksonomi/'..taxon, 'Şablon').exists then
			msg = 'Ebeveyn takson gerekli'
		end
		res = res .. TabloSatiri .. l.tabloHucresi('colspan=2', l.taksonomiOlustur(taxon, msg))
	end
	-- now output the rest of the table
	local currRankVal
	for i = taxonTable.n-1, 1, -1 do
		-- check ranks are in right order in the hierarchy
		taxon = taxonTable[i]
		local rank = taxonRankTable[i]
		currRankVal = l.araSiraDegeri(rankValTable, rank)
		if currRankVal then
			orderOk = currRankVal < lastRankVal
			if orderOk then lastRankVal = currRankVal end
		else
			orderOk = true
		end
		-- see if the row will be displayed in a taxobox; bold the rank if so
		local boldRank = false
		local ok, alwaysDisplay = p.getirTaksonBilgiOgesi(frame, taxon, 'hep_görüntüle')
		if ok and (alwaysDisplay == 'evet' or alwaysDisplay == 'true') then
			boldRank = true
		else
			boldRank = l.getirEsasSira(rank) == 'evet'
		end
		-- now return a row of the taxonomy table with anomalous ranks marked
		local errorStr = ''
		if not orderOk then errorStr = 'evet' end
		local link = l.getirTaksonBag(frame, taxon, rank, '', '', '', virus) -- bold, italic, abbreviated
		res = res .. l.taksonomiListeSatiri(taxon, rank, link, boldRank, errorStr)
	end
	-- close table
	res = res .. TabloSonu
	-- error-tracking for taxonomy templates
	-- if the last row has an anomalous rank, put the page in an error-tracking category
	if not orderOk then
		table.insert(cats, '[[Kategori:Aykırı sıra gösteren taksonomi şablonları]]')
	end
	-- if the last row has a taxon name in the page name that does not match the link text,
	-- put the taxonomy template in a tracking category
	local dummy, linkText = p.getirTaksonBilgiOgesi(frame, taxon, 'bağ_yazı')
	local match = l.matchTaxonLink(taxon, linkText, currRankVal and currRankVal < rankValTable['cins'])
	if not match then
		table.insert(cats, '[[Kategori:Bağ yazısı ve adı eşleşmeyen taksonomi şablonları|' .. taxon .. ']]')
	end
	if cats[1] then
		res = res .. frame:expandTemplate{ title = 'Şablon diğer', args = { table.concat(cats)} }
	end
	return res
end

--[[ = = = = = = = = = = = = = = taxonomyListRow  = = = = = = = = = = = = = = 
Returns a single row of the taxonomy table displayed on the right hand side
 of "Template:Taxonomy...." pages.
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =]]
function l.taksonomiListeSatiri(taxon, rank, link, boldRank, error)
	local res = ''
	if taxon == '' or rank == '' then return res end
	local baseTaxon, qualifier = l.kirpFazlaliklar(taxon)
	-- if appropriate, make it clear that some taxa have been skipped via a ... row
	if qualifier == '/geç' then
		res = res .. TabloSatiri .. l.tabloHucresi('.....') .. l.tabloHucresi('.....')
	end
	-- now generate a row of the table
	res = res .. TabloSatiri
	local cellContent = ''
	local anglicizedRank = l.getirCeviriSira(rank)
	if boldRank then
		cellContent = cellContent .. '<span style="white-space:nowrap;"><b>' .. anglicizedRank .. '</b>:</span>'
	else
		cellContent = cellContent .. '<span style="white-space:nowrap;">' .. anglicizedRank .. ':</span>'
	end
	if error == 'evet' then
		cellContent = '<span style="background-color:#FDD">' .. cellContent .. '</span>'
	end
	res = res .. l.tabloHucresi(cellContent)
	          .. l.tabloHucresi('<span style="white-space:nowrap;">' .. link .. '</span>')
	          .. l.tabloHucresi('<span style="font-size:smaller;">' .. qualifier  .. '</span>')
	          .. l.tabloHucresi('<span style="white-space:nowrap;">' .. l.birTaksonuDuzenle(taxon) .. '</span>')
	return res
end

--[[====================== cagirTaksonomiAnahtari ===========================
Prepares for, and then calls, Template:Taxonomy key to display a taxonomy
template page. It does this by building up the information the template
requires, following one 'aynısı' link, if required.
Kullanımı:
{{#invoke:Ototaksonkutu|cagirTaksonomiAnahtari
|ebeveyn=
|sıra=
|tükenmiş=
|hep_görüntüle=
|bağ_sayfa=value of 'link' parameter in taxonomy template
|bağ_yazı=value of parameter 2 in taxonomy template
|aynısı=
}}
=============================================================================]]
local PARENT = 1
local RANK = 2
local LINK_TARGET = 3
local LINK_TEXT = 4
local ALWAYS_DISPLAY = 5
local EXTINCT = 6
local SAME_AS = 7
local REFS = 8

function p.cagirTaksonomiAnahtari(frame)
	local taxon = frame.args['takson'] or ''
	local parent = frame.args['ebeveyn'] or ''
	local rank = frame.args['sıra'] or ''
	local extinct = string.lower(frame.args['tükenmiş']) or ''
	local alwaysDisplay = string.lower(frame.args['hep_görüntüle']) or ''
	local linkTarget = frame.args['bağ_sayfa'] or ''
	local linkText = frame.args['bağ_yazı'] or '' -- this is the "raw" link text, and can be ''
	local refs = frame.args['kaynak'] or ''
	local sameAsTaxon = frame.args['aynısı'] or ''
	if sameAsTaxon ~= '' then
		-- try using the 'aynısı' taxon; it's an error if it doesn't exist
		local ok, sameAsInfoStr = pcall(frame.expandTemplate, frame, { title = 'Şablon:Taksonomi/' .. sameAsTaxon, args = {['makine kodu'] = 'hepsi' } })
		if ok then
			local sameAsInfo = mw.text.split(sameAsInfoStr, '$', true)
			--'aynısı' taxon's taxonomy template must not have a 'aynısı' link
			if sameAsInfo[SAME_AS] == '' then
				if parent == '' then parent = sameAsInfo[PARENT] end
				if rank == '' then rank = sameAsInfo[RANK] end
				if extinct == '' then extinct = string.lower(sameAsInfo[EXTINCT]) end
				if alwaysDisplay == '' then alwaysDisplay = string.lower(sameAsInfo[ALWAYS_DISPLAY]) end
				if linkTarget == '' then linkTarget = sameAsInfo[LINK_TARGET] end
				if linkText == '' then linkText = sameAsInfo[LINK_TEXT] end
				if refs == '' and parent == sameAsInfo[PARENT] then refs = sameAsInfo[REFS] end
			else
				return '<span style="color:red; font-size:1.1em">Error: attempt to follow two "same as" links</span>: <code>same_as = ' .. sameAsTaxon .. '</code>, but [[Şablon:Taksonomi/' .. sameAsTaxon .. ']] also has a<code>same_as</code> parameter.'
			end
		else
			return l.eksikTaksonomiAnahtari(sameAsTaxon, 'given as the value of <code>same as</code>')
		end
	end
	local link = linkTarget
	if linkText ~= '' and linkText ~= linkTarget then link = link .. "|" .. linkText end
	-- check consistency of extinct status; if this taxon is not extinct, parent must not be either
	local extinctError = 'hayır'
	if parent ~= '' and (extinct == '' or extinct == 'hayır' or extinct == 'false') then
		local ok, parentExtinct = p.getirTaksonBilgiOgesi(frame, parent, 'tükenmiş')
		if ok and (parentExtinct == 'evet' or parentExtinct == 'true') then extinctError = 'evet' end
	end
	
	-- taksonomi anahtarını oluşturmaya başlayalım
	local taksAna = {}
	table.insert(taksAna, l._taksonomiListe(frame, taxon))
	
	if mw.title.new('Taksonomi/'..parent, 'Şablon').exists then
		if linkTarget then
			if mw.title.new(linkTarget).exists then
				table.insert(taksAna, "__NOINDEX__")
			else
				table.insert(taksAna, "Vikipedi'de henüz [["..linkTarget.."]] isimli bir madde bulunmamakta. "
					.."Bu maddeyi [["..linkTarget.."|oluşturarak]] yardımcı olabilirsiniz. Şu anda bulunduğunuz sayfa "
					.."[["..linkTarget.."]] bilimsel sınıflandırması hakkında size bilgi vermektedir."
					.."[[Kategori:Kırmızı bağlantılı taksona sahip taksonomi şablonları|"..l.secSon(mw.title.getCurrentTitle().text).."]]")
			end
		end
	else
		table.insert(taksAna, "<strong class='error'>Geliştiriliyor.</strong>"
			.. " Eğer aşağıdaki tablo doğru görünüyorsa, seçilmiş takson için gerekli bilgiler mevcut demektir.\n"
			.. l.eksikTaksonomiAnahtari(parent, "<code>ebeveyn</code> değeri olarak girildi"))
	end
	
	local ok, parRefs = p.getirTaksonBilgiOgesi(frame, parent, "kaynak")
	
	table.insert(taksAna, "\nNiye burada olduğundan emin değil misin? Otomatik taksonkutu sistemini [[Vikipedi:Otomatik taksonkutu sistemi/giriş|öğrenmeye başla]]."
		.. "\n{| class='wikitable'"
		.. "\n|-"
		.. "\n|Ebeveyn:"
		.. "\n|<code>"..parent.."</code> &#x5B;[[Şablon:Taksonomi/"..parent.."|Taksonomi]]; <span class=plainlinks>["..l.taksonomiOlusturBag(parent).." değiştir]&#x5D;</span>"
		.. "\n|-"
		.. "\n|Sıra:"
		.. "\n|<code>"..rank.."</code> (<code>"..l.getirCeviriSira(rank, "evet").."</code> şeklinde görünür)"..(rank~="" and "" or "<span class='error'>– bir sıra belirtilmeli</span")
		.. "\n|-"
		.. "\n|Bağ:"
		.. "\n|<code>"..l.yapBag(taxon, extinct, "hayır", p.getirItalikTakson(rank), nil, linkTarget, link)
		.."</code>"..(linkTarget == link and "" or " (<code>"..linkTarget.."</code> sayfasına bağlanır)")
		.. "\n|-"
		.. "\n|Tükenmiş:"
		.. "\n|"..(extinct~="" and "<code>"..extinct.."</code>" or "hayır")
		.. (extinctError == "evet" and "<span style='background-color:#FCC'>ebeveyn tükenmiş olarak belirtilmiş</span>" or "")
		.. "\n|-"
		.. "\n|Hep görüntüle:"
		.. "\n|"..(alwaysDisplay~="" and "<code>"..alwaysDisplay.."</code>[[Kategori:Hep_görüntüle kullanan taksonomi şablonları|"..taxon.."]]"
					or (l.getirEsasSira(rank) == "evet" and "evet (asil sıra)" or "hayır"))
		.. "\n|-"
		.. "\n|Taksonomi kaynakları:"
		.. "\n|"..l.yapKaynaklariGoster(taxon, refs)
		.. "\n|-"
		.. "\n|Ebeveyn taksonominin kaynakları:"
		.. "\n|"..l.yapKaynaklariGoster(parent, parRefs)
		.. "\n|-"
		.. (sameAsTaxon ~= '' and "\n|Takson ile aynı:||<code>"..sameAsTaxon.."</code> "
			.."&#x5B;[[Şablon:Taksonomi/"..sameAsTaxon.."|Taksonomi]]; "
			.."<span class=plainlinks>["..l.taksonomiOlusturBag(sameAsTaxon).." değiştir]&#x5D;</span>\n|-" or "")
		.. (mw.ustring.match(taxon, "/geç$") and '\n| colspan=2 |Sonunda "/geç" varsa, bakınız '
			..'[[Vikipedi:Otomatik taksonkutu sistemi/gelişmiş taksonomi#Geçilen taksonomi şablonları|Geçilen taksonomi şablonları]].'
			..'<br>Geçilen takson için, bakınız [[Şablon:Taksonomi/'..mw.ustring.gsub(taxon, "/geç$", "")..']].' or '')
		.. (mw.ustring.match(taxon, "/%?$") and '\n| colspan=2 |Sonunda "/?" varsa, bakınız [[Vikipedi:Otomatik taksonkutu sistemi/gelişmiş taksonomi#Kuşkulu atamalar|Kuşkulu atamalar]].' or '')
		.. (mw.ustring.match(l.secSon(taxon), "Incertae sedis") and '| colspan=2 |"Incertae sedis" takson isimleri için, bakınız '
			.."[[Vikipedi:Otomatik taksonkutu sistemi/gelişmiş taksonomi#Incertae_sedis_taksonomi_şablonları|''Incertae sedis'' taksonomi şablonları]]." or '')
		.. "\n|}"
		.. (extinctError == "evet" and "[[Kategori:Tutarsız tükenmiş değerine sahip taksonomi şablonları|"..taxon.."]]" or ""))
	
	-- mevcut sayfanın vikiveri ögesini bulalım
	local ID = mw.wikibase.getEntityIdForCurrentPage()
	local oge = ID and mw.wikibase.getEntity(ID)
	
	if not oge then
		table.insert(taksAna, "[[Kategori:Vikiveri ögesine bağlı olmayan taksonomi şablonları|"..taxon.."]]")
	else
		-- vikiveri'de taksonomi şablonu için herhangi bir etiket girilmiş mi?
		local vikiveriEtiket = oge:getLabel("tr")
		if vikiveriEtiket then else
			table.insert(taksAna, "[[Kategori:Vikiveri'de etiketi eksik olan taksonomi şablonları|"..taxon.."]]")
		end
		
		-- vikiveri'de taksonomi şablonu için herhangi bir açıklama girilmiş mi?
		local vikiveriAciklama = oge:getDescription("tr")
		if vikiveriAciklama then else
			table.insert(taksAna, "[[Kategori:Vikiveri'de açıklaması eksik olan taksonomi şablonları|"..taxon.."]]")
		end
	end
	
	return table.concat(taksAna)
end

function l.eksikTaksonomiAnahtari(takson, mesaj)
	return mw.title.new("Şablon:Taksonomi/"..takson).exists and "" or
		'<p><span class="error">Hata: eksik taksonomi şablonu.</span> "'
		.. takson .. '" için taksonomi bilgisi eksik'.. (mesaj and ", " .. mesaj or "")
		.. '.</span> "'.. takson ..'" doğru yazdığınıza emin misiniz? Belki İngilizce adı değil de, bilimsel adı olabilir?'
		.. ' Eminseniz, "Şablon:Taksonomi/'.. takson ..'" oluşturulması gerekir:'
		.. ' ['..l.taksonomiOlusturBag(takson)..' sayfayı oluştur].</p>'
end

--[[=========================== taksonBilgi =================================
Extracts and returns information from Şablon:Taksonomi/TAXON, following
one 'aynısı' link if required.
Kullanımı: {{#invoke:Ototaksonkutu|taksonBilgi|TAKSON|GİRDİ}}
GİRDİ şunlardan biridir: 'ebeveyn', 'sıra', 'bağ_sayfa', 'bağ_yazı',
'tükenmiş', 'hep_görüntüle', 'kaynak', 'aynısı' veya 'hepsi'.
Eğer GİRDİ belirlenmediyse, varsayılan değer 'hepsi' olur - tüm bilgiler tek
bir satırda '$' ile ayrılarak yazılır.
=============================================================================]]
function p.taksonBilgi(frame)
	local taxon = frame.args[1] or ''
	local item = frame.args[2] or ''
	if item == '' then item = 'hepsi' end
	local ok, info = p.getirTaksonBilgiOgesi(frame, taxon, item)
	return info
end

--[[= = = = = = = = = = = getirTaksonBilgiOgesi  = = = = = = = = = = = = = = =
Utility function to extract an item of information from a 
taxonomy template, following one 'aynısı' link if required.
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =]]
function p.getirTaksonBilgiOgesi(frame, taxon, item)
	local ok, info
	-- item == 'hançer' is a special case
	if item == 'hançer' then
		ok, info = p.getirTaksonBilgiOgesi(frame, taxon, 'tükenmiş')
		if ok then
			if info == 'evet' or info == 'true' then
				info = '&dagger;'
			else
				info = ''
			end
		end
	-- item ~= 'hançer'
	else
		ok, info = pcall(frame.expandTemplate, frame, { title = 'Şablon:Taksonomi/' .. taxon, args = {['makine kodu'] = item } })
		if ok then
			if info == '' then
				-- try 'aynısı'
				local sameAsTaxon = frame:expandTemplate{ title = 'Şablon:Taksonomi/' .. taxon, args = {['makine kodu'] = 'aynısı' } }
				if sameAsTaxon ~= '' then
					ok, info = pcall(frame.expandTemplate, frame, { title = 'Şablon:Taksonomi/' .. sameAsTaxon, args = {['makine kodu'] = item } })
				end
			end
		end
	end
	if ok then
		-- if item is 'bağ_yazı', trim info and check whether '(?)' needs to be added
		if item == 'bağ_yazı' then
			-- there is a newline at the end of linkText when taxonomy template has "|link = LINK_TARGET|LINK_TEXT"
			info = mw.text.trim(info)
			if string.sub(taxon, -2) == '/?' and not string.find(info, '?', 1, true) then
				info = info .. '<span style="font-style:normal;font-weight:normal;"> (?)</span>'
			end
		end
	else
		info = '[[Şablon:Taksonomi/' .. taxon .. ']]' --error indicator in code before conversion to Lua
	end
	return ok, info
end

--[[= = = = = = = = = = = = = = getirTaksonBag = = = = = = = = = = = = = = =
Internal function to drive l.yapBag().
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =]]
function l.getirTaksonBag(frame, taxon, rank, bold, italic, abbreviated, virus)
	local ok, extinct = p.getirTaksonBilgiOgesi(frame, taxon, 'tükenmiş')
	if italic == '' and taxon ~= "Virus" then
		italic = p.getirItalikTakson(rank, virus)
	end
	local ok, linkTarget = p.getirTaksonBilgiOgesi(frame, taxon, 'bağ_sayfa')
	local ok, linkText = p.getirTaksonBilgiOgesi(frame, taxon, 'bağ_yazı')
	return l.yapBag(taxon, extinct, bold, italic, abbreviated, linkTarget, linkText)
end

--[[= = = = = = = = = = = = = = yapBag = = = = = = = = = = = = = = = = = = = =
Actually make the link.
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =]]
function l.yapBag(taxon, extinct, bold, italic, abbreviated, linkTarget, linkText)
	local dummy
	-- if link text is missing, try to find a replacement
	if linkText == '' then
		if string.find(taxon, 'Incertae sedis', 1, true) then
			linkText = "''incertae sedis''"
			linkTarget = 'Incertae sedis'
		else
			linkText, dummy = l.kirpFazlaliklar(taxon)
		end
	end
	if linkTarget == '' then linkTarget = linkText end
	if italic == 'evet' then linkText = TaksonItalik.italicizeTaxonName(linkText, false, abbreviated=='evet') end
	local link = ''
	if bold == 'evet' then link = '<b>' .. linkText .. '</b>'
	else
		if linkTarget == linkText then link = linkText
		else link = linkTarget .. '|' .. linkText
		end
		link = '[[' .. link .. ']]'
	end
	if (extinct == 'evet' or extinct == 'true') and not string.find(link, '†', 1, true) then
		link = '<span style="font-style:normal;font-weight:normal;">†</span>' .. link
	end
	if string.sub(taxon, -2) == '/?' and not string.find(link, '?', 1, true) then
		link = link .. '<span style="font-style:normal;font-weight:normal;"> (?)</span>'
	end
	return link
end

--[[======================== gosterSiraTablosu ==============================
Returns a wikitable showing the ranks and their values as set up by
getRankTable().
Kullanımı: {{#invoke:Ototaksonkutu|gosterSiraTablosu}}
=============================================================================]]
function p.gosterSiraTablosu()
	local rankTable = l.getirSiraTablosu()
	local res = '{| class="wikitable sortable"\n|+ Taksonomi şablonlarında değerlendirilen sıralar\n! Sıra !! Görüntüsü !! Değeri\n'
	for k, v in pairs(rankTable) do
		local rankShown = l.getirCeviriSira(k)
		res = res .. TabloSatiri .. l.tabloHucresi(k) .. l.tabloHucresi(rankShown) .. l.tabloHucresi(v)
	end
	return res .. TabloSonu
end

--[[=============================== bul =====================================
Returns the taxon above the specified taxon with a given rank.
Kullanımı: {{#invoke:Ototaksonkutu|bul|TAKSON|SIRA}}
=============================================================================]]
function p.bul(frame)
	local currTaxon = frame.args[1] or ''
	if currTaxon == '' then return '<span class="error">no taxon supplied</span>' end
	local rank = frame.args[2] or ''
	if rank == '' then return '<span class="error">no rank supplied</span>' end
	local inHierarchy = true -- still in the taxonomic hierarchy or off the top?
	local searching = true -- still searching
	while inHierarchy and searching do
		local ok, parent = p.getirTaksonBilgiOgesi(frame, currTaxon, 'ebeveyn')
			if ok and parent ~= '' then
			currTaxon = parent
			local ok, currRank = p.getirTaksonBilgiOgesi(frame, currTaxon, 'rank')
			if currRank == rank then
				searching = false
			end
		else
			inHierarchy = false
		end
	end
	if inHierarchy and not searching then return currTaxon
	else return '<span class="error">rank not found</span>'
	end
end

--[[============================== ninci ====================================
External utility function primarily intended for use in checking and debugging.
Returns the nth level above a taxon in a taxonomic hierarchy, where the taxon
itself is counted as the first level.
Kullanımı: {{#invoke:Ototaksonkutu|ninci|TAKSON|n=N}}
=============================================================================]]
function p.ninci(frame)
	local currTaxon = frame.args[1] or ''
	if currTaxon == '' then return 'ERROR: no taxon supplied' end
	local n = tonumber(frame.args['n'] or 1)
	if n > MaksAramaSeviyesi then
		return 'Exceeded maximum number of levels allowed (' .. MaksAramaSeviyesi .. ')'
	end
	local i = 1
	local inHierarchy = true -- still in the taxonomic hierarchy or off the top?
	while i < n and inHierarchy do
		local ok, parent = p.getirTaksonBilgiOgesi(frame, currTaxon, 'ebeveyn')
			if ok and parent ~= '' then
			currTaxon = parent
			i = i + 1
		else
			inHierarchy = false
		end
	end
	if inHierarchy then return currTaxon
	else return 'Level ' .. n .. ' is past the top of the taxonomic hierarchy'
	end
end

--[[============================ nSeviyeler =================================
External utility function primarily intended for use in checking and debugging.
Returns number of levels in a taxonomic hierarchy, starting from
the supplied taxon as level 1.
Kullanımı: {{#invoke:Ototaksonkutu|nSeviyeler|TAKSON}}
=============================================================================]]
function p.nSeviyeler(frame)
	local currTaxon = frame.args[1] or ''
	if currTaxon == '' then return 'ERROR: no taxon supplied' end
	local i = 1
	local inHierarchy = true -- still in the taxonomic hierarchy or off the top?
	while inHierarchy and i < MaksAramaSeviyesi  do
		local ok, parent = p.getirTaksonBilgiOgesi(frame, currTaxon, 'ebeveyn')
		if ok and parent ~= '' then
			currTaxon = parent
			i = i + 1
		else
			inHierarchy = false
		end
	end
	if inHierarchy then return MaksAramaSeviyesi .. '+'
	else return i
	end
end

--[[=========================== siralaHepsi =================================
External utility function primarily intended for use in checking and debugging.
Returns a comma separated list of a taxonomic hierarchy, starting from
the supplied taxon.
Kullanımı: {{#invoke:Ototaksonkutu|siralaHepsi|TAKSON}}
=============================================================================]]
function p.siralaHepsi(frame)
	local currTaxon = frame.args[1] or ''
	if currTaxon == '' then return 'ERROR: no taxon supplied' end
	return l.doListAll(l.yapTablo(frame, currTaxon))
end

function l.doListAll(taxonTable, taxonRankTable)
	local lst = taxonTable[1] .. '-' .. tostring(taxonRankTable[1])
	for i = 2, taxonTable.n, 1 do
		lst = lst .. ', ' .. taxonTable[i] .. '-' .. taxonRankTable[i]
	end
	return lst
end

--[[============================== cogulSira ================================
Kullanımı: {{#invoke:Ototaksonkutu|cogulSira|SIRA}}
=============================================================================]]

function p.getirCogulSira(deger)
	local islem = veri.getirTabloyaGore(deger, "çeviri sıra")
	return veri.getirTabloyaGore(islem, "çoğul sıra") or
		"<strong class='error'>"
		.."Tanınamayan sıra: ".. deger .." <small>[[Modül:Ototaksonkutu/veri|değiştir]]</small>[[Kategori:Otomatik taksonkutu temizleme]]"
		.."</strong>"
end

function p.cogulSira(frame)
	return p.getirCogulSira(frame.args[1])
end

--[[============================== altSira ==================================
Kullanımı: {{#invoke:Ototaksonkutu|altSira|SIRA}}
=============================================================================]]

function p.getirAltSira(deger)
	local islem = veri.getirTabloyaGore(deger, "çeviri sıra")
	return veri.getirTabloyaGore(islem, "alt sıra") or
		"<strong class='error'>"
		.."Tanınamayan sıra: ".. deger .." <small>[[Modül:Ototaksonkutu/veri|değiştir]]</small>[[Kategori:Otomatik taksonkutu temizleme]]"
		.."</strong>"
end

function p.altSira(frame)
	return p.getirAltSira(frame.args[1])
end

--[[============================= esasSira ==================================
Kullanımı: {{#invoke:Ototaksonkutu|esasSira|SIRA}}
=============================================================================]]

function l.getirEsasSira(deger)
	local yazi = mw.ustring.gsub(mw.ustring.gsub( mw.getContentLanguage():lc(deger), "ichno", "" ), "oo", "")
	return veri.getirTabloyaGore(yazi, "esas sıra") or "hayır"
end

function p.esasSira(frame)
	return l.getirEsasSira(frame.args[1])
end

--[[=========================== ceviriSira ==================================
Kullanımı: {{#invoke:Ototaksonkutu|ceviriSira|SIRA|KONTROL}}
=============================================================================]]

function l.getirCeviriSira(deger, kontrol)
	local yazi = deger
	local sayfaAdi = mw.title.getCurrentTitle().text
	if mw.ustring.sub( mw.getContentLanguage():lc(yazi), 1, 7 ) == "sırasız" then
		yazi = "(sırasız)"
	else
		yazi = mw.ustring.gsub( yazi, "/(.*)", "" )
		if veri.getirTabloyaGore(yazi, "çeviri sıra") then
			yazi = veri.getirTabloyaGore(yazi, "çeviri sıra")
		else
			yazi = (kontrol == "evet" and "<span style='background-color:#F99'>" or "") .. yazi
				.. (kontrol == "evet" and "</span>" or "")
				.. (mw.ustring.gsub( sayfaAdi, "/(.*)", "" ) == "Taksonomi"
					and "[[Kategori:Tanınmayan sıra kullanan taksonomi şablonları]]" or "")
		end
	end
	
	if kontrol == "evet" and mw.ustring.gsub( sayfaAdi, "/(.*)", "" ) == "Taksonomi" then
		yazi = yazi .. (mw.getContentLanguage():lcfirst(deger) == deger and ""
						or "[[Kategori:Baş harfi büyük sıra adı kullanan taksonomi şablonları]]")
	end
	
	return mw.getContentLanguage():ucfirst(yazi)
end

function p.ceviriSira(frame)
	return l.getirCeviriSira(frame.args[1], frame.args[2] or "hayır")
end

--[[=========================== italikTakson ================================
Kullanımı: {{#invoke:Ototaksonkutu|italikTakson|TAKSON|VİRÜS}}
=============================================================================]]

function p.getirItalikTakson(deger, virus)
	if virus == "evet" then
		return veri.getirTabloyaGore(deger, "italik virüs") or "evet"
	else
		return veri.getirTabloyaGore(deger, "italik takson") or "hayır"
	end
end

function p.italikTakson(frame)
	return p.getirItalikTakson(frame.args[1], frame.args[2] or "hayır")
end

--[[=========================================================================
Modülde kullanılan fonksiyonlar
=============================================================================]]

--[[= = = = = = = = = = = = = = = = Önyükleme  = = = = = = = = = = = = = = = =

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =]]

function p.onyukleme(frame)
	return l.taksonomiOlustur("Denimilia")
end

function l.onyukleme(takson)
	local bir = l.secIlk(takson)
	local iki = l.secSon(takson)
	local uc = mw.ustring.find(iki, "/") and l.secSon(iki) or ""
	iki = mw.ustring.find(iki, "/") and l.secIlk(l.secSon(takson)) or iki

	local sonuc
	if iki == "?" or uc == "?" then
		sonuc = "önyükleme/?" .. (iki == "?" and uc or "")
	elseif mw.getContentLanguage():lc(bir) == "incertae sedis" or mw.getContentLanguage():lc(bir) == "belirsiz yerleştirme" then
		sonuc = "önyükleme/belirsiz_yerleştirme"
	else
		sonuc = iki ~= "" and "aynısı" or "önyükleme"
	end
	
	return sonuc
end

function l.secIlk(baslik)
	return mw.ustring.gsub(baslik, "/+[^/]*", "")
end

function l.secSon(baslik)
	return mw.ustring.gsub(baslik, "^[^/]*/*", "")
end

function l.taksonomiOlustur(takson, mesaj)
	local sonuc = "|-\n|"
	
	if l.secSon(mw.title.getCurrentTitle().text) == takson then
		sonuc = sonuc .. "Şu anda oluşturduğunuz takson:"
	else
		sonuc = sonuc .. "<span style='color: Red;'>"..(mesaj or "Tanınmayan takson").."</span> (<span class=plainlinks>"
			.. "[".. l.taksonomiOlusturBag(takson) .." düzenle]</span>):"
	end
	
	sonuc = sonuc .. "\n|[["..takson.."]]"
		.. ((mw.title.getCurrentTitle().namespace == 0 or mw.title.getCurrentTitle().nsText == "Şablon")
			and "[[Kategori:Otomatik taksonkutu temizleme]]" or "") .. "\n|-"
	
	return sonuc
end

function l.taksonomiOlusturBag(takson)
	return "//tr.wikipedia.org/w/index.php?action=edit&title=Şablon:Taksonomi/"
		.. mw.uri.encode(mw.getContentLanguage():ucfirst(takson))
		.. "&preload=Şablon:Taksonomi/"
		.. l.onyukleme(takson)
end

--[[= = = = = = = = = = = = birTaksonuDuzenle  = = = = = = = = = = = = = = = =

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =]]
function l.birTaksonuDuzenle(taksonAdi)
	local baglanti = "<span class='plainlinks' style='font-size:small; float:right'>&nbsp;&#91;"
	
	if taksonAdi then
		baglanti = baglanti .. "[[Şablon:Taksonomi/" .. taksonAdi .. "|Taksonomi]];"
			.. " [//tr.wikipedia.org/w/index.php?title=Şablon:Taksonomi/" .. mw.uri.encode(taksonAdi)
			.. "&action=edit değiştir]&#93;</span>"
	end
	
	return baglanti
end

--[[= = = = = = = = = = = = kirpFazlaliklar  = = = = = = = = = = = = = = = = =
Internal utility function to strip off any extra parts of a taxon name, i.e.
anything after a '/'. Thus 'Felidae/?' would be split into 'Felidae' and '?'.
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =]]
function l.kirpFazlaliklar(taxonName)
	local i = mw.ustring.find(taxonName, '/', 1, true)
	if i then
		return mw.ustring.sub(taxonName, 1, i-1), mw.ustring.sub(taxonName, i, -1)
	else
		return taxonName, ''
	end
end

--[[= = = = = = = = = = = = splitTaxonName  = = = = = = = = = = = = = = = = =
Internal utility function to split a taxon name into its parts and return
them. Possible formats include:
* taxon
* taxon (disambig)
* taxon (Subgenus)
* taxon/qualifier
* combinations, e.g. taxon (disambig)/qualifier
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =]]
function l.ayirTaksonAdlari(taxon)
	-- get any qualifier present
	local qualifier = ''
	local i = mw.ustring.find(taxon, '/', 1, true)
	if i then
		qualifier = mw.ustring.sub(taxon, i+1, -1)
		taxon = mw.ustring.sub(taxon, 1, i-1)
	end
	-- get any disambiguator or subgenus
	local disambig = ''
	local subgenus = ''
	i = mw.ustring.find(taxon, ' (', 1, true)
	if i then
		local parenTerm = mw.ustring.sub(taxon, i+2, -2)
		taxon = mw.ustring.sub(taxon, 1, i-1)
		local char1 = mw.ustring.sub(parenTerm, 1, 1)
		if char1 == mw.ustring.lower(char1) then
			disambig = parenTerm
		else
			subgenus = parenTerm
		end
	end
	return taxon, disambig, subgenus, qualifier
end

--[[= = = = = = = = = = = = matchTaxonLink  = = = = = = = = = = = = = = = = =
Function to determine whether the taxon name derived from the name of the 
taxonomy template (passed in the parameter taxon) matches the link text
(passed in the parameter linkText).
The taxon name may have any of the formats:
* baseTaxon/qualifier
* baseTaxon (disambig)
* baseTaxon (Subgenus) [distinguished by the capital letter]
* a qualifier may be present after the previous two formats.

Examples of matches (baseTaxon ~ linkText):
* Pinus ~ Pinus
* Pinus sect. Trifoliae ~ Pinus sect. Trifoliae
* Pinus sect. Trifoliae ~ ''Pinus'' sect. ''Trifoliae'' [italic markers ignored]
* Pinus sect. Trifoliae ~ P. sect. Trifoliae [abbreviated genus name matches]
* Bombus (Pyrobombus) ~ Bombus (Pyrobombus)
* Bombus (Pyrobombus) ~ B. (Pyrobombus)
* Bombus (Pyrobombus) ~ Pyrobombus [link text may just be the subgenus]
* Heteractinida ~ "Heteractinida" [double-quotes are ignored in link text]
* "Heteractinida" ~ Heteractinida [double-quotes are ignored in base taxon name]
* Incertae sedis ~ anything [link text is ignored for matching in this case]
* Cetotheriidae with qualifier=? ~ Cetotheriidae (?)
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =]]
function l.matchTaxonLink(taxon, linkText, rankBelowGenus)
	local dummy
	linkText, dummy = mw.ustring.gsub(linkText, "''", '') -- remove any italic wikitext in the link text
	linkText, dummy = mw.ustring.gsub(linkText, '<.->', '') -- strip all tags used to format the link text
	linkText, dummy = mw.ustring.gsub(linkText, '"', '') -- remove any occurrences of " in the link text
	local baseTaxon, disambig, subgenus, qualifier = l.ayirTaksonAdlari(taxon) -- split up the taxon name
	baseTaxon, dummy = mw.ustring.gsub(linkText, '"', '') -- remove any occurrences of " in the base taxon name
	local match = linkText == baseTaxon or
	              linkText == subgenus or
	              linkText == baseTaxon .. ' (' .. subgenus .. ')' or
	              linkText ==  mw.ustring.sub(baseTaxon, 1, 1) .. '. (' .. subgenus .. ')' or
	              baseTaxon == 'Incertae sedis' or
	              rankBelowGenus and linkText == mw.ustring.gsub(baseTaxon, '([A-Z]).- (.*)', '%1. %2') or 
	              mw.ustring.find(qualifier, '?', 1, true) and mw.ustring.find(linkText, baseTaxon, 1, true) == 1
	return match
end

--[[= = = = = = = = = = = = yapKaynaklariGoster  = = = = = = = = = = = = = = =
Show the refs field in a taxonomy template.
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =]]
function l.yapKaynaklariGoster(taxonName, refs)
	if mw.text.split(taxonName, '/', true)[1] == 'Incertae sedis' then
		refs = 'gösterilemez (<i>incertae sedis</i>)'
	elseif refs == '' then
		refs = '–'
	end
	return refs
end

--[[= = = = = = = = = = = = = makeTable = = = = = = = = = = = = = = = = = = =
Internal utility function to return a table (array) constructed from a
taxonomic hierarchy stored in "Şablon:Taksonomi/..." templates.
TABLE.n holds the total number of taxa; TABLE[1]..TABLE[TABLE.n] the taxon
names.
The last taxon in the table will either (a) have a taxonomy template but with
no parent given (e.g. 'Life') or (b) not have a taxonomy template.
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =]]
function l.yapTablo(frame, currTaxon)
	local taxonTable = {}
	local taxonRankTable = {}
	local ok, rank, parent
	local i = 1
	local topReached = false -- reached the top of the taxonomic hierarchy?
	repeat
		taxonTable[i] = currTaxon
		ok, rank = p.getirTaksonBilgiOgesi(frame, currTaxon, 'sıra')
		if ok then taxonRankTable[i] = string.lower(rank) else taxonRankTable[i] = '' end
		ok, parent = p.getirTaksonBilgiOgesi(frame, currTaxon, 'ebeveyn')
		if ok and parent ~= '' then
			currTaxon = parent
			i = i + 1
		else
			topReached = true -- reached the top of the hierarchy or tried to use a non-existent taxonomy template
		end
	until topReached or i > MaksAramaSeviyesi
	taxonTable.n = math.min(i, MaksAramaSeviyesi)
	return taxonTable, taxonRankTable
end

--[[= = = = = = = = = = = = getRankTable  = = = = = = = = = = = = = = = = = =
Internal utility function to set up a table of numerical values corresponding
to 'Linnaean' ranks, with upper ranks having higher values. In a valid
taxonomic hierarchy, a lower rank should never have a higher value than a
higher rank. The actual numerical values are arbitrary so long as they are
ordered.
The ranks should correspond to those in Şablon:Taksonkutu/Çeviri sıralama.
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =]]
function l.getirSiraTablosu()
	return {
		['sınıf'] = 1400,
		cohort = 1100,
		['bölüm'] = 1500,
		domain = 1700,
		familya = 800,
		forma = 100,
		['cins'] = 600,
		grandordo = 1005,
		['grandordo-mb'] = 1002,
		hyperfamilia = 805;
		['infrasınıf'] = 1397,
		infralegio = 1197,
		['infratakım'] = 997,
		['infraşube'] = 1497,
		infraalem = 1597,
		infraoymak = 697,
		legio = 1200,
		magnordo = 1006,
		['mikroşube'] = 1495,
		['mikrotakım'] = 995,
		mirordo = 1004,
		['mirordo-mb'] = 1001,
		nanophylum = 1494,
		nanordo = 994,
		['takım'] = 1000,
		parafamilia = 800,
		parvclassis = 1396; -- same as subterclassis
		parvordo = 996,
		['şube'] = 1500,
		alem = 1600,
		seksiyon = 500,
		--seri = 400, used too inconsistently to check
		['tür'] = 300,
		['altsınıf'] = 1398,
		subcohort = 1098,
		['altbölüm'] = 1498,
		altfamilya = 798,
		altcins = 598,
		sublegio = 1198,
		['alttakım'] = 998,
		['altşube'] = 1498,
		altalem = 1598,
		altseksiyon = 498,
		['alttür'] = 298,
		subterclassis = 1396; -- same as parvclassis
		altoymak = 698,
		['üstsınıf'] = 1403,
		supercohort = 1103,
		['üstbölüm'] = 1503,
		superdomain = 1703,
		['üstfamilya'] = 803,
		superlegio = 1203,
		['üsttakım'] = 1003,
		['üstşube'] = 1503,
		['üstalem'] = 1603,
		['üstoymak'] = 703,
		oymak = 700,
		varyete = 200,
		zoodivisio = 1300,
		zoosectio = 900,
		zoosubdivisio = 1298,
		zoosubsectio = 898,
	}
end

--[[= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Function to look up the arbitrary numerical value of a rank in a rank value
table. "Ichno" and "oo" ranks are not stored separately, so if present the
prefix is removed.
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =]]
function l.araSiraDegeri(rankValTable, rank)
	local rankVal = rankValTable[rank]
	if not rankVal then
		-- may be an "ichno" or "oo" ranks
		rank = mw.ustring.gsub(mw.ustring.gsub(rank, '^ichno', ''), '^oo', '')
		if rank == 'rdo' then rank = 'ordo' end
		rankVal = rankValTable[rank]
	end
	return rankVal
end

--[[= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =]]
function l.tabloHucresi(arg1, arg2)
	local text, style
	if arg2 then
		style = arg1
		text = arg2
	else
		style = ''
		text = arg1
	end
	local res = '|'
	if style ~= '' then
		res = res .. style .. '|'
	end
	return res .. text .. '\n'
end

return p