|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* MikoPBX - free phone system for small business |
|
4
|
|
|
* Copyright (C) 2017-2023 Alexey Portnov and Nikolay Beketov |
|
5
|
|
|
* |
|
6
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
7
|
|
|
* it under the terms of the GNU General Public License as published by |
|
8
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
|
9
|
|
|
* (at your option) any later version. |
|
10
|
|
|
* |
|
11
|
|
|
* This program is distributed in the hope that it will be useful, |
|
12
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14
|
|
|
* GNU General Public License for more details. |
|
15
|
|
|
* |
|
16
|
|
|
* You should have received a copy of the GNU General Public License along with this program. |
|
17
|
|
|
* If not, see <https://www.gnu.org/licenses/>. |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
namespace MikoPBX\AdminCabinet\Forms; |
|
21
|
|
|
|
|
22
|
|
|
|
|
23
|
|
|
use MikoPBX\Common\Models\PbxExtensionModules; |
|
24
|
|
|
use MikoPBX\Common\Providers\PBXConfModulesProvider; |
|
25
|
|
|
use MikoPBX\Modules\Config\WebUIConfigInterface; |
|
26
|
|
|
use Phalcon\Forms\Element\TextArea; |
|
27
|
|
|
use Phalcon\Forms\Form; |
|
28
|
|
|
|
|
29
|
|
|
abstract class BaseForm extends Form |
|
30
|
|
|
{ |
|
31
|
|
|
|
|
32
|
|
|
public function initialize($entity = null, $options = null): void |
|
33
|
|
|
{ |
|
34
|
|
|
PBXConfModulesProvider::hookModulesMethod(WebUIConfigInterface::ON_BEFORE_FORM_INITIALIZE, [$this, $entity, $options]); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Add a textarea form element. |
|
39
|
|
|
* |
|
40
|
|
|
* @param string $areaName The name of the textarea field. |
|
41
|
|
|
* @param string $areaValue The initial value for the textarea field. |
|
42
|
|
|
* @param int $areaWidth The width of the textarea field in columns (optional, default: 85). |
|
43
|
|
|
* |
|
44
|
|
|
* @return void |
|
45
|
|
|
*/ |
|
46
|
|
|
public function addTextArea(string $areaName, string $areaValue, int $areaWidth = 85): void |
|
|
|
|
|
|
47
|
|
|
{ |
|
48
|
|
|
$rows = 1; |
|
49
|
|
|
$strings = explode("\n", $areaValue); |
|
50
|
|
|
foreach ($strings as $string) { |
|
51
|
|
|
$rows += ceil(strlen($string) / 65); |
|
52
|
|
|
} |
|
53
|
|
|
$this->add(new TextArea($areaName, |
|
54
|
|
|
[ |
|
55
|
|
|
"rows" => max($rows, 2), |
|
56
|
|
|
"value" => $areaValue |
|
57
|
|
|
]) |
|
58
|
|
|
); |
|
59
|
|
|
|
|
60
|
|
|
} |
|
61
|
|
|
} |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.