1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?php
- /**
- * Image button element for use on forms.
- *
- * @author Ironpilot
- * @copyright Copywrite (c) 2011, STAPLE CODE
- *
- * This file is part of the STAPLE Framework.
- *
- * The STAPLE Framework is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by the
- * Free Software Foundation, either version 3 of the License, or (at your option)
- * any later version.
- *
- * The STAPLE Framework is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
- * more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with the STAPLE Framework. If not, see <http://www.gnu.org/licenses/>.
- */
- class Staple_Form_ImageElement extends Staple_Form_Element
- {
- protected $src;
-
- public function setSrc($insert)
- {
- $this->Image = $insert;
- return $this;
- }
-
- public function getSrc()
- {
- return $this->Image;
- }
-
- /* (non-PHPdoc)
- * @see Staple_Form_Element::field()
- */
- public function field()
- {
- return ' <input type="image" src="'.$this->link($this->src).'" id="'.$this->escape($this->id).'" name="'.$this->escape($this->name).'" value="'.$this->escape($this->value).'">';
- }
- /* (non-PHPdoc)
- * @see Staple_Form_Element::label()
- */
- public function label()
- {
- return ' <label for="'.$this->escape($this->id).'"'.$this->getClassString().'>'.$this->label.'</label>';
- }
- public function build()
- {
- $buf = '';
- $view = FORMS_ROOT.'/fields/ImageElement.phtml';
- if(file_exists($view))
- {
- ob_start();
- include $view;
- $buf = ob_get_contents();
- ob_end_clean();
- }
- else
- {
- $this->addClass('form_element');
- $this->addClass('element_image');
- $classes = $this->getClassString();
- $buf .= "<div$classes id=\"".$this->escape($this->id)."_element\">\n";
- if(isset($this->label))
- {
- $buf .= $this->label();
- }
- $buf .= $this->field();
- $buf .= '</div>';
- }
- return $buf;
- }
- }
|