1
|
|
|
<?php |
|
|
|
|
2
|
|
|
/* |
3
|
|
|
You may not change or alter any portion of this comment or credits |
4
|
|
|
of supporting developers from this source code or any supporting source code |
5
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
6
|
|
|
|
7
|
|
|
This program is distributed in the hope that it will be useful, |
8
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
9
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
10
|
|
|
*/ |
11
|
|
|
/** |
12
|
|
|
* Xoops Language |
13
|
|
|
* |
14
|
|
|
* @copyright (c) 2000-2016 XOOPS Project (www.xoops.org) |
15
|
|
|
* @license GNU GPL 2 (http://www.gnu.org/licenses/gpl-2.0.html) |
16
|
|
|
* @package kernel |
17
|
|
|
* @subpackage Xoops Mailer Local Language |
18
|
|
|
* @since 2.3.0 |
19
|
|
|
* @author Taiwen Jiang <[email protected]> |
20
|
|
|
*/ |
21
|
|
|
defined('XOOPS_ROOT_PATH') || exit('Restricted access'); |
22
|
|
|
/** |
23
|
|
|
* Localize the mail functions |
24
|
|
|
* |
25
|
|
|
* The English localization is solely for demonstration |
26
|
|
|
*/ |
27
|
|
|
// Do not change the class name |
28
|
|
|
class XoopsMailerLocal extends XoopsMailer |
29
|
|
|
{ |
30
|
|
|
/** |
31
|
|
|
* Constructor |
32
|
|
|
*/ |
33
|
|
|
public function __construct() |
34
|
|
|
{ |
35
|
|
|
parent::__construct(); |
36
|
|
|
// It is supposed no need to change the charset |
37
|
|
|
$this->charSet = strtolower(_CHARSET); |
38
|
|
|
// You MUST specify the language code value so that the file exists: XOOPS_ROOT_PAT/class/mail/phpmailer/language/lang-["your-language-code"].php |
39
|
|
|
$this->multimailer->setLanguage('en'); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Multibyte languages are encouraged to make their proper method for encoding FromName |
44
|
|
|
* |
45
|
|
|
* @param $text |
46
|
|
|
* |
47
|
|
|
* @return mixed |
48
|
|
|
*/ |
49
|
|
|
public function encodeFromName($text) |
50
|
|
|
{ |
51
|
|
|
// Activate the following line if needed |
52
|
|
|
// $text = "=?{$this->charSet}?B?".base64_encode($text)."?="; |
53
|
|
|
return $text; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Multibyte languages are encouraged to make their proper method for encoding Subject |
59
|
|
|
* |
60
|
|
|
* @param $text |
61
|
|
|
* |
62
|
|
|
* @return mixed |
63
|
|
|
*/ |
64
|
|
|
public function encodeSubject($text) |
65
|
|
|
{ |
66
|
|
|
// Activate the following line if needed |
67
|
|
|
// $text = "=?{$this->charSet}?B?".base64_encode($text)."?="; |
68
|
|
|
return $text; |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.