These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * /classes/DomainMOD/CustomField.php |
||
4 | * |
||
5 | * This file is part of DomainMOD, an open source domain and internet asset manager. |
||
6 | * Copyright (c) 2010-2017 Greg Chetcuti <[email protected]> |
||
7 | * |
||
8 | * Project: http://domainmod.org Author: http://chetcuti.com |
||
9 | * |
||
10 | * DomainMOD is free software: you can redistribute it and/or modify it under the terms of the GNU General Public |
||
11 | * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later |
||
12 | * version. |
||
13 | * |
||
14 | * DomainMOD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
||
15 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
||
16 | * |
||
17 | * You should have received a copy of the GNU General Public License along with DomainMOD. If not, see |
||
18 | * http://www.gnu.org/licenses/. |
||
19 | * |
||
20 | */ |
||
21 | //@formatter:off |
||
22 | namespace DomainMOD; |
||
23 | |||
24 | class CustomField |
||
25 | { |
||
26 | public $system; |
||
27 | |||
28 | public function __construct() |
||
29 | { |
||
30 | $this->system = new System(); |
||
31 | } |
||
32 | |||
33 | public function checkFieldFormat($input_field) |
||
34 | { |
||
35 | if (preg_match('/^[a-zA-Z_]+$/i', $input_field)) { |
||
1 ignored issue
–
show
Coding Style
introduced
by
Loading history...
|
|||
36 | |||
37 | return true; |
||
38 | |||
39 | } else { |
||
40 | |||
41 | return false; |
||
42 | |||
43 | } |
||
44 | } |
||
45 | |||
46 | public function getCustomFields($table_name) |
||
47 | { |
||
48 | $result = $this->queryCustomFields($table_name); |
||
49 | |||
50 | $columns_array = array(); |
||
51 | $count = 0; |
||
52 | |||
53 | if ($result) { |
||
54 | |||
55 | foreach ($result as $row) { |
||
56 | |||
57 | $columns_array[$count++] = $row->field_name; |
||
58 | |||
59 | } |
||
60 | |||
61 | } |
||
62 | |||
63 | return $columns_array; |
||
64 | } |
||
65 | |||
66 | public function queryCustomFields($table_name) |
||
67 | { |
||
68 | return $this->system->db()->query(" |
||
69 | SELECT field_name |
||
70 | FROM " . $table_name . " |
||
71 | ORDER BY `name` ASC")->fetchAll(); |
||
72 | } |
||
73 | |||
74 | public function getCustomFieldsSql($table_name, $column_prefix) |
||
75 | { |
||
76 | $result = $this->queryCustomFields($table_name); |
||
77 | |||
78 | $columns = ''; |
||
79 | |||
80 | if ($result) { |
||
81 | |||
82 | foreach ($result as $row) { |
||
83 | |||
84 | $columns .= ", " . $column_prefix . "." . $row->field_name; |
||
85 | |||
86 | } |
||
87 | |||
88 | } |
||
89 | |||
90 | return $columns; |
||
91 | } |
||
92 | |||
93 | } //@formatter:on |
||
94 |