ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ilLegacyFormElementsUtil Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilLegacyFormElementsUtil:

Static Public Member Functions

static prepareFormOutput ($a_str, bool $a_strip=false)
 
static period2String (ilDateTime $a_from, $a_to=null)
 Return a string of time period. More...
 
static prepareTextareaOutput (string $txt_output, bool $prepare_for_latex_output=false, bool $omitNl2BrWhenTextArea=false)
 Prepares a string for a text area output where latex code may be in it If the text is HTML-free, CHR(13) will be converted to a line break. More...
 
static makeTimeSelect (string $prefix, bool $short=true, int $hour=0, int $minute=0, int $second=0, bool $a_use_default=true, array $a_further_options=[])
 Creates a combination of HTML selects for time inputs. More...
 
static formCheckbox (bool $checked, string $varname, string $value, bool $disabled=false)
 
static formSelect ( $selected, string $varname, array $options, bool $multiple=false, bool $direct_text=false, int $size=0, string $style_class="", array $attribs=[], bool $disabled=false)
 Builds a select form field with options and shows the selected option first. More...
 
static formRadioButton (bool $checked, string $varname, string $value, ?string $onclick=null, bool $disabled=false)
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Util class various functions, usage as namespace

Author
Sascha Hofmann sasch.nosp@m.ahof.nosp@m.mann@.nosp@m.gmx..nosp@m.de
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e

grown helper class with many different UseCases and functions. The class is not under direct maintainership and the responsibilities are unclear. In this context, the class should no longer be used in the code and existing uses should be converted to their own service in the medium term. If you need ilUtil for the implementation of a new function in ILIAS > 7, please contact the Technical Board.

Definition at line 31 of file class.ilLegacyFormElementsUtil.php.

Member Function Documentation

◆ formCheckbox()

static ilLegacyFormElementsUtil::formCheckbox ( bool  $checked,
string  $varname,
string  $value,
bool  $disabled = false 
)
static
Deprecated:

Definition at line 255 of file class.ilLegacyFormElementsUtil.php.

Referenced by ilMailSearchGUI\appendRecipientSelection(), ilLocalUserGUI\assignRoles(), ilECSNodeMappingCmsExplorer\buildFormItem(), ilPasteIntoMultipleItemsExplorer\buildFormItem(), ilECSNodeMappingLocalExplorer\buildFormItem(), ilTestPersonalDefaultSettingsTableGUI\fillRow(), ilPCImageMapTableGUI\fillRow(), ilUnitCategoryTableGUI\fillRow(), ilImageMapTableGUI\fillRow(), ilWebResourceEditableLinkTableGUI\fillRow(), ilAccessibilityDocumentTableGUI\formatCellValue(), ilForumTopicTableGUI\initMergeThreadsTable(), and ilNestedListInputGUI\render().

260  : string {
261  $str = "<input type=\"checkbox\" name=\"" . $varname . "\"";
262 
263  if ($checked === true) {
264  $str .= " checked=\"checked\"";
265  }
266 
267  if ($disabled === true) {
268  $str .= " disabled=\"disabled\"";
269  }
270 
271  $array_var = false;
272 
273  if (substr($varname, -2) == "[]") {
274  $array_var = true;
275  }
276 
277  // if varname ends with [], use varname[-2] + _ + value as id tag (e.g. "user_id[]" => "user_id_15")
278  if ($array_var) {
279  $varname_id = substr($varname, 0, -2) . "_" . $value;
280  } else {
281  $varname_id = $varname;
282  }
283 
284  // dirty removal of other "[]" in string
285  $varname_id = str_replace("[", "_", $varname_id);
286  $varname_id = str_replace("]", "", $varname_id);
287 
288  $str .= " value=\"" . $value . "\" id=\"" . $varname_id . "\" />\n";
289 
290  return $str;
291  }
+ Here is the caller graph for this function:

◆ formRadioButton()

