summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2013-05-16 12:59:03 +0200
committerAleksander Machniak <alec@alec.pl>2013-05-16 12:59:03 +0200
commit52f2a698555dd50f176b58f09396a0a0d9227a04 (patch)
treee2abe3f191ab1121fe9c21fe8d8fc1725038f0fe
parentac5b58bac4a1760106da301b1c2c6c81103058d6 (diff)
Added rcube_plugin::add_label() method
-rw-r--r--program/lib/Roundcube/rcube_plugin.php24
1 files changed, 23 insertions, 1 deletions
diff --git a/program/lib/Roundcube/rcube_plugin.php b/program/lib/Roundcube/rcube_plugin.php
index d24a2693c..3153a8410 100644
--- a/program/lib/Roundcube/rcube_plugin.php
+++ b/program/lib/Roundcube/rcube_plugin.php
@@ -227,7 +227,7 @@ abstract class rcube_plugin
$rcube->load_language($lang, $add);
// add labels to client
- if ($add2client) {
+ if ($add2client && method_exists($rcube->output, 'add_label')) {
if (is_array($add2client)) {
$js_labels = array_map(array($this, 'label_map_callback'), $add2client);
}
@@ -240,6 +240,24 @@ abstract class rcube_plugin
}
/**
+ * Wrapper for add_label() adding the plugin ID as domain
+ */
+ public function add_label()
+ {
+ $rcube = rcube::get_instance();
+
+ if (method_exists($rcube->output, 'add_label')) {
+ $args = func_get_args();
+ if (count($args) == 1 && is_array($args[0])) {
+ $args = $args[0];
+ }
+
+ $args = array_map(array($this, 'label_map_callback'), $args);
+ $rcube->output->add_label($args);
+ }
+ }
+
+ /**
* Wrapper for rcube::gettext() adding the plugin ID as domain
*
* @param string $p Message identifier
@@ -390,6 +408,10 @@ abstract class rcube_plugin
*/
private function label_map_callback($key)
{
+ if (strpos($key, $this->ID.'.') === 0) {
+ return $key;
+ }
+
return $this->ID.'.'.$key;
}
}