Модуль:Wikidata/Medals

Материал из Википедии — свободной энциклопедии
Перейти к навигации Перейти к поиску
Документация

Модуль содержит функции форматирования для свойства и отдельных значений наград (полученные награды (P166)).

Функции модуля нельзя вызывать напрямую — они передаются в виде аргументов из соответствующих связанных шаблонов (и только из них, в другие шаблоны их также вставлять не нужно).

Обновление

Порядок наград обновляется в полуавтоматическом режиме при помощи скрипта. Не обновляйте его вручную, вместо этого исправьте значения свойств в Викиданных, и через некоторое время он будет обновлён.

Для того, чтобы награда попала в список, заполните в её элементе следующие свойства:

Если изображение награды не появляется, проверьте, установлены ли в элементе награды свойства изображение орденской планки (P2425) или пиктограмма (P2910). Категории проставляются через категория лауреатов награды (P2517)

Тесты

N 1 тест провалился.

Название Ожидается Фактически
N testGetImageFromEntity [[File:Золотая Звезда Героя Советского Союза.svg|40x40px]] [[File:Hero of the Soviet Union.png|x17px|border]]


Порядок сортировки

См. файл с порядком сортировки.

# Элемент Планка Название Государство
1 Q3885174 Order of Naval Merit Доминиканская Республика
2 Q112464 орден «За военные заслуги»
3 Q3885172 Order of Air Merit
4 Q113990376 действующий командор ордена Св. Иоанна
5 Q113990374 почётный командор ордена Св. Иоанна
6 Q113990371 кавалер ордена Св. Иоанна (вторая низшая степень)
7 Q18559565 почётный кавалер ордена Св. Иоанна
8 Q114345397 Knight Grand Cross of the Order of Saint Lazarus of Jerusalem
9 Q114345388 Knight Commander of the Order of Saint Lazarus of Jerusalem
10 Q114345368 Knight of the Order of Saint Lazarus of Jerusalem
11 Q114345407 Dame Grand Cross of the Order of Saint Lazarus of Jerusalem
12 Q114345412 Dame Commander of the Order of Saint Lazarus of Jerusalem
13 Q114345425 Dame of the Order of Saint Lazarus of Jerusalem
14 Q114345345 Commander of the Order of Saint Lazarus of Jerusalem
15 Q114345328 Officer of the Order of Saint Lazarus of Jerusalem
16 Q114345317 Member of the Order of Saint Lazarus of Jerusalem
17 Q4891694 India General Service Medal
18 Q2309070 звезда «1939—1945» Великобритания
19 Q2757888 Атлантическая звезда
20 Q12176893 Arctic Star
21 Q2005654 Air Crew Europe Star Великобритания
22 Q2701827 Африканская звезда Великобритания
23 Q2700447 Pacific Star Великобритания, Британская империя
24 Q767943 Бирманская звезда
25 Q2702037 Итальянская звезда Великобритания, Содружество наций
26 Q2354625 Французская и Германская звезда Великобритания, Содружество наций
27 Q93710 орден Индийской империи Великобритания
28 Q94141 орден «За заслуги в полицейских силах» Канада
29 Q94050 Королевский Викторианский орден Великобритания
30 Q14420 орден Британской империи Великобритания
31 Q1127626 крест «За выдающуюся храбрость» Великобритания
32 Q94340 Королевский Красный крест Великобритания
33 Q1229529 крест «За выдающиеся заслуги» Великобритания
34 Q98099641 Third Bar to the Military Cross Великобритания
35 Q18771631 Military Cross and Two Bars Великобритания
36 Q18771549 Military Cross and Bar Великобритания
37 Q1335064 Военный крест Великобритания
38 Q1229534 крест «За выдающиеся лётные заслуги» Великобритания
39 Q2427600 Крест Военно-воздушных сил Великобритания
40 Q339016 Медаль За выдающиеся заслуги Великобритания
41 Q586333 Conspicuous Gallantry Medal
42 Q1507907 Медаль Георга Великобритания
43 Q7113935 медаль Полиции заморских территорий Великобритания
44 Q72039 медаль Короля за отвагу
45 Q219578 крест Виктории Великобритания
46 Q3003423 Крест Виктории (Австралия) Австралия
47 Q1143510 крест Георга Великобритания
48 Q922732 Cross of Valour Австралия
49 Q215248 орден Подвязки Королевство Англия, Королевство Великобритания, Соединённое королевство Великобритании и Ирландии, Великобритания
50 Q721030 орден Чертополоха Великобритания
51 Q1326038 орден Святого Патрика Великобритания
52 Q506369 орден Бани Великобритания
53 Q1330936 орден Звезды Индии Великобритания
54 Q585087 Орден Святого Михаила и Святого Георгия Великобритания, Соединённое королевство Великобритании и Ирландии
55 Q12201378 рыцарь Большого креста ордена Британской империи Великобритания
56 Q16943677 дама Большого креста ордена Британской империи Великобритания
57 Q12201434 дама-командор ордена Британской империи Великобритания
58 Q12201445 рыцарь-командор ордена Британской империи Великобритания
59 Q12201477 командор ордена Британской империи Великобритания
60 Q615838 орден «За выдающиеся заслуги» Великобритания
61 Q12192290 рыцарь Большого креста Королевского Викторианского ордена Великобритания
62 Q12192384 дама Большого креста Королевского Викторианского ордена Великобритания
63 Q12192560 дама-командор Королевского Викторианского ордена Великобритания
64 Q12192712 рыцарь-командор Королевского Викторианского ордена Великобритания
65 Q12193183 командор Королевского Викторианского ордена Великобритания
66 Q12193574 лейтенант Королевского Викторианского ордена Великобритания
67 Q12193926 член Королевского Викторианского ордена Великобритания
68 Q5163408 Conspicuous Service Medal Австралия
69 Q4823818 Австралийская антарктическая медаль Австралия
70 Q1635491 орден Индийской короны Великобритания
71 Q1137694 орден Кавалеров Почёта Великобритания
72 Q973829 орден Новой Зеландии Новая Зеландия
73 Q94162 орден Заслуг Новая Зеландия
74 Q16933258 New Zealand Gallantry Decoration Новая Зеландия
75 Q7015242 New Zealand Bravery Decoration Новая Зеландия
76 Q2593632 Орден Британской Индии Индия
77 Q2423226 Кайсар-и-Хинд Индия
78 Q1465984 орден Святого Иоанна Иерусалимского Великобритания
79 Q7015385 New Zealand Gallantry Medal Новая Зеландия
80 Q7015243 New Zealand Bravery Medal Новая Зеландия
81 Q640996 медаль Королевского Викторианского ордена Великобритания
82 Q7270113 Queen's Service Medal Новая Зеландия
83 Q11790895 New Zealand Antarctic Medal Новая Зеландия
84 Q7015335 New Zealand Distinguished Service Decoration Новая Зеландия
85 Q918601 Медаль Британской империи Великобритания
86 Q18149754 Canada Medal Канада
87 Q2792177 King's Police Medal
88 Q267950 Empire Gallantry Medal
89 Q7015960 New Zealand campaign medals
90 Q16957496 New Zealand Special Service Medal
91 Q2707693 King's Fire Service Medal Великобритания
92 Q7269921 King's Ambulance Service Medal
93 Q2894808 King's Volunteer Reserves Medal Великобритания
94 Q2387610 Queen's Medal for Chiefs Британская империя
95 Q16983512 Badge of Honour
96 Q15410461 Британские медали за участие в кампании Великобритания
97 Q1093361 Полярная медаль Великобритания
98 Q6006872 медаль Имперской службы
99 Q18149115 African Distinguished Conduct Medal
100 Q2404179 Indian Distinguished Service Medal Индия
101 Q1818366 Union of South Africa King's Medal for Bravery ЮАР
102 Q6483675 Медаль «За выдающиеся заслуги» (Великобритания) Великобритания
103 Q1584344 Воинская медаль Великобритания
104 Q3503150 Медаль «За выдающиеся лётные заслуги» Соединённое королевство Великобритании и Ирландии
105 Q2592666 Медаль Военно-Воздушных сил (Великобритания) Великобритания
106 Q2500743 Constabulary Medal
107 Q1935462 медаль «За спасение жизни на море» Великобритания
108 Q764256 Indian Order of Merit Индия
109 Q2424249 Indian Police Medal Индия
110 Q2800343 Ceylon Police Medal
111 Q524516 медаль Обороны Великобритания
112 Q5030672 Canadian Volunteer Service Medal
113 Q11790920 Newfoundland Volunteer War Service Medal Канада
114 Q684444 Военная медаль 1939–1945 Великобритания
115 Q4689592 Africa Service Medal Южно-Африканский Союз
116 Q6431666 Korea Medal
117 Q5065797 Ceylon Police Long Service Medal
118 Q5030669 Canadian Volunteer Service Medal for Korea Канада
119 Q7455697 Service Medal of the Order of St John Канада
120 Q94817 коронационная медаль Георга V Великобритания
121 Q3332378 Gulf and Kuwait Medal Канада
122 Q7940958 Voluntary Medical Service Medal
123 Q25168495 Women's Royal Voluntary Service Medal
124 Q5152371 Commendation for Gallantry Австралия
125 Q5152367 Commendation for Brave Conduct Австралия
126 Q7565730 South African Medal for War Services ЮАР
127 Q5152370 Commendation for Distinguished Service Австралия
128 Q7269958 Queen's Commendation for Brave Conduct Великобритания
129 Q3003420 Крест Виктории (Новая Зеландия) Новая Зеландия
130 Q7015386 New Zealand Gallantry Star Новая Зеландия
131 Q1983220 New Zealand Cross Новая Зеландия
132 Q7015244 New Zealand Bravery Star Новая Зеландия
133 Q658976 Почётный орден королевы Новая Зеландия
134 Q1810753 орден Имперской службы Великобритания
135 Q16006972 рыцарь — великий командор ордена Индийской империи Великобритания
136 Q10762848 офицер ордена Британской империи Великобритания
137 Q16008267 рыцарь-командор ордена Индийской империи Британская Индия
138 Q79969696 Kaisar-i-Hind Medal, first class Индия
139 Q16008317 компаньон ордена Индийской империи Великобритания
140 Q27839491 Associate of the Royal Red Cross Великобритания
141 Q12201526 член ордена Британской империи Великобритания
142 Q5163406 Крест службы по призыву Австралия
143 Q7070255 Nursing Service Cross Австралия
144 Q3370636 Medal for Gallantry Австралия
145 Q833163 рыцарь-бакалавр Великобритания
146 Q7601244 Star of Gallantry Австралия
147 Q4958415 Bravery Medal Австралия
148 Q9343750 Star of Courage Австралия
149 Q5282996 Distinguished Service Medal Австралия
150 Q5282995 Distinguished Service Cross Австралия
151 Q7257613 Public Service Medal Австралия
152 Q4824569 Australian Police Medal Австралия
153 Q4824168 Australian Fire Service Medal Австралия
154 Q4741946 Ambulance Service Medal Австралия
155 Q5370654 Emergency Services Medal Австралия
156 Q48815918 Australian Corrections Medal Австралия
157 Q1141149 орден Австралии Австралия
158 Q3306330 Merchant Marine Distinguished Service Medal
159 Q3306336 Merchant Marine Meritorious Service Medal
160 Q6818379 Героическое судно
161 Q3306334 Merchant Marine Mariner's Medal
162 Q6818378 Merchant Marine Combat Bar
163 Q3306327 Merchant Marine Defense Bar
164 Q3306326 Merchant Marine Atlantic War Zone Medal
165 Q660954 Merchant Marine Mediterranean-Middle East War Zone Medal
166 Q3306340 Merchant Marine Pacific War Zone Medal
167 Q16981891 Merchant Marine World War II Victory Medal США
168 Q3306329 Merchant Marine Korean Service Medal США
169 Q3306341 Merchant Marine Vietnam Service Medal США
170 Q3042870 Awards and decorations of the United States Merchant Marine
171 Q7238644 Prathamadhara Padakkama
172 Q94793 коронационная медаль Елизаветы II Великобритания
173 Q5065780 Ceylon Armed Services Long Service Medal
174 Q7585894 Sri Lanka Armed Services Long Service Medal
175 Q7241166 President's Inauguration Medal
176 Q25340134 50th Independence Anniversary Commemoration Medal
177 Q5264143 Desha Putra Sammanaya
178 Q25101594 Eastern Humanitarian Operations Medal
179 Q25101593 Northern Humanitarian Operations Medal
180 Q17072652 North and East Operations Medal
181 Q7261328 Purna Bhumi Padakkama
182 Q7908151 Vadamarachchi Operation Medal
183 Q7338902 Riviresa Campaign Services Medal
184 Q6373832 Karyakshama Seva Vibhushanaya
185 Q6373831 Karyakshama Seva Padakkama
186 Q24189500 Queen's Medal for Champion Shots of the Air Forces
187 Q5016433 Cadet Forces Medal
188 Q7015322 New Zealand Defence Service Medal
189 Q20715926 Ebola Medal for Service in West Africa
190 Q42916111 National Crime Agency Long Service and Good Conduct Medal
191 Q16983045 H.M. Coastguard Long Service and Good Conduct Medal
192 Q17101827 Special Constabulary Long Service Medal
193 Q20716437 Royal Air Force Long Service and Good Conduct Medal
194 Q16997506 Medal for Long Service and Good Conduct
195 Q16985998 Indian Long Service and Good Conduct Medal
196 Q17101503 Royal West African Frontier Force Long Service and Good Conduct Medal
197 Q16986006 Indian Meritorious Service Medal Индия
198 Q7209476 Police Long Service and Good Conduct Medal
199 Q17105428 Fire Brigade Long Service and Good Conduct Medal
200 Q16974362 African Police Medal for Meritorious Service
201 Q630949 Common Security and Defence Policy Service Medal
202 Q5589549 Governor General's Northern Medal Канада
203 Q5589545 Governor General's Caring Canadian Award Канада
204 Q5029816 медаль «В память 100-летия Канады» Канада
205 Q2059227 медаль Серебряного юбилея королевы Елизаветы II
206 Q4548436 медаль «В память 125-летия Канадской конфедерации» Канада
207 Q1581457 медаль Золотого юбилея королевы Елизаветы II Канада
208 Q194540 медаль Бриллиантового юбилея королевы Елизаветы II королевство Содружества, Великобритания, Содружество наций
209 Q7373905 Royal Canadian Mounted Police Long Service Medal Канада
210 Q3042865 Отличие вооружённых сил Канады Канада
211 Q7374636 Royal Observer Corps Medal
212 Q3332339 Civil Defence Medal
213 Q16974776 Ambulance Service (Emergency Duties) Long Service and Good Conduct Medal
214 Q16258267 Royal Fleet Auxiliary Service Medal
215 Q17101264 Prison Services (Operational Duties) Long Service and Good Conduct Medal
216 Q10264302 Iraq Medal Австралия
217 Q4824665 Australian Service Medal 1945–1975 Австралия
218 Q4824202 Australian General Service Medal Korea Австралия
219 Q4824669 Australian Service Medal Австралия
220 Q4824517 Australian Operational Service Medal Австралия
221 Q7321055 Rhodesia Medal Австралия
222 Q17142598 Royal Ulster Constabulary Service Medal
223 Q16958931 Northern Ireland Prison Service Medal
224 Q17111529 Union of South Africa Commemoration Medal ЮАР
225 Q2500549 Медаль Независимости Индии Индия
226 Q7125627 Pakistan Medal
227 Q17023174 Prashansaniya Seva Vibhushanaya
228 Q7238495 Prashansaniya Seva Padakkama
229 Q5065779 Ceylon Armed Services Inauguration Medal
230 Q48726940 Sri Lanka Army Volunteer Force Centenary Medal Шри-Ланка
231 Q7209448 Police Exemplary Service Medal Канада
232 Q104878100 Медаль Платинового юбилея королевы Елизаветы II Канада
233 Q5172804 Corrections Exemplary Service Medal Канада
234 Q16933211 Новозеландская памятная медаль (1990) Новая Зеландия
235 Q16933403 New Zealand Suffrage Centennial Medal 1993
236 Q5347425 Efficiency Decoration Великобритания
237 Q5451442 Fire Services Exemplary Service Medal Канада
238 Q5029876 Canadian Coast Guard Exemplary Service Medal Канада
239 Q7703742 Territorial Efficiency Medal
240 Q16933427 Meritorious Service Medal
241 Q16933241 New Zealand Defence Meritorious Service Medal
242 Q5370618 Emergency Medical Services Exemplary Service Medal Канада
243 Q16933321 New Zealand Police Meritorious Service Medal
244 Q60766933 New Zealand Public Service Medal
245 Q7015215 New Zealand Armed Forces Award Новая Зеландия
246 Q5347428 Efficiency Medal
247 Q7157403 Peace Officer Exemplary Service Medal Канада
248 Q25168476 Special Reserve Long Service and Good Conduct Medal
249 Q5249616 Decoration for Officers of the Royal Naval Reserve
250 Q7941051 Volunteer Reserve Decoration Великобритания
251 Q7315252 Reserve Long Service and Good Conduct Medal
252 Q17101496 Royal Naval Auxiliary Service Long Service Medal
253 Q4697857 Air Efficiency Award
254 Q7941050 Volunteer Reserves Service Medal
255 Q17039425 Ulster Defence Regiment Medal
256 Q17017997 Northern Ireland Home Service Medal
257 Q7270029 Queen's Medal for Champion Shots Канада
258 Q6673234 Long Service and Good Conduct Medal
259 Q20716199 New Zealand Police Long Service and Good Conduct Medal
260 Q16933245 New Zealand Fire Brigades Long Service and Good Conduct Medal
261 Q7094832 Ontario Medal for Good Citizenship Канада
262 Q20716206 New Zealand Traffic Service Medal
263 Q4914530 Bintang Temasek Сингапур
264 Q2177611 орден Темасека Сингапур
265 Q4771140 The Order of Nila Utama Сингапур
266 Q7513509 Sijil Kemuliaan
267 Q16148558 Darjah Utama Bakti Cemerlang Сингапур
268 Q7195764 Pingat Kehormatan
269 Q7195758 Pingat Gagah Perkasa
270 Q7195759 Pingat Jasa Gemilang Сингапур
271 Q4914524 Bintang Bakti Masyarakat
272 Q7195767 Pingat Pentadbiran Awam Сингапур
273 Q7195766 Pingat Kepujian
274 Q7195753 Pingat Bakti Masyarakat
275 Q7195755 Pingat Berkebolehan
276 Q7195754 Pingat Bakti Setia Сингапур
277 Q7195762 Pingat Keberanian
278 Q5223056 Darjah Utama Bakti Cemerlang
279 Q7195757 Pingat Gagah Perkasa
280 Q7195760 Pingat Jasa Gemilang (Tentera) Сингапур
281 Q7195768 Pingat Pentadbiran Awam (Tentera)
282 Q7195765 Pingat Penghargaan
283 Q7195756 Pingat Berkebolehan
284 Q6673233 Long Service Medal (Military) Сингапур
285 Q7522886 Singapore Armed Forces Long Service and Good Conduct (20 Years) Medal
286 Q7522882 Singapore Armed Forces Long Service and Good Conduct (10 Years) Medal
287 Q7522891 Singapore Armed Forces National Service Medal
288 Q7522884 Singapore Armed Forces Good Service Medal
289 Q7522895 Singapore Armed Forces Overseas Service Medal
290 Q17143553 Secretary's Distinguished Service Award
291 Q7444230 Secretary's Award
292 Q4829837 За проявленный героизм
293 Q7603183 State Department Award for Valor
294 Q7791289 Thomas Jefferson Star for Foreign Service США
295 Q7866431 USIA Distinguished Honor Award
296 Q7866434 USIA Superior Honor Award
297 Q7866433 USIA Meritorious Honor Award
298 Q7865744 USAID Distinguished Honor Award
299 Q7865746 USAID Superior Honor Award
300 Q7865745 USAID Meritorious Honor Award
301 Q17004587 Distinguished Honor Award
302 Q7643538 Superior Honor Award
303 Q6819561 Meritorious Honor Award
304 Q7928495 Vietnam Civilian Service Award
305 Q4650570 ACDA Distinguished Honor Award
306 Q4650572 ACDA Superior Honor Award
307 Q4650571 ACDA Meritorious Honor Award
308 Q5420980 Expeditionary Service Award
309 Q7444234 Secretary's Career Achievement Award
310 Q6241421 John Jacob Rogers Award
311 Q203535 медаль Почёта США
312 Q833376 крест «За выдающиеся заслуги» США
313 Q407132 крест Военно-воздушных сил США
314 Q16199888 Coast Guard Cross США
315 Q11975757 Homeland Security Distinguished Service Medal США
316 Q7835169 Transportation Distinguished Service Medal
317 Q531410 медаль Министерства обороны «За выдающуюся службу» США
318 Q2981120 Coast Guard Distinguished Service Medal США
319 Q7257411 Медаль «За выдающиеся заслуги в службе общественного здравоохранения» (Министерство здравоохранения США)
320 Q1774648 медаль «За выдающиеся заслуги» США
321 Q7801207 Tiffany Cross Medal of Honor
322 Q1086458 медаль «За выдающуюся службу» ВМС США США
323 Q2731483 медаль «За выдающуюся службу» ВВС США США
324 Q852071 Серебряная звезда США
325 Q5260185 Department of Commerce Gold Medal
326 Q20716933 Public Health Service Meritorious Service Medal
327 Q16205025 Secretary of Transportation Outstanding Achievement Medal
328 Q2585651 медаль «За отличную службу»
329 Q5614061 Guardian Medal
330 Q724443 орден «Легион почёта» США
331 Q5260186 Department of Commerce Silver Medal
332 Q7646183 Surgeon General's Medallion
333 Q1754110 Крест лётных заслуг США
334 Q2828736 Airman's Medal США
335 Q5260184 Department of Commerce Bronze Medal
336 Q602928 Citation Star США
337 Q976753 медаль Береговой охраны США
338 Q1772872 медаль ВМФ и Корпуса морской пехоты США
339 Q4675298 медаль «За отличие в боевых операциях» США
340 Q1408756 Солдатская медаль США
341 Q2416255 Certificate of Merit Medal
342 Q928314 Бронзовая звезда США
343 Q25005028 Surgeon General's Exemplary Service Medal
344 Q6764079 Медаль внеочередного звания Корпуса морской пехоты США
345 Q20716259 NOAA Corps Meritorious Service Medal
346 Q833465 Военно-морской крест США
347 Q145752 Пурпурное сердце США
348 Q2500323 медаль «За похвальную службу»
349 Q20716251 NOAA Administrator's Award
350 Q1760530 медаль «За похвальную службу» США
5008 Q65130315 National Order of June 27 Джибути
local WDS = require( 'Module:WikidataSelectors' )
local moduleDate = require( 'Module:Wikidata/date' )
local awardsOrder = mw.ext.data.get( "Wikidata/awards order.tab" )
local p = {}

