42 $a_str = htmlspecialchars((
string) $a_str);
46 $a_str = str_replace(
"{",
"{", $a_str);
47 $a_str = str_replace(
"}",
"}", $a_str);
63 $lng = $DIC->language();
71 $diff = $to->diff($from);
74 $periods[
"years"] = $diff->format(
"%y");
75 $periods[
"months"] = $diff->format(
"%m");
76 $periods[
"days"] = $diff->format(
"%d");
77 $periods[
"hours"] = $diff->format(
"%h");
78 $periods[
"minutes"] = $diff->format(
"%i");
79 $periods[
"seconds"] = $diff->format(
"%s");
81 if (!array_sum($periods)) {
85 foreach ($periods as $key => $value) {
87 $segment_name = ($value > 1)
89 : substr($key, 0, -1);
90 $array[] = $value .
' ' .
$lng->txt($segment_name);
94 if ($len = count($array) > 3) {
95 $array = array_slice($array, 0, (3 - $len));
98 return implode(
', ', $array);
111 bool $prepare_for_latex_output =
false,
112 bool $omitNl2BrWhenTextArea =
false 114 $result = $txt_output;
119 if (!$omitNl2BrWhenTextArea) {
121 $result = preg_replace(
"/[\n]/",
"<br />", $result);
125 if (preg_match_all(
"/(<pre>.*?<\/pre>)/ims", $result, $matches)) {
126 foreach ($matches[0] as $found) {
128 if (strpos(
"\n", $found) ===
false) {
131 $removed = preg_replace(
"/<br\s*?\/>/ims", $replacement, $found);
132 $result = str_replace($found, $removed, $result);
137 if ($prepare_for_latex_output) {
142 $result = str_replace(
"{",
"{", $result);
143 $result = str_replace(
"}",
"}", $result);
144 $result = str_replace(
"\\",
"\", $result);
171 bool $a_use_default =
true,
172 array $a_further_options = []
176 $lng = $DIC->language();
177 $ilUser = $DIC->user();
181 if (count($a_further_options)) {
182 if (isset($a_further_options[
'minute_steps'])) {
183 $minute_steps = $a_further_options[
'minute_steps'];
185 if (isset($a_further_options[
'disabled']) and $a_further_options[
'disabled']) {
186 $disabled =
'disabled="disabled" ';
190 if ($a_use_default and !strlen(
"$hour$minute$second")) {
198 $sel_hour =
'<select ';
199 if (isset($a_further_options[
'select_attributes'])) {
200 foreach ($a_further_options[
'select_attributes'] as $name => $value) {
201 $sel_hour .= $name .
'=' . $value .
' ';
204 $sel_hour .=
" " . $disabled .
"name=\"" . $prefix .
"[h]\" id=\"" . $prefix .
"_h\" class=\"form-control\">\n";
206 $format = $ilUser->getTimeFormat();
207 for ($i = 0; $i <= 23; $i++) {
209 $sel_hour .=
"<option value=\"$i\">" . sprintf(
"%02d", $i) .
"</option>\n";
211 $sel_hour .=
"<option value=\"$i\">" . date(
"ga", mktime($i, 0, 0)) .
"</option>\n";
214 $sel_hour .=
"</select>\n";
215 $sel_hour = preg_replace(
"/(value\=\"$hour\")/",
"$1 selected=\"selected\"", $sel_hour);
218 $sel_minute =
"<select " . $disabled .
"name=\"" . $prefix .
"[m]\" id=\"" . $prefix .
"_m\" class=\"form-control\">\n";
220 for ($i = 0; $i <= 59; $i = $i + $minute_steps) {
221 $sel_minute .=
"<option value=\"$i\">" . sprintf(
"%02d", $i) .
"</option>\n";
223 $sel_minute .=
"</select>\n";
224 $sel_minute = preg_replace(
"/(value\=\"$minute\")/",
"$1 selected=\"selected\"", $sel_minute);
228 $sel_second =
"<select " . $disabled .
"name=\"" . $prefix .
"[s]\" id=\"" . $prefix .
"_s\" class=\"form-control\">\n";
230 for ($i = 0; $i <= 59; $i++) {
231 $sel_second .=
"<option value=\"$i\">" . sprintf(
"%02d", $i) .
"</option>\n";
233 $sel_second .=
"</select>\n";
234 $sel_second = preg_replace(
"/(value\=\"$second\")/",
"$1 selected=\"selected\"", $sel_second);
236 $timeformat = (
$lng->text[
"lang_timeformat"] ??
'');
237 if (strlen($timeformat) == 0) {
238 $timeformat =
"H:i:s";
240 $timeformat = strtolower(preg_replace(
"/\W/",
"", $timeformat));
241 $timeformat = preg_replace(
"/(\w)/",
"%%$1", $timeformat);
242 $timeformat = preg_replace(
"/%%h/", $sel_hour, $timeformat);
243 $timeformat = preg_replace(
"/%%i/", $sel_minute, $timeformat);
245 $timeformat = preg_replace(
"/%%s/",
"", $timeformat);
247 $timeformat = preg_replace(
"/%%s/", $sel_second, $timeformat);
259 bool $disabled =
false 261 $str =
"<input type=\"checkbox\" name=\"" . $varname .
"\"";
263 if ($checked ===
true) {
264 $str .=
" checked=\"checked\"";
267 if ($disabled ===
true) {
268 $str .=
" disabled=\"disabled\"";
273 if (substr($varname, -2) ==
"[]") {
279 $varname_id = substr($varname, 0, -2) .
"_" . $value;
281 $varname_id = $varname;
285 $varname_id = str_replace(
"[",
"_", $varname_id);
286 $varname_id = str_replace(
"]",
"", $varname_id);
288 $str .=
" value=\"" . $value .
"\" id=\"" . $varname_id .
"\" />\n";
314 bool $multiple =
false,
315 bool $direct_text =
false,
317 string $style_class =
"",
319 bool $disabled =
false 323 $lng = $DIC->language();
325 if ($multiple ==
true) {
326 $multiple =
" multiple=\"multiple\"";
332 $class =
" class=\" form-control " . $style_class .
"\"";
339 if (is_array($attribs)) {
340 foreach ($attribs as $key => $val) {
341 $attributes .=
" " . $key .
"=\"" . $val .
"\"";
345 $disabled =
' disabled=\"disabled\"';
350 $size_str =
' size="' . $size .
'" ';
352 $str =
"<select name=\"" . $varname .
"\"" . $multiple .
" $class " . $size_str .
" $attributes $disabled>\n";
354 foreach ($options as $key => $val) {
356 if (is_array($val)) {
357 $style = $val[
"style"];
361 $sty = ($style !=
"")
362 ?
' style="' . $style .
'" ' 366 $str .=
" <option $sty value=\"" . $key .
"\"";
368 $str .=
" <option $sty value=\"" . $val .
"\"";
370 if (is_array($selected)) {
371 if (in_array($key, $selected)) {
372 $str .=
" selected=\"selected\"";
374 } elseif ($selected == $key) {
375 $str .=
" selected=\"selected\"";
379 $str .=
">" . $val .
"</option>\n";
381 $str .=
">" .
$lng->txt($val) .
"</option>\n";
385 $str .=
"</select>\n";
397 ?
string $onclick =
null,
398 bool $disabled =
false 402 if ($onclick !==
null) {
403 $str .= (
'onclick="' . $onclick .
'"');
406 $str .= (
" type=\"radio\" name=\"" . $varname .
"\"");
407 if ($checked ===
true) {
408 $str .=
" checked=\"checked\"";
411 if ($disabled ===
true) {
412 $str .=
" disabled=\"disabled\"";
415 $str .=
" value=\"" . $value .
"\"";
417 $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 replaceLatexSpan(string $text)
Replace the latex delimiters used by the rich text editor Unfortunately these can't be processed by M...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null