XOOPS  2.6.0
ButtonTray.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 */
11 
12 namespace Xoops\Form;
13 
25 class ButtonTray extends Element
26 {
27 
31  //private $type;
32 
36  private $showDelete;
37 
47  public function __construct($name, $value = '', $type = '', $onclick = '', $showDelete = false)
48  {
49  $this->setAttribute('name', $name);
50  $this->setValue($value);
51  $this->setAttribute('type', (!empty($type)) ? $type : 'submit');
52  $this->showDelete = $showDelete;
53  if ($onclick) {
54  $this->setExtra($onclick);
55  } else {
56  $this->setExtra('');
57  }
58  }
59 
65  public function getType()
66  {
67  return (string) $this->getAttribute('type');
68  }
69 
75  public function render()
76  {
77  $ret = '';
78  $this->addAttribute('class', 'btn');
79 
80  $class = 'class="' . $this->getClass() . '"';
82 
83  if ($this->showDelete) {
84  $ret .= '<input type="submit"' . $class . ' name="delete" id="delete" value="'
85  . \XoopsLocale::A_DELETE . '" onclick="this.form.elements.op.value=\'delete\'"> ';
86  }
87  $ret .= '<input type="button" ' . $class . ' value="' . \XoopsLocale::A_CANCEL
88  . '" onClick="history.go(-1);return true;" /> <input type="reset"' . $class
89  . ' name="reset" id="reset" value="' . \XoopsLocale::A_RESET . '" /> '
90  . '<input ' . $attributes . ' value="' . $this->getValue() . '" '
91  . $this->getExtra() . ' />';
92  return $ret;
93  }
94 }
const A_RESET
Definition: en_US.php:121
setValue($value)
Definition: Element.php:199
getValue($encode=false)
Definition: Element.php:180
setAttribute($name, $value=null)
Definition: Attributes.php:42
__construct($name, $value= '', $type= '', $onclick= '', $showDelete=false)
Definition: ButtonTray.php:47
getExtra($encode=false)
Definition: Element.php:539
const A_CANCEL
Definition: en_US.php:82
addAttribute($name, $value)
Definition: Attributes.php:117
$type
Definition: misc.php:33
const A_DELETE
Definition: en_US.php:89
setExtra($extra, $replace=false)
Definition: Element.php:522