ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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
Deprecated:
The 2021 Technical Board has decided to mark the ilUtil class as deprecated. The ilUtil is a historically 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 32 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 261 of file class.ilLegacyFormElementsUtil.php.

Referenced by ilMailSearchGUI\appendRecipientSelection(), ilLocalUserGUI\assignRoles(), ilObjCategoryGUI\assignRolesObject(), ilECSNodeMappingCmsExplorer\buildFormItem(), ilPasteIntoMultipleItemsExplorer\buildFormItem(), ilECSNodeMappingLocalExplorer\buildFormItem(), ilStartUpGUI\confirmWithdrawal(), ilForumModeratorsGUI\detachModeratorRole(), ilForumDraftsTableGUI\fillRow(), ilTestPersonalDefaultSettingsTableGUI\fillRow(), ilQuestionPoolImportVerificationTableGUI\fillRow(), ilMailAttachmentTableGUI\fillRow(), ilPCImageMapTableGUI\fillRow(), ilPCIIMTriggerTableGUI\fillRow(), ilImageMapTableGUI\fillRow(), ilMarkSchemaTableGUI\fillRow(), ilWebResourceEditableLinkTableGUI\fillRow(), ilBuddySystemRelationsTableGUI\fillRow(), ilMailTemplateTableGUI\formatCellValue(), ilTermsOfServiceDocumentTableGUI\formatCellValue(), ilAccessibilityDocumentTableGUI\formatCellValue(), ilForumSettingsGUI\getUserNotificationTableData(), ilForumTopicTableGUI\initMergeThreadsTable(), ilNestedListInputGUI\render(), ilMailingListsGUI\showMailingLists(), and ilMailingListsGUI\showMembersList().

266  : string {
267  $str = "<input type=\"checkbox\" name=\"" . $varname . "\"";
268 
269  if ($checked === true) {
270  $str .= " checked=\"checked\"";
271  }
272 
273  if ($disabled === true) {
274  $str .= " disabled=\"disabled\"";
275  }
276 
277  $array_var = false;
278 
279  if (substr($varname, -2) == "[]") {
280  $array_var = true;
281  }
282 
283  // if varname ends with [], use varname[-2] + _ + value as id tag (e.g. "user_id[]" => "user_id_15")
284  if ($array_var) {
285  $varname_id = substr($varname, 0, -2) . "_" . $value;
286  } else {
287  $varname_id = $varname;
288  }
289 
290  // dirty removal of other "[]" in string
291  $varname_id = str_replace("[", "_", $varname_id);
292  $varname_id = str_replace("]", "", $varname_id);
293 
294  $str .= " value=\"" . $value . "\" id=\"" . $varname_id . "\" />\n";
295 
296  return $str;
297  }
+ 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 399 of file class.ilLegacyFormElementsUtil.php.

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

405  : string {
406  $str = '<input ';
407 
408  if ($onclick !== null) {
409  $str .= ('onclick="' . $onclick . '"');
410  }
411 
412  $str .= (" type=\"radio\" name=\"" . $varname . "\"");
413  if ($checked === true) {
414  $str .= " checked=\"checked\"";
415  }
416 
417  if ($disabled === true) {
418  $str .= " disabled=\"disabled\"";
419  }
420 
421  $str .= " value=\"" . $value . "\"";
422 
423  $str .= " id=\"" . $value . "\" />\n";
424 
425  return $str;
426  }
+ 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 316 of file class.ilLegacyFormElementsUtil.php.

References $attributes, $DIC, ILIAS\LTI\ToolProvider\$key, and $lng.