local config = {
	--Hide award with key QID if there is a reward with value QID
	absorption = {
		Q16675272 = 'Q654471',
		Q16481808 = 'Q8706404',
		Q1948730 = 'Q178473',
		Q1980962 = 'Q208167',
	}
}

--Get string with dates from qualifiers table
local function datesFromQualifier( context, options, qualifierId )
	local dates = {}
	local qualifiers = options.qualifiers[ qualifierId ]

	if qualifiers then
		for _, qualifier in pairs( qualifiers ) do
			if qualifier.datavalue then
				local dateValue = moduleDate.formatDate( context, options, qualifier.datavalue.value )
				if dateValue then
					table.insert( dates, dateValue )
				end
			end
		end
	end

	return table.concat( dates, ', ' )
end

--Property function for [[d:Property:P166]]
function p.formatProperty( context, options )
	if ( not context ) then error( 'context not specified' ); end;
	if ( not options ) then error( 'options not specified' ); end;
	if ( not options.entityId ) then error( 'options.entityId missing' ); end;

	local claims;
	if options.property then -- TODO: Почему тут может не быть property?
		claims = context.selectClaims( options, options.property );
	end
	if claims == nil then
		return '' --TODO error?
	end

	-- Обход всех заявлений утверждения и с накоплением оформленых
	-- предпочтительных заявлений в таблице.
	local formattedData = {}

	for i, claim in ipairs( claims ) do
		if ( claim.mainsnak and
			claim.mainsnak and
			claim.mainsnak.datavalue and
			claim.mainsnak.datavalue.type == 'wikibase-entityid'
		) then
			local valueId = claim.mainsnak.datavalue.value.id
			local formattedStatement = context.formatStatement( options, claim )
			-- здесь может вернуться либо оформленный текст заявления, либо строка ошибки, либо nil
			if ( formattedStatement and formattedStatement ~= '' ) then
				formattedStatement = '<span class="wikidata-claim" data-wikidata-property-id="' .. string.upper( options.property ) .. '" data-wikidata-claim-id="' .. claim.id .. '">' .. formattedStatement .. '</span>'
				table.insert( formattedData, {
					id = valueId,
					html = formattedStatement,
				} )
			end
		end
	end

	-- Удаление дублей (медаль + звание -> звание)
	for i, awardData in ipairs( formattedData ) do
		local isAbsorptionFound = false
		if config.absorption[ awardData.id ] then
			local absorptionAwardId = config.absorption[ awardData.id ]
			for _, absorptionAwardData in ipairs( formattedData ) do
				if absorptionAwardData.id == absorptionAwardId then
					isAbsorptionFound = true
					break
				end
			end
		end
		if isAbsorptionFound then
			table.remove( formattedData, i )
		end
	end
	
	-- Сортировка медалей по старшинству
	local orderedData = {}
	local lastValue;
	
	if ( type (awardsOrder) == 'table' ) then
		-- Если не отсохла stuctured data
		for i, awardFields in ipairs( awardsOrder.data ) do
			local awardOrder = awardFields[ 1 ]
			if awardOrder == '-' then
				-- separator
				if lastValue ~= '-' then
					table.insert( orderedData, '<br>' )
					lastHeight = nil
				end
			else
				for k, awardData in ipairs( formattedData ) do
					if awardOrder == awardData.id and not awardData.used then
						table.insert( orderedData, awardData.html )
						formattedData[ k ].used = true
					end
				end
			end
		end
	end

	for i, awardData in ipairs( formattedData ) do
		if not awardData.used then
			table.insert( orderedData, awardData.html )
		end
	end

	local lastHeight
	for i, awardHtml in ipairs( orderedData ) do
		local height = mw.ustring.match( awardHtml, 'x%d+px' )
		if height and lastHeight and height ~= lastHeight then
			table.insert( orderedData, i, '<br>' )
		end
		lastHeight = height
	end

	-- создание текстовой строки со списком оформленых заявлений из таблицы
	local out = mw.text.listToText( orderedData, options.separator, options.conjunction )
	if out ~= '' then
		if options.before then
			out = options.before .. out
		end
		if options.after then
			out = out .. options.after
		end
	end

	return out