static ilLegacyFormElementsUtil::formRadioButton ( bool  $checked,
string  $varname,
string  $value,
?string  $onclick = null,
bool  $disabled = false 
)
static
Deprecated:

Definition at line 393 of file class.ilLegacyFormElementsUtil.php.

References null.

Referenced by ilECSNodeMappingCmsExplorer\buildFormItem(), ilPasteIntoMultipleItemsExplorer\buildFormItem(), ilECSNodeMappingLocalExplorer\buildFormItem(), and ilForumTopicTableGUI\initMergeThreadsTable().

399  : string {
400  $str = '<input ';
401 
402  if ($onclick !== null) {
403  $str .= ('onclick="' . $onclick . '"');
404  }
405 
406  $str .= (" type=\"radio\" name=\"" . $varname . "\"");
407  if ($checked === true) {
408  $str .= " checked=\"checked\"";
409  }
410 
411  if ($disabled === true) {
412  $str .= " disabled=\"disabled\"";
413  }
414 
415  $str .= " value=\"" . $value . "\"";
416 
417  $str .= " id=\"" . $value . "\" />\n";
418 
419  return $str;
420  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ formSelect()

static ilLegacyFormElementsUtil::formSelect (   $selected,
string  $varname,
array  $options,
bool  $multiple = false,
bool  $direct_text = false,
int  $size = 0,
string  $style_class = "",
array  $attribs = [],
bool  $disabled = false 
)
static

Builds a select form field with options and shows the selected option first.

public

Parameters
string/arrayvalue to be selected
stringvariable name in formular
arrayarray with $options (key = lang_key, value = long name)
booleanmultiple selection list true/false
booleanif true, the option values are displayed directly, otherwise they are handled as language variable keys and the corresponding language variable is displayed
intsize
stringstyle class
arrayadditional attributes (key = attribute name, value = attribute value)
booleandisabled
Deprecated:

Definition at line 310 of file class.ilLegacyFormElementsUtil.php.

References $DIC, and $lng.

Referenced by ilLearningProgressBaseGUI\__appendLPDetails(), ilObjUserGUI\__buildFilterSelect(), ilObjUserFolderGUI\__buildUserFilterSelect(), ilObjUserGUI\__getDateSelect(), ilObjUserGUI\__showUserDefinedFields(), ilPersonalProfileGUI\__showUserDefinedFields(), ilRecurrenceInputGUI\buildMonthlyByDaySelection(), ilRecurrenceInputGUI\buildMonthlyByMonthDaySelection(), ilRecurrenceInputGUI\buildYearlyByDaySelection(), ilRecurrenceInputGUI\buildYearlyByMonthDaySelection(), ilObjTypeDefinitionGUI\editObject(), ilTable2GUI\fillActionRow(), ilPCImageMapTableGUI\fillRow(), ilPCGridCellTableGUI\fillRow(), ilAdvancedMDRecordTableGUI\fillRow(), ilPCFileListTableGUI\fillRow(), ilImportantPagesTableGUI\fillRow(), ilECSCommunityTableGUI\fillRow(), ilInstallationHeadingTableGUI\fillRow(), ilMultilingualismTableGUI\fillRow(), ilLPCollectionSettingsTableGUI\fillRow(), ilImageMapTableGUI\fillRow(), ilWebResourceEditableLinkTableGUI\fillRow(), ilModulesTableGUI\fillRow(), ilTable2GUI\getLinkbar(), ilLocationInputGUI\insert(), ilRecurrenceInputGUI\insert(), ilLDAPSettingsGUI\prepareMappingSelect(), ilDurationInputGUI\render(), ilPortfolioPageGUI\renderMyCourses(), ilInternalLinkGUI\showLinkHelp(), ilPageObjectGUI\showPage(), ilObjUserFolderGUI\showPossibleSubObjects(), and ilObjectGUI\showPossibleSubObjects().

320  : string {
321  global $DIC;
322 
323  $lng = $DIC->language();
324 
325  if ($multiple == true) {
326  $multiple = " multiple=\"multiple\"";
327  } else {
328  $multiple = "";
329  $size = 0;
330  }
331 
332  $class = " class=\" form-control " . $style_class . "\"";
333 
334  // use form-inline!
335  // this is workaround the whole function should be set deprecated
336  // $attributes = " style='display:inline-block;' ";
337 
338  $attributes = "";
339  if (is_array($attribs)) {
340  foreach ($attribs as $key => $val) {
341  $attributes .= " " . $key . "=\"" . $val . "\"";
342  }
343  }
344  if ($disabled) {
345  $disabled = ' disabled=\"disabled\"';
346  }
347 
348  $size_str = "";
349  if ($size > 0) {
350  $size_str = ' size="' . $size . '" ';
351  }
352  $str = "<select name=\"" . $varname . "\"" . $multiple . " $class " . $size_str . " $attributes $disabled>\n";
353 
354  foreach ($options as $key => $val) {
355  $style = "";
356  if (is_array($val)) {
357  $style = $val["style"];
358  $val = $val["text"]; // mus be last line, since we overwrite
359  }
360 
361  $sty = ($style != "")
362  ? ' style="' . $style . '" '
363  : "";
364 
365  if ($direct_text) {
366  $str .= " <option $sty value=\"" . $key . "\"";
367  } else {
368  $str .= " <option $sty value=\"" . $val . "\"";
369  }
370  if (is_array($selected)) {
371  if (in_array($key, $selected)) {
372  $str .= " selected=\"selected\"";
373  }
374  } elseif ($selected == $key) {
375  $str .= " selected=\"selected\"";
376  }
377 
378  if ($direct_text) {
379  $str .= ">" . $val . "</option>\n";
380  } else {
381  $str .= ">" . $lng->txt($val) . "</option>\n";
382  }
383  }
384 
385  $str .= "</select>\n";
386 
387  return $str;
388  }
global $DIC
Definition: shib_login.php:26
global $lng
Definition: privfeed.php:31
+ Here is the caller graph for this function:

◆ makeTimeSelect()

static ilLegacyFormElementsUtil::makeTimeSelect ( string  $prefix,
bool  $short = true,
int  $hour = 0,
int  $minute = 0,
int  $second = 0,
bool  $a_use_default = true,
array  $a_further_options = [] 
)
static

Creates a combination of HTML selects for time inputs.

Creates a combination of HTML selects for time inputs. The select names are $prefix[h] for hours, $prefix[m] for minutes and $prefix[s] for seconds.

public

Parameters
string$prefixPrefix of the select name
boolean$shortSet TRUE for a short time input (only hours and minutes). Default is TRUE
integer$hourDefault hour value
integer$minuteDefault minute value
integer$secondDefault second value
Deprecated:

Definition at line 165 of file class.ilLegacyFormElementsUtil.php.

References $DIC, $lng, and ilCalendarSettings\TIME_FORMAT_24.

Referenced by ilLPCollectionSettingsTableGUI\fillRow().

173  : string {
174  global $DIC;
175 
176  $lng = $DIC->language();
177  $ilUser = $DIC->user();
178 
179  $minute_steps = 1;
180  $disabled = '';
181  if (count($a_further_options)) {
182  if (isset($a_further_options['minute_steps'])) {
183  $minute_steps = $a_further_options['minute_steps'];
184  }
185  if (isset($a_further_options['disabled']) and $a_further_options['disabled']) {
186  $disabled = 'disabled="disabled" ';
187  }
188  }
189 
190  if ($a_use_default and !strlen("$hour$minute$second")) {
191  $now = localtime();
192  $hour = $now[2];
193  $minute = $now[1];
194  $second = $now[0];
195  }
196 
197  // build hour select
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 . ' ';
202  }
203  }
204  $sel_hour .= " " . $disabled . "name=\"" . $prefix . "[h]\" id=\"" . $prefix . "_h\" class=\"form-control\">\n";
205 
206  $format = $ilUser->getTimeFormat();
207  for ($i = 0; $i <= 23; $i++) {
208  if ($format == ilCalendarSettings::TIME_FORMAT_24) {
209  $sel_hour .= "<option value=\"$i\">" . sprintf("%02d", $i) . "</option>\n";
210  } else {
211  $sel_hour .= "<option value=\"$i\">" . date("ga", mktime($i, 0, 0)) . "</option>\n";
212  }
213  }
214  $sel_hour .= "</select>\n";
215  $sel_hour = preg_replace("/(value\=\"$hour\")/", "$1 selected=\"selected\"", $sel_hour);
216 
217  // build minutes select
218  $sel_minute = "<select " . $disabled . "name=\"" . $prefix . "[m]\" id=\"" . $prefix . "_m\" class=\"form-control\">\n";
219 
220  for ($i = 0; $i <= 59; $i = $i + $minute_steps) {
221  $sel_minute .= "<option value=\"$i\">" . sprintf("%02d", $i) . "</option>\n";
222  }
223  $sel_minute .= "</select>\n";
224  $sel_minute = preg_replace("/(value\=\"$minute\")/", "$1 selected=\"selected\"", $sel_minute);
225 
226  if (!$short) {
227  // build seconds select
228  $sel_second = "<select " . $disabled . "name=\"" . $prefix . "[s]\" id=\"" . $prefix . "_s\" class=\"form-control\">\n";
229 
230  for ($i = 0; $i <= 59; $i++) {
231  $sel_second .= "<option value=\"$i\">" . sprintf("%02d", $i) . "</option>\n";
232  }
233  $sel_second .= "</select>\n";
234  $sel_second = preg_replace("/(value\=\"$second\")/", "$1 selected=\"selected\"", $sel_second);
235  }
236  $timeformat = ($lng->text["lang_timeformat"] ?? '');
237  if (strlen($timeformat) == 0) {
238  $timeformat = "H:i:s";
239  }
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);
244  if ($short) {
245  $timeformat = preg_replace("/%%s/", "", $timeformat);
246  } else {
247  $timeformat = preg_replace("/%%s/", $sel_second, $timeformat);
248  }
249  return $timeformat;
250  }
global $DIC
Definition: shib_login.php:26
global $lng
Definition: privfeed.php:31
+ Here is the caller graph for this function:

