aboutsummaryrefslogtreecommitdiffstats
path: root/library/HTMLPurifier/Language.php
diff options
context:
space:
mode:
authorChristian Vogeley <christian.vogeley@hotmail.de>2015-01-11 16:22:59 +0100
committerChristian Vogeley <christian.vogeley@hotmail.de>2015-01-11 16:22:59 +0100
commitf0c7612bcd49d32e408e67ac1829ee891c677f7e (patch)
treed4cff4aa2d728524b631776ffffee71f42056421 /library/HTMLPurifier/Language.php
parent43f143a211c75138d09ceb89acc48ea7d5c31ca9 (diff)
parent10102ac2ac4d5b02012a9794e23656717ab05556 (diff)
downloadvolse-hubzilla-f0c7612bcd49d32e408e67ac1829ee891c677f7e.tar.gz
volse-hubzilla-f0c7612bcd49d32e408e67ac1829ee891c677f7e.tar.bz2
volse-hubzilla-f0c7612bcd49d32e408e67ac1829ee891c677f7e.zip
Merge remote-tracking branch 'upstream/master'
Conflicts: doc/html/classRedmatrix_1_1Import_1_1Import-members.html doc/html/classRedmatrix_1_1Import_1_1Import.js
Diffstat (limited to 'library/HTMLPurifier/Language.php')
-rw-r--r--library/HTMLPurifier/Language.php97
1 files changed, 69 insertions, 28 deletions
diff --git a/library/HTMLPurifier/Language.php b/library/HTMLPurifier/Language.php
index 3e2be03b5..65277dd43 100644
--- a/library/HTMLPurifier/Language.php
+++ b/library/HTMLPurifier/Language.php
@@ -8,22 +8,26 @@ class HTMLPurifier_Language
{
/**
- * ISO 639 language code of language. Prefers shortest possible version
+ * ISO 639 language code of language. Prefers shortest possible version.
+ * @type string
*/
public $code = 'en';
/**
- * Fallback language code
+ * Fallback language code.
+ * @type bool|string
*/
public $fallback = false;
/**
- * Array of localizable messages
+ * Array of localizable messages.
+ * @type array
*/
public $messages = array();
/**
- * Array of localizable error codes
+ * Array of localizable error codes.
+ * @type array
*/
public $errorNames = array();
@@ -31,21 +35,33 @@ class HTMLPurifier_Language
* True if no message file was found for this language, so English
* is being used instead. Check this if you'd like to notify the
* user that they've used a non-supported language.
+ * @type bool
*/
public $error = false;
/**
* Has the language object been loaded yet?
+ * @type bool
* @todo Make it private, fix usage in HTMLPurifier_LanguageTest
*/
public $_loaded = false;
/**
- * Instances of HTMLPurifier_Config and HTMLPurifier_Context
+ * @type HTMLPurifier_Config
*/
- protected $config, $context;
+ protected $config;
- public function __construct($config, $context) {
+ /**
+ * @type HTMLPurifier_Context
+ */
+ protected $context;
+
+ /**
+ * @param HTMLPurifier_Config $config
+ * @param HTMLPurifier_Context $context
+ */
+ public function __construct($config, $context)
+ {
$this->config = $config;
$this->context = $context;
}
@@ -54,8 +70,11 @@ class HTMLPurifier_Language
* Loads language object with necessary info from factory cache
* @note This is a lazy loader
*/
- public function load() {
- if ($this->_loaded) return;
+ public function load()
+ {
+ if ($this->_loaded) {
+ return;
+ }
$factory = HTMLPurifier_LanguageFactory::instance();
$factory->loadLanguage($this->code);
foreach ($factory->keys as $key) {
@@ -66,31 +85,43 @@ class HTMLPurifier_Language
/**
* Retrieves a localised message.
- * @param $key string identifier of message
+ * @param string $key string identifier of message
* @return string localised message
*/
- public function getMessage($key) {
- if (!$this->_loaded) $this->load();
- if (!isset($this->messages[$key])) return "[$key]";
+ public function getMessage($key)
+ {
+ if (!$this->_loaded) {
+ $this->load();
+ }
+ if (!isset($this->messages[$key])) {
+ return "[$key]";
+ }
return $this->messages[$key];
}
/**
* Retrieves a localised error name.
- * @param $int integer error number, corresponding to PHP's error
- * reporting
+ * @param int $int error number, corresponding to PHP's error reporting
* @return string localised message
*/
- public function getErrorName($int) {
- if (!$this->_loaded) $this->load();
- if (!isset($this->errorNames[$int])) return "[Error: $int]";
+ public function getErrorName($int)
+ {
+ if (!$this->_loaded) {
+ $this->load();
+ }
+ if (!isset($this->errorNames[$int])) {
+ return "[Error: $int]";
+ }
return $this->errorNames[$int];
}
/**
* Converts an array list into a string readable representation
+ * @param array $array
+ * @return string
*/
- public function listify($array) {
+ public function listify($array)
+ {
$sep = $this->getMessage('Item separator');
$sep_last = $this->getMessage('Item separator last');
$ret = '';
@@ -108,15 +139,20 @@ class HTMLPurifier_Language
/**
* Formats a localised message with passed parameters
- * @param $key string identifier of message
- * @param $args Parameters to substitute in
+ * @param string $key string identifier of message
+ * @param array $args Parameters to substitute in
* @return string localised message
* @todo Implement conditionals? Right now, some messages make
* reference to line numbers, but those aren't always available
*/
- public function formatMessage($key, $args = array()) {
- if (!$this->_loaded) $this->load();
- if (!isset($this->messages[$key])) return "[$key]";
+ public function formatMessage($key, $args = array())
+ {
+ if (!$this->_loaded) {
+ $this->load();
+ }
+ if (!isset($this->messages[$key])) {
+ return "[$key]";
+ }
$raw = $this->messages[$key];
$subst = array();
$generator = false;
@@ -124,9 +160,15 @@ class HTMLPurifier_Language
if (is_object($value)) {
if ($value instanceof HTMLPurifier_Token) {
// factor this out some time
- if (!$generator) $generator = $this->context->get('Generator');
- if (isset($value->name)) $subst['$'.$i.'.Name'] = $value->name;
- if (isset($value->data)) $subst['$'.$i.'.Data'] = $value->data;
+ if (!$generator) {
+ $generator = $this->context->get('Generator');
+ }
+ if (isset($value->name)) {
+ $subst['$'.$i.'.Name'] = $value->name;
+ }
+ if (isset($value->data)) {
+ $subst['$'.$i.'.Data'] = $value->data;
+ }
$subst['$'.$i.'.Compact'] =
$subst['$'.$i.'.Serialized'] = $generator->generateFromToken($value);
// a more complex algorithm for compact representation
@@ -157,7 +199,6 @@ class HTMLPurifier_Language
}
return strtr($raw, $subst);
}
-
}
// vim: et sw=4 sts=4