You are here

function _l10n_update_source_compare in Localization update 7.2

Same name and namespace in other branches
  1. 6 l10n_update.check.inc \_l10n_update_source_compare()
  2. 7 l10n_update.check.inc \_l10n_update_source_compare()

Compare two update sources, looking for the newer one.

The timestamp property of the source objects are used to determine which is the newer one.

Parameters

object $source1: Source object of the first translation source.

object $source2: Source object of available update.

Return value

int

  • "L10N_UPDATE_SOURCE_COMPARE_LT": $source1 < $source2 OR $source1 is missing.
  • "L10N_UPDATE_SOURCE_COMPARE_EQ": $source1 == $source2 OR both $source1 and $source2 are missing.
  • "L10N_UPDATE_SOURCE_COMPARE_EQ": $source1 > $source2 OR $source2 is missing.
1 call to _l10n_update_source_compare()
l10n_update_status_form in ./l10n_update.admin.inc
Page callback: Translation status page.

File

./l10n_update.translation.inc, line 400
Common API for interface translation.

Code

function _l10n_update_source_compare($source1, $source2) {
  if (isset($source1->timestamp) && isset($source2->timestamp)) {
    if ($source1->timestamp == $source2->timestamp) {
      return L10N_UPDATE_SOURCE_COMPARE_EQ;
    }
    else {
      return $source1->timestamp > $source2->timestamp ? L10N_UPDATE_SOURCE_COMPARE_GT : L10N_UPDATE_SOURCE_COMPARE_LT;
    }
  }
  elseif (isset($source1->timestamp) && !isset($source2->timestamp)) {
    return L10N_UPDATE_SOURCE_COMPARE_GT;
  }
  elseif (!isset($source1->timestamp) && isset($source2->timestamp)) {
    return L10N_UPDATE_SOURCE_COMPARE_LT;
  }
  else {
    return L10N_UPDATE_SOURCE_COMPARE_EQ;
  }
}