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',
),
),
),
);
}
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | new_hooks_01.patch | 19.75 KB | xano |
| #2 | hook_02.patch | 20.58 KB | xano |
Comments
Comment #1
xanoFor 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.
Comment #2
xanoThe attached patch updates the current dev release. Hook implementations are as follows:
Possible language codes are listed in _locale_get_predefined_list (not all are ISO 639-1). As mentioned before,
allis 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.Comment #3
xanoFollow-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.
Comment #5
xano