43 $a_str = htmlspecialchars($a_str);
47 $a_str = str_replace(
"{",
"{", $a_str);
48 $a_str = str_replace(
"}",
"}", $a_str);
64 $lng = $DIC->language();
72 $diff = $to->diff($from);
75 $periods[
"years"] = $diff->format(
"%y");
76 $periods[
"months"] = $diff->format(
"%m");
77 $periods[
"days"] = $diff->format(
"%d");
78 $periods[
"hours"] = $diff->format(
"%h");
79 $periods[
"minutes"] = $diff->format(
"%i");
80 $periods[
"seconds"] = $diff->format(
"%s");
82 if (!array_sum($periods)) {
86 foreach ($periods as
$key => $value) {
88 $segment_name = ($value > 1)
90 : substr(
$key, 0, -1);
91 $array[] = $value .
' ' .
$lng->txt($segment_name);
95 if ($len = count($array) > 3) {
96 $array = array_slice($array, 0, (3 - $len));
99 return implode(
', ', $array);
112 bool $prepare_for_latex_output =
false,
113 bool $omitNl2BrWhenTextArea =
false 115 $result = $txt_output;
120 if (!$omitNl2BrWhenTextArea) {
122 $result = preg_replace(
"/[\n]/",
"<br />", $result);
126 if (preg_match_all(
"/(<pre>.*?<\/pre>)/ims", $result, $matches)) {
127 foreach ($matches[0] as $found) {
129 if (strpos(
"\n", $found) ===
false) {
132 $removed = preg_replace(
"/<br\s*?\/>/ims", $replacement, $found);
133 $result = str_replace($found, $removed, $result);
140 if ($prepare_for_latex_output) {
145 if ($prepare_for_latex_output) {
148 $result = str_replace(
"{",
"{", $result);
149 $result = str_replace(
"}",
"}", $result);
150 $result = str_replace(
"\\",
"\", $result);
177 bool $a_use_default =
true,
178 array $a_further_options = []
182 $lng = $DIC->language();
187 if (count($a_further_options)) {
188 if (isset($a_further_options[
'minute_steps'])) {
189 $minute_steps = $a_further_options[
'minute_steps'];
191 if (isset($a_further_options[
'disabled']) and $a_further_options[
'disabled']) {
192 $disabled =
'disabled="disabled" ';
196 if ($a_use_default and !strlen(
"$hour$minute$second")) {
204 $sel_hour =
'<select ';
205 if (isset($a_further_options[
'select_attributes'])) {
206 foreach ($a_further_options[
'select_attributes'] as
$name => $value) {
207 $sel_hour .=
$name .
'=' . $value .
' ';
210 $sel_hour .=
" " . $disabled .
"name=\"" . $prefix .
"[h]\" id=\"" . $prefix .
"_h\" class=\"form-control\">\n";
213 for (
$i = 0;
$i <= 23;
$i++) {
215 $sel_hour .=
"<option value=\"$i\">" . sprintf(
"%02d",
$i) .
"</option>\n";
217 $sel_hour .=
"<option value=\"$i\">" . date(
"ga", mktime(
$i, 0, 0)) .
"</option>\n";
220 $sel_hour .=
"</select>\n";
221 $sel_hour = preg_replace(
"/(value\=\"$hour\")/",
"$1 selected=\"selected\"", $sel_hour);
224 $sel_minute =
"<select " . $disabled .
"name=\"" . $prefix .
"[m]\" id=\"" . $prefix .
"_m\" class=\"form-control\">\n";
226 for (
$i = 0;
$i <= 59;
$i =
$i + $minute_steps) {
227 $sel_minute .=
"<option value=\"$i\">" . sprintf(
"%02d",
$i) .
"</option>\n";
229 $sel_minute .=
"</select>\n";
230 $sel_minute = preg_replace(
"/(value\=\"$minute\")/",
"$1 selected=\"selected\"", $sel_minute);
234 $sel_second =
"<select " . $disabled .
"name=\"" . $prefix .
"[s]\" id=\"" . $prefix .
"_s\" class=\"form-control\">\n";
236 for (
$i = 0;
$i <= 59;
$i++) {
237 $sel_second .=
"<option value=\"$i\">" . sprintf(
"%02d",
$i) .
"</option>\n";
239 $sel_second .=
"</select>\n";
240 $sel_second = preg_replace(
"/(value\=\"$second\")/",
"$1 selected=\"selected\"", $sel_second);
242 $timeformat = (
$lng->text[
"lang_timeformat"] ??
'');
243 if (strlen($timeformat) == 0) {
244 $timeformat =
"H:i:s";
246 $timeformat = strtolower(preg_replace(
"/\W/",
"", $timeformat));
247 $timeformat = preg_replace(
"/(\w)/",
"%%$1", $timeformat);
248 $timeformat = preg_replace(
"/%%h/", $sel_hour, $timeformat);
249 $timeformat = preg_replace(
"/%%i/", $sel_minute, $timeformat);
251 $timeformat = preg_replace(
"/%%s/",
"", $timeformat);
253 $timeformat = preg_replace(
"/%%s/", $sel_second, $timeformat);
265 bool $disabled =
false 267 $str =
"<input type=\"checkbox\" name=\"" . $varname .
"\"";
269 if ($checked ===
true) {
270 $str .=
" checked=\"checked\"";
273 if ($disabled ===
true) {
274 $str .=
" disabled=\"disabled\"";
279 if (substr($varname, -2) ==
"[]") {
285 $varname_id = substr($varname, 0, -2) .
"_" . $value;
287 $varname_id = $varname;
291 $varname_id = str_replace(
"[",
"_", $varname_id);
292 $varname_id = str_replace(
"]",
"", $varname_id);
294 $str .=
" value=\"" . $value .
"\" id=\"" . $varname_id .
"\" />\n";
320 bool $multiple =
false,
321 bool $direct_text =
false,
323 string $style_class =
"",
325 bool $disabled =
false 329 $lng = $DIC->language();
331 if ($multiple ==
true) {
332 $multiple =
" multiple=\"multiple\"";
338 $class =
" class=\" form-control " . $style_class .
"\"";
345 if (is_array($attribs)) {
346 foreach ($attribs as
$key => $val) {
351 $disabled =
' disabled=\"disabled\"';
356 $size_str =
' size="' . $size .
'" ';
358 $str =
"<select name=\"" . $varname .
"\"" . $multiple .
" $class " . $size_str .
" $attributes $disabled>\n";
360 foreach ($options as
$key => $val) {
362 if (is_array($val)) {
363 $style = $val[
"style"];
367 $sty = ($style !=
"")
368 ?
' style="' . $style .
'" ' 372 $str .=
" <option $sty value=\"" .
$key .
"\"";
374 $str .=
" <option $sty value=\"" . $val .
"\"";
376 if (is_array($selected)) {
377 if (in_array(
$key, $selected)) {
378 $str .=
" selected=\"selected\"";
380 } elseif ($selected ==
$key) {
381 $str .=
" selected=\"selected\"";
385 $str .=
">" . $val .
"</option>\n";
387 $str .=
">" .
$lng->txt($val) .
"</option>\n";
391 $str .=
"</select>\n";
403 string $onclick = null,
404 bool $disabled =
false 408 if ($onclick !== null) {
409 $str .= (
'onclick="' . $onclick .
'"');
412 $str .= (
" type=\"radio\" name=\"" . $varname .
"\"");
413 if ($checked ===
true) {
414 $str .=
" checked=\"checked\"";
417 if ($disabled ===
true) {
418 $str .=
" disabled=\"disabled\"";
421 $str .=
" value=\"" . $value .
"\"";
423 $str .=
" id=\"" . $value .
"\" />\n";
get(int $a_format, string $a_format_str='', string $a_tz='')
get formatted date
static isHTML(string $a_text)
Checks if a given string contains HTML or not.
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static getInstance()
Singleton: get instance for use in ILIAS requests with a config loaded from the settings.