<commit_before><?php
/**
 * @version     $Id: templates.php 1161 2011-05-11 14:52:09Z johanjanssens $
 * @category	Nooku
 * @package     Nooku_Server
 * @subpackage  Extensions
 * @copyright   Copyright (C) 2011 - 2012 Timble CVBA and Contributors. (http://www.timble.net).
 * @license     GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link        http://www.nooku.org
 */

/**
 * Language Database Row Class
 *
 * @author      <NAME> <http://nooku.assembla.com/profile/ercanozkaya>
 * @category	Nooku
 * @package     Nooku_Server
 * @subpackage  Extensions
 */

class ComExtensionsDatabaseRowLanguage extends KDatabaseRowAbstract
{
	/**
     * Whitelist for keys to get from the xml manifest
     *
     * @var array
     */
    protected static $_manifest_fields = array(
    	'creationDate',
        'author',
        'copyright',
        'authorEmail',
        'authorUrl',
        'version',
        'description'
    );
    
	public function __get($column)
	{    
	    if ($column == 'name' && empty($this->_data['name'])) {
			$this->_data['name'] = basename($this->_data['path']);
		}
		
	    if($column == 'title' && empty($this->_data['title'])) 
	    {
            if($this->manifest instanceof SimpleXMLElement) {
                $this->_data['title'] = $this->manifest->name;
            } else {
                 $this->_data['title'] = '';
            }
	    }

		if ($column == 'manifest' && empty($this->_data['manifest'])) 
		{
            $file = $this->_data['path'].'/'.basename($this->_data['path']).'.xml';
           
            if(file_exists($file)) {
		        $this->_data['manifest'] = simplexml_load_file($file);
            } else {
                $this->_data['manifest'] = null;
            }
		}

		if (in_array($column, self::$_manifest_fields) && empty($this->_data[$column])) {
			$this->_data[$column] = $this->manifest->{$column};
		}

		return parent::__get($column);
	}
	
    public function save()
	{
		if (isset($this->_modified['default']) && $this->default)
		{   
		    //Update the params
		    $params = JComponentHelper::getParams('com_extensions');
		    $params->set('language_'.$this->application, $this->name);
 
		    //Save the params   
			$result = $this->getService('com://admin/extensions.model.components', array('name' => 'components'))
                        ->select(array('option' => 'com_extensions'), KDatabase::FETCH_ROW) 
                        ->set('params', $params)       
			            ->save();

			return $result;
		}

		return true;
	}
<commit_msg>re #197 : Unable to switch default language<commit_after><?php
/**
 * @version     $Id: templates.php 1161 2011-05-11 14:52:09Z johanjanssens $
 * @category	Nooku
 * @package     Nooku_Server
 * @subpackage  Extensions
 * @copyright   Copyright (C) 2011 - 2012 Timble CVBA and Contributors. (http://www.timble.net).
 * @license     GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link        http://www.nooku.org
 */

/**
 * Language Database Row Class
 *
 * @author      <NAME> <http://nooku.assembla.com/profile/ercanozkaya>
 * @category	Nooku
 * @package     Nooku_Server
 * @subpackage  Extensions
 */

class ComExtensionsDatabaseRowLanguage extends KDatabaseRowAbstract
{
	/**
     * Whitelist for keys to get from the xml manifest
     *
     * @var array
     */
    protected static $_manifest_fields = array(
    	'creationDate',
        'author',
        'copyright',
        'authorEmail',
        'authorUrl',
        'version',
        'description'
    );
    
	public function __get($column)
	{    
	    if ($column == 'name' && empty($this->_data['name'])) {
			$this->_data['name'] = basename($this->_data['path']);
		}
		
	    if($column == 'title' && empty($this->_data['title'])) 
	    {
            if($this->manifest instanceof SimpleXMLElement) {
                $this->_data['title'] = $this->manifest->name;
            } else {
                 $this->_data['title'] = '';
            }
	    }

		if ($column == 'manifest' && empty($this->_data['manifest'])) 
		{
            $file = $this->_data['path'].'/'.basename($this->_data['path']).'.xml';
           
            if(file_exists($file)) {
		        $this->_data['manifest'] = simplexml_load_file($file);
            } else {
                $this->_data['manifest'] = null;
            }
		}

		if (in_array($column, self::$_manifest_fields) && empty($this->_data[$column])) {
			$this->_data[$column] = $this->manifest->{$column};
		}

		return parent::__get($column);
	}
	
    public function save()
	{
		if (isset($this->_modified['default']) && $this->default)
		{   
		    //Update the params
		    $params = JComponentHelper::getParams('com_extensions');
		    $params->set('language_'.$this->application, $this->name);
 
		     //Save the params
			$result = $this->getService('com://admin/extensions.database.table.components')
                           ->select(array('option' => 'com_extensions'), KDatabase::FETCH_ROW)
                           ->set('params', $params)
			               ->save();
			
			return $result;
		}

		return true;
	}

{'fraction_non_alphanumeric': 0.17355371900826447, 'fraction_numerical': 0.011216056670602124, 'mean_word_length': 2.3484848484848486, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 66, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 6}, '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': '7251412', 'n_tokens_mistral': 1708, 'n_tokens_neox': 1531, 'n_words': 280}