<commit_before><?php
abstract class Vps_Controller_Action_Auto_Vpc_Grid extends Vps_Controller_Action_Auto_Grid
{
    protected $_hasComponentId = true;

    public function preDispatch()
    {
        if (!isset($this->_model) && !isset($this->_tableName)) {
            $this->setModel(Vpc_Abstract::createModel($this->_getParam('class')));
        }
        parent::preDispatch();
    }

    protected function _getSelect()
    {
        $ret = parent::_getSelect();
        if ($this->_hasComponentId) {
            $ret->whereEquals('component_id', $this->_getParam('componentId'));
        }
        return $ret;
    }

    protected function _beforeSave($row)
    {
        if ($this->_hasComponentId) {
            $row->component_id = $this->_getParam('componentId');
        }
    }

    public function indexAction()
    {
        //nicht: parent::indexAction();
        $this->view->xtype = 'vps.component';
        $this->view->mainComponentClass = $this->_getParam('class');
        $this->view->baseParams = array('id' => $this->_getParam('componentId'));

        $this->view->componentConfigs = array();
        $this->view->mainEditComponents = array();
        $config = Vpc_Admin::getInstance($this->_getParam('class'))->getExtConfig();
        if (!$config) {
            throw new Vps_Exception("Not ExtConfig avaliable for this component");
        }
        foreach ($config as $k=>$c) {
            $this->view->componentConfigs[$this->_getParam('class').'-'.$k] = $c;
            $this->view->mainEditComponents[] = array(
                'componentClass' => $this->_getParam('class'),
                'type' => $k
            );
        }
        $this->view->mainType = $this->view->mainEditComponents[0]['type'];
    }

    public function jsonInsertAction()
    {
        //TODO: permissions überprüfen!
        Zend_Registry::get('db')->beginTransaction();
        $row = $this->_model->createRow();
        $this->_beforeInsert($row);
        $this->_beforeSave($row);
        if ($this->_position) {
            $row->pos = 0;
        }
        $this->view->id = $row->save();

        Zend_Registry::get('db')->commit();
    }
}<commit_msg>einerseits falsch weil das pos feld anders heissen kann, andererseits soll das feld fast immer null sein, da es dann von einem Numberize filter hinten angefuegt wird (was eher gewuenscht ist) und nicht vorn<commit_after><?php
abstract class Vps_Controller_Action_Auto_Vpc_Grid extends Vps_Controller_Action_Auto_Grid
{
    protected $_hasComponentId = true;

    public function preDispatch()
    {
        if (!isset($this->_model) && !isset($this->_tableName)) {
            $this->setModel(Vpc_Abstract::createModel($this->_getParam('class')));
        }
        parent::preDispatch();
    }

    protected function _getSelect()
    {
        $ret = parent::_getSelect();
        if ($this->_hasComponentId) {
            $ret->whereEquals('component_id', $this->_getParam('componentId'));
        }
        return $ret;
    }

    protected function _beforeSave($row)
    {
        if ($this->_hasComponentId) {
            $row->component_id = $this->_getParam('componentId');
        }
    }

    public function indexAction()
    {
        //nicht: parent::indexAction();
        $this->view->xtype = 'vps.component';
        $this->view->mainComponentClass = $this->_getParam('class');
        $this->view->baseParams = array('id' => $this->_getParam('componentId'));

        $this->view->componentConfigs = array();
        $this->view->mainEditComponents = array();
        $config = Vpc_Admin::getInstance($this->_getParam('class'))->getExtConfig();
        if (!$config) {
            throw new Vps_Exception("Not ExtConfig avaliable for this component");
        }
        foreach ($config as $k=>$c) {
            $this->view->componentConfigs[$this->_getParam('class').'-'.$k] = $c;
            $this->view->mainEditComponents[] = array(
                'componentClass' => $this->_getParam('class'),
                'type' => $k
            );
        }
        $this->view->mainType = $this->view->mainEditComponents[0]['type'];
    }

    public function jsonInsertAction()
    {
        //TODO: permissions überprüfen!
        Zend_Registry::get('db')->beginTransaction();
        $row = $this->_model->createRow();
        $this->_beforeInsert($row);
        $this->_beforeSave($row);
        $this->view->id = $row->save();

        Zend_Registry::get('db')->commit();
    }
}
{'fraction_non_alphanumeric': 0.1650268336314848, 'fraction_numerical': 0.0006708407871198568, 'mean_word_length': 2.558472553699284, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 99, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '5202386', 'n_tokens_mistral': 1296, 'n_tokens_neox': 1281, 'n_words': 219}