Referenced by ilLearningProgressBaseGUI\__appendLPDetails(), ilTypicalLearningTimeInputGUI\__buildDaysSelect(), ilMDEditorGUI\__buildDaysSelect(), ilObjUserGUI\__buildFilterSelect(), ilTypicalLearningTimeInputGUI\__buildMonthsSelect(), ilMDEditorGUI\__buildMonthsSelect(), ilObjUserFolderGUI\__buildUserFilterSelect(), ilMDEditorGUI\__fillSubelements(), ilObjUserGUI\__getDateSelect(), ilAdvancedSearchGUI\__getFilterSelect(), ilObjUserGUI\__showUserDefinedFields(), ilPersonalProfileGUI\__showUserDefinedFields(), ilMDUtilSelect\_getBrowserSelect(), ilMDUtilSelect\_getContextSelect(), ilMDUtilSelect\_getCopyrightAndOtherRestrictionsSelect(), ilMDUtilSelect\_getCostsSelect(), ilMDUtilSelect\_getDifficultySelect(), ilMDUtilSelect\_getDurationSelect(), ilMDUtilSelect\_getFormatSelect(), ilMDUtilSelect\_getIntendedEndUserRoleSelect(), ilMDUtilSelect\_getInteractivityLevelSelect(), ilMDUtilSelect\_getInteractivityTypeSelect(), ilMDUtilSelect\_getLanguageSelect(), ilMDUtilSelect\_getLearningResourceTypeSelect(), ilMDUtilSelect\_getLocationTypeSelect(), ilMDUtilSelect\_getOperatingSystemSelect(), ilMDUtilSelect\_getPurposeSelect(), ilMDUtilSelect\_getRoleSelect(), ilMDUtilSelect\_getSemanticDensitySelect(), ilMDUtilSelect\_getStatusSelect(), ilMDUtilSelect\_getStructureSelect(), ilMDUtilSelect\_getTypicalAgeRangeSelect(), ilMDUtilSelect\_getTypicalLearningTimeSelect(), ilRecurrenceInputGUI\buildMonthlyByDaySelection(), ilRecurrenceInputGUI\buildMonthlyByMonthDaySelection(), ilRecurrenceInputGUI\buildYearlyByDaySelection(), ilRecurrenceInputGUI\buildYearlyByMonthDaySelection(), ilObjSystemFolderGUI\checkObject(), ilObjTypeDefinitionGUI\editObject(), ilTable2GUI\fillActionRow(), ilPCImageMapTableGUI\fillRow(), ilImportantPagesTableGUI\fillRow(), ilPCGridCellTableGUI\fillRow(), ilAdvancedMDRecordTableGUI\fillRow(), ilECSCommunityTableGUI\fillRow(), ilPCFileListTableGUI\fillRow(), ilObjectTranslationTableGUI\fillRow(), ilLPCollectionSettingsTableGUI\fillRow(), ilMultilingualismTableGUI\fillRow(), ilObjectTranslation2TableGUI\fillRow(), ilPCIIMTriggerTableGUI\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(), ilObjectGUI\showPossibleSubObjects(), and ilStructureObjectGUI\subchap().

326  : string {
327  global $DIC;
328 
329  $lng = $DIC->language();
330 
331  if ($multiple == true) {
332  $multiple = " multiple=\"multiple\"";
333  } else {
334  $multiple = "";
335  $size = 0;
336  }
337 
338  $class = " class=\" form-control " . $style_class . "\"";
339 
340  // use form-inline!
341  // this is workaround the whole function should be set deprecated
342  // $attributes = " style='display:inline-block;' ";
343 
344  $attributes = "";
345  if (is_array($attribs)) {
346  foreach ($attribs as $key => $val) {
347  $attributes .= " " . $key . "=\"" . $val . "\"";
348  }
349  }
350  if ($disabled) {
351  $disabled = ' disabled=\"disabled\"';
352  }
353 
354  $size_str = "";
355  if ($size > 0) {
356  $size_str = ' size="' . $size . '" ';
357  }
358  $str = "<select name=\"" . $varname . "\"" . $multiple . " $class " . $size_str . " $attributes $disabled>\n";
359 
360  foreach ($options as $key => $val) {
361  $style = "";
362  if (is_array($val)) {
363  $style = $val["style"];
364  $val = $val["text"]; // mus be last line, since we overwrite
365  }
366 
367  $sty = ($style != "")
368  ? ' style="' . $style . '" '
369  : "";
370 
371  if ($direct_text) {
372  $str .= " <option $sty value=\"" . $key . "\"";
373  } else {
374  $str .= " <option $sty value=\"" . $val . "\"";
375  }
376  if (is_array($selected)) {
377  if (in_array($key, $selected)) {
378  $str .= " selected=\"selected\"";
379  }
380  } elseif ($selected == $key) {
381  $str .= " selected=\"selected\"";
382  }
383 
384  if ($direct_text) {
385  $str .= ">" . $val . "</option>\n";
386  } else {
387  $str .= ">" . $lng->txt($val) . "</option>\n";
388  }
389  }
390 
391  $str .= "</select>\n";
392 
393  return $str;
394  }
$attributes
Definition: metadata.php:248
$lng
global $DIC
Definition: feed.php:28
string $key
Consumer key/client ID value.
Definition: System.php:193
+ 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 171 of file class.ilLegacyFormElementsUtil.php.

