Common methods
These methods are available directly in the Context Object.
readFile
|
This method is deprecated and is going to be dismissed. See new context object reference for further details. |
Reads a file given its filename, and returns it in a particular format.
Syntax
ctx.readFile( filename, format, resolveEntities, asString )
Params
| Parameter | Values | Description | Default value |
|---|---|---|---|
filename (required) |
String or JSON Object |
|
|
format (optional) |
String |
The format to convert the file into. Available formats: json, xml. |
json |
resolveEntities (optional) |
Boolean |
Boolean value to choose whether to get raw or resolved content, valid only in case the format is xml. |
false |
asString (optional) |
Boolean |
Boolean value to choose whether to get XML object or String content, valid only in case the format is xml. |
false |
Example
var file = ctx.readFile( '/SysConfig/Common/Data/Sections.xml', 'xml', true, true );
or
var file = ctx.readFile( { filename: '/SysConfig/Common/Data/Sections.xml', format: 'xml', 'resolveEntities': true, 'asString': true });
showError, showWarning
|
This method is deprecated and is going to be dismissed soon. See new context object reference for further details. |
Shows an error or a warning message, using Méthode Swing dialogs.
Syntax
ctx.showError( message )
ctx.showWarning( message )
Params
| Parameter | Values | Description | Default value |
|---|---|---|---|
message (required) |
String |
The message to show. |
Example
ctx.showError('My error message');
ctx.showWarning('My warning message');
showConfirmationDialog
|
This method is deprecated and is going to be dismissed soon. See new context object reference for further details. |
Shows a Swing-like confirmation dialog, such as the following:
Syntax
ctx.showConfirmationDialog( options )
Params
| Parameter | Values | Description |
|---|---|---|
options (required) |
JSON Object |
The options for the confirmation dialog:
|
|
Remember that the Confirmation Dialog is NOT really blocking the flow of execution. Only a Javascript |
Example
ctx.showConfirmationDialog({
message: 'Incredibly important attention required. Are you really (really) sure?',
title: '',
buttons: 'yesnocancel',
type: 'warning',
onYes: function() {
// DO SOMETHING
},
onNo: function() {
// DO SOMETHING
},
onCancel: function() {
// DO SOMETHING
}
});
getCurrentUserInfo
|
This method is deprecated and is going to be dismissed soon. See new context object reference for further details. |
Return the info on the current user
Syntax
ctx.getCurrentUserInfo();
Example
var userInfo = ctx.getCurrentUserInfo();
Now, userInfo is something like this:
{
"picture": "/WebClient/user/avatar/kgy89?token=3959bee9-d142-4a74-bcb4-2663dfbe8de3",
"name": "john.doe",
"description": "Eidosmedia top class R&D",
"config_folder": "eomfs:/Configurations/Profiles/kgy89/Config",
"databaseId": 199,
"id": "1.0.417997841",
"fullName": "John Doe",
"team": "Globe_Web",
"phoneNumber": "456",
"mobileNumber": "123",
"twitter": "john.doe",
"facebook": "john.doe@r.com",
"role": "Reporter",
"homeEmail": "john.doe@google.com",
"businessEmail": "john.doe@star.com",
"statusMessage": "Status msg",
"workDir": "workfolder:///Globe/Art",
"location": "Milano",
"profileDir": "eomfs:/Configurations/Profiles/kgy89",
"lastLoggedOn": 1433422139,
"initials": "AP",
"signature": "John",
"system_attributes": "<props><principalInfo><statusMessage>Status msgsdsadsadasw</statusMessage>\r\n<location>Roma</location>\r\n<initials>APw</initials>\r\n<signature>John</signature>\r\n<email type=\"business\">john.doe@r.com2</email>\r\n<email type=\"home\">john.doe.home@r.com</email>\r\n<twitter>kgy89</twitter>\r\n<facebook>john.doe@r.com</facebook>\r\n<mobileNumber>123</mobileNumber>\r\n<phoneNumber>456</phoneNumber>\r\n<workDir>workfolder:///Globe/Art</workDir>\r\n<status>donotdisturb</status>\r\n\r\n</principalInfo>\r\n<role>Reporter</role>\r\n</props>",
"metadata": "",
"homePath": "/Users/john.doe",
"workPath": "/Globe/Stories/Art",
"admin": true,
"groups": [
{
"name": "Administrators",
"description": "",
"config_folder": "eomfs:/Configurations/Profiles/Administrators/Config",
"profile_folder": "eomfs:/Configurations/Profiles/Administrators",
"id": "1.0.7398",
"categories": [
"EOM::Group",
"EOM::Configuration",
"EOM::Privileges"
],
"isConfiguration": true
}
],
"status": "donotdisturb",
"teams": [
"Globe_Team",
"Globe_Web"
],
"defaultChannel": "Globe-Print"
}
getUserList
|
This method is deprecated and is going to be dismissed soon. See new context object reference for further details. |
Return an array with the info of all the users in Methode.
Syntax
ctx.getUserList();
Example
var users = ctx.getUserList();
getSiteConfigFragment
|
This method is deprecated and is going to be dismissed soon. See new context object reference for further details. |
Returns an array containing the string XML fragments obtained from the evaluation in the siteConfig.cfg file of the provided xpath.
Syntax
ctx.siteConfigFragment(xpath);
Example
var presetCropsArray = ctx.siteConfigFragment('/siteConfiguration/presetCrops');
/*
presetCropsArray:
[ "<presetCrops>
<crop channel="Globe-Web,Globe-Print,Globe-WireNews" favorite="yes" height="719px" name="Homepage-Main" width="107px"/>
<crop height="667px" name="iPhone 6" width="375px"/>
<crop height="512px" name="iPad 4" width="384px"/>
</presetCrops>" ]
*/
Method |
|
Parameter |
|
openPopupPanel
|
This method is deprecated and is going to be dismissed soon. See new context object reference for further details. |
Opens a custom HTML panel developed and specified by the user.
Syntax
ctx.openPopupPanel( panelName );
Method |
|
Parameter |
|
Returns |
|
Example
var panelName = 'myTestPanel';
ctx.openPopupPanel( panelName );
Registration of the custom panel
The custom panel must be registered via Javascript. The namespace of reference is the following:
eidosmedia.webclient.extensions.popups
A call to the register method must be done as follows:
eidosmedia.webclient.extensions.popups.register( name, settings );
-
{String} name: the name of the custom popup ( same as the one called from thectx.openPopupPanel()method. -
{Object} settings: a javascript object with the settings. It has the following parameters:-
{String} icon: the icon css class. -
{String} title: the title of the custom dialog. -
{String} containerStyle: the style of the container. See info box below. -
{String} template: the path to the HTML file. It is relative to the application context. -
{Function} ready: a function which is called when the popup is loaded. The function is called with two parameters:-
ctx- the Context Object ( with the activeDocument if you are in the Story Editor context ) -
$modal- the jQuery reference to identify the modal. The example below will show some possible uses.
-
-
eidosmedia.webclient.extensions.popups.register('testpopup', {
icon: 'icon-plus',
title: 'Custom panel title',
containerStyle: 'background-color:red;',
template: '/config/templates/customTemplates/testpopup.html',
ready: function( ctx, $modal ) {
// Popup is visible.
console.log( ctx );
// CUSTOM EXAMPLE
/*
In the footer example, we added a 'data-modal-action' to the OK button.
We now intercept the click inside the modal.
*/
// Add modal listeners.
$modal.on('click', '[data-modal-action]', function( event ) {
var action = $(this).attr('data-modal-action');
switch(action) {
case 'ok':
alert('Button clicked!');
// To close the modal, use $modal.modal('hide');
$modal.modal('hide');
break;
}
event.preventDefault();
event.stopPropagation();
});
}
});
|
The popup panel is built around a classical Bootstrap Modal.
In particular, the HTML code in your template will be placed INSIDE the So, the modal will be basically created as follows:
No predefined style is given for the footer, but it is recommended to be as follows:
So, considering that your code is wrapped inside the modal-body, if you want to use a footer,
close a Example:
IMPORTANT: as it is a bootstrap modal, by adding |
getContextObject, getContextObjectByPath
|
This method is deprecated and is going to be dismissed soon. See new context object reference for further details. |
Returns a new context for the element specified.
Syntax
ctx.getContextObject( objectId );
ctx.getContextObjectByPath( objectPath );
Method |
|
Parameter |
|
Returns |
|
Method |
|
Parameter |
|
Returns |
|
Example
var correlatedCTX = ctx.getContextObject('199$1.0.752763933');
console.log( correlatedCTX.activeObj.getName() );
Methods available for a single object
|
This method is deprecated and is going to be dismissed soon. See new context object reference for further details. |
These methods are available for the Context.activeObj and for each object in the Context.selection array.
getId(), getType(), getInfo(), getBundleInfo(), getSysAttributes(), getUsageTickets()
Return, respectively, the id, the type, the info, the compound story info (e.g. info of created channel copies) and the system attributes of the current object.
Syntax
var _id = ctx.activeObj.getId(),
_type = ctx.activeObj.getType(),
_info = ctx.activeObj.getInfo(),
_bundleInfo = ctx.activeObj.getBundleInfo(),
_sysAttributes = ctx.activeObj.getSysAttributes();
_usageTickects = ctx.activeObj.getUsageTickets();
// or ctx.selection[0].... etc.
isType( testType )
Check if the object is of a specified type.
Syntax
var isImage = ctx.activeObj.isType( 'Image' ); // This checks the Methode Types Configuration
// or ctx.selection[0].... etc.
Params
| Parameter | Values | Description | Default value |
|---|---|---|---|
testType (required) |
String |
The type to compare to. |
setMetadataField
Sets a metadata field of an EOM Object.
|
For the method to work properly, at least EOMDB version 6.0.4 is required. |
Syntax
ctx.activeObj.setMetadataField( options, callback )
Params
| Parameter | Values | Description | Default value |
|---|---|---|---|
options (required) |
Object |
The options of the metadata to set |
|
callback |
Object |
An object containing two functions: success and error to be called after the execution of the action. |
options the following properties are supported:
-
xpath (String): the xpath of the metadata to set. REQUIRED
-
content (String/Boolean/Numeric): the value to set. REQUIRED
Example
ctx.activeObj.setMetadataField({
xpath: "/attributes/ObjectMetadata/General/Priority",
content: "High"
}, {
success: function() {
//...
},
error: function() {
//...
}
});
// OR
ctx.selection[0].setMetadataField({
xpath: "/attributes/ObjectMetadata/General/Priority",
content: "High"
}, {
success: function() {
//...
},
error: function() {
//...
}
});
cleanMetadataField
Clean a metadata field of all the items inside an EOM::Folder.
|
For the method to work properly, at least EOMDB version 6.0.4 is required. |
Syntax
ctx.activeObj.cleanMetadataField( options, callback )
Params
| Parameter | Values | Description | Default value |
|---|---|---|---|
options (required) |
Object |
The options of the metadata to clean |
|
callback |
Object |
An object containing two functions: success and error to be called after the execution of the action. |
Example
ctx.activeObj.cleanMetadataField({
container: params.container,
xpath: "/attributes/ObjectMetadata/General/Priority"
}, {
success: function() {
//...
},
error: function() {
//...
}
});
// OR
ctx.selection[0].cleanMetadataField({
container: params.container,
xpath: "/attributes/ObjectMetadata/General/Priority"
}, {
success: function() {
//...
},
error: function() {
//...
}
});
executeObjectAction
Executes an action to the object.
Syntax
ctx.activeObj.executeObjectAction( settings, callbackSettings )
Params
| Parameter | Values | Description | Default value |
|---|---|---|---|
settings (required) |
Object or String |
If a string is passed, it represents the name of the action to execute. Else, represents a set of arguments. |
|
callbackSettings (options) |
Object |
An object containing two functions: success and error to be called after the execution of the action. |
settings can be either a string or a Javascript Object. If it is a string, it will interpreted as the actionId, and the action will be executed with no other params. Elsewhere, if a Javascript object is passed, the following properties are supported:
-
actionId: the action name. REQUIRED.
-
args: the arguments as a String.
Example
ctx.activeObj.executeObjectAction( 'postToTwitter', {
success: function() {
//...
},
error: function() {
//...
}
});
// OR ctx.selection[0].executeObjectAction( 'postToTwitter', ...
// OR
ctx.activeObj.executeObjectAction( { actionId: 'postToTwitter', args: 'arguments here' }, {
success: function() {
//...
},
error: function() {
//...
}
});
setSysAttributeField
Sets a system attribute field of an EOM Object.
|
For the method to work properly, at least EOMDB version 6.0.4 is required. |
Syntax
ctx.activeObj.setSysAttributeField( xpath, value )
Params
| Parameter | Values | Description | Default value |
|---|---|---|---|
xpath (required) |
String |
The xpath of the system attribute to set |
|
value (required) |
String/Boolean/Numeric |
The value to set. |
Example
ctx.activeObj.setSysAttributeField( "/attributes/ObjectMetadata/General/Priority", "true" );
getMetadata
Obtain the metadata of the object, as a string.
Syntax
ctx.activeObj.getMetadata( onSuccess, onError );
Params
| Parameter | Values | Description | Default value |
|---|---|---|---|
onSuccess (required) |
Function |
The function to be called when the Metadata is available. |
|
onError (optional) |
Function |
The function to be called in case of error |
|
The metadata can be obtained only through the onSuccess callback. The method is called asynchronously. |
Example
ctx.activeObj.getMetadata( function( metadata ) {
// Do something with the metadata.
}, function( error ) {
alert( error.message );
});