1 <?php
2
3 /*
4 * This file is part of the Icybee package.
5 *
6 * (c) Olivier Laviale <olivier.laviale@gmail.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Icybee\Modules\Forms;
13
14 use Brickrouge\Element;
15 use Brickrouge\Text;
16
17 class QuickContactForm extends \Brickrouge\Form
18 {
19 public function __construct($tags, $dummy=null)
20 {
21 parent::__construct
22 (
23 \ICanBoogie\array_merge_recursive
24 (
25 $tags, array
26 (
27 self::RENDERER => 'Simple',
28
29 Element::CHILDREN => array
30 (
31 'email' => new Text
32 (
33 array
34 (
35 Element::LABEL => 'Votre e-mail',
36 Element::REQUIRED => true,
37 Element::VALIDATOR => array('Brickrouge\Form::validate_email')
38 )
39 ),
40
41 'message' => new Element
42 (
43 'textarea', array
44 (
45 self::LABEL_MISSING => 'Message',
46 Element::REQUIRED => true
47 )
48 )
49 )
50 )
51 )
52 );
53 }
54
55 static public function getConfig() // TODO-20120304: refactor this
56 {
57 global $core;
58
59 $email = $core->user->email;
60
61 return array
62 (
63 Element::CHILDREN => array
64 (
65 'config[destination]' => new Text
66 (
67 array
68 (
69 self::LABEL => 'Addresse de destination',
70 Element::GROUP => 'config',
71 Element::DEFAULT_VALUE => $email
72 )
73 ),
74
75 'config' => new \WdEMailNotifyElement
76 (
77 array
78 (
79 self::LABEL => 'Paramètres du message électronique',
80 Element::GROUP => 'config',
81 Element::DEFAULT_VALUE => array
82 (
83 'from' => "Contact <{$core->site->email}>",
84 'subject' => 'Formulaire de contact',
85 'template' => <<<EOT
86 Un message a été posté depuis le formulaire de contact :
87
88 E-Mail : #{@email}
89
90 #{@message}
91 EOT
92 )
93 )
94 )
95 )
96 );
97 }
98 }