end

local function getImageFromProperty( entityId, propertyId )
	local imageClaims = WDS.load( entityId, propertyId )
	if imageClaims and #imageClaims > 0 then
		for _, claim in ipairs( imageClaims ) do
			if claim.type == 'statement' and claim.mainsnak.snaktype == 'value' then
				return claim.mainsnak.datavalue.value
			end
		end
	end

	return nil
end

-- Получение изображения (планки или иконки) и его размера
function p.getImageFromEntity( entityId, actualDate )
	if type( entityId ) ~= "string" then
		entityId = entityId.id
	end

	local image = nil
	local size = 'x17px'
	local border = false

	-- получение изображения планки из элемента
	image = getImageFromProperty( entityId, 'P2425' )
	if image then
		border = true
	end

	-- получение иконки из элемента
	if not image then
		image = getImageFromProperty( entityId, 'P2910' )
		if image then
			size = '40x40px'
		end
	end
	
	return image, size, border
end

--Value function for [[d:Property:P166]]
function p.formatValue( context, options, statement )
	local entityId = statement.id
	if not entityId then
		return statement
	end

	local label = mw.wikibase.getLabel( entityId )
	local image, size, border = p.getImageFromEntity( entityId )

	local recipientCategory = ''
	if not options.nocat and options.nocat ~= '' then
		recipientCategory = context.extractCategory( { category = 'P7084[P4224:Q24571879]' }, entityId )
		if recipientCategory == '' then
			recipientCategory = context.extractCategory( { category = 'P2517' }, entityId )
		end
	end

	local dates = ''
	if options.qualifiers then
		local startDates = {}
		dates = datesFromQualifier( context, options, 'P580' )
		if dates ~= '' then
			local endDates = datesFromQualifier( context, options, 'P582' )
			if endDates and endDates ~= '' then
				dates = dates .. ' — ' .. endDates
			end
		else
			dates = datesFromQualifier( context, options, 'P585' )
		end
		
		if options.qualifiers.P27 then
