1
|
|
|
<?php |
2
|
|
|
//------------------------------------------------------------------------- |
3
|
|
|
// OVIDENTIA http://www.ovidentia.org |
4
|
|
|
// Ovidentia is free software; you can redistribute it and/or modify |
5
|
|
|
// it under the terms of the GNU General Public License as published by |
6
|
|
|
// the Free Software Foundation; either version 2, or (at your option) |
7
|
|
|
// any later version. |
8
|
|
|
// |
9
|
|
|
// This program is distributed in the hope that it will be useful, but |
10
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of |
11
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
12
|
|
|
// See the GNU General Public License for more details. |
13
|
|
|
// |
14
|
|
|
// You should have received a copy of the GNU General Public License |
15
|
|
|
// along with this program; if not, write to the Free Software |
16
|
|
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
17
|
|
|
// USA. |
18
|
|
|
//------------------------------------------------------------------------- |
19
|
|
|
/** |
20
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL) |
21
|
|
|
* @copyright Copyright (c) 2009 by CANTICO ({@link http://www.cantico.fr}) |
22
|
|
|
*/ |
23
|
|
|
|
24
|
|
|
if (!class_exists('Widget_Action')) { |
25
|
|
|
bab_widgets()->includePhpClass('Widget_Action'); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
|
29
|
|
|
require_once $GLOBALS['babInstallPath'].'utilit/urlincl.php'; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Translates the string. |
33
|
|
|
* |
34
|
|
|
* @param string $str |
35
|
|
|
* @return string |
36
|
|
|
*/ |
37
|
|
|
function app_translate($str) |
38
|
|
|
{ |
39
|
|
|
$translation = bab_translate($str, 'LibApp'); |
40
|
|
|
|
41
|
|
|
return $translation; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Translates all the string in an array and returns a new array. |
46
|
|
|
* |
47
|
|
|
* @param array $arr |
48
|
|
|
* @return array |
49
|
|
|
*/ |
50
|
|
|
function app_translateArray($arr) |
51
|
|
|
{ |
52
|
|
|
$newarr = $arr; |
53
|
|
|
|
54
|
|
|
foreach ($newarr as &$str) { |
55
|
|
|
$str = app_translate($str); |
56
|
|
|
} |
57
|
|
|
return $newarr; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
|
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Instanciates the App factory. |
64
|
|
|
* |
65
|
|
|
* @return Func_App |
66
|
|
|
*/ |
67
|
|
|
function app_App() |
68
|
|
|
{ |
69
|
|
|
return bab_functionality::get('App'); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Instanciates the Newsletter factory. |
75
|
|
|
* |
76
|
|
|
* @return Func_Newsletter |
77
|
|
|
*/ |
78
|
|
|
/*function app_Newsletter() |
79
|
|
|
{ |
80
|
|
|
return bab_functionality::get('Newsletter'); |
81
|
|
|
}*/ |
82
|
|
|
|
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Instanciates the MailingList factory. |
86
|
|
|
* |
87
|
|
|
* @return Func_MailingList |
|
|
|
|
88
|
|
|
*/ |
89
|
|
|
function app_MailingList() |
90
|
|
|
{ |
91
|
|
|
return bab_functionality::getOriginal('MailingList'); |
|
|
|
|
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
|
95
|
|
|
|
96
|
|
|
function app_addPageInfo($message) |
97
|
|
|
{ |
98
|
|
|
$_SESSION['app_msginfo'][] = $message; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Redirects to the specified url or action. |
104
|
|
|
* This function makes the current script die. |
105
|
|
|
* |
106
|
|
|
* @param Widget_Action|string $url |
107
|
|
|
*/ |
108
|
|
|
function app_redirect($url, $message = null) |
109
|
|
|
{ |
110
|
|
|
global $babBody; |
111
|
|
|
|
112
|
|
|
if (null === $url) { |
|
|
|
|
113
|
|
|
$script = '<script type="text/javascript">'; |
114
|
|
|
if (isset($message)) { |
115
|
|
|
$script .= 'alert("' . bab_toHtml($message, BAB_HTML_JS) . '");'; |
116
|
|
|
} |
117
|
|
|
$script .= 'history.back();'; |
118
|
|
|
$script .= '</script>'; |
119
|
|
|
|
120
|
|
|
die($script); |
|
|
|
|
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
if ($url instanceof Widget_Action) { |
|
|
|
|
124
|
|
|
$url = $url->url(); |
125
|
|
|
} |
126
|
|
|
if (!empty($babBody->msgerror)) { |
127
|
|
|
$url .= '&msgerror=' . urlencode($babBody->msgerror); |
128
|
|
|
} |
129
|
|
|
if (isset($message)) { |
130
|
|
|
$lines = explode("\n", $message); |
131
|
|
|
foreach ($lines as $line) { |
132
|
|
|
app_addPageInfo($line); |
133
|
|
|
} |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
header('Location: ' . $url); |
137
|
|
|
die; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
|
141
|
|
|
|
142
|
|
|
|
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* create or validate a rewriten name |
146
|
|
|
* @param string $name |
147
|
|
|
*/ |
148
|
|
|
function app_getRewriteName($rewriteName) |
149
|
|
|
{ |
150
|
|
|
$rewriteName = bab_removeDiacritics($rewriteName); |
151
|
|
|
$rewriteName = strtolower($rewriteName); |
152
|
|
|
$rewriteName = str_replace(array(' ', '/'), '-', $rewriteName); |
153
|
|
|
$rewriteName = preg_replace('/[^-0-9A-Za-z]/', '', $rewriteName); |
154
|
|
|
$rewriteName = preg_replace('/[-]+/', '-', $rewriteName); |
155
|
|
|
$rewriteName = trim($rewriteName, '- '); |
156
|
|
|
|
157
|
|
|
return $rewriteName; |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
|
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* Upload file error to string |
164
|
|
|
* @return string |
165
|
|
|
*/ |
166
|
|
|
function app_fileUploadError($error) |
167
|
|
|
{ |
168
|
|
|
switch($error) { |
169
|
|
|
case UPLOAD_ERR_OK: |
170
|
|
|
return null; |
171
|
|
|
|
172
|
|
|
case UPLOAD_ERR_INI_SIZE: |
173
|
|
|
return app_translate('The uploaded file exceeds the upload_max_filesize directive.'); |
174
|
|
|
|
175
|
|
|
case UPLOAD_ERR_FORM_SIZE: |
176
|
|
|
return app_translate('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.'); |
177
|
|
|
|
178
|
|
|
case UPLOAD_ERR_PARTIAL: |
179
|
|
|
return app_translate('The uploaded file was only partially uploaded.'); |
180
|
|
|
|
181
|
|
|
case UPLOAD_ERR_NO_FILE: |
182
|
|
|
return app_translate('No file was uploaded.'); |
183
|
|
|
|
184
|
|
|
case UPLOAD_ERR_NO_TMP_DIR: // since PHP 4.3.10 and PHP 5.0.3 |
185
|
|
|
return app_translate('Missing a temporary folder.'); |
186
|
|
|
|
187
|
|
|
case UPLOAD_ERR_CANT_WRITE: // since php 5.1.0 |
188
|
|
|
return app_translate('Failed to write file to disk.'); |
189
|
|
|
|
190
|
|
|
default : |
191
|
|
|
return app_translate('Unknown File Error.'); |
192
|
|
|
} |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
|
196
|
|
|
|
197
|
|
|
|
198
|
|
|
|
199
|
|
|
/** |
200
|
|
|
* Fix datetime submited from a separated datePicker and timePicker |
201
|
|
|
* @param array $dateTime |
202
|
|
|
* @param bool $ignoreTime |
203
|
|
|
* |
204
|
|
|
* @return string |
205
|
|
|
*/ |
206
|
|
|
function app_fixDateTime(Array $dateTime, $ignoreTime) |
207
|
|
|
{ |
208
|
|
|
$W = app_Widgets(); |
|
|
|
|
209
|
|
|
$date = $W->DatePicker()->getISODate($dateTime['date']); |
210
|
|
|
|
211
|
|
|
if (!$date || '0000-00-00' === $date) { |
212
|
|
|
return '0000-00-00 00:00:00'; |
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
$hour = $dateTime['time']; |
216
|
|
|
|
217
|
|
|
if (5 === mb_strlen($hour)) { |
218
|
|
|
$hour .= ':00'; |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
if ($ignoreTime || empty($hour) || 8 !== mb_strlen($hour)) { |
222
|
|
|
$hour = '00:00:00'; |
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
return $date.' '.$hour; |
226
|
|
|
} |
227
|
|
|
|
228
|
|
|
|
229
|
|
|
|
230
|
|
|
/** |
231
|
|
|
* @param mixed $value |
232
|
|
|
* @return string |
233
|
|
|
* @deprecated Use bab_json_encode() |
234
|
|
|
*/ |
235
|
|
|
function app_json_encode($a) |
236
|
|
|
{ |
237
|
|
|
return bab_json_encode($a); |
238
|
|
|
} |
239
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths