|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @author Pierre-Henry Soria <[email protected]> |
|
4
|
|
|
* @copyright (c) 2012-2018, Pierre-Henry Soria. All Rights Reserved. |
|
5
|
|
|
* @license GNU General Public License; See PH7.LICENSE.txt and PH7.COPYRIGHT.txt in the root directory. |
|
6
|
|
|
* @package PH7 / App / System / Module / Picture / Form |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace PH7; |
|
10
|
|
|
|
|
11
|
|
|
use PH7\Framework\Config\Config; |
|
12
|
|
|
use PH7\Framework\Mvc\Request\Http; |
|
13
|
|
|
use PH7\Framework\Session\Session; |
|
14
|
|
|
use PH7\Framework\Url\Header; |
|
15
|
|
|
|
|
16
|
|
|
class EditAlbumForm |
|
17
|
|
|
{ |
|
18
|
|
|
public static function display() |
|
|
|
|
|
|
19
|
|
|
{ |
|
20
|
|
|
if (isset($_POST['submit_edit_picture_album'])) { |
|
21
|
|
|
if (\PFBC\Form::isValid($_POST['submit_edit_picture_album'])) { |
|
22
|
|
|
new EditAlbumFormProcess(); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
Header::redirect(); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
$oAlbum = (new PictureModel)->album( |
|
29
|
|
|
(new Session)->get('member_id'), |
|
30
|
|
|
(new Http)->get('album_id'), |
|
31
|
|
|
'1', |
|
32
|
|
|
0, |
|
33
|
|
|
1 |
|
34
|
|
|
); |
|
35
|
|
|
$sTitlePattern = Config::getInstance()->values['module.setting']['url_title.pattern']; |
|
36
|
|
|
|
|
37
|
|
|
$oForm = new \PFBC\Form('form_edit_picture_album'); |
|
38
|
|
|
$oForm->configure(array('action' => '')); |
|
39
|
|
|
$oForm->addElement(new \PFBC\Element\Hidden('submit_edit_picture_album', 'form_edit_picture_album')); |
|
40
|
|
|
$oForm->addElement(new \PFBC\Element\Token('edit_album')); |
|
41
|
|
|
$oForm->addElement(new \PFBC\Element\Textbox(t('Album Cover Name:'), 'name', array('value' => $oAlbum->name, 'required' => 1, 'pattern' => $sTitlePattern, 'validation' => new \PFBC\Validation\RegExp($sTitlePattern)))); |
|
42
|
|
|
$oForm->addElement(new \PFBC\Element\Textarea(t('Album Cover Description:'), 'description', array('value' => $oAlbum->description, 'validation' => new \PFBC\Validation\Str(2, 200)))); |
|
43
|
|
|
$oForm->addElement(new \PFBC\Element\Button); |
|
44
|
|
|
$oForm->render(); |
|
45
|
|
|
} |
|
46
|
|
|
} |
|
47
|
|
|
|
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: