Allow plugins to define their own tasks + add 'domain' parameter for rcube_template::button()

release-0.6
thomascube 16 years ago
parent d4d1a2505d
commit 1c932d58b5

@ -91,7 +91,7 @@ class rcmail
} }
// set task and action properties // set task and action properties
$this->set_task(strip_quotes(get_input_value('_task', RCUBE_INPUT_GPC))); $this->set_task(get_input_value('_task', RCUBE_INPUT_GPC));
$this->action = asciiwords(get_input_value('_action', RCUBE_INPUT_GPC)); $this->action = asciiwords(get_input_value('_action', RCUBE_INPUT_GPC));
// connect to database // connect to database
@ -145,14 +145,12 @@ class rcmail
*/ */
public function set_task($task) public function set_task($task)
{ {
if (!in_array($task, self::$main_tasks)) $task = asciiwords($task);
$task = 'mail'; $this->task = $task ? $task : 'mail';
$this->comm_path = $this->url(array('task' => $this->task));
$this->task = $task;
$this->comm_path = $this->url(array('task' => $task));
if ($this->output) if ($this->output)
$this->output->set_env('task', $task); $this->output->set_env('task', $this->task);
} }
@ -937,10 +935,7 @@ class rcmail
if (!is_array($p)) if (!is_array($p))
$p = array('_action' => @func_get_arg(0)); $p = array('_action' => @func_get_arg(0));
$task = $p['_task'] ? $p['_task'] : $p['task']; $task = $p['_task'] ? $p['_task'] : ($p['task'] ? $p['task'] : $this->task);
if (!$task || !in_array($task, rcmail::$main_tasks))
$task = $this->task;
$p['_task'] = $task; $p['_task'] = $task;
unset($p['task']); unset($p['task']);

@ -101,11 +101,29 @@ abstract class rcube_plugin
* @return string Localized text * @return string Localized text
* @see rcmail::gettext() * @see rcmail::gettext()
*/ */
function gettext($p) public function gettext($p)
{ {
return rcmail::get_instance()->gettext($p, $this->ID); return rcmail::get_instance()->gettext($p, $this->ID);
} }
/**
* Register this plugin to be responsible for a specific task
*
* @param string Task name (only characters [a-z0-9_.-] are allowed)
*/
public function register_task($task)
{
if ($task != asciiwords($task)) {
raise_error(array('code' => 526, 'type' => 'php', 'message' => "Invalid task name: $task. Only characters [a-z0-9_.-] are allowed"), true, false);
}
else if (in_array(rcmail::$main_tasks, $task)) {
raise_error(array('code' => 526, 'type' => 'php', 'message' => "Cannot register taks $task; already taken by another plugin or the application itself"), true, false);
}
else {
rcmail::$main_tasks[] = $task;
}
}
/** /**
* Register a handler for a specific client-request action * Register a handler for a specific client-request action
* *

@ -732,13 +732,13 @@ class rcube_template extends rcube_html_page
} }
// get localized text for labels and titles // get localized text for labels and titles
if ($attrib['title']) { if ($attrib['title']) {
$attrib['title'] = Q(rcube_label($attrib['title'])); $attrib['title'] = Q(rcube_label($attrib['title'], $attrib['domain']));
} }
if ($attrib['label']) { if ($attrib['label']) {
$attrib['label'] = Q(rcube_label($attrib['label'])); $attrib['label'] = Q(rcube_label($attrib['label'], $attrib['domain']));
} }
if ($attrib['alt']) { if ($attrib['alt']) {
$attrib['alt'] = Q(rcube_label($attrib['alt'])); $attrib['alt'] = Q(rcube_label($attrib['alt'], $attrib['domain']));
} }
// set title to alt attribute for IE browsers // set title to alt attribute for IE browsers
if ($this->browser->ie && $attrib['title'] && !$attrib['alt']) { if ($this->browser->ie && $attrib['title'] && !$attrib['alt']) {

Loading…
Cancel
Save