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 PressContactForm 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 Element::CHILDREN => array
28 (
29 'gender' => new Element
30 (
31 Element::TYPE_RADIO_GROUP, array
32 (
33 self::LABEL => 'Gender',
34 Element::OPTIONS => array('salutation.misses', 'salutation.miss', 'salutation.mister'),
35 Element::REQUIRED => true
36 )
37 ),
38
39 'lastname' => new Text
40 (
41 array
42 (
43 self::LABEL => 'Lastname',
44 Element::REQUIRED => true
45 )
46 ),
47
48 'firstname' => new Text
49 (
50 array
51 (
52 self::LABEL => 'Firstname',
53 Element::REQUIRED => true
54 )
55 ),
56
57 'media' => new Text
58 (
59 array
60 (
61 self::LABEL => 'Média'
62 )
63 ),
64
65 'email' => new Text
66 (
67 array
68 (
69 self::LABEL => 'E-Mail',
70 Element::REQUIRED => true,
71 Element::VALIDATOR => array('Brickrouge\Form::validate_email')
72 )
73 ),
74
75 'subject' => new Text
76 (
77 array
78 (
79 self::LABEL => 'Subject',
80 Element::REQUIRED => true
81 )
82 ),
83
84 'message' => new Element
85 (
86 'textarea', array
87 (
88 self::LABEL => 'Your message'
89 )
90 )
91 )
92 )
93 )
94 );
95 }
96
97 static public function get_defaults()
98 {
99 global $core;
100
101 return array
102 (
103 'notify_destination' => $core->user->email,
104 'notify_bcc' => $core->user->email,
105 'notify_from' => $core->site->email,
106 'notify_subject' => 'Formulaire de contact presse',
107 'notify_template' => <<<EOT
108 Un message a été posté depuis le formulaire de contact presse :
109
110 Nom : #{@gender.index('Mme', 'Mlle', 'M')} #{@lastname} #{@firstname}
111 Média : #{@media.or('N/C')}
112 E-Mail : #{@email}
113
114 Message :
115
116 #{@message}
117 EOT
118 );
119 }
120 }