For faster navigation, this Iframe is preloading the Wikiwand page for Модуль:CategoryForProfession.

Модуль:CategoryForProfession

Материал из Википедии — свободной энциклопедии

Документация

Используется в шаблонах о персоналиях.

В 2015 году модуль был намеренно сломан (на подстранице Модуль:ListOfProfessions), поскольку ставил любые комбинации вида <профессия><страны>, что в общем случае неверно. Для включения модуля или его аналога для автоматически заполняемых карточек, следует обернуть все его влючения в условия отсутствия заполнения соответствующих полей карточки «род деятельности», «профессия» и аналогичных, а затем включить его обратно, причем не целиком, а только в части алфавитных категорий.

Функции

Используется только одна функция — mainFunction. Она добавляет в статью категории профессий по алфавиту, и профессий по странам. Сами профессии, гражданства и академические степени берёт на викиданных.

Для использования данного модуля напишите: ((#invoke:CategoryForProfession|mainFunction))

Функции данного модуля не предназначены для прямого вызова из шаблонов карточек или других модулей.

В параметре без категорий= можно указать через точку с запятой перечень категорий которые нужно исключить.

См. также

local p = {}

-- отключено в связи с тем, что модуль был намеренно сломан в 2015 году
-- на подстранице 'Модуль:ListOfProfessions'
--[===[
local ListOfProfessions = mw.loadData( 'Модуль:ListOfProfessions' )
local ListOfCountries = mw.loadData( 'Модуль:ListOfCountries' )

local ProfessionsCategoryByAlphabet = {}
for k, v in pairs(ListOfProfessions) do
	ProfessionsCategoryByAlphabet[k] = '[[Категория:' .. v .. ' по алфавиту]]'
end

local ProfessionsCategoriesByCountry = {}
local QQQ = {}
for i, j in pairs(ListOfCountries) do
	QQQ = {}
	for k, v in pairs(ListOfProfessions) do
		QQQ[k] = '[[Категория:' .. v ..' ' .. j ..']]'
	end
	ProfessionsCategoriesByCountry[i] = QQQ
end
--]===]

local function MakeGeneralCategories(professionsList, dict)
	local res = ''
	for i, prof in pairs(professionsList) do
		local cat=nil
		if(prof.mainsnak.datavalue) then -- если значение свойства "значение неизвестно", то datavalue nil
			id = 'Q' .. prof.mainsnak.datavalue.value['numeric-id']
			cat = dict[id];
		end
		if cat ~= nil then
			res = res .. cat;	
		end
	end
    return res
end

local function MakeCountriesCategories(countriesList, professionsList)
	local res = ''
	for i, cant in pairs(countriesList) do
		if cant.mainsnak.datavalue ~= nil then
			id = 'Q' .. cant.mainsnak.datavalue.value['numeric-id']
			local professionsCategories = ProfessionsCategoriesByCountry[id];
			if professionsCategories ~= nil then
				res = res .. MakeGeneralCategories(professionsList, professionsCategories);
			end
		end
	end
    return res
end

function p.mainFunction(frame)
	-- отключение модуля в связи с тем, что он был намеренно сломан в 2015 году
	-- на подстранице 'Модуль:ListOfProfessions'
	do	return '' end
	
	local result = ''
	local wbStatus, entity = pcall( mw.wikibase.getEntity )

	if wbStatus ~= true then
		return '' -- [[Категория:Википедия:Страницы с ошибками скриптов, использующих Викиданные]]
	end

	if entity ~= nil and entity.claims ~= nil then
		if entity.claims[ 'P106' ] ~= nil then
			professions = entity.claims[ 'P106' ]
			result = result .. MakeGeneralCategories(professions, ProfessionsCategoryByAlphabet)
			if entity.claims[ 'P27' ] ~= nil then
				countries = entity.claims[ 'P27' ]
				result = result .. MakeCountriesCategories(countries, professions)
			end
		end
		local args = {}
		if frame == mw.getCurrentFrame() then
			if frame.args['без категорий'] == nil then
				frame = frame:getParent();
			end
			if frame ~= nil then
				args = frame.args;
			end
		else
			args = frame
		end
		-- исключаем ненужные категории указанные в параметре через точку с запятой
    	local excude = args['без категорий'];
    	if excude ~= nil and excude ~= '' then
    		exclude = mw.text.split(excude, '%s*;%s*' )
			for i, v in ipairs(exclude) do 
				local cat = mw.ustring.gsub( v, "([%(%)%.%%%+%-%*%?%[%^%$%]])", "%%%1" ); -- маскируем спецсимволы
				result = mw.ustring.gsub(result, '%[%[Категория:' .. cat .. '%]%]', '');	
			end
    	end;
	end
	return result
end

return p
{{bottomLinkPreText}} {{bottomLinkText}}
Модуль:CategoryForProfession
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?