MOBILE-2333 siteplugins: Rename site addons to site plugins

main
Dani Palou 2018-03-09 14:36:30 +01:00
parent 557011d560
commit 046b300051
46 changed files with 469 additions and 467 deletions

View File

@ -65,7 +65,7 @@ import { CoreContentLinksModule } from '@core/contentlinks/contentlinks.module';
import { CoreUserModule } from '@core/user/user.module';
import { CoreGradesModule } from '@core/grades/grades.module';
import { CoreSettingsModule } from '@core/settings/settings.module';
import { CoreSiteAddonsModule } from '@core/siteaddons/siteaddons.module';
import { CoreSitePluginsModule } from '@core/siteplugins/siteplugins.module';
import { CoreCompileModule } from '@core/compile/compile.module';
// Addon modules.
@ -144,7 +144,7 @@ export const CORE_PROVIDERS: any[] = [
CoreUserModule,
CoreGradesModule,
CoreSettingsModule,
CoreSiteAddonsModule,
CoreSitePluginsModule,
CoreCompileModule,
AddonCalendarModule,
AddonUserProfileFieldModule,

View File

@ -91,7 +91,7 @@ export class CoreDelegate {
// Update handlers on this cases.
eventsProvider.on(CoreEventsProvider.LOGIN, this.updateHandlers.bind(this));
eventsProvider.on(CoreEventsProvider.SITE_UPDATED, this.updateHandlers.bind(this));
eventsProvider.on(CoreEventsProvider.SITE_ADDONS_LOADED, this.updateHandlers.bind(this));
eventsProvider.on(CoreEventsProvider.SITE_PLUGINS_LOADED, this.updateHandlers.bind(this));
}
}

View File

@ -42,7 +42,7 @@ import { CoreLoggerProvider } from '@providers/logger';
*
* Alternatively, you can also supply a ComponentRef instead of the class of the component. In this case, the component won't
* be instantiated because it already is, it will be attached to the view and the right data will be passed to it.
* Passing ComponentRef is meant for site addons, so we'll inject a NavController instance to the component.
* Passing ComponentRef is meant for site plugins, so we'll inject a NavController instance to the component.
*
* The contents of this component will be displayed if no component is supplied or it cannot be created. In the example above,
* if no component is supplied then the template will show the message "Cannot render the data.".
@ -139,7 +139,7 @@ export class CoreDynamicComponent implements OnInit, OnChanges, DoCheck {
this.container.insert(this.component.hostView);
this.instance = this.component.instance;
// This feature is usually meant for site addons. Inject some properties.
// This feature is usually meant for site plugins. Inject some properties.
this.instance['ChangeDetectorRef'] = this.cdr;
this.instance['NavController'] = this.navCtrl;
this.instance['componentContainer'] = this.element.nativeElement;

View File

@ -35,7 +35,7 @@ import { CORE_USER_PROVIDERS } from '../../user/user.module';
import { IONIC_NATIVE_PROVIDERS } from '../../emulator/emulator.module';
// Import only this provider to prevent circular dependencies.
import { CoreSiteAddonsProvider } from '../../siteaddons/providers/siteaddons';
import { CoreSitePluginsProvider } from '../../siteplugins/providers/siteplugins';
// Import other libraries and providers.
import { DomSanitizer } from '@angular/platform-browser';
@ -47,7 +47,7 @@ import { CoreConstants } from '../../constants';
import * as moment from 'moment';
import { Md5 } from 'ts-md5/dist/md5';
// Import core classes that can be useful for site addons.
// Import core classes that can be useful for site plugins.
import { CoreSyncBaseProvider } from '../../../classes/base-sync';
import { CoreCache } from '../../../classes/cache';
import { CoreDelegate } from '../../../classes/delegate';
@ -63,16 +63,16 @@ import { CorePipesModule } from '../../../pipes/pipes.module';
import { CoreCourseComponentsModule } from '../../course/components/components.module';
import { CoreCourseDirectivesModule } from '../../course/directives/directives.module';
import { CoreCoursesComponentsModule } from '../../courses/components/components.module';
import { CoreSiteAddonsDirectivesModule } from '../../siteaddons/directives/directives.module';
import { CoreSitePluginsDirectivesModule } from '../../siteplugins/directives/directives.module';
import { CoreSiteHomeComponentsModule } from '../../sitehome/components/components.module';
import { CoreUserComponentsModule } from '../../user/components/components.module';
// Import some components listed in entryComponents so they can be injected dynamically.
import { CoreCourseUnsupportedModuleComponent } from '../../course/components/unsupported-module/unsupported-module';
import { CoreCourseFormatSingleActivityComponent } from '../../course/formats/singleactivity/components/singleactivity';
import { CoreSiteAddonsModuleIndexComponent } from '../../siteaddons/components/module-index/module-index';
import { CoreSiteAddonsCourseOptionComponent } from '../../siteaddons/components/course-option/course-option';
import { CoreSiteAddonsCourseFormatComponent } from '../../siteaddons/components/course-format/course-format';
import { CoreSitePluginsModuleIndexComponent } from '../../siteplugins/components/module-index/module-index';
import { CoreSitePluginsCourseOptionComponent } from '../../siteplugins/components/course-option/course-option';
import { CoreSitePluginsCourseFormatComponent } from '../../siteplugins/components/course-format/course-format';
/**
* Service to provide functionalities regarding compiling dynamic HTML and Javascript.
@ -92,7 +92,7 @@ export class CoreCompileProvider {
protected IMPORTS = [
IonicModule, TranslateModule.forChild(), CoreComponentsModule, CoreDirectivesModule, CorePipesModule,
CoreCourseComponentsModule, CoreCoursesComponentsModule, CoreSiteHomeComponentsModule, CoreUserComponentsModule,
CoreCourseDirectivesModule, CoreSiteAddonsDirectivesModule
CoreCourseDirectivesModule, CoreSitePluginsDirectivesModule
];
constructor(protected injector: Injector, logger: CoreLoggerProvider, protected compiler: Compiler) {
@ -163,7 +163,7 @@ export class CoreCompileProvider {
const providers = (<any[]> CORE_PROVIDERS).concat(CORE_CONTENTLINKS_PROVIDERS).concat(CORE_COURSE_PROVIDERS)
.concat(CORE_COURSES_PROVIDERS).concat(CORE_FILEUPLOADER_PROVIDERS).concat(CORE_GRADES_PROVIDERS)
.concat(CORE_LOGIN_PROVIDERS).concat(CORE_MAINMENU_PROVIDERS).concat(CORE_SHAREDFILES_PROVIDERS)
.concat(CORE_SITEHOME_PROVIDERS).concat([CoreSiteAddonsProvider]).concat(CORE_USER_PROVIDERS)
.concat(CORE_SITEHOME_PROVIDERS).concat([CoreSitePluginsProvider]).concat(CORE_USER_PROVIDERS)
.concat(IONIC_NATIVE_PROVIDERS).concat(this.OTHER_PROVIDERS);
// We cannot inject anything to this constructor. Use the Injector to inject all the providers into the instance.
@ -198,9 +198,9 @@ export class CoreCompileProvider {
instance['CoreCourseModulePrefetchHandlerBase'] = CoreCourseModulePrefetchHandlerBase;
instance['CoreCourseUnsupportedModuleComponent'] = CoreCourseUnsupportedModuleComponent;
instance['CoreCourseFormatSingleActivityComponent'] = CoreCourseFormatSingleActivityComponent;
instance['CoreSiteAddonsModuleIndexComponent'] = CoreSiteAddonsModuleIndexComponent;
instance['CoreSiteAddonsCourseOptionComponent'] = CoreSiteAddonsCourseOptionComponent;
instance['CoreSiteAddonsCourseFormatComponent'] = CoreSiteAddonsCourseFormatComponent;
instance['CoreSitePluginsModuleIndexComponent'] = CoreSitePluginsModuleIndexComponent;
instance['CoreSitePluginsCourseOptionComponent'] = CoreSitePluginsCourseOptionComponent;
instance['CoreSitePluginsCourseFormatComponent'] = CoreSitePluginsCourseFormatComponent;
}
/**

View File

@ -1 +0,0 @@
<core-site-addons-addon-content *ngIf="component && method" [component]="component" [method]="method" [args]="args" [bootstrapResult]="bootstrapResult"></core-site-addons-addon-content>

View File

@ -1,15 +0,0 @@
<ion-header>
<ion-navbar>
<ion-title>{{ title }}</ion-title>
<ion-buttons end>
<!-- If the site addon defines some buttons using core-nav-buttons, they will be added here. -->
</ion-buttons>
</ion-navbar>
</ion-header>
<ion-content>
<ion-refresher [enabled]="content && content.addonContent && content.addonContent.dataLoaded" (ionRefresh)="refreshData($event)">
<ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
</ion-refresher>
<core-site-addons-module-index [module]="module" [courseId]="courseId"></core-site-addons-module-index>
</ion-content>

View File

@ -15,9 +15,9 @@
import { CoreDelegateHandler } from '../../../classes/delegate';
/**
* Super class for handlers for site addons.
* Super class for handlers for site plugins.
*/
export class CoreSiteAddonsBaseHandler implements CoreDelegateHandler {
export class CoreSitePluginsBaseHandler implements CoreDelegateHandler {
constructor(public name: string) { }

View File

@ -15,23 +15,24 @@
import { Input, OnInit, ElementRef } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { CoreDomUtilsProvider } from '../../../providers/utils/dom';
import { CoreSiteAddonsProvider } from '../providers/siteaddons';
import { CoreSiteAddonsAddonContentComponent } from '../components/addon-content/addon-content';
import { CoreSiteAddonsCallWSBaseDirective } from './call-ws-directive';
import { CoreSitePluginsProvider } from '../providers/siteplugins';
import { CoreSitePluginsPluginContentComponent } from '../components/plugin-content/plugin-content';
import { CoreSitePluginsCallWSBaseDirective } from './call-ws-directive';
/**
* Base class for directives to call a WS when the element is clicked.
*
* The directives that inherit from this class will call a WS method when the element is clicked.
*
* @see CoreSiteAddonsCallWSBaseDirective
* @see CoreSitePluginsCallWSBaseDirective
*/
export class CoreSiteAddonsCallWSOnClickBaseDirective extends CoreSiteAddonsCallWSBaseDirective implements OnInit {
export class CoreSitePluginsCallWSOnClickBaseDirective extends CoreSitePluginsCallWSBaseDirective implements OnInit {
@Input() confirmMessage: string; // Message to confirm the action. If not supplied, no confirmation. If empty, default message.
constructor(element: ElementRef, protected translate: TranslateService, protected domUtils: CoreDomUtilsProvider,
protected siteAddonsProvider: CoreSiteAddonsProvider, protected parentContent: CoreSiteAddonsAddonContentComponent) {
super(element, translate, domUtils, siteAddonsProvider, parentContent);
protected sitePluginsProvider: CoreSitePluginsProvider,
protected parentContent: CoreSitePluginsPluginContentComponent) {
super(element, translate, domUtils, sitePluginsProvider, parentContent);
}
/**

View File

@ -15,19 +15,19 @@
import { Input, OnInit, OnDestroy, ElementRef } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { CoreDomUtilsProvider } from '../../../providers/utils/dom';
import { CoreSiteAddonsProvider } from '../providers/siteaddons';
import { CoreSiteAddonsAddonContentComponent } from '../components/addon-content/addon-content';
import { CoreSitePluginsProvider } from '../providers/siteplugins';
import { CoreSitePluginsPluginContentComponent } from '../components/plugin-content/plugin-content';
import { Subscription } from 'rxjs';
/**
* Base class for directives that need to call a WS.
*/
export class CoreSiteAddonsCallWSBaseDirective implements OnInit, OnDestroy {
export class CoreSitePluginsCallWSBaseDirective implements OnInit, OnDestroy {
@Input() name: string; // The name of the WS to call.
@Input() params: any; // The params for the WS call.
@Input() preSets: any; // The preSets for the WS call.
@Input() useOtherDataForWS: any[]; // Whether to include other data in the params for the WS.
// @see CoreSiteAddonsProvider.loadOtherDataInArgs.
// @see CoreSitePluginsProvider.loadOtherDataInArgs.
@Input() form: string; // ID or name to identify a form. The form will be obtained from document.forms.
// If supplied and form is found, the form data will be retrieved and sent to the WS.
@ -35,7 +35,8 @@ export class CoreSiteAddonsCallWSBaseDirective implements OnInit, OnDestroy {
protected invalidateObserver: Subscription;
constructor(element: ElementRef, protected translate: TranslateService, protected domUtils: CoreDomUtilsProvider,
protected siteAddonsProvider: CoreSiteAddonsProvider, protected parentContent: CoreSiteAddonsAddonContentComponent) {
protected sitePluginsProvider: CoreSitePluginsProvider,
protected parentContent: CoreSitePluginsPluginContentComponent) {
this.element = element.nativeElement || element;
}
@ -58,7 +59,7 @@ export class CoreSiteAddonsCallWSBaseDirective implements OnInit, OnDestroy {
protected callWS(): Promise<any> {
const params = this.getParamsForWS();
return this.siteAddonsProvider.callWS(this.name, params, this.preSets).then((result) => {
return this.sitePluginsProvider.callWS(this.name, params, this.preSets).then((result) => {
return this.wsCallSuccess(result);
}).catch((error) => {
this.domUtils.showErrorModalDefault(error, 'core.serverconnection', true);
@ -74,7 +75,7 @@ export class CoreSiteAddonsCallWSBaseDirective implements OnInit, OnDestroy {
let params = this.params || {};
if (this.parentContent) {
params = this.siteAddonsProvider.loadOtherDataInArgs(params, this.parentContent.otherData, this.useOtherDataForWS);
params = this.sitePluginsProvider.loadOtherDataInArgs(params, this.parentContent.otherData, this.useOtherDataForWS);
}
if (this.form && document.forms[this.form]) {
@ -101,7 +102,7 @@ export class CoreSiteAddonsCallWSBaseDirective implements OnInit, OnDestroy {
invalidate(): Promise<any> {
const params = this.getParamsForWS();
return this.siteAddonsProvider.invalidateCallWS(this.name, params, this.preSets);
return this.sitePluginsProvider.invalidateCallWS(this.name, params, this.preSets);
}
/**

View File

@ -14,13 +14,13 @@
import { Injector } from '@angular/core';
import { CoreCourseFormatHandler } from '../../course/providers/format-delegate';
import { CoreSiteAddonsBaseHandler } from './base-handler';
import { CoreSiteAddonsCourseFormatComponent } from '../components/course-format/course-format';
import { CoreSitePluginsBaseHandler } from './base-handler';
import { CoreSitePluginsCourseFormatComponent } from '../components/course-format/course-format';
/**
* Handler to support a course format using a site addon.
* Handler to support a course format using a site plugin.
*/
export class CoreSiteAddonsCourseFormatHandler extends CoreSiteAddonsBaseHandler implements CoreCourseFormatHandler {
export class CoreSitePluginsCourseFormatHandler extends CoreSitePluginsBaseHandler implements CoreCourseFormatHandler {
constructor(name: string, protected handlerSchema: any) {
super(name);
@ -68,7 +68,7 @@ export class CoreSiteAddonsCourseFormatHandler extends CoreSiteAddonsBaseHandler
*/
getCourseFormatComponent(injector: Injector, course: any): any | Promise<any> {
if (this.handlerSchema.method) {
return CoreSiteAddonsCourseFormatComponent;
return CoreSitePluginsCourseFormatComponent;
}
}
}

View File

@ -13,19 +13,19 @@
// limitations under the License.
import { Injector } from '@angular/core';
import { CoreSiteAddonsProvider } from '../providers/siteaddons';
import { CoreSitePluginsProvider } from '../providers/siteplugins';
import { CoreCourseOptionsHandler, CoreCourseOptionsHandlerData } from '../../course/providers/options-delegate';
import { CoreSiteAddonsBaseHandler } from './base-handler';
import { CoreSiteAddonsCourseOptionComponent } from '../components/course-option/course-option';
import { CoreSitePluginsBaseHandler } from './base-handler';
import { CoreSitePluginsCourseOptionComponent } from '../components/course-option/course-option';
/**
* Handler to display a site addon in course options.
* Handler to display a site plugin in course options.
*/
export class CoreSiteAddonsCourseOptionHandler extends CoreSiteAddonsBaseHandler implements CoreCourseOptionsHandler {
export class CoreSitePluginsCourseOptionHandler extends CoreSitePluginsBaseHandler implements CoreCourseOptionsHandler {
priority: number;
constructor(name: string, protected title: string, protected addon: any, protected handlerSchema: any,
protected bootstrapResult: any, protected siteAddonsProvider: CoreSiteAddonsProvider) {
constructor(name: string, protected title: string, protected plugin: any, protected handlerSchema: any,
protected bootstrapResult: any, protected sitePluginsProvider: CoreSitePluginsProvider) {
super(name);
this.priority = handlerSchema.priority;
@ -41,7 +41,7 @@ export class CoreSiteAddonsCourseOptionHandler extends CoreSiteAddonsBaseHandler
* @return {boolean|Promise<boolean>} True or promise resolved with true if enabled.
*/
isEnabledForCourse(courseId: number, accessData: any, navOptions?: any, admOptions?: any): boolean | Promise<boolean> {
return this.siteAddonsProvider.isHandlerEnabledForCourse(
return this.sitePluginsProvider.isHandlerEnabledForCourse(
courseId, this.handlerSchema.restricttoenrolledcourses, this.bootstrapResult.restrict);
}
@ -56,7 +56,7 @@ export class CoreSiteAddonsCourseOptionHandler extends CoreSiteAddonsBaseHandler
return {
title: this.title,
class: this.handlerSchema.displaydata.class,
component: CoreSiteAddonsCourseOptionComponent,
component: CoreSitePluginsCourseOptionComponent,
componentData: {
handlerUniqueName: this.name
}
@ -64,7 +64,7 @@ export class CoreSiteAddonsCourseOptionHandler extends CoreSiteAddonsBaseHandler
}
/**
* Called when a course is downloaded. It should prefetch all the data to be able to see the addon in offline.
* Called when a course is downloaded. It should prefetch all the data to be able to see the plugin in offline.
*
* @param {any} course The course.
* @return {Promise<any>} Promise resolved when done.
@ -73,8 +73,8 @@ export class CoreSiteAddonsCourseOptionHandler extends CoreSiteAddonsBaseHandler
const args = {
courseid: course.id,
},
component = this.addon.component;
component = this.plugin.component;
return this.siteAddonsProvider.prefetchFunctions(component, args, this.handlerSchema, course.id, undefined, true);
return this.sitePluginsProvider.prefetchFunctions(component, args, this.handlerSchema, course.id, undefined, true);
}
}

View File

@ -13,15 +13,15 @@
// limitations under the License.
import { CoreMainMenuHandler, CoreMainMenuHandlerData } from '../../mainmenu/providers/delegate';
import { CoreSiteAddonsBaseHandler } from './base-handler';
import { CoreSitePluginsBaseHandler } from './base-handler';
/**
* Handler to display a site addon in the main menu.
* Handler to display a site plugin in the main menu.
*/
export class CoreSiteAddonsMainMenuHandler extends CoreSiteAddonsBaseHandler implements CoreMainMenuHandler {
export class CoreSitePluginsMainMenuHandler extends CoreSitePluginsBaseHandler implements CoreMainMenuHandler {
priority: number;
constructor(name: string, protected title: string, protected addon: any, protected handlerSchema: any,
constructor(name: string, protected title: string, protected plugin: any, protected handlerSchema: any,
protected bootstrapResult: any) {
super(name);
@ -38,10 +38,10 @@ export class CoreSiteAddonsMainMenuHandler extends CoreSiteAddonsBaseHandler imp
title: this.title,
icon: this.handlerSchema.displaydata.icon,
class: this.handlerSchema.displaydata.class,
page: 'CoreSiteAddonsAddonPage',
page: 'CoreSitePluginsPluginPage',
pageParams: {
title: this.title,
component: this.addon.component,
component: this.plugin.component,
method: this.handlerSchema.method,
bootstrapResult: this.bootstrapResult
}

View File

@ -15,13 +15,13 @@
import { Injector } from '@angular/core';
import { NavController, NavOptions } from 'ionic-angular';
import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '../../course/providers/module-delegate';
import { CoreSiteAddonsBaseHandler } from './base-handler';
import { CoreSiteAddonsModuleIndexComponent } from '../components/module-index/module-index';
import { CoreSitePluginsBaseHandler } from './base-handler';
import { CoreSitePluginsModuleIndexComponent } from '../components/module-index/module-index';
/**
* Handler to support a module using a site addon.
* Handler to support a module using a site plugin.
*/
export class CoreSiteAddonsModuleHandler extends CoreSiteAddonsBaseHandler implements CoreCourseModuleHandler {
export class CoreSitePluginsModuleHandler extends CoreSitePluginsBaseHandler implements CoreCourseModuleHandler {
priority: number;
constructor(name: string, protected handlerSchema: any) {
@ -49,7 +49,7 @@ export class CoreSiteAddonsModuleHandler extends CoreSiteAddonsBaseHandler imple
event.preventDefault();
event.stopPropagation();
navCtrl.push('CoreSiteAddonsModuleIndexPage', {
navCtrl.push('CoreSitePluginsModuleIndexPage', {
title: module.name,
module: module,
courseId: courseId
@ -69,6 +69,6 @@ export class CoreSiteAddonsModuleHandler extends CoreSiteAddonsBaseHandler imple
* @return {any|Promise<any>} The component (or promise resolved with component) to use, undefined if not found.
*/
getMainComponent(injector: Injector, course: any, module: any): any | Promise<any> {
return CoreSiteAddonsModuleIndexComponent;
return CoreSitePluginsModuleIndexComponent;
}
}

View File

@ -13,16 +13,16 @@
// limitations under the License.
import { Injector } from '@angular/core';
import { CoreSiteAddonsProvider } from '../../siteaddons/providers/siteaddons';
import { CoreSitePluginsProvider } from '../providers/siteplugins';
import { CoreCourseModulePrefetchHandlerBase } from '../../course/classes/module-prefetch-handler';
/**
* Handler to prefetch a site addon.
* Handler to prefetch a module site plugin.
*/
export class CoreSiteAddonsModulePrefetchHandler extends CoreCourseModulePrefetchHandlerBase {
protected ROOT_CACHE_KEY = 'CoreSiteAddonsModulePrefetchHandler:';
export class CoreSitePluginsModulePrefetchHandler extends CoreCourseModulePrefetchHandlerBase {
protected ROOT_CACHE_KEY = 'CoreSitePluginsModulePrefetchHandler:';
constructor(injector: Injector, protected siteAddonsProvider: CoreSiteAddonsProvider, component: string, modName: string,
constructor(injector: Injector, protected sitePluginsProvider: CoreSitePluginsProvider, component: string, modName: string,
protected handlerSchema: any) {
super(injector);
@ -51,11 +51,11 @@ export class CoreSiteAddonsModulePrefetchHandler extends CoreCourseModulePrefetc
* @return {Promise<any>} Promise resolved when all content is downloaded. Data returned is not reliable.
*/
downloadOrPrefetch(module: any, courseId: number, prefetch?: boolean, dirPath?: string): Promise<any> {
return this.prefetchPackage(module, courseId, false, this.downloadOrPrefetchAddon.bind(this), undefined, prefetch, dirPath);
return this.prefetchPackage(module, courseId, false, this.downloadPrefetchPlugin.bind(this), undefined, prefetch, dirPath);
}
/**
* Download or prefetch the addon, downloading the files and calling the needed WS.
* Download or prefetch the plugin, downloading the files and calling the needed WS.
*
* @param {any} module The module object returned by WS.
* @param {number} courseId Course ID.
@ -65,7 +65,7 @@ export class CoreSiteAddonsModulePrefetchHandler extends CoreCourseModulePrefetc
* @param {string} [dirPath] Path of the directory where to store all the content files. @see downloadOrPrefetch.
* @return {Promise<any>} Promise resolved when done.
*/
protected downloadOrPrefetchAddon(module: any, courseId: number, single?: boolean, siteId?: string, prefetch?: boolean,
protected downloadPrefetchPlugin(module: any, courseId: number, single?: boolean, siteId?: string, prefetch?: boolean,
dirPath?: string): Promise<any> {
return this.sitesProvider.getSite(siteId).then((site) => {
@ -80,7 +80,7 @@ export class CoreSiteAddonsModulePrefetchHandler extends CoreCourseModulePrefetc
promises.push(this.downloadOrPrefetchFiles(site.id, module, courseId, prefetch, dirPath));
// Call all the offline functions.
promises.push(this.siteAddonsProvider.prefetchFunctions(this.component, args, this.handlerSchema, courseId,
promises.push(this.sitePluginsProvider.prefetchFunctions(this.component, args, this.handlerSchema, courseId,
module, prefetch, dirPath, site));
return Promise.all(promises);
@ -88,7 +88,7 @@ export class CoreSiteAddonsModulePrefetchHandler extends CoreCourseModulePrefetc
}
/**
* Download or prefetch the addon files.
* Download or prefetch the plugin files.
*
* @param {any} module The module object returned by WS.
* @param {number} courseId Course ID.
@ -150,10 +150,10 @@ export class CoreSiteAddonsModulePrefetchHandler extends CoreCourseModulePrefetc
for (const method in this.handlerSchema.offlinefunctions) {
if (currentSite.wsAvailable(method)) {
// The method is a WS.
promises.push(currentSite.invalidateWsCacheForKey(this.siteAddonsProvider.getCallWSCacheKey(method, args)));
promises.push(currentSite.invalidateWsCacheForKey(this.sitePluginsProvider.getCallWSCacheKey(method, args)));
} else {
// It's a method to get content.
promises.push(this.siteAddonsProvider.invalidateContent(this.component, method, args));
promises.push(this.sitePluginsProvider.invalidateContent(this.component, method, args));
}
}

View File

@ -14,13 +14,13 @@
import { NavController } from 'ionic-angular';
import { CoreUserDelegate, CoreUserProfileHandler, CoreUserProfileHandlerData } from '../../user/providers/user-delegate';
import { CoreSiteAddonsProvider } from '../providers/siteaddons';
import { CoreSiteAddonsBaseHandler } from './base-handler';
import { CoreSitePluginsProvider } from '../providers/siteplugins';
import { CoreSitePluginsBaseHandler } from './base-handler';
/**
* Handler to display a site addon in the user profile.
* Handler to display a site plugin in the user profile.
*/
export class CoreSiteAddonsUserProfileHandler extends CoreSiteAddonsBaseHandler implements CoreUserProfileHandler {
export class CoreSitePluginsUserProfileHandler extends CoreSitePluginsBaseHandler implements CoreUserProfileHandler {
/**
* The highest priority is displayed first.
* @type {number}
@ -37,8 +37,8 @@ export class CoreSiteAddonsUserProfileHandler extends CoreSiteAddonsBaseHandler
*/
type: string;
constructor(name: string, protected title: string, protected addon: any, protected handlerSchema: any,
protected bootstrapResult: any, protected siteAddonsProvider: CoreSiteAddonsProvider) {
constructor(name: string, protected title: string, protected plugin: any, protected handlerSchema: any,
protected bootstrapResult: any, protected sitePluginsProvider: CoreSitePluginsProvider) {
super(name);
this.priority = handlerSchema.priority;
@ -58,14 +58,14 @@ export class CoreSiteAddonsUserProfileHandler extends CoreSiteAddonsBaseHandler
*/
isEnabledForUser(user: any, courseId: number, navOptions?: any, admOptions?: any): boolean | Promise<boolean> {
// First check if it's enabled for the user.
const enabledForUser = this.siteAddonsProvider.isHandlerEnabledForUser(user.id, this.handlerSchema.restricttocurrentuser,
const enabledForUser = this.sitePluginsProvider.isHandlerEnabledForUser(user.id, this.handlerSchema.restricttocurrentuser,
this.bootstrapResult.restrict);
if (!enabledForUser) {
return false;
}
// Enabled for user, check if it's enabled for the course.
return this.siteAddonsProvider.isHandlerEnabledForCourse(
return this.sitePluginsProvider.isHandlerEnabledForCourse(
courseId, this.handlerSchema.restricttoenrolledcourses, this.bootstrapResult.restrict);
}
@ -84,9 +84,9 @@ export class CoreSiteAddonsUserProfileHandler extends CoreSiteAddonsBaseHandler
event.preventDefault();
event.stopPropagation();
navCtrl.push('CoreSiteAddonsAddonPage', {
navCtrl.push('CoreSitePluginsPluginPage', {
title: this.title,
component: this.addon.component,
component: this.plugin.component,
method: this.handlerSchema.method,
args: {
courseid: courseId,

View File

@ -14,13 +14,13 @@
import { Injector } from '@angular/core';
import { CoreUserProfileFieldHandler, CoreUserProfileFieldHandlerData } from '../../user/providers/user-profile-field-delegate';
import { CoreSiteAddonsBaseHandler } from './base-handler';
import { CoreSiteAddonsUserProfileFieldComponent } from '../components/user-profile-field/user-profile-field';
import { CoreSitePluginsBaseHandler } from './base-handler';
import { CoreSitePluginsUserProfileFieldComponent } from '../components/user-profile-field/user-profile-field';
/**
* Handler to display a site addon in the user profile.
* Handler to display a site plugin in the user profile.
*/
export class CoreSiteAddonsUserProfileFieldHandler extends CoreSiteAddonsBaseHandler implements CoreUserProfileFieldHandler {
export class CoreSitePluginsUserProfileFieldHandler extends CoreSitePluginsBaseHandler implements CoreUserProfileFieldHandler {
constructor(name: string) {
super(name);
@ -34,7 +34,7 @@ export class CoreSiteAddonsUserProfileFieldHandler extends CoreSiteAddonsBaseHan
* @return {any|Promise<any>} The component (or promise resolved with component) to use, undefined if not found.
*/
getComponent(injector: Injector): any | Promise<any> {
return CoreSiteAddonsUserProfileFieldComponent;
return CoreSitePluginsUserProfileFieldComponent;
}
/**

View File

@ -18,19 +18,19 @@ import { IonicModule } from 'ionic-angular';
import { TranslateModule } from '@ngx-translate/core';
import { CoreComponentsModule } from '../../../components/components.module';
import { CoreCompileHtmlComponentModule } from '../../compile/components/compile-html/compile-html.module';
import { CoreSiteAddonsAddonContentComponent } from './addon-content/addon-content';
import { CoreSiteAddonsModuleIndexComponent } from './module-index/module-index';
import { CoreSiteAddonsCourseOptionComponent } from './course-option/course-option';
import { CoreSiteAddonsCourseFormatComponent } from './course-format/course-format';
import { CoreSiteAddonsUserProfileFieldComponent } from './user-profile-field/user-profile-field';
import { CoreSitePluginsPluginContentComponent } from './plugin-content/plugin-content';
import { CoreSitePluginsModuleIndexComponent } from './module-index/module-index';
import { CoreSitePluginsCourseOptionComponent } from './course-option/course-option';
import { CoreSitePluginsCourseFormatComponent } from './course-format/course-format';
import { CoreSitePluginsUserProfileFieldComponent } from './user-profile-field/user-profile-field';
@NgModule({
declarations: [
CoreSiteAddonsAddonContentComponent,
CoreSiteAddonsModuleIndexComponent,
CoreSiteAddonsCourseOptionComponent,
CoreSiteAddonsCourseFormatComponent,
CoreSiteAddonsUserProfileFieldComponent
CoreSitePluginsPluginContentComponent,
CoreSitePluginsModuleIndexComponent,
CoreSitePluginsCourseOptionComponent,
CoreSitePluginsCourseFormatComponent,
CoreSitePluginsUserProfileFieldComponent
],
imports: [
CommonModule,
@ -42,17 +42,17 @@ import { CoreSiteAddonsUserProfileFieldComponent } from './user-profile-field/us
providers: [
],
exports: [
CoreSiteAddonsAddonContentComponent,
CoreSiteAddonsModuleIndexComponent,
CoreSiteAddonsCourseOptionComponent,
CoreSiteAddonsCourseFormatComponent,
CoreSiteAddonsUserProfileFieldComponent
CoreSitePluginsPluginContentComponent,
CoreSitePluginsModuleIndexComponent,
CoreSitePluginsCourseOptionComponent,
CoreSitePluginsCourseFormatComponent,
CoreSitePluginsUserProfileFieldComponent
],
entryComponents: [
CoreSiteAddonsModuleIndexComponent,
CoreSiteAddonsCourseOptionComponent,
CoreSiteAddonsCourseFormatComponent,
CoreSiteAddonsUserProfileFieldComponent
CoreSitePluginsModuleIndexComponent,
CoreSitePluginsCourseOptionComponent,
CoreSitePluginsCourseFormatComponent,
CoreSitePluginsUserProfileFieldComponent
]
})
export class CoreSiteAddonsComponentsModule {}
export class CoreSitePluginsComponentsModule {}

View File

@ -0,0 +1 @@
<core-site-plugins-plugin-content *ngIf="component && method" [component]="component" [method]="method" [args]="args" [bootstrapResult]="bootstrapResult"></core-site-plugins-plugin-content>

View File

@ -13,38 +13,38 @@
// limitations under the License.
import { Component, OnInit, Input, ViewChild } from '@angular/core';
import { CoreSiteAddonsProvider } from '../../providers/siteaddons';
import { CoreSiteAddonsAddonContentComponent } from '../addon-content/addon-content';
import { CoreSitePluginsProvider } from '../../providers/siteplugins';
import { CoreSitePluginsPluginContentComponent } from '../plugin-content/plugin-content';
/**
* Component that displays the index of a course format site addon.
* Component that displays the index of a course format site plugin.
*/
@Component({
selector: 'core-site-addons-course-format',
selector: 'core-site-plugins-course-format',
templateUrl: 'course-format.html',
})
export class CoreSiteAddonsCourseFormatComponent implements OnInit {
export class CoreSitePluginsCourseFormatComponent implements OnInit {
@Input() course: any; // The course to render.
@Input() sections: any[]; // List of course sections.
@Input() downloadEnabled?: boolean; // Whether the download of sections and modules is enabled.
@ViewChild(CoreSiteAddonsAddonContentComponent) content: CoreSiteAddonsAddonContentComponent;
@ViewChild(CoreSitePluginsPluginContentComponent) content: CoreSitePluginsPluginContentComponent;
component: string;
method: string;
args: any;
bootstrapResult: any;
constructor(protected siteAddonsProvider: CoreSiteAddonsProvider) { }
constructor(protected sitePluginsProvider: CoreSitePluginsProvider) { }
/**
* Component being initialized.
*/
ngOnInit(): void {
if (this.course && this.course.format) {
const handler = this.siteAddonsProvider.getSiteAddonHandler(this.course.format);
const handler = this.sitePluginsProvider.getSitePluginHandler(this.course.format);
if (handler) {
this.component = handler.addon.component;
this.component = handler.plugin.component;
this.method = handler.handlerSchema.method;
this.args = {
courseid: this.course.id,

View File

@ -2,5 +2,5 @@
<ion-refresher [enabled]="content && content.dataLoaded" (ionRefresh)="refreshData($event)">
<ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
</ion-refresher>
<core-site-addons-addon-content *ngIf="component && method" [component]="component" [method]="method" [args]="args" [bootstrapResult]="bootstrapResult"></core-site-addons-addon-content>
<core-site-plugins-plugin-content *ngIf="component && method" [component]="component" [method]="method" [args]="args" [bootstrapResult]="bootstrapResult"></core-site-plugins-plugin-content>
</ion-content>

View File

@ -13,37 +13,37 @@
// limitations under the License.
import { Component, OnInit, Input, ViewChild } from '@angular/core';
import { CoreSiteAddonsProvider } from '../../providers/siteaddons';
import { CoreSiteAddonsAddonContentComponent } from '../addon-content/addon-content';
import { CoreSitePluginsProvider } from '../../providers/siteplugins';
import { CoreSitePluginsPluginContentComponent } from '../plugin-content/plugin-content';
/**
* Component that displays the index of a course option site addon.
* Component that displays the index of a course option site plugin.
*/
@Component({
selector: 'core-site-addons-course-option',
selector: 'core-site-plugins-course-option',
templateUrl: 'course-option.html',
})
export class CoreSiteAddonsCourseOptionComponent implements OnInit {
export class CoreSitePluginsCourseOptionComponent implements OnInit {
@Input() courseId: number;
@Input() handlerUniqueName: string;
@ViewChild(CoreSiteAddonsAddonContentComponent) content: CoreSiteAddonsAddonContentComponent;
@ViewChild(CoreSitePluginsPluginContentComponent) content: CoreSitePluginsPluginContentComponent;
component: string;
method: string;
args: any;
bootstrapResult: any;
constructor(protected siteAddonsProvider: CoreSiteAddonsProvider) { }
constructor(protected sitePluginsProvider: CoreSitePluginsProvider) { }
/**
* Component being initialized.
*/
ngOnInit(): void {
if (this.handlerUniqueName) {
const handler = this.siteAddonsProvider.getSiteAddonHandler(this.handlerUniqueName);
const handler = this.sitePluginsProvider.getSitePluginHandler(this.handlerUniqueName);
if (handler) {
this.component = handler.addon.component;
this.component = handler.plugin.component;
this.method = handler.handlerSchema.method;
this.args = {
courseid: this.courseId,

View File

@ -9,4 +9,4 @@
</core-context-menu>
</core-navbar-buttons>
<core-site-addons-addon-content *ngIf="component && method" [component]="component" [method]="method" [args]="args" [bootstrapResult]="bootstrapResult" (onContentLoaded)="contentLoaded($event)" (onLoadingContent)="contentLoading($event)"></core-site-addons-addon-content>
<core-site-plugins-plugin-content *ngIf="component && method" [component]="component" [method]="method" [args]="args" [bootstrapResult]="bootstrapResult" (onContentLoaded)="contentLoaded($event)" (onLoadingContent)="contentLoading($event)"></core-site-plugins-plugin-content>

View File

@ -15,24 +15,24 @@
import { Component, OnInit, OnDestroy, Input, ViewChild } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { CoreTextUtilsProvider } from '../../../../providers/utils/text';
import { CoreSiteAddonsProvider } from '../../providers/siteaddons';
import { CoreSitePluginsProvider } from '../../providers/siteplugins';
import { CoreCourseModuleMainComponent } from '../../../course/providers/module-delegate';
import { CoreCourseModulePrefetchDelegate } from '../../../course/providers/module-prefetch-delegate';
import { CoreCourseHelperProvider } from '../../../course/providers/helper';
import { CoreSiteAddonsAddonContentComponent } from '../addon-content/addon-content';
import { CoreSitePluginsPluginContentComponent } from '../plugin-content/plugin-content';
/**
* Component that displays the index of a module site addon.
* Component that displays the index of a module site plugin.
*/
@Component({
selector: 'core-site-addons-module-index',
selector: 'core-site-plugins-module-index',
templateUrl: 'module-index.html',
})
export class CoreSiteAddonsModuleIndexComponent implements OnInit, OnDestroy, CoreCourseModuleMainComponent {
export class CoreSitePluginsModuleIndexComponent implements OnInit, OnDestroy, CoreCourseModuleMainComponent {
@Input() module: any; // The module.
@Input() courseId: number; // Course ID the module belongs to.
@ViewChild(CoreSiteAddonsAddonContentComponent) addonContent: CoreSiteAddonsAddonContentComponent;
@ViewChild(CoreSitePluginsPluginContentComponent) content: CoreSitePluginsPluginContentComponent;
component: string;
method: string;
@ -50,7 +50,7 @@ export class CoreSiteAddonsModuleIndexComponent implements OnInit, OnDestroy, Co
protected isDestroyed = false;
protected statusObserver;
constructor(protected siteAddonsProvider: CoreSiteAddonsProvider, protected courseHelper: CoreCourseHelperProvider,
constructor(protected sitePluginsProvider: CoreSitePluginsProvider, protected courseHelper: CoreCourseHelperProvider,
protected prefetchDelegate: CoreCourseModulePrefetchDelegate, protected textUtils: CoreTextUtilsProvider,
protected translate: TranslateService) { }
@ -61,9 +61,9 @@ export class CoreSiteAddonsModuleIndexComponent implements OnInit, OnDestroy, Co
this.refreshIcon = 'spinner';
if (this.module) {
const handler = this.siteAddonsProvider.getSiteAddonHandler(this.module.modname);
const handler = this.sitePluginsProvider.getSitePluginHandler(this.module.modname);
if (handler) {
this.component = handler.addon.component;
this.component = handler.plugin.component;
this.method = handler.handlerSchema.method;
this.args = {
courseid: this.courseId,
@ -86,10 +86,10 @@ export class CoreSiteAddonsModuleIndexComponent implements OnInit, OnDestroy, Co
* @return {Promise<any>} Promise resolved when done.
*/
doRefresh(refresher?: any, done?: () => void): Promise<any> {
if (this.addonContent) {
if (this.content) {
this.refreshIcon = 'spinner';
return Promise.resolve(this.addonContent.refreshData()).finally(() => {
return Promise.resolve(this.content.refreshData()).finally(() => {
refresher && refresher.complete();
done && done();
});
@ -102,7 +102,7 @@ export class CoreSiteAddonsModuleIndexComponent implements OnInit, OnDestroy, Co
}
/**
* Function called when the data of the site addon content is loaded.
* Function called when the data of the site plugin content is loaded.
*/
contentLoaded(refresh: boolean): void {
this.refreshIcon = 'refresh';
@ -114,7 +114,7 @@ export class CoreSiteAddonsModuleIndexComponent implements OnInit, OnDestroy, Co
}
/**
* Function called when starting to load the data of the site addon content.
* Function called when starting to load the data of the site plugin content.
*/
contentLoading(refresh: boolean): void {
this.refreshIcon = 'spinner';

View File

@ -14,17 +14,17 @@
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { CoreDomUtilsProvider } from '../../../../providers/utils/dom';
import { CoreSiteAddonsProvider } from '../../providers/siteaddons';
import { CoreSitePluginsProvider } from '../../providers/siteplugins';
import { Subject } from 'rxjs';
/**
* Component to render a site addon content.
* Component to render a site plugin content.
*/
@Component({
selector: 'core-site-addons-addon-content',
templateUrl: 'addon-content.html',
selector: 'core-site-plugins-plugin-content',
templateUrl: 'plugin-content.html',
})
export class CoreSiteAddonsAddonContentComponent implements OnInit {
export class CoreSitePluginsPluginContentComponent implements OnInit {
@Input() component: string;
@Input() method: string;
@Input() args: any;
@ -39,7 +39,7 @@ export class CoreSiteAddonsAddonContentComponent implements OnInit {
invalidateObservable: Subject<void>; // An observable to notify observers when to invalidate data.
jsData: any; // Data to pass to the component.
constructor(protected domUtils: CoreDomUtilsProvider, protected siteAddonsProvider: CoreSiteAddonsProvider) {
constructor(protected domUtils: CoreDomUtilsProvider, protected sitePluginsProvider: CoreSitePluginsProvider) {
this.onContentLoaded = new EventEmitter();
this.onLoadingContent = new EventEmitter();
this.invalidateObservable = new Subject<void>();
@ -61,11 +61,11 @@ export class CoreSiteAddonsAddonContentComponent implements OnInit {
fetchContent(refresh?: boolean): Promise<any> {
this.onLoadingContent.emit(refresh);
return this.siteAddonsProvider.getContent(this.component, this.method, this.args).then((result) => {
return this.sitePluginsProvider.getContent(this.component, this.method, this.args).then((result) => {
this.content = result.templates.length ? result.templates[0].html : ''; // Load first template.
this.javascript = result.javascript;
this.otherData = result.otherdata;
this.jsData = this.siteAddonsProvider.createDataForJS(this.bootstrapResult, result);
this.jsData = this.sitePluginsProvider.createDataForJS(this.bootstrapResult, result);
this.onContentLoaded.emit(refresh);
}).catch((error) => {
@ -87,7 +87,7 @@ export class CoreSiteAddonsAddonContentComponent implements OnInit {
this.invalidateObservable.next(); // Notify observers.
return this.siteAddonsProvider.invalidateContent(this.component, this.method, this.args).finally(() => {
return this.sitePluginsProvider.invalidateContent(this.component, this.method, this.args).finally(() => {
return this.fetchContent(true);
});
}

View File

@ -13,18 +13,18 @@
// limitations under the License.
import { Component, OnInit, Input, ViewChild, OnDestroy } from '@angular/core';
import { CoreSiteAddonsProvider } from '../../providers/siteaddons';
import { CoreSitePluginsProvider } from '../../providers/siteplugins';
import { CoreCompileHtmlComponent } from '../../../compile/components/compile-html/compile-html';
import { Subscription } from 'rxjs';
/**
* Component that displays a user profile field created using a site addon.
* Component that displays a user profile field created using a site plugin.
*/
@Component({
selector: 'core-site-addons-user-profile-field',
selector: 'core-site-plugins-user-profile-field',
templateUrl: 'user-profile-field.html',
})
export class CoreSiteAddonsUserProfileFieldComponent implements OnInit, OnDestroy {
export class CoreSitePluginsUserProfileFieldComponent implements OnInit, OnDestroy {
@Input() field: any; // The profile field to be rendered.
@Input() signup = false; // True if editing the field in signup. Defaults to false.
@Input() edit = false; // True if editing the field. Defaults to false.
@ -37,7 +37,7 @@ export class CoreSiteAddonsUserProfileFieldComponent implements OnInit, OnDestro
jsData;
protected componentObserver: Subscription;
constructor(protected siteAddonsProvider: CoreSiteAddonsProvider) { }
constructor(protected sitePluginsProvider: CoreSitePluginsProvider) { }
/**
* Component being initialized.
@ -55,7 +55,7 @@ export class CoreSiteAddonsUserProfileFieldComponent implements OnInit, OnDestro
if (this.field) {
// Retrieve the handler data.
const handler = this.siteAddonsProvider.getSiteAddonHandler(this.field.type || this.field.datatype),
const handler = this.sitePluginsProvider.getSitePluginHandler(this.field.type || this.field.datatype),
handlerSchema = handler && handler.handlerSchema;
if (handlerSchema) {

View File

@ -17,53 +17,53 @@ import { NavController } from 'ionic-angular';
import { TranslateService } from '@ngx-translate/core';
import { CoreDomUtilsProvider } from '../../../providers/utils/dom';
import { CoreUtilsProvider } from '../../../providers/utils/utils';
import { CoreSiteAddonsProvider } from '../providers/siteaddons';
import { CoreSiteAddonsCallWSOnClickBaseDirective } from '../classes/call-ws-click-directive';
import { CoreSiteAddonsAddonContentComponent } from '../components/addon-content/addon-content';
import { CoreSitePluginsProvider } from '../providers/siteplugins';
import { CoreSitePluginsCallWSOnClickBaseDirective } from '../classes/call-ws-click-directive';
import { CoreSitePluginsPluginContentComponent } from '../components/plugin-content/plugin-content';
/**
* Directive to call a WS when the element is clicked and load a new content passing the WS result as args. This new content
* can be displayed in a new page or in the same page (only if current page is already displaying a site addon content).
* can be displayed in a new page or in the same page (only if current page is already displaying a site plugin content).
*
* If you don't need to load some new content when done, @see CoreSiteAddonsCallWSDirective.
* If you don't need to load some new content when done, @see CoreSitePluginsCallWSDirective.
*
* @see CoreSiteAddonsCallWSOnClickBaseDirective.
* @see CoreSitePluginsCallWSOnClickBaseDirective.
*
* Example usages:
*
* A button to get some data from the server without using cache, showing default confirm and displaying a new page:
*
* <button ion-button core-site-addons-call-ws-new-content name="mod_certificate_get_issued_certificates"
* <button ion-button core-site-plugins-call-ws-new-content name="mod_certificate_get_issued_certificates"
* [params]="{certificateid: <% certificate.id %>}" [preSets]="{getFromCache: 0, saveToCache: 0}" confirmMessage
* title="<% certificate.name %>" component="mod_certificate" method="mobile_issues_view"
* [args]="{cmid: <% cmid %>, courseid: <% courseid %>}">
* {{ 'addon.mod_certificate_coursecertificate.getissued' | translate }}
* {{ 'plugin.mod_certificate_coursecertificate.getissued' | translate }}
* </button>
*
* A button to get some data from the server using cache, without confirm, displaying new content in same page and using
* userid from otherdata:
*
* <button ion-button core-site-addons-call-ws-new-content name="mod_certificate_get_issued_certificates"
* <button ion-button core-site-plugins-call-ws-new-content name="mod_certificate_get_issued_certificates"
* [params]="{certificateid: <% certificate.id %>}" component="mod_certificate" method="mobile_issues_view"
* [args]="{cmid: <% cmid %>, courseid: <% courseid %>}" samePage="true" [useOtherData]="['userid']">
* {{ 'addon.mod_certificate_coursecertificate.getissued' | translate }}
* {{ 'plugin.mod_certificate_coursecertificate.getissued' | translate }}
* </button>
*/
@Directive({
selector: '[core-site-addons-call-ws-new-content]'
selector: '[core-site-plugins-call-ws-new-content]'
})
export class CoreSiteAddonsCallWSNewContentDirective extends CoreSiteAddonsCallWSOnClickBaseDirective {
export class CoreSitePluginsCallWSNewContentDirective extends CoreSitePluginsCallWSOnClickBaseDirective {
@Input() component: string; // The component of the new content.
@Input() method: string; // The method to get the new content.
@Input() args: any; // The params to get the new content.
@Input() title: string; // The title to display with the new content. Only if samePage=false.
@Input() samePage: boolean | string; // Whether to display the content in same page or open a new one. Defaults to new page.
@Input() useOtherData: any[]; // Whether to include other data in the args. @see CoreSiteAddonsProvider.loadOtherDataInArgs.
@Input() useOtherData: any[]; // Whether to include other data in the args. @see CoreSitePluginsProvider.loadOtherDataInArgs.
constructor(element: ElementRef, translate: TranslateService, domUtils: CoreDomUtilsProvider,
siteAddonsProvider: CoreSiteAddonsProvider, @Optional() parentContent: CoreSiteAddonsAddonContentComponent,
sitePluginsProvider: CoreSitePluginsProvider, @Optional() parentContent: CoreSitePluginsPluginContentComponent,
protected utils: CoreUtilsProvider, @Optional() protected navCtrl: NavController) {
super(element, translate, domUtils, siteAddonsProvider, parentContent);
super(element, translate, domUtils, sitePluginsProvider, parentContent);
}
/**
@ -75,7 +75,7 @@ export class CoreSiteAddonsCallWSNewContentDirective extends CoreSiteAddonsCallW
let args = this.args || {};
if (this.parentContent) {
args = this.siteAddonsProvider.loadOtherDataInArgs(this.args, this.parentContent.otherData, this.useOtherData);
args = this.sitePluginsProvider.loadOtherDataInArgs(this.args, this.parentContent.otherData, this.useOtherData);
}
// Add the properties from the WS call result to the args.
@ -87,7 +87,7 @@ export class CoreSiteAddonsCallWSNewContentDirective extends CoreSiteAddonsCallW
this.parentContent.updateContent(this.component, this.method, args);
}
} else {
this.navCtrl.push('CoreSiteAddonsAddonPage', {
this.navCtrl.push('CoreSitePluginsPluginPage', {
title: this.title,
component: this.component,
method: this.method,

View File

@ -16,31 +16,31 @@ import { Directive, Input, OnInit, ElementRef, Optional } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { CoreDomUtilsProvider } from '../../../providers/utils/dom';
import { CoreUtilsProvider } from '../../../providers/utils/utils';
import { CoreSiteAddonsProvider } from '../providers/siteaddons';
import { CoreSiteAddonsCallWSBaseDirective } from '../classes/call-ws-directive';
import { CoreSiteAddonsAddonContentComponent } from '../components/addon-content/addon-content';
import { CoreSitePluginsProvider } from '../providers/siteplugins';
import { CoreSitePluginsCallWSBaseDirective } from '../classes/call-ws-directive';
import { CoreSitePluginsPluginContentComponent } from '../components/plugin-content/plugin-content';
/**
* Directive to call a WS as soon as its loaded.
* This directive is meant for actions to do in the background, like calling logging WebServices.
*
* If you want to call a WS when the user clicks on a certain element, @see CoreSiteAddonsCallWSDirective.
* If you want to call a WS when the user clicks on a certain element, @see CoreSitePluginsCallWSDirective.
*
* @see CoreSiteAddonsCallWSBaseDirective.
* @see CoreSitePluginsCallWSBaseDirective.
*
* Example usage:
*
* <span core-site-addons-call-ws-on-load name="mod_certificate_view_certificate" [params]="{certificateid: <% certificate.id %>}"
* <span core-site-plugins-call-ws-on-load name="mod_certificate_view_certificate" [params]="{certificateid: <% certificate.id %>}"
* [preSets]="{getFromCache: 0, saveToCache: 0}"></span>
*/
@Directive({
selector: '[core-site-addons-call-ws-on-load]'
selector: '[core-site-plugins-call-ws-on-load]'
})
export class CoreSiteAddonsCallWSOnLoadDirective extends CoreSiteAddonsCallWSBaseDirective implements OnInit {
export class CoreSitePluginsCallWSOnLoadDirective extends CoreSitePluginsCallWSBaseDirective implements OnInit {
constructor(element: ElementRef, translate: TranslateService, domUtils: CoreDomUtilsProvider,
siteAddonsProvider: CoreSiteAddonsProvider, @Optional() parentContent: CoreSiteAddonsAddonContentComponent) {
super(element, translate, domUtils, siteAddonsProvider, parentContent);
sitePluginsProvider: CoreSitePluginsProvider, @Optional() parentContent: CoreSitePluginsPluginContentComponent) {
super(element, translate, domUtils, sitePluginsProvider, parentContent);
}
/**

View File

@ -17,47 +17,47 @@ import { NavController } from 'ionic-angular';
import { TranslateService } from '@ngx-translate/core';
import { CoreDomUtilsProvider } from '../../../providers/utils/dom';
import { CoreUtilsProvider } from '../../../providers/utils/utils';
import { CoreSiteAddonsProvider } from '../providers/siteaddons';
import { CoreSiteAddonsCallWSOnClickBaseDirective } from '../classes/call-ws-click-directive';
import { CoreSiteAddonsAddonContentComponent } from '../components/addon-content/addon-content';
import { CoreSitePluginsProvider } from '../providers/siteplugins';
import { CoreSitePluginsCallWSOnClickBaseDirective } from '../classes/call-ws-click-directive';
import { CoreSitePluginsPluginContentComponent } from '../components/plugin-content/plugin-content';
/**
* Directive to call a WS when the element is clicked. The action to do when the WS call is successful depends on the input data:
* display a message, go back or refresh current view.
*
* If you want to load a new content when the WS call is done, @see CoreSiteAddonsCallWSNewContentDirective.
* If you want to load a new content when the WS call is done, @see CoreSitePluginsCallWSNewContentDirective.
*
* @see CoreSiteAddonsCallWSOnClickBaseDirective.
* @see CoreSitePluginsCallWSOnClickBaseDirective.
*
* Example usages:
*
* A button to send some data to the server without using cache, displaying default messages and refreshing on success:
*
* <button ion-button core-site-addons-call-ws name="mod_certificate_view_certificate"
* <button ion-button core-site-plugins-call-ws name="mod_certificate_view_certificate"
* [params]="{certificateid: <% certificate.id %>}" [preSets]="{getFromCache: 0, saveToCache: 0}" confirmMessage
* successMessage refreshOnSuccess="true">
* {{ 'addon.mod_certificate_coursecertificate.senddata' | translate }}
* {{ 'plugin.mod_certificate_coursecertificate.senddata' | translate }}
* </button>
*
* A button to send some data to the server using cache, without confirm, going back on success and using userid from otherdata:
*
* <button ion-button core-site-addons-call-ws name="mod_certificate_view_certificate"
* <button ion-button core-site-plugins-call-ws name="mod_certificate_view_certificate"
* [params]="{certificateid: <% certificate.id %>}" goBackOnSuccess="true" [useOtherData]="['userid']">
* {{ 'addon.mod_certificate_coursecertificate.senddata' | translate }}
* {{ 'plugin.mod_certificate_coursecertificate.senddata' | translate }}
* </button>
*/
@Directive({
selector: '[core-site-addons-call-ws]'
selector: '[core-site-plugins-call-ws]'
})
export class CoreSiteAddonsCallWSDirective extends CoreSiteAddonsCallWSOnClickBaseDirective {
export class CoreSitePluginsCallWSDirective extends CoreSitePluginsCallWSOnClickBaseDirective {
@Input() successMessage: string; // Message to show on success. If not supplied, no message. If empty, default message.
@Input() goBackOnSuccess: boolean | string; // Whether to go back if the WS call is successful.
@Input() refreshOnSuccess: boolean | string; // Whether to refresh the current view if the WS call is successful.
constructor(element: ElementRef, translate: TranslateService, domUtils: CoreDomUtilsProvider,
siteAddonsProvider: CoreSiteAddonsProvider, @Optional() parentContent: CoreSiteAddonsAddonContentComponent,
sitePluginsProvider: CoreSitePluginsProvider, @Optional() parentContent: CoreSitePluginsPluginContentComponent,
protected utils: CoreUtilsProvider, protected navCtrl: NavController) {
super(element, translate, domUtils, siteAddonsProvider, parentContent);
super(element, translate, domUtils, sitePluginsProvider, parentContent);
}
/**

View File

@ -13,24 +13,24 @@
// limitations under the License.
import { NgModule } from '@angular/core';
import { CoreSiteAddonsCallWSDirective } from './call-ws';
import { CoreSiteAddonsCallWSNewContentDirective } from './call-ws-new-content';
import { CoreSiteAddonsCallWSOnLoadDirective } from './call-ws-on-load';
import { CoreSiteAddonsNewContentDirective } from './new-content';
import { CoreSitePluginsCallWSDirective } from './call-ws';
import { CoreSitePluginsCallWSNewContentDirective } from './call-ws-new-content';
import { CoreSitePluginsCallWSOnLoadDirective } from './call-ws-on-load';
import { CoreSitePluginsNewContentDirective } from './new-content';
@NgModule({
declarations: [
CoreSiteAddonsCallWSDirective,
CoreSiteAddonsCallWSNewContentDirective,
CoreSiteAddonsCallWSOnLoadDirective,
CoreSiteAddonsNewContentDirective
CoreSitePluginsCallWSDirective,
CoreSitePluginsCallWSNewContentDirective,
CoreSitePluginsCallWSOnLoadDirective,
CoreSitePluginsNewContentDirective
],
imports: [],
exports: [
CoreSiteAddonsCallWSDirective,
CoreSiteAddonsCallWSNewContentDirective,
CoreSiteAddonsCallWSOnLoadDirective,
CoreSiteAddonsNewContentDirective
CoreSitePluginsCallWSDirective,
CoreSitePluginsCallWSNewContentDirective,
CoreSitePluginsCallWSOnLoadDirective,
CoreSitePluginsNewContentDirective
]
})
export class CoreSiteAddonsDirectivesModule {}
export class CoreSitePluginsDirectivesModule {}

View File

@ -16,47 +16,47 @@ import { Directive, Input, OnInit, ElementRef, Optional } from '@angular/core';
import { NavController } from 'ionic-angular';
import { CoreDomUtilsProvider } from '../../../providers/utils/dom';
import { CoreUtilsProvider } from '../../../providers/utils/utils';
import { CoreSiteAddonsProvider } from '../providers/siteaddons';
import { CoreSiteAddonsAddonContentComponent } from '../components/addon-content/addon-content';
import { CoreSitePluginsProvider } from '../providers/siteplugins';
import { CoreSitePluginsPluginContentComponent } from '../components/plugin-content/plugin-content';
/**
* Directive to display a new site addon content when clicked. This new content can be displayed in a new page or in the
* current page (only if the current page is already displaying a site addon content).
* Directive to display a new site plugin content when clicked. This new content can be displayed in a new page or in the
* current page (only if the current page is already displaying a site plugin content).
*
* Example usages:
*
* A button to go to a new content page:
*
* <button ion-button core-site-addons-new-content title="<% certificate.name %>" component="mod_certificate"
* <button ion-button core-site-plugins-new-content title="<% certificate.name %>" component="mod_certificate"
* method="mobile_issues_view" [args]="{cmid: <% cmid %>, courseid: <% courseid %>}">
* {{ 'addon.mod_certificate_coursecertificate.viewissued' | translate }}
* {{ 'plugin.mod_certificate_coursecertificate.viewissued' | translate }}
* </button>
*
* A button to load new content in current page using a param from otherdata:
*
* <button ion-button core-site-addons-new-content component="mod_certificate" method="mobile_issues_view"
* <button ion-button core-site-plugins-new-content component="mod_certificate" method="mobile_issues_view"
* [args]="{cmid: <% cmid %>, courseid: <% courseid %>}" samePage="true" [useOtherData]="['userid']">
* {{ 'addon.mod_certificate_coursecertificate.viewissued' | translate }}
* {{ 'plugin.mod_certificate_coursecertificate.viewissued' | translate }}
* </button>
*/
@Directive({
selector: '[core-site-addons-new-content]'
selector: '[core-site-plugins-new-content]'
})
export class CoreSiteAddonsNewContentDirective implements OnInit {
export class CoreSitePluginsNewContentDirective implements OnInit {
@Input() component: string; // The component of the new content.
@Input() method: string; // The method to get the new content.
@Input() args: any; // The params to get the new content.
@Input() title: string; // The title to display with the new content. Only if samePage=false.
@Input() samePage: boolean | string; // Whether to display the content in same page or open a new one. Defaults to new page.
@Input() useOtherData: any[]; // Whether to include other data in the args. @see CoreSiteAddonsProvider.loadOtherDataInArgs.
@Input() useOtherData: any[]; // Whether to include other data in the args. @see CoreSitePluginsProvider.loadOtherDataInArgs.
@Input() form: string; // ID or name to identify a form. The form will be obtained from document.forms.
// If supplied and form is found, the form data will be retrieved and sent to the new content.
protected element: HTMLElement;
constructor(element: ElementRef, protected utils: CoreUtilsProvider, @Optional() protected navCtrl: NavController,
@Optional() protected parentContent: CoreSiteAddonsAddonContentComponent, protected domUtils: CoreDomUtilsProvider,
protected siteAddonsProvider: CoreSiteAddonsProvider) {
@Optional() protected parentContent: CoreSitePluginsPluginContentComponent, protected domUtils: CoreDomUtilsProvider,
protected sitePluginsProvider: CoreSitePluginsProvider) {
this.element = element.nativeElement || element;
}
@ -71,7 +71,7 @@ export class CoreSiteAddonsNewContentDirective implements OnInit {
let args = this.args || {};
if (this.parentContent) {
args = this.siteAddonsProvider.loadOtherDataInArgs(this.args, this.parentContent.otherData, this.useOtherData);
args = this.sitePluginsProvider.loadOtherDataInArgs(this.args, this.parentContent.otherData, this.useOtherData);
}
if (this.form && document.forms[this.form]) {
@ -84,7 +84,7 @@ export class CoreSiteAddonsNewContentDirective implements OnInit {
this.parentContent.updateContent(this.component, this.method, args);
}
} else {
this.navCtrl.push('CoreSiteAddonsAddonPage', {
this.navCtrl.push('CoreSitePluginsPluginPage', {
title: this.title,
component: this.component,
method: this.method,

View File

@ -0,0 +1,15 @@
<ion-header>
<ion-navbar>
<ion-title>{{ title }}</ion-title>
<ion-buttons end>
<!-- If the site plugin defines some buttons using core-nav-buttons, they will be added here. -->
</ion-buttons>
</ion-navbar>
</ion-header>
<ion-content>
<ion-refresher [enabled]="content && content.content && content.content.dataLoaded" (ionRefresh)="refreshData($event)">
<ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
</ion-refresher>
<core-site-plugins-module-index [module]="module" [courseId]="courseId"></core-site-plugins-module-index>
</ion-content>

View File

@ -15,20 +15,20 @@
import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { TranslateModule } from '@ngx-translate/core';
import { CoreSiteAddonsModuleIndexPage } from './module-index';
import { CoreSiteAddonsComponentsModule } from '../../components/components.module';
import { CoreSitePluginsModuleIndexPage } from './module-index';
import { CoreSitePluginsComponentsModule } from '../../components/components.module';
/**
* Module to lazy load the page.
*/
@NgModule({
declarations: [
CoreSiteAddonsModuleIndexPage
CoreSitePluginsModuleIndexPage
],
imports: [
CoreSiteAddonsComponentsModule,
IonicPageModule.forChild(CoreSiteAddonsModuleIndexPage),
CoreSitePluginsComponentsModule,
IonicPageModule.forChild(CoreSitePluginsModuleIndexPage),
TranslateModule.forChild()
]
})
export class CoreSiteAddonsAddonPageModule {}
export class CoreSitePluginsModuleIndexPageModule {}

View File

@ -14,18 +14,18 @@
import { Component, ViewChild } from '@angular/core';
import { IonicPage, NavParams } from 'ionic-angular';
import { CoreSiteAddonsModuleIndexComponent } from '../../components/module-index/module-index';
import { CoreSitePluginsModuleIndexComponent } from '../../components/module-index/module-index';
/**
* Page to render the index page of a module site addon.
* Page to render the index page of a module site plugin.
*/
@IonicPage({ segment: 'core-site-addons-module-index-page' })
@IonicPage({ segment: 'core-site-plugins-module-index-page' })
@Component({
selector: 'page-core-site-addons-module-index',
selector: 'page-core-site-plugins-module-index',
templateUrl: 'module-index.html',
})
export class CoreSiteAddonsModuleIndexPage {
@ViewChild(CoreSiteAddonsModuleIndexComponent) content: CoreSiteAddonsModuleIndexComponent;
export class CoreSitePluginsModuleIndexPage {
@ViewChild(CoreSitePluginsModuleIndexComponent) content: CoreSitePluginsModuleIndexComponent;
title: string; // Page title.

View File

@ -3,7 +3,7 @@
<ion-title>{{ title }}</ion-title>
<ion-buttons end>
<!-- If the site addon defines some buttons using core-nav-buttons, they will be added here. -->
<!-- If the site plugin defines some buttons using core-nav-buttons, they will be added here. -->
</ion-buttons>
</ion-navbar>
</ion-header>
@ -11,5 +11,5 @@
<ion-refresher [enabled]="content && content.dataLoaded" (ionRefresh)="refreshData($event)">
<ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
</ion-refresher>
<core-site-addons-addon-content [component]="component" [method]="method" [args]="args" [bootstrapResult]="bootstrapResult"></core-site-addons-addon-content>
<core-site-plugins-plugin-content [component]="component" [method]="method" [args]="args" [bootstrapResult]="bootstrapResult"></core-site-plugins-plugin-content>
</ion-content>

View File

@ -15,20 +15,20 @@
import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { TranslateModule } from '@ngx-translate/core';
import { CoreSiteAddonsAddonPage } from './addon-page';
import { CoreSiteAddonsComponentsModule } from '../../components/components.module';
import { CoreSitePluginsPluginPage } from './plugin-page';
import { CoreSitePluginsComponentsModule } from '../../components/components.module';
/**
* Module to lazy load the page.
*/
@NgModule({
declarations: [
CoreSiteAddonsAddonPage
CoreSitePluginsPluginPage
],
imports: [
CoreSiteAddonsComponentsModule,
IonicPageModule.forChild(CoreSiteAddonsAddonPage),
CoreSitePluginsComponentsModule,
IonicPageModule.forChild(CoreSitePluginsPluginPage),
TranslateModule.forChild()
]
})
export class CoreSiteAddonsAddonPageModule {}
export class CoreSitePluginsPluginPageModule {}

View File

@ -14,18 +14,18 @@
import { Component, ViewChild } from '@angular/core';
import { IonicPage, NavParams } from 'ionic-angular';
import { CoreSiteAddonsAddonContentComponent } from '../../components/addon-content/addon-content';
import { CoreSitePluginsPluginContentComponent } from '../../components/plugin-content/plugin-content';
/**
* Page to render a site addon page.
* Page to render a site plugin page.
*/
@IonicPage({ segment: 'core-site-addons-addon-page' })
@IonicPage({ segment: 'core-site-plugins-plugin-page' })
@Component({
selector: 'page-core-site-addons-addon',
templateUrl: 'addon-page.html',
selector: 'page-core-site-plugins-plugin',
templateUrl: 'plugin-page.html',
})
export class CoreSiteAddonsAddonPage {
@ViewChild(CoreSiteAddonsAddonContentComponent) content: CoreSiteAddonsAddonContentComponent;
export class CoreSitePluginsPluginPage {
@ViewChild(CoreSitePluginsPluginContentComponent) content: CoreSitePluginsPluginContentComponent;
title: string; // Page title.

View File

@ -19,7 +19,7 @@ import { CoreLoggerProvider } from '../../../providers/logger';
import { CoreSite } from '../../../classes/site';
import { CoreSitesProvider } from '../../../providers/sites';
import { CoreUtilsProvider } from '../../../providers/utils/utils';
import { CoreSiteAddonsProvider } from './siteaddons';
import { CoreSitePluginsProvider } from './siteplugins';
import { CoreCompileProvider } from '../../compile/providers/compile';
// Delegates
@ -32,55 +32,55 @@ import { CoreUserDelegate } from '../../user/providers/user-delegate';
import { CoreUserProfileFieldDelegate } from '../../user/providers/user-profile-field-delegate';
// Handler classes.
import { CoreSiteAddonsCourseFormatHandler } from '../classes/course-format-handler';
import { CoreSiteAddonsCourseOptionHandler } from '../classes/course-option-handler';
import { CoreSiteAddonsModuleHandler } from '../classes/module-handler';
import { CoreSiteAddonsModulePrefetchHandler } from '../classes/module-prefetch-handler';
import { CoreSiteAddonsMainMenuHandler } from '../classes/main-menu-handler';
import { CoreSiteAddonsUserProfileHandler } from '../classes/user-handler';
import { CoreSiteAddonsUserProfileFieldHandler } from '../classes/user-profile-field-handler';
import { CoreSitePluginsCourseFormatHandler } from '../classes/course-format-handler';
import { CoreSitePluginsCourseOptionHandler } from '../classes/course-option-handler';
import { CoreSitePluginsModuleHandler } from '../classes/module-handler';
import { CoreSitePluginsModulePrefetchHandler } from '../classes/module-prefetch-handler';
import { CoreSitePluginsMainMenuHandler } from '../classes/main-menu-handler';
import { CoreSitePluginsUserProfileHandler } from '../classes/user-handler';
import { CoreSitePluginsUserProfileFieldHandler } from '../classes/user-profile-field-handler';
/**
* Helper service to provide functionalities regarding site addons. It basically has the features to load and register site
* addons.
* Helper service to provide functionalities regarding site plugins. It basically has the features to load and register site
* plugin.
*
* This code is split from CoreSiteAddonsProvider to prevent circular dependencies.
* This code is split from CoreSitePluginsProvider to prevent circular dependencies.
*
* @todo: Support ViewChild and similar in site addons. Possible solution: make components and directives inject the instance
* @todo: Support ViewChild and similar in site plugins. Possible solution: make components and directives inject the instance
* inside the host DOM element?
*/
@Injectable()
export class CoreSiteAddonsHelperProvider {
export class CoreSitePluginsHelperProvider {
protected logger;
protected hasSiteAddonsLoaded = false;
protected hasSitePluginsLoaded = false;
constructor(logger: CoreLoggerProvider, private sitesProvider: CoreSitesProvider, private injector: Injector,
private mainMenuDelegate: CoreMainMenuDelegate, private moduleDelegate: CoreCourseModuleDelegate,
private userDelegate: CoreUserDelegate, private langProvider: CoreLangProvider,
private siteAddonsProvider: CoreSiteAddonsProvider, private prefetchDelegate: CoreCourseModulePrefetchDelegate,
private sitePluginsProvider: CoreSitePluginsProvider, private prefetchDelegate: CoreCourseModulePrefetchDelegate,
private compileProvider: CoreCompileProvider, private utils: CoreUtilsProvider,
private courseOptionsDelegate: CoreCourseOptionsDelegate, eventsProvider: CoreEventsProvider,
private courseFormatDelegate: CoreCourseFormatDelegate, private profileFieldDelegate: CoreUserProfileFieldDelegate) {
this.logger = logger.getInstance('CoreSiteAddonsHelperProvider');
this.logger = logger.getInstance('CoreSitePluginsHelperProvider');
// Fetch the addons on login.
// Fetch the plugins on login.
eventsProvider.on(CoreEventsProvider.LOGIN, () => {
const siteId = this.sitesProvider.getCurrentSiteId();
this.fetchSiteAddons(siteId).then((addons) => {
// Addons fetched, check that site hasn't changed.
if (siteId == this.sitesProvider.getCurrentSiteId() && addons.length) {
// Site is still the same. Load the addons and trigger the event.
this.loadSiteAddons(addons).then(() => {
eventsProvider.trigger(CoreEventsProvider.SITE_ADDONS_LOADED, {}, siteId);
this.fetchSitePlugins(siteId).then((plugins) => {
// Plugins fetched, check that site hasn't changed.
if (siteId == this.sitesProvider.getCurrentSiteId() && plugins.length) {
// Site is still the same. Load the plugins and trigger the event.
this.loadSitePlugins(plugins).then(() => {
eventsProvider.trigger(CoreEventsProvider.SITE_PLUGINS_LOADED, {}, siteId);
});
}
});
});
// Unload addons on logout if any.
// Unload plugins on logout if any.
eventsProvider.on(CoreEventsProvider.LOGOUT, () => {
if (this.hasSiteAddonsLoaded) {
if (this.hasSitePluginsLoaded) {
// Temporary fix. Reload the page to unload all plugins.
window.location.reload();
}
@ -90,32 +90,32 @@ export class CoreSiteAddonsHelperProvider {
/**
* Bootstrap a handler if it has some bootstrap method.
*
* @param {any} addon Data of the addon.
* @param {any} plugin Data of the plugin.
* @param {any} handlerSchema Data about the handler.
* @return {Promise<any>} Promise resolved when done. It returns the results of the getContent call and the data returned by
* the bootstrap JS (if any).
*/
protected bootstrapHandler(addon: any, handlerSchema: any): Promise<any> {
protected bootstrapHandler(plugin: any, handlerSchema: any): Promise<any> {
if (!handlerSchema.bootstrap) {
return Promise.resolve({});
}
return this.executeMethodAndJS(addon, handlerSchema.bootstrap);
return this.executeMethodAndJS(plugin, handlerSchema.bootstrap);
}
/**
* Execute a get_content method and run its javascript (if any).
*
* @param {any} addon Data of the addon.
* @param {any} plugin Data of the plugin.
* @param {string} method The method to call.
* @return {Promise<any>} Promise resolved when done. It returns the results of the getContent call and the data returned by
* the JS (if any).
*/
protected executeMethodAndJS(addon: any, method: string): Promise<any> {
protected executeMethodAndJS(plugin: any, method: string): Promise<any> {
const siteId = this.sitesProvider.getCurrentSiteId(),
preSets = {getFromCache: false}; // Try to ignore cache.
return this.siteAddonsProvider.getContent(addon.component, method, {}, preSets).then((result) => {
return this.sitePluginsProvider.getContent(plugin.component, method, {}, preSets).then((result) => {
if (!result.javascript || this.sitesProvider.getCurrentSiteId() != siteId) {
// No javascript or site has changed, stop.
return result;
@ -126,7 +126,7 @@ export class CoreSiteAddonsHelperProvider {
this.compileProvider.injectLibraries(instance);
// Add some data of the WS call result.
const jsData = this.siteAddonsProvider.createDataForJS(result);
const jsData = this.sitePluginsProvider.createDataForJS(result);
for (const name in jsData) {
instance[name] = jsData[name];
}
@ -139,30 +139,30 @@ export class CoreSiteAddonsHelperProvider {
}
/**
* Fetch site addons.
* Fetch site plugins.
*
* @param {string} [siteId] Site ID. If not defined, current site.
* @return {Promise<any[]>} Promise resolved when done. Returns the list of addons to load.
* @return {Promise<any[]>} Promise resolved when done. Returns the list of plugins to load.
*/
fetchSiteAddons(siteId?: string): Promise<any[]> {
const addons = [];
fetchSitePlugins(siteId?: string): Promise<any[]> {
const plugins = [];
return this.sitesProvider.getSite(siteId).then((site) => {
if (!this.siteAddonsProvider.isGetContentAvailable(site)) {
// Cannot load site addons, so there's no point to fetch them.
return addons;
if (!this.sitePluginsProvider.isGetContentAvailable(site)) {
// Cannot load site plugins, so there's no point to fetch them.
return plugins;
}
// Get the list of addons. Try not to use cache.
// Get the list of plugins. Try not to use cache.
return site.read('tool_mobile_get_plugins_supporting_mobile', {}, { getFromCache: false }).then((data) => {
data.plugins.forEach((addon: any) => {
// Check if it's a site addon and it's enabled.
if (this.isSiteAddonEnabled(addon, site)) {
addons.push(addon);
data.plugins.forEach((plugin: any) => {
// Check if it's a site plugin and it's enabled.
if (this.isSitePluginEnabled(plugin, site)) {
plugins.push(plugin);
}
});
return addons;
return plugins;
});
});
}
@ -175,7 +175,7 @@ export class CoreSiteAddonsHelperProvider {
*/
protected getHandlerPrefixForStrings(handlerName: string): string {
if (handlerName) {
return 'addon.' + handlerName + '.';
return 'plugin.' + handlerName + '.';
}
return '';
@ -193,23 +193,23 @@ export class CoreSiteAddonsHelperProvider {
}
/**
* Check if a certain addon is a site addon and it's enabled in a certain site.
* Check if a certain plugin is a site plugin and it's enabled in a certain site.
*
* @param {any} addon Data of the addon.
* @param {any} plugin Data of the plugin.
* @param {CoreSite} site Site affected.
* @return {boolean} Whether it's a site addon and it's enabled.
* @return {boolean} Whether it's a site plugin and it's enabled.
*/
isSiteAddonEnabled(addon: any, site: CoreSite): boolean {
if (!site.isFeatureDisabled('siteAddOn_' + addon.component + '_' + addon.addon) && addon.handlers) {
// Site addon not disabled. Check if it has handlers.
isSitePluginEnabled(plugin: any, site: CoreSite): boolean {
if (!site.isFeatureDisabled('sitePlugin_' + plugin.component + '_' + plugin.addon) && plugin.handlers) {
// Site plugin not disabled. Check if it has handlers.
try {
if (!addon.parsedHandlers) {
addon.parsedHandlers = JSON.parse(addon.handlers);
if (!plugin.parsedHandlers) {
plugin.parsedHandlers = JSON.parse(plugin.handlers);
}
return !!(addon.parsedHandlers && Object.keys(addon.parsedHandlers).length);
return !!(plugin.parsedHandlers && Object.keys(plugin.parsedHandlers).length);
} catch (ex) {
this.logger.warn('Error parsing site addon', ex);
this.logger.warn('Error parsing site plugin', ex);
}
}
@ -219,105 +219,105 @@ export class CoreSiteAddonsHelperProvider {
/**
* Load the lang strings for a handler.
*
* @param {any} addon Data of the addon.
* @param {string} handlerName Name of the handler in the addon.
* @param {any} plugin Data of the plugin.
* @param {string} handlerName Name of the handler in the plugin.
* @param {any} handlerSchema Data about the handler.
*/
loadHandlerLangStrings(addon: any, handlerName: string, handlerSchema: any): void {
loadHandlerLangStrings(plugin: any, handlerName: string, handlerSchema: any): void {
if (!handlerSchema.lang) {
return;
}
for (const lang in handlerSchema.lang) {
const prefix = this.getHandlerPrefixForStrings(this.siteAddonsProvider.getHandlerUniqueName(addon, handlerName));
const prefix = this.getHandlerPrefixForStrings(this.sitePluginsProvider.getHandlerUniqueName(plugin, handlerName));
this.langProvider.addSiteAddonsStrings(lang, handlerSchema.lang[lang], prefix);
this.langProvider.addSitePluginsStrings(lang, handlerSchema.lang[lang], prefix);
}
}
/**
* Load a site addon.
* Load a site plugin.
*
* @param {any} addon Data of the addon.
* @param {any} plugin Data of the plugin.
* @return {Promise<any>} Promise resolved when loaded.
*/
loadSiteAddon(addon: any): Promise<any> {
loadSitePlugin(plugin: any): Promise<any> {
const promises = [];
this.logger.debug('Load site addon:', addon);
this.logger.debug('Load site plugin:', plugin);
try {
if (!addon.parsedHandlers) {
addon.parsedHandlers = JSON.parse(addon.handlers);
if (!plugin.parsedHandlers) {
plugin.parsedHandlers = JSON.parse(plugin.handlers);
}
this.hasSiteAddonsLoaded = true;
this.hasSitePluginsLoaded = true;
// Register all the handlers.
for (const name in addon.parsedHandlers) {
promises.push(this.registerHandler(addon, name, addon.parsedHandlers[name]));
for (const name in plugin.parsedHandlers) {
promises.push(this.registerHandler(plugin, name, plugin.parsedHandlers[name]));
}
} catch (ex) {
this.logger.warn('Error parsing site addon', ex);
this.logger.warn('Error parsing site plugin', ex);
}
return this.utils.allPromises(promises);
}
/**
* Load site addons.
* Load site plugins.
*
* @param {any[]} addons The addons to load.
* @param {any[]} plugins The plugins to load.
* @return {Promise<any>} Promise resolved when loaded.
*/
loadSiteAddons(addons: any[]): Promise<any> {
loadSitePlugins(plugins: any[]): Promise<any> {
const promises = [];
addons.forEach((addon) => {
promises.push(this.loadSiteAddon(addon));
plugins.forEach((plugin) => {
promises.push(this.loadSitePlugin(plugin));
});
return this.utils.allPromises(promises);
}
/**
* Register a site addon handler in the right delegate.
* Register a site plugin handler in the right delegate.
*
* @param {any} addon Data of the addon.
* @param {string} handlerName Name of the handler in the addon.
* @param {any} plugin Data of the plugin.
* @param {string} handlerName Name of the handler in the plugin.
* @param {any} handlerSchema Data about the handler.
* @return {Promise<any>} Promise resolved when done.
*/
registerHandler(addon: any, handlerName: string, handlerSchema: any): Promise<any> {
this.loadHandlerLangStrings(addon, handlerName, handlerSchema);
registerHandler(plugin: any, handlerName: string, handlerSchema: any): Promise<any> {
this.loadHandlerLangStrings(plugin, handlerName, handlerSchema);
// Wait for the bootstrap JS to be executed.
return this.bootstrapHandler(addon, handlerSchema).then((result) => {
return this.bootstrapHandler(plugin, handlerSchema).then((result) => {
let promise;
switch (handlerSchema.delegate) {
case 'CoreMainMenuDelegate':
promise = Promise.resolve(this.registerMainMenuHandler(addon, handlerName, handlerSchema, result));
promise = Promise.resolve(this.registerMainMenuHandler(plugin, handlerName, handlerSchema, result));
break;
case 'CoreCourseModuleDelegate':
promise = Promise.resolve(this.registerModuleHandler(addon, handlerName, handlerSchema, result));
promise = Promise.resolve(this.registerModuleHandler(plugin, handlerName, handlerSchema, result));
break;
case 'CoreUserDelegate':
promise = Promise.resolve(this.registerUserProfileHandler(addon, handlerName, handlerSchema, result));
promise = Promise.resolve(this.registerUserProfileHandler(plugin, handlerName, handlerSchema, result));
break;
case 'CoreCourseOptionsDelegate':
promise = Promise.resolve(this.registerCourseOptionHandler(addon, handlerName, handlerSchema, result));
promise = Promise.resolve(this.registerCourseOptionHandler(plugin, handlerName, handlerSchema, result));
break;
case 'CoreCourseFormatDelegate':
promise = Promise.resolve(this.registerCourseFormatHandler(addon, handlerName, handlerSchema, result));
promise = Promise.resolve(this.registerCourseFormatHandler(plugin, handlerName, handlerSchema, result));
break;
case 'CoreUserProfileFieldDelegate':
promise = Promise.resolve(this.registerUserProfileFieldHandler(addon, handlerName, handlerSchema, result));
promise = Promise.resolve(this.registerUserProfileFieldHandler(plugin, handlerName, handlerSchema, result));
break;
default:
@ -328,8 +328,8 @@ export class CoreSiteAddonsHelperProvider {
return promise.then((uniqueName) => {
if (uniqueName) {
// Store the handler data.
this.siteAddonsProvider.setSiteAddonHandler(uniqueName, {
addon: addon,
this.sitePluginsProvider.setSitePluginHandler(uniqueName, {
plugin: plugin,
handlerName: handlerName,
handlerSchema: handlerSchema,
bootstrapResult: result
@ -342,169 +342,169 @@ export class CoreSiteAddonsHelperProvider {
}
/**
* Given a handler in an addon, register it in the course format delegate.
* Given a handler in a plugin, register it in the course format delegate.
*
* @param {any} addon Data of the addon.
* @param {string} handlerName Name of the handler in the addon.
* @param {any} plugin Data of the plugin.
* @param {string} handlerName Name of the handler in the plugin.
* @param {any} handlerSchema Data about the handler.
* @param {any} bootstrapResult Result of the bootstrap WS call.
* @return {string} A string to identify the handler.
*/
protected registerCourseFormatHandler(addon: any, handlerName: string, handlerSchema: any, bootstrapResult: any): string {
this.logger.debug('Register site addon in course format delegate:', addon, handlerSchema, bootstrapResult);
protected registerCourseFormatHandler(plugin: any, handlerName: string, handlerSchema: any, bootstrapResult: any): string {
this.logger.debug('Register site plugin in course format delegate:', plugin, handlerSchema, bootstrapResult);
// Create and register the handler.
const formatName = addon.component.replace('format_', '');
this.courseFormatDelegate.registerHandler(new CoreSiteAddonsCourseFormatHandler(formatName, handlerSchema));
const formatName = plugin.component.replace('format_', '');
this.courseFormatDelegate.registerHandler(new CoreSitePluginsCourseFormatHandler(formatName, handlerSchema));
return formatName;
}
/**
* Given a handler in an addon, register it in the course options delegate.
* Given a handler in an plugin, register it in the course options delegate.
*
* @param {any} addon Data of the addon.
* @param {string} handlerName Name of the handler in the addon.
* @param {any} plugin Data of the plugin.
* @param {string} handlerName Name of the handler in the plugin.
* @param {any} handlerSchema Data about the handler.
* @param {any} bootstrapResult Result of the bootstrap WS call.
* @return {string} A string to identify the handler.
*/
protected registerCourseOptionHandler(addon: any, handlerName: string, handlerSchema: any, bootstrapResult: any): string {
protected registerCourseOptionHandler(plugin: any, handlerName: string, handlerSchema: any, bootstrapResult: any): string {
if (!handlerSchema.displaydata) {
// Required data not provided, stop.
this.logger.warn('Ignore site addon because it doesn\'t provide displaydata', addon, handlerSchema);
this.logger.warn('Ignore site plugin because it doesn\'t provide displaydata', plugin, handlerSchema);
return;
}
this.logger.debug('Register site addon in course option delegate:', addon, handlerSchema, bootstrapResult);
this.logger.debug('Register site plugin in course option delegate:', plugin, handlerSchema, bootstrapResult);
// Create and register the handler.
const uniqueName = this.siteAddonsProvider.getHandlerUniqueName(addon, handlerName),
const uniqueName = this.sitePluginsProvider.getHandlerUniqueName(plugin, handlerName),
prefixedTitle = this.getHandlerPrefixedString(uniqueName, handlerSchema.displaydata.title);
this.courseOptionsDelegate.registerHandler(new CoreSiteAddonsCourseOptionHandler(uniqueName, prefixedTitle, addon,
handlerSchema, bootstrapResult, this.siteAddonsProvider));
this.courseOptionsDelegate.registerHandler(new CoreSitePluginsCourseOptionHandler(uniqueName, prefixedTitle, plugin,
handlerSchema, bootstrapResult, this.sitePluginsProvider));
return uniqueName;
}
/**
* Given a handler in an addon, register it in the main menu delegate.
* Given a handler in an plugin, register it in the main menu delegate.
*
* @param {any} addon Data of the addon.
* @param {string} handlerName Name of the handler in the addon.
* @param {any} plugin Data of the plugin.
* @param {string} handlerName Name of the handler in the plugin.
* @param {any} handlerSchema Data about the handler.
* @param {any} bootstrapResult Result of the bootstrap WS call.
* @return {string} A string to identify the handler.
*/
protected registerMainMenuHandler(addon: any, handlerName: string, handlerSchema: any, bootstrapResult: any): string {
protected registerMainMenuHandler(plugin: any, handlerName: string, handlerSchema: any, bootstrapResult: any): string {
if (!handlerSchema.displaydata) {
// Required data not provided, stop.
this.logger.warn('Ignore site addon because it doesn\'t provide displaydata', addon, handlerSchema);
this.logger.warn('Ignore site plugin because it doesn\'t provide displaydata', plugin, handlerSchema);
return;
}
this.logger.debug('Register site addon in main menu delegate:', addon, handlerSchema, bootstrapResult);
this.logger.debug('Register site plugin in main menu delegate:', plugin, handlerSchema, bootstrapResult);
// Create and register the handler.
const uniqueName = this.siteAddonsProvider.getHandlerUniqueName(addon, handlerName),
const uniqueName = this.sitePluginsProvider.getHandlerUniqueName(plugin, handlerName),
prefixedTitle = this.getHandlerPrefixedString(uniqueName, handlerSchema.displaydata.title);
this.mainMenuDelegate.registerHandler(
new CoreSiteAddonsMainMenuHandler(uniqueName, prefixedTitle, addon, handlerSchema, bootstrapResult));
new CoreSitePluginsMainMenuHandler(uniqueName, prefixedTitle, plugin, handlerSchema, bootstrapResult));
return uniqueName;
}
/**
* Given a handler in an addon, register it in the module delegate.
* Given a handler in an plugin, register it in the module delegate.
*
* @param {any} addon Data of the addon.
* @param {string} handlerName Name of the handler in the addon.
* @param {any} plugin Data of the plugin.
* @param {string} handlerName Name of the handler in the plugin.
* @param {any} handlerSchema Data about the handler.
* @param {any} bootstrapResult Result of the bootstrap WS call.
* @return {string} A string to identify the handler.
*/
protected registerModuleHandler(addon: any, handlerName: string, handlerSchema: any, bootstrapResult: any): string {
protected registerModuleHandler(plugin: any, handlerName: string, handlerSchema: any, bootstrapResult: any): string {
if (!handlerSchema.displaydata) {
// Required data not provided, stop.
this.logger.warn('Ignore site addon because it doesn\'t provide displaydata', addon, handlerSchema);
this.logger.warn('Ignore site plugin because it doesn\'t provide displaydata', plugin, handlerSchema);
return;
}
this.logger.debug('Register site addon in module delegate:', addon, handlerSchema, bootstrapResult);
this.logger.debug('Register site plugin in module delegate:', plugin, handlerSchema, bootstrapResult);
// Create and register the handler.
const modName = addon.component.replace('mod_', '');
const modName = plugin.component.replace('mod_', '');
this.moduleDelegate.registerHandler(new CoreSiteAddonsModuleHandler(modName, handlerSchema));
this.moduleDelegate.registerHandler(new CoreSitePluginsModuleHandler(modName, handlerSchema));
if (handlerSchema.offlinefunctions && Object.keys(handlerSchema.offlinefunctions).length) {
// Register the prefetch handler.
this.prefetchDelegate.registerHandler(new CoreSiteAddonsModulePrefetchHandler(
this.injector, this.siteAddonsProvider, addon.component, modName, handlerSchema));
this.prefetchDelegate.registerHandler(new CoreSitePluginsModulePrefetchHandler(
this.injector, this.sitePluginsProvider, plugin.component, modName, handlerSchema));
}
return modName;
}
/**
* Given a handler in an addon, register it in the user profile delegate.
* Given a handler in an plugin, register it in the user profile delegate.
*
* @param {any} addon Data of the addon.
* @param {string} handlerName Name of the handler in the addon.
* @param {any} plugin Data of the plugin.
* @param {string} handlerName Name of the handler in the plugin.
* @param {any} handlerSchema Data about the handler.
* @param {any} bootstrapResult Result of the bootstrap WS call.
* @return {string} A string to identify the handler.
*/
protected registerUserProfileHandler(addon: any, handlerName: string, handlerSchema: any, bootstrapResult: any): string {
protected registerUserProfileHandler(plugin: any, handlerName: string, handlerSchema: any, bootstrapResult: any): string {
if (!handlerSchema.displaydata) {
// Required data not provided, stop.
this.logger.warn('Ignore site addon because it doesn\'t provide displaydata', addon, handlerSchema);
this.logger.warn('Ignore site plugin because it doesn\'t provide displaydata', plugin, handlerSchema);
return;
}
this.logger.debug('Register site addon in user profile delegate:', addon, handlerSchema, bootstrapResult);
this.logger.debug('Register site plugin in user profile delegate:', plugin, handlerSchema, bootstrapResult);
// Create and register the handler.
const uniqueName = this.siteAddonsProvider.getHandlerUniqueName(addon, handlerName),
const uniqueName = this.sitePluginsProvider.getHandlerUniqueName(plugin, handlerName),
prefixedTitle = this.getHandlerPrefixedString(uniqueName, handlerSchema.displaydata.title);
this.userDelegate.registerHandler(new CoreSiteAddonsUserProfileHandler(uniqueName, prefixedTitle, addon, handlerSchema,
bootstrapResult, this.siteAddonsProvider));
this.userDelegate.registerHandler(new CoreSitePluginsUserProfileHandler(uniqueName, prefixedTitle, plugin, handlerSchema,
bootstrapResult, this.sitePluginsProvider));
return uniqueName;
}
/**
* Given a handler in an addon, register it in the user profile field delegate.
* Given a handler in an plugin, register it in the user profile field delegate.
*
* @param {any} addon Data of the addon.
* @param {string} handlerName Name of the handler in the addon.
* @param {any} plugin Data of the plugin.
* @param {string} handlerName Name of the handler in the plugin.
* @param {any} handlerSchema Data about the handler.
* @param {any} bootstrapResult Result of the bootstrap WS call.
* @return {string|Promise<string>} A string (or a promise resolved with a string) to identify the handler.
*/
protected registerUserProfileFieldHandler(addon: any, handlerName: string, handlerSchema: any, bootstrapResult: any)
protected registerUserProfileFieldHandler(plugin: any, handlerName: string, handlerSchema: any, bootstrapResult: any)
: string | Promise<string> {
if (!handlerSchema.method) {
// Required data not provided, stop.
this.logger.warn('Ignore site addon because it doesn\'t provide method', addon, handlerSchema);
this.logger.warn('Ignore site plugin because it doesn\'t provide method', plugin, handlerSchema);
return;
}
this.logger.debug('Register site addon in user profile field delegate:', addon, handlerSchema, bootstrapResult);
this.logger.debug('Register site plugin in user profile field delegate:', plugin, handlerSchema, bootstrapResult);
// Execute the main method and its JS. The template returned will be used in the profile field component.
return this.executeMethodAndJS(addon, handlerSchema.method).then((result) => {
return this.executeMethodAndJS(plugin, handlerSchema.method).then((result) => {
// Create and register the handler.
const fieldType = addon.component.replace('profilefield_', ''),
fieldHandler = new CoreSiteAddonsUserProfileFieldHandler(fieldType);
const fieldType = plugin.component.replace('profilefield_', ''),
fieldHandler = new CoreSitePluginsUserProfileFieldHandler(fieldType);
// Store in handlerSchema some data required by the component.
handlerSchema.methodTemplates = result.templates;

View File

@ -25,14 +25,14 @@ import { CoreConfigConstants } from '../../../configconstants';
import { CoreCoursesProvider } from '../../courses/providers/courses';
/**
* Handler of a site addon.
* Handler of a site plugin.
*/
export interface CoreSiteAddonsHandler {
export interface CoreSitePluginsHandler {
/**
* The site addon data.
* The site plugin data.
* @type {any}
*/
addon: any;
plugin: any;
/**
* Name of the handler.
@ -54,14 +54,14 @@ export interface CoreSiteAddonsHandler {
}
/**
* Service to provide functionalities regarding site addons.
* Service to provide functionalities regarding site plugins.
*/
@Injectable()
export class CoreSiteAddonsProvider {
protected ROOT_CACHE_KEY = 'CoreSiteAddons:';
export class CoreSitePluginsProvider {
protected ROOT_CACHE_KEY = 'CoreSitePlugins:';
protected logger;
protected siteAddons: {[name: string]: CoreSiteAddonsHandler} = {}; // Site addons registered.
protected sitePlugins: {[name: string]: CoreSitePluginsHandler} = {}; // Site plugins registered.
constructor(logger: CoreLoggerProvider, private sitesProvider: CoreSitesProvider, private utils: CoreUtilsProvider,
private langProvider: CoreLangProvider, private appProvider: CoreAppProvider, private platform: Platform,
@ -118,7 +118,7 @@ export class CoreSiteAddonsProvider {
}
/**
* Call a WS for a site addon.
* Call a WS for a site plugin.
*
* @param {string} method WS method to use.
* @param {any} data Data to send to the WS.
@ -185,7 +185,7 @@ export class CoreSiteAddonsProvider {
}
/**
* Get a certain content for a site addon.
* Get a certain content for a site plugin.
*
* @param {string} component Component where the class is. E.g. mod_assign.
* @param {string} method Method to execute in the class.
@ -265,24 +265,24 @@ export class CoreSiteAddonsProvider {
}
/**
* Get the unique name of a handler (addon + handler).
* Get the unique name of a handler (plugin + handler).
*
* @param {any} addon Data of the addon.
* @param {string} handlerName Name of the handler inside the addon.
* @param {any} plugin Data of the plugin.
* @param {string} handlerName Name of the handler inside the plugin.
* @return {string} Unique name.
*/
getHandlerUniqueName(addon: any, handlerName: string): string {
return addon.addon + '_' + handlerName;
getHandlerUniqueName(plugin: any, handlerName: string): string {
return plugin.addon + '_' + handlerName;
}
/**
* Get a site addon handler.
* Get a site plugin handler.
*
* @param {string} name Unique name of the handler.
* @return {CoreSiteAddonsHandler} Handler.
* @return {CoreSitePluginsHandler} Handler.
*/
getSiteAddonHandler(name: string): CoreSiteAddonsHandler {
return this.siteAddons[name];
getSitePluginHandler(name: string): CoreSitePluginsHandler {
return this.sitePlugins[name];
}
/**
@ -426,7 +426,7 @@ export class CoreSiteAddonsProvider {
}
/**
* Prefetch offline functions for a site addon handler.
* Prefetch offline functions for a site plugin handler.
*
* @param {string} component The component of the handler.
* @param {any} args Params to send to the get_content calls.
@ -491,12 +491,12 @@ export class CoreSiteAddonsProvider {
}
/**
* Store a site addon handler.
* Store a site plugin handler.
*
* @param {string} name A unique name to identify the handler.
* @param {CoreSiteAddonsHandler} handler Handler to set.
* @param {CoreSitePluginsHandler} handler Handler to set.
*/
setSiteAddonHandler(name: string, handler: CoreSiteAddonsHandler): void {
this.siteAddons[name] = handler;
setSitePluginHandler(name: string, handler: CoreSitePluginsHandler): void {
this.sitePlugins[name] = handler;
}
}

View File

@ -13,26 +13,26 @@
// limitations under the License.
import { NgModule } from '@angular/core';
import { CoreSiteAddonsProvider } from './providers/siteaddons';
import { CoreSiteAddonsHelperProvider } from './providers/helper';
import { CoreSiteAddonsComponentsModule } from './components/components.module';
import { CoreSitePluginsProvider } from './providers/siteplugins';
import { CoreSitePluginsHelperProvider } from './providers/helper';
import { CoreSitePluginsComponentsModule } from './components/components.module';
// List of providers.
export const CORE_SITEADDONS_PROVIDERS = [
CoreSiteAddonsProvider,
CoreSiteAddonsHelperProvider
export const CORE_SITEPLUGINS_PROVIDERS = [
CoreSitePluginsProvider,
CoreSitePluginsHelperProvider
];
@NgModule({
declarations: [
],
imports: [
CoreSiteAddonsComponentsModule
CoreSitePluginsComponentsModule
],
providers: CORE_SITEADDONS_PROVIDERS
providers: CORE_SITEPLUGINS_PROVIDERS
})
export class CoreSiteAddonsModule {
constructor(helper: CoreSiteAddonsHelperProvider) {
export class CoreSitePluginsModule {
constructor(helper: CoreSitePluginsHelperProvider) {
// Inject the helper even if it isn't used so it's instantiated.
}
}

View File

@ -47,7 +47,7 @@ export class CoreUserParticipantsLinkHandler extends CoreContentLinksHandlerBase
return [{
action: (siteId, navCtrl?): void => {
// Always use redirect to make it the new history root (to avoid "loops" in history).
this.loginHelper.redirect('AddonParticipantsListPage', {courseId: courseId}, siteId);
this.loginHelper.redirect('CoreUserParticipantsPage', {courseId: courseId}, siteId);
}
}];
}

View File

@ -310,7 +310,7 @@ export class CoreUserProvider {
}
/**
* Returns whether or not the participants addon is enabled for a certain course.
* Returns whether or not participants is enabled for a certain course.
*
* @param {number} courseId Course ID.
* @param {string} [siteId] Site Id. If not defined, use current site.

View File

@ -47,7 +47,7 @@ export class CoreEventsProvider {
static PACKAGE_STATUS_CHANGED = 'package_status_changed';
static COURSE_STATUS_CHANGED = 'course_status_changed';
static SECTION_STATUS_CHANGED = 'section_status_changed';
static SITE_ADDONS_LOADED = 'site_addons_loaded';
static SITE_PLUGINS_LOADED = 'site_plugins_loaded';
static LOGIN_SITE_CHECKED = 'login_site_checked';
static LOGIN_SITE_UNCHECKED = 'login_site_unchecked';
static IAB_LOAD_START = 'inappbrowser_load_start';

View File

@ -161,7 +161,7 @@ export class CoreInitDelegate {
*
* An init process should never change state or prompt user interaction.
*
* This delegate cannot be used in remote addons.
* This delegate cannot be used by site plugins.
*
* @param {CoreInitHandler} instance The instance of the handler.
*/

View File

@ -30,7 +30,7 @@ export class CoreLangProvider {
protected currentLanguage: string; // Save current language in a variable to speed up the get function.
protected customStrings = {}; // Strings defined using the admin tool.
protected customStringsRaw: string;
protected siteAddonsStrings = {}; // Strings defined by site addons.
protected sitePluginsStrings = {}; // Strings defined by site plugins.
constructor(private translate: TranslateService, private configProvider: CoreConfigProvider, platform: Platform,
private globalization: Globalization) {
@ -47,16 +47,16 @@ export class CoreLangProvider {
}
/**
* Add a set of site addons strings for a certain language.
* Add a set of site plugins strings for a certain language.
*
* @param {string} lang The language where to add the strings.
* @param {any} strings Object with the strings to add.
* @param {string} [prefix] A prefix to add to all keys.
*/
addSiteAddonsStrings(lang: string, strings: any, prefix?: string): void {
addSitePluginsStrings(lang: string, strings: any, prefix?: string): void {
// Initialize structures if they don't exist.
if (!this.siteAddonsStrings[lang]) {
this.siteAddonsStrings[lang] = {};
if (!this.sitePluginsStrings[lang]) {
this.sitePluginsStrings[lang] = {};
}
if (!this.translate.translations[lang]) {
this.translate.translations[lang] = {};
@ -71,15 +71,15 @@ export class CoreLangProvider {
continue;
}
if (!this.siteAddonsStrings[lang][prefixedKey]) {
// It's a new site addon string. Store the original value.
this.siteAddonsStrings[lang][prefixedKey] = {
if (!this.sitePluginsStrings[lang][prefixedKey]) {
// It's a new site plugin string. Store the original value.
this.sitePluginsStrings[lang][prefixedKey] = {
original: this.translate.translations[lang][prefixedKey],
value: value
};
} else {
// Site addon string already defined. Store the new value.
this.siteAddonsStrings[lang][prefixedKey].value = value;
// Site plugin string already defined. Store the new value.
this.sitePluginsStrings[lang][prefixedKey].value = value;
}
// Store the string in the translations table.
@ -115,11 +115,11 @@ export class CoreLangProvider {
}
/**
* Clear current site addons strings.
* Clear current site plugins strings.
*/
clearSiteAddonsStrings(): void {
this.unloadStrings(this.siteAddonsStrings);
this.siteAddonsStrings = {};
clearSitePluginsStrings(): void {
this.unloadStrings(this.sitePluginsStrings);
this.sitePluginsStrings = {};
}
/**
@ -132,12 +132,12 @@ export class CoreLangProvider {
}
/**
* Get all current site addons strings.
* Get all current site plugins strings.
*
* @return {any} Site addons strings.
* @return {any} Site plugins strings.
*/
getAllSiteAddonsStrings(): any {
return this.siteAddonsStrings;
getAllSitePluginsStrings(): any {
return this.sitePluginsStrings;
}
/**
@ -235,7 +235,7 @@ export class CoreLangProvider {
}
/**
* Unload custom or site addon strings, removing the to the translations table.
* Unload custom or site plugin strings, removing them from the translations table.
*
* @param {any} strings Strings to unload.
*/