MediaWiki
fundraising/REL1_35
EncodingMangler.php
Go to the documentation of this file.
1
<?php
25
class
EncodingMangler
implements
StagingHelper
{
26
protected
$use_transliterator
=
false
;
27
protected
$transliterator
;
28
29
public
function
__construct
() {
30
if
( class_exists( Transliterator::class ) ) {
31
$this->use_transliterator =
true
;
32
// Use Any-Latin to munge Cyrillic, Kanji, etc
33
// Then convert anything outside the ISO-8859-1 range to nearest ASCII
34
$this->transliterator = Transliterator::create(
'Any-Latin; [^a-ΓΏ] Latin-ASCII'
);
35
}
36
}
37
38
public
function
stage
(
GatewayType
$adapter, $normalized, &$stagedData ) {
39
foreach
( array_keys( $stagedData ) as $key ) {
40
$stagedData[$key] = $this->
transliterate
( $stagedData[$key] );
41
}
42
}
43
50
public
function
transliterate
( $value ) {
51
if
( $this->use_transliterator ) {
52
return
$this->transliterator->transliterate( $value );
53
}
54
$iso = iconv(
'UTF-8'
,
'ISO-8859-1//TRANSLIT'
, $value );
55
return
iconv(
'ISO-8859-1'
,
'UTF-8'
, $iso );
56
}
57
}
EncodingMangler
Wikimedia Foundation.
Definition
EncodingMangler.php:25
EncodingMangler\__construct
__construct()
Definition
EncodingMangler.php:29
EncodingMangler\$transliterator
$transliterator
Definition
EncodingMangler.php:27
EncodingMangler\$use_transliterator
$use_transliterator
Definition
EncodingMangler.php:26
EncodingMangler\transliterate
transliterate( $value)
Forces string into ISO-8859-1 space.
Definition
EncodingMangler.php:50
EncodingMangler\stage
stage(GatewayType $adapter, $normalized, &$stagedData)
Transform a subset of normalized data into the "staged" data expected by a payment processor.
Definition
EncodingMangler.php:38
GatewayType
GatewayType Interface.
Definition
GatewayType.php:7
StagingHelper
Used to mark any class which implements an staging method, for transforming data into the form expect...
Definition
StagingHelper.php:7
extensions
DonationInterface
gateway_common
EncodingMangler.php
Generated on Mon Nov 25 2024 16:14:06 for MediaWiki by
1.10.0