<?php
namespace Moto\Application\Fonts\InputFilter; use Moto; use Zend; class UploadFontVariant extends Moto\InputFilter\AbstractInputFilter { protected $_name = 'fonts.uploadFontVariant'; public function init() { $this->add([ 'name' => 'id', 'required' => true, 'validators' => [ [ 'name' => 'Digits', 'break_chain_on_failure' => true, ], [ 'name' => Moto\Validator\Db\RecordExists::class, 'options' => [ 'table' => Moto\Config::get('database.prefix') . 'fonts', 'field' => 'id', 'adapter' => Moto\System::getDatabaseAdapter(), ], ], ], ]); $this->add([ 'name' => 'variant', 'required' => true, 'filters' => [ ['name' => 'StripTags'], ['name' => 'StringTrim'], ], 'validators' => [ [ 'name' => Zend\Validator\InArray::class, 'options' => [ 'haystack' => [ '100', '100italic', '200', '200italic', '300', '300italic', '400', '400italic', '500', '500italic', '600', '600italic', '700', '700italic', '800', '800italic', '900', '900italic', ], ], ], ], ]); $this->add([ 'name' => 'activate', 'required' => false, 'filters' => [ [ 'name' => 'Boolean', 'options' => [ 'type' => 'all', ] ], ], ]); $targetPath = Moto\System::getAbsolutePath('@tempUploads'); if (!is_dir($targetPath . '/')) { if (is_file($targetPath)) { @unlink($targetPath); } Moto\Util::createNotWebIndexingDir($targetPath); } $targetPath .= '/'; $this->add([ 'name' => 'file', 'type' => Zend\InputFilter\FileInput::class, 'required' => true, 'filters' => [ [ 'name' => Moto\Application\FileManager\Filter\RenameUpload::class, 'options' => [ 'target' => $targetPath, 'overwrite' => false, 'randomize' => true, 'use_upload_name' => false, ], ], ], 'validators' => [ [ 'name' => Zend\Validator\File\UploadFile::class, ], [ 'name' => Zend\Validator\File\Extension::class, 'options' => [ 'extension' => ['woff',], ], ], ], ]); } } 