From c7c19c4f6b4827f3cb90547d08a3eac7306af43b Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20CHAZALLET?= Date: Fri, 16 Nov 2012 13:32:06 +0100 Subject: [PATCH] =?utf8?q?Formulaire=20:=20cr=C3=A9ation=20de=20mani=C3=A8re?= =?utf8?q?=20g=C3=A9n=C3=A9rique?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- data/jeu_essai.db | Bin 41984 -> 41984 bytes module/Galerie/src/Galerie/Form/GalerieForm.php | 113 +++++--------------- .../src/Galerie/Form/galerie.form.config.php | 35 ++++++ module/Galerie/src/Galerie/Model/Galerie.php | 66 +----------- .../Model/galerie.defaultinputfilter.config.php | 36 +++++++ 5 files changed, 98 insertions(+), 152 deletions(-) create mode 100644 module/Galerie/src/Galerie/Form/galerie.form.config.php create mode 100644 module/Galerie/src/Galerie/Model/galerie.defaultinputfilter.config.php diff --git a/data/jeu_essai.db b/data/jeu_essai.db index 90fe97561317aab7c476c9b3695881877e6884a8..eb497b3f9d3fce4068c1c529734418ab0d7cd68e 100644 GIT binary patch delta 281 zcmZoT!PIbqX@WGP&O{k!MxBib%gi~pGB9mrPGaWV*tnEQgn4TaBRd15tgEpxqeo_L zVoqXZ;^YH<7F=cuhDKJ#hE|3KlR2$_@G>wkFf-p`VE)Yfl=;?XL4m!@rp%ui_<_PO zz{M=d7;t!HQGO{iFS9&jKw?p1L26z}DiaU0EZk_uO%9AK)HBS3jfG<^1JhdOIA-RJ bjdPhqnKy@WFhYF82)7i?Kbx8S|Ahbm$UaAX delta 279 zcmZoT!PIbqX@WGP_Cy(HM(vFW%gi}8GcavtPGaWV*tnEQB!rQjfl<-b*qG5HGdD3O zu`*FXfARr83ocUyLqjVA3o8?&$(+_dc$q&lFf*TKU_QXI94+-t!9p6X5QF1 Xmq|37gAw8vMkJS^`DQbd|Gy9bMS(`y diff --git a/module/Galerie/src/Galerie/Form/GalerieForm.php b/module/Galerie/src/Galerie/Form/GalerieForm.php index 4e3749b..a5fbcea 100644 --- a/module/Galerie/src/Galerie/Form/GalerieForm.php +++ b/module/Galerie/src/Galerie/Form/GalerieForm.php @@ -2,103 +2,38 @@ namespace Galerie\Form; -use Zend\Form\Form; +use Custom\Form\AbstractForm; -use Zend\I18n\Translator\TranslatorAwareInterface; -use Zend\I18n\Translator\Translator; - -class GalerieForm extends Form implements TranslatorAwareInterface +class GalerieForm extends AbstractForm { - private $_translator; - private $_textDomain = 'galerie'; - private $_translator_enabled = true; - - public function initialize() { - $this->setAttribute('method', 'post'); - $this->add(array( - 'name' => 'id', - 'attributes' => array( - 'type' => 'hidden', - ), - )); - $this->add(array( - 'name' => 'name', - 'attributes' => array( - 'type' => 'text', - ), - 'options' => array( - 'label' => $this->translate('Galerie_form_label_name'), - ) - )); - $this->add(array( - 'name' => 'description', - 'attributes' => array( - 'type' => 'text', - ), - 'options' => array( - 'label' => $this->translate('Galerie_form_label_description'), - ) - )); - $this->add(array( - 'name' => 'submit', - 'attributes' => array( - 'type' => 'submit', + $elements = include __DIR__ . '/galerie.form.config.php'; + $this->addElements($elements); + /* Méthode alternative + $this->setMethod('post'); + $this->addElement('id', 'hidden'); + $this->addElement( + 'name', + 'text', + $this->translate('Galerie_form_label_name') + ); + $this->addElement( + 'description', + 'text', + $this->translate('Galerie_form_label_description') + ); + $this->addElement( + 'submit', + 'submit', + null, + array( 'value' => 'Valider', 'id' => 'submit_galerie_form', - ), - )); - } - - - - - public function translate($k) - { - if ($this->_translator && $this->_translator_enabled) { - return $this->_translator->translate($k, $this->_textDomain); - } - return $k . '(Non traduit)'; - } - - - public function setTranslator(Translator $translator = null, $textDomain = null) - { - $this->_translator = $translator; - $this->_textDomain = $textDomain; - } - - public function getTranslator() - { - return $this->_translator; - } - - public function hasTranslator() - { - return $this->_translator !== null; - } - - public function setTranslatorEnabled($enabled = true) - { - $this->_translator_enabled = $enabed; - } - - public function isTranslatorEnabled() - { - return $this->_translator_enabled; - } - - public function setTranslatorTextDomain($textDomain = 'default') - { - $this->_textDomain = $textDomain; - } - - public function getTranslatorTextDomain() - { - return $this->_textDomain; + ) + );*/ } } diff --git a/module/Galerie/src/Galerie/Form/galerie.form.config.php b/module/Galerie/src/Galerie/Form/galerie.form.config.php new file mode 100644 index 0000000..bb2c8c7 --- /dev/null +++ b/module/Galerie/src/Galerie/Form/galerie.form.config.php @@ -0,0 +1,35 @@ + 'id', + 'attributes' => array( + 'type' => 'hidden', + ), + ), + array( + 'name' => 'name', + 'attributes' => array( + 'type' => 'text', + ), + 'options' => array( + 'label' => $this->translate('Galerie_form_label_name'), + ), + ), + array( + 'name' => 'description', + 'attributes' => array( + 'type' => 'text', + ), + 'options' => array( + 'label' => $this->translate('Galerie_form_label_description'), + ), + ), + array( + 'name' => 'submit', + 'attributes' => array( + 'type' => 'submit', + 'value' => 'Valider', + 'id' => 'submit_galerie_form', + ), + ), +); diff --git a/module/Galerie/src/Galerie/Model/Galerie.php b/module/Galerie/src/Galerie/Model/Galerie.php index 6b46e20..acb3e7b 100644 --- a/module/Galerie/src/Galerie/Model/Galerie.php +++ b/module/Galerie/src/Galerie/Model/Galerie.php @@ -2,14 +2,9 @@ namespace Galerie\Model; -use Zend\InputFilter\Factory as InputFactory; -use Zend\InputFilter\InputFilter; -use Zend\InputFilter\InputFilterInterface; -use Zend\InputFilter\InputFilterAwareInterface; - use Custom\Model\Entity; -class Galerie extends Entity implements InputFilterAwareInterface +class Galerie extends Entity { public $id; public $id_user; @@ -18,8 +13,6 @@ class Galerie extends Entity implements InputFilterAwareInterface public $created; public $updated; - protected $inputFilter; - protected $columns = array( 'id', @@ -40,63 +33,10 @@ class Galerie extends Entity implements InputFilterAwareInterface 'id', ); - public function getArrayCopy() - { - return $this->toArray(); - } - - public function setInputFilter(InputFilterInterface $inputfilter) - { - throw new \Exception("This entity does not allow to set Input Filter"); - } - public function getInputFilter() + public function getDefaultInputFilterArrays() { - if (!$this->inputFilter) { - $inputFilter = new InputFilter; - $factory = new InputFactory; - - $inputFilter->add($factory->createInput(array( - 'name' => 'id', - 'required' => true, - 'filters' => array( - array('name' => 'Int'), - ), - ))); - - $inputFilter->add($factory->createInput(array( - 'name' => 'name', - 'required' => true, - 'filters' => array( - array('name' => 'StripTags'), - array('name' => 'StringTrim'), - ), - 'validators' => array( - array( - 'name' => 'StringLength', - 'options' => array( - 'encoding' => 'UTF-8', - 'min' => 1, - 'max' => 32, - ), - ), - ), - ))); - - $inputFilter->add($factory->createInput(array( - 'name' => 'description', - 'required' => true, - 'filters' => array( - array('name' => 'StripTags'), - array('name' => 'StringTrim'), - ), - ))); - - $this->inputFilter = $inputFilter; - } - - return $this->inputFilter; - + return include __DIR__ . '/galerie.defaultinputfilter.config.php'; } } diff --git a/module/Galerie/src/Galerie/Model/galerie.defaultinputfilter.config.php b/module/Galerie/src/Galerie/Model/galerie.defaultinputfilter.config.php new file mode 100644 index 0000000..923a577 --- /dev/null +++ b/module/Galerie/src/Galerie/Model/galerie.defaultinputfilter.config.php @@ -0,0 +1,36 @@ + 'id', + 'required' => true, + 'filters' => array( + array('name' => 'Int'), + ), + ), + array( + 'name' => 'name', + 'required' => true, + 'filters' => array( + array('name' => 'StripTags'), + array('name' => 'StringTrim'), + ), + 'validators' => array( + array( + 'name' => 'StringLength', + 'options' => array( + 'encoding' => 'UTF-8', + 'min' => 1, + 'max' => 32, + ), + ), + ), + ), + array( + 'name' => 'description', + 'required' => true, + 'filters' => array( + array('name' => 'StripTags'), + array('name' => 'StringTrim'), + ), + ) + ); -- 1.7.10.4