Modul:Citation: Redaktələr arasındakı fərq

Redaktənin izahı yoxdur
Redaktənin izahı yoxdur
Sətir 44: Sətir 44:




function doi(id, inactive, nocat)
    local cat = ""
    local text;
    if ( inactive ~= nil ) then
        text = "[[Digital object identifier|doi]]:" .. id;
        cat = cat .. "[[Category:Pages with DOIs inactive since " .. selectyear(inactive) .. "]]"
        inactive = " (inactive " .. inactive .. ")"
    else
        text = externallinkid({link="Digital object identifier",label="doi",prefix="http://dx.doi.org/",id=id,separator=":"})
        inactive = ""
    end
    if ( string.sub(id,1,3) ~= "10." ) then
        cat = cat .. "[[Category:Pages with DOI errors]]" .. '<span class="error"> Bad DOI (expected "10." prefix) in code number</span>'
    end
    if ( nocat and nocat ~= "" ) then cat = "" end
    return text .. inactive .. cat   
end
function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then
        return result;
    else
        return '';
    end
end
function anchorid(label, args)
    local P1 = trim(args[1]) or ""
    local P2 = trim(args[2]) or ""
    local P3 = trim(args[3]) or ""
    local P4 = trim(args[4]) or ""
    local P5 = trim(args[5]) or ""
    local anchor = P1 .. P2 .. P3 .. P4 .. P5;
    if anchor ~= '' then  -- See bug description in Citation/CS1
        anchor = mw.uri.anchorEncode( anchor );
    end
   
    return label .. anchor
end


function refid(label, args)
function refid(label, args)