Adding hook_atr_review_info() allows for pluggable and language-dependent review methods. With the example below we define review callbacks for review methods on a per-language basis. Languages are defined according to ISO 639-1. all is used if a callback is language independent.

function hook_atr_review_info() {
  return array(
    'similarity' => array( // The review method.
      '#title' => t('Similarity'),
      '#reviews' => array(
        'all' => array( // This review function is for texts from all languages.
          '#callback' => 'atr_review_similar',
          '#module' 'atr',
          '#file' => 'includes/atr.review.inc',
        ),
      ),
    ),
    'blacklist' => array( // The review method.
      '#title' => t('Blacklist'),
      '#reviews' => array(
        'en' => array( // This review function is for English texts only.
          '#callback' => 'atr_review_blacklist_en',
          '#module' 'atr',
          '#file' => 'includes/atr.review.inc',
        ),
      ),
    ),
    'summary' => array( // The review method.
      '#title' => t('Summaries'),
      '#reviews' => array(
        'en' => array( // This review function is for English texts only.
          '#callback' => 'atr_review_summary_en',
          '#module' 'atr',
          '#file' => 'includes/atr.review.inc',
        ),
        'nl' => array( // This review function is for Dutch texts only.
          '#callback' => 'atr_review_summary_nl',
          '#module' 'atr',
          '#file' => 'includes/atr.review.inc',
        ),
      ),
    ),
  );
}
CommentFileSizeAuthor
#3 new_hooks_01.patch19.75 KBxano
#2 hook_02.patch20.58 KBxano

Comments

xano’s picture

Assigned: Unassigned » xano

For every method a callback for all languages may be defined as well as language specific callbacks. If there is no callback available for the language set for a review the 'all' callback will be used.

xano’s picture

Status: Active » Fixed
StatusFileSize
new20.58 KB

The attached patch updates the current dev release. Hook implementations are as follows:

/**
 * Define review methods.
 *
 * @return
 *  An associative array.
 */
function hook_atr_review_info() {
  return array(
    'similarity' => array( // The review method.
      'all' => array( // Two-character language code as defined in
      // _locale_get_predefined_list or 'all' to define the languages this
      // callback can review.
        '#callback' => 'atr_review_similar', // The name of the function.
        '#module' => 'atr', // The module this function is from.
        '#file' => 'includes/atr.review.inc', // The file within the module's
        // directory the callback is located in.
      ),
    ),
    'blacklist' => array( // The review method.
      'en' => array( // Two-character language code as defined in
      // _locale_get_predefined_list or 'all' to define the languages this
      // callback can review.
        '#callback' => 'atr_review_blacklist', // The name of the function.
        '#module' => 'atr', // The module this function is from.
        '#file' => 'includes/atr.review.inc', // The file within the module's
        // directory the callback is located in.
      ),
    ),
  );
}

Possible language codes are listed in _locale_get_predefined_list (not all are ISO 639-1). As mentioned before, all is a possible code as well. Modules may use this hook to add review methods and callbacks for them. They can add callbacks for different languages by simply defining callbacks for a review method's system name.

xano’s picture

StatusFileSize
new19.75 KB

Follow-up patch changing hook_atr_review_info() to hook_atr_method_info() and adding hook_atr_method_callback(). These hooks allow modules to define review methods and language-specific callbacks for every part of the review process. For the actual review a combination of language-specific callbacks can be used, depending on what's available. A process callback may be available for all languages, while only the review callback is language-specific. For language-independent profiles this results in 'all' callbacks for the process and review states, while for English texts this results in the process callback being for 'all' and the review callback being for 'en'. hook_atr_method_info() also allows fieldsets with "Enabled" checkboxes and the necessary JS to show and hide optional extra settings to be added to the settings profiles form automatically.

The patch has been committed to atr-6.x-1.x-dev.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

xano’s picture

Assigned: xano » Unassigned