/** * Return list of available data exporters * * @param int $pn_table_num * @param array $pa_options * countOnly = return number of exporters available rather than a list of exporters * * @return mixed List of exporters, or integer count of exporters if countOnly option is set */ public static function getExporters($pn_table_num = null, $pa_options = null) { $o_db = new Db(); $t_exporter = new ca_data_exporters(); $vo_dm = $t_exporter->getAppDatamodel(); $va_sql_params = array(); if ((int) $pn_table_num) { $va_sql_wheres[] = "(de.table_num = ?)"; $va_sql_params[] = (int) $pn_table_num; } $vs_sql_wheres = sizeof($va_sql_wheres) ? " WHERE " . join(" AND ", $va_sql_wheres) : ""; $qr_res = $o_db->query("\n\t\t\tSELECT *\n\t\t\tFROM ca_data_exporters de\n\t\t\t{$vs_sql_wheres}\n\t\t", $va_sql_params); $va_exporters = array(); $va_ids = array(); if (isset($pa_options['countOnly']) && $pa_options['countOnly']) { return (int) $qr_res->numRows(); } while ($qr_res->nextRow()) { $va_row = $qr_res->getRow(); $va_ids[] = $vn_id = $va_row['exporter_id']; $va_exporters[$vn_id] = $va_row; $t_instance = $vo_dm->getInstanceByTableNum($va_row['table_num'], true); $va_exporters[$vn_id]['exporter_type'] = $t_instance->getProperty('NAME_PLURAL'); $va_exporters[$vn_id]['exporter_type_singular'] = $t_instance->getProperty('NAME_SINGULAR'); $va_exporters[$vn_id]['settings'] = caUnserializeForDatabase($va_row['settings']); $va_exporters[$vn_id]['last_modified_on'] = $t_exporter->getLastChangeTimestamp($vn_id, array('timestampOnly' => true)); } $va_labels = $t_exporter->getPreferredDisplayLabelsForIDs($va_ids); foreach ($va_labels as $vn_id => $vs_label) { $va_exporters[$vn_id]['label'] = $vs_label; } return $va_exporters; }