◆ period2String()

static ilLegacyFormElementsUtil::period2String ( ilDateTime  $a_from,
  $a_to = null 
)
static

Return a string of time period.

Deprecated:

Definition at line 59 of file class.ilLegacyFormElementsUtil.php.

References $DIC, $lng, ilDateTime\get(), IL_CAL_DATETIME, and IL_CAL_UNIX.

Referenced by ilObjExerciseAccess\_lookupRemainingWorkingTimeString(), ilExcAssMemberState\getRemainingPeerReviewPresentation(), ilExcAssMemberState\getRemainingTimePresentation(), ilExcAssMemberState\getRemainingTimePresentationOfLastSubmissionOfRelativeDeadline(), and ILIAS\Exercise\Assignment\PropertyAndActionBuilderUI\getTimeString().

59  : string
60  {
61  global $DIC;
62 
63  $lng = $DIC->language();
64 
65  if (!$a_to) {
66  $a_to = new ilDateTime(time(), IL_CAL_UNIX);
67  }
68 
69  $from = new DateTime($a_from->get(IL_CAL_DATETIME));
70  $to = new DateTime($a_to->get(IL_CAL_DATETIME));
71  $diff = $to->diff($from);
72 
73  $periods = [];
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");
80 
81  if (!array_sum($periods)) {
82  return '';
83  }
84  $array = [];
85  foreach ($periods as $key => $value) {
86  if ($value) {
87  $segment_name = ($value > 1)
88  ? $key
89  : substr($key, 0, -1);
90  $array[] = $value . ' ' . $lng->txt($segment_name);
91  }
92  }
93 
94  if ($len = count($array) > 3) {
95  $array = array_slice($array, 0, (3 - $len));
96  }
97 
98  return implode(', ', $array);
99  }
get(int $a_format, string $a_format_str='', string $a_tz='')
get formatted date
const IL_CAL_DATETIME
const IL_CAL_UNIX
global $DIC
Definition: shib_login.php:26
global $lng
Definition: privfeed.php:31
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ prepareFormOutput()

