Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezshuffletranslator.php
Go to the documentation of this file.
1 <?php
19 class eZShuffleTranslator extends eZTranslatorHandler
20 {
21 public $MaxChars;
27 public function __construct( $max_chars = 3 )
28 {
29 parent::__construct( false );
30
31 $this->MaxChars = $max_chars;
32 $this->Messages = array();
33 }
34
35 function findMessage( $context, $source, $comment = null )
36 {
37 $man = eZTranslatorManager::instance();
38 $translation = $this->shuffleText( $source );
39 return $man->createMessage( $context, $source, $comment, $translation );
40 }
41
46 function &shuffleText( $text )
47 {
48 $num = mt_rand( 0, $this->MaxChars );
49 for ( $i = 0; $i < $num; ++$i )
50 {
51 $len = strlen( $text );
52 $offs = mt_rand( 0, $len - 1 );
53 if ( $offs == 0 )
54 {
55 $tmp = $text[$offs];
56 $text[$offs] = $text[$len - 1];
57 $text[$len] = $tmp;
58 }
59 else
60 {
61 $delta = -1;
62 if ( $text[$offs+$delta] == " " and
63 $offs + 1 < $len )
64 $delta = 1;
65 $tmp = $text[$offs];
66 $text[$offs] = $text[$offs+$delta];
67 $text[$offs+$delta] = $tmp;
68 }
69 }
70 return $text;
71 }
72
73 function translate( $context, $source, $comment = null )
74 {
75 $msg = $this->findMessage( $context, $source, $comment );
76 if ( $msg !== null )
77 {
78 return $msg["translation"];
79 }
80
81 return null;
82 }
83
86 public $Messages;
87 }
88
89 ?>
$i
$i
Definition: admin/adlist.php:91
$tmp
$tmp
Definition: bugview.php:99
eZShuffleTranslator
Translates text by moving characters around.
Definition: ezshuffletranslator.php:20
eZShuffleTranslator\translate
translate( $context, $source, $comment=null)
Definition: ezshuffletranslator.php:73
eZShuffleTranslator\findMessage
findMessage( $context, $source, $comment=null)
Definition: ezshuffletranslator.php:35
eZShuffleTranslator\shuffleText
& shuffleText( $text)
Definition: ezshuffletranslator.php:46
eZShuffleTranslator\$MaxChars
$MaxChars
Definition: ezshuffletranslator.php:21
eZShuffleTranslator\$Messages
$Messages
Definition: ezshuffletranslator.php:86
eZShuffleTranslator\__construct
__construct( $max_chars=3)
Definition: ezshuffletranslator.php:27
eZTranslatorHandler
Base class for translation handling.
Definition: eztranslatorhandler.php:20
eZTranslatorManager\instance
static instance()
Definition: eztranslatormanager.php:128
$msg
$msg
Definition: editmessage.php:47
$translation
$translation
Definition: ordersendt.php:62
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.