]>
git.agnieray.net Git - galette.git/blob - galette/lib/Galette/DynamicFields/File.php
3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
10 * Copyright © 2013-2014 The Galette Team
12 * This file is part of Galette (http://galette.tuxfamily.org).
14 * Galette is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
19 * Galette is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with Galette. If not, see <http://www.gnu.org/licenses/>.
27 * @category DynamicFields
30 * @author Guillaume Rousse <guillomovitch@gmail.com>
31 * @copyright 2013-2014 The Galette Team
32 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
33 * @link http://galette.tuxfamily.org
34 * @since Available since 0.8 - 2013-07-27
37 namespace Galette\DynamicFields
;
46 * @category DynamicFields
49 * @author Guillaume Rousse <guillomovitch@gmail.com>
50 * @copyright 2013-2014 The Galette Team
51 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
52 * @link http://galette.tuxfamily.org
55 class File
extends DynamicField
60 * @param Db $zdb Database instance
61 * @param int $id Optional field id to load data
63 public function __construct(Db
$zdb, $id = null)
65 parent
::__construct($zdb, $id);
66 $this->has_data
= true;
67 $this->has_size
= true;
75 public function getType(): int
81 * Get file name on disk
83 * @param int $id Object (member, contribution, ...) ID
84 * @param int $pos Position in the list of values (0-based)
85 * @param string|null $prefix Forced file prefix; if null (defaults) form_name wil be used verbatim
89 public function getFileName(int $id, int $pos, string $prefix = null): string
91 $form_name = $this->form
;
92 if ($form_name === 'adh') {
93 $form_name = 'member'; //fix expected filename
96 $filename = str_replace(
104 $prefix ??
$form_name,
109 '%form_%oid_field_%fid_value_%pos'