References $DIC, $format, $i, $ilUser, $lng, $name, and ilCalendarSettings\TIME_FORMAT_24.

Referenced by ilLPCollectionSettingsTableGUI\fillRow(), ilTypicalLearningTimeInputGUI\insert(), ilMDEditorGUI\listEducational(), and ilMDEditorGUI\listQuickEdit_scorm().

179  : string {
180  global $DIC;
181 
182  $lng = $DIC->language();
183  $ilUser = $DIC->user();
184 
185  $minute_steps = 1;
186  $disabled = '';
187  if (count($a_further_options)) {
188  if (isset($a_further_options['minute_steps'])) {
189  $minute_steps = $a_further_options['minute_steps'];
190  }
191  if (isset($a_further_options['disabled']) and $a_further_options['disabled']) {
192  $disabled = 'disabled="disabled" ';
193  }
194  }
195 
196  if ($a_use_default and !strlen("$hour$minute$second")) {
197  $now = localtime();
198  $hour = $now[2];
199  $minute = $now[1];
200  $second = $now[0];
201  }
202 
203  // build hour select
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 . ' ';
208  }
209  }
210  $sel_hour .= " " . $disabled . "name=\"" . $prefix . "[h]\" id=\"" . $prefix . "_h\" class=\"form-control\">\n";
211 
212  $format = $ilUser->getTimeFormat();
213  for ($i = 0; $i <= 23; $i++) {
215  $sel_hour .= "<option value=\"$i\">" . sprintf("%02d", $i) . "</option>\n";
216  } else {
217  $sel_hour .= "<option value=\"$i\">" . date("ga", mktime($i, 0, 0)) . "</option>\n";
218  }
219  }
220  $sel_hour .= "</select>\n";
221  $sel_hour = preg_replace("/(value\=\"$hour\")/", "$1 selected=\"selected\"", $sel_hour);
222 
223  // build minutes select
224  $sel_minute = "<select " . $disabled . "name=\"" . $prefix . "[m]\" id=\"" . $prefix . "_m\" class=\"form-control\">\n";
225 
226  for ($i = 0; $i <= 59; $i = $i + $minute_steps) {
227  $sel_minute .= "<option value=\"$i\">" . sprintf("%02d", $i) . "</option>\n";
228  }
229  $sel_minute .= "</select>\n";
230  $sel_minute = preg_replace("/(value\=\"$minute\")/", "$1 selected=\"selected\"", $sel_minute);
231 
232  if (!$short) {
233  // build seconds select
234  $sel_second = "<select " . $disabled . "name=\"" . $prefix . "[s]\" id=\"" . $prefix . "_s\" class=\"form-control\">\n";
235 
236  for ($i = 0; $i <= 59; $i++) {
237  $sel_second .= "<option value=\"$i\">" . sprintf("%02d", $i) . "</option>\n";
238  }
239  $sel_second .= "</select>\n";
240  $sel_second = preg_replace("/(value\=\"$second\")/", "$1 selected=\"selected\"", $sel_second);
241  }
242  $timeformat = ($lng->text["lang_timeformat"] ?? '');
243  if (strlen($timeformat) == 0) {
244  $timeformat = "H:i:s";
245  }
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);
250  if ($short) {
251  $timeformat = preg_replace("/%%s/", "", $timeformat);
252  } else {
253  $timeformat = preg_replace("/%%s/", $sel_second, $timeformat);
254  }
255  return $timeformat;
256  }
$lng
global $DIC
Definition: feed.php:28
if($format !==null) $name
Definition: metadata.php:247
$format
Definition: metadata.php:235
$ilUser
Definition: imgupload.php:34
$i
Definition: metadata.php:41
+ 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 60 of file class.ilLegacyFormElementsUtil.php.

References $DIC, ILIAS\LTI\ToolProvider\$key, $lng, ilDateTime\get(), IL_CAL_DATETIME, and IL_CAL_UNIX.

Referenced by ilObjExerciseAccess\_lookupRemainingWorkingTimeString(), ilExcAssMemberState\getRemainingTimePresentation(), and ilExAssignmentGUI\getTimeString().

60  : string
61  {
62  global $DIC;
63 
64  $lng = $DIC->language();
65 
66  if (!$a_to) {
67  $a_to = new ilDateTime(time(), IL_CAL_UNIX);
68  }
69 
70  $from = new DateTime($a_from->get(IL_CAL_DATETIME));
71  $to = new DateTime($a_to->get(IL_CAL_DATETIME));
72  $diff = $to->diff($from);
73 
74  $periods = [];
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");
81 
82  if (!array_sum($periods)) {
83  return '';
84  }
85  $array = [];
86  foreach ($periods as $key => $value) {
87  if ($value) {
88  $segment_name = ($value > 1)
89  ? $key
90  : substr($key, 0, -1);
91  $array[] = $value . ' ' . $lng->txt($segment_name);
92  }
93  }
94 
95  if ($len = count($array) > 3) {
96  $array = array_slice($array, 0, (3 - $len));
97  }
98 
99  return implode(', ', $array);
100  }
get(int $a_format, string $a_format_str='', string $a_tz='')
get formatted date
const IL_CAL_DATETIME
$lng
const IL_CAL_UNIX
global $DIC
Definition: feed.php:28
string $key
Consumer key/client ID value.
Definition: System.php:193
+ 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 38 of file class.ilLegacyFormElementsUtil.php.

References ilUtil\stripSlashes().

