Módulo:Citas: Diferenzas entre revisións

Contido eliminado Contido engadido
Banjo (conversa | contribucións)
m Protexeu "Módulo:Citas" ([Editar=Permitir só aos usuarios autoconfirmados] (indefinido) [Mover=Permitir só aos usuarios autoconfirmados] (indefinido))
Banjo (conversa | contribucións)
m corrixo local function lccn(lccn) copiando da wiki en:
Liña 274:
 
]]
local function lccn(idlccn)
local handler = cfg.id_handlers['LCCN'];
local err_cat = ''; -- presume that LCCN is valid
local id = lccn; -- local copy of the lccn
 
id = normalize_lccn (id); -- get canonical form (no whitespace, hyphens, forward slashes)
local len = id:len(); -- get the length of the lccn
 
if 8 == len then
if id:match("[^%d]") then -- if LCCN has anything but digits (nil if only digits)
err_cat = ' ' .. seterrorset_error( 'bad_lccn' ); -- set an error message
end
elseif 9 == len then -- LCCN should be adddddddd
if nil == id:match("%al%d%d%d%d%d%d%d%d") then -- does it match our pattern?
err_cat = ' ' .. seterrorset_error( 'bad_lccn' ); -- set an error message
end
elseif 10 == len then -- LCCN should be aadddddddd or dddddddddd
if id:match("[^%d]") then -- if LCCN has anything but digits (nil if only digits) ...
if nil == id:match("^%al%al%d%d%d%d%d%d%d%d") then -- ... see if it matches our pattern
err_cat = ' ' .. seterrorset_error( 'bad_lccn' ); -- no match, set an error message
end
end
elseif 11 == len then -- LCCN should be aaadddddddd or adddddddddd
if not (id:match("^%al%al%al%d%d%d%d%d%d%d%d") or id:match("^%al%d%d%d%d%d%d%d%d%d%d")) then -- see if it matches one of our patterns
err_cat = ' ' .. seterrorset_error( 'bad_lccn' ); -- no match, set an error message
end
elseif 12 == len then -- LCCN should be aadddddddddd
if not id:match("^%al%al%d%d%d%d%d%d%d%d%d%d") then -- see if it matches our pattern
err_cat = ' ' .. seterrorset_error( 'bad_lccn' ); -- no match, set an error message
end
else
err_cat = ' ' .. seterrorset_error( 'bad_lccn' ); -- wrong length, set an error message
end
 
if not is_set (err_cat) and nil ~= lccn:find ('%s') then
return externallinkid({link = handler.link, label = handler.label,
err_cat = ' ' .. set_error( 'bad_lccn' ); -- lccn contains a space, set an error message
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end
 
return externallinkidexternal_link_id({link = handler.link, label = handler.label,
prefix=handler.prefix,id=idlccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end