HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers64/klimroosbudel.nl/wwwroot/kms/lib/ui/button.class.php
<?php
/**
 * button.class.php
 * Created by Komma Mediadesign.
 * Author: mike
 * Date: 3/21/13
 */
class Button
{
    /*
     * @property string $_label
     * Button Label
     */
    private $_label;

    /*
     * @property string $_button
     * A button can be an "a-link" or an "input/submit" or an "input/button"
     */
    private $_type;

    /*
     * @property string $_name
     * Name is used in an input button.
     */
    private $_name;

    /*
     * @property string $_href
     * Url on an "a-link"
     */
    private $_href;

    /*
     * @property array $_classes
     * Class which are added to a button
     */
    private $_classes;

    /*
     * @property string $_id
     * An id which is added to the button
     */
    private $_id;

    public function __construct($options)
    {
        isset($options['type']) ? $this->_type = $options['type'] : $this->_type = 'submit';
        isset($options['label']) ? $this->_label = $options['label'] : $this->_label = 'button';
        isset($options['name']) ? $this->_name = $options['name'] : $this->_name = 'submit';
        isset($options['href']) ? $this->_href = $options['href'] : $this->_href = '#';

        $this->_classes = [];
        $this->_id = '';
    }

    /**
     * Adds classes to the button
     *
     * @param array
     * @return null
     */
    public function addClasses($classes = null)
    {
        foreach ($classes as $class) {
            $this->_classes[] = $class;
        }
    }

    /**
     * Adds id to the button
     *
     * @param array
     * @return null
     */
    public function addId($id = null)
    {
        if (! empty($id)) {
            $this->_id = $id;
        }
    }

    /**
     * Returns a string containing a submit button
     *
     * @param
     * @return string
     */
    private function createInputButton()
    {
        $str = '';
        $str .= '
        <div class="btn ';
        if (! empty($this->_classes)) {
            foreach ($this->_classes as $class) {
                $str .= $class.' ';
            }
            $str = substr($str, 0, -1);
        }
        $str .= '">';
        $str .= '<input type="'.$this->_type.'" name="'.$this->_name.'" value="'.$this->_label.'" ';

        if (! empty($this->_id)) {
            $str .= 'id="'.$this->_id.'" ';
        }
        $str .= '/>';

        $str .= '<span class="over"></span>
                     <span class="out"></span>
        </div>';

        return $str;
    }

    /**
     * Returns a string containing an <a> link
     *
     * @param
     * @return string
     */
    private function createLinkButton()
    {
        $str = '';
        $str .= '<a href="'.$this->_href.'" title="'.$this->_label.'" ';
        $str .= 'class="btn ';
        if (! empty($this->_classes)) {
            foreach ($this->_classes as $class) {
                $str .= $class.' ';
            }
            $str = substr($str, 0, -1);
        }
        $str .= '" ';
        if (! empty($this->_id)) {
            $str .= '"'.$this->_id.'" ';
        }
        $str .= '>

		<span class="over">'.$this->_label.'</span>
		<span class="out">'.$this->_label.'</span>


		</a>';

        return $str;
    }

    /**
     * returns a string containing the button
     *
     * @param
     * @return
     */
    public function display($echo = true)
    {
        $output = '';
        switch($this->_type) {
            case 'submit':
            case 'button':
                $output .= $this->createInputButton();
                break;
            case 'link':
                $output .= $this->createLinkButton();
                break;
        }
        if ($echo) {
            echo $output;
        } else {
            return $output;
        }
    }
}