mw.log('>>>>>>>>>>>>>')
			for _, claim in ipairs( options.qualifiers.P27 ) do
				if claim and claim.datavalue and claim.datavalue.value and claim.datavalue.value.id then
					local categoryOptions = { category = 'P7084[P27:' .. claim.datavalue.value.id .. ']' }
					recipientCategory = recipientCategory .. context.extractCategory( categoryOptions, entityId )
				end
			end 
		end
	end

	-- получение ссылки по идентификатору и вывод планки
	if image then
		local link = mw.wikibase.getSitelink( entityId )
		local out = '[[File:' .. image
		if border == true then
			out = out .. '|border'
		end
		out = out .. '|' .. size .. '|link='
		
		-- получение ссылки из родительского элемента
		-- для степеней обычно только одна общая статья
		if not link then
			local partOfClaims = WDS.load( entityId, 'P361' ) -- часть от
			if not partOfClaims or #partOfClaims == 0 then
				partOfClaims = WDS.load( entityId, 'P279' ) -- подкласс от
			end
			if partOfClaims and #partOfClaims > 0 then
				for _, claim in ipairs( partOfClaims ) do
					if claim.type == 'statement' and claim.mainsnak.snaktype == 'value' then
						link = mw.wikibase.getSitelink( claim.mainsnak.datavalue.value.id )
						if link then
							break
						end
					end
				end
			end
		end
		
		if link then
			out = out .. link
		else
			out = out .. 'd:' .. entityId
		end
		if label then
			out = out .. '|' .. label
		end
		out = out .. ']]'
		out = out .. recipientCategory

		return out
	end

	local out = context.formatValueDefault( context, options, statement )
	if out and out ~= '' then
		if dates ~= '' then
			out = out .. ' (' .. dates .. ')'
		end
		return '<span style="display:inline-block; text-align:left>' .. out .. recipientCategory .. '</span>'
	end
	
	return ''
