<commit_before><?php
/**
 * @version     $Id$
 * @package     Nooku_Server
 * @subpackage  Languages
 * @copyright   Copyright (C) 2011 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/gergoerdosi>
 * @package     Nooku_Server
 * @subpackage  Languages
 */

class ComLanguagesDatabaseRowLanguage extends KDatabaseRowDefault
{
    public function save()
    {
        $modified = $this->isModified('enabled');
        $result   = parent::save();
        
        if($this->getStatus() == KDatabase::STATUS_UPDATED && $modified && $this->enabled && $this->application == 'site')
        {
            $tables   = $this->getService('com://admin/languages.model.tables')->getList();
            $database = $this->getTable()->getDatabase();
            $prefix   = $database->getTablePrefix();
            
            foreach($tables as $table)
            {
                $table_name = strtolower($this->iso_code).'_'.$table->name;
                
                // Add language specific table and copy the content of the original table.
                $database->execute('CREATE TABLE '.$database->quoteIdentifier($prefix.$table_name).' LIKE '.$database->quoteIdentifier($prefix.$table->name));
                
                $select = $this->getService('koowa:database.query.select')
                    ->table($table->name);
                
                $insert = $this->getService('koowa:database.query.insert')
                    ->table($table_name)
                    ->values($select);
                
                $database->insert($insert);

                // Add items to the translations table.
                $columns = array(
                    'iso_code' => ':iso_code',
                    'table' => ':table',
                    'row' => 'tbl.'.$table->unique_column,
                    'status' => ':status',
                    'original' => ':original'
                );
                
                $select = $this->getService('koowa:database.query.select')
                    ->columns($columns)
                    ->table(array('tbl' => $table_name))
                    ->bind(array(
                        'iso_code' => $this->iso_code,
                        'table' => $table->name,
                        'status' => ComLanguagesDatabaseRowTranslation::STATUS_MISSING,
                        'original' => 0
                    ));
                
                $insert = $this->getService('koowa:database.query.insert')
                    ->table('languages_translations')
                    ->columns(array_keys($columns))
                    ->values($select);
                
                $database->insert($insert);
            }
        }
        
        return $result;
    }
}<commit_msg>Don't extend from default class.<commit_after><?php
/**
 * @version     $Id$
 * @package     Nooku_Server
 * @subpackage  Languages
 * @copyright   Copyright (C) 2011 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/gergoerdosi>
 * @package     Nooku_Server
 * @subpackage  Languages
 */

class ComLanguagesDatabaseRowLanguage extends KDatabaseRowTable
{
    public function save()
    {
        $modified = $this->isModified('enabled');
        $result   = parent::save();
        
        if($this->getStatus() == KDatabase::STATUS_UPDATED && $modified && $this->enabled && $this->application == 'site')
        {
            $tables   = $this->getService('com://admin/languages.model.tables')->getRowset();
            $database = $this->getTable()->getDatabase();
            $prefix   = $database->getTablePrefix();
            
            foreach($tables as $table)
            {
                $table_name = strtolower($this->iso_code).'_'.$table->name;
                
                // Add language specific table and copy the content of the original table.
                $database->execute('CREATE TABLE '.$database->quoteIdentifier($prefix.$table_name).' LIKE '.$database->quoteIdentifier($prefix.$table->name));
                
                $select = $this->getService('koowa:database.query.select')
                    ->table($table->name);
                
                $insert = $this->getService('koowa:database.query.insert')
                    ->table($table_name)
                    ->values($select);
                
                $database->insert($insert);

                // Add items to the translations table.
                $columns = array(
                    'iso_code' => ':iso_code',
                    'table' => ':table',
                    'row' => 'tbl.'.$table->unique_column,
                    'status' => ':status',
                    'original' => ':original'
                );
                
                $select = $this->getService('koowa:database.query.select')
                    ->columns($columns)
                    ->table(array('tbl' => $table_name))
                    ->bind(array(
                        'iso_code' => $this->iso_code,
                        'table' => $table->name,
                        'status' => ComLanguagesDatabaseRowTranslation::STATUS_MISSING,
                        'original' => 0
                    ));
                
                $insert = $this->getService('koowa:database.query.insert')
                    ->table('languages_translations')
                    ->columns(array_keys($columns))
                    ->values($select);
                
                $database->insert($insert);
            }
        }
        
        return $result;
    }
}
{'fraction_non_alphanumeric': 0.14273747696431563, 'fraction_numerical': 0.002010386999497403, 'mean_word_length': 1.5, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 97, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, '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': '6648866', 'n_tokens_mistral': 1578, 'n_tokens_neox': 1493, 'n_words': 256}