The script editor lets you write and execute scripts from the back-office tool, which is also present in the administration and repository views.
It is based on GraalJS syntax.
It can be enhanced with your own customizations.
Enhancing the script repository Variables Functions Tutorials Enhancing the script repository If there are pieces of code that you use regularly in your scripts, you are encouraged to enrich your repository so that they are available in all your scripts.
You can enhance the script tool with your own variables, functions and tutorials by adding the WEB-INF/param/scripts file .xml .
The format is as follows; each tag is optional.
Oops! Copy to clipboard failed. Open the code and copy it manually.<?xml version="1.0" encoding="UTF-8"?>
<binding>
<variables>...</variables>
<functions>...</functions>
<tutorials>...</tutorials>
</binding> <?xml version="1.0" encoding="UTF-8"?>
<binding>
<variables>...</variables>
<functions>...</functions>
<tutorials>...</tutorials>
</binding>
<?xml version="1.0" encoding="UTF-8"?>
<binding>
<variables>...</variables>
<functions>...</functions>
<tutorials>...</tutorials>
</binding> Variables To define variables, under the variables tag, add a variable tag for each desired variable.
Each variable tag includes :
name : Variable nametext : Explanatory textscript Code corresponding to variable initialization. It is recommended to externalize it via the file attribute, which contains a relative pathsignature Variable signature
examples with several tags example itself composed of :
text : Explanatory text for the examplescript Content of the example. It is recommended to externalize it via the file attribute, which contains a relative path
Oops! Copy to clipboard failed. Open the code and copy it manually.<variable>
<name>Content.selection</name>
<text type="i18n">PLUGINS_CMS_SCRIPT_VAR_SELECTION</text>
<script file="js/Content-variables.js"/>
<signature>
<type>org.ametys.cms.repository.Content[]</type>
</signature>
<examples>
<example>
<script file="examples/Content.selection-01.js"/>
</example>
</examples>
</variable> <variable>
<name>Content.selection</name>
<text type="i18n">PLUGINS_CMS_SCRIPT_VAR_SELECTION</text>
<script file="js/Content-variables.js"/>
<signature>
<type>org.ametys.cms.repository.Content[]</type>
</signature>
<examples>
<example>
<script file="examples/Content.selection-01.js"/>
</example>
</examples>
</variable> Voir le code
<variable>
<name>Content.selection</name>
<text type="i18n">PLUGINS_CMS_SCRIPT_VAR_SELECTION</text>
<script file="js/Content-variables.js"/>
<signature>
<type>org.ametys.cms.repository.Content[]</type>
</signature>
<examples>
<example>
<script file="examples/Content.selection-01.js"/>
</example>
</examples>
</variable>
Functions To define functions, below the functions tag, add a function tag for each desired variable.
Each function tag includes :
name : Function nametext : Explanatory textscript Code corresponding to the function content. It is recommended to externalize it via the file attribute, which contains a relative pathsignature Function signature
type : Type of function return valuetext : Return value documentationarguments composed of several argument with :
name : Argument nametype : Type of argumenttext : Text explaining the argumentoptional : Boolean indicating whether the argument is optional
examples with several tags example itself composed of :
text : Explanatory text for the examplescript Content of the example. It is recommended to externalize it via the file attribute, which contains a relative path
Oops! Copy to clipboard failed. Open the code and copy it manually.<function>
<name>Solr.contentQuery</name>
<text i18n="true">plugin.cms:PLUGINS_CMS_SCRIPT_FCT_SOLR_QUERY_CONTENT</text>
<signature>
<type>org.ametys.plugins.repository.AmetysObjectIterable</type>
<text type="i18n">PLUGINS_CMS_SCRIPT_FCT_SOLR_QUERY_CONTENT_SIGNATURE_RETURN</text>
<arguments>
<argument>
<name>query</name>
<type>String</type>
<text type="i18n">PLUGINS_CMS_SCRIPT_FCT_SOLR_QUERY_CONTENT_SIGNATURE_ARG_QUERY</text>
</argument>
<argument>
<name>contentTypes</name>
<type>String/String[]</type>
<text type="i18n">PLUGINS_CMS_SCRIPT_FCT_SOLR_QUERY_CONTENT_SIGNATURE_ARG_CONTENT_TYPES</text>
</argument>
<argument>
<name>facets</name>
<type>Object</type>
<text type="i18n">PLUGINS_CMS_SCRIPT_FCT_SOLR_QUERY_CONTENT_SIGNATURE_ARG_FACETS</text>
</argument>
<argument>
<name>workspaceName</name>
<type>String</type>
<text type="i18n">PLUGINS_CMS_SCRIPT_FCT_SOLR_QUERY_CONTENT_SIGNATURE_ARG_WORKSPACE</text>
</argument>
</arguments>
</signature>
<examples>
<example>
<script file="examples/Solr.contentQuery-01.js"/>
</example>
</examples>
</function> <function>
<name>Solr.contentQuery</name>
<text i18n="true">plugin.cms:PLUGINS_CMS_SCRIPT_FCT_SOLR_QUERY_CONTENT</text>
<signature>
<type>org.ametys.plugins.repository.AmetysObjectIterable</type>
<text type="i18n">PLUGINS_CMS_SCRIPT_FCT_SOLR_QUERY_CONTENT_SIGNATURE_RETURN</text>
<arguments>
<argument>
<name>query</name>
<type>String</type>
<text type="i18n">PLUGINS_CMS_SCRIPT_FCT_SOLR_QUERY_CONTENT_SIGNATURE_ARG_QUERY</text>
</argument>
<argument>
<name>contentTypes</name>
<type>String/String[]</type>
<text type="i18n">PLUGINS_CMS_SCRIPT_FCT_SOLR_QUERY_CONTENT_SIGNATURE_ARG_CONTENT_TYPES</text>
</argument>
<argument>
<name>facets</name>
<type>Object</type>
<text type="i18n">PLUGINS_CMS_SCRIPT_FCT_SOLR_QUERY_CONTENT_SIGNATURE_ARG_FACETS</text>
</argument>
<argument>
<name>workspaceName</name>
<type>String</type>
<text type="i18n">PLUGINS_CMS_SCRIPT_FCT_SOLR_QUERY_CONTENT_SIGNATURE_ARG_WORKSPACE</text>
</argument>
</arguments>
</signature>
<examples>
<example>
<script file="examples/Solr.contentQuery-01.js"/>
</example>
</examples>
</function> Voir le code
<function>
<name>Solr.contentQuery</name>
<text i18n="true">plugin.cms:PLUGINS_CMS_SCRIPT_FCT_SOLR_QUERY_CONTENT</text>
<signature>
<type>org.ametys.plugins.repository.AmetysObjectIterable</type>
<text type="i18n">PLUGINS_CMS_SCRIPT_FCT_SOLR_QUERY_CONTENT_SIGNATURE_RETURN</text>
<arguments>
<argument>
<name>query</name>
<type>String</type>
<text type="i18n">PLUGINS_CMS_SCRIPT_FCT_SOLR_QUERY_CONTENT_SIGNATURE_ARG_QUERY</text>
</argument>
<argument>
<name>contentTypes</name>
<type>String/String[]</type>
<text type="i18n">PLUGINS_CMS_SCRIPT_FCT_SOLR_QUERY_CONTENT_SIGNATURE_ARG_CONTENT_TYPES</text>
</argument>
<argument>
<name>facets</name>
<type>Object</type>
<text type="i18n">PLUGINS_CMS_SCRIPT_FCT_SOLR_QUERY_CONTENT_SIGNATURE_ARG_FACETS</text>
</argument>
<argument>
<name>workspaceName</name>
<type>String</type>
<text type="i18n">PLUGINS_CMS_SCRIPT_FCT_SOLR_QUERY_CONTENT_SIGNATURE_ARG_WORKSPACE</text>
</argument>
</arguments>
</signature>
<examples>
<example>
<script file="examples/Solr.contentQuery-01.js"/>
</example>
</examples>
</function>
Tutorials Tutorials are documentation only. Under the tutorials tag, add a tutorial tag for each tutorial you want.
Each tutorial tag includes :
name : Labeltext : Explanatory textexamples with several tags example itself composed of :
text : Explanatory text for the examplescript Content of the example. It is recommended to externalize it via the file attribute, which contains a relative path
Oops! Copy to clipboard failed. Open the code and copy it manually.<tutorial>
<name type="i18n">PLUGINS_CORE_UI_SCRIPT_TUTO_FIRSTSTEP</name>
<text type="i18n">PLUGINS_CORE_UI_SCRIPT_TUTO_FIRSTSTEP_DESCRIPTION</text>
<examples>
<example>
<text type="i18n">PLUGINS_CORE_UI_SCRIPT_TUTO_FIRSTSTEP_EXAMPLE_01</text>
<script file="tutorials/tuto-01.js"/>
</example>
<example>
<text type="i18n">PLUGINS_CORE_UI_SCRIPT_TUTO_FIRSTSTEP_EXAMPLE_02</text>
<script file="tutorials/tuto-02.js"/>
</example>
</examples>
</tutorial> <tutorial>
<name type="i18n">PLUGINS_CORE_UI_SCRIPT_TUTO_FIRSTSTEP</name>
<text type="i18n">PLUGINS_CORE_UI_SCRIPT_TUTO_FIRSTSTEP_DESCRIPTION</text>
<examples>
<example>
<text type="i18n">PLUGINS_CORE_UI_SCRIPT_TUTO_FIRSTSTEP_EXAMPLE_01</text>
<script file="tutorials/tuto-01.js"/>
</example>
<example>
<text type="i18n">PLUGINS_CORE_UI_SCRIPT_TUTO_FIRSTSTEP_EXAMPLE_02</text>
<script file="tutorials/tuto-02.js"/>
</example>
</examples>
</tutorial> Voir le code
<tutorial>
<name type="i18n">PLUGINS_CORE_UI_SCRIPT_TUTO_FIRSTSTEP</name>
<text type="i18n">PLUGINS_CORE_UI_SCRIPT_TUTO_FIRSTSTEP_DESCRIPTION</text>
<examples>
<example>
<text type="i18n">PLUGINS_CORE_UI_SCRIPT_TUTO_FIRSTSTEP_EXAMPLE_01</text>
<script file="tutorials/tuto-01.js"/>
</example>
<example>
<text type="i18n">PLUGINS_CORE_UI_SCRIPT_TUTO_FIRSTSTEP_EXAMPLE_02</text>
<script file="tutorials/tuto-02.js"/>
</example>
</examples>
</tutorial>