Source for file tel.php

Documentation is available at tel.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Libraries
  4.  * @subpackage  HTML
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE
  8.  */
  9.  
  10. defined('JPATH_PLATFORM'or die;
  11.  
  12. /**
  13.  * HTML helper class for rendering telephone numbers.
  14.  *
  15.  * @package     Joomla.Libraries
  16.  * @subpackage  HTML
  17.  * @since       1.6
  18.  */
  19. abstract class JHtmlTel
  20. {
  21.     /**
  22.      * Converts strings of integers into more readable telephone format
  23.      *
  24.      * By default, the ITU-T format will automatically be used.
  25.      * However, one of the allowed unit types may also be used instead.
  26.      *
  27.      * @param   integer  $number       The integers in a phone number with dot separated country code
  28.      *                                  ccc.nnnnnnn where ccc represents country code and nnn represents the local number.
  29.      * @param   string   $displayplan  The numbering plan used to display the numbers.
  30.      *
  31.      * @return  string  The formatted telephone number.
  32.      *
  33.      * @see     JFormRuleTel
  34.      * @since   1.6
  35.      */
  36.     public static function tel($number$displayplan)
  37.     {
  38.         $number explode('.'$number);
  39.         $countrycode $number[0];
  40.         $number $number[1];
  41.  
  42.         if ($displayplan == 'ITU-T' || $displayplan == 'International' || $displayplan == 'int' || $displayplan == 'missdn' || $displayplan == null)
  43.         {
  44.             $display[0'+';
  45.             $display[1$countrycode;
  46.             $display[2' ';
  47.             $display[3implode(str_split($number2)' ');
  48.         }
  49.         elseif ($displayplan == 'NANP' || $displayplan == 'northamerica' || $displayplan == 'US')
  50.         {
  51.             $display[0'(';
  52.             $display[1substr($number03);
  53.             $display[2') ';
  54.             $display[3substr($number33);
  55.             $display[4'-';
  56.             $display[5substr($number64);
  57.         }
  58.         elseif ($displayplan == 'EPP' || $displayplan == 'IETF')
  59.         {
  60.             $display[0'+';
  61.             $display[1$countrycode;
  62.             $display[2'.';
  63.             $display[3$number;
  64.  
  65.         }
  66.         elseif ($displayplan == 'ARPA' || $displayplan == 'ENUM')
  67.         {
  68.             $number implode(str_split(strrev($number)1)'.');
  69.             $display[0'+';
  70.             $display[1$number;
  71.             $display[2'.';
  72.             $display[3$countrycode;
  73.             $display[4'.e164.arpa';
  74.         }
  75.  
  76.         $display implode($display'');
  77.  
  78.         return $display;
  79.     }
  80. }

Documentation generated on Tue, 19 Nov 2013 15:15:22 +0100 by phpDocumentor 1.4.3