static ilLegacyFormElementsUtil::prepareFormOutput (   $a_str,
bool  $a_strip = false 
)
static
Parameters
string | int$a_str
Deprecated:

Definition at line 37 of file class.ilLegacyFormElementsUtil.php.

References ilUtil\stripSlashes().

Referenced by ilScormPlaceholderDescription\__construct(), ILIAS\Test\Certificate\TestPlaceholderDescription\__construct(), ilLTIConsumerPlaceholderDescription\__construct(), ILIAS\Exercise\Certificate\ExercisePlaceholderDescription\__construct(), ILIAS\Course\Certificate\CoursePlaceholderDescription\__construct(), ilCmiXapiPlaceholderDescription\__construct(), ilObjUserGUI\__showUserDefinedFields(), ilPersonalProfileGUI\__showUserDefinedFields(), assQuestionGUI\addBasicQuestionFormProperties(), ilInfoScreenGUI\addPropertyTextinput(), assFileUploadFileTableGUI\buildFileItemContent(), ilAssClozeTestFeedback\buildGapFeedbackLabel(), ilAssClozeTestFeedback\buildSelectGapOptionFeedbackLabel(), ilAssClozeTestFeedback\buildTextGapGivenAnswerFeedbackLabel(), ilKprimChoiceCorrectionsInputGUI\checkInput(), ilObjStyleSheetGUI\deleteColorConfirmationObject(), ilObjTest\deliverPDFfromHTML(), ilLMEditShortTitlesTableGUI\fillRow(), ilKprimChoiceAnswerFreqStatTableGUI\fillRow(), ilLanguageExtTableGUI\fillRow(), ilHelpTooltipTableGUI\fillRow(), ilPCTabsTableGUI\fillRow(), ilMultiSrtConfirmationTable2GUI\fillRow(), ilPCGridCellTableGUI\fillRow(), ilWikiContributorsTableGUI\fillRow(), ilSurveyQuestionPoolExportTableGUI\fillRow(), ilInstallationHeadingTableGUI\fillRow(), ilStyleColorTableGUI\fillRow(), ilHelpMappingTableGUI\fillRow(), ilMultilingualismTableGUI\fillRow(), ilPortfolioPageTableGUI\fillRow(), ilExportIDTableGUI\fillRow(), ilTaxonomyTableGUI\fillRow(), ilImageMapTableGUI\fillRow(), ilSurveyQuestionblockbrowserTableGUI\fillRow(), ilQuestionPoolPrintViewTableGUI\fillRow(), ilExGradesTableGUI\fillRow(), ilWebResourceEditableLinkTableGUI\fillRow(), ilSurveyQuestionbrowserTableGUI\fillRow(), ilModulesTableGUI\fillRow(), ilMailErrorFormatter\format(), assFormulaQuestion\generateResultInputHTML(), ilAwarenessGUI\getAwarenessList(), assClozeTestGUI\getBestSolutionText(), assErrorText\getErrorTokenHtml(), ilAccessibilitySupportContactsGUI\getFooterLink(), ilSystemSupportContactsGUI\getFooterLink(), ilFormPropertyGUI\getHiddenTag(), ilUserFilterGUI\getHTML(), ilTaggingGUI\getHTML(), ilAdvancedSelectionListGUI\getHTML(), ilAssNestedOrderingElementsInputGUI\getItemHtml(), ilRepositoryObjectSearchBlockGUI\getLegacyContent(), ilMailExplorer\getNodeContent(), ILIAS\StudyProgramme\Certificate\ilStudyProgrammePlaceholderValues\getPlaceholderValues(), ILIAS\StudyProgramme\Certificate\ilStudyProgrammePlaceholderValues\getPlaceholderValuesForPreview(), ILIAS\Course\Certificate\CoursePlaceholderValues\getPlaceholderValuesForPreview(), assOrderingHorizontalGUI\getPreview(), assSingleChoiceGUI\getPreview(), assTextQuestionGUI\getPreview(), assMultipleChoiceGUI\getPreview(), assKprimChoiceGUI\getPreview(), assImagemapQuestionGUI\getPreview(), assClozeTestGUI\getPreview(), SurveySingleChoiceQuestionGUI\getPrintView(), SurveyMultipleChoiceQuestionGUI\getPrintView(), SurveyMatrixQuestionGUI\getPrintView(), SurveyQuestionGUI\getPrintViewQuestionTitle(), assQuestion\getSuggestedSolutionOutput(), ilTaggingGUI\getTaggingInputHTML(), assOrderingHorizontalGUI\getTestOutput(), assKprimChoiceGUI\getTestOutput(), assSingleChoiceGUI\getTestOutput(), assMultipleChoiceGUI\getTestOutput(), assImagemapQuestionGUI\getTestOutput(), assClozeTestGUI\getTestOutput(), ilObjTest\getTestResult(), ilHiddenInputGUI\getToolbarHTML(), SurveyTextQuestionGUI\getWorkingForm(), SurveySingleChoiceQuestionGUI\getWorkingForm(), SurveyMultipleChoiceQuestionGUI\getWorkingForm(), SurveyMatrixQuestionGUI\getWorkingForm(), ILIAS\Course\Certificate\CoursePlaceholderValues\hasCompletionDate(), ilRepositoryObjectSearchResultTableGUI\init(), LDAPRoleMappingTable\initRecords(), ilMailSearchGUI\initSearchForm(), ilAssSingleChoiceCorrectionsInputGUI\insert(), ilAssErrorTextCorrectionsInputGUI\insert(), ilHiddenInputGUI\insert(), ilAssMultipleChoiceCorrectionsInputGUI\insert(), ilEssayKeywordWizardInputGUI\insert(), ilRandomTestROInputGUI\insert(), ilBackgroundImageInputGUI\insert(), ilSelectBuilderInputGUI\insert(), ilEMailInputGUI\insert(), ilUserLoginInputGUI\insert(), ilKprimChoiceWizardInputGUI\insert(), ilMatrixRowWizardInputGUI\insert(), ilTRBLColorPickerInputGUI\insert(), ilMatchingPairWizardInputGUI\insert(), ilFileWizardInputGUI\insert(), ilColorPickerInputGUI\insert(), ilMultipleChoiceWizardInputGUI\insert(), ilCSSRectInputGUI\insert(), ilErrorTextWizardInputGUI\insert(), ilAnswerWizardInputGUI\insert(), ilMatchingWizardInputGUI\insert(), ilCategoryWizardInputGUI\insert(), ilTextAreaInputGUI\insert(), ilSingleChoiceWizardInputGUI\insert(), assQuestionGUI\outPageSelector(), ilExerciseSubmissionTableGUI\parseColumns(), ilLuceneSearchGUI\performSearch(), assClozeTestGUI\populateNumericGapCorrectionFormProperty(), assClozeTestGUI\populateNumericGapFormPart(), ilCertificateUtilHelper\prepareFormOutput(), ilObjForumGUI\prepareFormOutput(), ilNonEditableValueGUI\render(), ilTextWizardInputGUI\render(), ilCheckboxInputGUI\render(), ilMultipleTextsInputGUI\render(), ilTagInputGUI\render(), ilSelectInputGUI\render(), ilMultiSelectInputGUI\render(), ilRepositorySelectorInputGUI\render(), ilPasswordInputGUI\render(), ilOrgUnitGenericMultiInputGUI\render(), ilNumberInputGUI\render(), ilTextInputGUI\render(), ilMultipleImagesInputGUI\render(), ilDateDurationInputGUI\render(), ilObjForumGUI\renderDraftContent(), ilObjForumGUI\renderPostContent(), ilSearchBaseGUI\renderSearch(), assOrderingHorizontalGUI\renderSolutionOutput(), assSingleChoiceGUI\renderSolutionOutput(), assMultipleChoiceGUI\renderSolutionOutput(), assMatchingQuestionGUI\renderSolutionOutput(), assKprimChoiceGUI\renderSolutionOutput(), assClozeTestGUI\renderSolutionOutput(), ILIAS\LegalDocuments\ConsumerToolbox\ConsumerSlots\SelfRegistration\saveLegacyForm(), ilHelpGUI\search(), ilMailFormGUI\searchUsers(), ilPasswordAssistanceGUI\showAssistanceForm(), ilAccessibilityControlConceptGUI\showControlConcept(), ILIAS\LegalDocuments\ConsumerToolbox\ConsumerSlots\Agreement\showDocument(), ilHelpGUI\showPage(), ilLuceneSearchGUI\showSavedResults(), ilPasswordAssistanceGUI\showUsernameAssistanceForm(), and assQuestionGUI\suggestedsolution().

