updated rules
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
class RulesI18nStringController extends EntityDefaultI18nStringController {
|
||||
|
||||
/**
|
||||
* Overriden to customize i18n object info.
|
||||
* Overridden to customize i18n object info.
|
||||
*
|
||||
* @see EntityDefaultI18nStringController::hook_object_info()
|
||||
*/
|
||||
@@ -22,7 +22,7 @@ class RulesI18nStringController extends EntityDefaultI18nStringController {
|
||||
}
|
||||
|
||||
/**
|
||||
* Overriden to customize the used menu wildcard.
|
||||
* Overridden to customize the used menu wildcard.
|
||||
*/
|
||||
protected function menuWildcard() {
|
||||
return '%rules_config';
|
||||
@@ -34,6 +34,7 @@ class RulesI18nStringController extends EntityDefaultI18nStringController {
|
||||
protected function menuBasePath() {
|
||||
return 'admin/config/workflow/rules/reaction';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,7 +43,7 @@ class RulesI18nStringController extends EntityDefaultI18nStringController {
|
||||
class RulesI18nStringObjectWrapper extends i18n_string_object_wrapper {
|
||||
|
||||
/**
|
||||
* Get translatable properties
|
||||
* Get translatable properties.
|
||||
*/
|
||||
protected function build_properties() {
|
||||
$strings = parent::build_properties();
|
||||
@@ -91,4 +92,5 @@ class RulesI18nStringObjectWrapper extends i18n_string_object_wrapper {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -7,9 +7,9 @@ core = 7.x
|
||||
files[] = rules_i18n.i18n.inc
|
||||
files[] = rules_i18n.rules.inc
|
||||
files[] = rules_i18n.test
|
||||
; Information added by drupal.org packaging script on 2013-03-27
|
||||
version = "7.x-2.3"
|
||||
|
||||
; Information added by Drupal.org packaging script on 2019-01-24
|
||||
version = "7.x-2.12"
|
||||
core = "7.x"
|
||||
project = "rules"
|
||||
datestamp = "1364401818"
|
||||
|
||||
datestamp = "1548305586"
|
||||
|
19
sites/all/modules/rules/rules_i18n/rules_i18n.install
Normal file
19
sites/all/modules/rules/rules_i18n/rules_i18n.install
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Install file for Rules i18n.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_install().
|
||||
*/
|
||||
function rules_i18n_install() {
|
||||
global $language;
|
||||
|
||||
$langcode = $language->language;
|
||||
drupal_static_reset('i18n_object_info');
|
||||
drupal_static_reset('entity_get_info');
|
||||
drupal_static_reset('entity_i18n_controller');
|
||||
cache_clear_all("entity_info:$langcode", 'cache');
|
||||
}
|
@@ -5,7 +5,6 @@
|
||||
* Rules i18n integration.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Implements hook_menu().
|
||||
*/
|
||||
@@ -111,7 +110,10 @@ function rules_i18n_rules_config_update($rules_config, $original = NULL) {
|
||||
* Implements hook_rules_config_delete().
|
||||
*/
|
||||
function rules_i18n_rules_config_delete($rules_config) {
|
||||
i18n_string_object_remove('rules_config', $rules_config);
|
||||
// Only react on real delete, not revert.
|
||||
if (!$rules_config->hasStatus(ENTITY_IN_CODE)) {
|
||||
i18n_string_object_remove('rules_config', $rules_config);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -115,7 +115,7 @@ function rules_i18n_rules_evaluator_info() {
|
||||
'type' => array('text', 'list<text>', 'token', 'list<token>'),
|
||||
// Be sure to translate after doing PHP evaluation.
|
||||
'weight' => -8,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -128,6 +128,9 @@ class RulesI18nStringEvaluator extends RulesDataInputEvaluator {
|
||||
return user_access('translate admin strings');
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides RulesDataInputEvaluator::prepare().
|
||||
*/
|
||||
public function prepare($text, $var_info, $param_info = NULL) {
|
||||
if (!empty($param_info['translatable'])) {
|
||||
$this->setting = TRUE;
|
||||
@@ -177,9 +180,12 @@ class RulesI18nStringEvaluator extends RulesDataInputEvaluator {
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides RulesDataInputEvaluator::help().
|
||||
*/
|
||||
public static function help($var_info, $param_info = array()) {
|
||||
if (!empty($param_info['translatable'])) {
|
||||
if ($param_info['custom translation language']) {
|
||||
if (!empty($param_info['custom translation language'])) {
|
||||
$text = t('Translations can be provided at the %translate tab. The argument value is translated to the configured language.', array('%translate' => t('Translate')));
|
||||
}
|
||||
else {
|
||||
@@ -193,4 +199,5 @@ class RulesI18nStringEvaluator extends RulesDataInputEvaluator {
|
||||
return $render;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -10,6 +10,9 @@
|
||||
*/
|
||||
class RulesI18nTestCase extends DrupalWebTestCase {
|
||||
|
||||
/**
|
||||
* Declares test metadata.
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Rules I18n',
|
||||
@@ -19,7 +22,10 @@ class RulesI18nTestCase extends DrupalWebTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
/**
|
||||
* Overrides DrupalWebTestCase::setUp().
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp('rules_i18n');
|
||||
$this->admin_user = $this->drupalCreateUser(array('bypass node access', 'administer nodes', 'administer languages', 'administer content types', 'administer blocks', 'access administration pages'));
|
||||
$this->drupalLogin($this->admin_user);
|
||||
@@ -52,11 +58,11 @@ class RulesI18nTestCase extends DrupalWebTestCase {
|
||||
}
|
||||
elseif ($this->xpath('//input[@type="checkbox" and @name=:name and @checked="checked"]', array(':name' => 'enabled[' . $language_code . ']'))) {
|
||||
// It's installed and enabled. No need to do anything.
|
||||
$this->assertTrue(true, 'Language [' . $language_code . '] already installed and enabled.');
|
||||
$this->assertTrue(TRUE, 'Language [' . $language_code . '] already installed and enabled.');
|
||||
}
|
||||
else {
|
||||
// It's installed but not enabled. Enable it.
|
||||
$this->assertTrue(true, 'Language [' . $language_code . '] already installed.');
|
||||
$this->assertTrue(TRUE, 'Language [' . $language_code . '] already installed.');
|
||||
$this->drupalPost(NULL, array('enabled[' . $language_code . ']' => TRUE), t('Save configuration'));
|
||||
$this->assertRaw(t('Configuration saved.'), t('Language successfully enabled.'));
|
||||
}
|
||||
@@ -139,7 +145,7 @@ class RulesI18nTestCase extends DrupalWebTestCase {
|
||||
$messages = drupal_get_messages();
|
||||
$this->assertEqual($messages['status'][0], 'text-de', 'Text has been successfully translated.');
|
||||
|
||||
// Enable the PHP module and make sure PHP in translations is not evaluted.
|
||||
// Enable the PHP module and make sure PHP in translations is not evaluated.
|
||||
module_enable(array('php'));
|
||||
i18n_string_textgroup('rules')->update_translation("rules_config:{$set->name}:$id:text", 'de', 'text <?php echo "eval";?>');
|
||||
|
||||
@@ -162,9 +168,9 @@ class RulesI18nTestCase extends DrupalWebTestCase {
|
||||
|
||||
$set = rules_action_set(array('node' => array('type' => 'node')));
|
||||
$set->action('rules_i18n_select', array(
|
||||
'data:select' => 'node:body:value',
|
||||
'language' => 'de',
|
||||
'data_translated:var' => 'body',
|
||||
'data:select' => 'node:body:value',
|
||||
'language' => 'de',
|
||||
'data_translated:var' => 'body',
|
||||
));
|
||||
$set->action('drupal_message', array('message:select' => 'body'));
|
||||
$set->save();
|
||||
@@ -180,4 +186,5 @@ class RulesI18nTestCase extends DrupalWebTestCase {
|
||||
$messages = drupal_get_messages();
|
||||
$this->assertEqual($messages['status'][0], "German body.\n", 'Translated text has been selected.');
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user