#retHTMLImg#
#LEFT(ceDataArray[i].Values.title,50)#
";
// Debug text
//retHTML = retHTML & "
items: #arguments.item#
";
//retHTML = retHTML & "
photoID: #ceDataArray[i].Values.photoID#
";
retHTML = retHTML & "";
}
}
// Check if we had any values
if ( NOT LEN(retHTML) )
retHTML = "No records to display.";
// Initialize the return variable
var retHTML = "";
// Get the CE Data
var dataArray = ArrayNew(1);
var photoIDList = "";
var i=1;
var s=1;
var filteredSearchArray = ArrayNew(1);
var maxReturnRecs = 100;
var limitReturnRecs = false; //Flag to set if we want to limit the return amount
// clean the search text
if ( arguments.queryType eq "search" AND LEN(arguments.searchValues) ){
arguments.searchValues = cleanChooserSearchText(arguments.searchValues);
}
// Get custom element data
// Get the selected records back
if ( (arguments.queryType EQ "selected") AND (LEN(arguments.item) GT 0) ) {
dataArray = application.ptPhotoGallery.photoDAO.getPhotoData(photoID=arguments.item);
}
// Run the search if there is a search term
else if ( arguments.queryType EQ "search" ) {
dataArray = getCEData(variables.CUSTOM_ELEMENT, "", "", arguments.queryType, arguments.searchValues, variables.SEARCH_FIELDS);
// Filter out all records from the search results that have already been selected
if ( ArrayLen(dataArray) AND LEN(TRIM(arguments.item)) ) {
for ( s=1; s LTE ArrayLen(dataArray); s=s+1 ) {
// - Check if the returned record match the passed in selected item
if ( ListFindNoCase(TRIM(arguments.item), TRIM(dataArray[s].values[variables.CE_FIELD]) ) EQ 0 ) {
// - Build new array with valid records
ArrayAppend(filteredSearchArray, dataArray[s]);
}
}
// Convert filteredSearchArray back the dataArray for the return
dataArray = filteredSearchArray;
}
}
else {
// Check if the category field is defined
if ( LEN(arguments.categoryID) )
dataArray = getCEData(variables.CUSTOM_ELEMENT, "category", arguments.categoryID);
else
dataArray = getCEData(variables.CUSTOM_ELEMENT);
// Flag to set if we want to limit the return amount
limitReturnRecs = true;
}
// if are returning the selected items
// sort the dataArray array order to match the passed in items ID order
if ( arguments.queryType NEQ "selected" ) {
// Determine max records to return
if ( !limitReturnRecs OR (ArrayLen(dataArray) LT maxReturnRecs) )
maxReturnRecs = ArrayLen(dataArray);
// Build the list of UUIDs for the photos
for ( i=1; i LTE maxReturnRecs; i++ ) {
if ( ListFindNoCase(arguments.item,dataArray[i].values.photoID) EQ 0 )
photoIDList = ListAppend(photoIDList, dataArray[i].values.photoID);
}
// Get the data based on the new photo ID list... else return nothing
if ( LEN(photoIDList) ){
// Call photo DAO to set the fields
dataArray = application.ptPhotoGallery.photoDAO.getPhotoData(photoID=photoIDList);
// sort the dataArray
dataArray = arrayOfCEDataSort(dataArray, variables.ORDER_FIELD);
}
else {
dataArray = ArrayNew(1);
}
}