summaryrefslogtreecommitdiff
path: root/program/include/rcmail.php
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2011-09-12 12:52:01 +0000
committeralecpl <alec@alec.pl>2011-09-12 12:52:01 +0000
commit8703b0801865eb47505c960037d916253e315fc7 (patch)
tree0f053d02dd4512e98731d7adede5253b7dafdc38 /program/include/rcmail.php
parent979679b311c3f55c5a2d556391554613420f6379 (diff)
- Extend rcube_label_exists() to search in loaded plugins localizations
- Allow use localized addressbook field subtypes from plugins
Diffstat (limited to 'program/include/rcmail.php')
-rw-r--r--program/include/rcmail.php37
1 files changed, 30 insertions, 7 deletions
diff --git a/program/include/rcmail.php b/program/include/rcmail.php
index f126a912f..b364bd643 100644
--- a/program/include/rcmail.php
+++ b/program/include/rcmail.php
@@ -970,7 +970,9 @@ class rcmail
/**
* Get localized text in the desired language
*
- * @param mixed Named parameters array or label name
+ * @param mixed $attrib Named parameters array or label name
+ * @param string $domain Label domain (plugin) name
+ *
* @return string Localized text
*/
public function gettext($attrib, $domain=null)
@@ -985,7 +987,7 @@ class rcmail
$nr = is_numeric($attrib['nr']) ? $attrib['nr'] : 1;
$name = $attrib['name'] ? $attrib['name'] : '';
-
+
// attrib contain text values: use them from now
if (($setval = $attrib[strtolower($_SESSION['language'])]) || ($setval = $attrib['en_us']))
$this->texts[$name] = $setval;
@@ -1041,19 +1043,40 @@ class rcmail
/**
- * Check if the given text lable exists
+ * Check if the given text label exists
+ *
+ * @param string $name Label name
+ * @param string $domain Label domain (plugin) name or '*' for all domains
+ * @param string $ref_domain Sets domain name if label is found
*
- * @param string Label name
* @return boolean True if text exists (either in the current language or in en_US)
*/
- public function text_exists($name, $domain=null)
+ public function text_exists($name, $domain = null, &$ref_domain = null)
{
// load localization files if not done yet
if (empty($this->texts))
$this->load_language();
- // check for text with domain first
- return ($domain && isset($this->texts[$domain.'.'.$name])) || isset($this->texts[$name]);
+ if (isset($this->texts[$name])) {
+ $ref_domain = '';
+ return true;
+ }
+
+ // any of loaded domains (plugins)
+ if ($domain == '*') {
+ foreach ($this->plugins->loaded_plugins() as $domain)
+ if (isset($this->texts[$domain.'.'.$name])) {
+ $ref_domain = $domain;
+ return true;
+ }
+ }
+ // specified domain
+ else if ($domain) {
+ $ref_domain = $domain;
+ return isset($this->texts[$domain.'.'.$name]);
+ }
+
+ return false;
}
/**