Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob
  • Smarty
    • Cacher
    • Compiler
    • Config
    • Debug
    • PluginsBlock
    • PluginsFilter
    • PluginsFunction
    • PluginsInternal
    • PluginsModifier
    • PluginsModifierCompiler
    • PluginsShared
    • Security
    • Template
    • TemplateResources
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Swift_FailoverTransport
  • Swift_LoadBalancedTransport
  • Swift_MailTransport
  • Swift_Plugins_Loggers_ArrayLogger
  • Swift_Plugins_Loggers_EchoLogger
  • Swift_SendmailTransport
  • Swift_SmtpTransport
  • Swift_Transport_AbstractSmtpTransport
  • Swift_Transport_Esmtp_Auth_CramMd5Authenticator
  • Swift_Transport_Esmtp_Auth_LoginAuthenticator
  • Swift_Transport_Esmtp_Auth_PlainAuthenticator
  • Swift_Transport_Esmtp_AuthHandler
  • Swift_Transport_EsmtpTransport
  • Swift_Transport_FailoverTransport
  • Swift_Transport_LoadBalancedTransport
  • Swift_Transport_MailTransport
  • Swift_Transport_SendmailTransport
  • Swift_Transport_SimpleMailInvoker
  • Swift_Transport_StreamBuffer

Interfaces

  • Swift_Plugins_Logger
  • Swift_Plugins_Pop_Pop3Exception
  • Swift_Transport
  • Swift_Transport_Esmtp_Authenticator
  • Swift_Transport_EsmtpHandler
  • Swift_Transport_IoBuffer
  • Swift_Transport_MailInvoker
  • Swift_Transport_SmtpAgent
  • Swift_TransportException
  • Overview
  • Package
  • Function
  • Todo
  • Download
  1: <?php
  2: 
  3: /*
  4:  * This file is part of SwiftMailer.
  5:  * (c) 2004-2009 Chris Corbyn
  6:  *
  7:  * For the full copyright and license information, please view the LICENSE
  8:  * file that was distributed with this source code.
  9:  */
 10: 
 11: /**
 12:  * Standard factory for creating CharacterReaders.
 13:  * @package Swift
 14:  * @subpackage Encoder
 15:  * @author Chris Corbyn
 16:  */
 17: class Swift_CharacterReaderFactory_SimpleCharacterReaderFactory implements Swift_CharacterReaderFactory
 18: {
 19:     /**
 20:      * A map of charset patterns to their implementation classes.
 21:      * @var array
 22:      * @access private
 23:      */
 24:     private static $_map = array();
 25: 
 26:     /**
 27:      * Factories which have already been loaded.
 28:      * @var Swift_CharacterReaderFactory[]
 29:      * @access private
 30:      */
 31:     private static $_loaded = array();
 32: 
 33:     /**
 34:      * Creates a new CharacterReaderFactory.
 35:      */
 36:     public function __construct()
 37:     {
 38:         $this->init();
 39:     }
 40: 
 41:     public function __wakeup()
 42:     {
 43:         $this->init();
 44:     }
 45: 
 46:     public function init()
 47:     {
 48:         if (count(self::$_map) > 0) {
 49:             return;
 50:         }
 51: 
 52:         $prefix = 'Swift_CharacterReader_';
 53: 
 54:         $singleByte = array(
 55:             'class' => $prefix . 'GenericFixedWidthReader',
 56:             'constructor' => array(1)
 57:             );
 58: 
 59:         $doubleByte = array(
 60:             'class' => $prefix . 'GenericFixedWidthReader',
 61:             'constructor' => array(2)
 62:             );
 63: 
 64:         $fourBytes = array(
 65:             'class' => $prefix . 'GenericFixedWidthReader',
 66:             'constructor' => array(4)
 67:             );
 68: 
 69:         //Utf-8
 70:         self::$_map['utf-?8'] = array(
 71:             'class' => $prefix . 'Utf8Reader',
 72:             'constructor' => array()
 73:             );
 74: 
 75:         //7-8 bit charsets
 76:         self::$_map['(us-)?ascii'] = $singleByte;
 77:         self::$_map['(iso|iec)-?8859-?[0-9]+'] = $singleByte;
 78:         self::$_map['windows-?125[0-9]'] = $singleByte;
 79:         self::$_map['cp-?[0-9]+'] = $singleByte;
 80:         self::$_map['ansi'] = $singleByte;
 81:         self::$_map['macintosh'] = $singleByte;
 82:         self::$_map['koi-?7'] = $singleByte;
 83:         self::$_map['koi-?8-?.+'] = $singleByte;
 84:         self::$_map['mik'] = $singleByte;
 85:         self::$_map['(cork|t1)'] = $singleByte;
 86:         self::$_map['v?iscii'] = $singleByte;
 87: 
 88:         //16 bits
 89:         self::$_map['(ucs-?2|utf-?16)'] = $doubleByte;
 90: 
 91:         //32 bits
 92:         self::$_map['(ucs-?4|utf-?32)'] = $fourBytes;
 93: 
 94:         //Fallback
 95:         self::$_map['.*'] = $singleByte;
 96:     }
 97: 
 98:     /**
 99:      * Returns a CharacterReader suitable for the charset applied.
100:      * @param  string                $charset
101:      * @return Swift_CharacterReader
102:      */
103:     public function getReaderFor($charset)
104:     {
105:         $charset = trim(strtolower($charset));
106:         foreach (self::$_map as $pattern => $spec) {
107:             $re = '/^' . $pattern . '$/D';
108:             if (preg_match($re, $charset)) {
109:                 if (!array_key_exists($pattern, self::$_loaded)) {
110:                     $reflector = new ReflectionClass($spec['class']);
111:                     if ($reflector->getConstructor()) {
112:                         $reader = $reflector->newInstanceArgs($spec['constructor']);
113:                     } else {
114:                         $reader = $reflector->newInstance();
115:                     }
116:                     self::$_loaded[$pattern] = $reader;
117:                 }
118: 
119:                 return self::$_loaded[$pattern];
120:             }
121:         }
122:     }
123: }
124: 
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen