commit
4193bfc1d9
|
@ -69,7 +69,7 @@ jobs:
|
||||||
cat circular-dependencies
|
cat circular-dependencies
|
||||||
lines=$(cat circular-dependencies | wc -l)
|
lines=$(cat circular-dependencies | wc -l)
|
||||||
echo "Total circular dependencies: $lines"
|
echo "Total circular dependencies: $lines"
|
||||||
test $lines -eq 131
|
test $lines -eq 130
|
||||||
- name: JavaScript code compatibility
|
- name: JavaScript code compatibility
|
||||||
run: |
|
run: |
|
||||||
npx check-es-compat www/*.js --polyfills="\{Array,String,TypedArray\}.prototype.at,Object.hasOwn"
|
npx check-es-compat www/*.js --polyfills="\{Array,String,TypedArray\}.prototype.at,Object.hasOwn"
|
||||||
|
|
|
@ -29,7 +29,7 @@ import { CoreBlockBaseComponent } from '@features/block/classes/base-block-compo
|
||||||
import { CoreSite } from '@classes/sites/site';
|
import { CoreSite } from '@classes/sites/site';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
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 { AddonCourseCompletion } from '@addons/coursecompletion/services/coursecompletion';
|
||||||
import { IonSearchbar } from '@ionic/angular';
|
import { IonSearchbar } from '@ionic/angular';
|
||||||
import { CoreNavigator } from '@services/navigator';
|
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.show.custom = config?.displaygroupingcustomfield?.value == '1' && !!config?.customfieldsexport?.value;
|
||||||
|
|
||||||
this.filters.customFilters = this.filters.show.custom
|
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.
|
// Check if any selector is shown and not disabled.
|
||||||
|
|
|
@ -19,7 +19,7 @@ import {
|
||||||
AddonBlockRecentlyAccessedItems,
|
AddonBlockRecentlyAccessedItems,
|
||||||
AddonBlockRecentlyAccessedItemsItemCalculatedData,
|
AddonBlockRecentlyAccessedItemsItemCalculatedData,
|
||||||
} from '../../services/recentlyaccesseditems';
|
} from '../../services/recentlyaccesseditems';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreLoadings } from '@services/loadings';
|
import { CoreLoadings } from '@services/loadings';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { CoreSharedModule } from '@/core/shared.module';
|
import { CoreSharedModule } from '@/core/shared.module';
|
||||||
|
@ -92,7 +92,7 @@ export class AddonBlockRecentlyAccessedItemsComponent extends CoreBlockBaseCompo
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
||||||
const url = CoreTextUtils.decodeHTMLEntities(item.viewurl);
|
const url = CoreText.decodeHTMLEntities(item.viewurl);
|
||||||
const modal = await CoreLoadings.show();
|
const modal = await CoreLoadings.show();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
import { Component, Input, Output, EventEmitter, OnInit } from '@angular/core';
|
import { Component, Input, Output, EventEmitter, OnInit } from '@angular/core';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreLoadings } from '@services/loadings';
|
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 { CoreEnrolledCourseDataWithOptions } from '@features/courses/services/courses-helper';
|
||||||
import { AddonBlockTimelineDayEvents } from '@addons/block/timeline/classes/section';
|
import { AddonBlockTimelineDayEvents } from '@addons/block/timeline/classes/section';
|
||||||
import { CoreSharedModule } from '@/core/shared.module';
|
import { CoreSharedModule } from '@/core/shared.module';
|
||||||
|
@ -64,7 +64,7 @@ export class AddonBlockTimelineEventsComponent implements OnInit {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
// Fix URL format.
|
// Fix URL format.
|
||||||
url = CoreTextUtils.decodeHTMLEntities(url);
|
url = CoreText.decodeHTMLEntities(url);
|
||||||
|
|
||||||
const modal = await CoreLoadings.show();
|
const modal = await CoreLoadings.show();
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
|
||||||
import { CoreNavigator } from '@services/navigator';
|
import { CoreNavigator } from '@services/navigator';
|
||||||
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
|
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreFileHelper } from '@services/file-helper';
|
||||||
import { CoreUrl } from '@singletons/url';
|
import { CoreUrl } from '@singletons/url';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { CoreArray } from '@singletons/array';
|
import { CoreArray } from '@singletons/array';
|
||||||
|
@ -212,7 +212,7 @@ export class AddonBlogIndexPage implements OnInit, OnDestroy {
|
||||||
entry.contextInstanceId = entry.userid;
|
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));
|
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 { CoreNetwork } from '@services/network';
|
||||||
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreCourse } from '@features/course/services/course';
|
import { CoreCourse } from '@features/course/services/course';
|
||||||
import { CoreTimeUtils } from '@services/utils/time';
|
import { CoreTimeUtils } from '@services/utils/time';
|
||||||
|
@ -45,6 +45,7 @@ import { CoreConfig } from '@services/config';
|
||||||
import { CoreToasts, ToastDuration } from '@services/toasts';
|
import { CoreToasts, ToastDuration } from '@services/toasts';
|
||||||
import { CorePopovers } from '@services/popovers';
|
import { CorePopovers } from '@services/popovers';
|
||||||
import { CoreLoadings } from '@services/loadings';
|
import { CoreLoadings } from '@services/loadings';
|
||||||
|
import { CoreUrl } from '@singletons/url';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Page that displays a single calendar event.
|
* Page that displays a single calendar event.
|
||||||
|
@ -288,8 +289,8 @@ export class AddonCalendarEventPage implements OnInit, OnDestroy {
|
||||||
|
|
||||||
if (this.event.location) {
|
if (this.event.location) {
|
||||||
// Build a link to open the address in maps.
|
// Build a link to open the address in maps.
|
||||||
this.event.location = CoreTextUtils.decodeHTML(this.event.location);
|
this.event.location = CoreText.decodeHTML(this.event.location);
|
||||||
this.event.encodedLocation = CoreTextUtils.buildAddressURL(this.event.location);
|
this.event.encodedLocation = CoreUrl.buildAddressURL(this.event.location);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if event was deleted in offine.
|
// Check if event was deleted in offine.
|
||||||
|
|
|
@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreSite } from '@classes/sites/site';
|
import { CoreSite } from '@classes/sites/site';
|
||||||
import { CoreNetwork } from '@services/network';
|
import { CoreNetwork } from '@services/network';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreTimeUtils } from '@services/utils/time';
|
import { CoreTimeUtils } from '@services/utils/time';
|
||||||
import { CoreUrl } from '@singletons/url';
|
import { CoreUrl } from '@singletons/url';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
|
@ -330,7 +330,7 @@ export class AddonCalendarProvider {
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
|
|
||||||
const getTimeHtml = (time: string, a11yLangKey: string): 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 getStartTimeHtml = (time: string): string => getTimeHtml(time, 'core.startingtime');
|
||||||
const getEndTimeHtml = (time: string): string => getTimeHtml(time, 'core.endingtime');
|
const getEndTimeHtml = (time: string): string => getTimeHtml(time, 'core.endingtime');
|
||||||
|
|
||||||
|
@ -666,18 +666,18 @@ export class AddonCalendarProvider {
|
||||||
eventConverted.iscategoryevent = originalEvent.eventtype == AddonCalendarEventType.CATEGORY;
|
eventConverted.iscategoryevent = originalEvent.eventtype == AddonCalendarEventType.CATEGORY;
|
||||||
eventConverted.normalisedeventtype = this.getEventType(recordAsRecord);
|
eventConverted.normalisedeventtype = this.getEventType(recordAsRecord);
|
||||||
try {
|
try {
|
||||||
eventConverted.category = CoreTextUtils.parseJSON(recordAsRecord.category || '');
|
eventConverted.category = CoreText.parseJSON(recordAsRecord.category || '');
|
||||||
} catch {
|
} catch {
|
||||||
// Ignore errors.
|
// Ignore errors.
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
eventConverted.course = CoreTextUtils.parseJSON(recordAsRecord.course || '');
|
eventConverted.course = CoreText.parseJSON(recordAsRecord.course || '');
|
||||||
} catch {
|
} catch {
|
||||||
// Ignore errors.
|
// Ignore errors.
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
eventConverted.subscription = CoreTextUtils.parseJSON(recordAsRecord.subscription || '');
|
eventConverted.subscription = CoreText.parseJSON(recordAsRecord.subscription || '');
|
||||||
} catch {
|
} catch {
|
||||||
// Ignore errors.
|
// Ignore errors.
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ import { makeSingleton } from '@singletons';
|
||||||
import { CoreH5PPlayerComponent } from '@features/h5p/components/h5p-player/h5p-player';
|
import { CoreH5PPlayerComponent } from '@features/h5p/components/h5p-player/h5p-player';
|
||||||
import { CoreUrl } from '@singletons/url';
|
import { CoreUrl } from '@singletons/url';
|
||||||
import { CoreH5PHelper } from '@features/h5p/classes/helper';
|
import { CoreH5PHelper } from '@features/h5p/classes/helper';
|
||||||
|
import { CoreText } from '@singletons/text';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler to support the Display H5P filter.
|
* Handler to support the Display H5P filter.
|
||||||
|
@ -30,47 +31,45 @@ export class AddonFilterDisplayH5PHandlerService extends CoreFilterDefaultHandle
|
||||||
name = 'AddonFilterDisplayH5PHandler';
|
name = 'AddonFilterDisplayH5PHandler';
|
||||||
filterName = 'displayh5p';
|
filterName = 'displayh5p';
|
||||||
|
|
||||||
protected template = document.createElement('template'); // A template element to convert HTML to element.
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
filter(
|
filter(
|
||||||
text: string,
|
text: string,
|
||||||
): string | Promise<string> {
|
): string | Promise<string> {
|
||||||
this.template.innerHTML = text;
|
return CoreText.processHTML(text, (element) => {
|
||||||
|
const h5pIframes = <HTMLIFrameElement[]> Array.from(element.querySelectorAll('iframe.h5p-iframe'));
|
||||||
|
|
||||||
const h5pIframes = <HTMLIFrameElement[]> Array.from(this.template.content.querySelectorAll('iframe.h5p-iframe'));
|
// Replace all iframes with an empty div that will be treated in handleHtml.
|
||||||
|
h5pIframes.forEach((iframe) => {
|
||||||
|
const placeholder = document.createElement('div');
|
||||||
|
|
||||||
// Replace all iframes with an empty div that will be treated in handleHtml.
|
placeholder.classList.add('core-h5p-tmp-placeholder');
|
||||||
h5pIframes.forEach((iframe) => {
|
placeholder.setAttribute('data-player-src', iframe.src);
|
||||||
const placeholder = document.createElement('div');
|
|
||||||
|
|
||||||
placeholder.classList.add('core-h5p-tmp-placeholder');
|
iframe.parentElement?.replaceChild(placeholder, iframe);
|
||||||
placeholder.setAttribute('data-player-src', iframe.src);
|
});
|
||||||
|
|
||||||
iframe.parentElement?.replaceChild(placeholder, iframe);
|
// Handle H5P iframes embedded using the embed HTML code.
|
||||||
|
const embeddedH5PIframes = <HTMLIFrameElement[]> Array.from(
|
||||||
|
element.querySelectorAll('iframe.h5p-player'),
|
||||||
|
);
|
||||||
|
|
||||||
|
embeddedH5PIframes.forEach((iframe) => {
|
||||||
|
// Add the preventredirect param to allow authenticating if auto-login fails.
|
||||||
|
iframe.src = CoreUrl.addParamsToUrl(iframe.src, { preventredirect: false });
|
||||||
|
|
||||||
|
// Add resizer script so the H5P has the right height.
|
||||||
|
CoreH5PHelper.addResizerScript();
|
||||||
|
|
||||||
|
// If the iframe has a small height, add some minimum initial height so it's seen if auto-login fails.
|
||||||
|
const styleHeight = Number(iframe.style.height);
|
||||||
|
const height = Number(iframe.getAttribute('height'));
|
||||||
|
if ((!height || height < 400) && (!styleHeight || styleHeight < 400)) {
|
||||||
|
iframe.style.height = '400px';
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Handle H5P iframes embedded using the embed HTML code.
|
|
||||||
const embeddedH5PIframes = <HTMLIFrameElement[]> Array.from(this.template.content.querySelectorAll('iframe.h5p-player'));
|
|
||||||
|
|
||||||
embeddedH5PIframes.forEach((iframe) => {
|
|
||||||
// Add the preventredirect param to allow authenticating if auto-login fails.
|
|
||||||
iframe.src = CoreUrl.addParamsToUrl(iframe.src, { preventredirect: false });
|
|
||||||
|
|
||||||
// Add resizer script so the H5P has the right height.
|
|
||||||
CoreH5PHelper.addResizerScript();
|
|
||||||
|
|
||||||
// If the iframe has a small height, add some minimum initial height so it's seen if auto-login fails.
|
|
||||||
const styleHeight = Number(iframe.style.height);
|
|
||||||
const height = Number(iframe.getAttribute('height'));
|
|
||||||
if ((!height || height < 400) && (!styleHeight || styleHeight < 400)) {
|
|
||||||
iframe.style.height = '400px';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return this.template.innerHTML;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,7 +18,7 @@ import { CoreFilterDefaultHandler } from '@features/filter/services/handlers/def
|
||||||
import { CoreFilterFilter, CoreFilterFormatTextOptions } from '@features/filter/services/filter';
|
import { CoreFilterFilter, CoreFilterFormatTextOptions } from '@features/filter/services/filter';
|
||||||
import { CoreLang } from '@services/lang';
|
import { CoreLang } from '@services/lang';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { CoreEvents } from '@singletons/events';
|
import { CoreEvents } from '@singletons/events';
|
||||||
import { CoreSite } from '@classes/sites/site';
|
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.
|
* @returns The whole text with the span inserted around the defined substring.
|
||||||
*/
|
*/
|
||||||
protected insertSpan(text: string, start: number, end: number): string {
|
protected insertSpan(text: string, start: number, end: number): string {
|
||||||
return CoreTextUtils.substrReplace(
|
return CoreText.substrReplace(
|
||||||
text,
|
text,
|
||||||
'<span class="nolink">' + text.substring(start, end + 1) + '</span>',
|
'<span class="nolink">' + text.substring(start, end + 1) + '</span>',
|
||||||
start,
|
start,
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
import { CoreText } from '@singletons/text';
|
||||||
import { AddonFilterMediaPluginVideoJS } from '@addons/filter/mediaplugin/services/videojs';
|
import { AddonFilterMediaPluginVideoJS } from '@addons/filter/mediaplugin/services/videojs';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
|
@ -28,21 +29,17 @@ export class AddonFilterMediaPluginHandlerService extends CoreFilterDefaultHandl
|
||||||
name = 'AddonFilterMediaPluginHandler';
|
name = 'AddonFilterMediaPluginHandler';
|
||||||
filterName = 'mediaplugin';
|
filterName = 'mediaplugin';
|
||||||
|
|
||||||
protected template = document.createElement('template'); // A template element to convert HTML to element.
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
filter(text: string): string | Promise<string> {
|
filter(text: string): string | Promise<string> {
|
||||||
this.template.innerHTML = text;
|
return CoreText.processHTML(text, (element) => {
|
||||||
|
const videos = Array.from(element.querySelectorAll('video'));
|
||||||
|
|
||||||
const videos = Array.from(this.template.content.querySelectorAll('video'));
|
videos.forEach((video) => {
|
||||||
|
AddonFilterMediaPluginVideoJS.treatYoutubeVideos(video);
|
||||||
videos.forEach((video) => {
|
});
|
||||||
AddonFilterMediaPluginVideoJS.treatYoutubeVideos(video);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return this.template.innerHTML;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
|
||||||
import { CorePromisedValue } from '@classes/promised-value';
|
import { CorePromisedValue } from '@classes/promised-value';
|
||||||
import { CoreExternalContentDirective } from '@directives/external-content';
|
import { CoreExternalContentDirective } from '@directives/external-content';
|
||||||
import { CoreLang } from '@services/lang';
|
import { CoreLang } from '@services/lang';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreUrl } from '@singletons/url';
|
import { CoreUrl } from '@singletons/url';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { CoreDirectivesRegistry } from '@singletons/directives-registry';
|
import { CoreDirectivesRegistry } from '@singletons/directives-registry';
|
||||||
|
@ -64,7 +64,7 @@ export class AddonFilterMediaPluginVideoJSService {
|
||||||
// Create player.
|
// Create player.
|
||||||
const videojs = await this.getVideoJS();
|
const videojs = await this.getVideoJS();
|
||||||
const dataSetupString = element.getAttribute('data-setup') || element.getAttribute('data-setup-lazy') || '{}';
|
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(
|
const player = videojs(
|
||||||
element,
|
element,
|
||||||
{
|
{
|
||||||
|
@ -106,7 +106,7 @@ export class AddonFilterMediaPluginVideoJSService {
|
||||||
}
|
}
|
||||||
|
|
||||||
const dataSetupString = video.getAttribute('data-setup') || video.getAttribute('data-setup-lazy') || '{}';
|
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);
|
const youtubeUrl = data.techOrder?.[0] == 'youtube' && CoreUrl.getYoutubeEmbedUrl(data.sources?.[0]?.src);
|
||||||
|
|
||||||
if (!youtubeUrl) {
|
if (!youtubeUrl) {
|
||||||
|
|
|
@ -32,7 +32,6 @@ import { AddonMessagesSync, AddonMessagesSyncProvider } from '../../services/mes
|
||||||
import { CoreUser } from '@features/user/services/user';
|
import { CoreUser } from '@features/user/services/user';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
|
||||||
import { CoreLogger } from '@singletons/logger';
|
import { CoreLogger } from '@singletons/logger';
|
||||||
import { CoreInfiniteLoadingComponent } from '@components/infinite-loading/infinite-loading';
|
import { CoreInfiniteLoadingComponent } from '@components/infinite-loading/infinite-loading';
|
||||||
import { Md5 } from 'ts-md5/dist/md5';
|
import { Md5 } from 'ts-md5/dist/md5';
|
||||||
|
@ -928,7 +927,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView
|
||||||
*/
|
*/
|
||||||
copyMessage(message: AddonMessagesConversationMessageFormatted): void {
|
copyMessage(message: AddonMessagesConversationMessageFormatted): void {
|
||||||
const text = 'smallmessage' in message ? message.smallmessage || message.text || '' : message.text || '';
|
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 { CoreConstants } from '@/core/constants';
|
||||||
import { AddonNotificationsPreferencesNotificationProcessorState } from '@addons/notifications/services/notifications';
|
import { AddonNotificationsPreferencesNotificationProcessorState } from '@addons/notifications/services/notifications';
|
||||||
import { CorePlatform } from '@services/platform';
|
import { CorePlatform } from '@services/platform';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreErrorHelper } from '@services/error-helper';
|
||||||
import { CoreLoadings } from '@services/loadings';
|
import { CoreLoadings } from '@services/loadings';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -112,7 +112,7 @@ export class AddonMessagesSettingsPage implements OnInit, OnDestroy {
|
||||||
this.warningMessage.set(undefined);
|
this.warningMessage.set(undefined);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.errorcode === 'nopermissions') {
|
if (error.errorcode === 'nopermissions') {
|
||||||
this.warningMessage.set(CoreTextUtils.getErrorMessageFromError(error));
|
this.warningMessage.set(CoreErrorHelper.getErrorMessageFromError(error));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreNetwork } from '@services/network';
|
import { CoreNetwork } from '@services/network';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import {
|
import {
|
||||||
AddonMessagesOfflineConversationMessagesDBRecord,
|
AddonMessagesOfflineConversationMessagesDBRecord,
|
||||||
AddonMessagesOfflineMessagesDBRecord,
|
AddonMessagesOfflineMessagesDBRecord,
|
||||||
|
@ -227,7 +227,7 @@ export class AddonMessagesOfflineProvider {
|
||||||
text: message.text,
|
text: message.text,
|
||||||
timecreated: message.timecreated,
|
timecreated: message.timecreated,
|
||||||
deviceoffline: message.deviceoffline,
|
deviceoffline: message.deviceoffline,
|
||||||
conversation: message.conversation ? CoreTextUtils.parseJSON(message.conversation, undefined) : undefined,
|
conversation: message.conversation ? CoreText.parseJSON(message.conversation, undefined) : undefined,
|
||||||
pending: true,
|
pending: true,
|
||||||
useridfrom: userIdFrom,
|
useridfrom: userIdFrom,
|
||||||
};
|
};
|
||||||
|
|
|
@ -30,9 +30,9 @@ import { CoreNetwork } from '@services/network';
|
||||||
import { CoreConstants } from '@/core/constants';
|
import { CoreConstants } from '@/core/constants';
|
||||||
import { CoreUser } from '@features/user/services/user';
|
import { CoreUser } from '@features/user/services/user';
|
||||||
import { CoreError } from '@classes/errors/error';
|
import { CoreError } from '@classes/errors/error';
|
||||||
import { CoreTextErrorObject, CoreTextUtils } from '@services/utils/text';
|
|
||||||
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
|
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
|
||||||
import { CoreWait } from '@singletons/wait';
|
import { CoreWait } from '@singletons/wait';
|
||||||
|
import { CoreErrorHelper, CoreErrorObject } from '@services/error-helper';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service to sync messages.
|
* Service to sync messages.
|
||||||
|
@ -178,7 +178,7 @@ export class AddonMessagesSyncProvider extends CoreSyncBaseProvider<AddonMessage
|
||||||
|
|
||||||
const groupMessagingEnabled = AddonMessages.isGroupMessagingEnabled();
|
const groupMessagingEnabled = AddonMessages.isGroupMessagingEnabled();
|
||||||
let messages: AddonMessagesOfflineAnyMessagesFormatted[];
|
let messages: AddonMessagesOfflineAnyMessagesFormatted[];
|
||||||
const errors: (string | CoreError | CoreTextErrorObject)[] = [];
|
const errors: (string | CoreError | CoreErrorObject)[] = [];
|
||||||
|
|
||||||
if (conversationId) {
|
if (conversationId) {
|
||||||
this.logger.debug(`Try to sync conversation '${conversationId}'`);
|
this.logger.debug(`Try to sync conversation '${conversationId}'`);
|
||||||
|
@ -336,7 +336,7 @@ export class AddonMessagesSyncProvider extends CoreSyncBaseProvider<AddonMessage
|
||||||
protected async handleSyncErrors(
|
protected async handleSyncErrors(
|
||||||
conversationId?: number,
|
conversationId?: number,
|
||||||
userId?: number,
|
userId?: number,
|
||||||
errors: (string | CoreError | CoreTextErrorObject)[] = [],
|
errors: (string | CoreError | CoreErrorObject)[] = [],
|
||||||
warnings: string[] = [],
|
warnings: string[] = [],
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
if (!errors || errors.length <= 0) {
|
if (!errors || errors.length <= 0) {
|
||||||
|
@ -356,7 +356,7 @@ export class AddonMessagesSyncProvider extends CoreSyncBaseProvider<AddonMessage
|
||||||
errors.forEach((error) => {
|
errors.forEach((error) => {
|
||||||
warnings.push(Translate.instant('addon.messages.warningconversationmessagenotsent', {
|
warnings.push(Translate.instant('addon.messages.warningconversationmessagenotsent', {
|
||||||
conversation: conversationIdentifier,
|
conversation: conversationIdentifier,
|
||||||
error: CoreTextUtils.getErrorMessageFromError(error),
|
error: CoreErrorHelper.getErrorMessageFromError(error),
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
} else if (userId) {
|
} else if (userId) {
|
||||||
|
@ -373,7 +373,7 @@ export class AddonMessagesSyncProvider extends CoreSyncBaseProvider<AddonMessage
|
||||||
errors.forEach((error) => {
|
errors.forEach((error) => {
|
||||||
warnings.push(Translate.instant('addon.messages.warningmessagenotsent', {
|
warnings.push(Translate.instant('addon.messages.warningmessagenotsent', {
|
||||||
user: userIdentifier,
|
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 { AddonModAssignHelper, AddonModAssignSubmissionFormatted } from '../../services/assign-helper';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { Translate } from '@singletons';
|
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 { CoreCourse, CoreCourseModuleGradeInfo, CoreCourseModuleGradeOutcome } from '@features/course/services/course';
|
||||||
import { AddonModAssignOffline } from '../../services/assign-offline';
|
import { AddonModAssignOffline } from '../../services/assign-offline';
|
||||||
import { CoreUser, CoreUserProfile } from '@features/user/services/user';
|
import { CoreUser, CoreUserProfile } from '@features/user/services/user';
|
||||||
|
@ -1078,7 +1078,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can
|
||||||
if (!grade.outcomeid && !grade.scaleid) {
|
if (!grade.outcomeid && !grade.scaleid) {
|
||||||
|
|
||||||
// Clean HTML tags, grade can contain an icon.
|
// 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.
|
// Not using outcomes or scale, get the numeric grade.
|
||||||
if (this.grade.scale) {
|
if (this.grade.scale) {
|
||||||
this.grade.gradebookGrade = CoreUtils.formatFloat(
|
this.grade.gradebookGrade = CoreUtils.formatFloat(
|
||||||
|
@ -1099,7 +1099,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can
|
||||||
gradeInfo.outcomes?.forEach((outcome) => {
|
gradeInfo.outcomes?.forEach((outcome) => {
|
||||||
if (outcome.id == String(grade.outcomeid)) {
|
if (outcome.id == String(grade.outcomeid)) {
|
||||||
// Clean HTML tags, grade can contain an icon.
|
// Clean HTML tags, grade can contain an icon.
|
||||||
outcome.selected = CoreTextUtils.cleanTags(grade.gradeformatted || '');
|
outcome.selected = CoreText.cleanTags(grade.gradeformatted || '');
|
||||||
outcome.modified = grade.gradedategraded;
|
outcome.modified = grade.gradedategraded;
|
||||||
if (outcome.options) {
|
if (outcome.options) {
|
||||||
outcome.selectedId = CoreGradesHelper.getGradeValueFromLabel(outcome.options, outcome.selected);
|
outcome.selectedId = CoreGradesHelper.getGradeValueFromLabel(outcome.options, outcome.selected);
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
import { Component, OnInit, ElementRef } from '@angular/core';
|
import { Component, OnInit, ElementRef } from '@angular/core';
|
||||||
import { FormBuilder, FormControl } from '@angular/forms';
|
import { FormBuilder, FormControl } from '@angular/forms';
|
||||||
import { AddonModAssign } from '@addons/mod/assign/services/assign';
|
import { AddonModAssign } from '@addons/mod/assign/services/assign';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreFileHelper } from '@services/file-helper';
|
||||||
import {
|
import {
|
||||||
AddonModAssignFeedbackCommentsDraftData,
|
AddonModAssignFeedbackCommentsDraftData,
|
||||||
AddonModAssignFeedbackCommentsHandler,
|
AddonModAssignFeedbackCommentsHandler,
|
||||||
|
@ -159,7 +159,7 @@ export class AddonModAssignFeedbackCommentsComponent extends AddonModAssignFeedb
|
||||||
replacePluginfileUrls(text: string): string {
|
replacePluginfileUrls(text: string): string {
|
||||||
const files = this.plugin.fileareas && this.plugin.fileareas[0] && this.plugin.fileareas[0].files;
|
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 { AddonModAssignFeedbackHandler } from '@addons/mod/assign/services/feedback-delegate';
|
||||||
import { Injectable, Type } from '@angular/core';
|
import { Injectable, Type } from '@angular/core';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { CoreWSFile } from '@services/ws';
|
import { CoreWSFile } from '@services/ws';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { AddonModAssignFeedbackCommentsComponent } from '../component/comments';
|
import { AddonModAssignFeedbackCommentsComponent } from '../component/comments';
|
||||||
|
import { CoreFileHelper } from '@services/file-helper';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler for comments feedback plugin.
|
* 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 : [];
|
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) {
|
if (draft) {
|
||||||
// Add some HTML to the text if needed.
|
// Add some HTML to the text if needed.
|
||||||
draft.text = CoreTextUtils.formatHtmlLines(draft.text);
|
draft.text = CoreText.formatHtmlLines(draft.text);
|
||||||
|
|
||||||
pluginData.assignfeedbackcomments_editor = draft;
|
pluginData.assignfeedbackcomments_editor = draft;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ import { CoreError } from '@classes/errors/error';
|
||||||
import { SQLiteDBRecordValues } from '@classes/sqlitedb';
|
import { SQLiteDBRecordValues } from '@classes/sqlitedb';
|
||||||
import { CoreFile } from '@services/file';
|
import { CoreFile } from '@services/file';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreTimeUtils } from '@services/utils/time';
|
import { CoreTimeUtils } from '@services/utils/time';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { CorePath } from '@singletons/path';
|
import { CorePath } from '@singletons/path';
|
||||||
|
@ -137,7 +137,7 @@ export class AddonModAssignOfflineProvider {
|
||||||
assignid: submission.assignid,
|
assignid: submission.assignid,
|
||||||
userid: submission.userid,
|
userid: submission.userid,
|
||||||
courseid: submission.courseid,
|
courseid: submission.courseid,
|
||||||
plugindata: CoreTextUtils.parseJSON<AddonModAssignSavePluginData>(submission.plugindata, {}),
|
plugindata: CoreText.parseJSON<AddonModAssignSavePluginData>(submission.plugindata, {}),
|
||||||
onlinetimemodified: submission.onlinetimemodified,
|
onlinetimemodified: submission.onlinetimemodified,
|
||||||
timecreated: submission.timecreated,
|
timecreated: submission.timecreated,
|
||||||
timemodified: submission.timemodified,
|
timemodified: submission.timemodified,
|
||||||
|
@ -195,8 +195,8 @@ export class AddonModAssignOfflineProvider {
|
||||||
addattempt: submission.addattempt,
|
addattempt: submission.addattempt,
|
||||||
workflowstate: submission.workflowstate,
|
workflowstate: submission.workflowstate,
|
||||||
applytoall: submission.applytoall,
|
applytoall: submission.applytoall,
|
||||||
outcomes: CoreTextUtils.parseJSON<AddonModAssignOutcomes>(submission.outcomes, {}),
|
outcomes: CoreText.parseJSON<AddonModAssignOutcomes>(submission.outcomes, {}),
|
||||||
plugindata: CoreTextUtils.parseJSON<AddonModAssignSavePluginData>(submission.plugindata, {}),
|
plugindata: CoreText.parseJSON<AddonModAssignSavePluginData>(submission.plugindata, {}),
|
||||||
timemodified: submission.timemodified,
|
timemodified: submission.timemodified,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ import { CoreInterceptor } from '@classes/interceptor';
|
||||||
import { CoreWSExternalWarning, CoreWSExternalFile, CoreWSFile } from '@services/ws';
|
import { CoreWSExternalWarning, CoreWSExternalFile, CoreWSFile } from '@services/ws';
|
||||||
import { makeSingleton, Translate } from '@singletons';
|
import { makeSingleton, Translate } from '@singletons';
|
||||||
import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
|
import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
|
||||||
import { CoreGrades } from '@features/grades/services/grades';
|
import { CoreGrades } from '@features/grades/services/grades';
|
||||||
import { CoreTimeUtils } from '@services/utils/time';
|
import { CoreTimeUtils } from '@services/utils/time';
|
||||||
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
||||||
|
@ -431,7 +430,7 @@ export class AddonModAssignProvider {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!keepUrls && submissionPlugin.fileareas && submissionPlugin.fileareas[0]) {
|
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;
|
return text;
|
||||||
|
|
|
@ -18,7 +18,7 @@ import { AddonModAssignOffline } from '@addons/mod/assign/services/assign-offlin
|
||||||
import { Component, OnInit, ElementRef } from '@angular/core';
|
import { Component, OnInit, ElementRef } from '@angular/core';
|
||||||
import { FormBuilder, FormControl } from '@angular/forms';
|
import { FormBuilder, FormControl } from '@angular/forms';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { AddonModAssignSubmissionOnlineTextPluginData } from '../services/handler';
|
import { AddonModAssignSubmissionOnlineTextPluginData } from '../services/handler';
|
||||||
import { ContextLevel } from '@/core/constants';
|
import { ContextLevel } from '@/core/constants';
|
||||||
|
@ -102,7 +102,7 @@ export class AddonModAssignSubmissionOnlineTextComponent extends AddonModAssignS
|
||||||
|
|
||||||
// Calculate initial words.
|
// Calculate initial words.
|
||||||
if (this.wordLimitEnabled) {
|
if (this.wordLimitEnabled) {
|
||||||
this.words = CoreTextUtils.countWords(this.text);
|
this.words = CoreText.countWords(this.text);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
this.loaded = true;
|
this.loaded = true;
|
||||||
|
@ -123,7 +123,7 @@ export class AddonModAssignSubmissionOnlineTextComponent extends AddonModAssignS
|
||||||
// Wait before calculating, if the user keeps inputing we won't calculate.
|
// 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 is to prevent slowing down devices, this calculation can be slow if the text is long.
|
||||||
this.wordCountTimeout = window.setTimeout(() => {
|
this.wordCountTimeout = window.setTimeout(() => {
|
||||||
this.words = CoreTextUtils.countWords(text);
|
this.words = CoreText.countWords(text);
|
||||||
}, 1500);
|
}, 1500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ import { AddonModAssignSubmissionHandler } from '@addons/mod/assign/services/sub
|
||||||
import { Injectable, Type } from '@angular/core';
|
import { Injectable, Type } from '@angular/core';
|
||||||
import { CoreError } from '@classes/errors/error';
|
import { CoreError } from '@classes/errors/error';
|
||||||
import { CoreFileHelper } from '@services/file-helper';
|
import { CoreFileHelper } from '@services/file-helper';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { CoreWSFile } from '@services/ws';
|
import { CoreWSFile } from '@services/ws';
|
||||||
import { makeSingleton, Translate } from '@singletons';
|
import { makeSingleton, Translate } from '@singletons';
|
||||||
|
@ -139,7 +139,7 @@ export class AddonModAssignSubmissionOnlineTextHandlerService implements AddonMo
|
||||||
const text = inputData.onlinetext_editor_text;
|
const text = inputData.onlinetext_editor_text;
|
||||||
const files = plugin.fileareas && plugin.fileareas[0] && plugin.fileareas[0].files || [];
|
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.
|
// Check word limit.
|
||||||
const configs = AddonModAssignHelper.getPluginConfig(assign, 'assignsubmission', plugin.type);
|
const configs = AddonModAssignHelper.getPluginConfig(assign, 'assignsubmission', plugin.type);
|
||||||
if (parseInt(configs.wordlimitenabled, 10)) {
|
if (parseInt(configs.wordlimitenabled, 10)) {
|
||||||
const words = CoreTextUtils.countWords(text);
|
const words = CoreText.countWords(text);
|
||||||
const wordlimit = parseInt(configs.wordlimit, 10);
|
const wordlimit = parseInt(configs.wordlimit, 10);
|
||||||
if (words > wordlimit) {
|
if (words > wordlimit) {
|
||||||
const params = { $a: { count: words, limit: 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.
|
// Add some HTML to the text if needed.
|
||||||
text = CoreTextUtils.formatHtmlLines(text);
|
text = CoreText.formatHtmlLines(text);
|
||||||
|
|
||||||
pluginData.onlinetext_editor = {
|
pluginData.onlinetext_editor = {
|
||||||
text: text,
|
text: text,
|
||||||
|
|
|
@ -21,7 +21,7 @@ import { CoreApp } from '@services/app';
|
||||||
import { CoreGroupInfo, CoreGroups } from '@services/groups';
|
import { CoreGroupInfo, CoreGroups } from '@services/groups';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreTimeUtils } from '@services/utils/time';
|
import { CoreTimeUtils } from '@services/utils/time';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { Translate } from '@singletons';
|
import { Translate } from '@singletons';
|
||||||
|
@ -33,6 +33,7 @@ import {
|
||||||
} from '../../services/bigbluebuttonbn';
|
} from '../../services/bigbluebuttonbn';
|
||||||
import { ADDON_MOD_BBB_COMPONENT } from '../../constants';
|
import { ADDON_MOD_BBB_COMPONENT } from '../../constants';
|
||||||
import { CoreLoadings } from '@services/loadings';
|
import { CoreLoadings } from '@services/loadings';
|
||||||
|
import { convertTextToHTMLElement } from '@/core/utils/create-html-element';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component that displays a Big Blue Button activity.
|
* Component that displays a Big Blue Button activity.
|
||||||
|
@ -147,7 +148,7 @@ export class AddonModBBBIndexComponent extends CoreCourseModuleMainActivityCompo
|
||||||
|
|
||||||
this.recordings = recordingsTable.parsedData.map(recordingData => {
|
this.recordings = recordingsTable.parsedData.map(recordingData => {
|
||||||
const details: RecordingDetail[] = [];
|
const details: RecordingDetail[] = [];
|
||||||
const playbacksEl = CoreDomUtils.convertToElement(String(recordingData.playback));
|
const playbacksEl = convertTextToHTMLElement(String(recordingData.playback));
|
||||||
const playbacks: RecordingPlayback[] = Array.from(playbacksEl.querySelectorAll('a')).map(playbackAnchor => ({
|
const playbacks: RecordingPlayback[] = Array.from(playbacksEl.querySelectorAll('a')).map(playbackAnchor => ({
|
||||||
name: playbackAnchor.textContent ?? '',
|
name: playbackAnchor.textContent ?? '',
|
||||||
url: playbackAnchor.href,
|
url: playbackAnchor.href,
|
||||||
|
@ -164,7 +165,7 @@ export class AddonModBBBIndexComponent extends CoreCourseModuleMainActivityCompo
|
||||||
value = CoreTimeUtils.userDate(Number(value), 'core.strftimedaydate');
|
value = CoreTimeUtils.userDate(Number(value), 'core.strftimedaydate');
|
||||||
} else if (columnData.allowHTML && typeof value === 'string') {
|
} else if (columnData.allowHTML && typeof value === 'string') {
|
||||||
// If the HTML is empty, don't display it.
|
// If the HTML is empty, don't display it.
|
||||||
const valueElement = CoreDomUtils.convertToElement(value);
|
const valueElement = convertTextToHTMLElement(value);
|
||||||
if (!valueElement.querySelector('img') && (valueElement.textContent ?? '').trim() === '') {
|
if (!valueElement.querySelector('img') && (valueElement.textContent ?? '').trim() === '') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -185,7 +186,7 @@ export class AddonModBBBIndexComponent extends CoreCourseModuleMainActivityCompo
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: CoreTextUtils.cleanTags(String(recordingData.recording), { singleLine: true }),
|
name: CoreText.cleanTags(String(recordingData.recording), { singleLine: true }),
|
||||||
playbackLabel: columns.playback.label,
|
playbackLabel: columns.playback.label,
|
||||||
playbacks,
|
playbacks,
|
||||||
details,
|
details,
|
||||||
|
|
|
@ -20,7 +20,7 @@ import { CoreSite } from '@classes/sites/site';
|
||||||
import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
|
import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
|
||||||
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
||||||
import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites';
|
import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
|
import { CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
|
||||||
import { makeSingleton, Translate } from '@singletons';
|
import { makeSingleton, Translate } from '@singletons';
|
||||||
|
@ -247,7 +247,7 @@ export class AddonModBBBService {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...result.tabledata,
|
...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 { CoreNetwork } from '@services/network';
|
||||||
import { CoreNavigator } from '@services/navigator';
|
import { CoreNavigator } from '@services/navigator';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
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 { CoreUtils } from '@services/utils/utils';
|
||||||
import { Translate } from '@singletons';
|
import { Translate } from '@singletons';
|
||||||
import {
|
import {
|
||||||
|
@ -385,7 +385,7 @@ class AddonModBookSlidesItemsManagerSource extends CoreSwipeSlidesItemsManagerSo
|
||||||
|
|
||||||
return newChapters;
|
return newChapters;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (!CoreTextUtils.getErrorMessageFromError(error)) {
|
if (!CoreErrorHelper.getErrorMessageFromError(error)) {
|
||||||
throw new CoreError(Translate.instant('addon.mod_book.errorchapter'));
|
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 { CoreCourse, CoreCourseModuleContentFile } from '@features/course/services/course';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { CoreFilepool } from '@services/filepool';
|
import { CoreFilepool } from '@services/filepool';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreFile } from '@services/file';
|
import { CoreFile } from '@services/file';
|
||||||
import { CoreError } from '@classes/errors/error';
|
import { CoreError } from '@classes/errors/error';
|
||||||
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
|
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
|
||||||
import { ADDON_MOD_BOOK_COMPONENT } from '../constants';
|
import { ADDON_MOD_BOOK_COMPONENT } from '../constants';
|
||||||
|
import { CoreUrl } from '@singletons/url';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service that provides some features for books.
|
* Service that provides some features for books.
|
||||||
|
@ -177,7 +178,7 @@ export class AddonModBookProvider {
|
||||||
key = content.filepath.replace('/' + chapter + '/', '') + content.filename;
|
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;
|
return map;
|
||||||
|
@ -224,7 +225,7 @@ export class AddonModBookProvider {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return CoreTextUtils.parseJSON(contents[0].content, []);
|
return CoreText.parseJSON(contents[0].content, []);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { AddonModChoiceResponsesDBRecord, RESPONSES_TABLE_NAME } from './database/choice';
|
import { AddonModChoiceResponsesDBRecord, RESPONSES_TABLE_NAME } from './database/choice';
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ export class AddonModChoiceOfflineProvider {
|
||||||
protected parseResponse(entry: AddonModChoiceResponsesDBRecord): AddonModChoiceOfflineResponses {
|
protected parseResponse(entry: AddonModChoiceResponsesDBRecord): AddonModChoiceOfflineResponses {
|
||||||
return {
|
return {
|
||||||
...entry,
|
...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 { CoreTag } from '@features/tag/services/tag';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreFormFields, CoreForms } from '@singletons/form';
|
import { CoreFormFields, CoreForms } from '@singletons/form';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { ModalController } from '@singletons';
|
import { ModalController } from '@singletons';
|
||||||
import {
|
import {
|
||||||
|
@ -78,7 +78,7 @@ export class AddonModDataSearchModalComponent implements OnInit {
|
||||||
this.search.advanced?.forEach((field) => {
|
this.search.advanced?.forEach((field) => {
|
||||||
if (field !== undefined) {
|
if (field !== undefined) {
|
||||||
this.advancedIndexed[field.name] = field.value
|
this.advancedIndexed[field.name] = field.value
|
||||||
? CoreTextUtils.parseJSON(field.value, '')
|
? CoreText.parseJSON(field.value, '')
|
||||||
: '';
|
: '';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { AddonModDataFieldPluginBaseComponent } from '../../../classes/base-field-plugin-component';
|
import { AddonModDataFieldPluginBaseComponent } from '../../../classes/base-field-plugin-component';
|
||||||
import { AddonModDataEntryField } from '@addons/mod/data/services/data';
|
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 { CoreWSFile } from '@services/ws';
|
||||||
import { ADDON_MOD_DATA_COMPONENT } from '@addons/mod/data/constants';
|
import { ADDON_MOD_DATA_COMPONENT } from '@addons/mod/data/constants';
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ export class AddonModDataFieldTextareaComponent extends AddonModDataFieldPluginB
|
||||||
format(value?: Partial<AddonModDataEntryField>): string {
|
format(value?: Partial<AddonModDataEntryField>): string {
|
||||||
const files: CoreWSFile[] = (value && <CoreWSFile[]>value.files) || [];
|
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 { AddonModDataEntryField, AddonModDataField, AddonModDataSubfieldData } from '@addons/mod/data/services/data';
|
||||||
import { Injectable, Type } from '@angular/core';
|
import { Injectable, Type } from '@angular/core';
|
||||||
import { CoreFormFields } from '@singletons/form';
|
import { CoreFormFields } from '@singletons/form';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreWSFile } from '@services/ws';
|
import { CoreWSFile } from '@services/ws';
|
||||||
import { makeSingleton, Translate } from '@singletons';
|
import { makeSingleton, Translate } from '@singletons';
|
||||||
import { AddonModDataFieldTextHandlerService } from '../../text/services/handler';
|
import { AddonModDataFieldTextHandlerService } from '../../text/services/handler';
|
||||||
import { AddonModDataFieldTextareaComponent } from '../component/textarea';
|
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 type { AddonModDataFieldPluginBaseComponent } from '@addons/mod/data/classes/base-field-plugin-component';
|
||||||
|
import { CoreDom } from '@singletons/dom';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler for textarea data field plugin.
|
* Handler for textarea data field plugin.
|
||||||
|
@ -50,12 +51,12 @@ export class AddonModDataFieldTextareaHandlerService extends AddonModDataFieldTe
|
||||||
const fieldName = 'f_' + field.id;
|
const fieldName = 'f_' + field.id;
|
||||||
const files = this.getFieldEditFiles(field, inputData, originalFieldData);
|
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.
|
// 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.
|
// WS does not properly check if HTML content is blank when the field is required.
|
||||||
if (CoreTextUtils.htmlIsBlank(text)) {
|
if (CoreDom.htmlIsBlank(text)) {
|
||||||
text = '';
|
text = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +103,7 @@ export class AddonModDataFieldTextareaHandlerService extends AddonModDataFieldTe
|
||||||
|
|
||||||
const value = inputData.find((value) => value.subfield == '');
|
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');
|
return Translate.instant('addon.mod_data.errormustsupplyvalue');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +116,7 @@ export class AddonModDataFieldTextareaHandlerService extends AddonModDataFieldTe
|
||||||
originalContent.content = offlineContent[''] || '';
|
originalContent.content = offlineContent[''] || '';
|
||||||
if (originalContent.content.length > 0 && originalContent.files && originalContent.files.length > 0) {
|
if (originalContent.content.length > 0 && originalContent.files && originalContent.files.length > 0) {
|
||||||
// Take the original files since we cannot edit them on the app.
|
// Take the original files since we cannot edit them on the app.
|
||||||
originalContent.content = CoreTextUtils.replacePluginfileUrls(
|
originalContent.content = CoreFileHelper.replacePluginfileUrls(
|
||||||
originalContent.content,
|
originalContent.content,
|
||||||
<CoreWSFile[]> originalContent.files,
|
<CoreWSFile[]> originalContent.files,
|
||||||
);
|
);
|
||||||
|
|
|
@ -40,7 +40,7 @@ import {
|
||||||
import { AddonModDataHelper } from '../../services/data-helper';
|
import { AddonModDataHelper } from '../../services/data-helper';
|
||||||
import { CoreDom } from '@singletons/dom';
|
import { CoreDom } from '@singletons/dom';
|
||||||
import { AddonModDataEntryFieldInitialized } from '../../classes/base-field-plugin-component';
|
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 { CoreTime } from '@singletons/time';
|
||||||
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
|
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
|
||||||
import { ADDON_MOD_DATA_COMPONENT, ADDON_MOD_DATA_ENTRY_CHANGED, AddonModDataTemplateType } from '../../constants';
|
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) {
|
if (updateEntryResult.generalnotifications?.length) {
|
||||||
CoreDomUtils.showAlertWithOptions({
|
CoreDomUtils.showAlertWithOptions({
|
||||||
header: Translate.instant('core.notice'),
|
header: Translate.instant('core.notice'),
|
||||||
message: CoreTextUtils.buildMessage(updateEntryResult.generalnotifications),
|
message: CoreText.buildMessage(updateEntryResult.generalnotifications),
|
||||||
buttons: [Translate.instant('core.ok')],
|
buttons: [Translate.instant('core.ok')],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ import { FileEntry } from '@awesome-cordova-plugins/file/ngx';
|
||||||
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
|
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreFormFields } from '@singletons/form';
|
import { CoreFormFields } from '@singletons/form';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { makeSingleton, Translate } from '@singletons';
|
import { makeSingleton, Translate } from '@singletons';
|
||||||
import { CoreEvents } from '@singletons/events';
|
import { CoreEvents } from '@singletons/events';
|
||||||
|
@ -97,9 +97,9 @@ export class AddonModDataHelperProvider {
|
||||||
|
|
||||||
if (offlineContent.subfield) {
|
if (offlineContent.subfield) {
|
||||||
offlineContents[offlineContent.fieldid][offlineContent.subfield] =
|
offlineContents[offlineContent.fieldid][offlineContent.subfield] =
|
||||||
CoreTextUtils.parseJSON(offlineContent.value, '');
|
CoreText.parseJSON(offlineContent.value, '');
|
||||||
} else {
|
} 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 { CoreFileUploader, CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader';
|
||||||
import { CoreFile } from '@services/file';
|
import { CoreFile } from '@services/file';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { CorePath } from '@singletons/path';
|
import { CorePath } from '@singletons/path';
|
||||||
|
@ -90,7 +90,7 @@ export class AddonModDataOfflineProvider {
|
||||||
const promises: Promise<void>[] = [];
|
const promises: Promise<void>[] = [];
|
||||||
|
|
||||||
entry.fields.forEach((field) => {
|
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) {
|
if (!value || !value.offline) {
|
||||||
return;
|
return;
|
||||||
|
@ -234,7 +234,7 @@ export class AddonModDataOfflineProvider {
|
||||||
*/
|
*/
|
||||||
protected parseRecord(record: AddonModDataEntryDBRecord): AddonModDataOfflineAction {
|
protected parseRecord(record: AddonModDataEntryDBRecord): AddonModDataOfflineAction {
|
||||||
return Object.assign(record, {
|
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 { CoreFileEntry } from '@services/file-helper';
|
||||||
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
|
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
|
||||||
import { CoreSync, CoreSyncResult } from '@services/sync';
|
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 { CoreUtils } from '@services/utils/utils';
|
||||||
import { Translate, makeSingleton } from '@singletons';
|
import { Translate, makeSingleton } from '@singletons';
|
||||||
import { CoreEvents } from '@singletons/events';
|
import { CoreEvents } from '@singletons/events';
|
||||||
|
@ -33,6 +33,7 @@ import { AddonModData, AddonModDataData } from './data';
|
||||||
import { AddonModDataHelper } from './data-helper';
|
import { AddonModDataHelper } from './data-helper';
|
||||||
import { AddonModDataOffline, AddonModDataOfflineAction } from './data-offline';
|
import { AddonModDataOffline, AddonModDataOfflineAction } from './data-offline';
|
||||||
import { ADDON_MOD_DATA_AUTO_SYNCED, ADDON_MOD_DATA_COMPONENT, AddonModDataAction } from '../constants';
|
import { ADDON_MOD_DATA_AUTO_SYNCED, ADDON_MOD_DATA_COMPONENT, AddonModDataAction } from '../constants';
|
||||||
|
import { CoreText } from '@singletons/text';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service to sync databases.
|
* Service to sync databases.
|
||||||
|
@ -326,7 +327,7 @@ export class AddonModDataSyncProvider extends CoreCourseActivitySyncBaseProvider
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error && CoreUtils.isWebServiceError(error)) {
|
if (error && CoreUtils.isWebServiceError(error)) {
|
||||||
// The WebService has thrown an error, this means it cannot be performed. Discard.
|
// The WebService has thrown an error, this means it cannot be performed. Discard.
|
||||||
entryResult.discardError = CoreTextUtils.getErrorMessageFromError(error);
|
entryResult.discardError = CoreErrorHelper.getErrorMessageFromError(error);
|
||||||
} else {
|
} else {
|
||||||
// Couldn't connect to server, reject.
|
// Couldn't connect to server, reject.
|
||||||
throw error;
|
throw error;
|
||||||
|
@ -345,7 +346,7 @@ export class AddonModDataSyncProvider extends CoreCourseActivitySyncBaseProvider
|
||||||
try {
|
try {
|
||||||
await Promise.all(editAction.fields.map(async (field) => {
|
await Promise.all(editAction.fields.map(async (field) => {
|
||||||
// Upload Files if asked.
|
// 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)) {
|
if (value && (value.online || value.offline)) {
|
||||||
let files: CoreFileEntry[] = value.online || [];
|
let files: CoreFileEntry[] = value.online || [];
|
||||||
|
|
||||||
|
@ -384,7 +385,7 @@ export class AddonModDataSyncProvider extends CoreCourseActivitySyncBaseProvider
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error && CoreUtils.isWebServiceError(error)) {
|
if (error && CoreUtils.isWebServiceError(error)) {
|
||||||
// The WebService has thrown an error, this means it cannot be performed. Discard.
|
// The WebService has thrown an error, this means it cannot be performed. Discard.
|
||||||
entryResult.discardError = CoreTextUtils.getErrorMessageFromError(error);
|
entryResult.discardError = CoreErrorHelper.getErrorMessageFromError(error);
|
||||||
} else {
|
} else {
|
||||||
// Couldn't connect to server, reject.
|
// Couldn't connect to server, reject.
|
||||||
throw error;
|
throw error;
|
||||||
|
@ -402,7 +403,7 @@ export class AddonModDataSyncProvider extends CoreCourseActivitySyncBaseProvider
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error && CoreUtils.isWebServiceError(error)) {
|
if (error && CoreUtils.isWebServiceError(error)) {
|
||||||
// The WebService has thrown an error, this means it cannot be performed. Discard.
|
// The WebService has thrown an error, this means it cannot be performed. Discard.
|
||||||
entryResult.discardError = CoreTextUtils.getErrorMessageFromError(error);
|
entryResult.discardError = CoreErrorHelper.getErrorMessageFromError(error);
|
||||||
} else {
|
} else {
|
||||||
// Couldn't connect to server, reject.
|
// Couldn't connect to server, reject.
|
||||||
throw error;
|
throw error;
|
||||||
|
|
|
@ -20,7 +20,7 @@ import { CoreCourseContentsPage } from '@features/course/pages/contents/contents
|
||||||
import { IonContent } from '@ionic/angular';
|
import { IonContent } from '@ionic/angular';
|
||||||
import { CoreGroupInfo, CoreGroups } from '@services/groups';
|
import { CoreGroupInfo, CoreGroups } from '@services/groups';
|
||||||
import { CoreNavigator } from '@services/navigator';
|
import { CoreNavigator } from '@services/navigator';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreTimeUtils } from '@services/utils/time';
|
import { CoreTimeUtils } from '@services/utils/time';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||||
|
@ -312,7 +312,7 @@ export class AddonModFeedbackIndexComponent extends CoreCourseModuleMainActivity
|
||||||
|
|
||||||
case 'info':
|
case 'info':
|
||||||
item.data = <string[]> item.data.map((dataItem) => {
|
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;
|
return parsed.show !== undefined ? parsed.show : false;
|
||||||
}).filter((dataItem) => dataItem); // Filter false entries.
|
}).filter((dataItem) => dataItem); // Filter false entries.
|
||||||
|
@ -325,7 +325,7 @@ export class AddonModFeedbackIndexComponent extends CoreCourseModuleMainActivity
|
||||||
case 'multichoicerated':
|
case 'multichoicerated':
|
||||||
case 'multichoice': {
|
case 'multichoice': {
|
||||||
const parsedData = <Record<string, string | number>[]> item.data.map((dataItem) => {
|
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;
|
return parsed.answertext !== undefined ? parsed : false;
|
||||||
}).filter((dataItem) => dataItem); // Filter false entries.
|
}).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 { CoreSwipeNavigationItemsManager } from '@classes/items-management/swipe-navigation-items-manager';
|
||||||
import { CoreNavigator } from '@services/navigator';
|
import { CoreNavigator } from '@services/navigator';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
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 { AddonModFeedbackAttemptsSource } from '../../classes/feedback-attempts-source';
|
||||||
import {
|
import {
|
||||||
AddonModFeedback,
|
AddonModFeedback,
|
||||||
|
@ -140,7 +140,7 @@ export class AddonModFeedbackAttemptPage implements OnInit, OnDestroy {
|
||||||
const attemptItem = <AddonModFeedbackAttemptItem> formItem;
|
const attemptItem = <AddonModFeedbackAttemptItem> formItem;
|
||||||
|
|
||||||
if (item.typ == 'label') {
|
if (item.typ == 'label') {
|
||||||
attemptItem.submittedValue = CoreTextUtils.replacePluginfileUrls(item.presentation, item.itemfiles);
|
attemptItem.submittedValue = CoreFileHelper.replacePluginfileUrls(item.presentation, item.itemfiles);
|
||||||
} else {
|
} else {
|
||||||
for (const x in attempt.responses) {
|
for (const x in attempt.responses) {
|
||||||
if (attempt.responses[x].id == item.id) {
|
if (attempt.responses[x].id == item.id) {
|
||||||
|
|
|
@ -18,7 +18,7 @@ import { CoreUser } from '@features/user/services/user';
|
||||||
import { CoreNavigator } from '@services/navigator';
|
import { CoreNavigator } from '@services/navigator';
|
||||||
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
|
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
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 { CoreTimeUtils } from '@services/utils/time';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { makeSingleton, Translate } from '@singletons';
|
import { makeSingleton, Translate } from '@singletons';
|
||||||
|
@ -41,6 +41,7 @@ import {
|
||||||
ADDON_MOD_FEEDBACK_PAGE_NAME,
|
ADDON_MOD_FEEDBACK_PAGE_NAME,
|
||||||
} from '../constants';
|
} from '../constants';
|
||||||
import { CoreLoadings } from '@services/loadings';
|
import { CoreLoadings } from '@services/loadings';
|
||||||
|
import { CoreText } from '@singletons/text';
|
||||||
|
|
||||||
const MODE_RESPONSETIME = 1;
|
const MODE_RESPONSETIME = 1;
|
||||||
const MODE_COURSE = 2;
|
const MODE_COURSE = 2;
|
||||||
|
@ -253,7 +254,7 @@ export class AddonModFeedbackHelperProvider {
|
||||||
*/
|
*/
|
||||||
protected getItemFormLabel(item: AddonModFeedbackItem): AddonModFeedbackFormBasicItem {
|
protected getItemFormLabel(item: AddonModFeedbackItem): AddonModFeedbackFormBasicItem {
|
||||||
item.name = '';
|
item.name = '';
|
||||||
item.presentation = CoreTextUtils.replacePluginfileUrls(item.presentation, item.itemfiles);
|
item.presentation = CoreFileHelper.replacePluginfileUrls(item.presentation, item.itemfiles);
|
||||||
|
|
||||||
return Object.assign(item, {
|
return Object.assign(item, {
|
||||||
templateName: 'label',
|
templateName: 'label',
|
||||||
|
@ -421,7 +422,7 @@ export class AddonModFeedbackHelperProvider {
|
||||||
slottedLabel: false,
|
slottedLabel: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const data = <string[]> CoreTextUtils.parseJSON(item.otherdata);
|
const data = <string[]> CoreText.parseJSON(item.otherdata);
|
||||||
if (data && data.length > 3) {
|
if (data && data.length > 3) {
|
||||||
formItem.captcha = {
|
formItem.captcha = {
|
||||||
recaptchapublickey: data[3],
|
recaptchapublickey: data[3],
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreTimeUtils } from '@services/utils/time';
|
import { CoreTimeUtils } from '@services/utils/time';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { AddonModFeedbackResponseDBRecord, FEEDBACK_TABLE_NAME } from './database/feedback';
|
import { AddonModFeedbackResponseDBRecord, FEEDBACK_TABLE_NAME } from './database/feedback';
|
||||||
|
@ -116,7 +116,7 @@ export class AddonModFeedbackOfflineProvider {
|
||||||
*/
|
*/
|
||||||
protected parseResponse(record: AddonModFeedbackResponseDBRecord): AddonModFeedbackOfflineResponse {
|
protected parseResponse(record: AddonModFeedbackResponseDBRecord): AddonModFeedbackOfflineResponse {
|
||||||
return Object.assign(record, {
|
return Object.assign(record, {
|
||||||
responses: <Record<string, AddonModFeedbackResponseValue>> CoreTextUtils.parseJSON(record.responses),
|
responses: <Record<string, AddonModFeedbackResponseValue>> CoreText.parseJSON(record.responses),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ import { CoreModuleHandlerBase } from '@features/course/classes/module-base-hand
|
||||||
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||||
import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@features/course/services/module-delegate';
|
import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@features/course/services/module-delegate';
|
||||||
import { CoreNavigator } from '@services/navigator';
|
import { CoreNavigator } from '@services/navigator';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { convertTextToHTMLElement } from '@/core/utils/create-html-element';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { ADDON_MOD_FOLDER_PAGE_NAME } from '../../constants';
|
import { ADDON_MOD_FOLDER_PAGE_NAME } from '../../constants';
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ export class AddonModFolderModuleHandlerService extends CoreModuleHandlerBase im
|
||||||
|
|
||||||
if (module.description) {
|
if (module.description) {
|
||||||
// Module description can contain the folder contents if it's inline, remove it.
|
// Module description can contain the folder contents if it's inline, remove it.
|
||||||
const descriptionElement = CoreDomUtils.convertToElement(module.description);
|
const descriptionElement = convertTextToHTMLElement(module.description);
|
||||||
|
|
||||||
Array.from(descriptionElement.querySelectorAll('.foldertree, .folderbuttons, .tertiary-navigation'))
|
Array.from(descriptionElement.querySelectorAll('.foldertree, .folderbuttons, .tertiary-navigation'))
|
||||||
.forEach(element => element.remove());
|
.forEach(element => element.remove());
|
||||||
|
|
|
@ -41,7 +41,7 @@ import { Translate } from '@singletons';
|
||||||
import { CoreFileUploader } from '@features/fileuploader/services/fileuploader';
|
import { CoreFileUploader } from '@features/fileuploader/services/fileuploader';
|
||||||
import { AddonModForumSync } from '../../services/forum-sync';
|
import { AddonModForumSync } from '../../services/forum-sync';
|
||||||
import { CoreSync } from '@services/sync';
|
import { CoreSync } from '@services/sync';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { AddonModForumHelper } from '../../services/forum-helper';
|
import { AddonModForumHelper } from '../../services/forum-helper';
|
||||||
import { AddonModForumOffline } from '../../services/forum-offline';
|
import { AddonModForumOffline } from '../../services/forum-offline';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
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);
|
const modal = await CoreLoadings.show('core.sending', true);
|
||||||
|
|
||||||
// Add some HTML to the message if needed.
|
// Add some HTML to the message if needed.
|
||||||
message = CoreTextUtils.formatHtmlLines(message);
|
message = CoreText.formatHtmlLines(message);
|
||||||
|
|
||||||
// Upload attachments first if any.
|
// Upload attachments first if any.
|
||||||
let attachments;
|
let attachments;
|
||||||
|
|
|
@ -34,7 +34,7 @@ import { AddonModForumDiscussionOptions, AddonModForumOffline } from '@addons/mo
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { AddonModForumHelper } from '@addons/mod/forum/services/forum-helper';
|
import { AddonModForumHelper } from '@addons/mod/forum/services/forum-helper';
|
||||||
import { CoreFileUploader } from '@features/fileuploader/services/fileuploader';
|
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 { CanLeave } from '@guards/can-leave';
|
||||||
import { CoreSplitViewComponent } from '@components/split-view/split-view';
|
import { CoreSplitViewComponent } from '@components/split-view/split-view';
|
||||||
import { CoreForms } from '@singletons/form';
|
import { CoreForms } from '@singletons/form';
|
||||||
|
@ -553,7 +553,7 @@ export class AddonModForumNewDiscussionPage implements OnInit, OnDestroy, CanLea
|
||||||
const modal = await CoreLoadings.show('core.sending', true);
|
const modal = await CoreLoadings.show('core.sending', true);
|
||||||
|
|
||||||
// Add some HTML to the message if needed.
|
// Add some HTML to the message if needed.
|
||||||
message = CoreTextUtils.formatHtmlLines(message);
|
message = CoreText.formatHtmlLines(message);
|
||||||
|
|
||||||
if (pin) {
|
if (pin) {
|
||||||
options.discussionpinned = true;
|
options.discussionpinned = true;
|
||||||
|
|
|
@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
|
||||||
import { CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader';
|
import { CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader';
|
||||||
import { CoreFile } from '@services/file';
|
import { CoreFile } from '@services/file';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import {
|
import {
|
||||||
AddonModForumOfflineDiscussionDBRecord,
|
AddonModForumOfflineDiscussionDBRecord,
|
||||||
|
@ -399,7 +399,7 @@ export class AddonModForumOfflineProvider {
|
||||||
R extends { options: string },
|
R extends { options: string },
|
||||||
O extends Record<string, unknown> = Record<string, unknown>
|
O extends Record<string, unknown> = Record<string, unknown>
|
||||||
>(record: R): Omit<R, 'options'> & { options: O } {
|
>(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 };
|
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 { CoreConstants, ModPurpose } from '@/core/constants';
|
||||||
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
|
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
|
||||||
import { CoreCourseModuleData } from '@features/course/services/course-helper';
|
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 { CoreUser } from '@features/user/services/user';
|
||||||
import { ADDON_MOD_FORUM_MARK_READ_EVENT, ADDON_MOD_FORUM_PAGE_NAME } from '../../constants';
|
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 data = await super.getData(module, courseId);
|
||||||
|
|
||||||
const customData = module.customdata ?
|
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 ?
|
const trackingType = typeof customData !== 'string' && customData.trackingtype !== undefined ?
|
||||||
Number(customData.trackingtype) : undefined;
|
Number(customData.trackingtype) : undefined;
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ import { IonContent } from '@ionic/angular';
|
||||||
import { CoreNavigator } from '@services/navigator';
|
import { CoreNavigator } from '@services/navigator';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { Translate } from '@singletons';
|
import { Translate } from '@singletons';
|
||||||
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||||
import {
|
import {
|
||||||
|
@ -312,7 +312,7 @@ export class AddonModGlossaryIndexComponent extends CoreCourseModuleMainActivity
|
||||||
// Consider it is 'letter_all'.
|
// Consider it is 'letter_all'.
|
||||||
const getDivider = (entry) => {
|
const getDivider = (entry) => {
|
||||||
// Try to get the first letter without HTML tags.
|
// 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();
|
return (noTags || entry.concept).substring(0, 1).toUpperCase();
|
||||||
};
|
};
|
||||||
|
|
|
@ -24,7 +24,7 @@ import { CoreNavigator } from '@services/navigator';
|
||||||
import { CoreNetwork } from '@services/network';
|
import { CoreNetwork } from '@services/network';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { Translate } from '@singletons';
|
import { Translate } from '@singletons';
|
||||||
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||||
|
@ -472,7 +472,7 @@ class AddonModGlossaryOfflineFormHandler extends AddonModGlossaryFormHandler {
|
||||||
const originalData = this.page.originalData;
|
const originalData = this.page.originalData;
|
||||||
const data = this.page.data;
|
const data = this.page.data;
|
||||||
const options = this.getSaveOptions(glossary);
|
const options = this.getSaveOptions(glossary);
|
||||||
const definition = CoreTextUtils.formatHtmlLines(data.definition);
|
const definition = CoreText.formatHtmlLines(data.definition);
|
||||||
|
|
||||||
if (!originalData) {
|
if (!originalData) {
|
||||||
return;
|
return;
|
||||||
|
@ -561,7 +561,7 @@ class AddonModGlossaryNewFormHandler extends AddonModGlossaryFormHandler {
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const data = this.page.data;
|
const data = this.page.data;
|
||||||
const options = this.getSaveOptions(glossary);
|
const options = this.getSaveOptions(glossary);
|
||||||
const definition = CoreTextUtils.formatHtmlLines(data.definition);
|
const definition = CoreText.formatHtmlLines(data.definition);
|
||||||
|
|
||||||
await this.checkDuplicates(glossary);
|
await this.checkDuplicates(glossary);
|
||||||
await AddonModGlossaryOffline.addOfflineEntry(
|
await AddonModGlossaryOffline.addOfflineEntry(
|
||||||
|
@ -594,7 +594,7 @@ class AddonModGlossaryNewFormHandler extends AddonModGlossaryFormHandler {
|
||||||
): Promise<number | false> {
|
): Promise<number | false> {
|
||||||
const data = this.page.data;
|
const data = this.page.data;
|
||||||
const options = this.getSaveOptions(glossary);
|
const options = this.getSaveOptions(glossary);
|
||||||
const definition = CoreTextUtils.formatHtmlLines(data.definition);
|
const definition = CoreText.formatHtmlLines(data.definition);
|
||||||
const entryId = await AddonModGlossary.addEntry(
|
const entryId = await AddonModGlossary.addEntry(
|
||||||
glossary.id,
|
glossary.id,
|
||||||
data.concept,
|
data.concept,
|
||||||
|
@ -674,7 +674,7 @@ class AddonModGlossaryOnlineFormHandler extends AddonModGlossaryFormHandler {
|
||||||
|
|
||||||
const data = this.page.data;
|
const data = this.page.data;
|
||||||
const options = this.getSaveOptions(glossary);
|
const options = this.getSaveOptions(glossary);
|
||||||
const definition = CoreTextUtils.formatHtmlLines(data.definition);
|
const definition = CoreText.formatHtmlLines(data.definition);
|
||||||
|
|
||||||
// Upload attachments, if any.
|
// Upload attachments, if any.
|
||||||
let attachmentsId: number | undefined = undefined;
|
let attachmentsId: number | undefined = undefined;
|
||||||
|
|
|
@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
|
||||||
import { CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader';
|
import { CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader';
|
||||||
import { CoreFile } from '@services/file';
|
import { CoreFile } from '@services/file';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { CoreEvents } from '@singletons/events';
|
import { CoreEvents } from '@singletons/events';
|
||||||
import { CorePath } from '@singletons/path';
|
import { CorePath } from '@singletons/path';
|
||||||
|
@ -269,9 +269,9 @@ export class AddonModGlossaryOfflineProvider {
|
||||||
*/
|
*/
|
||||||
protected parseRecord(record: AddonModGlossaryOfflineEntryDBRecord): AddonModGlossaryOfflineEntry {
|
protected parseRecord(record: AddonModGlossaryOfflineEntryDBRecord): AddonModGlossaryOfflineEntry {
|
||||||
return Object.assign(record, {
|
return Object.assign(record, {
|
||||||
options: <Record<string, AddonModGlossaryEntryOption>> CoreTextUtils.parseJSON(record.options),
|
options: <Record<string, AddonModGlossaryEntryOption>> CoreText.parseJSON(record.options),
|
||||||
attachments: record.attachments ?
|
attachments: record.attachments ?
|
||||||
<CoreFileUploaderStoreFilesResult> CoreTextUtils.parseJSON(record.attachments) : undefined,
|
<CoreFileUploaderStoreFilesResult> CoreText.parseJSON(record.attachments) : undefined,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ import {
|
||||||
AddonModH5PActivitySyncResult,
|
AddonModH5PActivitySyncResult,
|
||||||
} from '../../services/h5pactivity-sync';
|
} from '../../services/h5pactivity-sync';
|
||||||
import { CoreFileHelper } from '@services/file-helper';
|
import { CoreFileHelper } from '@services/file-helper';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import {
|
import {
|
||||||
ADDON_MOD_H5PACTIVITY_AUTO_SYNCED,
|
ADDON_MOD_H5PACTIVITY_AUTO_SYNCED,
|
||||||
|
@ -269,7 +269,7 @@ export class AddonModH5PActivityIndexComponent extends CoreCourseModuleMainActiv
|
||||||
return;
|
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.
|
// The H5P state doesn't always use JSON, so an h5p property was added to jsonize it.
|
||||||
this.contentState = contentStateObj.h5p ?? '{}';
|
this.contentState = contentStateObj.h5p ?? '{}';
|
||||||
|
|
|
@ -31,7 +31,7 @@ import {
|
||||||
AddonModH5PActivityData,
|
AddonModH5PActivityData,
|
||||||
} from './h5pactivity';
|
} from './h5pactivity';
|
||||||
import { CoreXAPIStateDBRecord, CoreXAPIStatementDBRecord } from '@features/xapi/services/database/xapi';
|
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 { CoreXAPIIRI } from '@features/xapi/classes/iri';
|
||||||
import { CoreXAPIItemAgent } from '@features/xapi/classes/item-agent';
|
import { CoreXAPIItemAgent } from '@features/xapi/classes/item-agent';
|
||||||
import { CoreWSError } from '@classes/errors/wserror';
|
import { CoreWSError } from '@classes/errors/wserror';
|
||||||
|
@ -196,7 +196,7 @@ export class AddonModH5PActivitySyncProvider extends CoreCourseActivitySyncBaseP
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (
|
if (
|
||||||
CoreUtils.isWebServiceError(error) ||
|
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.
|
// Activity no longer accessible. Delete the data and finish the sync.
|
||||||
await deleteOfflineData();
|
await deleteOfflineData();
|
||||||
|
|
|
@ -23,7 +23,7 @@ import { CoreCourseModulePrefetchDelegate } from '@features/course/services/modu
|
||||||
import { CoreNetwork } from '@services/network';
|
import { CoreNetwork } from '@services/network';
|
||||||
import { CoreNavigator } from '@services/navigator';
|
import { CoreNavigator } from '@services/navigator';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
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 { CoreUtils } from '@services/utils/utils';
|
||||||
import { Translate } from '@singletons';
|
import { Translate } from '@singletons';
|
||||||
import { AddonModImscp, AddonModImscpImscp, AddonModImscpTocItem } from '../../services/imscp';
|
import { AddonModImscp, AddonModImscpImscp, AddonModImscpTocItem } from '../../services/imscp';
|
||||||
|
@ -124,7 +124,7 @@ export class AddonModImscpViewPage implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (downloadResult?.failed) {
|
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 : '');
|
this.warning = Translate.instant('core.errordownloadingsomefiles') + (error ? ' ' + error : '');
|
||||||
} else {
|
} else {
|
||||||
this.warning = '';
|
this.warning = '';
|
||||||
|
|
|
@ -21,7 +21,7 @@ import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
||||||
import { CoreNetwork } from '@services/network';
|
import { CoreNetwork } from '@services/network';
|
||||||
import { CoreFilepool } from '@services/filepool';
|
import { CoreFilepool } from '@services/filepool';
|
||||||
import { CoreSitesCommonWSOptions, CoreSites } from '@services/sites';
|
import { CoreSitesCommonWSOptions, CoreSites } from '@services/sites';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
|
import { CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
|
||||||
import { makeSingleton, Translate } from '@singletons';
|
import { makeSingleton, Translate } from '@singletons';
|
||||||
|
@ -48,7 +48,7 @@ export class AddonModImscpProvider {
|
||||||
return [];
|
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 { CoreNavigator } from '@services/navigator';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreForms } from '@singletons/form';
|
import { CoreForms } from '@singletons/form';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||||
import { AddonModLessonRetakeFinishedInSyncDBRecord } from '../../services/database/lesson';
|
import { AddonModLessonRetakeFinishedInSyncDBRecord } from '../../services/database/lesson';
|
||||||
|
@ -550,20 +550,20 @@ export class AddonModLessonIndexComponent extends CoreCourseModuleMainActivityCo
|
||||||
|
|
||||||
if (formattedData.lessonscored) {
|
if (formattedData.lessonscored) {
|
||||||
if (formattedData.numofattempts && formattedData.avescore != null) {
|
if (formattedData.numofattempts && formattedData.avescore != null) {
|
||||||
formattedData.avescore = CoreTextUtils.roundToDecimals(formattedData.avescore, 2);
|
formattedData.avescore = CoreText.roundToDecimals(formattedData.avescore, 2);
|
||||||
}
|
}
|
||||||
if (formattedData.highscore != null) {
|
if (formattedData.highscore != null) {
|
||||||
formattedData.highscore = CoreTextUtils.roundToDecimals(formattedData.highscore, 2);
|
formattedData.highscore = CoreText.roundToDecimals(formattedData.highscore, 2);
|
||||||
}
|
}
|
||||||
if (formattedData.lowscore != null) {
|
if (formattedData.lowscore != null) {
|
||||||
formattedData.lowscore = CoreTextUtils.roundToDecimals(formattedData.lowscore, 2);
|
formattedData.lowscore = CoreText.roundToDecimals(formattedData.lowscore, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (formattedData.students) {
|
if (formattedData.students) {
|
||||||
// Get the user data for each student returned.
|
// Get the user data for each student returned.
|
||||||
await CoreUtils.allPromises(formattedData.students.map(async (student) => {
|
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));
|
const user = await CoreUtils.ignoreErrors(CoreUser.getProfile(student.id, this.courseId, true));
|
||||||
if (user) {
|
if (user) {
|
||||||
|
|
|
@ -19,7 +19,7 @@ import { CoreUser } from '@features/user/services/user';
|
||||||
import { CoreNavigator } from '@services/navigator';
|
import { CoreNavigator } from '@services/navigator';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { Translate } from '@singletons';
|
import { Translate } from '@singletons';
|
||||||
import {
|
import {
|
||||||
|
@ -145,7 +145,7 @@ export class AddonModLessonUserRetakePage implements OnInit {
|
||||||
throw new CoreError(Translate.instant('addon.mod_lesson.cannotfindattempt'));
|
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) => {
|
student.attempts.forEach((retake) => {
|
||||||
if (!this.selectedRetake && this.retakeNumber == retake.try) {
|
if (!this.selectedRetake && this.retakeNumber == retake.try) {
|
||||||
// The retake specified as parameter exists. Use it.
|
// The retake specified as parameter exists. Use it.
|
||||||
|
@ -222,7 +222,7 @@ export class AddonModLessonUserRetakePage implements OnInit {
|
||||||
|
|
||||||
if (formattedData.userstats.gradeinfo) {
|
if (formattedData.userstats.gradeinfo) {
|
||||||
// Completed.
|
// 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);
|
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 { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreFormFields } from '@singletons/form';
|
import { CoreFormFields } from '@singletons/form';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreTimeUtils } from '@services/utils/time';
|
import { CoreTimeUtils } from '@services/utils/time';
|
||||||
import { makeSingleton, Translate } from '@singletons';
|
import { makeSingleton, Translate } from '@singletons';
|
||||||
import {
|
import {
|
||||||
|
@ -28,6 +28,7 @@ import {
|
||||||
import { CoreTime } from '@singletons/time';
|
import { CoreTime } from '@singletons/time';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { AddonModLessonPageSubtype } from '../constants';
|
import { AddonModLessonPageSubtype } from '../constants';
|
||||||
|
import { convertTextToHTMLElement } from '@/core/utils/create-html-element';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper service that provides some features for quiz.
|
* Helper service that provides some features for quiz.
|
||||||
|
@ -46,7 +47,7 @@ export class AddonModLessonHelperProvider {
|
||||||
* @returns Formatted data.
|
* @returns Formatted data.
|
||||||
*/
|
*/
|
||||||
formatActivityLink(activityLink: string): AddonModLessonActivityLink {
|
formatActivityLink(activityLink: string): AddonModLessonActivityLink {
|
||||||
const element = CoreDomUtils.convertToElement(activityLink);
|
const element = convertTextToHTMLElement(activityLink);
|
||||||
const anchor = element.querySelector('a');
|
const anchor = element.querySelector('a');
|
||||||
|
|
||||||
if (!anchor) {
|
if (!anchor) {
|
||||||
|
@ -76,7 +77,7 @@ export class AddonModLessonHelperProvider {
|
||||||
buttonText: '',
|
buttonText: '',
|
||||||
content: '',
|
content: '',
|
||||||
};
|
};
|
||||||
const element = CoreDomUtils.convertToElement(html);
|
const element = convertTextToHTMLElement(html);
|
||||||
|
|
||||||
// Search the input button.
|
// Search the input button.
|
||||||
const button = <HTMLInputElement> element.querySelector('input[type="button"]');
|
const button = <HTMLInputElement> element.querySelector('input[type="button"]');
|
||||||
|
@ -100,7 +101,7 @@ export class AddonModLessonHelperProvider {
|
||||||
*/
|
*/
|
||||||
getPageButtonsFromHtml(html: string): AddonModLessonPageButton[] {
|
getPageButtonsFromHtml(html: string): AddonModLessonPageButton[] {
|
||||||
const buttons: AddonModLessonPageButton[] = [];
|
const buttons: AddonModLessonPageButton[] = [];
|
||||||
const element = CoreDomUtils.convertToElement(html);
|
const element = convertTextToHTMLElement(html);
|
||||||
|
|
||||||
// Get the container of the buttons if it exists.
|
// Get the container of the buttons if it exists.
|
||||||
let buttonsContainer = element.querySelector('.branchbuttoncontainer');
|
let buttonsContainer = element.querySelector('.branchbuttoncontainer');
|
||||||
|
@ -152,7 +153,7 @@ export class AddonModLessonHelperProvider {
|
||||||
*/
|
*/
|
||||||
getPageContentsFromPageData(data: AddonModLessonGetPageDataWSResponse): string {
|
getPageContentsFromPageData(data: AddonModLessonGetPageDataWSResponse): string {
|
||||||
// Search the page contents inside the whole page HTML. Use data.pagecontent because it's filtered.
|
// Search the page contents inside the whole page HTML. Use data.pagecontent because it's filtered.
|
||||||
const element = CoreDomUtils.convertToElement(data.pagecontent || '');
|
const element = convertTextToHTMLElement(data.pagecontent || '');
|
||||||
const contents = element.querySelector('.contents');
|
const contents = element.querySelector('.contents');
|
||||||
|
|
||||||
if (contents) {
|
if (contents) {
|
||||||
|
@ -178,7 +179,7 @@ export class AddonModLessonHelperProvider {
|
||||||
* @returns Question data.
|
* @returns Question data.
|
||||||
*/
|
*/
|
||||||
getQuestionFromPageData(questionForm: FormGroup, pageData: AddonModLessonGetPageDataWSResponse): AddonModLessonQuestion {
|
getQuestionFromPageData(questionForm: FormGroup, pageData: AddonModLessonGetPageDataWSResponse): AddonModLessonQuestion {
|
||||||
const element = CoreDomUtils.convertToElement(pageData.pagecontent || '');
|
const element = convertTextToHTMLElement(pageData.pagecontent || '');
|
||||||
|
|
||||||
// Get the container of the question answers if it exists.
|
// Get the container of the question answers if it exists.
|
||||||
const fieldContainer = <HTMLElement> element.querySelector('.fcontainer');
|
const fieldContainer = <HTMLElement> element.querySelector('.fcontainer');
|
||||||
|
@ -463,7 +464,7 @@ export class AddonModLessonHelperProvider {
|
||||||
* @returns Object with the data to render the answer. If the answer doesn't require any parsing, return a string with the HTML.
|
* @returns Object with the data to render the answer. If the answer doesn't require any parsing, return a string with the HTML.
|
||||||
*/
|
*/
|
||||||
getQuestionPageAnswerDataFromHtml(html: string): AddonModLessonAnswerData {
|
getQuestionPageAnswerDataFromHtml(html: string): AddonModLessonAnswerData {
|
||||||
const element = CoreDomUtils.convertToElement(html);
|
const element = convertTextToHTMLElement(html);
|
||||||
|
|
||||||
// Check if it has a checkbox.
|
// Check if it has a checkbox.
|
||||||
let input = element.querySelector<HTMLInputElement>('input[type="checkbox"][name*="answer"]');
|
let input = element.querySelector<HTMLInputElement>('input[type="checkbox"][name*="answer"]');
|
||||||
|
@ -567,7 +568,7 @@ export class AddonModLessonHelperProvider {
|
||||||
|
|
||||||
// Add some HTML to the answer if needed.
|
// Add some HTML to the answer if needed.
|
||||||
if (textarea) {
|
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) {
|
} else if (question.template == 'multichoice' && (<AddonModLessonMultichoiceQuestion> question).multi) {
|
||||||
// Only send the options with value set to true.
|
// Only send the options with value set to true.
|
||||||
|
@ -588,7 +589,7 @@ export class AddonModLessonHelperProvider {
|
||||||
* @returns Feedback without the question text.
|
* @returns Feedback without the question text.
|
||||||
*/
|
*/
|
||||||
removeQuestionFromFeedback(html: string): string {
|
removeQuestionFromFeedback(html: string): string {
|
||||||
const element = CoreDomUtils.convertToElement(html);
|
const element = convertTextToHTMLElement(html);
|
||||||
|
|
||||||
// Remove the question text.
|
// Remove the question text.
|
||||||
CoreDomUtils.removeElement(element, '.generalbox:not(.feedback):not(.correctanswer)');
|
CoreDomUtils.removeElement(element, '.generalbox:not(.feedback):not(.correctanswer)');
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreFormFields } from '@singletons/form';
|
import { CoreFormFields } from '@singletons/form';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreTimeUtils } from '@services/utils/time';
|
import { CoreTimeUtils } from '@services/utils/time';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
|
@ -454,8 +454,8 @@ export class AddonModLessonOfflineProvider {
|
||||||
protected parsePageAttempt(attempt: AddonModLessonPageAttemptDBRecord): AddonModLessonPageAttemptRecord {
|
protected parsePageAttempt(attempt: AddonModLessonPageAttemptDBRecord): AddonModLessonPageAttemptRecord {
|
||||||
return {
|
return {
|
||||||
...attempt,
|
...attempt,
|
||||||
data: attempt.data ? CoreTextUtils.parseJSON(attempt.data) : null,
|
data: attempt.data ? CoreText.parseJSON(attempt.data) : null,
|
||||||
useranswer: attempt.useranswer ? CoreTextUtils.parseJSON(attempt.useranswer) : null,
|
useranswer: attempt.useranswer ? CoreText.parseJSON(attempt.useranswer) : null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,8 @@ import { CoreSite } from '@classes/sites/site';
|
||||||
import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
|
import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
|
||||||
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
||||||
import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites';
|
import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { convertTextToHTMLElement } from '@/core/utils/create-html-element';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
|
import { CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
|
||||||
import { makeSingleton, Translate } from '@singletons';
|
import { makeSingleton, Translate } from '@singletons';
|
||||||
|
@ -90,7 +90,7 @@ export class AddonModLessonProvider {
|
||||||
className: string,
|
className: string,
|
||||||
): string {
|
): string {
|
||||||
// Add a table row containing the answer.
|
// 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>';
|
'</td></tr>';
|
||||||
|
|
||||||
// If the response exists, add a table row containing the response. If not, add en empty row.
|
// If the response exists, add a table row containing the response. If not, add en empty row.
|
||||||
|
@ -164,7 +164,7 @@ export class AddonModLessonProvider {
|
||||||
if (page.answerdata && !this.answerPageIsQuestion(page)) {
|
if (page.answerdata && !this.answerPageIsQuestion(page)) {
|
||||||
// It isn't a question page, but it can be an end of branch, etc. Check if the first answer has a button.
|
// It isn't a question page, but it can be an end of branch, etc. Check if the first answer has a button.
|
||||||
if (page.answerdata.answers && page.answerdata.answers[0]) {
|
if (page.answerdata.answers && page.answerdata.answers[0]) {
|
||||||
const element = CoreDomUtils.convertToElement(page.answerdata.answers[0][0]);
|
const element = convertTextToHTMLElement(page.answerdata.answers[0][0]);
|
||||||
|
|
||||||
return !!element.querySelector('input[type="button"]');
|
return !!element.querySelector('input[type="button"]');
|
||||||
}
|
}
|
||||||
|
@ -301,7 +301,7 @@ export class AddonModLessonProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Progress calculation as a percent.
|
// 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
value = CoreTextUtils.decodeHTML(value);
|
value = CoreText.decodeHTML(value);
|
||||||
userResponse.push(value);
|
userResponse.push(value);
|
||||||
|
|
||||||
if (answers[id] !== undefined) {
|
if (answers[id] !== undefined) {
|
||||||
|
@ -747,7 +747,7 @@ export class AddonModLessonProvider {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
expectedAnswer = expectedAnswer.replace('*', '#####');
|
expectedAnswer = expectedAnswer.replace('*', '#####');
|
||||||
expectedAnswer = CoreTextUtils.escapeForRegex(expectedAnswer);
|
expectedAnswer = CoreText.escapeForRegex(expectedAnswer);
|
||||||
expectedAnswer = expectedAnswer.replace('#####', '.*');
|
expectedAnswer = expectedAnswer.replace('#####', '.*');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -830,7 +830,7 @@ export class AddonModLessonProvider {
|
||||||
this.checkOtherAnswers(lesson, pageData, result);
|
this.checkOtherAnswers(lesson, pageData, result);
|
||||||
|
|
||||||
result.userresponse = studentAnswer;
|
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) => {
|
response.data.forEach((entry) => {
|
||||||
if (entry.value && typeof entry.value == 'string' && entry.value !== '1') {
|
if (entry.value && typeof entry.value == 'string' && entry.value !== '1') {
|
||||||
// It's a JSON encoded object. Try to decode it.
|
// 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;
|
map[entry.name] = entry;
|
||||||
|
@ -1108,7 +1108,7 @@ export class AddonModLessonProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lesson.grade !== undefined && lesson.grade !== CoreGradeType.NONE) {
|
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;
|
entryData.total = lesson.grade;
|
||||||
this.addResultValueEolPage(result, 'yourcurrentgradeisoutof', entryData, true);
|
this.addResultValueEolPage(result, 'yourcurrentgradeisoutof', entryData, true);
|
||||||
}
|
}
|
||||||
|
@ -1904,7 +1904,7 @@ export class AddonModLessonProvider {
|
||||||
|
|
||||||
if (lesson.grade !== undefined && lesson.grade !== CoreGradeType.NONE) {
|
if (lesson.grade !== undefined && lesson.grade !== CoreGradeType.NONE) {
|
||||||
this.addMessage(messages, 'addon.mod_lesson.yourcurrentgradeisoutof', { $a: {
|
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,
|
total: lesson.grade,
|
||||||
} });
|
} });
|
||||||
}
|
}
|
||||||
|
@ -2920,7 +2920,7 @@ export class AddonModLessonProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.total) { // Not zero.
|
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;
|
return result;
|
||||||
|
|
|
@ -21,7 +21,7 @@ import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
||||||
import { CoreFile } from '@services/file';
|
import { CoreFile } from '@services/file';
|
||||||
import { CorePlatform } from '@services/platform';
|
import { CorePlatform } from '@services/platform';
|
||||||
import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites';
|
import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreUrl } from '@singletons/url';
|
import { CoreUrl } from '@singletons/url';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
|
import { CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
|
||||||
|
@ -64,9 +64,9 @@ export class AddonModLtiProvider {
|
||||||
if (p.name == 'ext_submit') {
|
if (p.name == 'ext_submit') {
|
||||||
text += ' <input type="submit"';
|
text += ' <input type="submit"';
|
||||||
} else {
|
} 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';
|
text += '</form>\n';
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
import { Component, OnInit, Optional } from '@angular/core';
|
import { Component, OnInit, Optional } from '@angular/core';
|
||||||
import { CoreCourseModuleMainResourceComponent } from '@features/course/classes/main-resource-component';
|
import { CoreCourseModuleMainResourceComponent } from '@features/course/classes/main-resource-component';
|
||||||
import { CoreCourseContentsPage } from '@features/course/pages/contents/contents';
|
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 { CoreUtils } from '@services/utils/utils';
|
||||||
import { AddonModPagePage, AddonModPage } from '../../services/page';
|
import { AddonModPagePage, AddonModPage } from '../../services/page';
|
||||||
import { AddonModPageHelper } from '../../services/page-helper';
|
import { AddonModPageHelper } from '../../services/page-helper';
|
||||||
|
@ -89,7 +89,7 @@ export class AddonModPageIndexComponent extends CoreCourseModuleMainResourceComp
|
||||||
// Check if description and timemodified should be displayed.
|
// Check if description and timemodified should be displayed.
|
||||||
if (this.page.displayoptions) {
|
if (this.page.displayoptions) {
|
||||||
const options: Record<string, string | boolean> =
|
const options: Record<string, string | boolean> =
|
||||||
CoreTextUtils.unserialize(this.page.displayoptions) || {};
|
CoreText.unserialize(this.page.displayoptions) || {};
|
||||||
|
|
||||||
this.displayDescription = options.printintro === undefined ||
|
this.displayDescription = options.printintro === undefined ||
|
||||||
CoreUtils.isTrueOrOne(options.printintro);
|
CoreUtils.isTrueOrOne(options.printintro);
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { CoreError } from '@classes/errors/error';
|
import { CoreError } from '@classes/errors/error';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreUrl } from '@singletons/url';
|
||||||
import { CoreFile } from '@services/file';
|
import { CoreFile } from '@services/file';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreFilepool } from '@services/filepool';
|
import { CoreFilepool } from '@services/filepool';
|
||||||
|
@ -54,7 +54,7 @@ export class AddonModPageHelperProvider {
|
||||||
// Add the folders without the leading slash.
|
// Add the folders without the leading slash.
|
||||||
key = content.filepath.substring(1) + key;
|
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 { IonContent } from '@ionic/angular';
|
||||||
import { CoreNavigator } from '@services/navigator';
|
import { CoreNavigator } from '@services/navigator';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { Translate } from '@singletons';
|
import { Translate } from '@singletons';
|
||||||
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||||
|
@ -192,7 +192,7 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp
|
||||||
|
|
||||||
if (warnings?.length) {
|
if (warnings?.length) {
|
||||||
// Show warnings and delete them so they aren't shown again.
|
// 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, []);
|
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 { CoreQuestionHelper } from '@features/question/services/question-helper';
|
||||||
import { CoreFilepool } from '@services/filepool';
|
import { CoreFilepool } from '@services/filepool';
|
||||||
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
|
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { CoreWSFile } from '@services/ws';
|
import { CoreWSFile } from '@services/ws';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
|
@ -334,7 +334,7 @@ export class AddonModQuizPrefetchHandlerService extends CoreCourseActivityPrefet
|
||||||
if (canStart && (!attempt || AddonModQuiz.isAttemptCompleted(attempt.state))) {
|
if (canStart && (!attempt || AddonModQuiz.isAttemptCompleted(attempt.state))) {
|
||||||
// Check if the user can attempt the quiz.
|
// Check if the user can attempt the quiz.
|
||||||
if (attemptAccessInfo.preventnewattemptreasons.length) {
|
if (attemptAccessInfo.preventnewattemptreasons.length) {
|
||||||
throw new CoreError(CoreTextUtils.buildMessage(attemptAccessInfo.preventnewattemptreasons));
|
throw new CoreError(CoreText.buildMessage(attemptAccessInfo.preventnewattemptreasons));
|
||||||
}
|
}
|
||||||
|
|
||||||
startAttempt = true;
|
startAttempt = true;
|
||||||
|
|
|
@ -42,6 +42,7 @@ import { CoreGroups } from '@services/groups';
|
||||||
import { CoreTimeUtils } from '@services/utils/time';
|
import { CoreTimeUtils } from '@services/utils/time';
|
||||||
import { CoreModals } from '@services/modals';
|
import { CoreModals } from '@services/modals';
|
||||||
import { CoreLoadings } from '@services/loadings';
|
import { CoreLoadings } from '@services/loadings';
|
||||||
|
import { convertTextToHTMLElement } from '@/core/utils/create-html-element';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper service that provides some features for quiz.
|
* Helper service that provides some features for quiz.
|
||||||
|
@ -301,7 +302,7 @@ export class AddonModQuizHelperProvider {
|
||||||
* @returns Question's mark.
|
* @returns Question's mark.
|
||||||
*/
|
*/
|
||||||
getQuestionMarkFromHtml(html: string): string | undefined {
|
getQuestionMarkFromHtml(html: string): string | undefined {
|
||||||
const element = CoreDomUtils.convertToElement(html);
|
const element = convertTextToHTMLElement(html);
|
||||||
|
|
||||||
return CoreDomUtils.getContentsOfElement(element, '.grade');
|
return CoreDomUtils.getContentsOfElement(element, '.grade');
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ import {
|
||||||
} from '@features/question/services/question';
|
} from '@features/question/services/question';
|
||||||
import { CoreQuestionDelegate } from '@features/question/services/question-delegate';
|
import { CoreQuestionDelegate } from '@features/question/services/question-delegate';
|
||||||
import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites';
|
import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { convertTextToHTMLElement } from '@/core/utils/create-html-element';
|
||||||
import { CoreTimeUtils } from '@services/utils/time';
|
import { CoreTimeUtils } from '@services/utils/time';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { CoreStatusWithWarningsWSResponse, CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
|
import { CoreStatusWithWarningsWSResponse, CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
|
||||||
|
@ -1588,7 +1588,7 @@ export class AddonModQuizProvider {
|
||||||
* @returns Whether it's blocked.
|
* @returns Whether it's blocked.
|
||||||
*/
|
*/
|
||||||
isQuestionBlocked(question: CoreQuestionQuestionParsed): boolean {
|
isQuestionBlocked(question: CoreQuestionQuestionParsed): boolean {
|
||||||
const element = CoreDomUtils.convertToElement(question.html);
|
const element = convertTextToHTMLElement(question.html);
|
||||||
|
|
||||||
return !!element.querySelector('.mod_quiz-blocked_question_warning');
|
return !!element.querySelector('.mod_quiz-blocked_question_warning');
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ import { CoreFileHelper } from '@services/file-helper';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreMimetypeUtils } from '@services/utils/mimetype';
|
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 { CoreUtils, OpenFileAction } from '@services/utils/utils';
|
||||||
import { NgZone, Translate } from '@singletons';
|
import { NgZone, Translate } from '@singletons';
|
||||||
import { Subscription } from 'rxjs';
|
import { Subscription } from 'rxjs';
|
||||||
|
@ -118,7 +118,7 @@ export class AddonModResourceIndexComponent extends CoreCourseModuleMainResource
|
||||||
const resource = await AddonModResource.getResourceData(this.courseId, this.module.id);
|
const resource = await AddonModResource.getResourceData(this.courseId, this.module.id);
|
||||||
this.description = resource.intro || '';
|
this.description = resource.intro || '';
|
||||||
const options: AddonModResourceCustomData =
|
const options: AddonModResourceCustomData =
|
||||||
resource.displayoptions ? CoreTextUtils.unserialize(resource.displayoptions) : {};
|
resource.displayoptions ? CoreText.unserialize(resource.displayoptions) : {};
|
||||||
|
|
||||||
this.displayDescription = options.printintro === undefined || !!options.printintro;
|
this.displayDescription = options.printintro === undefined || !!options.printintro;
|
||||||
this.dataRetrieved.emit(resource);
|
this.dataRetrieved.emit(resource);
|
||||||
|
@ -172,11 +172,11 @@ export class AddonModResourceIndexComponent extends CoreCourseModuleMainResource
|
||||||
|
|
||||||
if ('contentsinfo' in this.module && this.module.contentsinfo) {
|
if ('contentsinfo' in this.module && this.module.contentsinfo) {
|
||||||
mimetype = this.module.contentsinfo.mimetypes[0];
|
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;
|
this.timemodified = this.module.contentsinfo.lastmodified * 1000;
|
||||||
} else {
|
} else {
|
||||||
mimetype = await CoreUtils.getMimeTypeFromUrl(CoreFileHelper.getFileUrl(contents[0]));
|
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;
|
this.timemodified = contents[0].timemodified * 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ import { makeSingleton, Translate } from '@singletons';
|
||||||
import { CorePath } from '@singletons/path';
|
import { CorePath } from '@singletons/path';
|
||||||
import { AddonModResource, AddonModResourceCustomData } from './resource';
|
import { AddonModResource, AddonModResourceCustomData } from './resource';
|
||||||
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
|
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreTimeUtils } from '@services/utils/time';
|
import { CoreTimeUtils } from '@services/utils/time';
|
||||||
import { ADDON_MOD_RESOURCE_COMPONENT } from '../constants';
|
import { ADDON_MOD_RESOURCE_COMPONENT } from '../constants';
|
||||||
import { CoreLoadings } from '@services/loadings';
|
import { CoreLoadings } from '@services/loadings';
|
||||||
|
@ -235,15 +235,15 @@ export class AddonModResourceHelperProvider {
|
||||||
*/
|
*/
|
||||||
protected async getModuleOptions(module: CoreCourseModuleData, courseId: number): Promise<AddonModResourceCustomData> {
|
protected async getModuleOptions(module: CoreCourseModuleData, courseId: number): Promise<AddonModResourceCustomData> {
|
||||||
if (module.customdata !== undefined) {
|
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;
|
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)
|
// Get the resource data. Legacy version (from 3.5 to 3.6.6)
|
||||||
const info = await AddonModResource.getResourceData(courseId, module.id);
|
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) {
|
if (!module.contents?.[0] || options.filedetails !== undefined) {
|
||||||
// Contents attribute should be loaded at this point and it's needed to get mainFile.
|
// 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[] = [];
|
const extra: string[] = [];
|
||||||
|
|
||||||
if (options.showsize && details.size) {
|
if (options.showsize && details.size) {
|
||||||
extra.push(CoreTextUtils.bytesToSize(details.size, 1));
|
extra.push(CoreText.bytesToSize(details.size, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.showtype) {
|
if (options.showtype) {
|
||||||
|
|
|
@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
|
||||||
import { CoreUser } from '@features/user/services/user';
|
import { CoreUser } from '@features/user/services/user';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreSync } from '@services/sync';
|
import { CoreSync } from '@services/sync';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreTimeUtils } from '@services/utils/time';
|
import { CoreTimeUtils } from '@services/utils/time';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
|
@ -297,7 +297,7 @@ export class AddonModScormOfflineProvider {
|
||||||
|
|
||||||
case 'cmi.core.score.raw':
|
case 'cmi.core.score.raw':
|
||||||
case 'cmi.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;
|
break;
|
||||||
|
|
||||||
case 'cmi.core.session_time':
|
case 'cmi.core.session_time':
|
||||||
|
@ -813,7 +813,7 @@ export class AddonModScormOfflineProvider {
|
||||||
protected parseAttempt(attempt: AddonModScormAttemptDBRecord): AddonModScormOfflineAttempt {
|
protected parseAttempt(attempt: AddonModScormAttemptDBRecord): AddonModScormOfflineAttempt {
|
||||||
return {
|
return {
|
||||||
...attempt,
|
...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[] {
|
protected parseTracks(tracks: AddonModScormTrackDBRecord[]): AddonModScormOfflineTrack[] {
|
||||||
return tracks.map((track) => ({
|
return tracks.map((track) => ({
|
||||||
...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 { CoreFilepool } from '@services/filepool';
|
||||||
import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites';
|
import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites';
|
||||||
import { CoreSync } from '@services/sync';
|
import { CoreSync } from '@services/sync';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreTimeUtils } from '@services/utils/time';
|
import { CoreTimeUtils } from '@services/utils/time';
|
||||||
import { CoreUrl } from '@singletons/url';
|
import { CoreUrl } from '@singletons/url';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
|
@ -400,7 +400,7 @@ export class AddonModScormProvider {
|
||||||
if (scorm.grademethod !== AddonModScormGradingMethod.GRADESCOES && scorm.maxgrade) {
|
if (scorm.grademethod !== AddonModScormGradingMethod.GRADESCOES && scorm.maxgrade) {
|
||||||
grade = (grade / scorm.maxgrade) * 100;
|
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);
|
return String(grade);
|
||||||
|
|
|
@ -20,7 +20,7 @@ import { CoreCourseContentsPage } from '@features/course/pages/contents/contents
|
||||||
import { IonContent } from '@ionic/angular';
|
import { IonContent } from '@ionic/angular';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { Translate } from '@singletons';
|
import { Translate } from '@singletons';
|
||||||
import { CoreEvents } from '@singletons/events';
|
import { CoreEvents } from '@singletons/events';
|
||||||
import { getPrefetchHandlerInstance } from '../../services/handlers/prefetch';
|
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) {
|
if (question.multiArray && !question.multiArray.length && question.parent === 0 && question.type > 0) {
|
||||||
// Options shown in a select. Remove all HTML.
|
// 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 { Injectable } from '@angular/core';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { AddonModSurveyAnswersDBRecord, SURVEY_TABLE } from './database/survey';
|
import { AddonModSurveyAnswersDBRecord, SURVEY_TABLE } from './database/survey';
|
||||||
import { AddonModSurveySubmitAnswerData } from './survey';
|
import { AddonModSurveySubmitAnswerData } from './survey';
|
||||||
|
@ -51,7 +51,7 @@ export class AddonModSurveyOfflineProvider {
|
||||||
const entries = await site.getDb().getAllRecords<AddonModSurveyAnswersDBRecord>(SURVEY_TABLE);
|
const entries = await site.getDb().getAllRecords<AddonModSurveyAnswersDBRecord>(SURVEY_TABLE);
|
||||||
|
|
||||||
return entries.map((entry) => Object.assign(entry, {
|
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, {
|
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 { CoreCourseContentsPage } from '@features/course/pages/contents/contents';
|
||||||
import { CoreCourse } from '@features/course/services/course';
|
import { CoreCourse } from '@features/course/services/course';
|
||||||
import { CoreMimetypeUtils } from '@services/utils/mimetype';
|
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 { AddonModUrl, AddonModUrlDisplayOptions, AddonModUrlUrl } from '../../services/url';
|
||||||
import { AddonModUrlHelper } from '../../services/url-helper';
|
import { AddonModUrlHelper } from '../../services/url-helper';
|
||||||
import { ADDON_MOD_URL_COMPONENT } from '../../constants';
|
import { ADDON_MOD_URL_COMPONENT } from '../../constants';
|
||||||
|
@ -90,7 +90,7 @@ export class AddonModUrlIndexComponent extends CoreCourseModuleMainResourceCompo
|
||||||
this.dataRetrieved.emit(url);
|
this.dataRetrieved.emit(url);
|
||||||
|
|
||||||
if (url.displayoptions) {
|
if (url.displayoptions) {
|
||||||
const unserialized = CoreTextUtils.unserialize<AddonModUrlDisplayOptions>(url.displayoptions);
|
const unserialized = CoreText.unserialize<AddonModUrlDisplayOptions>(url.displayoptions);
|
||||||
this.displayDescription = unserialized.printintro === undefined || !!unserialized.printintro;
|
this.displayDescription = unserialized.printintro === undefined || !!unserialized.printintro;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ import { CoreNavigator } from '@services/navigator';
|
||||||
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
|
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
|
||||||
import { CoreSync } from '@services/sync';
|
import { CoreSync } from '@services/sync';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { CoreWSFile } from '@services/ws';
|
import { CoreWSFile } from '@services/ws';
|
||||||
import { Translate } from '@singletons';
|
import { Translate } from '@singletons';
|
||||||
|
@ -33,6 +33,7 @@ import { AddonModWikiSync } from '../../services/wiki-sync';
|
||||||
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
|
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 { ADDON_MOD_WIKI_COMPONENT, ADDON_MOD_WIKI_PAGE_CREATED_EVENT, ADDON_MOD_WIKI_RENEW_LOCK_TIME } from '../../constants';
|
||||||
import { CoreLoadings } from '@services/loadings';
|
import { CoreLoadings } from '@services/loadings';
|
||||||
|
import { CoreFileHelper } from '@services/file-helper';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Page that allows adding or editing a wiki page.
|
* 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');
|
this.userId = CoreNavigator.getRouteNumberParam('userId');
|
||||||
|
|
||||||
const pageTitle = CoreNavigator.getRouteParam<string>('pageTitle');
|
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.canEditTitle = !this.originalTitle;
|
||||||
this.title = 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);
|
const editContents = await AddonModWiki.getPageForEditing(this.pageId, this.section);
|
||||||
|
|
||||||
// Get the original page contents, treating file URLs if needed.
|
// 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.contentControl.setValue(content);
|
||||||
this.originalContent = content;
|
this.originalContent = content;
|
||||||
|
@ -365,8 +366,8 @@ export class AddonModWikiEditPage implements OnInit, OnDestroy, CanLeave {
|
||||||
|
|
||||||
const modal = await CoreLoadings.show('core.sending', true);
|
const modal = await CoreLoadings.show('core.sending', true);
|
||||||
|
|
||||||
text = CoreTextUtils.restorePluginfileUrls(text, this.subwikiFiles);
|
text = CoreFileHelper.restorePluginfileUrls(text, this.subwikiFiles);
|
||||||
text = CoreTextUtils.formatHtmlLines(text);
|
text = CoreText.formatHtmlLines(text);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (this.editing && this.pageId) {
|
if (this.editing && this.pageId) {
|
||||||
|
|
|
@ -22,7 +22,6 @@ import { CoreFileSession } from '@services/file-session';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreSync } from '@services/sync';
|
import { CoreSync } from '@services/sync';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { Translate } from '@singletons';
|
import { Translate } from '@singletons';
|
||||||
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||||
|
@ -260,7 +259,7 @@ export class AddonModWorkshopAssessmentStrategyComponent implements OnInit, OnDe
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compare feedback text.
|
// 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) {
|
if (this.originalData.text != text) {
|
||||||
return true;
|
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>;
|
let assessmentData: CoreFormFields<unknown>;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -22,7 +22,7 @@ import { CoreNavigator } from '@services/navigator';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreSync } from '@services/sync';
|
import { CoreSync } from '@services/sync';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { Translate } from '@singletons';
|
import { Translate } from '@singletons';
|
||||||
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||||
import { CoreForms } from '@singletons/form';
|
import { CoreForms } from '@singletons/form';
|
||||||
|
@ -378,7 +378,7 @@ export class AddonModWorkshopAssessmentPage implements OnInit, OnDestroy, CanLea
|
||||||
|
|
||||||
const grade = inputData.grade >= 0 ? String(inputData.grade) : '';
|
const grade = inputData.grade >= 0 ? String(inputData.grade) : '';
|
||||||
// Add some HTML to the message if needed.
|
// Add some HTML to the message if needed.
|
||||||
const text = CoreTextUtils.formatHtmlLines(inputData.text);
|
const text = CoreText.formatHtmlLines(inputData.text);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Try to send it to server.
|
// Try to send it to server.
|
||||||
|
|
|
@ -24,7 +24,7 @@ import { CoreNavigator } from '@services/navigator';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreSync } from '@services/sync';
|
import { CoreSync } from '@services/sync';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { Translate } from '@singletons';
|
import { Translate } from '@singletons';
|
||||||
import { CoreEvents } from '@singletons/events';
|
import { CoreEvents } from '@singletons/events';
|
||||||
|
@ -45,6 +45,7 @@ import {
|
||||||
AddonModWorkshopSubmissionType,
|
AddonModWorkshopSubmissionType,
|
||||||
} from '@addons/mod/workshop/constants';
|
} from '@addons/mod/workshop/constants';
|
||||||
import { CoreLoadings } from '@services/loadings';
|
import { CoreLoadings } from '@services/loadings';
|
||||||
|
import { CoreDom } from '@singletons/dom';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Page that displays the workshop edit submission.
|
* 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'));
|
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;
|
const noFiles = !inputData.attachmentfiles.length;
|
||||||
|
|
||||||
if ((this.textRequired && noText) || (this.fileRequired && noFiles) || (noText && noFiles)) {
|
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.
|
// Add some HTML to the message if needed.
|
||||||
if (this.textAvailable) {
|
if (this.textAvailable) {
|
||||||
inputData.content = CoreTextUtils.formatHtmlLines(inputData.content);
|
inputData.content = CoreText.formatHtmlLines(inputData.content);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Upload attachments first if any.
|
// Upload attachments first if any.
|
||||||
|
|
|
@ -25,7 +25,7 @@ import { CoreNavigator } from '@services/navigator';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreSync } from '@services/sync';
|
import { CoreSync } from '@services/sync';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { Translate } from '@singletons';
|
import { Translate } from '@singletons';
|
||||||
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||||
import { CoreForms } from '@singletons/form';
|
import { CoreForms } from '@singletons/form';
|
||||||
|
@ -521,7 +521,7 @@ export class AddonModWorkshopSubmissionPage implements OnInit, OnDestroy, CanLea
|
||||||
|
|
||||||
inputData.grade = Number(inputData.grade) >= 0 ? inputData.grade : '';
|
inputData.grade = Number(inputData.grade) >= 0 ? inputData.grade : '';
|
||||||
// Add some HTML to the message if needed.
|
// 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 to send it to server.
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -19,7 +19,7 @@ import { FileEntry } from '@awesome-cordova-plugins/file/ngx';
|
||||||
import { CoreFile } from '@services/file';
|
import { CoreFile } from '@services/file';
|
||||||
import { CoreFileEntry } from '@services/file-helper';
|
import { CoreFileEntry } from '@services/file-helper';
|
||||||
import { CoreSites } from '@services/sites';
|
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 { CoreUtils } from '@services/utils/utils';
|
||||||
import { makeSingleton, Translate } from '@singletons';
|
import { makeSingleton, Translate } from '@singletons';
|
||||||
import { CoreFormFields } from '@singletons/form';
|
import { CoreFormFields } from '@singletons/form';
|
||||||
|
@ -564,7 +564,7 @@ export class AddonModWorkshopHelperProvider {
|
||||||
return '0';
|
return '0';
|
||||||
}
|
}
|
||||||
|
|
||||||
value = CoreTextUtils.roundToDecimals(max * value / 100, decimals);
|
value = CoreText.roundToDecimals(max * value / 100, decimals);
|
||||||
|
|
||||||
return CoreUtils.formatFloat(value);
|
return CoreUtils.formatFloat(value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
|
||||||
import { CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader';
|
import { CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader';
|
||||||
import { CoreFile } from '@services/file';
|
import { CoreFile } from '@services/file';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreTimeUtils } from '@services/utils/time';
|
import { CoreTimeUtils } from '@services/utils/time';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { CoreFormFields } from '@singletons/form';
|
import { CoreFormFields } from '@singletons/form';
|
||||||
|
@ -239,7 +239,7 @@ export class AddonModWorkshopOfflineProvider {
|
||||||
protected parseSubmissionRecord(record: AddonModWorkshopSubmissionDBRecord): AddonModWorkshopOfflineSubmission {
|
protected parseSubmissionRecord(record: AddonModWorkshopSubmissionDBRecord): AddonModWorkshopOfflineSubmission {
|
||||||
return {
|
return {
|
||||||
...record,
|
...record,
|
||||||
attachmentsid: CoreTextUtils.parseJSON(record.attachmentsid),
|
attachmentsid: CoreText.parseJSON(record.attachmentsid),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,7 +355,7 @@ export class AddonModWorkshopOfflineProvider {
|
||||||
protected parseAssessmentRecord(record: AddonModWorkshopAssessmentDBRecord): AddonModWorkshopOfflineAssessment {
|
protected parseAssessmentRecord(record: AddonModWorkshopAssessmentDBRecord): AddonModWorkshopOfflineAssessment {
|
||||||
return {
|
return {
|
||||||
...record,
|
...record,
|
||||||
inputdata: CoreTextUtils.parseJSON(record.inputdata),
|
inputdata: CoreText.parseJSON(record.inputdata),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -486,7 +486,7 @@ export class AddonModWorkshopOfflineProvider {
|
||||||
return {
|
return {
|
||||||
...record,
|
...record,
|
||||||
published: Boolean(record.published),
|
published: Boolean(record.published),
|
||||||
gradeover: CoreTextUtils.parseJSON(record.gradeover),
|
gradeover: CoreText.parseJSON(record.gradeover),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -616,7 +616,7 @@ export class AddonModWorkshopOfflineProvider {
|
||||||
): AddonModWorkshopOfflineEvaluateAssessment {
|
): AddonModWorkshopOfflineEvaluateAssessment {
|
||||||
return {
|
return {
|
||||||
...record,
|
...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 { CoreFileEntry } from '@services/file-helper';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreSync, CoreSyncResult } from '@services/sync';
|
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 { CoreUtils } from '@services/utils/utils';
|
||||||
import { Translate, makeSingleton } from '@singletons';
|
import { Translate, makeSingleton } from '@singletons';
|
||||||
import { CoreEvents } from '@singletons/events';
|
import { CoreEvents } from '@singletons/events';
|
||||||
|
@ -373,7 +373,7 @@ export class AddonModWorkshopSyncProvider extends CoreSyncBaseProvider<AddonModW
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error && CoreUtils.isWebServiceError(error)) {
|
if (error && CoreUtils.isWebServiceError(error)) {
|
||||||
// The WebService has thrown an error, this means it cannot be performed. Discard.
|
// 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.
|
// Couldn't connect to server, reject.
|
||||||
|
@ -472,7 +472,7 @@ export class AddonModWorkshopSyncProvider extends CoreSyncBaseProvider<AddonModW
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error && CoreUtils.isWebServiceError(error)) {
|
if (error && CoreUtils.isWebServiceError(error)) {
|
||||||
// The WebService has thrown an error, this means it cannot be performed. Discard.
|
// The WebService has thrown an error, this means it cannot be performed. Discard.
|
||||||
discardError = CoreTextUtils.getErrorMessageFromError(error);
|
discardError = CoreErrorHelper.getErrorMessageFromError(error);
|
||||||
} else {
|
} else {
|
||||||
// Couldn't connect to server, reject.
|
// Couldn't connect to server, reject.
|
||||||
throw error;
|
throw error;
|
||||||
|
@ -545,7 +545,7 @@ export class AddonModWorkshopSyncProvider extends CoreSyncBaseProvider<AddonModW
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error && CoreUtils.isWebServiceError(error)) {
|
if (error && CoreUtils.isWebServiceError(error)) {
|
||||||
// The WebService has thrown an error, this means it cannot be performed. Discard.
|
// The WebService has thrown an error, this means it cannot be performed. Discard.
|
||||||
discardError = CoreTextUtils.getErrorMessageFromError(error);
|
discardError = CoreErrorHelper.getErrorMessageFromError(error);
|
||||||
} else {
|
} else {
|
||||||
// Couldn't connect to server, reject.
|
// Couldn't connect to server, reject.
|
||||||
throw error;
|
throw error;
|
||||||
|
@ -613,7 +613,7 @@ export class AddonModWorkshopSyncProvider extends CoreSyncBaseProvider<AddonModW
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error && CoreUtils.isWebServiceError(error)) {
|
if (error && CoreUtils.isWebServiceError(error)) {
|
||||||
// The WebService has thrown an error, this means it cannot be performed. Discard.
|
// The WebService has thrown an error, this means it cannot be performed. Discard.
|
||||||
discardError = CoreTextUtils.getErrorMessageFromError(error);
|
discardError = CoreErrorHelper.getErrorMessageFromError(error);
|
||||||
} else {
|
} else {
|
||||||
// Couldn't connect to server, reject.
|
// Couldn't connect to server, reject.
|
||||||
throw error;
|
throw error;
|
||||||
|
|
|
@ -20,7 +20,7 @@ import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
||||||
import { CoreGradesMenuItem } from '@features/grades/services/grades-helper';
|
import { CoreGradesMenuItem } from '@features/grades/services/grades-helper';
|
||||||
import { CoreNetwork } from '@services/network';
|
import { CoreNetwork } from '@services/network';
|
||||||
import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites';
|
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 { CoreUtils } from '@services/utils/utils';
|
||||||
import { CoreStatusWithWarningsWSResponse, CoreWS, CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
|
import { CoreStatusWithWarningsWSResponse, CoreWS, CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
|
||||||
import { makeSingleton, Translate } from '@singletons';
|
import { makeSingleton, Translate } from '@singletons';
|
||||||
|
|
|
@ -25,7 +25,7 @@ import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
|
||||||
import { CoreNavigator } from '@services/navigator';
|
import { CoreNavigator } from '@services/navigator';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreUrl } from '@singletons/url';
|
import { CoreUrl } from '@singletons/url';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { Translate } from '@singletons';
|
import { Translate } from '@singletons';
|
||||||
|
@ -120,7 +120,7 @@ export class AddonNotesListPage implements OnInit, OnDestroy {
|
||||||
const notesList: AddonNotesNoteFormatted[] = allNotes[this.type + 'notes'] || [];
|
const notesList: AddonNotesNoteFormatted[] = allNotes[this.type + 'notes'] || [];
|
||||||
|
|
||||||
notesList.forEach((note) => {
|
notesList.forEach((note) => {
|
||||||
note.content = CoreTextUtils.decodeHTML(note.content);
|
note.content = CoreText.decodeHTML(note.content);
|
||||||
});
|
});
|
||||||
|
|
||||||
await AddonNotes.setOfflineDeletedNotes(notesList, this.courseId);
|
await AddonNotes.setOfflineDeletedNotes(notesList, this.courseId);
|
||||||
|
@ -301,7 +301,7 @@ export class AddonNotesListPage implements OnInit, OnDestroy {
|
||||||
* @param warnings the warnings
|
* @param warnings the warnings
|
||||||
*/
|
*/
|
||||||
protected showSyncWarnings(warnings: string[]): void {
|
protected showSyncWarnings(warnings: string[]): void {
|
||||||
const message = CoreTextUtils.buildMessage(warnings);
|
const message = CoreText.buildMessage(warnings);
|
||||||
|
|
||||||
if (message) {
|
if (message) {
|
||||||
CoreDomUtils.showAlert(undefined, message);
|
CoreDomUtils.showAlert(undefined, message);
|
||||||
|
|
|
@ -26,7 +26,7 @@ import { AddonNotes, AddonNotesCreateNoteData } from './notes';
|
||||||
import { AddonNotesOffline } from './notes-offline';
|
import { AddonNotesOffline } from './notes-offline';
|
||||||
import { CoreArray } from '@singletons/array';
|
import { CoreArray } from '@singletons/array';
|
||||||
import { CoreAnyError } from '@classes/errors/error';
|
import { CoreAnyError } from '@classes/errors/error';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreErrorHelper } from '@services/error-helper';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service to sync notes.
|
* Service to sync notes.
|
||||||
|
@ -235,7 +235,7 @@ export class AddonNotesSyncProvider extends CoreSyncBaseProvider<AddonNotesSyncR
|
||||||
result.warnings = errors.map((error) =>
|
result.warnings = errors.map((error) =>
|
||||||
Translate.instant('addon.notes.warningnotenotsent', {
|
Translate.instant('addon.notes.warningnotenotsent', {
|
||||||
course: 'fullname' in course ? course.fullname : courseId, // @deprecated since 4.3.
|
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 { CoreTime } from '@singletons/time';
|
||||||
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
|
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
|
||||||
import { Translate } from '@singletons';
|
import { Translate } from '@singletons';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreErrorHelper } from '@services/error-helper';
|
||||||
import { CoreLoadings } from '@services/loadings';
|
import { CoreLoadings } from '@services/loadings';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -122,7 +122,7 @@ export class AddonNotificationsSettingsPage implements OnInit, OnDestroy {
|
||||||
this.logView();
|
this.logView();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.errorcode === 'nopermissions') {
|
if (error.errorcode === 'nopermissions') {
|
||||||
this.warningMessage.set(CoreTextUtils.getErrorMessageFromError(error));
|
this.warningMessage.set(CoreErrorHelper.getErrorMessageFromError(error));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites';
|
import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites';
|
||||||
import { CoreWSExternalWarning } from '@services/ws';
|
import { CoreWSExternalWarning } from '@services/ws';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreTimeUtils } from '@services/utils/time';
|
import { CoreTimeUtils } from '@services/utils/time';
|
||||||
import { CoreUser, USER_NOREPLY_USER } from '@features/user/services/user';
|
import { CoreUser, USER_NOREPLY_USER } from '@features/user/services/user';
|
||||||
import { CoreSite } from '@classes/sites/site';
|
import { CoreSite } from '@classes/sites/site';
|
||||||
|
@ -120,7 +120,7 @@ export class AddonNotificationsProvider {
|
||||||
notification.read = notification.timeread > 0;
|
notification.read = notification.timeread > 0;
|
||||||
|
|
||||||
if (typeof notification.customdata === 'string') {
|
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.
|
// 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 { CoreNetwork } from '@services/network';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { Translate } from '@singletons';
|
import { Translate } from '@singletons';
|
||||||
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||||
import {
|
import {
|
||||||
|
@ -214,8 +214,8 @@ export class AddonPrivateFilesIndexPage implements OnInit, OnDestroy {
|
||||||
// Get the info to calculate the available size.
|
// Get the info to calculate the available size.
|
||||||
this.filesInfo = await AddonPrivateFiles.getPrivateFilesInfo();
|
this.filesInfo = await AddonPrivateFiles.getPrivateFilesInfo();
|
||||||
|
|
||||||
this.spaceUsed = CoreTextUtils.bytesToSize(this.filesInfo.filesizewithoutreferences, 1);
|
this.spaceUsed = CoreText.bytesToSize(this.filesInfo.filesizewithoutreferences, 1);
|
||||||
this.userQuotaReadable = CoreTextUtils.bytesToSize(this.userQuota, 1);
|
this.userQuotaReadable = CoreText.bytesToSize(this.userQuota, 1);
|
||||||
} else {
|
} else {
|
||||||
// User quota isn't useful, delete it.
|
// User quota isn't useful, delete it.
|
||||||
delete this.userQuota;
|
delete this.userQuota;
|
||||||
|
|
|
@ -16,7 +16,7 @@ import { Injectable, Type } from '@angular/core';
|
||||||
|
|
||||||
import { CoreQuestionQuestionParsed, CoreQuestionsAnswers } from '@features/question/services/question';
|
import { CoreQuestionQuestionParsed, CoreQuestionsAnswers } from '@features/question/services/question';
|
||||||
import { CoreQuestionHandler } from '@features/question/services/question-delegate';
|
import { CoreQuestionHandler } from '@features/question/services/question-delegate';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { convertTextToHTMLElement } from '@/core/utils/create-html-element';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { AddonQtypeCalculatedComponent } from '../../component/calculated';
|
import { AddonQtypeCalculatedComponent } from '../../component/calculated';
|
||||||
|
@ -53,7 +53,7 @@ export class AddonQtypeCalculatedHandlerService implements CoreQuestionHandler {
|
||||||
*/
|
*/
|
||||||
hasSeparateUnitField(question: CoreQuestionQuestionParsed): boolean {
|
hasSeparateUnitField(question: CoreQuestionQuestionParsed): boolean {
|
||||||
if (!question.parsedSettings) {
|
if (!question.parsedSettings) {
|
||||||
const element = CoreDomUtils.convertToElement(question.html);
|
const element = convertTextToHTMLElement(question.html);
|
||||||
|
|
||||||
return !!(element.querySelector('select[name*=unit]') || element.querySelector('input[type="radio"]'));
|
return !!(element.querySelector('select[name*=unit]') || element.querySelector('input[type="radio"]'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { CoreFormatTextDirective } from '@directives/format-text';
|
import { CoreFormatTextDirective } from '@directives/format-text';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreDirectivesRegistry } from '@singletons/directives-registry';
|
import { CoreDirectivesRegistry } from '@singletons/directives-registry';
|
||||||
import { CoreCoordinates, CoreDom } from '@singletons/dom';
|
import { CoreCoordinates, CoreDom } from '@singletons/dom';
|
||||||
import { CoreEventObserver } from '@singletons/events';
|
import { CoreEventObserver } from '@singletons/events';
|
||||||
|
@ -490,7 +490,7 @@ export class AddonQtypeDdwtosQuestion {
|
||||||
}
|
}
|
||||||
|
|
||||||
groupItems.forEach((item) => {
|
groupItems.forEach((item) => {
|
||||||
item.innerHTML = CoreTextUtils.decodeHTML(item.innerHTML);
|
item.innerHTML = CoreText.decodeHTML(item.innerHTML);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Wait to render in order to calculate size.
|
// 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 { CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader';
|
||||||
import { AddonModQuizEssayQuestion, CoreQuestionBaseComponent } from '@features/question/classes/base-question-component';
|
import { AddonModQuizEssayQuestion, CoreQuestionBaseComponent } from '@features/question/classes/base-question-component';
|
||||||
import { CoreQuestionHelper } from '@features/question/services/question-helper';
|
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 { CoreFileSession } from '@services/file-session';
|
||||||
import { CoreQuestion } from '@features/question/services/question';
|
import { CoreQuestion } from '@features/question/services/question';
|
||||||
import { CoreFileEntry } from '@services/file-helper';
|
import { CoreFileEntry } from '@services/file-helper';
|
||||||
|
@ -71,7 +71,7 @@ export class AddonQtypeEssayComponent extends CoreQuestionBaseComponent<AddonMod
|
||||||
|
|
||||||
if (this.offlineEnabled && this.question.localAnswers?.attachments_offline) {
|
if (this.offlineEnabled && this.question.localAnswers?.attachments_offline) {
|
||||||
|
|
||||||
const attachmentsData: CoreFileUploaderStoreFilesResult = CoreTextUtils.parseJSON(
|
const attachmentsData: CoreFileUploaderStoreFilesResult = CoreText.parseJSON(
|
||||||
this.question.localAnswers.attachments_offline,
|
this.question.localAnswers.attachments_offline,
|
||||||
{
|
{
|
||||||
online: [],
|
online: [],
|
||||||
|
|
|
@ -22,12 +22,13 @@ import { CoreQuestionHandler } from '@features/question/services/question-delega
|
||||||
import { CoreQuestionHelper } from '@features/question/services/question-helper';
|
import { CoreQuestionHelper } from '@features/question/services/question-helper';
|
||||||
import { CoreFileSession } from '@services/file-session';
|
import { CoreFileSession } from '@services/file-session';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { convertTextToHTMLElement } from '@/core/utils/create-html-element';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { CoreWSFile } from '@services/ws';
|
import { CoreWSFile } from '@services/ws';
|
||||||
import { makeSingleton, Translate } from '@singletons';
|
import { makeSingleton, Translate } from '@singletons';
|
||||||
import { AddonQtypeEssayComponent } from '../../component/essay';
|
import { AddonQtypeEssayComponent } from '../../component/essay';
|
||||||
|
import { CoreFileHelper } from '@services/file-helper';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler to support essay question type.
|
* Handler to support essay question type.
|
||||||
|
@ -89,7 +90,7 @@ export class AddonQtypeEssayHandlerService implements CoreQuestionHandler {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const element = CoreDomUtils.convertToElement(question.html);
|
const element = convertTextToHTMLElement(question.html);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
text: !!element.querySelector('textarea[name*=_answer]'),
|
text: !!element.querySelector('textarea[name*=_answer]'),
|
||||||
|
@ -115,7 +116,7 @@ export class AddonQtypeEssayHandlerService implements CoreQuestionHandler {
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
getPreventSubmitMessage(question: CoreQuestionQuestionParsed): string | undefined {
|
getPreventSubmitMessage(question: CoreQuestionQuestionParsed): string | undefined {
|
||||||
const element = CoreDomUtils.convertToElement(question.html);
|
const element = convertTextToHTMLElement(question.html);
|
||||||
const uploadFilesSupported = question.responsefileareas !== undefined;
|
const uploadFilesSupported = question.responsefileareas !== undefined;
|
||||||
|
|
||||||
if (!uploadFilesSupported && element.querySelector('div[id*=filemanager]')) {
|
if (!uploadFilesSupported && element.querySelector('div[id*=filemanager]')) {
|
||||||
|
@ -177,7 +178,7 @@ export class AddonQtypeEssayHandlerService implements CoreQuestionHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Count the number of words in the response string.
|
// Count the number of words in the response string.
|
||||||
const count = CoreTextUtils.countWords(answer);
|
const count = CoreText.countWords(answer);
|
||||||
if (maxWords && count > maxWords) {
|
if (maxWords && count > maxWords) {
|
||||||
return Translate.instant('addon.qtype_essay.maxwordlimitboundary', { $a: { limit: maxWords, count: count } });
|
return Translate.instant('addon.qtype_essay.maxwordlimitboundary', { $a: { limit: maxWords, count: count } });
|
||||||
} else if (count < minWords) {
|
} else if (count < minWords) {
|
||||||
|
@ -292,7 +293,7 @@ export class AddonQtypeEssayHandlerService implements CoreQuestionHandler {
|
||||||
siteId?: string,
|
siteId?: string,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
|
||||||
const element = CoreDomUtils.convertToElement(question.html);
|
const element = convertTextToHTMLElement(question.html);
|
||||||
const attachmentsInput = <HTMLInputElement> element.querySelector('.attachments input[name*=_attachments]');
|
const attachmentsInput = <HTMLInputElement> element.querySelector('.attachments input[name*=_attachments]');
|
||||||
|
|
||||||
// Search the textarea to get its name.
|
// Search the textarea to get its name.
|
||||||
|
@ -374,7 +375,7 @@ export class AddonQtypeEssayHandlerService implements CoreQuestionHandler {
|
||||||
siteId?: string,
|
siteId?: string,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
|
||||||
const element = CoreDomUtils.convertToElement(question.html);
|
const element = convertTextToHTMLElement(question.html);
|
||||||
const attachmentsInput = <HTMLInputElement> element.querySelector('.attachments input[name*=_attachments]');
|
const attachmentsInput = <HTMLInputElement> element.querySelector('.attachments input[name*=_attachments]');
|
||||||
|
|
||||||
if (attachmentsInput) {
|
if (attachmentsInput) {
|
||||||
|
@ -386,7 +387,7 @@ export class AddonQtypeEssayHandlerService implements CoreQuestionHandler {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const attachmentsData: CoreFileUploaderStoreFilesResult = CoreTextUtils.parseJSON(
|
const attachmentsData: CoreFileUploaderStoreFilesResult = CoreText.parseJSON(
|
||||||
<string> answers.attachments_offline,
|
<string> answers.attachments_offline,
|
||||||
{
|
{
|
||||||
online: [],
|
online: [],
|
||||||
|
@ -438,7 +439,7 @@ export class AddonQtypeEssayHandlerService implements CoreQuestionHandler {
|
||||||
// Restore draftfile URLs.
|
// Restore draftfile URLs.
|
||||||
const site = await CoreSites.getSite(siteId);
|
const site = await CoreSites.getSite(siteId);
|
||||||
|
|
||||||
answers[textarea.name] = CoreTextUtils.restoreDraftfileUrls(
|
answers[textarea.name] = CoreFileHelper.restoreDraftfileUrls(
|
||||||
site.getURL(),
|
site.getURL(),
|
||||||
<string> answers[textarea.name],
|
<string> answers[textarea.name],
|
||||||
question.html,
|
question.html,
|
||||||
|
@ -453,13 +454,13 @@ export class AddonQtypeEssayHandlerService implements CoreQuestionHandler {
|
||||||
isPlainText = question.parsedSettings.responseformat == 'monospaced' ||
|
isPlainText = question.parsedSettings.responseformat == 'monospaced' ||
|
||||||
question.parsedSettings.responseformat == 'plain';
|
question.parsedSettings.responseformat == 'plain';
|
||||||
} else {
|
} else {
|
||||||
const questionEl = CoreDomUtils.convertToElement(question.html);
|
const questionEl = convertTextToHTMLElement(question.html);
|
||||||
isPlainText = !!questionEl.querySelector('.qtype_essay_monospaced') || !!questionEl.querySelector('.qtype_essay_plain');
|
isPlainText = !!questionEl.querySelector('.qtype_essay_monospaced') || !!questionEl.querySelector('.qtype_essay_plain');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isPlainText) {
|
if (!isPlainText) {
|
||||||
// Add some HTML to the text if needed.
|
// 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 { CoreUserProfileFieldHandler, CoreUserProfileFieldHandlerData } from '@features/user/services/user-profile-field-delegate';
|
||||||
import { AddonUserProfileFieldSocialComponent } from '../../component/social';
|
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 { AuthEmailSignupProfileField } from '@features/login/services/login-helper';
|
||||||
import { CoreUserProfileField } from '@features/user/services/user';
|
import { CoreUserProfileField } from '@features/user/services/user';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
|
@ -60,7 +60,7 @@ export class AddonUserProfileFieldSocialHandlerService implements CoreUserProfil
|
||||||
return {
|
return {
|
||||||
type: 'social',
|
type: 'social',
|
||||||
name: name,
|
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 { CoreUserProfileFieldHandler, CoreUserProfileFieldHandlerData } from '@features/user/services/user-profile-field-delegate';
|
||||||
import { AddonUserProfileFieldTextComponent } from '../../component/text';
|
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 { AuthEmailSignupProfileField } from '@features/login/services/login-helper';
|
||||||
import { CoreUserProfileField } from '@features/user/services/user';
|
import { CoreUserProfileField } from '@features/user/services/user';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
|
@ -60,7 +60,7 @@ export class AddonUserProfileFieldTextHandlerService implements CoreUserProfileF
|
||||||
return {
|
return {
|
||||||
type: 'text',
|
type: 'text',
|
||||||
name: name,
|
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 { CoreUserProfileFieldHandler, CoreUserProfileFieldHandlerData } from '@features/user/services/user-profile-field-delegate';
|
||||||
import { AddonUserProfileFieldTextareaComponent } from '../../component/textarea';
|
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 { AuthEmailSignupProfileField } from '@features/login/services/login-helper';
|
||||||
import { CoreUserProfileField } from '@features/user/services/user';
|
import { CoreUserProfileField } from '@features/user/services/user';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
|
@ -60,7 +60,7 @@ export class AddonUserProfileFieldTextareaHandlerService implements CoreUserProf
|
||||||
if (formValues[name]) {
|
if (formValues[name]) {
|
||||||
let text = <string> formValues[name] || '';
|
let text = <string> formValues[name] || '';
|
||||||
// Add some HTML to the message in case the user edited with textarea.
|
// Add some HTML to the message in case the user edited with textarea.
|
||||||
text = CoreTextUtils.formatHtmlLines(text);
|
text = CoreText.formatHtmlLines(text);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: 'textarea',
|
type: 'textarea',
|
||||||
|
|
|
@ -15,11 +15,12 @@
|
||||||
import { CoreNetwork } from '@services/network';
|
import { CoreNetwork } from '@services/network';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreSync } from '@services/sync';
|
import { CoreSync } from '@services/sync';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreTimeUtils } from '@services/utils/time';
|
import { CoreTimeUtils } from '@services/utils/time';
|
||||||
import { Translate } from '@singletons';
|
import { Translate } from '@singletons';
|
||||||
import { CoreLogger } from '@singletons/logger';
|
import { CoreLogger } from '@singletons/logger';
|
||||||
import { CoreAnyError, CoreError } from '@classes/errors/error';
|
import { CoreAnyError, CoreError } from '@classes/errors/error';
|
||||||
|
import { CoreErrorHelper } from '@services/error-helper';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Blocked sync error.
|
* Blocked sync error.
|
||||||
|
@ -120,7 +121,7 @@ export class CoreSyncBaseProvider<T = void> {
|
||||||
return Translate.instant('core.warningofflinedatadeleted', {
|
return Translate.instant('core.warningofflinedatadeleted', {
|
||||||
component: this.componentTranslate,
|
component: this.componentTranslate,
|
||||||
name: name,
|
name: name,
|
||||||
error: CoreTextUtils.getErrorMessageFromError(error),
|
error: CoreErrorHelper.getErrorMessageFromError(error),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,7 +196,7 @@ export class CoreSyncBaseProvider<T = void> {
|
||||||
try {
|
try {
|
||||||
const entry = await CoreSync.getSyncRecord(this.component, id, siteId);
|
const entry = await CoreSync.getSyncRecord(this.component, id, siteId);
|
||||||
|
|
||||||
return <string[]> CoreTextUtils.parseJSON(entry.warnings, []);
|
return <string[]> CoreText.parseJSON(entry.warnings, []);
|
||||||
} catch {
|
} catch {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { CoreTextErrorObject } from '@services/utils/text';
|
import { CoreErrorObject } from '@services/error-helper';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base Error class.
|
* 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,
|
CoreWSTypeExpected,
|
||||||
} from '@services/ws';
|
} from '@services/ws';
|
||||||
import { CoreToasts, ToastDuration } from '@services/toasts';
|
import { CoreToasts, ToastDuration } from '@services/toasts';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { CoreConstants } from '@/core/constants';
|
import { CoreConstants } from '@/core/constants';
|
||||||
import { CoreError } from '@classes/errors/error';
|
import { CoreError } from '@classes/errors/error';
|
||||||
|
@ -418,7 +418,7 @@ export class CoreAuthenticatedSite extends CoreUnauthenticatedSite {
|
||||||
splitRequest: preSets.splitRequest,
|
splitRequest: preSets.splitRequest,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (wsPreSets.cleanUnicode && CoreTextUtils.hasUnicodeData(data)) {
|
if (wsPreSets.cleanUnicode && CoreText.hasUnicodeData(data)) {
|
||||||
// Data will be cleaned, notify the user.
|
// Data will be cleaned, notify the user.
|
||||||
CoreToasts.show({
|
CoreToasts.show({
|
||||||
message: 'core.unicodenotsupported',
|
message: 'core.unicodenotsupported',
|
||||||
|
@ -676,7 +676,7 @@ export class CoreAuthenticatedSite extends CoreUnauthenticatedSite {
|
||||||
error.message = Translate.instant('core.policy.sitepolicynotagreederror');
|
error.message = Translate.instant('core.policy.sitepolicynotagreederror');
|
||||||
|
|
||||||
throw new CoreSilentError(error);
|
throw new CoreSilentError(error);
|
||||||
} else if (error.errorcode === 'dmlwriteexception' && CoreTextUtils.hasUnicodeData(data)) {
|
} else if (error.errorcode === 'dmlwriteexception' && CoreText.hasUnicodeData(data)) {
|
||||||
if (!this.cleanUnicode) {
|
if (!this.cleanUnicode) {
|
||||||
// Try again cleaning unicode.
|
// Try again cleaning unicode.
|
||||||
this.cleanUnicode = true;
|
this.cleanUnicode = true;
|
||||||
|
@ -961,7 +961,7 @@ export class CoreAuthenticatedSite extends CoreUnauthenticatedSite {
|
||||||
// Request not executed, enqueue again.
|
// Request not executed, enqueue again.
|
||||||
this.enqueueRequest(request);
|
this.enqueueRequest(request);
|
||||||
} else if (response.error) {
|
} 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);
|
request.deferred.reject(rejectReason);
|
||||||
CoreErrorLogs.addErrorLog({
|
CoreErrorLogs.addErrorLog({
|
||||||
method: request.method,
|
method: request.method,
|
||||||
|
@ -971,7 +971,7 @@ export class CoreAuthenticatedSite extends CoreUnauthenticatedSite {
|
||||||
data: request.data,
|
data: request.data,
|
||||||
});
|
});
|
||||||
} else {
|
} 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.
|
// Match the behaviour of CoreWSProvider.call when no response is expected.
|
||||||
const responseExpected = wsPresets.responseExpected === undefined || wsPresets.responseExpected;
|
const responseExpected = wsPresets.responseExpected === undefined || wsPresets.responseExpected;
|
||||||
if (!responseExpected && (responseData == null || responseData === '')) {
|
if (!responseExpected && (responseData == null || responseData === '')) {
|
||||||
|
@ -1097,7 +1097,7 @@ export class CoreAuthenticatedSite extends CoreUnauthenticatedSite {
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
response: <T> CoreTextUtils.parseJSON(entry.data, {}),
|
response: <T> CoreText.parseJSON(entry.data, {}),
|
||||||
expirationIgnored: forceCache,
|
expirationIgnored: forceCache,
|
||||||
expirationTime,
|
expirationTime,
|
||||||
};
|
};
|
||||||
|
|
|
@ -25,7 +25,6 @@ import {
|
||||||
CoreWSUploadFileResult,
|
CoreWSUploadFileResult,
|
||||||
} from '@services/ws';
|
} from '@services/ws';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
|
||||||
import { CoreTimeUtils } from '@services/utils/time';
|
import { CoreTimeUtils } from '@services/utils/time';
|
||||||
import { CoreUrl } from '@singletons/url';
|
import { CoreUrl } from '@singletons/url';
|
||||||
import { CoreUtils, CoreUtilsOpenInBrowserOptions } from '@services/utils/utils';
|
import { CoreUtils, CoreUtilsOpenInBrowserOptions } from '@services/utils/utils';
|
||||||
|
@ -166,7 +165,7 @@ export class CoreSite extends CoreAuthenticatedSite {
|
||||||
*/
|
*/
|
||||||
setConfig(config: CoreSiteConfig): void {
|
setConfig(config: CoreSiteConfig): void {
|
||||||
if (config) {
|
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;
|
this.config = config;
|
||||||
|
|
|
@ -16,7 +16,7 @@ import { CoreConstants } from '@/core/constants';
|
||||||
import { CoreError } from '@classes/errors/error';
|
import { CoreError } from '@classes/errors/error';
|
||||||
import { CoreLoginHelper } from '@features/login/services/login-helper';
|
import { CoreLoginHelper } from '@features/login/services/login-helper';
|
||||||
import { CoreSitesReadingStrategy } from '@services/sites';
|
import { CoreSitesReadingStrategy } from '@services/sites';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreUrl, CoreUrlPartNames } from '@singletons/url';
|
import { CoreUrl, CoreUrlPartNames } from '@singletons/url';
|
||||||
import { CoreWS, CoreWSAjaxPreSets, CoreWSExternalWarning } from '@services/ws';
|
import { CoreWS, CoreWSAjaxPreSets, CoreWSExternalWarning } from '@services/ws';
|
||||||
import { CorePath } from '@singletons/path';
|
import { CorePath } from '@singletons/path';
|
||||||
|
@ -30,6 +30,55 @@ export class CoreUnauthenticatedSite {
|
||||||
|
|
||||||
protected publicConfig?: CoreSitePublicConfigResponse;
|
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.
|
* Create a site.
|
||||||
*
|
*
|
||||||
|
@ -160,10 +209,10 @@ export class CoreUnauthenticatedSite {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const siteUrl = CoreTextUtils.addEndingSlash(
|
const siteUrl = CoreText.addEndingSlash(
|
||||||
CoreUrl.removeUrlParts(this.siteUrl, [CoreUrlPartNames.Protocol, CoreUrlPartNames.WWWInDomain]),
|
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;
|
return url.indexOf(siteUrl) == 0;
|
||||||
}
|
}
|
||||||
|
@ -207,7 +256,7 @@ export class CoreUnauthenticatedSite {
|
||||||
*/
|
*/
|
||||||
setPublicConfig(publicConfig: CoreSitePublicConfigResponse): void {
|
setPublicConfig(publicConfig: CoreSitePublicConfigResponse): void {
|
||||||
publicConfig.tool_mobile_disabledfeatures =
|
publicConfig.tool_mobile_disabledfeatures =
|
||||||
CoreTextUtils.treatDisabledFeatures(publicConfig.tool_mobile_disabledfeatures ?? '');
|
this.treatDisabledFeatures(publicConfig.tool_mobile_disabledfeatures ?? '');
|
||||||
this.publicConfig = publicConfig;
|
this.publicConfig = publicConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -330,7 +379,7 @@ export class CoreUnauthenticatedSite {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const regEx = new RegExp('(,|^)' + CoreTextUtils.escapeForRegex(name) + '(,|$)', 'g');
|
const regEx = new RegExp('(,|^)' + CoreText.escapeForRegex(name) + '(,|$)', 'g');
|
||||||
|
|
||||||
return !!disabledFeatures.match(regEx);
|
return !!disabledFeatures.match(regEx);
|
||||||
}
|
}
|
||||||
|
@ -344,6 +393,26 @@ export class CoreUnauthenticatedSite {
|
||||||
return this.publicConfig?.tool_mobile_disabledfeatures;
|
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 { CoreFileUploader, CoreFileUploaderTypeList } from '@features/fileuploader/services/fileuploader';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { Translate } from '@singletons';
|
import { Translate } from '@singletons';
|
||||||
import { CoreNetwork } from '@services/network';
|
import { CoreNetwork } from '@services/network';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
|
@ -74,7 +74,7 @@ export class CoreAttachmentsComponent implements OnInit {
|
||||||
if (this.maxSize === 0) {
|
if (this.maxSize === 0) {
|
||||||
await this.getMaxSizeOfArea();
|
await this.getMaxSizeOfArea();
|
||||||
} else if (this.maxSize > 0) {
|
} else if (this.maxSize > 0) {
|
||||||
this.maxSizeReadable = CoreTextUtils.bytesToSize(this.maxSize, 2);
|
this.maxSizeReadable = CoreText.bytesToSize(this.maxSize, 2);
|
||||||
} else if (this.maxSize === -1) {
|
} else if (this.maxSize === -1) {
|
||||||
this.maxSizeReadable = Translate.instant('core.unlimited');
|
this.maxSizeReadable = Translate.instant('core.unlimited');
|
||||||
} else {
|
} else {
|
||||||
|
@ -110,7 +110,7 @@ export class CoreAttachmentsComponent implements OnInit {
|
||||||
|
|
||||||
if (course?.maxbytes) {
|
if (course?.maxbytes) {
|
||||||
this.maxSize = course.maxbytes;
|
this.maxSize = course.maxbytes;
|
||||||
this.maxSizeReadable = CoreTextUtils.bytesToSize(this.maxSize, 2);
|
this.maxSizeReadable = CoreText.bytesToSize(this.maxSize, 2);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ export class CoreAttachmentsComponent implements OnInit {
|
||||||
|
|
||||||
if (siteInfo?.usermaxuploadfilesize) {
|
if (siteInfo?.usermaxuploadfilesize) {
|
||||||
this.maxSize = siteInfo.usermaxuploadfilesize;
|
this.maxSize = siteInfo.usermaxuploadfilesize;
|
||||||
this.maxSizeReadable = CoreTextUtils.bytesToSize(this.maxSize, 2);
|
this.maxSizeReadable = CoreText.bytesToSize(this.maxSize, 2);
|
||||||
} else {
|
} else {
|
||||||
this.maxSizeReadable = Translate.instant('core.unknown');
|
this.maxSizeReadable = Translate.instant('core.unknown');
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreMimetypeUtils } from '@services/utils/mimetype';
|
import { CoreMimetypeUtils } from '@services/utils/mimetype';
|
||||||
import { CoreUrl } from '@singletons/url';
|
import { CoreUrl } from '@singletons/url';
|
||||||
import { CoreUtils, CoreUtilsOpenFileOptions, OpenFileAction } from '@services/utils/utils';
|
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 { DownloadStatus } from '@/core/constants';
|
||||||
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||||
import { CoreWSFile } from '@services/ws';
|
import { CoreWSFile } from '@services/ws';
|
||||||
|
@ -90,7 +90,7 @@ export class CoreFileComponent implements OnInit, OnDestroy {
|
||||||
this.openButtonLabel = this.defaultIsOpenWithPicker ? 'core.openfile' : 'core.openwith';
|
this.openButtonLabel = this.defaultIsOpenWithPicker ? 'core.openfile' : 'core.openwith';
|
||||||
|
|
||||||
if (this.showSize && this.fileSize && this.fileSize >= 0) {
|
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;
|
this.showTime = this.showTime && this.timemodified > 0;
|
||||||
|
|
|
@ -21,7 +21,7 @@ import { CoreFileHelper } from '@services/file-helper';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreMimetypeUtils } from '@services/utils/mimetype';
|
import { CoreMimetypeUtils } from '@services/utils/mimetype';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreTimeUtils } from '@services/utils/time';
|
import { CoreTimeUtils } from '@services/utils/time';
|
||||||
import { CoreUtils, CoreUtilsOpenFileOptions, OpenFileAction } from '@services/utils/utils';
|
import { CoreUtils, CoreUtilsOpenFileOptions, OpenFileAction } from '@services/utils/utils';
|
||||||
import { CoreForms } from '@singletons/form';
|
import { CoreForms } from '@singletons/form';
|
||||||
|
@ -78,7 +78,7 @@ export class CoreLocalFileComponent implements OnInit {
|
||||||
// Get the size and timemodified.
|
// Get the size and timemodified.
|
||||||
const metadata = await CoreFile.getMetadata(this.file);
|
const metadata = await CoreFile.getMetadata(this.file);
|
||||||
if (metadata.size >= 0) {
|
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');
|
this.timemodified = CoreTimeUtils.userDate(metadata.modificationTime.getTime(), 'core.strftimedatetimeshort');
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
import { toBoolean } from '@/core/transforms/boolean';
|
import { toBoolean } from '@/core/transforms/boolean';
|
||||||
import { Component, Input, AfterViewInit, ElementRef } from '@angular/core';
|
import { Component, Input, AfterViewInit, ElementRef } from '@angular/core';
|
||||||
|
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { Translate } from '@singletons';
|
import { Translate } from '@singletons';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,7 +53,7 @@ export class CoreMarkRequiredComponent implements AfterViewInit {
|
||||||
if (this.coreMarkRequired) {
|
if (this.coreMarkRequired) {
|
||||||
// Add the "required" to the aria-label.
|
// Add the "required" to the aria-label.
|
||||||
const ariaLabel = this.hostElement.getAttribute('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) {
|
if (ariaLabel) {
|
||||||
this.hostElement.setAttribute('aria-label', ariaLabel + '. ' + this.requiredLabel);
|
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 { CoreAnimations } from '@components/animations';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreText } from '@singletons/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
|
||||||
import { CoreUserWithAvatar } from '@components/user-avatar/user-avatar';
|
import { CoreUserWithAvatar } from '@components/user-avatar/user-avatar';
|
||||||
import { toBoolean } from '@/core/transforms/boolean';
|
import { toBoolean } from '@/core/transforms/boolean';
|
||||||
|
|
||||||
|
@ -103,7 +102,7 @@ export class CoreMessageComponent implements OnInit {
|
||||||
* Copy message to clipboard.
|
* Copy message to clipboard.
|
||||||
*/
|
*/
|
||||||
copyMessage(): void {
|
copyMessage(): void {
|
||||||
CoreText.copyToClipboard(CoreTextUtils.decodeHTMLEntities(this.text));
|
CoreText.copyToClipboard(CoreText.decodeHTMLEntities(this.text));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue