本文整理汇总了TypeScript中@providers/sites.CoreSitesProvider.getCurrentSite方法的典型用法代码示例。如果您正苦于以下问题:TypeScript CoreSitesProvider.getCurrentSite方法的具体用法?TypeScript CoreSitesProvider.getCurrentSite怎么用?TypeScript CoreSitesProvider.getCurrentSite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@providers/sites.CoreSitesProvider
的用法示例。
在下文中一共展示了CoreSitesProvider.getCurrentSite方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(navParams: NavParams, navCtrl: NavController, courseHelper: CoreCourseHelperProvider,
sitesProvider: CoreSitesProvider) {
const module = navParams.get('module');
if (module) {
courseHelper.openModule(navCtrl, module, sitesProvider.getCurrentSite().getSiteHomeId());
}
}
示例2: completionClicked
/**
* Completion clicked.
*
* @param {Event} e The click event.
*/
completionClicked(e: Event): void {
if (this.completion) {
if (typeof this.completion.cmid == 'undefined' || this.completion.tracking !== 1) {
return;
}
e.preventDefault();
e.stopPropagation();
const modal = this.domUtils.showModalLoading(),
params = {
cmid: this.completion.cmid,
completed: this.completion.state === 1 ? 0 : 1
},
currentSite = this.sitesProvider.getCurrentSite();
currentSite.write('core_completion_update_activity_completion_status_manually', params).then((response) => {
if (!response.status) {
return Promise.reject(null);
}
this.completionChanged.emit();
}).catch((error) => {
this.domUtils.showErrorModalDefault(error, 'core.errorchangecompletion', true);
}).finally(() => {
modal.dismiss();
});
}
}
示例3: constructor
constructor(platform: Platform, device: Device, appProvider: CoreAppProvider, fileProvider: CoreFileProvider,
initDelegate: CoreInitDelegate, langProvider: CoreLangProvider, sitesProvider: CoreSitesProvider,
localNotificationsProvider: CoreLocalNotificationsProvider, pushNotificationsProvider: AddonPushNotificationsProvider) {
const currentSite = sitesProvider.getCurrentSite();
this.appName = appProvider.isDesktop() ? CoreConfigConstants.desktopappname : CoreConfigConstants.appname;
this.versionName = CoreConfigConstants.versionname;
this.versionCode = CoreConfigConstants.versioncode;
this.compilationTime = CoreConfigConstants.compilationtime;
this.lastCommit = CoreConfigConstants.lastcommit;
// Calculate the privacy policy to use.
this.privacyPolicy = (currentSite && (currentSite.getStoredConfig('tool_mobile_apppolicy') ||
currentSite.getStoredConfig('sitepolicy'))) || CoreConfigConstants.privacypolicy;
this.navigator = window.navigator;
if (window.location && window.location.href) {
const url = window.location.href;
this.locationHref = url.substr(0, url.indexOf('#'));
}
this.appReady = initDelegate.isReady() ? 'core.yes' : 'core.no';
this.deviceType = platform.is('tablet') ? 'core.tablet' : 'core.phone';
if (platform.is('android')) {
this.deviceOs = 'core.android';
} else if (platform.is('ios')) {
this.deviceOs = 'core.ios';
} else if (platform.is('windows')) {
this.deviceOs = 'core.windowsphone';
} else {
const matches = navigator.userAgent.match(/\(([^\)]*)\)/);
if (matches && matches.length > 1) {
this.deviceOs = matches[1];
} else {
this.deviceOs = 'core.unknown';
}
}
langProvider.getCurrentLanguage().then((lang) => {
this.currentLanguage = lang;
});
this.networkStatus = appProvider.isOnline() ? 'core.online' : 'core.offline';
this.wifiConnection = appProvider.isWifi() ? 'core.yes' : 'core.no';
this.deviceWebWorkers = !!window['Worker'] && !!window['URL'] ? 'core.yes' : 'core.no';
this.device = device;
if (fileProvider.isAvailable()) {
fileProvider.getBasePath().then((basepath) => {
this.fileSystemRoot = basepath;
this.fsClickable = fileProvider.usesHTMLAPI();
});
}
this.localNotifAvailable = localNotificationsProvider.isAvailable() ? 'core.yes' : 'core.no';
this.pushId = pushNotificationsProvider.getPushId();
}
示例4: constructor
constructor(private navCtrl: NavController, navParams: NavParams, fb: FormBuilder, private appProvider: CoreAppProvider,
private sitesProvider: CoreSitesProvider, private loginHelper: CoreLoginHelperProvider,
private domUtils: CoreDomUtilsProvider) {
const currentSite = this.sitesProvider.getCurrentSite();
this.infoSiteUrl = navParams.get('infoSiteUrl');
this.pageName = navParams.get('pageName');
this.pageParams = navParams.get('pageParams');
this.siteConfig = navParams.get('siteConfig');
this.siteUrl = navParams.get('siteUrl');
this.siteId = navParams.get('siteId');
this.isLoggedOut = currentSite && currentSite.isLoggedOut();
this.credForm = fb.group({
password: ['', Validators.required]
});
}
示例5: displayShowFields
/**
* Displays fields for being shown.
*
* @param {string} template Template HMTL.
* @param {any[]} fields Fields that defines every content in the entry.
* @param {any} entry Entry.
* @param {string} mode Mode list or show.
* @param {any} actions Actions that can be performed to the record.
* @return {string} Generated HTML.
*/
displayShowFields(template: string, fields: any[], entry: any, mode: string, actions: any): string {
if (!template) {
return '';
}
let replace, render;
// Replace the fields found on template.
fields.forEach((field) => {
replace = '[[' + field.name + ']]';
replace = replace.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
replace = new RegExp(replace, 'gi');
// Replace field by a generic directive.
render = '<addon-mod-data-field-plugin [field]="fields[' + field.id + ']" [value]="entries[' + entry.id +
'].contents[' + field.id + ']" mode="' + mode + '" [database]="data" (gotoEntry)="gotoEntry(' + entry.id +
')"></addon-mod-data-field-plugin>';
template = template.replace(replace, render);
});
for (const action in actions) {
replace = new RegExp('##' + action + '##', 'gi');
// Is enabled?
if (actions[action]) {
if (action == 'moreurl') {
// Render more url directly because it can be part of an HTML attribute.
render = this.sitesProvider.getCurrentSite().getURL() + '/mod/data/view.php?d={{data.id}}&rid=' + entry.id;
} else if (action == 'approvalstatus') {
render = this.translate.instant('addon.mod_data.' + (entry.approved ? 'approved' : 'notapproved'));
} else {
render = '<addon-mod-data-action action="' + action + '" [entry]="entries[' + entry.id +
']" mode="' + mode + '" [database]="data"></addon-mod-data-action>';
}
template = template.replace(replace, render);
} else {
template = template.replace(replace, '');
}
}
return template;
}
示例6: ngOnInit
/**
* Component being initialized.
*/
ngOnInit(): void {
// Get number of news items to show.
const currentSite = this.sitesProvider.getCurrentSite(),
newsItems = currentSite.getStoredConfig('newsitems') || 0;
if (!newsItems) {
return;
}
const siteHomeId = currentSite.getSiteHomeId();
// Get the news forum.
this.siteHomeProvider.getNewsForum(siteHomeId).then((forum) => {
return this.courseProvider.getModuleBasicInfo(forum.cmid).then((module) => {
this.show = true;
this.module = module;
module.handlerData = this.moduleDelegate.getModuleDataFor(module.modname, module, siteHomeId, module.section);
});
}).catch(() => {
// Ignore errors.
});
}
示例7: ionViewDidLoad
/**
* View laoded.
*/
ionViewDidLoad(): void {
this.currentSite = this.sitesProvider.getCurrentSite();
if (!this.currentSite) {
// Not logged in, stop.
this.cancel();
return;
}
const currentSiteId = this.currentSite.id;
this.siteId = this.siteId || currentSiteId;
if (this.siteId != currentSiteId || !this.currentSite.wsAvailable('core_user_agree_site_policy')) {
// Not current site or WS not available, stop.
this.cancel();
return;
}
this.fetchSitePolicy();
}
示例8: uploadPrivateFile
/**
* Select a file, upload it and move it to private files.
*
* @param {any} [info] Private files info. See AddonFilesProvider.getPrivateFilesInfo.
* @return {Promise<any>} Promise resolved when a file is uploaded, rejected otherwise.
*/
uploadPrivateFile(info?: any): Promise<any> {
// Calculate the max size.
const currentSite = this.sitesProvider.getCurrentSite();
let maxSize = currentSite.getInfo().usermaxuploadfilesize,
userQuota = currentSite.getInfo().userquota;
if (userQuota === 0) {
// 0 means ignore user quota. In the app it is -1.
userQuota = -1;
} else if (userQuota > 0 && typeof info != 'undefined') {
userQuota = userQuota - info.filesizewithoutreferences;
}
if (typeof userQuota != 'undefined') {
// Use the minimum value.
maxSize = Math.min(maxSize, userQuota);
}
// Select and upload the file.
return this.fileUploaderHelper.selectAndUploadFile(maxSize).then((result) => {
if (!result) {
return Promise.reject(null);
}
// File uploaded. Move it to private files.
const modal = this.domUtils.showModalLoading('core.fileuploader.uploading', true);
return this.filesProvider.moveFromDraftToPrivate(result.itemid).catch((error) => {
this.domUtils.showErrorModalDefault(error, 'core.fileuploader.errorwhileuploading', true);
return Promise.reject(null);
}).finally(() => {
modal.dismiss();
});
}).then(() => {
this.domUtils.showToast('core.fileuploader.fileuploaded', true, undefined, 'core-toast-success');
});
}
示例9: constructor
constructor(protected injector: Injector, protected dataProvider: AddonModDataProvider,
protected dataOffline: AddonModDataOfflineProvider, protected eventsProvider: CoreEventsProvider,
sitesProvider: CoreSitesProvider, protected userProvider: CoreUserProvider) {
this.rootUrl = sitesProvider.getCurrentSite().getURL();
this.siteId = sitesProvider.getCurrentSiteId();
}
示例10: constructor
constructor(private sitesProvider: CoreSitesProvider, private courseProvider: CoreCourseProvider,
private moduleDelegate: CoreCourseModuleDelegate, private siteHomeProvider: CoreSiteHomeProvider) {
this.siteHomeId = sitesProvider.getCurrentSite().getSiteHomeId();
}
示例11:
this.contentLinksHelper.handleLink(url).then((treated) => {
if (!treated) {
return this.sitesProvider.getCurrentSite().openInBrowserWithAutoLoginIfSameSite(url);
}
}).finally(() => {