Módulo:Phone

De Wikiviajes, la guía libre de viajes
Icono de documentación de módulo Documentación del módulo[ver] [editar] [historial] [purgar]

Version check

Designación de la versión en Wikidata: 2022-10-22 Ok!

Uso

Provides the functions for linking phone numbers.Fax numbers are checked but not linked.

Example

Text Code Ergebnis
+49 123 2 567.890 App. 5 {{#invoke:Phone|linkPhone|+49 123 2 567.890 App. 5}} +49 123 2 567.890 App. 5
+49 123 2 567.890 App. 5 {{#invoke:Phone|linkPhone|+49 123 2 567.890 App. 5|isFax=true}} +49 123 2 567.890 App. 5
+49 123 / 2 567.890 {{#invoke:Phone|linkPhone|+49 123 / 2 567.890}} +49 123 / 2 567.890 Category:Contacto: El teléfono contiene una barra (/) El teléfono contiene una barra (/)
++49 (123) 2 56 78 90 ext. 34 (Bar) {{#invoke:Phone|linkPhone|++49 (123) 2 56 78 90 ext. 34 (Bar)}} +49 (123) 2 56 78 90 ext. 34 (Bar)
++49 0123 2 56 78 90 ext. 34 (Bar) {{#invoke:Phone|linkPhone|++49 0123 2 56 78 90 ext. 34 (Bar)|cc=+49}} +49 (0)123 2 56 78 90 ext. 34 (Bar)
+49 (0)123 2 56 78 90;ext=34 {{#invoke:Phone|linkPhone|1=+49 (0)123 2 56 78 90;ext=34}} +49 (0)123 2 56 78 90 ext 34
+49 (123) 2 56 78 90 Bar {{#invoke:Phone|linkPhone|+49 (123) 2 56 78 90 Bar}} +49 (123) 2 56 78 90 Bar Category:Contacto: Formato de teléfono inválido Formato de teléfono inválido
+49 (0)123 VOYAGE {{#invoke:Phone|linkPhone|+''49'' (0)123 VOYAGE}} +49 (0)123 VOYAGE
(0)123 256 78 90 {{#invoke:Phone|linkPhone|(0)123 256 78 90}} (0)123 256 78 90 Category:Contacto: Teléfono sin código númerico del país Teléfono sin código númerico del país
(0)123 256 78 90 {{#invoke:Phone|linkPhone|(0)123 256 78 90|cc=+49}} (0)123 256 78 90
123 256 78 90 (Bar) {{#invoke:Phone|linkPhone|123 256 78 90 (Bar)|cc=+49}} 123 256 78 90 (Bar) Category:Contacto: Formato de teléfono inválido Formato de teléfono inválido
+49 (123) 2 56 78 90 (Lobby Bar), 0049 (123) 2 56 78 90 (Oasis Restaurant) {{#invoke:Phone|linkPhone|+49 (123) 2 56 78 90 (Lobby und Bar), 0049 (123) 2 56 78 91 (Restaurant)}} +49 (123) 2 56 78 90 (Lobby und Bar), +49 (123) 2 56 78 91 (Restaurant)
+49 (123) 2 56 78 90 oder +49 (123) 2 56 78 91 {{#invoke:Phone|linkPhone|+49 (123) 2 56 78 90 oder +49 (123) 2 56 78 91}} +49 (123) 2 56 78 90 oder +49 (123) 2 56 78 91 Category:Contacto: Formato de teléfono inválido Formato de teléfono inválido
(212) 307 4100 (USA) {{#invoke:Phone|linkPhone|(212) 307 4100 (USA)|cc=+1}} (212) 307 4100 (USA)
+49-345-1234567 {{#invoke:Phone|linkPhone|+49-345-1234567|format=true}} +49 (0)345 123 45 67
+20-92-1234567 {{#invoke:Phone|linkPhone|+20-92-1234567|format=true|size=4}} +20 (0)92 123 4567
0800 12 34 56 (gebührenfrei) {{#invoke:Phone|linkPhone|0800 12 34 56 (gebührenfrei)|isTollfree=true}} 0800 12 34 56 (gebührenfrei)
0900 12 34 56 (teure Servicenummer) {{#invoke:Phone|linkPhone|0900 12 34 56 (teure Servicenummer)}} 0900 12 34 56 (teure Servicenummer)
Esta documentación está transcluida desde Módulo:Phone/doc.
Los editores pueden experimentar en la zona de pruebas (crear) y en los casos de prueba (crear) del módulo.
Por favor, añade las categorías en la subpágina de documentación. Subpáginas de este módulo.

-- documentation
local Phone = {
	suite  = 'Phone',
	serial = '2022-10-22',
	item   = 106152593
}

-- module import
-- require( 'strict' )
local cm = require( 'Module:CountryData' )
local lp = require( 'Module:LinkPhone' )
local yn = require( 'Module:Yesno' )

-- module variable and administration
local ph = {
	moduleInterface = Phone
}

-- with parameter check for templates / #invoke
function ph.linkPhoneNumberSet( args )
	args.phone  = args.phone or args.mobile or args[ 1 ] or ''
	if args.phone == '' then
		return ''
	end

	args.cc     = ( args.cc or '' ):gsub( '^00', '+' ):gsub( '^%+%++', '+' )
	args.format = yn( args.format, false )
	args.isFax  = yn( args.isFax, false )
	args.isTollfree = yn( args.isTollfree, false )
	args.size   = tonumber( args.size )

	-- get country code if allowed
	local size
	if ( args.cc == '' or args.cc:sub( 1, 1 ) ~= '+' ) then
		args.cc, size = cm.getCountryCode()
		args.size = args.size or size
	end
	args.size = args.size or 2

	return lp.linkPhoneNumbers( args )
end

-- for #invoke call
function ph.linkPhone( frame )
	return ph.linkPhoneNumberSet( frame.args )
end

-- for template call
function ph.linkPhoneTemplate( frame )
	return ph.linkPhoneNumberSet( frame:getParent().args )
end

return ph