File Order

From VYRE

Jump to: navigation, search

Contents

AJAX API

The File order portlet must be on the page where the request for bulk download is taking place. In 4.7, watermarking was introduced to the file order portlet.

Dependancies

<script id="jQuery" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script id="FileOrder" type="text/javascript" src="/vyre_portlets/javascript/file_order/FileOrderApplication.js"></script>

Constructor

FileOrderApp

FileOrderApp is the main application which starts the file order process and returns the URL of the zipped file with all derived filed

var fileOrderApp = new FileOrderApp({
	fileServiceMapping:{
		32:"preview",
		41:"low-res",
		42:"thumbnail",
		original:"original"
	}
});

The constructor takes in an fileServiceMapping which maps file service ids to a human readable name. This is used to generate the file names.

FileOrderItem

FileOrderItem is a representation of a single unify item that will be ordered

var item = new FileOrderItem({id:1});

The constructor takes in an unify Item Id

Methods

FileOrderApp

  • addItem(FileOrderItem) - allows user to add Items (FileOrderItems) to be processes
    • @param FileOrderItem - FileOrderItem object which contain the item id and and the file services the user wishes to order
  • setFileOrderName(name) - allows user to specify the name of the zip file (since 4.6.2)
    • @param name - the name of the generated zip file which contains the bulk downloaded assets
  • addFileServiceMapping(id, name) - allows user to adds to the global fallback FileServiceMapping
    • @param id - either 'original' or file service id (integer)
    • @param name - name of the fileservice, this is used to generate a fallback name of files where the user has not specified the name.
  • registerEvent(eventName, callbackFunction) - allows user to register events (since 4.6.2)
    • @param eventName - there are two types of events:
      • callback is executed after the file order has started
      • pollStatus allows the user the poll the status of the file order
    • @param callbackFunction - the function that will be called when the event is fired
  • start() - starts the file order process

FileOrderItem

  • setId(itemId) - Sets the Item Id
    • @param itemId - specifies the id of the Unify Item the user wishes to order
  • addFileService(serviceId, name) - add file service the user wishes to be ordered
    • @param serviceId - id of the file service
    • @param name - specifies the name of the file. If the user does not specify a name, the system will generate a name using the fallback fileServiceMapping

Usage Code

[Note]

Note

You must add the File Order Portlet and the Javascript Dependencies for the FileOrderApp to work.

<script id="fileOrderUsageCode" type="text/javascript" >
 
 /*
 The values for 'FileOrderAjaxURL' & 'FileOrderStatus' are generated by the File Order Portlet. 
 Note: You must add the File Order Portlet before this javascript code.
 var FileOrderAjaxURL = "${ajaxInajaxInitialise}";
 var FileOrderStatus = "${ajaxProcessStatus}";
 */
 
 
 var fileOrderApp = new FileOrderApp({
	fileServiceMapping:{
		32:"preview",
		41:"low-res",
		42:"thumbnail",
		original:"original"
	}
 });
 
 //set the fileName for the zip file
 fileOrderApp.setFileOrderName("basket-images"+(new Date()).getTime());
 
 //callback function when the file order process starts
 fileOrderApp.registerEvent("callback", function(data){
    //alert the user order has started
    if (data.status =='processing') {
        alert('download has started');
    }else if (data.status == 'failed') {
       alert("download has failed");
    }
 });
 
 //callback function to poll the status of the file order
 fileOrderApp.registerEvent("pollStatus", function(data){
 
    if (data.status =='complete') {
       // let the save as dialouge appear
        window.open(data.filePath);
    }else if (data.status == 'failed') {
       alert("download has failed");
    }
 });
 
 
 //for Item 1
 var item1= new FileOrderItem ({id:32}); //file-item itemId
 item1.addFileService("original","wedding_photo_main");
 item1.addFileService(32,"wedding_photo_thumbnail");
 item1.addFileService(41,"wedding_photo_hi-res");
 
 fileOrderApp.addItem(item1);
 
 //for Item2
 var item2= new FileOrderItem ({id:33}); //file-item itemId
 item2.addFileService("original");//not specifying name
 item2.addFileService(32);//not specifying name
 item2.addFileService(42,"wedding_video_low-res");
 
 fileOrderApp.addItem(item2);
 
 
 fileOrderApp.start();
 
</script>

Watermarking

Watermarking can be done an order or a single file (original or derived file). The file order will not watermark all images.

configuration

Watermarking must be enabled in the portlet level. There are two fields for watermarking:

  • enable watermarking - enables watermarking on all watermarkable assets.
  • watermarking text - the text that should appear in the watermark. You have access to all the velocity variables. This is not used in single asset watermarking.

Usage Code for single image watermarking

<script type="text/javascript">
 
 var url = FileOrderWatermarkAsset + "&itemId=25592&fileServiceId=35&fileName=superEff.miah&watermarkText=confidential";
 
 jQuery.ajax({
  url:url, 
  type:"json", 
  success:function(xml){
 
 }
});
 
 
</script>
Personal tools