protected function _getFilename($dataRow)
 {
     if ($dataRow && (!empty($dataRow->firstname) || !empty($dataRow->lastname))) {
         $filename = $dataRow->lastname . '_' . $dataRow->firstname;
         $filter = new Kwf_Filter_Ascii();
         return $filter->filter($filename);
     }
     return null;
 }
 protected function _getFormField()
 {
     $ret = parent::_getFormField();
     $values = array();
     $filter = new Kwf_Filter_Ascii();
     foreach ($this->getRow()->getChildRows('Values') as $i) {
         $values[$filter->filter($i->value)] = $i->value;
     }
     $ret->setValues($values);
     return $ret;
 }
 protected function _beforeSave()
 {
     parent::_beforeSave();
     if (is_null($this->filename)) {
         $fRow = $this->getParentRow('File');
         if ($fRow) {
             $filter = new Kwf_Filter_Ascii();
             $this->filename = $filter->filter($fRow->filename);
         }
     }
 }
 public function jsonMultiUploadAction()
 {
     Zend_Registry::get('db')->beginTransaction();
     $asciiFilter = new Kwf_Filter_Ascii();
     $uploadIds = explode(',', $this->_getParam('uploadIds'));
     $max = Kwc_Abstract::getSetting($this->_getParam('class'), 'maxEntries');
     if ($max) {
         $s = new Kwf_Model_Select();
         $s->whereEquals('component_id', $this->_getParam('componentId'));
         if ($this->_model->countRows($s) + count($uploadIds) >= $max) {
             throw new Kwf_Exception_Client(trlKwf("Can't create more than {0} entries.", $max));
         }
     }
     foreach ($uploadIds as $uploadId) {
         $fileRow = Kwf_Model_Abstract::getInstance('Kwf_Uploads_Model')->getRow($uploadId);
         $row = $this->_model->createRow();
         $this->_beforeInsert($row, null);
         $this->_beforeSave($row, null);
         $row->save();
         $form = Kwc_Abstract_Form::createChildComponentForm($this->_getParam('class'), 'child');
         $form->setIdTemplate(null);
         $field = $this->_getFileUploadField($form);
         if (!$field) {
             throw new Kwf_Exception("can't find file field");
         }
         $form->setId($this->_getParam('componentId') . '-' . $row->id);
         $postData = array($field->getFieldName() => $uploadId);
         foreach ($this->_getAutoFillFilenameField($form) as $f) {
             if ($f->getAutoFillWithFilename() == 'filename') {
                 $postData[$f->getFieldName()] = $asciiFilter->filter($fileRow->filename);
             } else {
                 if ($f->getAutoFillWithFilename() == 'filenameWithExt') {
                     $postData[$f->getFieldName()] = $asciiFilter->filter($fileRow->filename) . '.' . $fileRow->extension;
                 }
             }
         }
         $postData = array_merge($postData, $this->_getDefaultValues($form));
         $postData = $form->processInput(null, $postData);
         if ($errors = $form->validate(null, $postData)) {
             throw new Kwf_Exception('validate failed');
         }
         $form->prepareSave(null, $postData);
         $form->save(null, $postData);
     }
     Zend_Registry::get('db')->commit();
 }
 public function testAscii()
 {
     $filter = new Kwf_Filter_Ascii();
     $this->assertEquals('abcdefghijklmno', $filter->filter('°a!b"c§d$e%f&g/h(i)j=k?l`m\\n^o'));
     $this->assertEquals('oe', $filter->filter('#+~:;,.<>|ö'));
     $this->assertEquals('ueber_uns', $filter->filter('Über uns'));
     $this->assertEquals('kontakt', $filter->filter('контакт'));
     $this->assertEquals('ab', $filter->filter('a:b'));
     $this->assertEquals('a_b', $filter->filter('a  b'));
 }