public static function LingotekSync::getDownloadableReport in Lingotek Translation 7.4
Same name and namespace in other branches
- 7.7 lib/Drupal/lingotek/LingotekSync.php \LingotekSync::getDownloadableReport()
- 7.3 lib/Drupal/lingotek/LingotekSync.php \LingotekSync::getDownloadableReport()
- 7.5 lib/Drupal/lingotek/LingotekSync.php \LingotekSync::getDownloadableReport()
- 7.6 lib/Drupal/lingotek/LingotekSync.php \LingotekSync::getDownloadableReport()
1 call to LingotekSync::getDownloadableReport()
- LingotekSync::getReport in lib/
Drupal/ lingotek/ LingotekSync.php
File
- lib/
Drupal/ lingotek/ LingotekSync.php, line 262 - LingotekSync
Class
- LingotekSync
- A utility class for Lingotek Syncing.
Code
public static function getDownloadableReport() {
$document_ids = array_unique(array_merge(self::getDocIdsByStatus(self::STATUS_PENDING, FALSE), self::getDocIdsByStatus(self::STATUS_READY, FALSE)));
$report = array(
'download_targets_workflow_complete' => array(),
// workflow complete and ready for download
'download_targets_workflow_complete_count' => 0,
'download_workflow_complete_targets' => array(),
'download_targets_workflow_incomplete' => array(),
// not workflow complete (but download if wanted)
'download_targets_workflow_incomplete_count' => 0,
'download_workflow_incomplete_targets' => array(),
);
if (empty($document_ids)) {
return $report;
}
// if no documents are PENDING, then no need to make the API call.
$response = lingotek_get_and_update_target_progress($document_ids);
$locales = lingotek_get_target_locales();
foreach ($document_ids as $document_id) {
if (!$document_id) {
continue;
}
foreach ($locales as $locale) {
if (isset($response->byDocumentIdAndTargetLocale->{$document_id}->{$locale})) {
$target_status = self::getTargetStatus($document_id, $locale);
$doc_target = array(
'document_id' => $document_id,
'locale' => $locale,
'percent_complete' => $response->byDocumentIdAndTargetLocale->{$document_id}->{$locale},
);
if ($target_status == self::STATUS_READY) {
$report['download_targets_workflow_complete'][] = $doc_target;
$report['download_targets_workflow_complete_count']++;
}
elseif ($target_status == self::STATUS_PENDING) {
$report['download_targets_workflow_incomplete'][] = $doc_target;
$report['download_targets_workflow_incomplete_count']++;
}
}
}
}
/*
if (isset($response->byDocumentIdAndTargetLocale)) {
$status_by_doc = $response->byDocumentIdAndTargetLocale;
}
if (isset($response->byTargetLocale)) {
$status_by_locale = $response->byTargetLocale;
}
if (isset($response->workflowCompletedByDocumentIdAndTargetLocale)) {
$progress_report = $response->workflowCompletedByDocumentIdAndTargetLocale;
foreach ($progress_report as $doc_id => $target_locales) {
foreach ($target_locales as $lingotek_locale => $workflow_completed) {
if (isset($status_by_doc->$doc_id) && isset($status_by_doc->$doc_id->$lingotek_locale)) {
$status = $status_by_doc->$doc_id->$lingotek_locale;
}
$doc_target = array(
'document_id' => $doc_id,
'locale' => $lingotek_locale,
'percent_complete' => $status,
);
$target_status = self::getTargetStatus($doc_id, $lingotek_locale);
if ($workflow_completed && $target_status != self::STATUS_EDITED && $target_status != self::STATUS_DISABLED) {
if ($target_status == self::STATUS_READY || $target_status == self::STATUS_PENDING) {
$report['download_targets_workflow_complete'][] = $doc_target;
$report['download_targets_workflow_complete_count']++;
}
else {
// Target already downloaded
}
}
elseif (!$workflow_completed) {
$report['download_targets_workflow_incomplete'][] = $doc_target;
$report['download_targets_workflow_incomplete_count']++;
}
}
}
}
*/
return $report;
}