diff options
author | friendica <info@friendica.com> | 2015-01-01 22:18:27 -0800 |
---|---|---|
committer | friendica <info@friendica.com> | 2015-01-01 22:18:27 -0800 |
commit | a0052f0176bd079e6a94baec59fea2ec5a8d651e (patch) | |
tree | c323edd823681bc2e8ca757e7eaf8354d42c7b51 /library/HTMLPurifier/Language.php | |
parent | 545e47933a0816699c68d98a7742a03260d6a54f (diff) | |
download | volse-hubzilla-a0052f0176bd079e6a94baec59fea2ec5a8d651e.tar.gz volse-hubzilla-a0052f0176bd079e6a94baec59fea2ec5a8d651e.tar.bz2 volse-hubzilla-a0052f0176bd079e6a94baec59fea2ec5a8d651e.zip |
htmlpurifier update - compatibility issue with language library autoloader
Diffstat (limited to 'library/HTMLPurifier/Language.php')
-rw-r--r-- | library/HTMLPurifier/Language.php | 97 |
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 |