/**
  * Returns list of caption/subtitle files attached to a representation
  * The return value is an array key'ed on the caption_id; array values are arrays
  * with keys set to values for each file returned. They keys are:
  *		path = The absolute file path to the file
  *		url = The URL for the file
  *		caption_id = a unique identifier for each attached caption file
  *
  * @param int $pn_representation_id The representation_id of the representation to return files for. If omitted the currently loaded representation is used. If no representation_id is specified and no row is loaded null will be returned.
  * @param array $pa_locale_ids 
  * @param array $pa_options
  * @return array A list of caption files attached to the representations. If no files are associated an empty array is returned.
  */
 public function getCaptionFileList($pn_representation_id = null, $pa_locale_ids = null, $pa_options = null)
 {
     if (!($vn_representation_id = $pn_representation_id)) {
         if (!($vn_representation_id = $this->getPrimaryKey())) {
             return null;
         }
     }
     $t_locale = new ca_locales();
     $va_locale_ids = array();
     if ($pa_locale_ids) {
         if (!is_array($pa_locale_ids)) {
             $pa_locale_ids = array($pa_locale_ids);
         }
         foreach ($pa_locale_ids as $vn_i => $vm_locale) {
             if (is_numeric($vm_locale) && (int) $vm_locale) {
                 $va_locale_ids[] = (int) $vm_locale;
             } else {
                 if ($vn_locale_id = $t_locale->localeCodeToID($vm_locale)) {
                     $va_locale_ids[] = $vn_locale_id;
                 }
             }
         }
     }
     $vs_locale_sql = '';
     $va_params = array((int) $vn_representation_id);
     if (sizeof($va_locale_ids) > 0) {
         $vs_locale_sql = " AND locale_id IN (?)";
         $va_params[] = $va_locale_ids;
     }
     $o_db = $this->getDb();
     $qr_res = $o_db->query("\n \t\t\tSELECT *\n \t\t\tFROM ca_object_representation_captions\n \t\t\tWHERE\n \t\t\t\trepresentation_id = ?\n \t\t\t{$vs_locale_sql}\n \t\t", $va_params);
     $va_files = array();
     while ($qr_res->nextRow()) {
         $vn_caption_id = $qr_res->get('caption_id');
         $vn_locale_id = $qr_res->get('locale_id');
         $va_files[$vn_caption_id] = $qr_res->getRow();
         unset($va_files[$vn_caption_id]['caption_file']);
         $va_files[$vn_caption_id]['path'] = $qr_res->getFilePath('caption_file');
         $va_files[$vn_caption_id]['url'] = $qr_res->getFileUrl('caption_file');
         $va_files[$vn_caption_id]['filesize'] = caFormatFileSize(filesize($va_files[$vn_caption_id]['path']));
         $va_files[$vn_caption_id]['caption_id'] = $vn_caption_id;
         $va_files[$vn_caption_id]['locale_id'] = $vn_locale_id;
         $va_files[$vn_caption_id]['locale'] = $t_locale->localeIDToName($vn_locale_id);
         $va_files[$vn_caption_id]['locale_code'] = $t_locale->localeIDToCode($vn_locale_id);
     }
     return $va_files;
 }