end

--Table for documentation
function p.renderDoc()
	local out = {}
	for i, awardFields in ipairs( awardsOrder.data ) do
		local awardId = awardFields[ 1 ]
		local link = '[[d:' .. awardId .. '|' .. awardId .. ']]'

		if i == 351 then
			-- limits
			table.insert( out, '| … || … || … || … || …' )
		elseif i > 351 and i < #awardsOrder.data then
			-- do nothing
		elseif awardId == '-' then
			-- separator
			table.insert( out, '|' .. i .. '|| colspan="3" | ----' )
		else
			local image, size, border = p.getImageFromEntity( awardId )
			if image then
				image = '[[File:' .. image
				if border == true then
					image = image .. '|border'
				end
				image = image .. '|' .. size .. ']]'
			else
				image = ''
			end

			local label = mw.wikibase.getLabel( awardId ) or ''
			local article = mw.wikibase.getSitelink( awardId )
			if article then
				if label == '' then
					label = article
				end
				label = '[[' .. article .. '|' .. label .. ']]'
			end

			local countryStatements = mw.wikibase.getBestStatements( awardId, 'P17' )
			local countries = {}
			if countryStatements then
				for _, statement in ipairs( countryStatements ) do
					if statement.mainsnak.datavalue and
						statement.mainsnak.datavalue.type == 'wikibase-entityid'
					then
						local countryId = statement.mainsnak.datavalue.value.id
						table.insert( countries, mw.wikibase.getLabel( countryId ) )
					end
				end
			end

			table.insert( out, '|' .. i .. '||' .. link .. '||' .. image ..
				'||' .. label .. '||' .. table.concat( countries, ', ' ) )
		end
	end

	return '{| class="wikitable"\n' ..
		'! # !! Элемент !! Планка !! Название !! Государство\n|-\n' ..
		table.concat( out, '\n|-\n' ) ..
		'\n|}'
end

return p