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

/**
 * Default Toolbar
.*
 * @author      <NAME> <<EMAIL>>
 * @category    Nooku
 * @package     Nooku_Components
 * @subpackage  Default
 */
class ComDefaultControllerToolbarDefault extends KControllerToolbarDefault
{
	/**
     * Constructor
     *
     * @param   object  An optional KConfig object with configuration options
     */
    public function __construct(KConfig $config)
    {
        parent::__construct($config);
       
        $name  = $this->_identifier->name;
        
        if(KInflector::isPlural($name))
        {        
            //Insert the default commands
            $this->append('new')
                 ->append('delete');    
        }
        else
        {
            //Insert the default commands
            $this->append('save')
                 ->append('apply')
                 ->append('cancel');
            
            //Set the title
            $name  = ucfirst($this->getName());  
            $state = $this->getController()->getModel()->getState();   
            $title = $state->isUnique() ?  'Edit '.$name : 'New '.$name;
            
            $this->setTitle($title);
        }
    }
    
    protected function _commandAction(KControllerToolbarCommand $command)
    {
        $command->append(array(
            'attribs'    => array(
                'data-action'  => $command->getName()
            )
        ));
    }
  
    protected function _commandNew(KControllerToolbarCommand $command)
    {
        $option = KRequest::get('get.option', 'cmd');
        $view   = KInflector::singularize(KRequest::get('get.view', 'cmd'));
        
        $command->append(array(
            'attribs' => array(
                'href'     => JRoute::_( 'index.php?option='.$option.'&view='.$view)
            )
        ));
    }
    
    protected function _commandCancel(KControllerToolbarCommand $command)
    {  
        $command->append(array(
        	'attribs' => array(
                'data-action' 	  => 'cancel',
        		'data-novalidate' => 'novalidate'
            )
        ));	
    }
    
    protected function _commandEnable(KControllerToolbarCommand $command)
    {
        $command->icon = 'icon-32-publish'; 
        
        $command->append(array(
            'attribs' => array(
                'data-action' => 'edit',
                'data-data'   => '{enabled:1}'
            )
        ));
    }
    
    protected function _commandDisable(KControllerToolbarCommand $command)
    {
        $command->icon = 'icon-32-unpublish';
        
        $command->append(array(   
            'attribs' => array(
                'data-action' => 'edit',
                'data-data'   => '{enabled:0}'
            )
        ));
    }
    
    protected function _commandExport(KControllerToolbarCommand $command)
    {
        $url = clone KRequest::url();
        $query = parse_str($url->getQuery(), $vars);
        
        unset($vars['limit']);
        unset($vars['offset']);
        
        $vars['format'] = 'csv';
        $url->setQuery(http_build_query($vars));
        
        $command->append(array(
            'attribs' => array(
                'href' =>  (string) $url
            )
        ));
    }
      
    protected function _commandPreferences(KControllerToolbarCommand $command)
    { 
        $command->append(array(
            'width'   => '640',
            'height'  => '480',
        ))->append(array(
            'attribs' => array(
                'class' => array('modal'),
                'href'  => 'index.php?option=com_config&controller=component&component=com_'.$this->_identifier->package,
                'rel'   => '{handler: \'iframe\', size: {x: '.$command->width.', y: '.$command->height.'}}'
            )
        ));
    }
}<commit_msg>re #99 : Renamed KControllerToolbarAsbtract::append() to insert() and removed prepend function.<commit_after><?php
/**
 * @version   	$Id$
 * @category	Nooku
 * @package     Nooku_Components
 * @subpackage  Default
 * @copyright  	Copyright (C) 2007 - 2010 <NAME>. All rights reserved.
 * @license   	GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link        http://www.nooku.org
 */

/**
 * Default Toolbar
.*
 * @author      <NAME> <<EMAIL>>
 * @category    Nooku
 * @package     Nooku_Components
 * @subpackage  Default
 */
class ComDefaultControllerToolbarDefault extends KControllerToolbarDefault
{
	/**
     * Constructor
     *
     * @param   object  An optional KConfig object with configuration options
     */
    public function __construct(KConfig $config)
    {
        parent::__construct($config);
       
        $name  = $this->_identifier->name;
        
        if(KInflector::isPlural($name))
        {        
            //Insert the default commands
            $this->insert('new')
                 ->insert('delete');    
        }
        else
        {
            //Insert the default commands
            $this->insert('save')
                 ->insert('apply')
                 ->insert('cancel');
            
            //Set the title
            $name  = ucfirst($this->getName());  
            $state = $this->getController()->getModel()->getState();   
            $title = $state->isUnique() ?  'Edit '.$name : 'New '.$name;
            
            $this->setTitle($title);
        }
    }
    
    protected function _commandAction(KControllerToolbarCommand $command)
    {
        $command->append(array(
            'attribs'    => array(
                'data-action'  => $command->getName()
            )
        ));
    }
  
    protected function _commandNew(KControllerToolbarCommand $command)
    {
        $option = KRequest::get('get.option', 'cmd');
        $view   = KInflector::singularize(KRequest::get('get.view', 'cmd'));
        
        $command->append(array(
            'attribs' => array(
                'href'     => JRoute::_( 'index.php?option='.$option.'&view='.$view)
            )
        ));
    }
    
    protected function _commandCancel(KControllerToolbarCommand $command)
    {  
        $command->append(array(
        	'attribs' => array(
                'data-action' 	  => 'cancel',
        		'data-novalidate' => 'novalidate'
            )
        ));	
    }
    
    protected function _commandEnable(KControllerToolbarCommand $command)
    {
        $command->icon = 'icon-32-publish'; 
        
        $command->append(array(
            'attribs' => array(
                'data-action' => 'edit',
                'data-data'   => '{enabled:1}'
            )
        ));
    }
    
    protected function _commandDisable(KControllerToolbarCommand $command)
    {
        $command->icon = 'icon-32-unpublish';
        
        $command->append(array(   
            'attribs' => array(
                'data-action' => 'edit',
                'data-data'   => '{enabled:0}'
            )
        ));
    }
    
    protected function _commandExport(KControllerToolbarCommand $command)
    {
        $url = clone KRequest::url();
        $query = parse_str($url->getQuery(), $vars);
        
        unset($vars['limit']);
        unset($vars['offset']);
        
        $vars['format'] = 'csv';
        $url->setQuery(http_build_query($vars));
        
        $command->append(array(
            'attribs' => array(
                'href' =>  (string) $url
            )
        ));
    }
      
    protected function _commandPreferences(KControllerToolbarCommand $command)
    { 
        $command->append(array(
            'width'   => '640',
            'height'  => '480',
        ))->append(array(
            'attribs' => array(
                'class' => array('modal'),
                'href'  => 'index.php?option=com_config&controller=component&component=com_'.$this->_identifier->package,
                'rel'   => '{handler: \'iframe\', size: {x: '.$command->width.', y: '.$command->height.'}}'
            )
        ));
    }
}
{'fraction_non_alphanumeric': 0.1497802734375, 'fraction_numerical': 0.00537109375, 'mean_word_length': 1.687992125984252, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 115, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '5014247', 'n_tokens_mistral': 2378, 'n_tokens_neox': 2336, 'n_words': 393}