37  : string
38  {
39  if ($a_strip) {
40  $a_str = ilUtil::stripSlashes($a_str);
41  }
42  $a_str = htmlspecialchars((string) $a_str);
43  // Added replacement of curly brackets to prevent
44  // problems with PEAR templates, because {xyz} will
45  // be removed as unused template variable
46  $a_str = str_replace("{", "&#123;", $a_str);
47  $a_str = str_replace("}", "&#125;", $a_str);
48  // needed for LaTeX conversion \\ in LaTeX is a line break
49  // but without this replacement, php changes \\ to \
50  $a_str = str_replace("\\", "&#92;", $a_str);
51  return $a_str;
52  }
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ prepareTextareaOutput()

static ilLegacyFormElementsUtil::prepareTextareaOutput ( string  $txt_output,
bool  $prepare_for_latex_output = false,
bool  $omitNl2BrWhenTextArea = false 
)
static

Prepares a string for a text area output where latex code may be in it If the text is HTML-free, CHR(13) will be converted to a line break.

Parameters
string$txt_outputString which should be prepared for output public
Returns
array|string|string[]|null

Definition at line 109 of file class.ilLegacyFormElementsUtil.php.

References ilUtil\isHTML(), and ilRTE\replaceLatexSpan().

Referenced by assMatchingQuestionGUI\buildTermHtml(), ilAssClozeTestFeedback\completeFbPropsForNumericGap(), ilAssClozeTestFeedback\completeFbPropsForSelectGap(), ilAssClozeTestFeedback\completeFbPropsForTextGap(), ilAssClozeTestFeedback\completeFormPropsForFeedbackModeGapQuestion(), ilAssConfigurableMultiOptionQuestionFeedback\completeSpecificFormProperties(), ilAssMultiOptionQuestionFeedback\completeSpecificFormProperties(), assTextQuestionGUI\getAutoSavedSolutionOutput(), assClozeTest\getClozeTextForHTMLOutput(), assQuestionGUI\getGenericFeedbackOutput(), assClozeTestGUI\getGenericFeedbackOutput(), assQuestionGUI\getGenericFeedbackOutputForCorrectSolution(), assQuestionGUI\getGenericFeedbackOutputForIncorrectSolution(), assLongMenuGUI\getLongMenuTextWithInputFieldsInsteadOfGaps(), assFileUploadGUI\getPreview(), assSingleChoiceGUI\getPreview(), assMultipleChoiceGUI\getPreview(), assKprimChoiceGUI\getPreview(), assClozeTestGUI\getPreview(), assFormulaQuestionGUI\getPreview(), assFileUploadGUI\getSolutionOutput(), assImagemapQuestionGUI\getSolutionOutput(), ilAssClozeTestFeedback\getSpecificAnswerFeedbackFormValue(), assNumericGUI\getSpecificFeedbackOutput(), assTextSubsetGUI\getSpecificFeedbackOutput(), assFileUploadGUI\getSpecificFeedbackOutput(), assErrorTextGUI\getSpecificFeedbackOutput(), assLongMenuGUI\getSpecificFeedbackOutput(), assSingleChoiceGUI\getSpecificFeedbackOutput(), assMultipleChoiceGUI\getSpecificFeedbackOutput(), assImagemapQuestionGUI\getSpecificFeedbackOutput(), assMatchingQuestionGUI\getSpecificFeedbackOutput(), assClozeTestGUI\getSpecificFeedbackOutput(), assFileUploadGUI\getTestOutput(), assKprimChoiceGUI\getTestOutput(), assSingleChoiceGUI\getTestOutput(), assMultipleChoiceGUI\getTestOutput(), assFormulaQuestionGUI\getTestOutput(), assClozeTestGUI\getTestOutput(), ilAssConfigurableMultiOptionQuestionFeedback\initSpecificFormProperties(), ilAssMultiOptionQuestionFeedback\initSpecificFormProperties(), ilAssMatchingPairCorrectionsInputGUI\insert(), ilAnswerWizardInputGUI\insert(), assMatchingQuestionGUI\populateDefinition(), assSingleChoiceGUI\populateInlineFeedback(), assKprimChoiceGUI\populateSpecificFeedbackInline(), assMultipleChoiceGUI\populateSpecificFeedbackInline(), SurveyQuestion\prepareTextareaOutput(), ilObjSurvey\prepareTextareaOutput(), ilObjTest\prepareTextareaOutput(), assQuestion\purifyAndPrepareTextAreaOutput(), assOrderingHorizontalGUI\renderSolutionOutput(), assTextQuestionGUI\renderSolutionOutput(), assTextSubsetGUI\renderSolutionOutput(), assNumericGUI\renderSolutionOutput(), assSingleChoiceGUI\renderSolutionOutput(), assMultipleChoiceGUI\renderSolutionOutput(), assErrorTextGUI\renderSolutionOutput(), assLongMenuGUI\renderSolutionOutput(), assOrderingQuestionGUI\renderSolutionOutput(), assMatchingQuestionGUI\renderSolutionOutput(), assKprimChoiceGUI\renderSolutionOutput(), assClozeTestGUI\renderSolutionOutput(), assFormulaQuestionGUI\renderSolutionOutput(), and assClozeTest\updateClozeTextFromGaps().

