[ Index ]
 

Code source de jpGraph 2.2

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/src/ -> jpgraph_flags.php (source)

   1  <?php
   2  //=======================================================================
   3  // File:    JPGRAPH_FLAGS.PHP
   4  // Description:    Class Jpfile. Handles plotmarks
   5  // Created:     2003-06-28
   6  // Ver:        $Id: jpgraph_flags.php 809 2006-12-03 23:50:13Z ljp $
   7  //
   8  // Copyright (c) Aditus Consulting. All rights reserved.
   9  //========================================================================
  10  
  11  //------------------------------------------------------------
  12  // Defines for the different basic sizes of flags
  13  //------------------------------------------------------------
  14  DEFINE('FLAGSIZE1',1);
  15  DEFINE('FLAGSIZE2',2);
  16  DEFINE('FLAGSIZE3',3);
  17  DEFINE('FLAGSIZE4',4);
  18  
  19  class FlagImages {
  20  
  21      private $iCountryNameMap = array(
  22      'Afghanistan' => 'afgh',
  23      'Republic of Angola' => 'agla',
  24      'Republic of Albania' => 'alba',
  25      'Alderney' => 'alde',
  26      'Democratic and Popular Republic of Algeria' => 'alge',
  27      'Territory of American Samoa' => 'amsa',
  28      'Principality of Andorra' => 'andr',
  29      'British Overseas Territory of Anguilla' => 'angu',
  30      'Antarctica' => 'anta',
  31      'Argentine Republic' => 'arge',
  32      'League of Arab States' => 'arle',
  33      'Republic of Armenia' => 'arme',
  34      'Aruba' => 'arub',
  35      'Commonwealth of Australia' => 'astl',
  36      'Republic of Austria' => 'aust',
  37      'Azerbaijani Republic' => 'azer',
  38      'British Antarctic Territory' => 'bant',
  39      'Kingdom of Belgium' => 'belg',
  40      'British Overseas Territory of Bermuda' => 'berm',
  41      'Commonwealth of the Bahamas' => 'bhms',
  42      'Kingdom of Bahrain' => 'bhrn',
  43      'Republic of Belarus' => 'blru',
  44      'Republic of Bolivia' => 'blva',
  45      'Belize' => 'blze',
  46      'Republic of Benin' => 'bnin',
  47      'Republic of Botswana' => 'bots',
  48      'Federative Republic of Brazil' => 'braz',
  49      'Barbados' => 'brbd',
  50      'British Indian Ocean Territory' => 'brin',
  51      'Brunei Darussalam' => 'brun',
  52      'Republic of Burkina' => 'bufa',
  53      'Republic of Bulgaria' => 'bulg',
  54      'Republic of Burundi' => 'buru',
  55      'Overseas Territory of the British Virgin Islands' => 'bvis',
  56      'Central African Republic' => 'cafr',
  57      'Kingdom of Cambodia' => 'camb',
  58      'Republic of Cameroon' => 'came',
  59      'Dominion of Canada' => 'cana',
  60      'Caribbean Community' => 'cari',
  61      'Republic of Cape Verde' => 'cave',
  62      'Republic of Chad' => 'chad',
  63      'Republic of Chile' => 'chil',
  64      'Peoples Republic of China' => 'chin',
  65      'Territory of Christmas Island' => 'chms',
  66      'Commonwealth of Independent States' => 'cins',
  67      'Cook Islands' => 'ckis',
  68      'Republic of Colombia' => 'clmb',
  69      'Territory of Cocos Islands' => 'cois',
  70      'Commonwealth' => 'comn',
  71      'Union of the Comoros' => 'como',
  72      'Republic of the Congo' => 'cong',
  73      'Republic of Costa Rica' => 'corc',
  74      'Republic of Croatia' => 'croa',
  75      'Republic of Cuba' => 'cuba',
  76      'British Overseas Territory of the Cayman Islands' => 'cyis',
  77      'Republic of Cyprus' => 'cypr',
  78      'The Czech Republic' => 'czec',
  79      'Kingdom of Denmark' => 'denm',
  80      'Republic of Djibouti' => 'djib',
  81      'Commonwealth of Dominica' => 'domn',
  82      'Dominican Republic' => 'dore',
  83      'Republic of Ecuador' => 'ecua',
  84      'Arab Republic of Egypt' => 'egyp',
  85      'Republic of El Salvador' => 'elsa',
  86      'England' => 'engl',
  87      'Republic of Equatorial Guinea' => 'eqgu',
  88      'State of Eritrea' => 'erit',
  89      'Republic of Estonia' => 'estn',
  90      'Ethiopia' => 'ethp',
  91      'European Union' => 'euun',
  92      'British Overseas Territory of the Falkland Islands' => 'fais',
  93      'International Federation of Vexillological Associations' => 'fiav',
  94      'Republic of Fiji' => 'fiji',
  95      'Republic of Finland' => 'finl',
  96      'Territory of French Polynesia' => 'fpol',
  97      'French Republic' => 'fran',
  98      'Overseas Department of French Guiana' => 'frgu',
  99      'Gabonese Republic' => 'gabn',
 100      'Republic of the Gambia' => 'gamb',
 101      'Republic of Georgia' => 'geor',
 102      'Federal Republic of Germany' => 'germ',
 103      'Republic of Ghana' => 'ghan',
 104      'Gibraltar' => 'gibr',
 105      'Hellenic Republic' => 'grec',
 106      'State of Grenada' => 'gren',
 107      'Overseas Department of Guadeloupe' => 'guad',
 108      'Territory of Guam' => 'guam',
 109      'Republic of Guatemala' => 'guat',
 110      'The Bailiwick of Guernsey' => 'guer',
 111      'Republic of Guinea' => 'guin',
 112      'Republic of Haiti' => 'hait',
 113      'Hong Kong Special Administrative Region' => 'hokn',
 114      'Republic of Honduras' => 'hond',
 115      'Republic of Hungary' => 'hung',
 116      'Republic of Iceland' => 'icel',
 117      'International Committee of the Red Cross' => 'icrc',
 118      'Republic of India' => 'inda',
 119      'Republic of Indonesia' => 'indn',
 120      'Republic of Iraq' => 'iraq',
 121      'Republic of Ireland' => 'irel',
 122      'Organization of the Islamic Conference' => 'isco',
 123      'Isle of Man' => 'isma',
 124      'State of Israel' => 'isra',
 125      'Italian Republic' => 'ital',
 126      'Jamaica' => 'jama',
 127      'Japan' => 'japa',
 128      'The Bailiwick of Jersey' => 'jers',
 129      'Hashemite Kingdom of Jordan' => 'jord',
 130      'Republic of Kazakhstan' => 'kazk',
 131      'Republic of Kenya' => 'keny',
 132      'Republic of Kiribati' => 'kirb',
 133      'State of Kuwait' => 'kuwa',
 134      'Kyrgyz Republic' => 'kyrg',
 135      'Republic of Latvia' => 'latv',
 136      'Lebanese Republic' => 'leba',
 137      'Kingdom of Lesotho' => 'lest',
 138      'Republic of Liberia' => 'libe',
 139      'Principality of Liechtenstein' => 'liec',
 140      'Republic of Lithuania' => 'lith',
 141      'Grand Duchy of Luxembourg' => 'luxe',
 142      'Macao Special Administrative Region' => 'maca',
 143      'Republic of Macedonia' => 'mace',
 144      'Republic of Madagascar' => 'mada',
 145      'Republic of the Marshall Islands' => 'mais',
 146      'Republic of Mali' => 'mali',
 147      'Federation of Malaysia' => 'mals',
 148      'Republic of Malta' => 'malt',
 149      'Republic of Malawi' => 'malw',
 150      'Overseas Department of Martinique' => 'mart',
 151      'Islamic Republic of Mauritania' => 'maur',
 152      'Territorial Collectivity of Mayotte' => 'mayt',
 153      'United Mexican States' => 'mexc',
 154      'Federated States of Micronesia' => 'micr',
 155      'Midway Islands' => 'miis',
 156      'Republic of Moldova' => 'mold',
 157      'Principality of Monaco' => 'mona',
 158      'Republic of Mongolia' => 'mong',
 159      'British Overseas Territory of Montserrat' => 'mont',
 160      'Kingdom of Morocco' => 'morc',
 161      'Republic of Mozambique' => 'moza',
 162      'Republic of Mauritius' => 'mrts',
 163      'Union of Myanmar' => 'myan',
 164      'Republic of Namibia' => 'namb',
 165      'North Atlantic Treaty Organization' => 'nato',
 166      'Republic of Nauru' => 'naur',
 167      'Turkish Republic of Northern Cyprus' => 'ncyp',
 168      'Netherlands Antilles' => 'nean',
 169      'Kingdom of Nepal' => 'nepa',
 170      'Kingdom of the Netherlands' => 'neth',
 171      'Territory of Norfolk Island' => 'nfis',
 172      'Federal Republic of Nigeria' => 'ngra',
 173      'Republic of Nicaragua' => 'nica',
 174      'Republic of Niger' => 'nigr',
 175      'Niue' => 'niue',
 176      'Commonwealth of the Northern Mariana Islands' => 'nmar',
 177      'Province of Northern Ireland' => 'noir',
 178      'Nordic Council' => 'nord',
 179      'Kingdom of Norway' => 'norw',
 180      'Territory of New Caledonia and Dependencies' => 'nwca',
 181      'New Zealand' => 'nwze',
 182      'Organization of American States' => 'oast',
 183      'Organization of African Unity' => 'oaun',
 184      'International Olympic Committee' => 'olym',
 185      'Sultanate of Oman' => 'oman',
 186      'Islamic Republic of Pakistan' => 'paks',
 187      'Republic of Palau' => 'pala',
 188      'Independent State of Papua New Guinea' => 'pang',
 189      'Republic of Paraguay' => 'para',
 190      'Republic of Peru' => 'peru',
 191      'Republic of the Philippines' => 'phil',
 192      'British Overseas Territory of the Pitcairn Islands' => 'piis',
 193      'Republic of Poland' => 'pola',
 194      'Republic of Portugal' => 'port',
 195      'Commonwealth of Puerto Rico' => 'purc',
 196      'State of Qatar' => 'qata',
 197      'Russian Federation' => 'russ',
 198      'Romania' => 'rmna',
 199      'Republic of Rwanda' => 'rwan',
 200      'Kingdom of Saudi Arabia' => 'saar',
 201      'Republic of San Marino' => 'sama',
 202      'Nordic Sami Conference' => 'sami',
 203      'Sark' => 'sark',
 204      'Scotland' => 'scot',
 205      'Principality of Seborga' => 'sebo',
 206      'Republic of Sierra Leone' => 'sile',
 207      'Republic of Singapore' => 'sing',
 208      'Republic of Korea' => 'skor',
 209      'Republic of Slovenia' => 'slva',
 210      'Somali Republic' => 'smla',
 211      'Republic of Somaliland' => 'smld',
 212      'Republic of South Africa' => 'soaf',
 213      'Solomon Islands' => 'sois',
 214      'Kingdom of Spain' => 'span',
 215      'Secretariat of the Pacific Community' => 'spco',
 216      'Democratic Socialist Republic of Sri Lanka' => 'srla',
 217      'Saint Lucia' => 'stlu',
 218      'Republic of the Sudan' => 'suda',
 219      'Republic of Suriname' => 'surn',
 220      'Slovak Republic' => 'svka',
 221      'Kingdom of Sweden' => 'swdn',
 222      'Swiss Confederation' => 'swit',
 223      'Syrian Arab Republic' => 'syra',
 224      'Kingdom of Swaziland' => 'szld',
 225      'Republic of China' => 'taiw',
 226      'Taiwan' => 'taiw',
 227      'Republic of Tajikistan' => 'tajk',
 228      'United Republic of Tanzania' => 'tanz',
 229      'Kingdom of Thailand' => 'thal',
 230      'Autonomous Region of Tibet' => 'tibe',
 231      'Turkmenistan' => 'tkst',
 232      'Togolese Republic' => 'togo',
 233      'Tokelau' => 'toke',
 234      'Kingdom of Tonga' => 'tong',
 235      'Tristan da Cunha' => 'trdc',
 236      'Tromelin' => 'tris',
 237      'Republic of Tunisia' => 'tuns',
 238      'Republic of Turkey' => 'turk',
 239      'Tuvalu' => 'tuva',
 240      'United Arab Emirates' => 'uaem',
 241      'Republic of Uganda' => 'ugan',
 242      'Ukraine' => 'ukrn',
 243      'United Kingdom of Great Britain' => 'unkg',
 244      'United Nations' => 'unna',
 245      'United States of America' => 'unst',
 246      'Oriental Republic of Uruguay' => 'urgy',
 247      'Virgin Islands of the United States' => 'usvs',
 248      'Republic of Uzbekistan' => 'uzbk',
 249      'State of the Vatican City' => 'vacy',
 250      'Republic of Vanuatu' => 'vant',
 251      'Bolivarian Republic of Venezuela' => 'venz',
 252      'Republic of Yemen' => 'yemn',
 253      'Democratic Republic of Congo' => 'zare',
 254      'Republic of Zimbabwe' => 'zbwe' ) ;
 255  
 256  
 257      private $iFlagCount = -1;
 258      private $iFlagSetMap = array(
 259      FLAGSIZE1 => 'flags_thumb35x35',
 260      FLAGSIZE2 => 'flags_thumb60x60',
 261      FLAGSIZE3 => 'flags_thumb100x100',
 262      FLAGSIZE4 => 'flags'
 263      );
 264  
 265      private $iFlagData ;
 266      private $iOrdIdx=array();
 267  
 268      function FlagImages($aSize=FLAGSIZE1) {
 269      switch($aSize) {
 270          case FLAGSIZE1 :
 271          case FLAGSIZE2 :
 272          case FLAGSIZE3 :
 273          case FLAGSIZE4 :
 274          $file = dirname(__FILE__).'/'.$this->iFlagSetMap[$aSize].'.dat';
 275          $fp = fopen($file,'rb');
 276          $rawdata = fread($fp,filesize($file));
 277          $this->iFlagData = unserialize($rawdata);
 278          break;
 279          default:
 280          JpGraphError::RaiseL(5001,$aSize);
 281  //('Unknown flag size. ('.$aSize.')');
 282      }
 283      $this->iFlagCount = count($this->iCountryNameMap);
 284      }
 285  
 286      function GetNum() {
 287      return $this->iFlagCount;
 288      }
 289  
 290      function GetImgByName($aName,&$outFullName) {
 291      $idx = $this->GetIdxByName($aName,$outFullName);
 292      return $this->GetImgByIdx($idx);
 293      }
 294  
 295      function GetImgByIdx($aIdx) {
 296      if( array_key_exists($aIdx,$this->iFlagData) ) {
 297          $d = $this->iFlagData[$aIdx][1];   
 298          return Image::CreateFromString($d);   
 299      }
 300      else {
 301          JpGraphError::RaiseL(5002,$aIdx);
 302  //("Flag index \" $aIdx\" does not exist.");
 303      }
 304      }
 305  
 306      function GetIdxByOrdinal($aOrd,&$outFullName) {
 307      $aOrd--;
 308      $n = count($this->iOrdIdx);
 309      if( $n == 0 ) {
 310          reset($this->iCountryNameMap);
 311          $this->iOrdIdx=array();
 312          $i=0;
 313          while( list($key,$val) = each($this->iCountryNameMap) ) {
 314          $this->iOrdIdx[$i++] = array($val,$key);
 315          }
 316          $tmp=$this->iOrdIdx[$aOrd];
 317          $outFullName = $tmp[1];
 318          return $tmp[0];
 319          
 320      }
 321      elseif( $aOrd >= 0 && $aOrd < $n ) {
 322          $tmp=$this->iOrdIdx[$aOrd];
 323          $outFullName = $tmp[1];
 324          return $tmp[0];
 325      }
 326      else {
 327          JpGraphError::RaiseL(5003,$aOrd);
 328  //('Invalid ordinal number specified for flag index.');
 329      }
 330      }
 331  
 332      function GetIdxByName($aName,&$outFullName) {
 333  
 334      if( is_integer($aName) ) {
 335          $idx = $this->GetIdxByOrdinal($aName,$outFullName);
 336          return $idx;
 337      }
 338  
 339      $found=false;
 340      $aName = strtolower($aName);
 341      $nlen = strlen($aName);
 342      reset($this->iCountryNameMap);
 343      // Start by trying to match exact index name
 344      while( list($key,$val) = each($this->iCountryNameMap) ) {
 345          if( $nlen == strlen($val) && $val == $aName )  {
 346          $found=true;
 347          break;
 348          }
 349      }
 350      if( !$found ) {
 351          reset($this->iCountryNameMap);
 352          // If the exact index doesn't work try a (partial) full name
 353          while( list($key,$val) = each($this->iCountryNameMap) ) {
 354          if( strpos(strtolower($key), $aName) !== false ) {
 355              $found=true;
 356              break;
 357          }
 358          }
 359      }
 360      if( $found ) {
 361          $outFullName = $key;
 362          return $val;   
 363      }
 364      else { 
 365          JpGraphError::RaiseL(5004,$aName);
 366  //("The (partial) country name \"$aName\" does not have a cooresponding flag image. The flag may still exist but under another name, e.g. insted of \"usa\" try \"united states\".");
 367      }
 368      }
 369  }
 370  
 371  
 372  
 373  
 374  ?>


Généré le : Sat Nov 24 09:27:55 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics