MOBILE-4616 text: Migrate text utils to text
parent
297cb57ff5
commit
90ec21333b
|
@ -29,7 +29,7 @@ import { CoreBlockBaseComponent } from '@features/block/classes/base-block-compo
|
|||
import { CoreSite } from '@classes/sites/site';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { AddonCourseCompletion } from '@addons/coursecompletion/services/coursecompletion';
|
||||
import { IonSearchbar } from '@ionic/angular';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
|
@ -375,7 +375,7 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem
|
|||
this.filters.show.custom = config?.displaygroupingcustomfield?.value == '1' && !!config?.customfieldsexport?.value;
|
||||
|
||||
this.filters.customFilters = this.filters.show.custom
|
||||
? CoreTextUtils.parseJSON(config?.customfieldsexport?.value || '[]', [])
|
||||
? CoreText.parseJSON(config?.customfieldsexport?.value || '[]', [])
|
||||
: [];
|
||||
|
||||
// Check if any selector is shown and not disabled.
|
||||
|
|
|
@ -19,7 +19,7 @@ import {
|
|||
AddonBlockRecentlyAccessedItems,
|
||||
AddonBlockRecentlyAccessedItemsItemCalculatedData,
|
||||
} from '../../services/recentlyaccesseditems';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreLoadings } from '@services/loadings';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreSharedModule } from '@/core/shared.module';
|
||||
|
@ -92,7 +92,7 @@ export class AddonBlockRecentlyAccessedItemsComponent extends CoreBlockBaseCompo
|
|||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
const url = CoreTextUtils.decodeHTMLEntities(item.viewurl);
|
||||
const url = CoreText.decodeHTMLEntities(item.viewurl);
|
||||
const modal = await CoreLoadings.show();
|
||||
|
||||
try {
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
import { Component, Input, Output, EventEmitter, OnInit } from '@angular/core';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreLoadings } from '@services/loadings';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreEnrolledCourseDataWithOptions } from '@features/courses/services/courses-helper';
|
||||
import { AddonBlockTimelineDayEvents } from '@addons/block/timeline/classes/section';
|
||||
import { CoreSharedModule } from '@/core/shared.module';
|
||||
|
@ -64,7 +64,7 @@ export class AddonBlockTimelineEventsComponent implements OnInit {
|
|||
event.stopPropagation();
|
||||
|
||||
// Fix URL format.
|
||||
url = CoreTextUtils.decodeHTMLEntities(url);
|
||||
url = CoreText.decodeHTMLEntities(url);
|
||||
|
||||
const modal = await CoreLoadings.show();
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
|
|||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreFileHelper } from '@services/file-helper';
|
||||
import { CoreUrl } from '@singletons/url';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreArray } from '@singletons/array';
|
||||
|
@ -212,7 +212,7 @@ export class AddonBlogIndexPage implements OnInit, OnDestroy {
|
|||
entry.contextInstanceId = entry.userid;
|
||||
}
|
||||
|
||||
entry.summary = CoreTextUtils.replacePluginfileUrls(entry.summary, entry.summaryfiles || []);
|
||||
entry.summary = CoreFileHelper.replacePluginfileUrls(entry.summary, entry.summaryfiles || []);
|
||||
|
||||
entry.user = await CoreUtils.ignoreErrors(CoreUser.getProfile(entry.userid, entry.courseid, true));
|
||||
});
|
||||
|
|
|
@ -25,7 +25,7 @@ import { AddonCalendarSync, AddonCalendarSyncEvents, AddonCalendarSyncProvider }
|
|||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreCourse } from '@features/course/services/course';
|
||||
import { CoreTimeUtils } from '@services/utils/time';
|
||||
|
@ -45,6 +45,7 @@ import { CoreConfig } from '@services/config';
|
|||
import { CoreToasts, ToastDuration } from '@services/toasts';
|
||||
import { CorePopovers } from '@services/popovers';
|
||||
import { CoreLoadings } from '@services/loadings';
|
||||
import { CoreUrl } from '@singletons/url';
|
||||
|
||||
/**
|
||||
* Page that displays a single calendar event.
|
||||
|
@ -288,8 +289,8 @@ export class AddonCalendarEventPage implements OnInit, OnDestroy {
|
|||
|
||||
if (this.event.location) {
|
||||
// Build a link to open the address in maps.
|
||||
this.event.location = CoreTextUtils.decodeHTML(this.event.location);
|
||||
this.event.encodedLocation = CoreTextUtils.buildAddressURL(this.event.location);
|
||||
this.event.location = CoreText.decodeHTML(this.event.location);
|
||||
this.event.encodedLocation = CoreUrl.buildAddressURL(this.event.location);
|
||||
}
|
||||
|
||||
// Check if event was deleted in offine.
|
||||
|
|
|
@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
|
|||
import { CoreSites } from '@services/sites';
|
||||
import { CoreSite } from '@classes/sites/site';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreTimeUtils } from '@services/utils/time';
|
||||
import { CoreUrl } from '@singletons/url';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
|
@ -330,7 +330,7 @@ export class AddonCalendarProvider {
|
|||
): Promise<string> {
|
||||
|
||||
const getTimeHtml = (time: string, a11yLangKey: string): string =>
|
||||
`<span aria-label="${Translate.instant(a11yLangKey, { $a: CoreTextUtils.cleanTags(time) })}">${time}</span>`;
|
||||
`<span aria-label="${Translate.instant(a11yLangKey, { $a: CoreText.cleanTags(time) })}">${time}</span>`;
|
||||
const getStartTimeHtml = (time: string): string => getTimeHtml(time, 'core.startingtime');
|
||||
const getEndTimeHtml = (time: string): string => getTimeHtml(time, 'core.endingtime');
|
||||
|
||||
|
@ -666,18 +666,18 @@ export class AddonCalendarProvider {
|
|||
eventConverted.iscategoryevent = originalEvent.eventtype == AddonCalendarEventType.CATEGORY;
|
||||
eventConverted.normalisedeventtype = this.getEventType(recordAsRecord);
|
||||
try {
|
||||
eventConverted.category = CoreTextUtils.parseJSON(recordAsRecord.category || '');
|
||||
eventConverted.category = CoreText.parseJSON(recordAsRecord.category || '');
|
||||
} catch {
|
||||
// Ignore errors.
|
||||
}
|
||||
|
||||
try {
|
||||
eventConverted.course = CoreTextUtils.parseJSON(recordAsRecord.course || '');
|
||||
eventConverted.course = CoreText.parseJSON(recordAsRecord.course || '');
|
||||
} catch {
|
||||
// Ignore errors.
|
||||
}
|
||||
try {
|
||||
eventConverted.subscription = CoreTextUtils.parseJSON(recordAsRecord.subscription || '');
|
||||
eventConverted.subscription = CoreText.parseJSON(recordAsRecord.subscription || '');
|
||||
} catch {
|
||||
// Ignore errors.
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ import { CoreFilterDefaultHandler } from '@features/filter/services/handlers/def
|
|||
import { CoreFilterFilter, CoreFilterFormatTextOptions } from '@features/filter/services/filter';
|
||||
import { CoreLang } from '@services/lang';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreEvents } from '@singletons/events';
|
||||
import { CoreSite } from '@classes/sites/site';
|
||||
|
@ -189,7 +189,7 @@ export class AddonFilterMathJaxLoaderHandlerService extends CoreFilterDefaultHan
|
|||
* @returns The whole text with the span inserted around the defined substring.
|
||||
*/
|
||||
protected insertSpan(text: string, start: number, end: number): string {
|
||||
return CoreTextUtils.substrReplace(
|
||||
return CoreText.substrReplace(
|
||||
text,
|
||||
'<span class="nolink">' + text.substring(start, end + 1) + '</span>',
|
||||
start,
|
||||
|
|
|
@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
|
|||
import { CorePromisedValue } from '@classes/promised-value';
|
||||
import { CoreExternalContentDirective } from '@directives/external-content';
|
||||
import { CoreLang } from '@services/lang';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreUrl } from '@singletons/url';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { CoreDirectivesRegistry } from '@singletons/directives-registry';
|
||||
|
@ -64,7 +64,7 @@ export class AddonFilterMediaPluginVideoJSService {
|
|||
// Create player.
|
||||
const videojs = await this.getVideoJS();
|
||||
const dataSetupString = element.getAttribute('data-setup') || element.getAttribute('data-setup-lazy') || '{}';
|
||||
const data = CoreTextUtils.parseJSON<VideoJSOptions>(dataSetupString, {});
|
||||
const data = CoreText.parseJSON<VideoJSOptions>(dataSetupString, {});
|
||||
const player = videojs(
|
||||
element,
|
||||
{
|
||||
|
@ -106,7 +106,7 @@ export class AddonFilterMediaPluginVideoJSService {
|
|||
}
|
||||
|
||||
const dataSetupString = video.getAttribute('data-setup') || video.getAttribute('data-setup-lazy') || '{}';
|
||||
const data = CoreTextUtils.parseJSON<VideoJSOptions>(dataSetupString, {});
|
||||
const data = CoreText.parseJSON<VideoJSOptions>(dataSetupString, {});
|
||||
const youtubeUrl = data.techOrder?.[0] == 'youtube' && CoreUrl.getYoutubeEmbedUrl(data.sources?.[0]?.src);
|
||||
|
||||
if (!youtubeUrl) {
|
||||
|
|
|
@ -32,7 +32,6 @@ import { AddonMessagesSync, AddonMessagesSyncProvider } from '../../services/mes
|
|||
import { CoreUser } from '@features/user/services/user';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreLogger } from '@singletons/logger';
|
||||
import { CoreInfiniteLoadingComponent } from '@components/infinite-loading/infinite-loading';
|
||||
import { Md5 } from 'ts-md5/dist/md5';
|
||||
|
@ -928,7 +927,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView
|
|||
*/
|
||||
copyMessage(message: AddonMessagesConversationMessageFormatted): void {
|
||||
const text = 'smallmessage' in message ? message.smallmessage || message.text || '' : message.text || '';
|
||||
CoreText.copyToClipboard(CoreTextUtils.decodeHTMLEntities(text));
|
||||
CoreText.copyToClipboard(CoreText.decodeHTMLEntities(text));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -27,7 +27,7 @@ import { CoreDomUtils } from '@services/utils/dom';
|
|||
import { CoreConstants } from '@/core/constants';
|
||||
import { AddonNotificationsPreferencesNotificationProcessorState } from '@addons/notifications/services/notifications';
|
||||
import { CorePlatform } from '@services/platform';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreErrorHelper } from '@services/error-helper';
|
||||
import { CoreLoadings } from '@services/loadings';
|
||||
|
||||
/**
|
||||
|
@ -112,7 +112,7 @@ export class AddonMessagesSettingsPage implements OnInit, OnDestroy {
|
|||
this.warningMessage.set(undefined);
|
||||
} catch (error) {
|
||||
if (error.errorcode === 'nopermissions') {
|
||||
this.warningMessage.set(CoreTextUtils.getErrorMessageFromError(error));
|
||||
this.warningMessage.set(CoreErrorHelper.getErrorMessageFromError(error));
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import {
|
||||
AddonMessagesOfflineConversationMessagesDBRecord,
|
||||
AddonMessagesOfflineMessagesDBRecord,
|
||||
|
@ -227,7 +227,7 @@ export class AddonMessagesOfflineProvider {
|
|||
text: message.text,
|
||||
timecreated: message.timecreated,
|
||||
deviceoffline: message.deviceoffline,
|
||||
conversation: message.conversation ? CoreTextUtils.parseJSON(message.conversation, undefined) : undefined,
|
||||
conversation: message.conversation ? CoreText.parseJSON(message.conversation, undefined) : undefined,
|
||||
pending: true,
|
||||
useridfrom: userIdFrom,
|
||||
};
|
||||
|
|
|
@ -30,9 +30,9 @@ import { CoreNetwork } from '@services/network';
|
|||
import { CoreConstants } from '@/core/constants';
|
||||
import { CoreUser } from '@features/user/services/user';
|
||||
import { CoreError } from '@classes/errors/error';
|
||||
import { CoreTextErrorObject, CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
|
||||
import { CoreWait } from '@singletons/wait';
|
||||
import { CoreErrorHelper, CoreErrorObject } from '@services/error-helper';
|
||||
|
||||
/**
|
||||
* Service to sync messages.
|
||||
|
@ -178,7 +178,7 @@ export class AddonMessagesSyncProvider extends CoreSyncBaseProvider<AddonMessage
|
|||
|
||||
const groupMessagingEnabled = AddonMessages.isGroupMessagingEnabled();
|
||||
let messages: AddonMessagesOfflineAnyMessagesFormatted[];
|
||||
const errors: (string | CoreError | CoreTextErrorObject)[] = [];
|
||||
const errors: (string | CoreError | CoreErrorObject)[] = [];
|
||||
|
||||
if (conversationId) {
|
||||
this.logger.debug(`Try to sync conversation '${conversationId}'`);
|
||||
|
@ -336,7 +336,7 @@ export class AddonMessagesSyncProvider extends CoreSyncBaseProvider<AddonMessage
|
|||
protected async handleSyncErrors(
|
||||
conversationId?: number,
|
||||
userId?: number,
|
||||
errors: (string | CoreError | CoreTextErrorObject)[] = [],
|
||||
errors: (string | CoreError | CoreErrorObject)[] = [],
|
||||
warnings: string[] = [],
|
||||
): Promise<void> {
|
||||
if (!errors || errors.length <= 0) {
|
||||
|
@ -356,7 +356,7 @@ export class AddonMessagesSyncProvider extends CoreSyncBaseProvider<AddonMessage
|
|||
errors.forEach((error) => {
|
||||
warnings.push(Translate.instant('addon.messages.warningconversationmessagenotsent', {
|
||||
conversation: conversationIdentifier,
|
||||
error: CoreTextUtils.getErrorMessageFromError(error),
|
||||
error: CoreErrorHelper.getErrorMessageFromError(error),
|
||||
}));
|
||||
});
|
||||
} else if (userId) {
|
||||
|
@ -373,7 +373,7 @@ export class AddonMessagesSyncProvider extends CoreSyncBaseProvider<AddonMessage
|
|||
errors.forEach((error) => {
|
||||
warnings.push(Translate.instant('addon.messages.warningmessagenotsent', {
|
||||
user: userIdentifier,
|
||||
error: CoreTextUtils.getErrorMessageFromError(error),
|
||||
error: CoreErrorHelper.getErrorMessageFromError(error),
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ import { CoreMenuItem, CoreUtils } from '@services/utils/utils';
|
|||
import { AddonModAssignHelper, AddonModAssignSubmissionFormatted } from '../../services/assign-helper';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { Translate } from '@singletons';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreCourse, CoreCourseModuleGradeInfo, CoreCourseModuleGradeOutcome } from '@features/course/services/course';
|
||||
import { AddonModAssignOffline } from '../../services/assign-offline';
|
||||
import { CoreUser, CoreUserProfile } from '@features/user/services/user';
|
||||
|
@ -1078,7 +1078,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can
|
|||
if (!grade.outcomeid && !grade.scaleid) {
|
||||
|
||||
// Clean HTML tags, grade can contain an icon.
|
||||
const gradeFormatted = CoreTextUtils.cleanTags(grade.gradeformatted || '');
|
||||
const gradeFormatted = CoreText.cleanTags(grade.gradeformatted || '');
|
||||
// Not using outcomes or scale, get the numeric grade.
|
||||
if (this.grade.scale) {
|
||||
this.grade.gradebookGrade = CoreUtils.formatFloat(
|
||||
|
@ -1099,7 +1099,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can
|
|||
gradeInfo.outcomes?.forEach((outcome) => {
|
||||
if (outcome.id == String(grade.outcomeid)) {
|
||||
// Clean HTML tags, grade can contain an icon.
|
||||
outcome.selected = CoreTextUtils.cleanTags(grade.gradeformatted || '');
|
||||
outcome.selected = CoreText.cleanTags(grade.gradeformatted || '');
|
||||
outcome.modified = grade.gradedategraded;
|
||||
if (outcome.options) {
|
||||
outcome.selectedId = CoreGradesHelper.getGradeValueFromLabel(outcome.options, outcome.selected);
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
import { Component, OnInit, ElementRef } from '@angular/core';
|
||||
import { FormBuilder, FormControl } from '@angular/forms';
|
||||
import { AddonModAssign } from '@addons/mod/assign/services/assign';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreFileHelper } from '@services/file-helper';
|
||||
import {
|
||||
AddonModAssignFeedbackCommentsDraftData,
|
||||
AddonModAssignFeedbackCommentsHandler,
|
||||
|
@ -159,7 +159,7 @@ export class AddonModAssignFeedbackCommentsComponent extends AddonModAssignFeedb
|
|||
replacePluginfileUrls(text: string): string {
|
||||
const files = this.plugin.fileareas && this.plugin.fileareas[0] && this.plugin.fileareas[0].files;
|
||||
|
||||
return CoreTextUtils.replacePluginfileUrls(text, files || []);
|
||||
return CoreFileHelper.replacePluginfileUrls(text, files || []);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,11 +24,12 @@ import { AddonModAssignOffline } from '@addons/mod/assign/services/assign-offlin
|
|||
import { AddonModAssignFeedbackHandler } from '@addons/mod/assign/services/feedback-delegate';
|
||||
import { Injectable, Type } from '@angular/core';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreWSFile } from '@services/ws';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { AddonModAssignFeedbackCommentsComponent } from '../component/comments';
|
||||
import { CoreFileHelper } from '@services/file-helper';
|
||||
|
||||
/**
|
||||
* Handler for comments feedback plugin.
|
||||
|
@ -56,7 +57,7 @@ export class AddonModAssignFeedbackCommentsHandlerService implements AddonModAss
|
|||
|
||||
const files = plugin.fileareas && plugin.fileareas[0] ? plugin.fileareas[0].files : [];
|
||||
|
||||
return CoreTextUtils.restorePluginfileUrls(inputData.assignfeedbackcomments_editor, files || []);
|
||||
return CoreFileHelper.restorePluginfileUrls(inputData.assignfeedbackcomments_editor, files || []);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -180,7 +181,7 @@ export class AddonModAssignFeedbackCommentsHandlerService implements AddonModAss
|
|||
|
||||
if (draft) {
|
||||
// Add some HTML to the text if needed.
|
||||
draft.text = CoreTextUtils.formatHtmlLines(draft.text);
|
||||
draft.text = CoreText.formatHtmlLines(draft.text);
|
||||
|
||||
pluginData.assignfeedbackcomments_editor = draft;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ import { CoreError } from '@classes/errors/error';
|
|||
import { SQLiteDBRecordValues } from '@classes/sqlitedb';
|
||||
import { CoreFile } from '@services/file';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreTimeUtils } from '@services/utils/time';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { CorePath } from '@singletons/path';
|
||||
|
@ -137,7 +137,7 @@ export class AddonModAssignOfflineProvider {
|
|||
assignid: submission.assignid,
|
||||
userid: submission.userid,
|
||||
courseid: submission.courseid,
|
||||
plugindata: CoreTextUtils.parseJSON<AddonModAssignSavePluginData>(submission.plugindata, {}),
|
||||
plugindata: CoreText.parseJSON<AddonModAssignSavePluginData>(submission.plugindata, {}),
|
||||
onlinetimemodified: submission.onlinetimemodified,
|
||||
timecreated: submission.timecreated,
|
||||
timemodified: submission.timemodified,
|
||||
|
@ -195,8 +195,8 @@ export class AddonModAssignOfflineProvider {
|
|||
addattempt: submission.addattempt,
|
||||
workflowstate: submission.workflowstate,
|
||||
applytoall: submission.applytoall,
|
||||
outcomes: CoreTextUtils.parseJSON<AddonModAssignOutcomes>(submission.outcomes, {}),
|
||||
plugindata: CoreTextUtils.parseJSON<AddonModAssignSavePluginData>(submission.plugindata, {}),
|
||||
outcomes: CoreText.parseJSON<AddonModAssignOutcomes>(submission.outcomes, {}),
|
||||
plugindata: CoreText.parseJSON<AddonModAssignSavePluginData>(submission.plugindata, {}),
|
||||
timemodified: submission.timemodified,
|
||||
}));
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ import { CoreInterceptor } from '@classes/interceptor';
|
|||
import { CoreWSExternalWarning, CoreWSExternalFile, CoreWSFile } from '@services/ws';
|
||||
import { makeSingleton, Translate } from '@singletons';
|
||||
import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreGrades } from '@features/grades/services/grades';
|
||||
import { CoreTimeUtils } from '@services/utils/time';
|
||||
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
||||
|
@ -431,7 +430,7 @@ export class AddonModAssignProvider {
|
|||
});
|
||||
|
||||
if (!keepUrls && submissionPlugin.fileareas && submissionPlugin.fileareas[0]) {
|
||||
text = CoreTextUtils.replacePluginfileUrls(text, submissionPlugin.fileareas[0].files || []);
|
||||
text = CoreFileHelper.replacePluginfileUrls(text, submissionPlugin.fileareas[0].files || []);
|
||||
}
|
||||
|
||||
return text;
|
||||
|
|
|
@ -18,7 +18,7 @@ import { AddonModAssignOffline } from '@addons/mod/assign/services/assign-offlin
|
|||
import { Component, OnInit, ElementRef } from '@angular/core';
|
||||
import { FormBuilder, FormControl } from '@angular/forms';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { AddonModAssignSubmissionOnlineTextPluginData } from '../services/handler';
|
||||
import { ContextLevel } from '@/core/constants';
|
||||
|
@ -102,7 +102,7 @@ export class AddonModAssignSubmissionOnlineTextComponent extends AddonModAssignS
|
|||
|
||||
// Calculate initial words.
|
||||
if (this.wordLimitEnabled) {
|
||||
this.words = CoreTextUtils.countWords(this.text);
|
||||
this.words = CoreText.countWords(this.text);
|
||||
}
|
||||
} finally {
|
||||
this.loaded = true;
|
||||
|
@ -123,7 +123,7 @@ export class AddonModAssignSubmissionOnlineTextComponent extends AddonModAssignS
|
|||
// Wait before calculating, if the user keeps inputing we won't calculate.
|
||||
// This is to prevent slowing down devices, this calculation can be slow if the text is long.
|
||||
this.wordCountTimeout = window.setTimeout(() => {
|
||||
this.words = CoreTextUtils.countWords(text);
|
||||
this.words = CoreText.countWords(text);
|
||||
}, 1500);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import { AddonModAssignSubmissionHandler } from '@addons/mod/assign/services/sub
|
|||
import { Injectable, Type } from '@angular/core';
|
||||
import { CoreError } from '@classes/errors/error';
|
||||
import { CoreFileHelper } from '@services/file-helper';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreWSFile } from '@services/ws';
|
||||
import { makeSingleton, Translate } from '@singletons';
|
||||
|
@ -139,7 +139,7 @@ export class AddonModAssignSubmissionOnlineTextHandlerService implements AddonMo
|
|||
const text = inputData.onlinetext_editor_text;
|
||||
const files = plugin.fileareas && plugin.fileareas[0] && plugin.fileareas[0].files || [];
|
||||
|
||||
return CoreTextUtils.restorePluginfileUrls(text, files || []);
|
||||
return CoreFileHelper.restorePluginfileUrls(text, files || []);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -198,7 +198,7 @@ export class AddonModAssignSubmissionOnlineTextHandlerService implements AddonMo
|
|||
// Check word limit.
|
||||
const configs = AddonModAssignHelper.getPluginConfig(assign, 'assignsubmission', plugin.type);
|
||||
if (parseInt(configs.wordlimitenabled, 10)) {
|
||||
const words = CoreTextUtils.countWords(text);
|
||||
const words = CoreText.countWords(text);
|
||||
const wordlimit = parseInt(configs.wordlimit, 10);
|
||||
if (words > wordlimit) {
|
||||
const params = { $a: { count: words, limit: wordlimit } };
|
||||
|
@ -209,7 +209,7 @@ export class AddonModAssignSubmissionOnlineTextHandlerService implements AddonMo
|
|||
}
|
||||
|
||||
// Add some HTML to the text if needed.
|
||||
text = CoreTextUtils.formatHtmlLines(text);
|
||||
text = CoreText.formatHtmlLines(text);
|
||||
|
||||
pluginData.onlinetext_editor = {
|
||||
text: text,
|
||||
|
|
|
@ -21,7 +21,7 @@ import { CoreApp } from '@services/app';
|
|||
import { CoreGroupInfo, CoreGroups } from '@services/groups';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreTimeUtils } from '@services/utils/time';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { Translate } from '@singletons';
|
||||
|
@ -185,7 +185,7 @@ export class AddonModBBBIndexComponent extends CoreCourseModuleMainActivityCompo
|
|||
});
|
||||
|
||||
return {
|
||||
name: CoreTextUtils.cleanTags(String(recordingData.recording), { singleLine: true }),
|
||||
name: CoreText.cleanTags(String(recordingData.recording), { singleLine: true }),
|
||||
playbackLabel: columns.playback.label,
|
||||
playbacks,
|
||||
details,
|
||||
|
|
|
@ -20,7 +20,7 @@ import { CoreSite } from '@classes/sites/site';
|
|||
import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
|
||||
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
||||
import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
|
||||
import { makeSingleton, Translate } from '@singletons';
|
||||
|
@ -247,7 +247,7 @@ export class AddonModBBBService {
|
|||
|
||||
return {
|
||||
...result.tabledata,
|
||||
parsedData: CoreTextUtils.parseJSON(result.tabledata?.data, []),
|
||||
parsedData: CoreText.parseJSON(result.tabledata?.data, []),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import { CoreTag, CoreTagItem } from '@features/tag/services/tag';
|
|||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreErrorHelper } from '@services/error-helper';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { Translate } from '@singletons';
|
||||
import {
|
||||
|
@ -385,7 +385,7 @@ class AddonModBookSlidesItemsManagerSource extends CoreSwipeSlidesItemsManagerSo
|
|||
|
||||
return newChapters;
|
||||
} catch (error) {
|
||||
if (!CoreTextUtils.getErrorMessageFromError(error)) {
|
||||
if (!CoreErrorHelper.getErrorMessageFromError(error)) {
|
||||
throw new CoreError(Translate.instant('addon.mod_book.errorchapter'));
|
||||
}
|
||||
|
||||
|
|
|
@ -22,12 +22,13 @@ import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
|||
import { CoreCourse, CoreCourseModuleContentFile } from '@features/course/services/course';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreFilepool } from '@services/filepool';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreFile } from '@services/file';
|
||||
import { CoreError } from '@classes/errors/error';
|
||||
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
|
||||
import { ADDON_MOD_BOOK_COMPONENT } from '../constants';
|
||||
import { CoreUrl } from '@singletons/url';
|
||||
|
||||
/**
|
||||
* Service that provides some features for books.
|
||||
|
@ -177,7 +178,7 @@ export class AddonModBookProvider {
|
|||
key = content.filepath.replace('/' + chapter + '/', '') + content.filename;
|
||||
}
|
||||
|
||||
map[chapter].paths[CoreTextUtils.decodeURIComponent(key)] = content.fileurl;
|
||||
map[chapter].paths[CoreUrl.decodeURIComponent(key)] = content.fileurl;
|
||||
});
|
||||
|
||||
return map;
|
||||
|
@ -224,7 +225,7 @@ export class AddonModBookProvider {
|
|||
return [];
|
||||
}
|
||||
|
||||
return CoreTextUtils.parseJSON(contents[0].content, []);
|
||||
return CoreText.parseJSON(contents[0].content, []);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { AddonModChoiceResponsesDBRecord, RESPONSES_TABLE_NAME } from './database/choice';
|
||||
|
||||
|
@ -101,7 +101,7 @@ export class AddonModChoiceOfflineProvider {
|
|||
protected parseResponse(entry: AddonModChoiceResponsesDBRecord): AddonModChoiceOfflineResponses {
|
||||
return {
|
||||
...entry,
|
||||
responses: CoreTextUtils.parseJSON(entry.responses, <number[]> []),
|
||||
responses: CoreText.parseJSON(entry.responses, <number[]> []),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ import { FormGroup, FormBuilder } from '@angular/forms';
|
|||
import { CoreTag } from '@features/tag/services/tag';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreFormFields, CoreForms } from '@singletons/form';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { ModalController } from '@singletons';
|
||||
import {
|
||||
|
@ -78,7 +78,7 @@ export class AddonModDataSearchModalComponent implements OnInit {
|
|||
this.search.advanced?.forEach((field) => {
|
||||
if (field !== undefined) {
|
||||
this.advancedIndexed[field.name] = field.value
|
||||
? CoreTextUtils.parseJSON(field.value, '')
|
||||
? CoreText.parseJSON(field.value, '')
|
||||
: '';
|
||||
}
|
||||
});
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
import { Component } from '@angular/core';
|
||||
import { AddonModDataFieldPluginBaseComponent } from '../../../classes/base-field-plugin-component';
|
||||
import { AddonModDataEntryField } from '@addons/mod/data/services/data';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreFileHelper } from '@services/file-helper';
|
||||
import { CoreWSFile } from '@services/ws';
|
||||
import { ADDON_MOD_DATA_COMPONENT } from '@addons/mod/data/constants';
|
||||
|
||||
|
@ -40,7 +40,7 @@ export class AddonModDataFieldTextareaComponent extends AddonModDataFieldPluginB
|
|||
format(value?: Partial<AddonModDataEntryField>): string {
|
||||
const files: CoreWSFile[] = (value && <CoreWSFile[]>value.files) || [];
|
||||
|
||||
return value ? CoreTextUtils.replacePluginfileUrls(value.content || '', files) : '';
|
||||
return value ? CoreFileHelper.replacePluginfileUrls(value.content || '', files) : '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,13 +15,14 @@
|
|||
import { AddonModDataEntryField, AddonModDataField, AddonModDataSubfieldData } from '@addons/mod/data/services/data';
|
||||
import { Injectable, Type } from '@angular/core';
|
||||
import { CoreFormFields } from '@singletons/form';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreWSFile } from '@services/ws';
|
||||
import { makeSingleton, Translate } from '@singletons';
|
||||
import { AddonModDataFieldTextHandlerService } from '../../text/services/handler';
|
||||
import { AddonModDataFieldTextareaComponent } from '../component/textarea';
|
||||
import { CoreFileEntry } from '@services/file-helper';
|
||||
import { CoreFileEntry, CoreFileHelper } from '@services/file-helper';
|
||||
import type { AddonModDataFieldPluginBaseComponent } from '@addons/mod/data/classes/base-field-plugin-component';
|
||||
import { CoreDom } from '@singletons/dom';
|
||||
|
||||
/**
|
||||
* Handler for textarea data field plugin.
|
||||
|
@ -50,12 +51,12 @@ export class AddonModDataFieldTextareaHandlerService extends AddonModDataFieldTe
|
|||
const fieldName = 'f_' + field.id;
|
||||
const files = this.getFieldEditFiles(field, inputData, originalFieldData);
|
||||
|
||||
let text = CoreTextUtils.restorePluginfileUrls(inputData[fieldName] || '', <CoreWSFile[]> files);
|
||||
let text = CoreFileHelper.restorePluginfileUrls(inputData[fieldName] || '', <CoreWSFile[]> files);
|
||||
// Add some HTML to the text if needed.
|
||||
text = CoreTextUtils.formatHtmlLines(text);
|
||||
text = CoreText.formatHtmlLines(text);
|
||||
|
||||
// WS does not properly check if HTML content is blank when the field is required.
|
||||
if (CoreTextUtils.htmlIsBlank(text)) {
|
||||
if (CoreDom.htmlIsBlank(text)) {
|
||||
text = '';
|
||||
}
|
||||
|
||||
|
@ -102,7 +103,7 @@ export class AddonModDataFieldTextareaHandlerService extends AddonModDataFieldTe
|
|||
|
||||
const value = inputData.find((value) => value.subfield == '');
|
||||
|
||||
if (!value || CoreTextUtils.htmlIsBlank(<string>value.value || '')) {
|
||||
if (!value || CoreDom.htmlIsBlank(<string>value.value || '')) {
|
||||
return Translate.instant('addon.mod_data.errormustsupplyvalue');
|
||||
}
|
||||
|
||||
|
@ -115,7 +116,7 @@ export class AddonModDataFieldTextareaHandlerService extends AddonModDataFieldTe
|
|||
originalContent.content = offlineContent[''] || '';
|
||||
if (originalContent.content.length > 0 && originalContent.files && originalContent.files.length > 0) {
|
||||
// Take the original files since we cannot edit them on the app.
|
||||
originalContent.content = CoreTextUtils.replacePluginfileUrls(
|
||||
originalContent.content = CoreFileHelper.replacePluginfileUrls(
|
||||
originalContent.content,
|
||||
<CoreWSFile[]> originalContent.files,
|
||||
);
|
||||
|
|
|
@ -40,7 +40,7 @@ import {
|
|||
import { AddonModDataHelper } from '../../services/data-helper';
|
||||
import { CoreDom } from '@singletons/dom';
|
||||
import { AddonModDataEntryFieldInitialized } from '../../classes/base-field-plugin-component';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreTime } from '@singletons/time';
|
||||
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
|
||||
import { ADDON_MOD_DATA_COMPONENT, ADDON_MOD_DATA_ENTRY_CHANGED, AddonModDataTemplateType } from '../../constants';
|
||||
|
@ -395,7 +395,7 @@ export class AddonModDataEditPage implements OnInit {
|
|||
if (updateEntryResult.generalnotifications?.length) {
|
||||
CoreDomUtils.showAlertWithOptions({
|
||||
header: Translate.instant('core.notice'),
|
||||
message: CoreTextUtils.buildMessage(updateEntryResult.generalnotifications),
|
||||
message: CoreText.buildMessage(updateEntryResult.generalnotifications),
|
||||
buttons: [Translate.instant('core.ok')],
|
||||
});
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ import { FileEntry } from '@awesome-cordova-plugins/file/ngx';
|
|||
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreFormFields } from '@singletons/form';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { makeSingleton, Translate } from '@singletons';
|
||||
import { CoreEvents } from '@singletons/events';
|
||||
|
@ -97,9 +97,9 @@ export class AddonModDataHelperProvider {
|
|||
|
||||
if (offlineContent.subfield) {
|
||||
offlineContents[offlineContent.fieldid][offlineContent.subfield] =
|
||||
CoreTextUtils.parseJSON(offlineContent.value, '');
|
||||
CoreText.parseJSON(offlineContent.value, '');
|
||||
} else {
|
||||
offlineContents[offlineContent.fieldid][''] = CoreTextUtils.parseJSON(offlineContent.value, '');
|
||||
offlineContents[offlineContent.fieldid][''] = CoreText.parseJSON(offlineContent.value, '');
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
|
|||
import { CoreFileUploader, CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader';
|
||||
import { CoreFile } from '@services/file';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { CorePath } from '@singletons/path';
|
||||
|
@ -90,7 +90,7 @@ export class AddonModDataOfflineProvider {
|
|||
const promises: Promise<void>[] = [];
|
||||
|
||||
entry.fields.forEach((field) => {
|
||||
const value = CoreTextUtils.parseJSON<CoreFileUploaderStoreFilesResult | null>(field.value, null);
|
||||
const value = CoreText.parseJSON<CoreFileUploaderStoreFilesResult | null>(field.value, null);
|
||||
|
||||
if (!value || !value.offline) {
|
||||
return;
|
||||
|
@ -234,7 +234,7 @@ export class AddonModDataOfflineProvider {
|
|||
*/
|
||||
protected parseRecord(record: AddonModDataEntryDBRecord): AddonModDataOfflineAction {
|
||||
return Object.assign(record, {
|
||||
fields: CoreTextUtils.parseJSON<AddonModDataEntryWSField[]>(record.fields),
|
||||
fields: CoreText.parseJSON<AddonModDataEntryWSField[]>(record.fields),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import { CoreNetwork } from '@services/network';
|
|||
import { CoreFileEntry } from '@services/file-helper';
|
||||
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreSync, CoreSyncResult } from '@services/sync';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreErrorHelper } from '@services/error-helper';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { Translate, makeSingleton } from '@singletons';
|
||||
import { CoreEvents } from '@singletons/events';
|
||||
|
@ -33,6 +33,7 @@ import { AddonModData, AddonModDataData } from './data';
|
|||
import { AddonModDataHelper } from './data-helper';
|
||||
import { AddonModDataOffline, AddonModDataOfflineAction } from './data-offline';
|
||||
import { ADDON_MOD_DATA_AUTO_SYNCED, ADDON_MOD_DATA_COMPONENT, AddonModDataAction } from '../constants';
|
||||
import { CoreText } from '@singletons/text';
|
||||
|
||||
/**
|
||||
* Service to sync databases.
|
||||
|
@ -326,7 +327,7 @@ export class AddonModDataSyncProvider extends CoreCourseActivitySyncBaseProvider
|
|||
} catch (error) {
|
||||
if (error && CoreUtils.isWebServiceError(error)) {
|
||||
// The WebService has thrown an error, this means it cannot be performed. Discard.
|
||||
entryResult.discardError = CoreTextUtils.getErrorMessageFromError(error);
|
||||
entryResult.discardError = CoreErrorHelper.getErrorMessageFromError(error);
|
||||
} else {
|
||||
// Couldn't connect to server, reject.
|
||||
throw error;
|
||||
|
@ -345,7 +346,7 @@ export class AddonModDataSyncProvider extends CoreCourseActivitySyncBaseProvider
|
|||
try {
|
||||
await Promise.all(editAction.fields.map(async (field) => {
|
||||
// Upload Files if asked.
|
||||
const value = CoreTextUtils.parseJSON<CoreFileUploaderStoreFilesResult | null>(field.value || '', null);
|
||||
const value = CoreText.parseJSON<CoreFileUploaderStoreFilesResult | null>(field.value || '', null);
|
||||
if (value && (value.online || value.offline)) {
|
||||
let files: CoreFileEntry[] = value.online || [];
|
||||
|
||||
|
@ -384,7 +385,7 @@ export class AddonModDataSyncProvider extends CoreCourseActivitySyncBaseProvider
|
|||
} catch (error) {
|
||||
if (error && CoreUtils.isWebServiceError(error)) {
|
||||
// The WebService has thrown an error, this means it cannot be performed. Discard.
|
||||
entryResult.discardError = CoreTextUtils.getErrorMessageFromError(error);
|
||||
entryResult.discardError = CoreErrorHelper.getErrorMessageFromError(error);
|
||||
} else {
|
||||
// Couldn't connect to server, reject.
|
||||
throw error;
|
||||
|
@ -402,7 +403,7 @@ export class AddonModDataSyncProvider extends CoreCourseActivitySyncBaseProvider
|
|||
} catch (error) {
|
||||
if (error && CoreUtils.isWebServiceError(error)) {
|
||||
// The WebService has thrown an error, this means it cannot be performed. Discard.
|
||||
entryResult.discardError = CoreTextUtils.getErrorMessageFromError(error);
|
||||
entryResult.discardError = CoreErrorHelper.getErrorMessageFromError(error);
|
||||
} else {
|
||||
// Couldn't connect to server, reject.
|
||||
throw error;
|
||||
|
|
|
@ -20,7 +20,7 @@ import { CoreCourseContentsPage } from '@features/course/pages/contents/contents
|
|||
import { IonContent } from '@ionic/angular';
|
||||
import { CoreGroupInfo, CoreGroups } from '@services/groups';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreTimeUtils } from '@services/utils/time';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||
|
@ -312,7 +312,7 @@ export class AddonModFeedbackIndexComponent extends CoreCourseModuleMainActivity
|
|||
|
||||
case 'info':
|
||||
item.data = <string[]> item.data.map((dataItem) => {
|
||||
const parsed = <Record<string, string>> CoreTextUtils.parseJSON(dataItem);
|
||||
const parsed = <Record<string, string>> CoreText.parseJSON(dataItem);
|
||||
|
||||
return parsed.show !== undefined ? parsed.show : false;
|
||||
}).filter((dataItem) => dataItem); // Filter false entries.
|
||||
|
@ -325,7 +325,7 @@ export class AddonModFeedbackIndexComponent extends CoreCourseModuleMainActivity
|
|||
case 'multichoicerated':
|
||||
case 'multichoice': {
|
||||
const parsedData = <Record<string, string | number>[]> item.data.map((dataItem) => {
|
||||
const parsed = <Record<string, string | number>> CoreTextUtils.parseJSON(dataItem);
|
||||
const parsed = <Record<string, string | number>> CoreText.parseJSON(dataItem);
|
||||
|
||||
return parsed.answertext !== undefined ? parsed : false;
|
||||
}).filter((dataItem) => dataItem); // Filter false entries.
|
||||
|
|
|
@ -18,7 +18,7 @@ import { CoreRoutedItemsManagerSourcesTracker } from '@classes/items-management/
|
|||
import { CoreSwipeNavigationItemsManager } from '@classes/items-management/swipe-navigation-items-manager';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreFileHelper } from '@services/file-helper';
|
||||
import { AddonModFeedbackAttemptsSource } from '../../classes/feedback-attempts-source';
|
||||
import {
|
||||
AddonModFeedback,
|
||||
|
@ -140,7 +140,7 @@ export class AddonModFeedbackAttemptPage implements OnInit, OnDestroy {
|
|||
const attemptItem = <AddonModFeedbackAttemptItem> formItem;
|
||||
|
||||
if (item.typ == 'label') {
|
||||
attemptItem.submittedValue = CoreTextUtils.replacePluginfileUrls(item.presentation, item.itemfiles);
|
||||
attemptItem.submittedValue = CoreFileHelper.replacePluginfileUrls(item.presentation, item.itemfiles);
|
||||
} else {
|
||||
for (const x in attempt.responses) {
|
||||
if (attempt.responses[x].id == item.id) {
|
||||
|
|
|
@ -18,7 +18,7 @@ import { CoreUser } from '@features/user/services/user';
|
|||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreFileHelper } from '@services/file-helper';
|
||||
import { CoreTimeUtils } from '@services/utils/time';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { makeSingleton, Translate } from '@singletons';
|
||||
|
@ -41,6 +41,7 @@ import {
|
|||
ADDON_MOD_FEEDBACK_PAGE_NAME,
|
||||
} from '../constants';
|
||||
import { CoreLoadings } from '@services/loadings';
|
||||
import { CoreText } from '@singletons/text';
|
||||
|
||||
const MODE_RESPONSETIME = 1;
|
||||
const MODE_COURSE = 2;
|
||||
|
@ -253,7 +254,7 @@ export class AddonModFeedbackHelperProvider {
|
|||
*/
|
||||
protected getItemFormLabel(item: AddonModFeedbackItem): AddonModFeedbackFormBasicItem {
|
||||
item.name = '';
|
||||
item.presentation = CoreTextUtils.replacePluginfileUrls(item.presentation, item.itemfiles);
|
||||
item.presentation = CoreFileHelper.replacePluginfileUrls(item.presentation, item.itemfiles);
|
||||
|
||||
return Object.assign(item, {
|
||||
templateName: 'label',
|
||||
|
@ -421,7 +422,7 @@ export class AddonModFeedbackHelperProvider {
|
|||
slottedLabel: false,
|
||||
});
|
||||
|
||||
const data = <string[]> CoreTextUtils.parseJSON(item.otherdata);
|
||||
const data = <string[]> CoreText.parseJSON(item.otherdata);
|
||||
if (data && data.length > 3) {
|
||||
formItem.captcha = {
|
||||
recaptchapublickey: data[3],
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreTimeUtils } from '@services/utils/time';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { AddonModFeedbackResponseDBRecord, FEEDBACK_TABLE_NAME } from './database/feedback';
|
||||
|
@ -116,7 +116,7 @@ export class AddonModFeedbackOfflineProvider {
|
|||
*/
|
||||
protected parseResponse(record: AddonModFeedbackResponseDBRecord): AddonModFeedbackOfflineResponse {
|
||||
return Object.assign(record, {
|
||||
responses: <Record<string, AddonModFeedbackResponseValue>> CoreTextUtils.parseJSON(record.responses),
|
||||
responses: <Record<string, AddonModFeedbackResponseValue>> CoreText.parseJSON(record.responses),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ import { Translate } from '@singletons';
|
|||
import { CoreFileUploader } from '@features/fileuploader/services/fileuploader';
|
||||
import { AddonModForumSync } from '../../services/forum-sync';
|
||||
import { CoreSync } from '@services/sync';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { AddonModForumHelper } from '../../services/forum-helper';
|
||||
import { AddonModForumOffline } from '../../services/forum-offline';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
|
@ -370,7 +370,7 @@ export class AddonModForumPostComponent implements OnInit, OnDestroy, OnChanges
|
|||
const modal = await CoreLoadings.show('core.sending', true);
|
||||
|
||||
// Add some HTML to the message if needed.
|
||||
message = CoreTextUtils.formatHtmlLines(message);
|
||||
message = CoreText.formatHtmlLines(message);
|
||||
|
||||
// Upload attachments first if any.
|
||||
let attachments;
|
||||
|
|
|
@ -34,7 +34,7 @@ import { AddonModForumDiscussionOptions, AddonModForumOffline } from '@addons/mo
|
|||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { AddonModForumHelper } from '@addons/mod/forum/services/forum-helper';
|
||||
import { CoreFileUploader } from '@features/fileuploader/services/fileuploader';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CanLeave } from '@guards/can-leave';
|
||||
import { CoreSplitViewComponent } from '@components/split-view/split-view';
|
||||
import { CoreForms } from '@singletons/form';
|
||||
|
@ -553,7 +553,7 @@ export class AddonModForumNewDiscussionPage implements OnInit, OnDestroy, CanLea
|
|||
const modal = await CoreLoadings.show('core.sending', true);
|
||||
|
||||
// Add some HTML to the message if needed.
|
||||
message = CoreTextUtils.formatHtmlLines(message);
|
||||
message = CoreText.formatHtmlLines(message);
|
||||
|
||||
if (pin) {
|
||||
options.discussionpinned = true;
|
||||
|
|
|
@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
|
|||
import { CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader';
|
||||
import { CoreFile } from '@services/file';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import {
|
||||
AddonModForumOfflineDiscussionDBRecord,
|
||||
|
@ -399,7 +399,7 @@ export class AddonModForumOfflineProvider {
|
|||
R extends { options: string },
|
||||
O extends Record<string, unknown> = Record<string, unknown>
|
||||
>(record: R): Omit<R, 'options'> & { options: O } {
|
||||
record.options = CoreTextUtils.parseJSON(record.options);
|
||||
record.options = CoreText.parseJSON(record.options);
|
||||
|
||||
return record as unknown as Omit<R, 'options'> & { options: O };
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@features/
|
|||
import { CoreConstants, ModPurpose } from '@/core/constants';
|
||||
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
|
||||
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreUser } from '@features/user/services/user';
|
||||
import { ADDON_MOD_FORUM_MARK_READ_EVENT, ADDON_MOD_FORUM_PAGE_NAME } from '../../constants';
|
||||
|
||||
|
@ -57,7 +57,7 @@ export class AddonModForumModuleHandlerService extends CoreModuleHandlerBase imp
|
|||
const data = await super.getData(module, courseId);
|
||||
|
||||
const customData = module.customdata ?
|
||||
CoreTextUtils.parseJSON<{ trackingtype?: string | number } | ''>(module.customdata, {}) : {};
|
||||
CoreText.parseJSON<{ trackingtype?: string | number } | ''>(module.customdata, {}) : {};
|
||||
const trackingType = typeof customData !== 'string' && customData.trackingtype !== undefined ?
|
||||
Number(customData.trackingtype) : undefined;
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ import { IonContent } from '@ionic/angular';
|
|||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { Translate } from '@singletons';
|
||||
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||
import {
|
||||
|
@ -312,7 +312,7 @@ export class AddonModGlossaryIndexComponent extends CoreCourseModuleMainActivity
|
|||
// Consider it is 'letter_all'.
|
||||
const getDivider = (entry) => {
|
||||
// Try to get the first letter without HTML tags.
|
||||
const noTags = CoreTextUtils.cleanTags(entry.concept);
|
||||
const noTags = CoreText.cleanTags(entry.concept);
|
||||
|
||||
return (noTags || entry.concept).substring(0, 1).toUpperCase();
|
||||
};
|
||||
|
|
|
@ -24,7 +24,7 @@ import { CoreNavigator } from '@services/navigator';
|
|||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { Translate } from '@singletons';
|
||||
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||
|
@ -472,7 +472,7 @@ class AddonModGlossaryOfflineFormHandler extends AddonModGlossaryFormHandler {
|
|||
const originalData = this.page.originalData;
|
||||
const data = this.page.data;
|
||||
const options = this.getSaveOptions(glossary);
|
||||
const definition = CoreTextUtils.formatHtmlLines(data.definition);
|
||||
const definition = CoreText.formatHtmlLines(data.definition);
|
||||
|
||||
if (!originalData) {
|
||||
return;
|
||||
|
@ -561,7 +561,7 @@ class AddonModGlossaryNewFormHandler extends AddonModGlossaryFormHandler {
|
|||
): Promise<void> {
|
||||
const data = this.page.data;
|
||||
const options = this.getSaveOptions(glossary);
|
||||
const definition = CoreTextUtils.formatHtmlLines(data.definition);
|
||||
const definition = CoreText.formatHtmlLines(data.definition);
|
||||
|
||||
await this.checkDuplicates(glossary);
|
||||
await AddonModGlossaryOffline.addOfflineEntry(
|
||||
|
@ -594,7 +594,7 @@ class AddonModGlossaryNewFormHandler extends AddonModGlossaryFormHandler {
|
|||
): Promise<number | false> {
|
||||
const data = this.page.data;
|
||||
const options = this.getSaveOptions(glossary);
|
||||
const definition = CoreTextUtils.formatHtmlLines(data.definition);
|
||||
const definition = CoreText.formatHtmlLines(data.definition);
|
||||
const entryId = await AddonModGlossary.addEntry(
|
||||
glossary.id,
|
||||
data.concept,
|
||||
|
@ -674,7 +674,7 @@ class AddonModGlossaryOnlineFormHandler extends AddonModGlossaryFormHandler {
|
|||
|
||||
const data = this.page.data;
|
||||
const options = this.getSaveOptions(glossary);
|
||||
const definition = CoreTextUtils.formatHtmlLines(data.definition);
|
||||
const definition = CoreText.formatHtmlLines(data.definition);
|
||||
|
||||
// Upload attachments, if any.
|
||||
let attachmentsId: number | undefined = undefined;
|
||||
|
|
|
@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
|
|||
import { CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader';
|
||||
import { CoreFile } from '@services/file';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { CoreEvents } from '@singletons/events';
|
||||
import { CorePath } from '@singletons/path';
|
||||
|
@ -269,9 +269,9 @@ export class AddonModGlossaryOfflineProvider {
|
|||
*/
|
||||
protected parseRecord(record: AddonModGlossaryOfflineEntryDBRecord): AddonModGlossaryOfflineEntry {
|
||||
return Object.assign(record, {
|
||||
options: <Record<string, AddonModGlossaryEntryOption>> CoreTextUtils.parseJSON(record.options),
|
||||
options: <Record<string, AddonModGlossaryEntryOption>> CoreText.parseJSON(record.options),
|
||||
attachments: record.attachments ?
|
||||
<CoreFileUploaderStoreFilesResult> CoreTextUtils.parseJSON(record.attachments) : undefined,
|
||||
<CoreFileUploaderStoreFilesResult> CoreText.parseJSON(record.attachments) : undefined,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ import {
|
|||
AddonModH5PActivitySyncResult,
|
||||
} from '../../services/h5pactivity-sync';
|
||||
import { CoreFileHelper } from '@services/file-helper';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import {
|
||||
ADDON_MOD_H5PACTIVITY_AUTO_SYNCED,
|
||||
|
@ -269,7 +269,7 @@ export class AddonModH5PActivityIndexComponent extends CoreCourseModuleMainActiv
|
|||
return;
|
||||
}
|
||||
|
||||
const contentStateObj = CoreTextUtils.parseJSON<{h5p: string}>(contentState, { h5p: '{}' });
|
||||
const contentStateObj = CoreText.parseJSON<{h5p: string}>(contentState, { h5p: '{}' });
|
||||
|
||||
// The H5P state doesn't always use JSON, so an h5p property was added to jsonize it.
|
||||
this.contentState = contentStateObj.h5p ?? '{}';
|
||||
|
|
|
@ -31,7 +31,7 @@ import {
|
|||
AddonModH5PActivityData,
|
||||
} from './h5pactivity';
|
||||
import { CoreXAPIStateDBRecord, CoreXAPIStatementDBRecord } from '@features/xapi/services/database/xapi';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreErrorHelper } from '@services/error-helper';
|
||||
import { CoreXAPIIRI } from '@features/xapi/classes/iri';
|
||||
import { CoreXAPIItemAgent } from '@features/xapi/classes/item-agent';
|
||||
import { CoreWSError } from '@classes/errors/wserror';
|
||||
|
@ -196,7 +196,7 @@ export class AddonModH5PActivitySyncProvider extends CoreCourseActivitySyncBaseP
|
|||
} catch (error) {
|
||||
if (
|
||||
CoreUtils.isWebServiceError(error) ||
|
||||
CoreTextUtils.getErrorMessageFromError(error) === Translate.instant('core.course.modulenotfound')
|
||||
CoreErrorHelper.getErrorMessageFromError(error) === Translate.instant('core.course.modulenotfound')
|
||||
) {
|
||||
// Activity no longer accessible. Delete the data and finish the sync.
|
||||
await deleteOfflineData();
|
||||
|
|
|
@ -23,7 +23,7 @@ import { CoreCourseModulePrefetchDelegate } from '@features/course/services/modu
|
|||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreErrorHelper } from '@services/error-helper';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { Translate } from '@singletons';
|
||||
import { AddonModImscp, AddonModImscpImscp, AddonModImscpTocItem } from '../../services/imscp';
|
||||
|
@ -124,7 +124,7 @@ export class AddonModImscpViewPage implements OnInit {
|
|||
}
|
||||
|
||||
if (downloadResult?.failed) {
|
||||
const error = CoreTextUtils.getErrorMessageFromError(downloadResult.error) || downloadResult.error;
|
||||
const error = CoreErrorHelper.getErrorMessageFromError(downloadResult.error) || downloadResult.error;
|
||||
this.warning = Translate.instant('core.errordownloadingsomefiles') + (error ? ' ' + error : '');
|
||||
} else {
|
||||
this.warning = '';
|
||||
|
|
|
@ -21,7 +21,7 @@ import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
|||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreFilepool } from '@services/filepool';
|
||||
import { CoreSitesCommonWSOptions, CoreSites } from '@services/sites';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
|
||||
import { makeSingleton, Translate } from '@singletons';
|
||||
|
@ -48,7 +48,7 @@ export class AddonModImscpProvider {
|
|||
return [];
|
||||
}
|
||||
|
||||
return CoreTextUtils.parseJSON<AddonModImscpTocItemTree[]>(contents[0].content || '');
|
||||
return CoreText.parseJSON<AddonModImscpTocItemTree[]>(contents[0].content || '');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,7 +24,7 @@ import { CoreGroupInfo, CoreGroups } from '@services/groups';
|
|||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreForms } from '@singletons/form';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||
import { AddonModLessonRetakeFinishedInSyncDBRecord } from '../../services/database/lesson';
|
||||
|
@ -550,20 +550,20 @@ export class AddonModLessonIndexComponent extends CoreCourseModuleMainActivityCo
|
|||
|
||||
if (formattedData.lessonscored) {
|
||||
if (formattedData.numofattempts && formattedData.avescore != null) {
|
||||
formattedData.avescore = CoreTextUtils.roundToDecimals(formattedData.avescore, 2);
|
||||
formattedData.avescore = CoreText.roundToDecimals(formattedData.avescore, 2);
|
||||
}
|
||||
if (formattedData.highscore != null) {
|
||||
formattedData.highscore = CoreTextUtils.roundToDecimals(formattedData.highscore, 2);
|
||||
formattedData.highscore = CoreText.roundToDecimals(formattedData.highscore, 2);
|
||||
}
|
||||
if (formattedData.lowscore != null) {
|
||||
formattedData.lowscore = CoreTextUtils.roundToDecimals(formattedData.lowscore, 2);
|
||||
formattedData.lowscore = CoreText.roundToDecimals(formattedData.lowscore, 2);
|
||||
}
|
||||
}
|
||||
|
||||
if (formattedData.students) {
|
||||
// Get the user data for each student returned.
|
||||
await CoreUtils.allPromises(formattedData.students.map(async (student) => {
|
||||
student.bestgrade = CoreTextUtils.roundToDecimals(student.bestgrade, 2);
|
||||
student.bestgrade = CoreText.roundToDecimals(student.bestgrade, 2);
|
||||
|
||||
const user = await CoreUtils.ignoreErrors(CoreUser.getProfile(student.id, this.courseId, true));
|
||||
if (user) {
|
||||
|
|
|
@ -19,7 +19,7 @@ import { CoreUser } from '@features/user/services/user';
|
|||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { Translate } from '@singletons';
|
||||
import {
|
||||
|
@ -145,7 +145,7 @@ export class AddonModLessonUserRetakePage implements OnInit {
|
|||
throw new CoreError(Translate.instant('addon.mod_lesson.cannotfindattempt'));
|
||||
}
|
||||
|
||||
student.bestgrade = CoreTextUtils.roundToDecimals(student.bestgrade, 2);
|
||||
student.bestgrade = CoreText.roundToDecimals(student.bestgrade, 2);
|
||||
student.attempts.forEach((retake) => {
|
||||
if (!this.selectedRetake && this.retakeNumber == retake.try) {
|
||||
// The retake specified as parameter exists. Use it.
|
||||
|
@ -222,7 +222,7 @@ export class AddonModLessonUserRetakePage implements OnInit {
|
|||
|
||||
if (formattedData.userstats.gradeinfo) {
|
||||
// Completed.
|
||||
formattedData.userstats.grade = CoreTextUtils.roundToDecimals(formattedData.userstats.grade, 2);
|
||||
formattedData.userstats.grade = CoreText.roundToDecimals(formattedData.userstats.grade, 2);
|
||||
this.timeTakenReadable = CoreTime.formatTime(formattedData.userstats.timetotake);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
|
|||
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreFormFields } from '@singletons/form';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreTimeUtils } from '@services/utils/time';
|
||||
import { makeSingleton, Translate } from '@singletons';
|
||||
import {
|
||||
|
@ -567,7 +567,7 @@ export class AddonModLessonHelperProvider {
|
|||
|
||||
// Add some HTML to the answer if needed.
|
||||
if (textarea) {
|
||||
data[textarea.name] = CoreTextUtils.formatHtmlLines(<string> data[textarea.name] || '');
|
||||
data[textarea.name] = CoreText.formatHtmlLines(<string> data[textarea.name] || '');
|
||||
}
|
||||
} else if (question.template == 'multichoice' && (<AddonModLessonMultichoiceQuestion> question).multi) {
|
||||
// Only send the options with value set to true.
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreFormFields } from '@singletons/form';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreTimeUtils } from '@services/utils/time';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { makeSingleton } from '@singletons';
|
||||
|
@ -454,8 +454,8 @@ export class AddonModLessonOfflineProvider {
|
|||
protected parsePageAttempt(attempt: AddonModLessonPageAttemptDBRecord): AddonModLessonPageAttemptRecord {
|
||||
return {
|
||||
...attempt,
|
||||
data: attempt.data ? CoreTextUtils.parseJSON(attempt.data) : null,
|
||||
useranswer: attempt.useranswer ? CoreTextUtils.parseJSON(attempt.useranswer) : null,
|
||||
data: attempt.data ? CoreText.parseJSON(attempt.data) : null,
|
||||
useranswer: attempt.useranswer ? CoreText.parseJSON(attempt.useranswer) : null,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
|
|||
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
||||
import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
|
||||
import { makeSingleton, Translate } from '@singletons';
|
||||
|
@ -90,7 +90,7 @@ export class AddonModLessonProvider {
|
|||
className: string,
|
||||
): string {
|
||||
// Add a table row containing the answer.
|
||||
feedback += '<tr><td class="cell c0 lastcol">' + (answerFormat ? answer : CoreTextUtils.cleanTags(answer)) +
|
||||
feedback += '<tr><td class="cell c0 lastcol">' + (answerFormat ? answer : CoreText.cleanTags(answer)) +
|
||||
'</td></tr>';
|
||||
|
||||
// If the response exists, add a table row containing the response. If not, add en empty row.
|
||||
|
@ -301,7 +301,7 @@ export class AddonModLessonProvider {
|
|||
}
|
||||
|
||||
// Progress calculation as a percent.
|
||||
return CoreTextUtils.roundToDecimals(viewedPagesIds.length / Object.keys(validPages).length, 2) * 100;
|
||||
return CoreText.roundToDecimals(viewedPagesIds.length / Object.keys(validPages).length, 2) * 100;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -482,7 +482,7 @@ export class AddonModLessonProvider {
|
|||
return;
|
||||
}
|
||||
|
||||
value = CoreTextUtils.decodeHTML(value);
|
||||
value = CoreText.decodeHTML(value);
|
||||
userResponse.push(value);
|
||||
|
||||
if (answers[id] !== undefined) {
|
||||
|
@ -747,7 +747,7 @@ export class AddonModLessonProvider {
|
|||
}
|
||||
} else {
|
||||
expectedAnswer = expectedAnswer.replace('*', '#####');
|
||||
expectedAnswer = CoreTextUtils.escapeForRegex(expectedAnswer);
|
||||
expectedAnswer = CoreText.escapeForRegex(expectedAnswer);
|
||||
expectedAnswer = expectedAnswer.replace('#####', '.*');
|
||||
}
|
||||
|
||||
|
@ -830,7 +830,7 @@ export class AddonModLessonProvider {
|
|||
this.checkOtherAnswers(lesson, pageData, result);
|
||||
|
||||
result.userresponse = studentAnswer;
|
||||
result.studentanswer = CoreTextUtils.s(studentAnswer); // Clean student answer as it goes to output.
|
||||
result.studentanswer = CoreText.s(studentAnswer); // Clean student answer as it goes to output.
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -981,7 +981,7 @@ export class AddonModLessonProvider {
|
|||
response.data.forEach((entry) => {
|
||||
if (entry.value && typeof entry.value == 'string' && entry.value !== '1') {
|
||||
// It's a JSON encoded object. Try to decode it.
|
||||
entry.value = CoreTextUtils.parseJSON(entry.value);
|
||||
entry.value = CoreText.parseJSON(entry.value);
|
||||
}
|
||||
|
||||
map[entry.name] = entry;
|
||||
|
@ -1108,7 +1108,7 @@ export class AddonModLessonProvider {
|
|||
}
|
||||
|
||||
if (lesson.grade !== undefined && lesson.grade !== CoreGradeType.NONE) {
|
||||
entryData.grade = CoreTextUtils.roundToDecimals(gradeInfo.grade * lesson.grade / 100, 1);
|
||||
entryData.grade = CoreText.roundToDecimals(gradeInfo.grade * lesson.grade / 100, 1);
|
||||
entryData.total = lesson.grade;
|
||||
this.addResultValueEolPage(result, 'yourcurrentgradeisoutof', entryData, true);
|
||||
}
|
||||
|
@ -1904,7 +1904,7 @@ export class AddonModLessonProvider {
|
|||
|
||||
if (lesson.grade !== undefined && lesson.grade !== CoreGradeType.NONE) {
|
||||
this.addMessage(messages, 'addon.mod_lesson.yourcurrentgradeisoutof', { $a: {
|
||||
grade: CoreTextUtils.roundToDecimals(gradeInfo.grade * lesson.grade / 100, 1),
|
||||
grade: CoreText.roundToDecimals(gradeInfo.grade * lesson.grade / 100, 1),
|
||||
total: lesson.grade,
|
||||
} });
|
||||
}
|
||||
|
@ -2920,7 +2920,7 @@ export class AddonModLessonProvider {
|
|||
}
|
||||
|
||||
if (result.total) { // Not zero.
|
||||
result.grade = CoreTextUtils.roundToDecimals(result.earned * 100 / result.total, 5);
|
||||
result.grade = CoreText.roundToDecimals(result.earned * 100 / result.total, 5);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
@ -21,7 +21,7 @@ import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
|||
import { CoreFile } from '@services/file';
|
||||
import { CorePlatform } from '@services/platform';
|
||||
import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreUrl } from '@singletons/url';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
|
||||
|
@ -64,9 +64,9 @@ export class AddonModLtiProvider {
|
|||
if (p.name == 'ext_submit') {
|
||||
text += ' <input type="submit"';
|
||||
} else {
|
||||
text += ' <input type="hidden" name="' + CoreTextUtils.escapeHTML(p.name) + '"';
|
||||
text += ' <input type="hidden" name="' + CoreText.escapeHTML(p.name) + '"';
|
||||
}
|
||||
text += ' value="' + CoreTextUtils.escapeHTML(p.value) + '"/>\n';
|
||||
text += ' value="' + CoreText.escapeHTML(p.value) + '"/>\n';
|
||||
});
|
||||
text += '</form>\n';
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
import { Component, OnInit, Optional } from '@angular/core';
|
||||
import { CoreCourseModuleMainResourceComponent } from '@features/course/classes/main-resource-component';
|
||||
import { CoreCourseContentsPage } from '@features/course/pages/contents/contents';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { AddonModPagePage, AddonModPage } from '../../services/page';
|
||||
import { AddonModPageHelper } from '../../services/page-helper';
|
||||
|
@ -89,7 +89,7 @@ export class AddonModPageIndexComponent extends CoreCourseModuleMainResourceComp
|
|||
// Check if description and timemodified should be displayed.
|
||||
if (this.page.displayoptions) {
|
||||
const options: Record<string, string | boolean> =
|
||||
CoreTextUtils.unserialize(this.page.displayoptions) || {};
|
||||
CoreText.unserialize(this.page.displayoptions) || {};
|
||||
|
||||
this.displayDescription = options.printintro === undefined ||
|
||||
CoreUtils.isTrueOrOne(options.printintro);
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreError } from '@classes/errors/error';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreUrl } from '@singletons/url';
|
||||
import { CoreFile } from '@services/file';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreFilepool } from '@services/filepool';
|
||||
|
@ -54,7 +54,7 @@ export class AddonModPageHelperProvider {
|
|||
// Add the folders without the leading slash.
|
||||
key = content.filepath.substring(1) + key;
|
||||
}
|
||||
paths[CoreTextUtils.decodeURIComponent(key)] = url;
|
||||
paths[CoreUrl.decodeURIComponent(key)] = url;
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import { CoreQuestionBehaviourDelegate } from '@features/question/services/behav
|
|||
import { IonContent } from '@ionic/angular';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { Translate } from '@singletons';
|
||||
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||
|
@ -192,7 +192,7 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp
|
|||
|
||||
if (warnings?.length) {
|
||||
// Show warnings and delete them so they aren't shown again.
|
||||
CoreDomUtils.showErrorModal(CoreTextUtils.buildMessage(warnings));
|
||||
CoreDomUtils.showErrorModal(CoreText.buildMessage(warnings));
|
||||
|
||||
await AddonModQuizSync.setSyncWarnings(quiz.id, []);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import { CoreCourses } from '@features/courses/services/courses';
|
|||
import { CoreQuestionHelper } from '@features/question/services/question-helper';
|
||||
import { CoreFilepool } from '@services/filepool';
|
||||
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreWSFile } from '@services/ws';
|
||||
import { makeSingleton } from '@singletons';
|
||||
|
@ -334,7 +334,7 @@ export class AddonModQuizPrefetchHandlerService extends CoreCourseActivityPrefet
|
|||
if (canStart && (!attempt || AddonModQuiz.isAttemptCompleted(attempt.state))) {
|
||||
// Check if the user can attempt the quiz.
|
||||
if (attemptAccessInfo.preventnewattemptreasons.length) {
|
||||
throw new CoreError(CoreTextUtils.buildMessage(attemptAccessInfo.preventnewattemptreasons));
|
||||
throw new CoreError(CoreText.buildMessage(attemptAccessInfo.preventnewattemptreasons));
|
||||
}
|
||||
|
||||
startAttempt = true;
|
||||
|
|
|
@ -24,7 +24,7 @@ import { CoreFileHelper } from '@services/file-helper';
|
|||
import { CoreSites } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreMimetypeUtils } from '@services/utils/mimetype';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreUtils, OpenFileAction } from '@services/utils/utils';
|
||||
import { NgZone, Translate } from '@singletons';
|
||||
import { Subscription } from 'rxjs';
|
||||
|
@ -118,7 +118,7 @@ export class AddonModResourceIndexComponent extends CoreCourseModuleMainResource
|
|||
const resource = await AddonModResource.getResourceData(this.courseId, this.module.id);
|
||||
this.description = resource.intro || '';
|
||||
const options: AddonModResourceCustomData =
|
||||
resource.displayoptions ? CoreTextUtils.unserialize(resource.displayoptions) : {};
|
||||
resource.displayoptions ? CoreText.unserialize(resource.displayoptions) : {};
|
||||
|
||||
this.displayDescription = options.printintro === undefined || !!options.printintro;
|
||||
this.dataRetrieved.emit(resource);
|
||||
|
@ -172,11 +172,11 @@ export class AddonModResourceIndexComponent extends CoreCourseModuleMainResource
|
|||
|
||||
if ('contentsinfo' in this.module && this.module.contentsinfo) {
|
||||
mimetype = this.module.contentsinfo.mimetypes[0];
|
||||
this.readableSize = CoreTextUtils.bytesToSize(this.module.contentsinfo.filessize, 1);
|
||||
this.readableSize = CoreText.bytesToSize(this.module.contentsinfo.filessize, 1);
|
||||
this.timemodified = this.module.contentsinfo.lastmodified * 1000;
|
||||
} else {
|
||||
mimetype = await CoreUtils.getMimeTypeFromUrl(CoreFileHelper.getFileUrl(contents[0]));
|
||||
this.readableSize = CoreTextUtils.bytesToSize(contents[0].filesize, 1);
|
||||
this.readableSize = CoreText.bytesToSize(contents[0].filesize, 1);
|
||||
this.timemodified = contents[0].timemodified * 1000;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ import { makeSingleton, Translate } from '@singletons';
|
|||
import { CorePath } from '@singletons/path';
|
||||
import { AddonModResource, AddonModResourceCustomData } from './resource';
|
||||
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreTimeUtils } from '@services/utils/time';
|
||||
import { ADDON_MOD_RESOURCE_COMPONENT } from '../constants';
|
||||
import { CoreLoadings } from '@services/loadings';
|
||||
|
@ -235,15 +235,15 @@ export class AddonModResourceHelperProvider {
|
|||
*/
|
||||
protected async getModuleOptions(module: CoreCourseModuleData, courseId: number): Promise<AddonModResourceCustomData> {
|
||||
if (module.customdata !== undefined) {
|
||||
const customData: { displayoptions: string } | string = CoreTextUtils.parseJSON(module.customdata);
|
||||
const customData: { displayoptions: string } | string = CoreText.parseJSON(module.customdata);
|
||||
const displayOptions = typeof customData === 'object' ? customData.displayoptions : customData;
|
||||
|
||||
return CoreTextUtils.unserialize(displayOptions);
|
||||
return CoreText.unserialize(displayOptions);
|
||||
}
|
||||
|
||||
// Get the resource data. Legacy version (from 3.5 to 3.6.6)
|
||||
const info = await AddonModResource.getResourceData(courseId, module.id);
|
||||
const options: AddonModResourceCustomData = CoreTextUtils.unserialize(info.displayoptions);
|
||||
const options: AddonModResourceCustomData = CoreText.unserialize(info.displayoptions);
|
||||
|
||||
if (!module.contents?.[0] || options.filedetails !== undefined) {
|
||||
// Contents attribute should be loaded at this point and it's needed to get mainFile.
|
||||
|
@ -303,7 +303,7 @@ export class AddonModResourceHelperProvider {
|
|||
const extra: string[] = [];
|
||||
|
||||
if (options.showsize && details.size) {
|
||||
extra.push(CoreTextUtils.bytesToSize(details.size, 1));
|
||||
extra.push(CoreText.bytesToSize(details.size, 1));
|
||||
}
|
||||
|
||||
if (options.showtype) {
|
||||
|
|
|
@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
|
|||
import { CoreUser } from '@features/user/services/user';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreSync } from '@services/sync';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreTimeUtils } from '@services/utils/time';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { makeSingleton } from '@singletons';
|
||||
|
@ -297,7 +297,7 @@ export class AddonModScormOfflineProvider {
|
|||
|
||||
case 'cmi.core.score.raw':
|
||||
case 'cmi.score.raw':
|
||||
formatted.score_raw = CoreTextUtils.roundToDecimals(Number(value), 2); // Round to 2 decimals max.
|
||||
formatted.score_raw = CoreText.roundToDecimals(Number(value), 2); // Round to 2 decimals max.
|
||||
break;
|
||||
|
||||
case 'cmi.core.session_time':
|
||||
|
@ -813,7 +813,7 @@ export class AddonModScormOfflineProvider {
|
|||
protected parseAttempt(attempt: AddonModScormAttemptDBRecord): AddonModScormOfflineAttempt {
|
||||
return {
|
||||
...attempt,
|
||||
snapshot: attempt.snapshot ? CoreTextUtils.parseJSON(attempt.snapshot) : null,
|
||||
snapshot: attempt.snapshot ? CoreText.parseJSON(attempt.snapshot) : null,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -826,7 +826,7 @@ export class AddonModScormOfflineProvider {
|
|||
protected parseTracks(tracks: AddonModScormTrackDBRecord[]): AddonModScormOfflineTrack[] {
|
||||
return tracks.map((track) => ({
|
||||
...track,
|
||||
value: track.value ? CoreTextUtils.parseJSON(track.value) : null,
|
||||
value: track.value ? CoreText.parseJSON(track.value) : null,
|
||||
}));
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
|||
import { CoreFilepool } from '@services/filepool';
|
||||
import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreSync } from '@services/sync';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreTimeUtils } from '@services/utils/time';
|
||||
import { CoreUrl } from '@singletons/url';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
|
@ -400,7 +400,7 @@ export class AddonModScormProvider {
|
|||
if (scorm.grademethod !== AddonModScormGradingMethod.GRADESCOES && scorm.maxgrade) {
|
||||
grade = (grade / scorm.maxgrade) * 100;
|
||||
|
||||
return Translate.instant('core.percentagenumber', { $a: CoreTextUtils.roundToDecimals(grade, 2) });
|
||||
return Translate.instant('core.percentagenumber', { $a: CoreText.roundToDecimals(grade, 2) });
|
||||
}
|
||||
|
||||
return String(grade);
|
||||
|
|
|
@ -20,7 +20,7 @@ import { CoreCourseContentsPage } from '@features/course/pages/contents/contents
|
|||
import { IonContent } from '@ionic/angular';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { Translate } from '@singletons';
|
||||
import { CoreEvents } from '@singletons/events';
|
||||
import { getPrefetchHandlerInstance } from '../../services/handlers/prefetch';
|
||||
|
@ -156,7 +156,7 @@ export class AddonModSurveyIndexComponent extends CoreCourseModuleMainActivityCo
|
|||
|
||||
if (question.multiArray && !question.multiArray.length && question.parent === 0 && question.type > 0) {
|
||||
// Options shown in a select. Remove all HTML.
|
||||
question.optionsArray = question.optionsArray?.map((option) => CoreTextUtils.cleanTags(option));
|
||||
question.optionsArray = question.optionsArray?.map((option) => CoreText.cleanTags(option));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { AddonModSurveyAnswersDBRecord, SURVEY_TABLE } from './database/survey';
|
||||
import { AddonModSurveySubmitAnswerData } from './survey';
|
||||
|
@ -51,7 +51,7 @@ export class AddonModSurveyOfflineProvider {
|
|||
const entries = await site.getDb().getAllRecords<AddonModSurveyAnswersDBRecord>(SURVEY_TABLE);
|
||||
|
||||
return entries.map((entry) => Object.assign(entry, {
|
||||
answers: CoreTextUtils.parseJSON<AddonModSurveySubmitAnswerData[]>(entry.answers),
|
||||
answers: CoreText.parseJSON<AddonModSurveySubmitAnswerData[]>(entry.answers),
|
||||
}));
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ export class AddonModSurveyOfflineProvider {
|
|||
);
|
||||
|
||||
return Object.assign(entry, {
|
||||
answers: CoreTextUtils.parseJSON<AddonModSurveySubmitAnswerData[]>(entry.answers),
|
||||
answers: CoreText.parseJSON<AddonModSurveySubmitAnswerData[]>(entry.answers),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ import { CoreCourseModuleMainResourceComponent } from '@features/course/classes/
|
|||
import { CoreCourseContentsPage } from '@features/course/pages/contents/contents';
|
||||
import { CoreCourse } from '@features/course/services/course';
|
||||
import { CoreMimetypeUtils } from '@services/utils/mimetype';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { AddonModUrl, AddonModUrlDisplayOptions, AddonModUrlUrl } from '../../services/url';
|
||||
import { AddonModUrlHelper } from '../../services/url-helper';
|
||||
import { ADDON_MOD_URL_COMPONENT } from '../../constants';
|
||||
|
@ -90,7 +90,7 @@ export class AddonModUrlIndexComponent extends CoreCourseModuleMainResourceCompo
|
|||
this.dataRetrieved.emit(url);
|
||||
|
||||
if (url.displayoptions) {
|
||||
const unserialized = CoreTextUtils.unserialize<AddonModUrlDisplayOptions>(url.displayoptions);
|
||||
const unserialized = CoreText.unserialize<AddonModUrlDisplayOptions>(url.displayoptions);
|
||||
this.displayDescription = unserialized.printintro === undefined || !!unserialized.printintro;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ import { CoreNavigator } from '@services/navigator';
|
|||
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreSync } from '@services/sync';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreWSFile } from '@services/ws';
|
||||
import { Translate } from '@singletons';
|
||||
|
@ -33,6 +33,7 @@ import { AddonModWikiSync } from '../../services/wiki-sync';
|
|||
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
|
||||
import { ADDON_MOD_WIKI_COMPONENT, ADDON_MOD_WIKI_PAGE_CREATED_EVENT, ADDON_MOD_WIKI_RENEW_LOCK_TIME } from '../../constants';
|
||||
import { CoreLoadings } from '@services/loadings';
|
||||
import { CoreFileHelper } from '@services/file-helper';
|
||||
|
||||
/**
|
||||
* Page that allows adding or editing a wiki page.
|
||||
|
@ -94,7 +95,7 @@ export class AddonModWikiEditPage implements OnInit, OnDestroy, CanLeave {
|
|||
this.userId = CoreNavigator.getRouteNumberParam('userId');
|
||||
|
||||
const pageTitle = CoreNavigator.getRouteParam<string>('pageTitle');
|
||||
this.originalTitle = pageTitle ? CoreTextUtils.cleanTags(pageTitle.replace(/\+/g, ' '), { singleLine: true }) : '';
|
||||
this.originalTitle = pageTitle ? CoreText.cleanTags(pageTitle.replace(/\+/g, ' '), { singleLine: true }) : '';
|
||||
|
||||
this.canEditTitle = !this.originalTitle;
|
||||
this.title = this.originalTitle ?
|
||||
|
@ -182,7 +183,7 @@ export class AddonModWikiEditPage implements OnInit, OnDestroy, CanLeave {
|
|||
const editContents = await AddonModWiki.getPageForEditing(this.pageId, this.section);
|
||||
|
||||
// Get the original page contents, treating file URLs if needed.
|
||||
const content = CoreTextUtils.replacePluginfileUrls(editContents.content || '', this.subwikiFiles);
|
||||
const content = CoreFileHelper.replacePluginfileUrls(editContents.content || '', this.subwikiFiles);
|
||||
|
||||
this.contentControl.setValue(content);
|
||||
this.originalContent = content;
|
||||
|
@ -365,8 +366,8 @@ export class AddonModWikiEditPage implements OnInit, OnDestroy, CanLeave {
|
|||
|
||||
const modal = await CoreLoadings.show('core.sending', true);
|
||||
|
||||
text = CoreTextUtils.restorePluginfileUrls(text, this.subwikiFiles);
|
||||
text = CoreTextUtils.formatHtmlLines(text);
|
||||
text = CoreFileHelper.restorePluginfileUrls(text, this.subwikiFiles);
|
||||
text = CoreText.formatHtmlLines(text);
|
||||
|
||||
try {
|
||||
if (this.editing && this.pageId) {
|
||||
|
|
|
@ -22,7 +22,6 @@ import { CoreFileSession } from '@services/file-session';
|
|||
import { CoreSites } from '@services/sites';
|
||||
import { CoreSync } from '@services/sync';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { Translate } from '@singletons';
|
||||
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||
|
@ -260,7 +259,7 @@ export class AddonModWorkshopAssessmentStrategyComponent implements OnInit, OnDe
|
|||
}
|
||||
|
||||
// Compare feedback text.
|
||||
const text = CoreTextUtils.restorePluginfileUrls(this.feedbackText, this.data.assessment?.feedbackcontentfiles || []);
|
||||
const text = CoreFileHelper.restorePluginfileUrls(this.feedbackText, this.data.assessment?.feedbackcontentfiles || []);
|
||||
if (this.originalData.text != text) {
|
||||
return true;
|
||||
}
|
||||
|
@ -334,7 +333,7 @@ export class AddonModWorkshopAssessmentStrategyComponent implements OnInit, OnDe
|
|||
);
|
||||
}
|
||||
|
||||
const text = CoreTextUtils.restorePluginfileUrls(this.feedbackText, this.data.assessment?.feedbackcontentfiles || []);
|
||||
const text = CoreFileHelper.restorePluginfileUrls(this.feedbackText, this.data.assessment?.feedbackcontentfiles || []);
|
||||
|
||||
let assessmentData: CoreFormFields<unknown>;
|
||||
try {
|
||||
|
|
|
@ -22,7 +22,7 @@ import { CoreNavigator } from '@services/navigator';
|
|||
import { CoreSites } from '@services/sites';
|
||||
import { CoreSync } from '@services/sync';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { Translate } from '@singletons';
|
||||
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||
import { CoreForms } from '@singletons/form';
|
||||
|
@ -378,7 +378,7 @@ export class AddonModWorkshopAssessmentPage implements OnInit, OnDestroy, CanLea
|
|||
|
||||
const grade = inputData.grade >= 0 ? String(inputData.grade) : '';
|
||||
// Add some HTML to the message if needed.
|
||||
const text = CoreTextUtils.formatHtmlLines(inputData.text);
|
||||
const text = CoreText.formatHtmlLines(inputData.text);
|
||||
|
||||
try {
|
||||
// Try to send it to server.
|
||||
|
|
|
@ -24,7 +24,7 @@ import { CoreNavigator } from '@services/navigator';
|
|||
import { CoreSites } from '@services/sites';
|
||||
import { CoreSync } from '@services/sync';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { Translate } from '@singletons';
|
||||
import { CoreEvents } from '@singletons/events';
|
||||
|
@ -45,6 +45,7 @@ import {
|
|||
AddonModWorkshopSubmissionType,
|
||||
} from '@addons/mod/workshop/constants';
|
||||
import { CoreLoadings } from '@services/loadings';
|
||||
import { CoreDom } from '@singletons/dom';
|
||||
|
||||
/**
|
||||
* Page that displays the workshop edit submission.
|
||||
|
@ -343,7 +344,7 @@ export class AddonModWorkshopEditSubmissionPage implements OnInit, OnDestroy, Ca
|
|||
throw new CoreError(Translate.instant('addon.mod_workshop.submissionrequiredtitle'));
|
||||
}
|
||||
|
||||
const noText = CoreTextUtils.htmlIsBlank(inputData.content);
|
||||
const noText = CoreDom.htmlIsBlank(inputData.content);
|
||||
const noFiles = !inputData.attachmentfiles.length;
|
||||
|
||||
if ((this.textRequired && noText) || (this.fileRequired && noFiles) || (noText && noFiles)) {
|
||||
|
@ -359,7 +360,7 @@ export class AddonModWorkshopEditSubmissionPage implements OnInit, OnDestroy, Ca
|
|||
|
||||
// Add some HTML to the message if needed.
|
||||
if (this.textAvailable) {
|
||||
inputData.content = CoreTextUtils.formatHtmlLines(inputData.content);
|
||||
inputData.content = CoreText.formatHtmlLines(inputData.content);
|
||||
}
|
||||
|
||||
// Upload attachments first if any.
|
||||
|
|
|
@ -25,7 +25,7 @@ import { CoreNavigator } from '@services/navigator';
|
|||
import { CoreSites } from '@services/sites';
|
||||
import { CoreSync } from '@services/sync';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { Translate } from '@singletons';
|
||||
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||
import { CoreForms } from '@singletons/form';
|
||||
|
@ -521,7 +521,7 @@ export class AddonModWorkshopSubmissionPage implements OnInit, OnDestroy, CanLea
|
|||
|
||||
inputData.grade = Number(inputData.grade) >= 0 ? inputData.grade : '';
|
||||
// Add some HTML to the message if needed.
|
||||
inputData.text = CoreTextUtils.formatHtmlLines(inputData.text);
|
||||
inputData.text = CoreText.formatHtmlLines(inputData.text);
|
||||
|
||||
// Try to send it to server.
|
||||
try {
|
||||
|
|
|
@ -19,7 +19,7 @@ import { FileEntry } from '@awesome-cordova-plugins/file/ngx';
|
|||
import { CoreFile } from '@services/file';
|
||||
import { CoreFileEntry } from '@services/file-helper';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreTextUtils, CoreTextFormat } from '@services/utils/text';
|
||||
import { CoreText, CoreTextFormat } from '@singletons/text';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { makeSingleton, Translate } from '@singletons';
|
||||
import { CoreFormFields } from '@singletons/form';
|
||||
|
@ -564,7 +564,7 @@ export class AddonModWorkshopHelperProvider {
|
|||
return '0';
|
||||
}
|
||||
|
||||
value = CoreTextUtils.roundToDecimals(max * value / 100, decimals);
|
||||
value = CoreText.roundToDecimals(max * value / 100, decimals);
|
||||
|
||||
return CoreUtils.formatFloat(value);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
|
|||
import { CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader';
|
||||
import { CoreFile } from '@services/file';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreTimeUtils } from '@services/utils/time';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { CoreFormFields } from '@singletons/form';
|
||||
|
@ -239,7 +239,7 @@ export class AddonModWorkshopOfflineProvider {
|
|||
protected parseSubmissionRecord(record: AddonModWorkshopSubmissionDBRecord): AddonModWorkshopOfflineSubmission {
|
||||
return {
|
||||
...record,
|
||||
attachmentsid: CoreTextUtils.parseJSON(record.attachmentsid),
|
||||
attachmentsid: CoreText.parseJSON(record.attachmentsid),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -355,7 +355,7 @@ export class AddonModWorkshopOfflineProvider {
|
|||
protected parseAssessmentRecord(record: AddonModWorkshopAssessmentDBRecord): AddonModWorkshopOfflineAssessment {
|
||||
return {
|
||||
...record,
|
||||
inputdata: CoreTextUtils.parseJSON(record.inputdata),
|
||||
inputdata: CoreText.parseJSON(record.inputdata),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -486,7 +486,7 @@ export class AddonModWorkshopOfflineProvider {
|
|||
return {
|
||||
...record,
|
||||
published: Boolean(record.published),
|
||||
gradeover: CoreTextUtils.parseJSON(record.gradeover),
|
||||
gradeover: CoreText.parseJSON(record.gradeover),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -616,7 +616,7 @@ export class AddonModWorkshopOfflineProvider {
|
|||
): AddonModWorkshopOfflineEvaluateAssessment {
|
||||
return {
|
||||
...record,
|
||||
gradinggradeover: CoreTextUtils.parseJSON(record.gradinggradeover),
|
||||
gradinggradeover: CoreText.parseJSON(record.gradinggradeover),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ import { CoreNetwork } from '@services/network';
|
|||
import { CoreFileEntry } from '@services/file-helper';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreSync, CoreSyncResult } from '@services/sync';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreErrorHelper } from '@services/error-helper';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { Translate, makeSingleton } from '@singletons';
|
||||
import { CoreEvents } from '@singletons/events';
|
||||
|
@ -373,7 +373,7 @@ export class AddonModWorkshopSyncProvider extends CoreSyncBaseProvider<AddonModW
|
|||
} catch (error) {
|
||||
if (error && CoreUtils.isWebServiceError(error)) {
|
||||
// The WebService has thrown an error, this means it cannot be performed. Discard.
|
||||
discardError = CoreTextUtils.getErrorMessageFromError(error);
|
||||
discardError = CoreErrorHelper.getErrorMessageFromError(error);
|
||||
}
|
||||
|
||||
// Couldn't connect to server, reject.
|
||||
|
@ -472,7 +472,7 @@ export class AddonModWorkshopSyncProvider extends CoreSyncBaseProvider<AddonModW
|
|||
} catch (error) {
|
||||
if (error && CoreUtils.isWebServiceError(error)) {
|
||||
// The WebService has thrown an error, this means it cannot be performed. Discard.
|
||||
discardError = CoreTextUtils.getErrorMessageFromError(error);
|
||||
discardError = CoreErrorHelper.getErrorMessageFromError(error);
|
||||
} else {
|
||||
// Couldn't connect to server, reject.
|
||||
throw error;
|
||||
|
@ -545,7 +545,7 @@ export class AddonModWorkshopSyncProvider extends CoreSyncBaseProvider<AddonModW
|
|||
} catch (error) {
|
||||
if (error && CoreUtils.isWebServiceError(error)) {
|
||||
// The WebService has thrown an error, this means it cannot be performed. Discard.
|
||||
discardError = CoreTextUtils.getErrorMessageFromError(error);
|
||||
discardError = CoreErrorHelper.getErrorMessageFromError(error);
|
||||
} else {
|
||||
// Couldn't connect to server, reject.
|
||||
throw error;
|
||||
|
@ -613,7 +613,7 @@ export class AddonModWorkshopSyncProvider extends CoreSyncBaseProvider<AddonModW
|
|||
} catch (error) {
|
||||
if (error && CoreUtils.isWebServiceError(error)) {
|
||||
// The WebService has thrown an error, this means it cannot be performed. Discard.
|
||||
discardError = CoreTextUtils.getErrorMessageFromError(error);
|
||||
discardError = CoreErrorHelper.getErrorMessageFromError(error);
|
||||
} else {
|
||||
// Couldn't connect to server, reject.
|
||||
throw error;
|
||||
|
|
|
@ -20,7 +20,7 @@ import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
|||
import { CoreGradesMenuItem } from '@features/grades/services/grades-helper';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreTextFormat, defaultTextFormat } from '@services/utils/text';
|
||||
import { CoreTextFormat, defaultTextFormat } from '@singletons/text';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreStatusWithWarningsWSResponse, CoreWS, CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
|
||||
import { makeSingleton, Translate } from '@singletons';
|
||||
|
|
|
@ -25,7 +25,7 @@ import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
|
|||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreUrl } from '@singletons/url';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { Translate } from '@singletons';
|
||||
|
@ -120,7 +120,7 @@ export class AddonNotesListPage implements OnInit, OnDestroy {
|
|||
const notesList: AddonNotesNoteFormatted[] = allNotes[this.type + 'notes'] || [];
|
||||
|
||||
notesList.forEach((note) => {
|
||||
note.content = CoreTextUtils.decodeHTML(note.content);
|
||||
note.content = CoreText.decodeHTML(note.content);
|
||||
});
|
||||
|
||||
await AddonNotes.setOfflineDeletedNotes(notesList, this.courseId);
|
||||
|
@ -301,7 +301,7 @@ export class AddonNotesListPage implements OnInit, OnDestroy {
|
|||
* @param warnings the warnings
|
||||
*/
|
||||
protected showSyncWarnings(warnings: string[]): void {
|
||||
const message = CoreTextUtils.buildMessage(warnings);
|
||||
const message = CoreText.buildMessage(warnings);
|
||||
|
||||
if (message) {
|
||||
CoreDomUtils.showAlert(undefined, message);
|
||||
|
|
|
@ -26,7 +26,7 @@ import { AddonNotes, AddonNotesCreateNoteData } from './notes';
|
|||
import { AddonNotesOffline } from './notes-offline';
|
||||
import { CoreArray } from '@singletons/array';
|
||||
import { CoreAnyError } from '@classes/errors/error';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreErrorHelper } from '@services/error-helper';
|
||||
|
||||
/**
|
||||
* Service to sync notes.
|
||||
|
@ -235,7 +235,7 @@ export class AddonNotesSyncProvider extends CoreSyncBaseProvider<AddonNotesSyncR
|
|||
result.warnings = errors.map((error) =>
|
||||
Translate.instant('addon.notes.warningnotenotsent', {
|
||||
course: 'fullname' in course ? course.fullname : courseId, // @deprecated since 4.3.
|
||||
error: CoreTextUtils.getErrorMessageFromError(error),
|
||||
error: CoreErrorHelper.getErrorMessageFromError(error),
|
||||
}));
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ import { CoreNavigator } from '@services/navigator';
|
|||
import { CoreTime } from '@singletons/time';
|
||||
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
|
||||
import { Translate } from '@singletons';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreErrorHelper } from '@services/error-helper';
|
||||
import { CoreLoadings } from '@services/loadings';
|
||||
|
||||
/**
|
||||
|
@ -122,7 +122,7 @@ export class AddonNotificationsSettingsPage implements OnInit, OnDestroy {
|
|||
this.logView();
|
||||
} catch (error) {
|
||||
if (error.errorcode === 'nopermissions') {
|
||||
this.warningMessage.set(CoreTextUtils.getErrorMessageFromError(error));
|
||||
this.warningMessage.set(CoreErrorHelper.getErrorMessageFromError(error));
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
|
|||
|
||||
import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites';
|
||||
import { CoreWSExternalWarning } from '@services/ws';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreTimeUtils } from '@services/utils/time';
|
||||
import { CoreUser, USER_NOREPLY_USER } from '@features/user/services/user';
|
||||
import { CoreSite } from '@classes/sites/site';
|
||||
|
@ -120,7 +120,7 @@ export class AddonNotificationsProvider {
|
|||
notification.read = notification.timeread > 0;
|
||||
|
||||
if (typeof notification.customdata === 'string') {
|
||||
notification.customdata = CoreTextUtils.parseJSON<Record<string, string|number>>(notification.customdata, {});
|
||||
notification.customdata = CoreText.parseJSON<Record<string, string|number>>(notification.customdata, {});
|
||||
}
|
||||
|
||||
// Try to set courseid the notification belongs to.
|
||||
|
|
|
@ -18,7 +18,7 @@ import { Md5 } from 'ts-md5/dist/md5';
|
|||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { Translate } from '@singletons';
|
||||
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||
import {
|
||||
|
@ -214,8 +214,8 @@ export class AddonPrivateFilesIndexPage implements OnInit, OnDestroy {
|
|||
// Get the info to calculate the available size.
|
||||
this.filesInfo = await AddonPrivateFiles.getPrivateFilesInfo();
|
||||
|
||||
this.spaceUsed = CoreTextUtils.bytesToSize(this.filesInfo.filesizewithoutreferences, 1);
|
||||
this.userQuotaReadable = CoreTextUtils.bytesToSize(this.userQuota, 1);
|
||||
this.spaceUsed = CoreText.bytesToSize(this.filesInfo.filesizewithoutreferences, 1);
|
||||
this.userQuotaReadable = CoreText.bytesToSize(this.userQuota, 1);
|
||||
} else {
|
||||
// User quota isn't useful, delete it.
|
||||
delete this.userQuota;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// limitations under the License.
|
||||
|
||||
import { CoreFormatTextDirective } from '@directives/format-text';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreDirectivesRegistry } from '@singletons/directives-registry';
|
||||
import { CoreCoordinates, CoreDom } from '@singletons/dom';
|
||||
import { CoreEventObserver } from '@singletons/events';
|
||||
|
@ -490,7 +490,7 @@ export class AddonQtypeDdwtosQuestion {
|
|||
}
|
||||
|
||||
groupItems.forEach((item) => {
|
||||
item.innerHTML = CoreTextUtils.decodeHTML(item.innerHTML);
|
||||
item.innerHTML = CoreText.decodeHTML(item.innerHTML);
|
||||
});
|
||||
|
||||
// Wait to render in order to calculate size.
|
||||
|
|
|
@ -19,7 +19,7 @@ import { FileEntry } from '@awesome-cordova-plugins/file/ngx';
|
|||
import { CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader';
|
||||
import { AddonModQuizEssayQuestion, CoreQuestionBaseComponent } from '@features/question/classes/base-question-component';
|
||||
import { CoreQuestionHelper } from '@features/question/services/question-helper';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreFileSession } from '@services/file-session';
|
||||
import { CoreQuestion } from '@features/question/services/question';
|
||||
import { CoreFileEntry } from '@services/file-helper';
|
||||
|
@ -71,7 +71,7 @@ export class AddonQtypeEssayComponent extends CoreQuestionBaseComponent<AddonMod
|
|||
|
||||
if (this.offlineEnabled && this.question.localAnswers?.attachments_offline) {
|
||||
|
||||
const attachmentsData: CoreFileUploaderStoreFilesResult = CoreTextUtils.parseJSON(
|
||||
const attachmentsData: CoreFileUploaderStoreFilesResult = CoreText.parseJSON(
|
||||
this.question.localAnswers.attachments_offline,
|
||||
{
|
||||
online: [],
|
||||
|
|
|
@ -23,11 +23,12 @@ import { CoreQuestionHelper } from '@features/question/services/question-helper'
|
|||
import { CoreFileSession } from '@services/file-session';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreWSFile } from '@services/ws';
|
||||
import { makeSingleton, Translate } from '@singletons';
|
||||
import { AddonQtypeEssayComponent } from '../../component/essay';
|
||||
import { CoreFileHelper } from '@services/file-helper';
|
||||
|
||||
/**
|
||||
* Handler to support essay question type.
|
||||
|
@ -177,7 +178,7 @@ export class AddonQtypeEssayHandlerService implements CoreQuestionHandler {
|
|||
}
|
||||
|
||||
// Count the number of words in the response string.
|
||||
const count = CoreTextUtils.countWords(answer);
|
||||
const count = CoreText.countWords(answer);
|
||||
if (maxWords && count > maxWords) {
|
||||
return Translate.instant('addon.qtype_essay.maxwordlimitboundary', { $a: { limit: maxWords, count: count } });
|
||||
} else if (count < minWords) {
|
||||
|
@ -386,7 +387,7 @@ export class AddonQtypeEssayHandlerService implements CoreQuestionHandler {
|
|||
return;
|
||||
}
|
||||
|
||||
const attachmentsData: CoreFileUploaderStoreFilesResult = CoreTextUtils.parseJSON(
|
||||
const attachmentsData: CoreFileUploaderStoreFilesResult = CoreText.parseJSON(
|
||||
<string> answers.attachments_offline,
|
||||
{
|
||||
online: [],
|
||||
|
@ -438,7 +439,7 @@ export class AddonQtypeEssayHandlerService implements CoreQuestionHandler {
|
|||
// Restore draftfile URLs.
|
||||
const site = await CoreSites.getSite(siteId);
|
||||
|
||||
answers[textarea.name] = CoreTextUtils.restoreDraftfileUrls(
|
||||
answers[textarea.name] = CoreFileHelper.restoreDraftfileUrls(
|
||||
site.getURL(),
|
||||
<string> answers[textarea.name],
|
||||
question.html,
|
||||
|
@ -459,7 +460,7 @@ export class AddonQtypeEssayHandlerService implements CoreQuestionHandler {
|
|||
|
||||
if (!isPlainText) {
|
||||
// Add some HTML to the text if needed.
|
||||
answers[textarea.name] = CoreTextUtils.formatHtmlLines(<string> answers[textarea.name] || '');
|
||||
answers[textarea.name] = CoreText.formatHtmlLines(<string> answers[textarea.name] || '');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ import { Injectable, Type } from '@angular/core';
|
|||
|
||||
import { CoreUserProfileFieldHandler, CoreUserProfileFieldHandlerData } from '@features/user/services/user-profile-field-delegate';
|
||||
import { AddonUserProfileFieldSocialComponent } from '../../component/social';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { AuthEmailSignupProfileField } from '@features/login/services/login-helper';
|
||||
import { CoreUserProfileField } from '@features/user/services/user';
|
||||
import { makeSingleton } from '@singletons';
|
||||
|
@ -60,7 +60,7 @@ export class AddonUserProfileFieldSocialHandlerService implements CoreUserProfil
|
|||
return {
|
||||
type: 'social',
|
||||
name: name,
|
||||
value: CoreTextUtils.cleanTags(<string> formValues[name]),
|
||||
value: CoreText.cleanTags(<string> formValues[name]),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ import { Injectable, Type } from '@angular/core';
|
|||
|
||||
import { CoreUserProfileFieldHandler, CoreUserProfileFieldHandlerData } from '@features/user/services/user-profile-field-delegate';
|
||||
import { AddonUserProfileFieldTextComponent } from '../../component/text';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { AuthEmailSignupProfileField } from '@features/login/services/login-helper';
|
||||
import { CoreUserProfileField } from '@features/user/services/user';
|
||||
import { makeSingleton } from '@singletons';
|
||||
|
@ -60,7 +60,7 @@ export class AddonUserProfileFieldTextHandlerService implements CoreUserProfileF
|
|||
return {
|
||||
type: 'text',
|
||||
name: name,
|
||||
value: CoreTextUtils.cleanTags(<string> formValues[name]),
|
||||
value: CoreText.cleanTags(<string> formValues[name]),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ import { Injectable, Type } from '@angular/core';
|
|||
|
||||
import { CoreUserProfileFieldHandler, CoreUserProfileFieldHandlerData } from '@features/user/services/user-profile-field-delegate';
|
||||
import { AddonUserProfileFieldTextareaComponent } from '../../component/textarea';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { AuthEmailSignupProfileField } from '@features/login/services/login-helper';
|
||||
import { CoreUserProfileField } from '@features/user/services/user';
|
||||
import { makeSingleton } from '@singletons';
|
||||
|
@ -60,7 +60,7 @@ export class AddonUserProfileFieldTextareaHandlerService implements CoreUserProf
|
|||
if (formValues[name]) {
|
||||
let text = <string> formValues[name] || '';
|
||||
// Add some HTML to the message in case the user edited with textarea.
|
||||
text = CoreTextUtils.formatHtmlLines(text);
|
||||
text = CoreText.formatHtmlLines(text);
|
||||
|
||||
return {
|
||||
type: 'textarea',
|
||||
|
|
|
@ -15,11 +15,12 @@
|
|||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreSync } from '@services/sync';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreTimeUtils } from '@services/utils/time';
|
||||
import { Translate } from '@singletons';
|
||||
import { CoreLogger } from '@singletons/logger';
|
||||
import { CoreAnyError, CoreError } from '@classes/errors/error';
|
||||
import { CoreErrorHelper } from '@services/error-helper';
|
||||
|
||||
/**
|
||||
* Blocked sync error.
|
||||
|
@ -120,7 +121,7 @@ export class CoreSyncBaseProvider<T = void> {
|
|||
return Translate.instant('core.warningofflinedatadeleted', {
|
||||
component: this.componentTranslate,
|
||||
name: name,
|
||||
error: CoreTextUtils.getErrorMessageFromError(error),
|
||||
error: CoreErrorHelper.getErrorMessageFromError(error),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -195,7 +196,7 @@ export class CoreSyncBaseProvider<T = void> {
|
|||
try {
|
||||
const entry = await CoreSync.getSyncRecord(this.component, id, siteId);
|
||||
|
||||
return <string[]> CoreTextUtils.parseJSON(entry.warnings, []);
|
||||
return <string[]> CoreText.parseJSON(entry.warnings, []);
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { CoreTextErrorObject } from '@services/utils/text';
|
||||
import { CoreErrorObject } from '@services/error-helper';
|
||||
|
||||
/**
|
||||
* Base Error class.
|
||||
|
@ -34,4 +34,4 @@ export class CoreError extends Error {
|
|||
|
||||
}
|
||||
|
||||
export type CoreAnyError = string | CoreError | CoreTextErrorObject | null | undefined;
|
||||
export type CoreAnyError = string | CoreError | CoreErrorObject | null | undefined;
|
||||
|
|
|
@ -22,7 +22,7 @@ import {
|
|||
CoreWSTypeExpected,
|
||||
} from '@services/ws';
|
||||
import { CoreToasts, ToastDuration } from '@services/toasts';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreConstants } from '@/core/constants';
|
||||
import { CoreError } from '@classes/errors/error';
|
||||
|
@ -418,7 +418,7 @@ export class CoreAuthenticatedSite extends CoreUnauthenticatedSite {
|
|||
splitRequest: preSets.splitRequest,
|
||||
};
|
||||
|
||||
if (wsPreSets.cleanUnicode && CoreTextUtils.hasUnicodeData(data)) {
|
||||
if (wsPreSets.cleanUnicode && CoreText.hasUnicodeData(data)) {
|
||||
// Data will be cleaned, notify the user.
|
||||
CoreToasts.show({
|
||||
message: 'core.unicodenotsupported',
|
||||
|
@ -676,7 +676,7 @@ export class CoreAuthenticatedSite extends CoreUnauthenticatedSite {
|
|||
error.message = Translate.instant('core.policy.sitepolicynotagreederror');
|
||||
|
||||
throw new CoreSilentError(error);
|
||||
} else if (error.errorcode === 'dmlwriteexception' && CoreTextUtils.hasUnicodeData(data)) {
|
||||
} else if (error.errorcode === 'dmlwriteexception' && CoreText.hasUnicodeData(data)) {
|
||||
if (!this.cleanUnicode) {
|
||||
// Try again cleaning unicode.
|
||||
this.cleanUnicode = true;
|
||||
|
@ -961,7 +961,7 @@ export class CoreAuthenticatedSite extends CoreUnauthenticatedSite {
|
|||
// Request not executed, enqueue again.
|
||||
this.enqueueRequest(request);
|
||||
} else if (response.error) {
|
||||
const rejectReason = CoreTextUtils.parseJSON(response.exception || '') as Error | undefined;
|
||||
const rejectReason = CoreText.parseJSON(response.exception || '') as Error | undefined;
|
||||
request.deferred.reject(rejectReason);
|
||||
CoreErrorLogs.addErrorLog({
|
||||
method: request.method,
|
||||
|
@ -971,7 +971,7 @@ export class CoreAuthenticatedSite extends CoreUnauthenticatedSite {
|
|||
data: request.data,
|
||||
});
|
||||
} else {
|
||||
let responseData = response.data ? CoreTextUtils.parseJSON(response.data) : {};
|
||||
let responseData = response.data ? CoreText.parseJSON(response.data) : {};
|
||||
// Match the behaviour of CoreWSProvider.call when no response is expected.
|
||||
const responseExpected = wsPresets.responseExpected === undefined || wsPresets.responseExpected;
|
||||
if (!responseExpected && (responseData == null || responseData === '')) {
|
||||
|
@ -1097,7 +1097,7 @@ export class CoreAuthenticatedSite extends CoreUnauthenticatedSite {
|
|||
}
|
||||
|
||||
return {
|
||||
response: <T> CoreTextUtils.parseJSON(entry.data, {}),
|
||||
response: <T> CoreText.parseJSON(entry.data, {}),
|
||||
expirationIgnored: forceCache,
|
||||
expirationTime,
|
||||
};
|
||||
|
|
|
@ -25,7 +25,6 @@ import {
|
|||
CoreWSUploadFileResult,
|
||||
} from '@services/ws';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreTimeUtils } from '@services/utils/time';
|
||||
import { CoreUrl } from '@singletons/url';
|
||||
import { CoreUtils, CoreUtilsOpenInBrowserOptions } from '@services/utils/utils';
|
||||
|
@ -166,7 +165,7 @@ export class CoreSite extends CoreAuthenticatedSite {
|
|||
*/
|
||||
setConfig(config: CoreSiteConfig): void {
|
||||
if (config) {
|
||||
config.tool_mobile_disabledfeatures = CoreTextUtils.treatDisabledFeatures(config.tool_mobile_disabledfeatures);
|
||||
config.tool_mobile_disabledfeatures = this.treatDisabledFeatures(config.tool_mobile_disabledfeatures);
|
||||
}
|
||||
|
||||
this.config = config;
|
||||
|
|
|
@ -16,7 +16,7 @@ import { CoreConstants } from '@/core/constants';
|
|||
import { CoreError } from '@classes/errors/error';
|
||||
import { CoreLoginHelper } from '@features/login/services/login-helper';
|
||||
import { CoreSitesReadingStrategy } from '@services/sites';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreUrl, CoreUrlPartNames } from '@singletons/url';
|
||||
import { CoreWS, CoreWSAjaxPreSets, CoreWSExternalWarning } from '@services/ws';
|
||||
import { CorePath } from '@singletons/path';
|
||||
|
@ -30,6 +30,55 @@ export class CoreUnauthenticatedSite {
|
|||
|
||||
protected publicConfig?: CoreSitePublicConfigResponse;
|
||||
|
||||
// List of regular expressions to convert the old nomenclature to new nomenclature for disabled features.
|
||||
protected static readonly DISABLED_FEATURES_COMPAT_REGEXPS: { old: RegExp; new: string }[] = [
|
||||
{ old: /\$mmLoginEmailSignup/g, new: 'CoreLoginEmailSignup' },
|
||||
{ old: /\$mmSideMenuDelegate/g, new: 'CoreMainMenuDelegate' },
|
||||
{ old: /\$mmCoursesDelegate/g, new: 'CoreCourseOptionsDelegate' },
|
||||
{ old: /\$mmUserDelegate/g, new: 'CoreUserDelegate' },
|
||||
{ old: /\$mmCourseDelegate/g, new: 'CoreCourseModuleDelegate' },
|
||||
{ old: /_mmCourses/g, new: '_CoreCourses' },
|
||||
{ old: /_mmaFrontpage/g, new: '_CoreSiteHome' },
|
||||
{ old: /_mmaGrades/g, new: '_CoreGrades' },
|
||||
{ old: /_mmaCompetency/g, new: '_AddonCompetency' },
|
||||
{ old: /_mmaNotifications/g, new: '_AddonNotifications' },
|
||||
{ old: /_mmaMessages/g, new: '_AddonMessages' },
|
||||
{ old: /_mmaCalendar/g, new: '_AddonCalendar' },
|
||||
{ old: /_mmaFiles/g, new: '_AddonPrivateFiles' },
|
||||
{ old: /_mmaParticipants/g, new: '_CoreUserParticipants' },
|
||||
{ old: /_mmaCourseCompletion/g, new: '_AddonCourseCompletion' },
|
||||
{ old: /_mmaNotes/g, new: '_AddonNotes' },
|
||||
{ old: /_mmaBadges/g, new: '_AddonBadges' },
|
||||
{ old: /files_privatefiles/g, new: 'AddonPrivateFilesPrivateFiles' },
|
||||
{ old: /files_sitefiles/g, new: 'AddonPrivateFilesSiteFiles' },
|
||||
{ old: /files_upload/g, new: 'AddonPrivateFilesUpload' },
|
||||
{ old: /_mmaModAssign/g, new: '_AddonModAssign' },
|
||||
{ old: /_mmaModBigbluebuttonbn/g, new: '_AddonModBBB' },
|
||||
{ old: /_mmaModBook/g, new: '_AddonModBook' },
|
||||
{ old: /_mmaModChat/g, new: '_AddonModChat' },
|
||||
{ old: /_mmaModChoice/g, new: '_AddonModChoice' },
|
||||
{ old: /_mmaModData/g, new: '_AddonModData' },
|
||||
{ old: /_mmaModFeedback/g, new: '_AddonModFeedback' },
|
||||
{ old: /_mmaModFolder/g, new: '_AddonModFolder' },
|
||||
{ old: /_mmaModForum/g, new: '_AddonModForum' },
|
||||
{ old: /_mmaModGlossary/g, new: '_AddonModGlossary' },
|
||||
{ old: /_mmaModH5pactivity/g, new: '_AddonModH5PActivity' },
|
||||
{ old: /_mmaModImscp/g, new: '_AddonModImscp' },
|
||||
{ old: /_mmaModLabel/g, new: '_AddonModLabel' },
|
||||
{ old: /_mmaModLesson/g, new: '_AddonModLesson' },
|
||||
{ old: /_mmaModLti/g, new: '_AddonModLti' },
|
||||
{ old: /_mmaModPage/g, new: '_AddonModPage' },
|
||||
{ old: /_mmaModQuiz/g, new: '_AddonModQuiz' },
|
||||
{ old: /_mmaModResource/g, new: '_AddonModResource' },
|
||||
{ old: /_mmaModScorm/g, new: '_AddonModScorm' },
|
||||
{ old: /_mmaModSurvey/g, new: '_AddonModSurvey' },
|
||||
{ old: /_mmaModUrl/g, new: '_AddonModUrl' },
|
||||
{ old: /_mmaModWiki/g, new: '_AddonModWiki' },
|
||||
{ old: /_mmaModWorkshop/g, new: '_AddonModWorkshop' },
|
||||
{ old: /remoteAddOn_/g, new: 'sitePlugin_' },
|
||||
{ old: /AddonNotes:addNote/g, new: 'AddonNotes:notes' },
|
||||
];
|
||||
|
||||
/**
|
||||
* Create a site.
|
||||
*
|
||||
|
@ -160,10 +209,10 @@ export class CoreUnauthenticatedSite {
|
|||
return false;
|
||||
}
|
||||
|
||||
const siteUrl = CoreTextUtils.addEndingSlash(
|
||||
const siteUrl = CoreText.addEndingSlash(
|
||||
CoreUrl.removeUrlParts(this.siteUrl, [CoreUrlPartNames.Protocol, CoreUrlPartNames.WWWInDomain]),
|
||||
);
|
||||
url = CoreTextUtils.addEndingSlash(CoreUrl.removeUrlParts(url, [CoreUrlPartNames.Protocol, CoreUrlPartNames.WWWInDomain]));
|
||||
url = CoreText.addEndingSlash(CoreUrl.removeUrlParts(url, [CoreUrlPartNames.Protocol, CoreUrlPartNames.WWWInDomain]));
|
||||
|
||||
return url.indexOf(siteUrl) == 0;
|
||||
}
|
||||
|
@ -207,7 +256,7 @@ export class CoreUnauthenticatedSite {
|
|||
*/
|
||||
setPublicConfig(publicConfig: CoreSitePublicConfigResponse): void {
|
||||
publicConfig.tool_mobile_disabledfeatures =
|
||||
CoreTextUtils.treatDisabledFeatures(publicConfig.tool_mobile_disabledfeatures ?? '');
|
||||
this.treatDisabledFeatures(publicConfig.tool_mobile_disabledfeatures ?? '');
|
||||
this.publicConfig = publicConfig;
|
||||
}
|
||||
|
||||
|
@ -330,7 +379,7 @@ export class CoreUnauthenticatedSite {
|
|||
return false;
|
||||
}
|
||||
|
||||
const regEx = new RegExp('(,|^)' + CoreTextUtils.escapeForRegex(name) + '(,|$)', 'g');
|
||||
const regEx = new RegExp('(,|^)' + CoreText.escapeForRegex(name) + '(,|$)', 'g');
|
||||
|
||||
return !!disabledFeatures.match(regEx);
|
||||
}
|
||||
|
@ -344,6 +393,26 @@ export class CoreUnauthenticatedSite {
|
|||
return this.publicConfig?.tool_mobile_disabledfeatures;
|
||||
}
|
||||
|
||||
/**
|
||||
* Treat the list of disabled features, replacing old nomenclature with the new one.
|
||||
*
|
||||
* @param features List of disabled features.
|
||||
* @returns Treated list.
|
||||
*/
|
||||
protected treatDisabledFeatures(features: string): string {
|
||||
if (!features) {
|
||||
return '';
|
||||
}
|
||||
|
||||
for (let i = 0; i < CoreUnauthenticatedSite.DISABLED_FEATURES_COMPAT_REGEXPS.length; i++) {
|
||||
const entry = CoreUnauthenticatedSite.DISABLED_FEATURES_COMPAT_REGEXPS[i];
|
||||
|
||||
features = features.replace(entry.old, entry.new);
|
||||
}
|
||||
|
||||
return features;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,7 +17,7 @@ import { FileEntry } from '@awesome-cordova-plugins/file/ngx';
|
|||
|
||||
import { CoreFileUploader, CoreFileUploaderTypeList } from '@features/fileuploader/services/fileuploader';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { Translate } from '@singletons';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
|
@ -74,7 +74,7 @@ export class CoreAttachmentsComponent implements OnInit {
|
|||
if (this.maxSize === 0) {
|
||||
await this.getMaxSizeOfArea();
|
||||
} else if (this.maxSize > 0) {
|
||||
this.maxSizeReadable = CoreTextUtils.bytesToSize(this.maxSize, 2);
|
||||
this.maxSizeReadable = CoreText.bytesToSize(this.maxSize, 2);
|
||||
} else if (this.maxSize === -1) {
|
||||
this.maxSizeReadable = Translate.instant('core.unlimited');
|
||||
} else {
|
||||
|
@ -110,7 +110,7 @@ export class CoreAttachmentsComponent implements OnInit {
|
|||
|
||||
if (course?.maxbytes) {
|
||||
this.maxSize = course.maxbytes;
|
||||
this.maxSizeReadable = CoreTextUtils.bytesToSize(this.maxSize, 2);
|
||||
this.maxSizeReadable = CoreText.bytesToSize(this.maxSize, 2);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ export class CoreAttachmentsComponent implements OnInit {
|
|||
|
||||
if (siteInfo?.usermaxuploadfilesize) {
|
||||
this.maxSize = siteInfo.usermaxuploadfilesize;
|
||||
this.maxSizeReadable = CoreTextUtils.bytesToSize(this.maxSize, 2);
|
||||
this.maxSizeReadable = CoreText.bytesToSize(this.maxSize, 2);
|
||||
} else {
|
||||
this.maxSizeReadable = Translate.instant('core.unknown');
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import { CoreDomUtils } from '@services/utils/dom';
|
|||
import { CoreMimetypeUtils } from '@services/utils/mimetype';
|
||||
import { CoreUrl } from '@singletons/url';
|
||||
import { CoreUtils, CoreUtilsOpenFileOptions, OpenFileAction } from '@services/utils/utils';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { DownloadStatus } from '@/core/constants';
|
||||
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||
import { CoreWSFile } from '@services/ws';
|
||||
|
@ -90,7 +90,7 @@ export class CoreFileComponent implements OnInit, OnDestroy {
|
|||
this.openButtonLabel = this.defaultIsOpenWithPicker ? 'core.openfile' : 'core.openwith';
|
||||
|
||||
if (this.showSize && this.fileSize && this.fileSize >= 0) {
|
||||
this.fileSizeReadable = CoreTextUtils.bytesToSize(this.fileSize, 2);
|
||||
this.fileSizeReadable = CoreText.bytesToSize(this.fileSize, 2);
|
||||
}
|
||||
|
||||
this.showTime = this.showTime && this.timemodified > 0;
|
||||
|
|
|
@ -21,7 +21,7 @@ import { CoreFileHelper } from '@services/file-helper';
|
|||
import { CoreSites } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreMimetypeUtils } from '@services/utils/mimetype';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreTimeUtils } from '@services/utils/time';
|
||||
import { CoreUtils, CoreUtilsOpenFileOptions, OpenFileAction } from '@services/utils/utils';
|
||||
import { CoreForms } from '@singletons/form';
|
||||
|
@ -78,7 +78,7 @@ export class CoreLocalFileComponent implements OnInit {
|
|||
// Get the size and timemodified.
|
||||
const metadata = await CoreFile.getMetadata(this.file);
|
||||
if (metadata.size >= 0) {
|
||||
this.size = CoreTextUtils.bytesToSize(metadata.size, 2);
|
||||
this.size = CoreText.bytesToSize(metadata.size, 2);
|
||||
}
|
||||
|
||||
this.timemodified = CoreTimeUtils.userDate(metadata.modificationTime.getTime(), 'core.strftimedatetimeshort');
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
import { toBoolean } from '@/core/transforms/boolean';
|
||||
import { Component, Input, AfterViewInit, ElementRef } from '@angular/core';
|
||||
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { Translate } from '@singletons';
|
||||
|
||||
/**
|
||||
|
@ -53,7 +53,7 @@ export class CoreMarkRequiredComponent implements AfterViewInit {
|
|||
if (this.coreMarkRequired) {
|
||||
// Add the "required" to the aria-label.
|
||||
const ariaLabel = this.hostElement.getAttribute('aria-label') ||
|
||||
CoreTextUtils.cleanTags(this.hostElement.innerHTML, { singleLine: true });
|
||||
CoreText.cleanTags(this.hostElement.innerHTML, { singleLine: true });
|
||||
if (ariaLabel) {
|
||||
this.hostElement.setAttribute('aria-label', ariaLabel + '. ' + this.requiredLabel);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ import { Component, EventEmitter, HostBinding, Input, OnInit, Output } from '@an
|
|||
import { CoreAnimations } from '@components/animations';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreUserWithAvatar } from '@components/user-avatar/user-avatar';
|
||||
import { toBoolean } from '@/core/transforms/boolean';
|
||||
|
||||
|
@ -103,7 +102,7 @@ export class CoreMessageComponent implements OnInit {
|
|||
* Copy message to clipboard.
|
||||
*/
|
||||
copyMessage(): void {
|
||||
CoreText.copyToClipboard(CoreTextUtils.decodeHTMLEntities(this.text));
|
||||
CoreText.copyToClipboard(CoreText.decodeHTMLEntities(this.text));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ import {
|
|||
import { CoreCourse } from '@features/course/services/course';
|
||||
import { CoreCourseModuleDelegate } from '@features/course/services/module-delegate';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreUrl } from '@singletons/url';
|
||||
|
||||
const assetsPath = 'assets/img/';
|
||||
|
@ -150,7 +150,7 @@ export class CoreModIconComponent implements OnInit, OnChanges {
|
|||
return;
|
||||
}
|
||||
|
||||
this.iconUrl.update(value => CoreTextUtils.decodeHTMLEntities(value));
|
||||
this.iconUrl.update(value => CoreText.decodeHTMLEntities(value));
|
||||
if (this.brandedClass !== undefined) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import { Component, Input, Output, EventEmitter, ViewChild, ElementRef } from '@
|
|||
import { CoreConfig } from '@services/config';
|
||||
import { CoreEvents } from '@singletons/events';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreConstants } from '@/core/constants';
|
||||
import { CoreForms } from '@singletons/form';
|
||||
import { CorePlatform } from '@services/platform';
|
||||
|
@ -88,7 +88,7 @@ export class CoreSendMessageFormComponent {
|
|||
|
||||
CoreForms.triggerFormSubmittedEvent(this.formElement, false, CoreSites.getCurrentSiteId());
|
||||
|
||||
value = CoreTextUtils.replaceNewLines(value, '<br>');
|
||||
value = CoreText.replaceNewLines(value, '<br>');
|
||||
this.onSubmit.emit(value);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ export async function getCoreServices(): Promise<Type<unknown>[]> {
|
|||
const { CoreCustomURLSchemesProvider } = await import('@services/urlschemes');
|
||||
const { CoreDbProvider } = await import('@services/db');
|
||||
const { CoreDomUtilsProvider } = await import('@services/utils/dom');
|
||||
const { CoreErrorHelperService } = await import('@services/error-helper');
|
||||
const { CoreToastsService } = await import('@services/toasts');
|
||||
const { CoreFileHelperProvider } = await import('@services/file-helper');
|
||||
const { CoreFilepoolProvider } = await import('@services/filepool');
|
||||
|
@ -51,6 +52,7 @@ export async function getCoreServices(): Promise<Type<unknown>[]> {
|
|||
const { CoreScreenService } = await import('@services/screen');
|
||||
const { CoreSitesProvider } = await import('@services/sites');
|
||||
const { CoreSyncProvider } = await import('@services/sync');
|
||||
// eslint-disable-next-line deprecation/deprecation
|
||||
const { CoreTextUtilsProvider } = await import('@services/utils/text');
|
||||
const { CoreTimeUtilsProvider } = await import('@services/utils/time');
|
||||
const { CoreUpdateManagerProvider } = await import('@services/update-manager');
|
||||
|
@ -68,6 +70,7 @@ export async function getCoreServices(): Promise<Type<unknown>[]> {
|
|||
CoreCustomURLSchemesProvider,
|
||||
CoreDbProvider,
|
||||
CoreDomUtilsProvider,
|
||||
CoreErrorHelperService,
|
||||
CoreFileHelperProvider,
|
||||
CoreFilepoolProvider,
|
||||
CoreFileProvider,
|
||||
|
|
|
@ -39,7 +39,7 @@ import { AsyncDirective } from '@classes/async-directive';
|
|||
import { CoreDirectivesRegistry } from '@singletons/directives-registry';
|
||||
import { CorePromisedValue } from '@classes/promised-value';
|
||||
import { CorePlatform } from '@services/platform';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreArray } from '@singletons/array';
|
||||
import { CoreMimetypeUtils } from '@services/utils/mimetype';
|
||||
import { FileEntry } from '@awesome-cordova-plugins/file/ngx';
|
||||
|
@ -301,7 +301,7 @@ export class CoreExternalContentDirective implements AfterViewInit, OnChanges, O
|
|||
const finalUrl = await CoreFilepool.getSrcByUrl(siteId, url, this.component, this.componentId, 0, true, true);
|
||||
|
||||
this.logger.debug('Using URL ' + finalUrl + ' for ' + url + ' in inline styles');
|
||||
inlineStyles = inlineStyles.replace(new RegExp(CoreTextUtils.escapeForRegex(url), 'gi'), finalUrl);
|
||||
inlineStyles = inlineStyles.replace(new RegExp(CoreText.escapeForRegex(url), 'gi'), finalUrl);
|
||||
});
|
||||
|
||||
try {
|
||||
|
|
|
@ -31,7 +31,7 @@ import {
|
|||
import { CoreSites } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreIframeUtils, CoreIframeUtilsProvider } from '@services/utils/iframe';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreSite } from '@classes/sites/site';
|
||||
import { NgZone, Translate } from '@singletons';
|
||||
|
@ -291,7 +291,7 @@ export class CoreFormatTextDirective implements OnChanges, OnDestroy, AsyncDirec
|
|||
button.innerHTML = `<ion-icon name="fas-${iconName}" aria-hidden="true" src="${src}"></ion-icon>`;
|
||||
|
||||
button.addEventListener('click', (e: Event) => {
|
||||
const imgSrc = CoreTextUtils.escapeHTML(img.getAttribute('data-original-src') || img.getAttribute('src'));
|
||||
const imgSrc = CoreText.escapeHTML(img.getAttribute('data-original-src') || img.getAttribute('src'));
|
||||
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
|
|
@ -20,7 +20,6 @@ import { CoreSites } from '@services/sites';
|
|||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreUrl } from '@singletons/url';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreConstants } from '@/core/constants';
|
||||
import { CoreContentLinksHelper } from '@features/contentlinks/services/contentlinks-helper';
|
||||
import { CoreCustomURLSchemes } from '@services/urlschemes';
|
||||
|
@ -96,7 +95,7 @@ export class CoreLinkDirective implements OnInit {
|
|||
const openIn = this.element.getAttribute('data-open-in');
|
||||
|
||||
if (this.capture) {
|
||||
const treated = await CoreContentLinksHelper.handleLink(CoreTextUtils.decodeURI(href), undefined, true, true);
|
||||
const treated = await CoreContentLinksHelper.handleLink(CoreUrl.decodeURI(href), undefined, true, true);
|
||||
|
||||
if (!treated) {
|
||||
this.navigate(href, openIn);
|
||||
|
|
|
@ -16,7 +16,7 @@ import { OnInit, Input, Component, Optional, Inject, OnChanges, SimpleChanges }
|
|||
import { CoreLogger } from '@singletons/logger';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreText } from '@singletons/text';
|
||||
import { CoreCourseBlock } from '../../course/services/course';
|
||||
import { Params } from '@angular/router';
|
||||
import { ContextLevel } from '@/core/constants';
|
||||
|
@ -75,7 +75,7 @@ export abstract class CoreBlockBaseComponent implements OnInit, OnChanges, ICore
|
|||
}
|
||||
|
||||
this.block.configs.forEach((config) => {
|
||||
config.value = CoreTextUtils.parseJSON(config.value);
|
||||
config.value = CoreText.parseJSON(config.value);
|
||||
});
|
||||
|
||||
this.block.configsRecord = CoreUtils.arrayToObject(this.block.configs, 'name');
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue