Модуль:Universal infocard: юрамалар арасында аерма

Контент бетерелгән Контент өстәлгән
Takhirgeran Umar (бәхәс | кертем)
Төзәтмә аңлатмасы юк
Takhirgeran Umar (бәхәс | кертем)
Takhirgeran Umar (бәхәс) кулланучысының 2503612 төзәтмәсе кире кагылды
Тамга: кире кайтару
Юл номеры - 17:
local entityId = nil;
 
-- CSS classesStyles.
local classesstyles = {};
infobox = '',
if config and config.classes then
error = '',
for key, value in pairs( config.classes ) do
title = 'background:#eaecf0; font-weight:bold;',
classes[ key ] = value;
original = 'font-style:oblique;',
label = 'width:9em;',
text = '',
media = '',
split = 'vertical-align:middle; text-align:center;',
footer = 'background:#eaecf0;',
};
local classes = {
class title = 'infobox-above';,
media = 'infobox-image',
footer = 'infobox-below'
};
if config and config.classesstyles then
for key, value in pairs( config.classesstyles ) do
classesstyles[ key ] = value;
end
end
function getClassString( type )
local class;
if classes[type] then
class = classes[type];
elseif type ~= '' then
class = 'infobox-' .. type;
else
class = 'infobox';
end
 
if class == '' then
return '';
end
 
return ' class="'.. class .. '"';
end
 
 
function getTemplate( propertyId )
Строка 97 ⟶ 94 :
colspan = 'colspan="2"';
end
result = result .. '<td ' .. colspan .. getClassString(' 'splitstyle="' ).. styles.split .. '">';
result = result .. value1;
result = result .. '</td>';
Строка 106 ⟶ 103 :
colspan = 'colspan="2"';
end
result = result .. '<td ' .. colspan .. getClassString(' 'splitstyle="' ).. styles.split .. '">';
result = result .. value2;
result = result .. '</td>';
Строка 116 ⟶ 113 :
end
 
function getLine( value, style, class )
local result = '';
if ( value and string.len( value ) ~= 0 ) then
result = result .. '<tr><td colspan="2" style="text-align:center;' .. getClassString( style or '' ) .. '" class="'.. ( class or '' ) .. '">';
result = result .. value;
result = result .. '</td></tr>\n';
Строка 131 ⟶ 128 :
if ( value ~= nil and string.len( value ) ~= 0 ) then
if label then
result = result .. '<tr><th style="' .. getClassString( 'styles.label' ) .. '">' .. label .. '</th>';
result = result .. '<td style="' .. getClassString( 'styles.text' ) .. '">\n';
else
result = result .. '<tr><td colspan="2" style="' .. getClassString( 'styles.text' ) .. '">';
end
result = result .. value;
Строка 158 ⟶ 155 :
local coord = statements[ 1 ].mainsnak.datavalue.value;
local title = expandTemplate( args.frame, getTemplate( 'title' ), { from = entityId } );
 
mw.logObject( coord, 'coord' );
mw.logObject( title, 'title' );
 
 
local mapContent = [[ {
Строка 279 ⟶ 280 :
 
function getErrorMessage( message )
local result = '<table class="infobox" cellspacing="2"' .. getClassString( 'error' ) .. '>\n';
if config and config.styles and config.styles.inferrorobox then
result = result .. '<tr><td colspan="2">' .. message .. '</td></tr>\n';
result = result .. ' style="' .. config.styles.error .. '"';
end
result = result .. '>\n';
result = result .. '<tr><td colspan="2" style="text-align:center">' .. message .. '</td></tr>\n';
result = result .. '</table>';
return result;
Строка 297 ⟶ 302 :
end
 
local result = '<table class="infobox" cellspacing="2"' .. getClassString( '' );
if config and config.i18n and config.i18n.dataName then
result = result .. ' data-name="' .. config.i18n.dataName .. '"';
end
if config and config.styles and config.styles.infobox then
result = result .. ' style="' .. config.styles.infobox .. '"';
end
result = result .. '>\n';
Строка 354 ⟶ 362 :
label = expandTemplate( frame, titleTemplate, { from = entityId } );
end
result = result .. getLine( label, 'above'styles.title, classes.title );
 
---- Original name.
if claims.P1559 ~= nil then
result = result .. getLine( expandTemplate( frame, getTemplate( 'P1559' ), { from = entityId } ), 'styles.original' );
elseif claims.P1705 ~= nil then
result = result .. getLine( expandTemplate( frame, getTemplate( 'P1705' ), { from = entityId } ), 'styles.original' );
end
 
Строка 413 ⟶ 421 :
local label = propertyLabel( propertyId );
if propertyClaims[ 1 ].mainsnak.datatype == 'commonsMedia' then
result = result .. getLine( renderValue( frame, propertyId, { alt = label } ), 'image'styles.media, classes.media );
else
result = result .. getValue( label, renderValue( frame, propertyId ) );
Строка 426 ⟶ 434 :
---- Map.
if claims.P625 ~= nil then
result = result .. getLine( renderValue( frame, 'map' ), 'styles.text' );
end
 
---- Commons.
if claims.P373 ~= nil then
result = result .. getLine( expandTemplate( frame, getTemplate( 'P373' ), { from = entityId } ), 'below'styles.footer, classes.footer );
end