<commit_before><?php
/**
* @version      $Id$
* @category		Koowa
* @package		Koowa_Toolbar
* @subpackage	Button
* @copyright    Copyright (C) 2007 - 2010 <NAME>. All rights reserved.
* @license      GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
*/

/**
 * Base button class for a toolbar
 *
 * @author      <NAME> <<EMAIL>>
 * @category    Koowa
 * @package     Koowa_Toolbar
 * @subpackage  Button
 * @uses        KInflector
 */
abstract class KToolbarButtonAbstract extends KObject implements KToolbarButtonInterface,  KObjectIdentifiable
{
    /**
     * Method used to submit the form
     *
     * @var string  [GET|POST|DELETE|PUT]
     */
    protected $_method;

    /**
     * Constructor
     *
     * @param   object  An optional KConfig object with configuration options
     */
    public function __construct(KConfig $config = null)
    {
        //If no config is passed create it
        if(!isset($config)) $config = new KConfig();

        parent::__construct($config);

        if($config->parent) {
            $this->setParent($config->parent);
        }

        $this->setMethod($config->method);

        $this->_options = $config;
    }

    /**
     * Initializes the options for the object
     *
     * Called from {@link __construct()} as a first step of object instantiation.
     *
     * @param   object  An optional KConfig object with configuration options
     * @return  void
     */
    protected function _initialize(KConfig $config)
    {
        $name = $this->_identifier->name;

        $config->append(array(
            'parent'     => null,
            'icon'       => 'icon-32-'.$name,
            'id'         => $name,
            'text'       => ucfirst($name),
            'method'     => 'get',
        ));

        parent::_initialize($config);
    }

    /**
     * Get the object identifier
     *
     * @return  KIdentifier
     * @see     KObjectIdentifiable
     */
    public function getIdentifier()
    {
        return $this->_identifier;
    }

    /**
     * Set the parent toolbar
     *
     * @param   KToolbarInterface   Toolbar
     * @return  this
     */
    public function setParent(KToolbarInterface $toolbar)
    {
        $this->_parent = $toolbar;
        return $this;
    }

    /**
     * Get the parent toolbar
     *
     * @return  KToolbarInterface   Toolbar
     */
    public function getParent()
    {
        return $this->_parent;
    }

    /**
     * Set the method used to submit the form
     *
     * @param   string  [get|post|delete]
     * @return  this
     */
    public function setMethod($method)
    {
        $this->_method = strtolower($method);
        return $this;
    }

    /**
     * Get the element name
     *
     * @return  string  Button name
     */
    public function getName()
    {
        return $this->_identifier->name;
    }

    public function getLink()
    {
        return '#';
    }

    public function getOnClick()
    {
        return '';
    }

    public function getId()
    {
        return 'toolbar-'.$this->getParent()->getName().'-'.$this->_options->id;
    }

    public function getClass()
    {
        return $this->_options->icon;
    }
    
    public function getText()
    {
        return $this->_options->text;
    }
}<commit_msg>re #99 : Toolbar buttons now have an attribs property in its options, allowing you to define what attributes are rendered on the toolbar button.<commit_after><?php
/**
* @version      $Id$
* @category		Koowa
* @package		Koowa_Toolbar
* @subpackage	Button
* @copyright    Copyright (C) 2007 - 2010 <NAME>. All rights reserved.
* @license      GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
*/

/**
 * Base button class for a toolbar
 *
 * @author      <NAME> <<EMAIL>>
 * @category    Koowa
 * @package     Koowa_Toolbar
 * @subpackage  Button
 * @uses        KInflector
 */
abstract class KToolbarButtonAbstract extends KObject implements KToolbarButtonInterface,  KObjectIdentifiable
{
    /**
     * Method used to submit the form
     *
     * @var string  [GET|POST|DELETE|PUT]
     */
    protected $_method;

    /**
     * Constructor
     *
     * @param   object  An optional KConfig object with configuration options
     */
    public function __construct(KConfig $config = null)
    {
        //If no config is passed create it
        if(!isset($config)) $config = new KConfig();

        parent::__construct($config);

        if($config->parent) {
            $this->setParent($config->parent);
        }

        $this->setMethod($config->method);

        $this->_options = $config;
    }

    /**
     * Initializes the options for the object
     *
     * Called from {@link __construct()} as a first step of object instantiation.
     *
     * @param   object  An optional KConfig object with configuration options
     * @return  void
     */
    protected function _initialize(KConfig $config)
    {
        $name = $this->_identifier->name;

        $config->append(array(
            'parent'     => null,
            'icon'       => 'icon-32-'.$name,
            'id'         => $name,
            'text'       => ucfirst($name),
            'method'     => 'get',
            'attribs'    => array(
                'class'    => 'toolbar'
            )
        ));

        parent::_initialize($config);
    }

    /**
     * Get the object identifier
     *
     * @return  KIdentifier
     * @see     KObjectIdentifiable
     */
    public function getIdentifier()
    {
        return $this->_identifier;
    }

    /**
     * Set the parent toolbar
     *
     * @param   KToolbarInterface   Toolbar
     * @return  this
     */
    public function setParent(KToolbarInterface $toolbar)
    {
        $this->_parent = $toolbar;
        return $this;
    }

    /**
     * Get the parent toolbar
     *
     * @return  KToolbarInterface   Toolbar
     */
    public function getParent()
    {
        return $this->_parent;
    }

    /**
     * Set the method used to submit the form
     *
     * @param   string  [get|post|delete]
     * @return  this
     */
    public function setMethod($method)
    {
        $this->_method = strtolower($method);
        return $this;
    }

    /**
     * Get the element name
     *
     * @return  string  Button name
     */
    public function getName()
    {
        return $this->_identifier->name;
    }

    public function getLink()
    {
        return '';
    }

    public function getOnClick()
    {
        return '';
    }

    public function getId()
    {
        return 'toolbar-'.$this->getParent()->getName().'-'.$this->_options->id;
    }

    public function getClass()
    {
        return $this->_options->icon;
    }
    
    public function getText()
    {
        return $this->_options->text;
    }
    
    public function getAttribs()
    {
    	return $this->_options->attribs->toArray();
    }
    
    public function setAttribs($attribs)
    {
        $this->_options->attribs = $attribs;

        return $this;
    }
}
{'fraction_non_alphanumeric': 0.12128995433789955, 'fraction_numerical': 0.003424657534246575, 'mean_word_length': 1.8503456689711264, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 76, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '363981', 'n_tokens_mistral': 2063, 'n_tokens_neox': 2017, 'n_words': 507}