Referenced by ilScormPlaceholderDescription\__construct(), ilExercisePlaceholderDescription\__construct(), ilTestPlaceholderDescription\__construct(), ilCoursePlaceholderDescription\__construct(), ilLTIConsumerPlaceholderDescription\__construct(), ilCmiXapiPlaceholderDescription\__construct(), ilObjUserGUI\__showUserDefinedFields(), ilPersonalProfileGUI\__showUserDefinedFields(), assClozeTestGUI\addBasicQuestionFormProperties(), assQuestionGUI\addBasicQuestionFormProperties(), ilInfoScreenGUI\addPropertyTextinput(), ilObjPDFGenerationGUI\buildConfigForm(), assFileUploadFileTableGUI\buildFileItemContent(), ilAssClozeTestFeedback\buildGapFeedbackLabel(), ilAssClozeTestFeedback\buildSelectGapOptionFeedbackLabel(), ilAssClozeTestFeedback\buildTextGapGivenAnswerFeedbackLabel(), ilObjSystemFolderGUI\changeHeaderTitleObject(), ilKprimChoiceCorrectionsInputGUI\checkInput(), ilKprimChoiceWizardInputGUI\checkInput(), ilStartUpGUI\confirmWithdrawal(), ilObjStyleSheetGUI\deleteColorConfirmationObject(), ilTable2GUI\deleteTemplate(), ilObjTest\deliverPDFfromHTML(), ilLMEditShortTitlesTableGUI\fillRow(), ilAssessmentFolderLogTableGUI\fillRow(), ilPCIIMPopupTableGUI\fillRow(), ilHelpTooltipTableGUI\fillRow(), ilTestHistoryTableGUI\fillRow(), ilLanguageExtTableGUI\fillRow(), ilLDAPRoleMappingTableGUI\fillRow(), ilPCTabsTableGUI\fillRow(), ilMultiSrtConfirmationTable2GUI\fillRow(), ilAssessmentFolderLogAdministrationTableGUI\fillRow(), ilKprimChoiceAnswerFreqStatTableGUI\fillRow(), ilPCGridCellTableGUI\fillRow(), ilWikiContributorsTableGUI\fillRow(), ilPortfolioTableGUI\fillRow(), ilObjectTranslationTableGUI\fillRow(), ilSurveyQuestionPoolExportTableGUI\fillRow(), ilMultilingualismTableGUI\fillRow(), ilHelpMappingTableGUI\fillRow(), ilStyleColorTableGUI\fillRow(), ilObjectTranslation2TableGUI\fillRow(), ilPortfolioPageTableGUI\fillRow(), ilExportIDTableGUI\fillRow(), ilTaxonomyTableGUI\fillRow(), ilImageMapTableGUI\fillRow(), ilSurveyQuestionblockbrowserTableGUI\fillRow(), ilListOfQuestionsTableGUI\fillRow(), ilQuestionPoolPrintViewTableGUI\fillRow(), ilExGradesTableGUI\fillRow(), ilWebResourceEditableLinkTableGUI\fillRow(), ilModulesTableGUI\fillRow(), ilSurveyQuestionbrowserTableGUI\fillRow(), ilMDCopyrightSelectionGUI\fillTemplate(), 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(), ilObjAssessmentFolderGUI\getLogDataOutputForm(), SurveyQuestionGUI\getMaterialOutput(), ilMailExplorer\getNodeContent(), ilTestServiceGUI\getPassListOfAnswersWithScoring(), ilStudyProgrammePlaceholderValues\getPlaceholderValues(), ilStudyProgrammePlaceholderValues\getPlaceholderValuesForPreview(), ilCoursePlaceholderValues\getPlaceholderValuesForPreview(), assOrderingHorizontalGUI\getPreview(), assSingleChoiceGUI\getPreview(), assMultipleChoiceGUI\getPreview(), assTextQuestionGUI\getPreview(), assKprimChoiceGUI\getPreview(), assImagemapQuestionGUI\getPreview(), assClozeTestGUI\getPreview(), SurveySingleChoiceQuestionGUI\getPrintView(), SurveyMultipleChoiceQuestionGUI\getPrintView(), SurveyMatrixQuestionGUI\getPrintView(), SurveyQuestionGUI\getPrintViewQuestionTitle(), assOrderingHorizontalGUI\getSolutionOutput(), assMultipleChoiceGUI\getSolutionOutput(), assSingleChoiceGUI\getSolutionOutput(), assMatchingQuestionGUI\getSolutionOutput(), assKprimChoiceGUI\getSolutionOutput(), assClozeTestGUI\getSolutionOutput(), 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(), ilRepositoryObjectSearchResultTableGUI\init(), ilPreviewGUI\initPreview(), ilMailSearchGUI\initSearchForm(), ilHiddenInputGUI\insert(), ilAssErrorTextCorrectionsInputGUI\insert(), ilAssSingleChoiceCorrectionsInputGUI\insert(), ilRandomTestROInputGUI\insert(), ilAssMultipleChoiceCorrectionsInputGUI\insert(), ilBackgroundImageInputGUI\insert(), ilSelectBuilderInputGUI\insert(), ilEMailInputGUI\insert(), ilUserLoginInputGUI\insert(), ilEssayKeywordWizardInputGUI\insert(), ilAssAnswerCorrectionsInputGUI\insert(), ilColorPickerInputGUI\insert(), ilMatrixRowWizardInputGUI\insert(), ilTRBLColorPickerInputGUI\insert(), ilFileWizardInputGUI\insert(), ilCSSRectInputGUI\insert(), ilMatchingPairWizardInputGUI\insert(), ilMultipleChoiceWizardInputGUI\insert(), ilImageWizardInputGUI\insert(), ilAnswerWizardInputGUI\insert(), ilErrorTextWizardInputGUI\insert(), ilKVPWizardInputGUI\insert(), ilCategoryWizardInputGUI\insert(), ilMatchingWizardInputGUI\insert(), ilTextAreaInputGUI\insert(), ilSingleChoiceWizardInputGUI\insert(), ilMDEditorGUI\listAnnotation(), ilMDEditorGUI\listClassification(), ilMDEditorGUI\listEducational(), ilMDEditorGUI\listGeneral(), ilMDEditorGUI\listLifecycle(), ilMDEditorGUI\listMetaMetaData(), ilMDEditorGUI\listQuickEdit_scorm(), ilMDEditorGUI\listRelation(), ilMDEditorGUI\listRights(), ilMDEditorGUI\listTechnical(), SurveyQuestionGUI\material(), assQuestionGUI\outPageSelector(), ilExerciseSubmissionTableGUI\parseColumns(), ilLuceneSearchGUI\performSearch(), assClozeTestGUI\populateNumericGapCorrectionFormProperty(), assClozeTestGUI\populateNumericGapFormPart(), ilCertificateUtilHelper\prepareFormOutput(), ilObjForumGUI\prepareFormOutput(), ilObjTestGUI\printobject(), ilDclMultiTextInputGUI\render(), ilGloAdvColSortInputGUI\render(), ilMailQuickFilterInputGUI\render(), ilNonEditableValueGUI\render(), ilTextWizardInputGUI\render(), ilCheckboxInputGUI\render(), ilMultipleTextsInputGUI\render(), ilSelectInputGUI\render(), ilMultiSelectInputGUI\render(), ilRepositorySelectorInputGUI\render(), ilTagInputGUI\render(), ilOrgUnitGenericMultiInputGUI\render(), ilOrgUnitMultiLineInputGUI\render(), ilDateTimeInputGUI\render(), ilPasswordInputGUI\render(), ilMultipleImagesInputGUI\render(), ilNumberInputGUI\render(), ilTextInputGUI\render(), ilDateDurationInputGUI\render(), ilHierarchyFormGUI\renderChild(), ilObjForumGUI\renderDraftContent(), ilTestQuestionSideListGUI\renderList(), ilObjForumGUI\renderPostContent(), ilObjTestGUI\reviewobject(), ilAccountRegistrationGUI\saveForm(), ilTable2GUI\saveTemplate(), ilHelpGUI\search(), ilMailFormGUI\searchUsers(), ilStartUpGUI\showAccountMigration(), ilPasswordAssistanceGUI\showAssistanceForm(), ilAccessibilityControlConceptGUI\showControlConcept(), ilHelpGUI\showPage(), ilLuceneSearchGUI\showSavedResults(), ilSearchGUI\showSearch(), ilLuceneUserSearchGUI\showSearchForm(), ilLuceneSearchGUI\showSearchForm(), ilStartUpGUI\showTermsOfService(), ilPersonalProfileGUI\showUserAgreement(), ilPasswordAssistanceGUI\showUsernameAssistanceForm(), and assQuestionGUI\suggestedsolution().

