. // if (!defined('BASEPATH')) exit ('No direct script access allowed'); /** * Generate a submit button. When pressed this button calls * a controller and passes a parameter. * * Note, as submit buttons uses their own form, they must not * be embedeed inside a form. */ class Button extends Widget { /** * Constructor - Sets Button's Preferences * * The constructor can be passed an array of attributes values * @param unknown_type $label * @param unknown_type $controller * @param unknown_type $param * @return the object */ public function __construct($attrs = array ()) { // Defaults $this->attr['label'] = 'Button'; $this->attr['controller'] = ""; $this->attr['action'] = ""; $this->attr['param'] = ""; $this->attr['image'] = ""; $this->attr['confirm'] = FALSE; $this->attr['confirmMsg'] = ""; parent :: __construct($attrs); } /** * Image of the widget * * @param array $where hash array with conditions */ public function image() { $controller = $this->attr['controller']; $action = $this->attr['action']; $param = $this->attr['param']; $label = $this->attr['label']; $confirm = $this->attr['confirm']; $image = $this->attr['image']; $txt = $this->attr['confirmMsg']; $res = ""; if ($confirm) { $txt = $txt . "?"; $attrs = "onclick=\"return confirm('$txt')\" "; } else { $attrs = ""; } if ($image != '') { $image_properties = array ( 'src' => $image, 'class' => 'icon', 'title' => $label ); $txt = img($image_properties); } else { $txt = $label; $attrs .= ' class="button btn btn-primary"'; } $res .= anchor(base_url() . "index.php/$controller/$action/$param", $txt, $attrs); return $res; } }