options['icon'] = $icon; $this->options['text'] = JText::translate($alt); $this->options['class'] = strtolower(preg_replace("/[^a-zA-Z0-9_\-]+/", '-', $icon)); $this->options['id'] = 'jbutton-' . strtolower(preg_replace("/[^a-zA-Z0-9_\-]+/", '-', $task)); $this->options['action'] = $this->getCommand($task, $check); } /** * @override * Returns an array containing the data to use for the button rendering. * * @return array Display data array. */ public function getDisplayData() { return $this->options; } /** * Returns the javascript onclick event to launch. * * @param string $task The form task to launch. * @param boolean $check If true, it is mandatory the selection of the rows. * * @return string The onclick event. */ protected function getCommand($task, $check = false) { $cmd = "Joomla.submitbutton('{$task}');"; if ($check) { $cmd = "if (Joomla.hasChecked()) { $cmd } else { alert('" . addslashes(JText::translate('PLEASE_MAKE_A_SELECTION')) . "'); }"; } return $cmd; } }