38  : string
39  {
40  if ($a_strip) {
41  $a_str = ilUtil::stripSlashes($a_str);
42  }
43  $a_str = htmlspecialchars($a_str);
44  // Added replacement of curly brackets to prevent
45  // problems with PEAR templates, because {xyz} will
46  // be removed as unused template variable
47  $a_str = str_replace("{", "&#123;", $a_str);
48  $a_str = str_replace("}", "&#125;", $a_str);
49  // needed for LaTeX conversion \\ in LaTeX is a line break
50  // but without this replacement, php changes \\ to \
51  $a_str = str_replace("\\", "&#92;", $a_str);
52  return $a_str;
53  }
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 110 of file class.ilLegacyFormElementsUtil.php.

References ilMathJax\getInstance(), and ilUtil\isHTML().

Referenced by ilAssQuestionHintsTableGUI\fillRow(), assTextQuestionGUI\getAutoSavedSolutionOutput(), ilAssMatchingPairCorrectionsInputGUI\insert(), SurveyQuestion\prepareTextareaOutput(), assQuestion\prepareTextareaOutput(), ilObjSurvey\prepareTextareaOutput(), ilObjTest\prepareTextareaOutput(), ilAnswerFrequencyStatisticTableGUI\purifyAndPrepareTextAreaOutput(), ilAssQuestionHintRequestGUI\showHintCmd(), and ilAssQuestionHintsGUI\showHintCmd().

114  {
115  $result = $txt_output;
116  $is_html = ilUtil::isHTML($result);
117 
118  // removed: did not work with magic_quotes_gpc = On
119  if (!$is_html) {
120  if (!$omitNl2BrWhenTextArea) {
121  // if the string does not contain HTML code, replace the newlines with HTML line breaks
122  $result = preg_replace("/[\n]/", "<br />", $result);
123  }
124  } else {
125  // patch for problems with the <pre> tags in tinyMCE
126  if (preg_match_all("/(<pre>.*?<\/pre>)/ims", $result, $matches)) {
127  foreach ($matches[0] as $found) {
128  $replacement = "";
129  if (strpos("\n", $found) === false) {
130  $replacement = "\n";
131  }
132  $removed = preg_replace("/<br\s*?\/>/ims", $replacement, $found);
133  $result = str_replace($found, $removed, $result);
134  }
135  }
136  }
137 
138  // since server side mathjax rendering does include svg-xml structures that indeed have linebreaks,
139  // do latex conversion AFTER replacing linebreaks with <br>. <svg> tag MUST NOT contain any <br> tags.
140  if ($prepare_for_latex_output) {
141  $result = ilMathJax::getInstance()->insertLatexImages($result, "<span class\=\"latex\">", "<\/span>");
142  $result = ilMathJax::getInstance()->insertLatexImages($result, "\[tex\]", "\[\/tex\]");
143  }
144 
145  if ($prepare_for_latex_output) {
146  // replace special characters to prevent problems with the ILIAS template system
147  // eg. if someone uses {1} as an answer, nothing will be shown without the replacement
148  $result = str_replace("{", "&#123;", $result);
149  $result = str_replace("}", "&#125;", $result);
150  $result = str_replace("\\", "&#92;", $result);
151  }
152 
153  return $result;
154  }
static isHTML(string $a_text)
Checks if a given string contains HTML or not.
static getInstance()
Singleton: get instance for use in ILIAS requests with a config loaded from the settings.
+ 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: