Overview
Renderer clients (such as the priint:renderer, priint:comet ID desktop or server) are configured using a set of configuration scripts (as known as panel statements). Some of these scripts are generated dynamically when connected to a priint:publishing server and some of these scripts can be adapted by partners to meet custom requirements.
When creating a new comet project or installing a priint:publishing server, the latest set of customizable scripts is installed. When updating an installation, these scripts are not updated, therefore you should check this document for recent and relevant changes and, if necessary, update scripts manually.
Check the version history below to find out, whether you have to update particular configuration files or not.
Requirements
This document does not refer to a particular version, but shows relevant change history of standard configuration scripts. Beside fixes and improvements in the configuration scripts (not so many, as you can see below), it is recommended using the latest available (released and tested) priint:publishing server version and priint:renderer resp. priint:comet ID desktop or server plug-ins, to make sure all these scripts indeed work as they should.
History
The version denotes the CometConfiguration plug-in version (not the Kernel). To find out, which plug-in version is currently installed on your publishing server, open the following page in a web browser:
http://your.pubserver.host:port/PubServerKerneland search for CometConfiguration.
- 4.1.5.1 Build #2327 New versions of document::after open and publication::after checkout. It's highly recommended updating both of these scripts. The new versions require PublishingServer version 4.1.5 / 4.1.5.1 Build #1910 or newer. For details see document::after open and publication::after checkout.
- 4.1.0.11174 New script library for publication functions
- 4.1.0.9065 Two new example scripts for generating and deleting table of content records:
When updating from a post 4.0.5.8456 configuration version, nothing has to be done.
To use one of the new example scripts in older configurations, simply add a script to the Product Panel using ison and copy & paste the code listed below. - 4.0.5.8456 typos, formatting and version info included in comments
When updating from a post 4.0.5.8330 configuration version, nothing has to be done.
When updating from an older or alpha version, check the files listed for the 4.0.5.8330 version. - 4.0.5.8330 initial version
Please check existing scripts against the following new versions:
Document Event Scripts
Repository path:: [project]/event/document
Ison path:: [project]/Events/Document
document::after close
Version (last update): 4.0.5.8456
Path: event/document/afterclose.xml
Script:
/** * Script to handle AFTER CLOSE events for documents. * Configuration version: 4.1.09065 * * THIS SCRIPT IS CURRENTLY UNUSED * The following global variables are defined: * gDocument ItemRef : the actual document * * For usage examples see the Comet Plugins Online documentation. * * (c) 2003 - 2016 Werk II GmbH, Auf der Hoehe 49, D-47059 Duisburg */ int main() { return 0; }
document::after new
Version (last update): 4.0.5.8456
Path: event/document/afternew.xml
Script:
/** * Script to handle AFTER NEW events for documents. * Configuration version: 4.1.09065 * * The following global variables are defined: * gDocument ItemRef : the actual document * * For usage examples see the Comet Plugins Online documentation. * * (c) 2003 - 2016 Werk II GmbH, Auf der Hoehe 49, D-47059 Duisburg */ int main() { return 0; }
document::after open
With PublishingServer 4.1.5.1 Build #2327, new versions of the document:open and publication::after checkout scripts have been established: these scripts handle the situation, when a document has just been checked out and closed without saving and then is reopened locally.
The former behaviour was:
- document parameters were not set for this document
- the display name for this document was not set correctly
Unfortunately, parts pf the functionality have to bee implemented twice, because depending on the situation, certain environment variables are or are not defined in the script context. For new Comet projects, the improved versions of the scripts is generated automatically, for old projects it's highly recommended updating the scripts as follows:
New version (last update): 4.1.5.1 Build #2327
Path: event/document/afteropen.xml
Note: when changing this script, you also have to update the publication::after checkout script
Script:
#include "[pubserver]/plugin/com.priint.pubserver.comet.bridge.publication.CometPublicationCScriptAddOns.c" int main() { int result = 0; char * documentId = alloc(4096); if (system::is_server()) { strcpy(documentId, gDocumentID); } else { xml::get_document_attribute(gDocument, "documentId", documentId); } if (strlen(documentId) && isPublicationDocument(documentId)) { result = xml::set_document_attribute(gDocument, "publication", publication::get_rootpublication_id (documentId)); result = publication::apply_parameters (gDocument, documentId); result = document::set_display_name (gDocument, publication::get_label (documentId)); } release(documentId); return result; }
Version (last update): 4.0.5.8456
Path: event/document/afteropen.xml
Script:
/** * Script to handle AFTER OPEN events for documents. * Configuration version: 4.1.09065 * * The following global variables are defined: * gDocument ItemRef : the actual document * * For usage examples see the Comet Plugins Online documentation. * * (c) 2003 - 2016 Werk II GmbH, Auf der Hoehe 49, D-47059 Duisburg */ int main() { if (system::is_server()) { publication::aftercheckout(gDocumentID, gDocumentPath); } return 0; }
document::after revert
Version (last update): 4.0.5.8456
Path: event/document/afterrevert.xml
Script:
/** * Script to handle AFTER REVERT events for documents. * Configuration version: 4.1.09065 * * The following global variables are defined: * gDocument ItemRef : the actual document * * For usage examples see the Comet Plugins Online documentation. * * (c) 2003 - 2016 Werk II GmbH, Auf der Hoehe 49, D-47059 Duisburg */ int main() { return 0; }
document::after save a copy
Version (last update): 4.0.5.8456
Path: event/document/aftersaveacopy.xml
Script:
/** * Script to handle AFTER SAVE A COPY events for documents. * Configuration version: 4.1.09065 * * The following global variables are defined: * gDocument ItemRef : the actual document * * For usage examples see the Comet Plugins Online documentation. * * (c) 2003 - 2016 Werk II GmbH, Auf der Hoehe 49, D-47059 Duisburg */ int main() { return 0; }
document::after save as
Version (last update): 4.0.5.8456
Path: event/document/aftersaveas.xml
Script:
/** * Script to handle AFTER SAVE AS events for documents. * Configuration version: 4.1.09065 * * The following global variables are defined: * gDocument ItemRef : the actual document * * For usage examples see the Comet Plugins Online documentation. * * (c) 2003 - 2016 Werk II GmbH, Auf der Hoehe 49, D-47059 Duisburg */ int main() { return 0; }
document::after save
Version (last update): 4.0.5.8456
Path: event/document/aftersave.xml
Script:
/** * Script to handle AFTER SAVE events for documents. * Configuration version: 4.1.09065 * * The following global variables are defined: * gDocument ItemRef : the actual document * * For usage examples see the Comet Plugins Online documentation. * * (c) 2003 - 2016 Werk II GmbH, Auf der Hoehe 49, D-47059 Duisburg */ int main() { if (system::is_server()) { publication::aftersave (gDocumentID, gDocumentPath); publication::checkin (gDocumentID, gDocumentPath); } return 0; }
document::after shown
Version (last update): 4.0.5.8456
Path: event/document/aftershown.xml
Script:
/** * Script to handle AFTER SHOWN events for documents. * Configuration version: 4.1.09065 * * The following global variables are defined: * gDocument ItemRef : the actual document * * For usage examples see the Comet Plugins Online documentation. * * (c) 2003 - 2016 Werk II GmbH, Auf der Hoehe 49, D-47059 Duisburg */ int main() { return 0; }
document::before close
Version (last update): 4.0.5.8456
Path: event/document/beforeclose.xml
Script:
/** * Script to handle BEFORE CLOSE events for documents. * Configuration version: 4.1.09065 * * The following global variables are defined: * gDocument ItemRef : the actual document * * For usage examples see the Comet Plugins Online documentation. * * (c) 2003 - 2016 Werk II GmbH, Auf der Hoehe 49, D-47059 Duisburg */ int main() { return 0; }
document::before new
Version (last update): 4.0.5.8456
Path: event/document/beforenew.xml
Script:
/** * Script to handle BEFORE NEW events for documents. * Configuration version: 4.1.09065 * * THIS SCRIPT IS CURRENTLY UNUSED * The following global variables are defined: * gDocument ItemRef : the actual document * * For usage examples see the Comet Plugins Online documentation. * * (c) 2003 - 2016 Werk II GmbH, Auf der Hoehe 49, D-47059 Duisburg */ int main() { return 0; }
document::before open
Version (last update): 4.0.5.8456
Path: event/document/beforeopen.xml
Script:
/** * Script to handle BEFORE OPEN events for documents. * Configuration version: 4.1.09065 * * The following global variables are defined: * gDocument ItemRef : the actual document * * For usage examples see the Comet Plugins Online documentation. * * (c) 2003 - 2016 Werk II GmbH, Auf der Hoehe 49, D-47059 Duisburg */ int main() { return 0; }
document::before revert
Version (last update): 4.0.5.8456
Path: event/document/beforerevert.xml
Script:
/** * Script to handle BEFORE REVERT events for documents. * Configuration version: 4.1.09065 * * The following global variables are defined: * gDocument ItemRef : the actual document * * For usage examples see the Comet Plugins Online documentation. * * (c) 2003 - 2016 Werk II GmbH, Auf der Hoehe 49, D-47059 Duisburg */ int main() { return 0; }
document::before save as
Version (last update): 4.0.5.8456
Path: event/document/beforesaveacopy.xml
Script:
/** * Script to handle BEFORE SAVE AS events for documents. * Configuration version: 4.1.09065 * * The following global variables are defined: * gDocument ItemRef : the actual document * * For usage examples see the Comet Plugins Online documentation. * * (c) 2003 - 2016 Werk II GmbH, Auf der Hoehe 49, D-47059 Duisburg */ int main() { return 0; }
document::before save as
Version (last update): 4.0.5.8456
Path: event/document/beforesaveas.xml
Script:
/** * Script to handle BEFORE SAVE AS events for documents. * Configuration version: 4.1.09065 * * The following global variables are defined: * gDocument ItemRef : the actual document * * For usage examples see the Comet Plugins Online documentation. * * (c) 2003 - 2016 Werk II GmbH, Auf der Hoehe 49, D-47059 Duisburg */ int main() { return 0; }
document::before save
Version (last update): 4.0.5.8456
Path: event/document/beforesave.xml
Script:
/** * Script to handle BEFORE SAVE events for documents. * Configuration version: 4.1.09065 * * The following global variables are defined: * gDocument ItemRef : the actual document * * For usage examples see the Comet Plugins Online documentation. * * (c) 2003 - 2016 Werk II GmbH, Auf der Hoehe 49, D-47059 Duisburg */ int main() { return 0; }
document::change front document
Version (last update): 4.0.5.8456
Path: event/document/changedocument.xml
Script:
/** * Script to handle CHANGE FRONT DOCUMENT events. * Configuration version: 4.1.09065 * * The following global variables are defined: * gDocument ItemRef : the actual document * * For usage examples see the Comet Plugins Online documentation. * * (c) 2003 - 2016 Werk II GmbH, Auf der Hoehe 49, D-47059 Duisburg */ int main() { return 0; }
Publication Event Scripts
Repository path:: [project]/event/publication
Ison path:: [project]/Events/Publication
publication::checkout
Version (last update): 4.0.5.8456
Path: event/publication/checkout.xml
Script:
/** * Script to handle CHECKOUT events for publication documents. * Configuration version: 4.1.09065 * * For usage examples see the Comet Plugins Online documentation. * * (c) 2003 - 2016 Werk II GmbH, Auf der Hoehe 49, D-47059 Duisburg */ #include "internal/types.h" int main () { char * path = alloc (4096); int status = 0; int result = 0; // get the recent status (maybe the information in the panel is outdated?) wtlog ("", "\n***************************************\n* Publication: getDocumentStatus documentID: '%s'\n", "<Content_StringID>"); status = priint::document_status ("<Content_StringID>"); if (status != kAvailable && status != kOpenedInSession) { wlog ("", "* FAILED with status %d\n***************************************\n", status); showmessage ("The document you requested isn't available any more. Maybe another user started editing in the meantime? Please update the publication panel to review the document status."); return -1; } wtlog ("", "* SUCCEEDED with status %d\n***************************************\n", status); wtlog ("", "\n***************************************\n* Publication: checkout documentID: '%s'\n* NOTE: DEPENDING ON THE FILESIZE AND CONNECTION THIS MAY TAKE A VERY _LONG_ TIME...\n", "<Content_StringID>"); result = priint::checkout ("<Content_StringID>", path); if (result == 0) { wlog ("", "* SUCCEEDED. local path: '%s'\n***************************************\n", path); strcpy (gDocumentPath, path); } else { wtlog ("", "* FAILED with result code %d\n***************************************\n", result); showmessage ("Document checkout finished with result code %d. You cannot use this document at the moment.", result); } if (path) release (path); return result; }
publication::after save
Version (last update): 4.0.5.8456
Path: event/publication/aftersave.xml
Script:
/** * Script to handle AFTER SAVE events for publication documents. * Configuration version: 4.1.09065 * * For usage examples see the Comet Plugins Online documentation. * * (c) 2003 - 2016 Werk II GmbH, Auf der Hoehe 49, D-47059 Duisburg */ int main () { wtlog ("", "\n***************************************\n* Publication: document '%s' ('%s') has been saved.\n* You may want to configure panelstatement 112 to handle\n* <SAVE> events of publication documents\n***************************************\n", gDocumentID, gDocumentPath); return 0; }
publication::before close
Version (last update): 4.0.5.8456
Path: event/publication/beforeclose.xml
Script:
/** * Script to handle BEFORE CLOSE events for publication documents. * Configuration version: 4.1.09065 * * For usage examples see the Comet Plugins Online documentation. * * (c) 2003 - 2016 Werk II GmbH, Auf der Hoehe 49, D-47059 Duisburg */ int main () { wtlog ("", "\n***************************************\n* Publication: document '%s' ('%s') will be closed.\n* You may want to configure panelstatement 113 to handle\n* <BEFORE CLOSE> events of publication documents\n***************************************\n", gDocumentID, gDocumentPath); return 0; }
publication::status
Version (last update): 4.0.5.8456
Path: event/publication/status.xml
Script:
/** * Script to handle STATUS events for publication documents. * Configuration version: 4.1.09065 * * For usage examples see the Comet Plugins Online documentation. * * (c) 2003 - 2016 Werk II GmbH, Auf der Hoehe 49, D-47059 Duisburg */ #include "internal/types.h" int main () { int result = 0; int status = 0; for (;;) { wtlog ("", "\n***************************************\n* Publication: documentStatus documentID: '%s' (Masterdoc: '%s')", "<Content_StringID>", gMasterDoc); status = priint::document_status ("<Content_StringID>"); if (status >= 0) { wtlog ("", "* DONE with status %d\n***************************************\n", status); if (status == kOpenedByUser) { status = kOpenedOnClient; } *gDocumentStatus = status; } else { wtlog ("", "* FAILED with status %d\n***************************************\n", status); *gDocumentStatus = kNotRegistered; } break; // !!! } return 0; }
publication::checkin
Version (last update): 4.0.5.8456
Path: event/publication/checkin.xml
Script:
/** * Script to handle CHECKIN events for publication documents. * Configuration version: 4.1.09065 * * For usage examples see the Comet Plugins Online documentation. * * (c) 2003 - 2016 Werk II GmbH, Auf der Hoehe 49, D-47059 Duisburg */ #include "internal/types.h" int main () { int result = 0; for (;;) { wtlog ("", "\n***************************************\n* Publication: checkin documentID: '%s', local path: '%s'\n* NOTE: DEPENDING ON THE FILESIZE THIS MAY TAKE A VERY VERY _LONG_ TIME...\n", gDocumentID, gDocumentPath); result = priint::checkin (gDocumentID, gDocumentPath); wlog ("", "* DONE with result code %d\n***************************************\n", result); break; // !!! } return result; }
publication::after close
Version (last update): 4.0.5.8456
Path: event/publication/afterclose.xml
Script:
/** * Script to handle AFTER CLOSE events for publication documents. * Configuration version: 4.1.09065 * * For usage examples see the Comet Plugins Online documentation. * * (c) 2003 - 2016 Werk II GmbH, Auf der Hoehe 49, D-47059 Duisburg */ int main () { wtlog ("", "\n***************************************\n* Publication: document '%s' ('%s') has been closed.\n* You may want to configure panelstatement 116 to handle\n* <AFTER CLOSE> events of publication documents\n***************************************\n", gDocumentID, gDocumentPath); return 0; }
publication::revert
Version (last update): 4.0.5.8456
Path: event/publication/revert.xml
Script:
/** * Script to handle REVERT events for publication documents. * Configuration version: 4.1.09065 * * For usage examples see the Comet Plugins Online documentation. * * (c) 2003 - 2016 Werk II GmbH, Auf der Hoehe 49, D-47059 Duisburg */ #include "internal/types.h" int main () { int result = 0; for (;;) { wtlog ("", "\n***************************************\n* Publication: revert documentID: '%s', local path: '%s'\n* NOTE: DEPENDING ON THE FILESIZE THIS MAY TAKE A VERY VERY _LONG_ TIME...\n", "<Content_StringID>", gDocumentPath); result = priint::revert ("<Content_StringID>", gDocumentPath); wlog ("", "* DONE with result code %d\n***************************************\n", result); break; // !!! } return result; }
publication::after checkout
With PublishingServer 4.1.5.1 Build #2327, new versions of the document:open and publication::after checkout scripts have been established: these scripts handle the situation, when a document has just been checked out and closed without saving and then is reopened locally.
The former behaviour was:
- document parameters were not set for this document
- the display name for this document was not set correctly
Unfortunately, parts pf the functionality have to bee implemented twice, because depending on the situation, certain environment variables are or are not defined in the script context. For new Comet projects, the improved versions of the scripts is generated automatically, for old projects it's highly recommended updating the scripts as follows:
Version (last update): 4.1.5.1 Build #2327
Path: event/publication/aftercheckout.xml
Note: when changing this script, you also have to update the document::after open script
Script:
int main () { int result = 0; wtlog ("", "\n***************************************\n* Publication: store publication / documentId '%s' in document xml structure, local path: '%s'\n", gDocumentID, gDocumentPath); result = xml::set_document_attribute(gDocument, "documentId", gDocumentID); if (document::get_modified()) { // document has to be saved in this stage, otherwise the documentId // documentId and thus linkage to the publication record might get lost // if the document is closed. document::save(); } result = xml::set_document_attribute(gDocument, "publication", publication::get_rootpublication_id (gDocumentID)); result = publication::apply_parameters (gDocument, gDocumentID); result = document::set_display_name (gDocument, publication::get_label (gDocumentID)); return result; }
Version (last update): 4.0.5.8456
Path: event/publication/aftercheckout.xml
Script:
/** * Script to handle AFTER CHECKOUT events for publication documents. * Configuration version: 4.1.09065 * * This script is executed AFTER checkout when the document has just * been opened. * The script won't be executed, if opening the document fails for any * reason. * The following variables are available in this script: * gDocument ItemRef the actual document * gDocumentID char * the (pubklication) ID of this document * gDocumentPath char * (local)path of the document * + all other variables defined in publication panel scripts. * * For usage examples see the Comet Plugins Online documentation. * * (c) 2003 - 2016 Werk II GmbH, Auf der Hoehe 49, D-47059 Duisburg */ int main () { int result = 0; wtlog ("", "\n***************************************\n* Publication: store publication / documentId '%s' in document xml structure, local path: '%s'\n", gDocumentID, gDocumentPath); result = xml::set_document_attribute(gDocument, "publication", publication::get_rootpublication_id (gDocumentID)); result = xml::set_document_attribute(gDocument, "documentId", gDocumentID); result = publication::apply_parameters (gDocument, gDocumentID); result = document::set_display_name (gDocument, publication::get_label (gDocumentID)); return result; }
publication::connection data
This script is deprecated and is not used any more when connected to priint:publishing server. You can safely delete it from the repository
Version (last update): 4.0.5.8456
Path: event/publication/connectiondata.xml
Script:
getList getPriintConnectionData '<server>','','<user>','<password>','<client>','<language>'
Login Event Scripts
Repository path:: [project]/event/session
Ison path:: [project]/Events/Login
session::after login
Version (last update): 4.0.5.8456
Path: event/session/login.xml
Script:
/** * After Login. * Configuration version: 4.1.09065 * * This script is executed after login to the PublishingServer. * * For usage examples see the Comet Plugins Online documentation. * * (c) 2003 - 2016 Werk II GmbH, Auf der Hoehe 49, D-47059 Duisburg */ #include "internal/types.h" int main () { // activate docwatch // if you need to handle document events // uncomment the following line system::set_docwatch (1); // set priint:cometserver preferences // see the PlugIn documentation for further information // if you have not installed the publication module // there is no need to adapt the following lines priint::set_pref (kPriintDownloadPolicy, kPriintAlwaysDownload); // do not allow users to change these settings priint::set_prefs_editable (0); // do NOT use soap proxy priint::use_soap_proxy (0); // we save idml and w2ml alongside with templates: prefs::add_idml_to_templates (1); prefs::add_w2ml_to_templates (1); // uncomment the following lines to enable // the new taggedtext import and export behaviour prefs::set_tags_readable (0); prefs::set_tags_writeable (0); prefs::set_script_buffer(8192); return 0; }
session::allow login
Version (last update): 4.0.5.8456
Path: event/session/allowlogin.xml
Script:
/** * Allow Login. * Configuration version: 4.1.09065 * * This script is executed after login to the PublishingServer and * BEFORE executing any login actino or initialization. * * For usage examples see the Comet Plugins Online documentation. * * (c) 2003 - 2016 Werk II GmbH, Auf der Hoehe 49, D-47059 Duisburg */ int main () { // return 0 to allow or any non zero value to disallow // login. In the latter case you should show an alert // why login is denied return 0; }
Standard Scripts
Repository path:: see individual scripts
ui::drop url script
Version (last update): 4.0.5.8456
Path: event/dropurl/dropurl.xml
Script:
/** * Drop Url Script. * Configuration version: 4.1.09065 * * This script is executed when an URL is dropped in the document. * The following variables are available: * gURL char * url * gPage int page index * gDropX float x coordinate on page * gDropY float y coordinate on page * gLayer char * target layer name * * For usage examples see the Comet Plugins Online documentation. * * (c) 2003 - 2016 Werk II GmbH, Auf der Hoehe 49, D-47059 Duisburg */ int main() { int resultCode = 0; // your code goes here return resultCode; }
publication::double click
Version (last update): 4.0.5.8456
Path: event/publication/doubleclick.xml
Script:
/** * Publication Double Click. * Configuration version: 4.1.09065 * * This script is executed when a publication entry is double clicked OR after checkout. * The following variables are available: * gDocument ItemRef 0 or valid document ref * gClicked 0-based index of the row clicked * + several tags replaced with the publication context, see example * script below or Comet Plugins Online documentation. * * For usage examples see the Comet Plugins Online documentation. * * (c) 2003 - 2016 Werk II GmbH, Auf der Hoehe 49, D-47059 Duisburg */ int main () { wlog("", "# Publication doubleclick or checkout: row %d : %d (%s of %s of %s)\n\nEdit the event/publication/doubleclick.xml script to get rid of this message.", gClicked+1, gRecordID, "<Name>", "<DokumentInfo>", "<parent.DokumentInfo>"); // Finish script in case of a double click if (!document::is_valid (gDocument)) return 0; // if gDocument refers a valid document, this script is // executed in a checkout / open context. We can operate on // that document below, if required. return 0; }
product::double click
Version (last update): 4.0.5.8456
Path: event/productpool/doubleclick.xml
Script:
/** * Product Double Click. * Configuration version: 4.1.09065 * * This script is executed when a product entry is double clicked. * The following variables are available: * gClicked 0-based index of the row clicked * + several tags replaced with the product context, see example * script below or Comet Plugins Online documentation. * * For usage examples see the Comet Plugins Online documentation. * * (c) 2003 - 2016 Werk II GmbH, Auf der Hoehe 49, D-47059 Duisburg */ int main () { wlog("", "# Product doubleclick: row %d : %s\n\nEdit the event/productpool/doubleclick.xml script to get rid of this message.", gClicked+1, gRecordStringID); return 0; }
preview::double click
Version (last update): 4.0.5.8456
Path: event/preview/doubleclick.xml
Script:
/** * Preview Double Click. * Configuration version: 4.1.09065 * * This script is executed when a preview entry is double clicked. * The following variables are available: * gClicked 0-based index of the row clicked * + several tags replaced with the preview context, see example * script below or Comet Plugins Online documentation. * * For usage examples see the Comet Plugins Online documentation. * * (c) 2003 - 2016 Werk II GmbH, Auf der Hoehe 49, D-47059 Duisburg */ int main () { wlog("", "# Preview doubleclick: row %d : %s\n\nEdit the event/productpool/doubleclick.xml script to get rid of this message.", gClicked+1, gRecordStringID); return 0; }
Build Product Selection
Version (last update): 4.0.5.8456
Path: planner/document/1003.xml
Script:
/* * Script Name : Build Product Selection (Publication Planner) * Configuration version: 4.1.09065 * * File : * Author : Maciej Kazmierczak * Creation Date : Fri Feb 23 12:30:00 CET 2012 * Description : Known Problems : * History : * Mon Aug 24 12:49:00 CET 2015: Christoph Soergel * Adaptions for Publishing Server integration * Tue Dec 08 14:07:00 CET 2015: Christoph Soergel * use publication module functions to fetch document * product selection * For usage examples see the Comet Plugins Online documentation. * * (c) 2003 - 2016 Werk II GmbH, Auf der Hoehe 49, D-47059 Duisburg */ #include "internal/text.h" #include "internal/products.h" #include "internal/types.h" int main() { // // TODO: // Set to valid ID of a existing page template. // This page template must exist in your comet repository. // If a page template has already been set in the target // document, you can also set 'flags' to kPreferExistingPages. // int pageTemplateId = 12345; // // OPTIONALLY: // Build flags. Refer to the Comet InDesign Plugin documentation for // possible values. // Examples: // int flags = kPreferExistingPages; // int flags = kAutoDetectType + kLoadMasterItems; // ... // int flags = 0; // = no build flags // // OPTIONALLY: // we use the templates defined in the planning system. // To override this, set defaultTemplateId to the ID of a valid // template in your comet repository. // This template will then be used for products with no template // definition, or - depending on flags - for just all products. // int defaultTemplateId = 0; // // OPTIONALLY: // Use a prescript to filter the product list loaded from the // planning system. // int preScript = 0; ProductList prds = publication::get_document_product_selection(); char * msg = alloc(10000); char * tmp = alloc(10000); wlog("", "BUILD PRODUCT SELECTION START BUILD PRODUCTS page =%d\n", document::pages(gDocument)); //Start build pages productlist::establish(prds, 0, document::pages(gDocument), "de", pageTemplateId, defaultTemplateId, flags, preScript, 0, "", msg); if (strlen(msg)) { wtlog("", "ERRORS:\n%s\nBUILD DONE WITH ERRORS IN DOCUMENT %s\n", msg, document::path(tmp, gDocument)); } else { wtlog("", "BUILD DONE SUCCESSFULLY IN DOCUMENT %s\n", document::path(tmp, gDocument)); } release(msg); release(tmp); wlog("", "END BUILD PRODUCT SELECTION\n"); return 0; }
Write for current document
Version (last update): 4.1.0.9065
Path: panel/productpool/panelaction/1009.xml
Script:
/* * Script Name : Write table of content entries * Configuration version: 4.1.09065 * * File : * Author : Christoph Soergel * Creation Date : Tue Jun 21 10:00:00 CET 2016 * Description : Example script to generate table of content * entries for a document * Known Problems : * History : * For usage examples see the Comet Plugins Online documentation. * * (c) 2003 - 2016 Werk II GmbH, Auf der Hoehe 49, D-47059 Duisburg */ #include "internal/types.h" int main () { // to define, which placeholders should be used to generate // table of content records, we need a LinkList of type // "placeholder" LinkList placeholders = linklist::alloc(1); int result; // placeholder IDs are project specific, so the following lines // most probably have to be adapted linklist::insert(placeholders, 268435763); linklist::insert(placeholders, 268435795); // etc. // the linklist::insert_toc_entry function takes 4 parameters: // - list of placeholders (mandatory) // - scope (optional), one of // kDesignateDocument, // kVisibleLayers or // kActiveLayer // - publication (optional) name or ID of the publication // - documentId (optional) ID of the document // If publication or documentId are empty, these values are read from // from document XML attributes, if available. // // NOTE: when writing toc entries, existing entries for the same // document, scope and placeholders are deleted before. showmessage("This script requires adaption before it can be used in your project. Please edit the script content in ISON, Comet Explorer > [ project ] > InDesign Desktop Panel > Product Pool"); // after adaption, remove the comment marks below: // result = linklist::insert_toc_entry(placeholders, kDesignateDocument); return result; }
Delete for current document
Version (last update): 4.1.0.9065
Path: panel/productpool/panelaction/1010.xml
Script:
/* * Script Name : Delete table of content entries * Configuration version: 4.1.09065 * * File : * Author : Christoph Soergel * Creation Date : Tue Jun 21 10:00:00 CET 2016 * Description : Example script to generate table of content * entries for a document * Known Problems : * History : * For usage examples see the Comet Plugins Online documentation. * * (c) 2003 - 2016 Werk II GmbH, Auf der Hoehe 49, D-47059 Duisburg */ #include "internal/types.h" int main () { // to define, which table of content records should be deleted // we need a LinkList of type "placeholder" LinkList placeholders = linklist::alloc(1); int result; // placeholder IDs are project specific, so the following lines // most probably have to be adapted linklist::insert(placeholders, 268435763); linklist::insert(placeholders, 268435795); // etc. // the linklist::delete_toc_entry function takes 4 parameters: // - list of placeholders (mandatory) // - scope (optional), one of // kDesignateDocument, // kVisibleLayers or // kActiveLayer // - publication (optional) name or ID of the publication // - documentId (optional) ID of the document // If publication or documentId are empty, these values are read from // from document XML attributes, if available. // // NOTE: only entries for the same document, scope and placeholders are deleted showmessage("This script requires adaption before it can be used in your project. Please edit the script content in ISON, Comet Explorer > [ project ] > InDesign Desktop Panel > Product Pool"); // after adaption, remove the comment marks below: // result = linklist::delete_toc_entry(placeholders, kDesignateDocument); return result; }
Activate trace
Version (last update): 4.0.5.8456
Path: panel/productpool/panelaction/1004.xml
Script:
/** * Activate trace for this session * Configuration version: 4.1.09065 * * This script is part of the standard installation of the CometBridge * application. It will be created automatically for all projects. * You can edit this script if required. If you delete it, it will be * recreated, when the PublishingServer or the CometConfiguration application * is restarted. * Unmodified scripts will be updated automatically, if an updated server version * provides modified versions of this script. * * (c) 2003 - 2016 Werk II GmbH, Auf der Hoehe 49, D-47059 Duisburg */ #include "internal/types.h" int main() { SOAP conn = soap::connection(); Query qu = 0; char buffer[4096]; if (conn == 0) { return -1; } qu = soap::call(conn, "pcs"); query::send(qu, "::getTraceStatus"); query::output(qu, kString, buffer, 4096); if (!query::exec(qu)) { query::close(qu); showerror("Activating trace failed:\nCouldn't query current trace status."); return -1; } while (query::fetch(qu)); query::close(qu); if (strstr(buffer, "1") == buffer) { showmessage("Trace has already been activated for this session.\n\nYou can use the priint:ison trace viewer to examine log messages.\nTracing is deactivated automatically, as soon as you logout or quit InDesign."); return 0; } qu = soap::call(conn, "pcs"); query::send(qu, "::activateTrace"); if (!query::exec(qu)) { query::close(qu); showerror("Activating trace failed:\nCouldn't set trace status."); return -1; } query::close(qu); showmessage("Trace is now activated for this session.\n\nYou can now use the priint:ison trace viewer to examine log messages.\n\nPlease note, that activating trace can significantly decrease performance. Tracing is deactivated automatically, as soon as you logout or quit InDesign."); return 0; }
Deactivate trace
Version (last update): 4.0.5.8456
Path: panel/productpool/panelaction/1005.xml
Script:
/** * Deactivate trace for this session * Configuration version: 4.1.09065 * * This script is part of the standard installation of the CometBridge * application. It will be created automatically for all projects. * You can edit this script if required. If you delete it, it will be * recreated, when the PublishingServer or the CometConfiguration application * is restarted. * Unmodified scripts will be updated automatically, if an updated server version * provides modified versions of this script. * * (c) 2003 - 2016 Werk II GmbH, Auf der Hoehe 49, D-47059 Duisburg */ #include "internal/types.h" int main() { SOAP conn = soap::connection(); Query qu = 0; char buffer[4096]; if (conn == 0) { return -1; } qu = soap::call(conn, "pcs"); query::send(qu, "::getTraceStatus"); query::output(qu, kString, buffer, 4096); if (!query::exec(qu)) { query::close(qu); showerror("Deactivating trace failed:\nCouldn't query current trace status."); return -1; } while (query::fetch(qu)); query::close(qu); if (strstr(buffer, "0") == buffer) { showmessage("Trace has not been activated for this session."); return 0; } qu = soap::call(conn, "pcs"); query::send(qu, "::deactivateTrace"); if (!query::exec(qu)) { query::close(qu); showerror("Deactivating trace failed:\nCouldn't set trace status."); return -1; } query::close(qu); showmessage("Trace is now deactivated for this session."); return 0; }
Export trace
Version (last update): 4.0.5.8456
Path: panel/productpool/panelaction/1006.xml
Script:
/** * Export trace for this session * Configuration version: 4.1.09065 * * This script is part of the standard installation of the CometBridge * application. It will be created automatically for all projects. * You can edit this script if required. If you delete it, it will be * recreated, when the PublishingServer or the CometConfiguration application * is restarted. * Unmodified scripts will be updated automatically, if an updated server version * provides modified versions of this script. * * (c) 2003 - 2016 Werk II GmbH, Auf der Hoehe 49, D-47059 Duisburg */ #include "internal/types.h" int main() { char tmp1[4096]; char tmp2[4096]; char filepath[4096]; char * outId = alloc(4096); char * outTimestamp = alloc(4096); char * outSessionId = alloc(4096); char * outUser = alloc(4096); char * outType = alloc(4096); char * outSource = alloc(4096); char * outHint = alloc(65536); char * outMessage = alloc(65536); int result = 0; int file = 0; SOAP connection = soap::connection(); Query qu = 0; for (;;) { result = file::select_folder(filepath, "Please select output folder"); if (result != 0) { break; } strcpy(tmp1, filepath); strcat(tmp1, "/export_trace_test"); file = file::open(tmp1, "w"); if (file == 0) { showmessage("Cannot write in folder '%s'", filepath); } file::close(file); file::get_date(tmp1, kDateCreated, 104, tmp2); file::remove(tmp1); strcat(filepath, "/trace_"); strcat(filepath, soap::user(connection, tmp1)); strcat(filepath, "_"); strcat(filepath, tmp2); strcat(filepath, ".csv"); showmessage("Exporting tracer messages for the current session to file %s", filepath); file = file::open(filepath, "w"); if (file == 0) { showmessage("Error: could not open '%s' for writing.", filepath); break; } file::write(file,"Id,SessionId,User,Type,Source,Hint,Message,\n"); qu = soap::getlist(connection, "stringtable plugin(globalName='com.priint.pubserver.comet.bridge.CometBridge',methodName='getSessionTracerMessages')[<Session.Id>]"); if (!qu) { file::close(file); showmessage("Memory error, cannot allocate query"); break; } query::output(qu, kString, outId, 4095); query::output(qu, kString, outTimestamp, 4095); query::output(qu, kString, outSessionId, 4095); query::output(qu, kString, outUser, 4095); query::output(qu, kString, outType, 4095); query::output(qu, kString, outSource, 4095); query::output(qu, kString, outMessage, 65535); query::output(qu, kString, outHint, 65535); if (!query::exec(qu)) { query::close(qu); file::close(file); showmessage("Error when executing request."); break; } while (query::fetch(qu)) { file::write(file, outId); file::write(file, ";"); file::write(file, outTimestamp); file::write(file, ";"); file::write(file, outSessionId); file::write(file, ";"); file::write(file, outUser); file::write(file, ";"); file::write(file, outType); file::write(file, ";"); file::write(file, outSource); file::write(file, ";"); file::write(file, outMessage); file::write(file, ";"); file::write(file, outHint); file::write(file, ";\n"); } query::close(qu); file::close(file); break; } release(outId); release(outTimestamp); release(outSessionId); release(outUser); release(outType); release(outSource); release(outMessage); release(outHint); return result; }
publication functions
Version (last update): 4.1.0.11174
Path: include/publicationfunctions.xml
Script:
#include "internal/types.h" #include "internal/publications.h" /** * String resources for dialogs and messages. * * TODO: support translations, currently dialog title and labels are all * English */ char * dialogTitle = "Set workflow status"; char * dialogPopup1Label = "Status"; char * dialogPopup2Label = "New status"; char * dialogPopup1Default = "Do not change"; char * dialogPopup1Change = "Change"; // CAUTION: when changing these messages, please preserve the order and type of // format placeholders - or also change code below, where the messages // are refered char * documentIdMustNotBeEmptyMsg = "Document ID must not be empty."; char * noWorkflowStatesAvailableMsg = "No workflow states available for document '%s' ('%s')"; char * userCanceledDialogMsg = "Workflow status not changed, operation canceled by user."; char * dontChangeWorkflowStatusMsg = "Status of document '%s' will remain unchanged as requested"; char * invalidNewWorkflowStatusMsg = "Workflow status '%d' isn't a valid status, please select a different one."; char * errorSettingWorkflowStateMsg = "Error '%d' when setting new workflow state '%s' to document '%s' ('%s')"; char * successfullyDoneMsg = "Workflow status '%s' has successfully been applied to document '%s' ('%s')"; char * documentCheckinFailedMsg = "Checkin document '%s' ('%s') failed with error code '%d'"; char * checkinDocumentMsg = "\n***************************************\n* Publication: checkin documentId: '%s', local path: '%s'\n* NOTE: DEPENDING ON THE FILESIZE THIS MAY TAKE A VERY VERY _LONG_ TIME...\n"; char * checkDocumentStatusMsg = "Check status of document '%s' ('%s'), run=%d / %d"; char * serverCheckinTimeoutMsg = "Server checkin processing for document '%s' ('%s') not finished in time. Tried %d times, operation took approx %.2f seconds"; char * documentStatusSucceededMsg = "Status for document '%s' ('%s') is available after %d runs, operation took approx %.2f seconds"; /** * Various settings. */ // depending on the system environment, document size and workflow // configuration, the following values may have to be adapted: // int waitForServerSeconds = 60; // wait maximum 1 minute int pollingIntervalMilliseconds = 500; // poll every 500ms /** * <p> * Shows a dialog to change a document workflow status * </p> * <p> * Shows up a dialog with 2 popups (using the cscript standard function * "askpopup2") and let the user choose, whether to change the document * workflow status or not.<br/> * <strong>Note:</strong> * depending on the workflow configuration, it may or may not be possible * to change the workflow status for documents, which are currently checked * out. To checkin a document and changing the workflow step respecting the * document status use the checkinWithDialog function also defined in this * library. * </p> * * @param documentId ID of the document, if executed in a document or * publication event script context usually "gDocumentID". * Must not be zero. * @param documentLabel label (ui name) for this document. If 0, the documentId * will be used in dialogs and alerts * @param uiLevel <ul> * <li>0 = only dialog, no errors and hints</li> * <li>1 = show warnings / errors only</li> * <li>2 = show hints</li> * <li>3 = show everything</li> * <li>4 = "debug level"</li> * </ul> * @param newWorkflowStatus if non-zero, this will be set to the status of the * document <em>after</em> running the dialog. * @return error code <ul> * <li>0 = set workflow status was successfull</li> * <li>1 = error (other than described below)</li> * <li>2 = user canceled dialog or operation</li> * <li>3 = no (next) document workflow states available</li> * <li>4 = error when setting new workflow status</li> * </ul> * * TODO: support translations, currently dialog title and labels are all * English * */ int workflowStatusDialog (char * documentId, char * documentLabel, int uiLevel, WorkflowStatus newStatus) { int resultCode = 0; int i = 0; char * buffer = alloc(4096); int dialogResult = 0, dialogOut1 = 0, dialogOut2 = 0; WorkflowStatusList nextWorkflowStates = 0; WorkflowStatus tmpWorkflowStatus = 0; IDTypeList popup1Values = 0; IDTypeList popup2Values = 0; IDType idTypeTmp = 0; for (;;) { // input validation if (!documentLabel) documentLabel = documentId; if (!documentId || strlen(documentId) == 0) { __showmessage(documentIdMustNotBeEmptyMsg, 1, uiLevel); resultCode = 1; break; } // query next available workflow states for document nextWorkflowStates = publication::get_next_workflow_states(documentId); if (nextWorkflowStates == 0 || publication::workflowstatuslist::length(nextWorkflowStates) == 0) { __showmessage (sprintf(buffer, noWorkflowStatesAvailableMsg, documentLabel, documentId), 2, uiLevel); resultCode = 4; break; } // values for the first popup popup1Values = idtypelist::alloc(); idTypeTmp =idtype::alloc(); idtype::set_id(idTypeTmp, 0); idtype::set_stringid(idTypeTmp, dialogPopup1Default); idtypelist::append(popup1Values, idTypeTmp); idTypeTmp =idtype::alloc(); idtype::set_id(idTypeTmp, 1); idtype::set_stringid(idTypeTmp, dialogPopup1Change); idtypelist::append(popup1Values, idTypeTmp); // values for the 2nd popup popup2Values = idtypelist::alloc(); for (i = 0; i < publication::workflowstatuslist::length(nextWorkflowStates); ++i) { tmpWorkflowStatus = publication::workflowstatuslist::get(nextWorkflowStates, i); idTypeTmp = idtype::alloc(); idtype::set_id(idTypeTmp, val(publication::workflowstatus::gets(tmpWorkflowStatus, kActionId))); idtype::set_stringid(idTypeTmp, publication::workflowstatus::gets(tmpWorkflowStatus, kLabel)); idtypelist::append(popup2Values, idTypeTmp); } // show dialog dialogResult = askpopup2(dialogTitle, "", "", 0, dialogPopup1Label, &dialogOut1, "", "", popup1Values, dialogPopup2Label, &dialogOut2, "", "", popup2Values); // dialog canceled: if (dialogResult == 0) { __showmessage(userCanceledDialogMsg, 3, uiLevel); resultCode = 2; break; } // in first popup "Do not change" was selected: if (dialogOut1 == 0) { __showmessage(sprintf(buffer, dontChangeWorkflowStatusMsg, documentLabel), 3, uiLevel); resultCode = 2; break; } // no valid selection in 2nd popup: if (dialogOut2 == 0) { __showmessage(sprintf(buffer, invalidNewWorkflowStatusMsg, dialogOut2), 2, uiLevel); resultCode = } // everything ok, try to change the document workflow status: sprintf(buffer, "%d", popup2Out); resultCode = publication::set_document_workflow_status(documentId, buffer, ""); if (resultCode != 0) { __showmessage(sprintf(buffer, errorSettingWorkflowStateMsg, resultCode, buffer, documentLabel, documentId), 1, uiLevel); resultCode = 4; break; } __showmessage(sprintf(buffer, successfullyDoneMsg, buffer, documentLabel, documentId), 3, uiLevel); // apply values of the new workflow status to out parameter: if (newWorkflowStatus) { for (i = 0; i < publication::workflowstatuslist::length(nextWorkflowStates); ++i) { tmpWorkflowStatus = publication::workflowstatuslist::get(nextWorkflowStates, i); if (strcmp(publication::workflowstatus::gets(tmpWorkflowStatus, kActionId),buffer) == 0) { break; } tmpWorkflowStatus = 0; } if (tmpWorkflowStatus) { publication::workflowstatus::copy(newWorkflowStatus, tmpWorkflowStatus); } } break; } // cleanup if (popup1Values != 0) { idtypelist::clear(popup1Values); idtypelist::release(popup1Values); } if (popup2Values != 0) { idtypelist::clear(popup2Values); idtypelist::release(popup2Values); } if (nextWorkflowStates != 0) { publication::workflowstatuslist::release(nextWorkflowStates); } if (buffer) release(buffer); return resultCode; } /** * <p> * Checks in a document and shows workflow dialog * </p> * <p> * Checks in a document, blocks, until the checkin has been fully processed * and then show a dialog to set a new workflow status. * </p> * <p><strong>CAUTION!</strong> if used in the publication::checkin event * script, the result code of this function must <strong>not</strong> * be returned directly by the calling main function.<br/> * If the document actually <em>has</em> been checked in (i.e.: result * code is other than 7 or 1), the main function <strong>must</strong> * return <strong>0</strong><br/> * Otherwise the client status of the document will remain "checked out" * and thus be out of sync with the server status.<br/> * Example: * <pre> * // publication::checkin script * * int main() { * WorflowStatus newStatus = publication::workflowstatus::alloc(); * int resultCode = * checkinWithDialog(gDocumentID, 0, gDocumentPath, * 3, // get detailed ui messages * newStatus // retrieve newly set status * ); * if (resultCode == 0) { * showmessage("Status has been successfully set to '%s'", * publication::workflowstatus::gets(newStatus, kLabel)); * } * if (resultCode == 7 || resultCode == 1) { * return 0; * } * // NEVER return resultCode other than 0 in other cases! * return 0; * } * </pre> * </p> * * @param documentId ID of the document, if executed in a document or * publication event script context usually "gDocumentID". * Must not be zero. * @param documentLabel label (ui name) for this document. If 0, the documentId * will be used in dialogs and alerts * @param documentPath path of the document, usually gDocumentPath * @param uiLevel <ul> * <li>0 = only dialog, no errors and hints</li> * <li>1 = show warnings / errors only</li> * <li>2 = show hints</li> * <li>3 = show everything</li> * <li>4 = "debug level"</li> * </ul> * @param newWorkflowStatus if non-zero, this will be set to the status of the * document <em>after</em> running the dialog. * @return error code <ul> * <li>0 = set workflow status was successfull</li> * <li>1 = error (other than described below)</li> * <li>2 = user canceled dialog or operation</li> * <li>3 = no (next) document workflow states available</li> * <li>4 = error when setting new workflow status</li> * <li>7 = checkin document failed</li> * <li>8 = server checkin process didn't finish in time</li> * </ul> * * TODO: support translations, currently dialog title and labels are all * English */ int checkinWithDialog (char * documentId, char * documentLabel, char * documentPath, int uiLevel, WorkflowStatus newWorkflowStatus) { int resultCode = 0, run = 0, status = 0; int iterations = 0; float f1, f2; char * buffer = alloc(4096); for (;;) { // input validation if (!documentLabel) documentLabel = documentId; if (!documentId || strlen(documentId) == 0) { __showmessage(documentIdMustNotBeEmptyMsg, 1, uiLevel); resultCode = 1; break; } if (!documentPath || strlen(documentPath) == 0) { __showmessage(documentIdMustNotBeEmptyMsg, 1, uiLevel); resultCode = 1; break; } __showmessage(sprintf(buffer, checkinDocumentMsg, documentId, documentPath), 4, uiLevel); resultCode = priint::checkin(documentId, documentPath); if (resultCode != 0) { __showmessage(sprintf(buffer, documentCheckinFailedMsg, documentLabel, documentId, resultCode), 1, uiLevel); resultCode = 7; break; } // with InDesignServer: just checkin, do not show dialog if(system::is_server()) { break; } f1 = 1000.0 / pollingIntervalMilliseconds; f2 = f1 * waitForServerSeconds; iterations = 1 * f2; // lazy waiting for server to finish checkin processes: for (run = 0; run < iterations; ++run) { status = priint::document_status(documentId); __showmessage(sprintf(buffer, checkDocumentStatusMsg, documentLabel, documentId, (run + 1), status), 4, uiLevel); if (status == kAvailable) { __showmessage(sprintf(buffer, documentStatusSucceededMsg, documentLabel, documentId, (run + 1), ((float)run * pollingIntervalMilliseconds / 1000.0)), 4, uiLevel); break; } if (run == iterations - 1) { __showmessage(sprintf(buffer, serverCheckinTimeoutMsg, documentId, documentLabel, (run + 1), ((float)run * pollingIntervalMilliseconds / 1000.0)), 1, uiLevel); result = 8; break; } system::sleep(pollingIntervalMilliseconds); } resultCode = workflowStatusDialog (documentId, documentLabel, uiLevel, newWorkflowStatus); break; } // cleanup if (buffer) release(buffer); return resultCode; } /** * helper function to show alerts depending on a user defined log level */ int __showmessage (char * msg, int errorLevel, int uiLevel) { wtlog ("", "%s\n", msg); if (system::is_server()) { return 0; } if (uiLevel >= errorLevel) { if (errorLevel == 1) { showerror("%s", msg); } else { showmessage("%s", msg); } } return 0; }