Admin Library

Contents

Admin Library

This library contains admin related functions.

Usage

Add the following into your build.gradle file:

dependencies {
  include 'com.enonic.xp:lib-admin:${xpVersion}
}

In your JavaScript controller, add a require statement:

const adminLib = require('/lib/xp/admin');

You are now free to use the library functionality.

Functions

getAssetsUri

Returns the admin assets uri.

Parameters

None

Returns

string : A URI pointing to the admin assets

getBaseUri

Returns the admin base uri.

Parameters

None

Returns

string : The admin base URI

getHomeToolUrl

Returns the URL for the Home admin tool.

Parameters

An object with the following keys and their value:

Name Kind Details

path

 string

Optional Admin Tool URI prefix

type

string

Either server (server-relative URL) or absolute

Returns

string : The URL pointing to the Home Tool

getInstallation

Returns installation name.

Parameters

None

Returns

string : The installation Name

getLauncherPath

Returns the URL for launcher javascript.

Parameters

None

Returns

string : The URL for the launcher javascript

getLauncherUrl

Returns the URL for the launcher panel.

Parameters

None

Returns

string : The URL for the launcher panel

getLocale

Returns the preferred locale based on the current HTTP request, or the server default locale if none is specified.

Parameters

None

Returns

string : The preferred locale for this request

getLocales

Returns the list of preferred locales based on the current HTTP request, or the server default locale if none is specified.

Parameters

None

Returns

Array.<string> : Current locales in order of preference

getPhrases

Returns all i18n phrases.

Parameters

None

Returns

object : JSON object with phrases

getToolUrl

Returns the URL for an admin tool of specific application.

Parameters

Name Kind Details

application

string

Full application name (f.ex, 'com.enonic.app')

tool

string

Name of the tool inside an app (f.ex, 'main')

Returns

string : The URL to the requested tool.

getVersion

Returns version of XP installation.

Parameters

None

Returns

string : The version number of the XP runtime.

Contents