113  {
114  $result = $txt_output;
115  $is_html = ilUtil::isHTML($result);
116 
117  // removed: did not work with magic_quotes_gpc = On
118  if (!$is_html) {
119  if (!$omitNl2BrWhenTextArea) {
120  // if the string does not contain HTML code, replace the newlines with HTML line breaks
121  $result = preg_replace("/[\n]/", "<br />", $result);
122  }
123  } else {
124  // patch for problems with the <pre> tags in tinyMCE
125  if (preg_match_all("/(<pre>.*?<\/pre>)/ims", $result, $matches)) {
126  foreach ($matches[0] as $found) {
127  $replacement = "";
128  if (strpos("\n", $found) === false) {
129  $replacement = "\n";
130  }
131  $removed = preg_replace("/<br\s*?\/>/ims", $replacement, $found);
132  $result = str_replace($found, $removed, $result);
133  }
134  }
135  }
136 
137  if ($prepare_for_latex_output) {
138  $result = ilRTE::replaceLatexSpan($result);
139 
140  // replace special characters to prevent problems with the ILIAS template system
141  // eg. if someone uses {1} as an answer, nothing will be shown without the replacement
142  $result = str_replace("{", "&#123;", $result);
143  $result = str_replace("}", "&#125;", $result);
144  $result = str_replace("\\", "&#92;", $result);
145  }
146 
147  return $result;
148  }
static isHTML(string $a_text)
Checks if a given string contains HTML or not.
static replaceLatexSpan(string $text)
Replace the latex delimiters used by the rich text editor Unfortunately these can&#39;t be processed by M...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: