Révision 6331c987
Ajouté par Assos Assos il y a environ 10 ans
drupal7/sites/all/modules/i18n/i18n.info | ||
---|---|---|
8 | 8 |
files[] = i18n.test |
9 | 9 |
configure = admin/config/regional/i18n |
10 | 10 |
|
11 |
; Information added by drupal.org packaging script on 2013-08-21
|
|
12 |
version = "7.x-1.10"
|
|
11 |
; Information added by Drupal.org packaging script on 2014-04-16
|
|
12 |
version = "7.x-1.11"
|
|
13 | 13 |
core = "7.x" |
14 | 14 |
project = "i18n" |
15 |
datestamp = "1377069696"
|
|
15 |
datestamp = "1397666996"
|
|
16 | 16 |
|
drupal7/sites/all/modules/i18n/i18n.install | ||
---|---|---|
22 | 22 |
} |
23 | 23 |
|
24 | 24 |
/** |
25 |
* Add fields to schema if they don't exist |
|
25 |
* Add fields to the schema if they don't exist. |
|
26 |
* |
|
27 |
* @param string $table |
|
28 |
* The name of the database table. |
|
29 |
* @param array $fields |
|
30 |
* The list of database fields to create. |
|
31 |
* @param boolean $force_rebuild_schema |
|
32 |
* Whether to force drupal_get_schema() to rebuild the schema. This may be |
|
33 |
* necessary when additional implementations of hook_schema_alter() have |
|
34 |
* become available since the schema was originally built. |
|
26 | 35 |
*/ |
27 |
function i18n_install_create_fields($table, $fields) { |
|
36 |
function i18n_install_create_fields($table, $fields, $force_rebuild_schema = FALSE) {
|
|
28 | 37 |
static $schema; |
29 |
// Do not force schema refresh more than once per request.
|
|
30 |
$schema = drupal_get_schema($table, !isset($schema));
|
|
38 |
$rebuild_schema = !isset($schema) || $force_rebuild_schema;
|
|
39 |
$schema = drupal_get_schema($table, $rebuild_schema);
|
|
31 | 40 |
foreach ($fields as $field) { |
32 | 41 |
if (!empty($schema['fields'][$field])) { |
33 | 42 |
if (!db_field_exists($table, $field)) { |
drupal7/sites/all/modules/i18n/i18n.module | ||
---|---|---|
498 | 498 |
* |
499 | 499 |
* @param $path |
500 | 500 |
* Path to get translations for or '<front>' for front page. |
501 |
* @param $check_access |
|
502 |
* Whether to check access to paths, defaults to TRUE |
|
501 | 503 |
*/ |
502 |
function i18n_get_path_translations($path) { |
|
504 |
function i18n_get_path_translations($path, $check_access = TRUE) {
|
|
503 | 505 |
$translations = &drupal_static(__FUNCTION__); |
506 |
|
|
504 | 507 |
if (!isset($translations[$path])) { |
505 | 508 |
$translations[$path] = array(); |
506 | 509 |
foreach (module_implements('i18n_translate_path') as $module) { |
... | ... | |
510 | 513 |
$translations[$path] += $translated; |
511 | 514 |
} |
512 | 515 |
} |
516 |
// Add access information if not there. |
|
517 |
foreach ($translations[$path] as $langcode => &$info) { |
|
518 |
if (!isset($info['access'])) { |
|
519 |
$item = menu_get_item($info['href']); |
|
520 |
// If no menu item, it may be an external URL, we allow access. |
|
521 |
$info['access'] = $item ? !empty($item['access']) : TRUE; |
|
522 |
} |
|
523 |
} |
|
513 | 524 |
// Chance for altering the results. |
514 | 525 |
drupal_alter('i18n_translate_path', $translations[$path], $path); |
515 | 526 |
} |
516 |
return $translations[$path]; |
|
527 |
|
|
528 |
if ($check_access) { |
|
529 |
return array_filter($translations[$path], '_i18n_get_path_translations_access'); |
|
530 |
} |
|
531 |
else { |
|
532 |
return $translations[$path]; |
|
533 |
} |
|
534 |
} |
|
535 |
|
|
536 |
/** |
|
537 |
* Helper function to check access to path translation. |
|
538 |
*/ |
|
539 |
function _i18n_get_path_translations_access($path) { |
|
540 |
return $path['access']; |
|
517 | 541 |
} |
518 | 542 |
|
519 | 543 |
/** |
drupal7/sites/all/modules/i18n/i18n_block/i18n_block.info | ||
---|---|---|
8 | 8 |
files[] = i18n_block.test |
9 | 9 |
|
10 | 10 |
|
11 |
; Information added by drupal.org packaging script on 2013-08-21
|
|
12 |
version = "7.x-1.10"
|
|
11 |
; Information added by Drupal.org packaging script on 2014-04-16
|
|
12 |
version = "7.x-1.11"
|
|
13 | 13 |
core = "7.x" |
14 | 14 |
project = "i18n" |
15 |
datestamp = "1377069696"
|
|
15 |
datestamp = "1397666996"
|
|
16 | 16 |
|
drupal7/sites/all/modules/i18n/i18n_contact/i18n_contact.info | ||
---|---|---|
5 | 5 |
package = Multilingual - Internationalization |
6 | 6 |
core = 7.x |
7 | 7 |
|
8 |
; Information added by drupal.org packaging script on 2013-08-21
|
|
9 |
version = "7.x-1.10"
|
|
8 |
; Information added by Drupal.org packaging script on 2014-04-16
|
|
9 |
version = "7.x-1.11"
|
|
10 | 10 |
core = "7.x" |
11 | 11 |
project = "i18n" |
12 |
datestamp = "1377069696"
|
|
12 |
datestamp = "1397666996"
|
|
13 | 13 |
|
drupal7/sites/all/modules/i18n/i18n_field/i18n_field.i18n.inc | ||
---|---|---|
72 | 72 |
'description' => t('Configurable fields descriptions, defaults, options, etc.'), |
73 | 73 |
'format' => FALSE, // This group doesn't have formatted strings |
74 | 74 |
'list' => TRUE, // This group can list all strings |
75 |
'class' => 'i18n_string_textgroup_cached', |
|
75 | 76 |
); |
76 | 77 |
return $groups; |
77 | 78 |
} |
drupal7/sites/all/modules/i18n/i18n_field/i18n_field.info | ||
---|---|---|
6 | 6 |
core = 7.x |
7 | 7 |
files[] = i18n_field.inc |
8 | 8 |
files[] = i18n_field.test |
9 |
; Information added by drupal.org packaging script on 2013-08-21
|
|
10 |
version = "7.x-1.10"
|
|
9 |
; Information added by Drupal.org packaging script on 2014-04-16
|
|
10 |
version = "7.x-1.11"
|
|
11 | 11 |
core = "7.x" |
12 | 12 |
project = "i18n" |
13 |
datestamp = "1377069696"
|
|
13 |
datestamp = "1397666996"
|
|
14 | 14 |
|
drupal7/sites/all/modules/i18n/i18n_forum/i18n_forum.info | ||
---|---|---|
7 | 7 |
core = 7.x |
8 | 8 |
files[] = i18n_forum.test |
9 | 9 |
|
10 |
; Information added by drupal.org packaging script on 2013-08-21
|
|
11 |
version = "7.x-1.10"
|
|
10 |
; Information added by Drupal.org packaging script on 2014-04-16
|
|
11 |
version = "7.x-1.11"
|
|
12 | 12 |
core = "7.x" |
13 | 13 |
project = "i18n" |
14 |
datestamp = "1377069696"
|
|
14 |
datestamp = "1397666996"
|
|
15 | 15 |
|
drupal7/sites/all/modules/i18n/i18n_forum/i18n_forum.module | ||
---|---|---|
35 | 35 |
if ($vid && ($vocabulary = taxonomy_vocabulary_load($vid)) && ($field = field_info_field('taxonomy_' . $vocabulary->machine_name))) { |
36 | 36 |
foreach ($field['bundles']['node'] as $type) { |
37 | 37 |
if (isset($data['actions']['output'][$type])) { |
38 |
$data['actions']['output'][$type]['#link']['title'] = t('Add new @node_type', array('@node_type' => i18n_node_type_name($type, node_type_get_name($type))));
|
|
38 |
$data['actions']['output'][$type]['#link']['title'] = t('Add new @node_type', array('@node_type' => i18n_node_type_name($type))); |
|
39 | 39 |
} |
40 | 40 |
} |
41 | 41 |
} |
drupal7/sites/all/modules/i18n/i18n_menu/i18n_menu.admin.inc | ||
---|---|---|
10 | 10 |
* Produces a menu translation form. |
11 | 11 |
*/ |
12 | 12 |
function i18n_menu_translation_form($form, $form_state, $translation_set = NULL, $item = NULL) { |
13 |
$translation_set = $translation_set ? $translation_set : i18n_translation_set_create('menu_link');
|
|
13 |
$translation_set = $translation_set ? $translation_set : i18n_translation_set_build('menu_link');
|
|
14 | 14 |
$form['translation_set'] = array('#type' => 'value', '#value' => $translation_set); |
15 | 15 |
$translations = $translation_set->get_translations(); |
16 | 16 |
// What to do with title? Let's make it a hidden field for now, some tests relay on it |
... | ... | |
55 | 55 |
} |
56 | 56 |
$form['actions'] = array('#type' => 'actions'); |
57 | 57 |
$form['actions']['update'] = array('#type' => 'submit', '#value' => t('Save')); |
58 |
if ($translation_set) {
|
|
58 |
if (!empty($translation_set->tsid)) {
|
|
59 | 59 |
$form['actions']['delete'] = array('#type' => 'submit', '#value' => t('Delete')); |
60 | 60 |
} |
61 | 61 |
return $form; |
... | ... | |
244 | 244 |
$title = t('n/a'); |
245 | 245 |
$options[] = l(t('add translation'), 'admin/structure/menu/manage/' . $item['menu_name'] . '/add', array('query' => array('translation' => $item['mlid'], 'target' => $langcode) + drupal_get_destination())); |
246 | 246 |
} |
247 |
$rows[] = array($language_name, $title, implode(" | ", $options)); |
|
247 |
$rows[$langcode] = array( |
|
248 |
'language' => $language_name, |
|
249 |
'title' => $title, |
|
250 |
'operations' => implode(" | ", $options) |
|
251 |
); |
|
248 | 252 |
} |
249 | 253 |
|
250 | 254 |
drupal_set_title(t('Translations of menu item %title', array('%title' => $item['link_title'])), PASS_THROUGH); |
251 | 255 |
|
252 |
$build['translation_item_overview'] = array(
|
|
256 |
$build['translation_overview'] = array( |
|
253 | 257 |
'#theme' => 'table', |
254 | 258 |
'#header' => $header, |
255 | 259 |
'#rows' => $rows, |
drupal7/sites/all/modules/i18n/i18n_menu/i18n_menu.i18n.inc | ||
---|---|---|
123 | 123 |
module_load_include('admin.inc', 'i18n_menu'); |
124 | 124 |
// If the item has a language code, we can only support translation sets. |
125 | 125 |
$translation_set = !empty($item['i18n_tsid']) ? i18n_translation_set_load($item['i18n_tsid']) : NULL; |
126 |
$build['overview'] = i18n_menu_translation_item_overview($item, $translation_set);
|
|
127 |
$build['translation_form'] = drupal_get_form('i18n_menu_translation_form', $translation_set, $item);
|
|
128 |
return $build;
|
|
126 |
$overview = i18n_menu_translation_item_overview($item, $translation_set);
|
|
127 |
$translation_form = drupal_get_form('i18n_menu_translation_form', $translation_set, $item);
|
|
128 |
return $overview + $translation_form;
|
|
129 | 129 |
} |
130 | 130 |
|
drupal7/sites/all/modules/i18n/i18n_menu/i18n_menu.info | ||
---|---|---|
10 | 10 |
files[] = i18n_menu.inc |
11 | 11 |
files[] = i18n_menu.test |
12 | 12 |
|
13 |
; Information added by drupal.org packaging script on 2013-08-21
|
|
14 |
version = "7.x-1.10"
|
|
13 |
; Information added by Drupal.org packaging script on 2014-04-16
|
|
14 |
version = "7.x-1.11"
|
|
15 | 15 |
core = "7.x" |
16 | 16 |
project = "i18n" |
17 |
datestamp = "1377069696"
|
|
17 |
datestamp = "1397666996"
|
|
18 | 18 |
|
drupal7/sites/all/modules/i18n/i18n_menu/i18n_menu.module | ||
---|---|---|
529 | 529 |
return FALSE; |
530 | 530 |
} |
531 | 531 |
} |
532 |
// Skip if administering this menu item through the node edit form. |
|
533 |
elseif (arg(0) == 'node' && arg(2) == 'edit') { |
|
534 |
return FALSE; |
|
535 |
} |
|
532 | 536 |
return TRUE; |
533 | 537 |
} |
534 | 538 |
else { |
drupal7/sites/all/modules/i18n/i18n_menu/i18n_menu.test | ||
---|---|---|
130 | 130 |
$this->drupalGet('admin/structure/menu/item/' . $node->menu['mlid'] . '/edit'); |
131 | 131 |
$this->assertText(t('This menu item belongs to a node, so it will have the same language as the node and cannot be localized.')); |
132 | 132 |
$this->assertNoField('language', 'We cannot edit language for menu items that belong to nodes.'); |
133 |
// Edit the node and submit it to see if the menu link stays enabled. |
|
134 |
$this->drupalPost('node/' . $node->nid . '/edit', array(), t('Save')); |
|
133 | 135 |
} |
134 | 136 |
// Check menu items show up for the right language. |
135 | 137 |
$this->drupalGet('<front>'); |
drupal7/sites/all/modules/i18n/i18n_node/i18n_node.info | ||
---|---|---|
9 | 9 |
files[]=i18n_node.test |
10 | 10 |
files[]=i18n_node.variable.inc |
11 | 11 |
|
12 |
; Information added by drupal.org packaging script on 2013-08-21
|
|
13 |
version = "7.x-1.10"
|
|
12 |
; Information added by Drupal.org packaging script on 2014-04-16
|
|
13 |
version = "7.x-1.11"
|
|
14 | 14 |
core = "7.x" |
15 | 15 |
project = "i18n" |
16 |
datestamp = "1377069696"
|
|
16 |
datestamp = "1397666996"
|
|
17 | 17 |
|
drupal7/sites/all/modules/i18n/i18n_node/i18n_node.module | ||
---|---|---|
54 | 54 |
$arg = drupal_help_arg(arg(NULL)); |
55 | 55 |
if ($arg[0] == 'node' && $arg[1] == 'add' && $arg[2]) { |
56 | 56 |
if (($type = node_type_get_type(str_replace('-', '_', $arg[2]))) && !empty($type->help)) { |
57 |
$help = i18n_node_translate_type($type, 'help'); |
|
57 |
$help = i18n_node_translate_type($type, 'help', NULL, array('sanitize' => FALSE));
|
|
58 | 58 |
if ($help !== $type->help) { |
59 | 59 |
$block['content'] = str_replace(filter_xss_admin($type->help), filter_xss_admin($help), $block['content']); |
60 | 60 |
} |
... | ... | |
64 | 64 |
$node = menu_get_object(); |
65 | 65 |
if ($node && isset($node->type)) { |
66 | 66 |
$type = node_type_get_type($node->type); |
67 |
$help = i18n_node_translate_type($type, 'help'); |
|
67 |
$help = i18n_node_translate_type($type, 'help', NULL, array('sanitize' => FALSE));
|
|
68 | 68 |
if ($help !== $type->help) { |
69 | 69 |
$block['content'] = str_replace(filter_xss_admin($type->help), filter_xss_admin($help), $block['content']); |
70 | 70 |
} |
... | ... | |
121 | 121 |
'href' => 'node/' . $node_translation->nid . $matches[2], |
122 | 122 |
'title' => $node_translation->title, |
123 | 123 |
'object' => $node_translation, |
124 |
// Performance: for node view add access information right away. |
|
125 |
'access' => !$matches[2] ? $node_translation->status : NULL, |
|
124 | 126 |
); |
125 | 127 |
} |
126 | 128 |
return $result; |
... | ... | |
347 | 349 |
static $sent = FALSE; |
348 | 350 |
|
349 | 351 |
// Ensure we send the Javascript only once. |
350 |
if (!$sent && isset($element['#autocomplete_path']) && !empty($element['#autocomplete_path']) && variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE) != LANGUAGE_NEGOTIATION_NONE) {
|
|
352 |
if (!$sent && isset($element['#autocomplete_path']) && !empty($element['#autocomplete_path']) && variable_get('language_negotiation', LANGUAGE_NEGOTIATION_DEFAULT) != LANGUAGE_NEGOTIATION_DEFAULT) {
|
|
351 | 353 |
// Add a JS file for node forms. |
352 | 354 |
// Determine if we are either editing or translating an existing node. |
353 | 355 |
// We can't act on regular node creation because we don't have a specified |
... | ... | |
442 | 444 |
* |
443 | 445 |
* @see http://drupal.org/node/765860 |
444 | 446 |
*/ |
445 |
|
|
447 |
|
|
446 | 448 |
// Replace core's node submit callback with our own, |
447 | 449 |
// in order to translate the node type name. |
448 | 450 |
$key = array_search('node_form_submit', $form['actions']['submit']['#submit']); |
... | ... | |
464 | 466 |
$insert = empty($node->nid); |
465 | 467 |
node_save($node); |
466 | 468 |
$node_link = l(t('view'), 'node/' . $node->nid); |
467 |
$type = node_type_get_type($node->type); |
|
468 |
$type_name = i18n_node_translate_type($type); |
|
469 |
$type_name = i18n_node_type_name($node->type); |
|
469 | 470 |
|
470 | 471 |
$watchdog_args = array('@type' => $node->type, '%title' => $node->title); |
471 | 472 |
$t_args = array('@type' => $type_name, '%title' => $node->title); |
... | ... | |
481 | 482 |
if ($node->nid) { |
482 | 483 |
$form_state['values']['nid'] = $node->nid; |
483 | 484 |
$form_state['nid'] = $node->nid; |
484 |
$form_state['redirect'] = 'node/' . $node->nid;
|
|
485 |
$form_state['redirect'] = node_access('view', $node) ? 'node/' . $node->nid : '<front>';
|
|
485 | 486 |
} |
486 | 487 |
else { |
487 | 488 |
// In the unlikely case something went wrong on save, the node will be |
... | ... | |
516 | 517 |
$form['body_field']['body']['#title'] = i18n_node_translate_type($node->type, 'body', $form['body_field']['body']['#title']); |
517 | 518 |
} |
518 | 519 |
// Translate page title for node/add/% and node/%/edit pages. |
519 |
$types = node_type_get_types(); |
|
520 | 520 |
if (empty($node->nid) && strpos($_GET['q'], 'node/add/' . str_replace('_', '-', $node->type)) === 0) { |
521 |
drupal_set_title(t('Create @name', array('@name' => i18n_node_translate_type($types[$node->type], 'name'))), PASS_THROUGH);
|
|
521 |
drupal_set_title(t('Create @name', array('@name' => i18n_node_type_name($node->type))), PASS_THROUGH);
|
|
522 | 522 |
} |
523 | 523 |
elseif (!empty($node->nid) && $_GET['q'] == 'node/' . $node->nid . '/edit') { |
524 |
drupal_set_title(t('<em>Edit @type</em> @title', array('@type' => i18n_node_translate_type($types[$node->type], 'name'), '@title' => $node->title)), PASS_THROUGH);
|
|
524 |
drupal_set_title(t('<em>Edit @type</em> @title', array('@type' => i18n_node_type_name($node->type), '@title' => $node->title)), PASS_THROUGH);
|
|
525 | 525 |
} |
526 | 526 |
return $form; |
527 | 527 |
} |
... | ... | |
553 | 553 |
} |
554 | 554 |
|
555 | 555 |
/** |
556 |
* Translate node type name (unfiltered) |
|
556 |
* Get translated node type name (unfiltered) |
|
557 |
* |
|
558 |
* @param string $type |
|
559 |
* Node type. |
|
560 |
* @param string $name |
|
561 |
* Optional node type name. |
|
557 | 562 |
*/ |
558 |
function i18n_node_type_name($type, $name) { |
|
559 |
return i18n_string_translate(array('node', 'type', $type, 'name'), $name); |
|
563 |
function i18n_node_type_name($type, $name = NULL) { |
|
564 |
$name = isset($name) ? $name : node_type_get_name($type); |
|
565 |
return i18n_string_translate(array('node', 'type', $type, 'name'), $name, array('sanitize' => FALSE)); |
|
560 | 566 |
} |
561 | 567 |
|
562 | 568 |
/** |
drupal7/sites/all/modules/i18n/i18n_node/i18n_node.pages.inc | ||
---|---|---|
25 | 25 |
if ($type) { |
26 | 26 |
// We just need to translate the description, the title is translated by the menu system |
27 | 27 |
// The string will be filtered (xss_admin) on the theme layer |
28 |
$item['description'] = i18n_node_translate_type($type, 'description', $item['description']); |
|
28 |
$item['description'] = i18n_node_translate_type($type, 'description', $item['description'], array('sanitize' => FALSE));
|
|
29 | 29 |
} |
30 | 30 |
} |
31 | 31 |
return theme('node_add_list', array('content' => $content)); |
drupal7/sites/all/modules/i18n/i18n_path/i18n_path.info | ||
---|---|---|
6 | 6 |
|
7 | 7 |
files[] = i18n_path.inc |
8 | 8 |
files[] = i18n_path.test |
9 |
; Information added by drupal.org packaging script on 2013-08-21
|
|
10 |
version = "7.x-1.10"
|
|
9 |
; Information added by Drupal.org packaging script on 2014-04-16
|
|
10 |
version = "7.x-1.11"
|
|
11 | 11 |
core = "7.x" |
12 | 12 |
project = "i18n" |
13 |
datestamp = "1377069696"
|
|
13 |
datestamp = "1397666996"
|
|
14 | 14 |
|
drupal7/sites/all/modules/i18n/i18n_redirect/i18n_redirect.info | ||
---|---|---|
4 | 4 |
package = Multilingual - Internationalization |
5 | 5 |
core = 7.x |
6 | 6 |
|
7 |
; Information added by drupal.org packaging script on 2013-08-21
|
|
8 |
version = "7.x-1.10"
|
|
7 |
; Information added by Drupal.org packaging script on 2014-04-16
|
|
8 |
version = "7.x-1.11"
|
|
9 | 9 |
core = "7.x" |
10 | 10 |
project = "i18n" |
11 |
datestamp = "1377069696"
|
|
11 |
datestamp = "1397666996"
|
|
12 | 12 |
|
drupal7/sites/all/modules/i18n/i18n_select/i18n_select.info | ||
---|---|---|
6 | 6 |
configure = admin/config/regional/i18n/select |
7 | 7 |
files[] = i18n_select.test |
8 | 8 |
|
9 |
; Information added by drupal.org packaging script on 2013-08-21
|
|
10 |
version = "7.x-1.10"
|
|
9 |
; Information added by Drupal.org packaging script on 2014-04-16
|
|
10 |
version = "7.x-1.11"
|
|
11 | 11 |
core = "7.x" |
12 | 12 |
project = "i18n" |
13 |
datestamp = "1377069696"
|
|
13 |
datestamp = "1397666996"
|
|
14 | 14 |
|
drupal7/sites/all/modules/i18n/i18n_string/i18n_string.inc | ||
---|---|---|
28 | 28 |
// Properties from metadata |
29 | 29 |
public $title; |
30 | 30 |
// Array of translations to multiple languages |
31 |
public $translations; |
|
31 |
public $translations = array();
|
|
32 | 32 |
// Textgroup object |
33 | 33 |
protected $_textgroup; |
34 | 34 |
|
... | ... | |
39 | 39 |
if ($data) { |
40 | 40 |
$this->set_properties($data); |
41 | 41 |
} |
42 |
// Attempt to re-build the data from the persistent cache. |
|
43 |
$this->rebuild_from_cache($data); |
|
42 | 44 |
} |
45 |
|
|
46 |
/** |
|
47 |
* Rebuild the object data based on the persistent cache. |
|
48 |
* |
|
49 |
* Since the textgroup defines if a string is cacheable or not the caching |
|
50 |
* of the string objects happens in the textgroup handler itself. |
|
51 |
* |
|
52 |
* @see i18n_string_textgroup_cached::__destruct() |
|
53 |
*/ |
|
54 |
protected function rebuild_from_cache($data = NULL) { |
|
55 |
// Check if we've the required information to repopulate the cache and do so |
|
56 |
// if possible. |
|
57 |
$meta_data_exist = isset($this->textgroup) && isset($this->type) && isset($this->objectid) && isset($this->property); |
|
58 |
if ($meta_data_exist && ($cache = cache_get($this->get_cid())) && !empty($cache->data)) { |
|
59 |
// Re-spawn the cached data. |
|
60 |
// @TODO do we need a array_diff to ensure we don't overwrite the data |
|
61 |
// provided by the $data parameter? |
|
62 |
$this->set_properties($cache->data); |
|
63 |
} |
|
64 |
} |
|
65 |
|
|
66 |
/** |
|
67 |
* Reset cache, needed for tests. |
|
68 |
*/ |
|
69 |
public function cache_reset() { |
|
70 |
$this->translations = array(); |
|
71 |
// Ensure a possible persistent cache of this object is cleared too. |
|
72 |
cache_clear_all($this->get_cid(), 'cache', TRUE); |
|
73 |
} |
|
74 |
|
|
75 |
/** |
|
76 |
* Returns the caching id for this object. |
|
77 |
* |
|
78 |
* @return string |
|
79 |
* The caching id. |
|
80 |
*/ |
|
81 |
public function get_cid() { |
|
82 |
return 'i18n:string:obj:' . $this->get_name(); |
|
83 |
} |
|
84 |
|
|
43 | 85 |
/** |
44 | 86 |
* Get message parameters from context and string. |
45 | 87 |
*/ |
... | ... | |
63 | 105 |
$this->objectkey = (int)$this->objectid; |
64 | 106 |
// Remaining elements glued again with ':' |
65 | 107 |
$this->property = $parts ? implode(':', $parts) : ''; |
108 |
|
|
109 |
// Attempt to re-build the other data from the persistent cache. |
|
110 |
$this->rebuild_from_cache(); |
|
111 |
|
|
66 | 112 |
return $this; |
67 | 113 |
} |
68 | 114 |
/** |
... | ... | |
100 | 146 |
if (isset($string['format'])) { |
101 | 147 |
$this->format = $string['format']; |
102 | 148 |
} |
149 |
if (isset($string['title'])) { |
|
150 |
$this->title = $string['title']; |
|
151 |
} |
|
103 | 152 |
} |
104 | 153 |
else { |
105 | 154 |
$this->string = $string; |
106 | 155 |
} |
107 |
if (isset($string['title'])) { |
|
108 |
$this->title = $string['title']; |
|
109 |
} |
|
156 |
|
|
110 | 157 |
return $this; |
111 | 158 |
} |
112 | 159 |
/** |
... | ... | |
119 | 166 |
* Get translation to language from string object |
120 | 167 |
*/ |
121 | 168 |
public function get_translation($langcode) { |
122 |
if (!isset($this->translations[$langcode])) {
|
|
169 |
if (empty($this->translations[$langcode])) {
|
|
123 | 170 |
$translation = $this->textgroup()->load_translation($this, $langcode); |
124 | 171 |
if ($translation && isset($translation->translation)) { |
125 | 172 |
$this->set_translation($translation, $langcode); |
... | ... | |
279 | 326 |
// Debug flag, set to true to print out more information. |
280 | 327 |
public $debug; |
281 | 328 |
// Cached or preloaded string objects |
282 |
public $strings; |
|
329 |
public $strings = array();
|
|
283 | 330 |
// Multiple translations search map |
284 |
protected $cache_multiple; |
|
331 |
protected $cache_multiple = array();
|
|
285 | 332 |
|
286 | 333 |
/** |
287 | 334 |
* Class constructor. |
... | ... | |
400 | 447 |
/** |
401 | 448 |
* Filter array of strings |
402 | 449 |
* |
403 |
* @param $filter |
|
450 |
* @param array $string_list |
|
451 |
* Array of strings to be filtered. |
|
452 |
* @param array $filter |
|
404 | 453 |
* Array of name value conditions. |
454 |
* |
|
455 |
* @return array |
|
456 |
* Strings from $string_list that match the filter conditions. |
|
405 | 457 |
*/ |
406 | 458 |
protected static function string_filter($string_list, $filter) { |
407 | 459 |
// Remove 'language' and '*' conditions. |
... | ... | |
566 | 618 |
public function cache_reset() { |
567 | 619 |
$this->strings = array(); |
568 | 620 |
$this->string_format = array(); |
569 |
$this->translations = array(); |
|
621 |
|
|
622 |
// Reset the persistent caches. |
|
623 |
cache_clear_all('i18n:string:tgroup:' . $this->textgroup , 'cache', TRUE); |
|
624 |
// Reset the complete string object cache too. |
|
625 |
cache_clear_all('i18n:string:obj:', 'cache', TRUE); |
|
570 | 626 |
} |
571 | 627 |
|
572 | 628 |
/** |
... | ... | |
613 | 669 |
public static function load_translation($i18nstring, $langcode) { |
614 | 670 |
// Search the database using lid if we've got it or textgroup, context otherwise |
615 | 671 |
if (!empty($i18nstring->lid)) { |
616 |
// We've alreay got lid, we just need translation data |
|
672 |
// We've already got lid, we just need translation data
|
|
617 | 673 |
$query = db_select('locales_target', 't'); |
618 | 674 |
$query->condition('t.lid', $i18nstring->lid); |
619 | 675 |
} |
... | ... | |
1178 | 1234 |
*/ |
1179 | 1235 |
public function translate($langcode, $options = array()) { |
1180 | 1236 |
// We may have it already translated. As objects are statically cached, translations are too. |
1181 |
if (!isset($this->translations[$langcode])) {
|
|
1237 |
if (empty($this->translations[$langcode])) {
|
|
1182 | 1238 |
$this->translations[$langcode] = $this->translate_object($langcode, $options); |
1183 | 1239 |
} |
1184 | 1240 |
return $this->translations[$langcode]; |
... | ... | |
1284 | 1340 |
return $this->textgroup()->load_strings(array('type' => $type, 'objectid' => $id)); |
1285 | 1341 |
} |
1286 | 1342 |
} |
1343 |
|
|
1344 |
|
|
1345 |
/** |
|
1346 |
* Textgroup handler for i18n_string API which integrated persistent caching. |
|
1347 |
*/ |
|
1348 |
class i18n_string_textgroup_cached extends i18n_string_textgroup_default { |
|
1349 |
|
|
1350 |
/** |
|
1351 |
* Defines the timeout for the persistent caching. |
|
1352 |
* @var int |
|
1353 |
*/ |
|
1354 |
public $caching_time = CACHE_TEMPORARY; |
|
1355 |
|
|
1356 |
/** |
|
1357 |
* Extends the existing constructor with a cache handling. |
|
1358 |
* |
|
1359 |
* @param string $textgroup |
|
1360 |
* The name of this textgroup. |
|
1361 |
*/ |
|
1362 |
public function __construct($textgroup) { |
|
1363 |
parent::__construct($textgroup); |
|
1364 |
// Fetch persistent caches, the persistent caches contain only metadata. |
|
1365 |
// Those metadata are processed by the related cache_get() methods. |
|
1366 |
foreach (array('cache_multiple', 'strings') as $caches_type) { |
|
1367 |
if (($cache = cache_get('i18n:string:tgroup:' . $this->textgroup . ':' . $caches_type)) && !empty($cache->data)) { |
|
1368 |
$this->{$caches_type} = $cache->data; |
|
1369 |
} |
|
1370 |
} |
|
1371 |
} |
|
1372 |
|
|
1373 |
/** |
|
1374 |
* Class destructor. |
|
1375 |
* |
|
1376 |
* Updates the persistent caches for the next usage. |
|
1377 |
* This function not only stores the data of the textgroup objects but also |
|
1378 |
* of the string objects. That way we ensure that only cacheable string object |
|
1379 |
* go into the persistent cache. |
|
1380 |
*/ |
|
1381 |
public function __destruct() { |
|
1382 |
// Reduce size to cache by removing NULL values. |
|
1383 |
$this->strings = array_filter($this->strings); |
|
1384 |
|
|
1385 |
|
|
1386 |
$strings_to_cache = array(); |
|
1387 |
// Store the persistent caches. We just store the metadata the translations |
|
1388 |
// are stored by the string object itself. However storing the metadata |
|
1389 |
// reduces the number of DB queries executed during runtime. |
|
1390 |
$cache_data = array(); |
|
1391 |
foreach ($this->strings as $context => $i18n_string_object) { |
|
1392 |
$cache_data[$context] = $context; |
|
1393 |
$strings_to_cache[$context] = $i18n_string_object; |
|
1394 |
} |
|
1395 |
cache_set('i18n:string:tgroup:' . $this->textgroup . ':strings', $cache_data, 'cache', $this->caching_time); |
|
1396 |
|
|
1397 |
$cache_data = array(); |
|
1398 |
foreach ($this->cache_multiple as $pattern => $strings) { |
|
1399 |
foreach ($strings as $context => $i18n_string_object) { |
|
1400 |
$cache_data[$pattern][$context] = $context; |
|
1401 |
$strings_to_cache[$context] = $i18n_string_object; |
|
1402 |
} |
|
1403 |
} |
|
1404 |
cache_set('i18n:string:tgroup:' . $this->textgroup . ':cache_multiple', $cache_data, 'cache', $this->caching_time); |
|
1405 |
|
|
1406 |
// Cache the string objects related to this textgroup. |
|
1407 |
// Store only the public visible data into the persistent cache. |
|
1408 |
foreach ($strings_to_cache as $i18n_string_object) { |
|
1409 |
// If this isn't an object it's an unprocessed cache item and doesn't need |
|
1410 |
// to be stored again. |
|
1411 |
if (is_object($i18n_string_object)) { |
|
1412 |
cache_set($i18n_string_object->get_cid(), get_object_vars($i18n_string_object), 'cache', $this->caching_time); |
|
1413 |
} |
|
1414 |
} |
|
1415 |
} |
|
1416 |
|
|
1417 |
/** |
|
1418 |
* Reset cache, needed for tests. |
|
1419 |
* |
|
1420 |
* Takes care of the persistent caches. |
|
1421 |
*/ |
|
1422 |
public function cache_reset() { |
|
1423 |
// Reset the persistent caches. |
|
1424 |
cache_clear_all('i18n:string:tgroup:' . $this->textgroup , 'cache', TRUE); |
|
1425 |
// Reset the complete string object cache too. This will affect string |
|
1426 |
// objects of other textgroups as well. |
|
1427 |
cache_clear_all('i18n:string:obj:', 'cache', TRUE); |
|
1428 |
|
|
1429 |
return parent::cache_reset(); |
|
1430 |
} |
|
1431 |
|
|
1432 |
/** |
|
1433 |
* Get translation from cache. |
|
1434 |
* |
|
1435 |
* Extends the original handler with persistent caching. |
|
1436 |
* |
|
1437 |
* @param string $context |
|
1438 |
* The context to look out for. |
|
1439 |
* @return i18n_string_object|NULL |
|
1440 |
* The string object if available or NULL otherwise. |
|
1441 |
*/ |
|
1442 |
protected function cache_get($context) { |
|
1443 |
if (isset($this->strings[$context])) { |
|
1444 |
// If the cache contains a string re-build i18n_string_object. |
|
1445 |
if (is_string($this->strings[$context])) { |
|
1446 |
$i8n_string_object = new i18n_string_object(array('textgroup' => $this->textgroup)); |
|
1447 |
$i8n_string_object->set_context($context); |
|
1448 |
$this->strings[$context] = $i8n_string_object; |
|
1449 |
} |
|
1450 |
// Now run the original handling. |
|
1451 |
return parent::cache_get($context); |
|
1452 |
} |
|
1453 |
return NULL; |
|
1454 |
} |
|
1455 |
|
|
1456 |
/** |
|
1457 |
* Get strings from multiple cache. |
|
1458 |
* |
|
1459 |
* @param $context array |
|
1460 |
* String context as array with language property at the end. |
|
1461 |
* |
|
1462 |
* @return mixed |
|
1463 |
* Array of strings (may be empty) if we've got a cache hit. |
|
1464 |
* Null otherwise. |
|
1465 |
*/ |
|
1466 |
protected function multiple_cache_get($context) { |
|
1467 |
// Ensure the values from the persistent cache are properly re-build. |
|
1468 |
$cache_key = implode(':', $context); |
|
1469 |
if (isset($this->cache_multiple[$cache_key])) { |
|
1470 |
foreach ($this->cache_multiple[$cache_key] as $cached_context) { |
|
1471 |
if (is_string($cached_context)) { |
|
1472 |
$i8n_string_object = new i18n_string_object(array('textgroup' => $this->textgroup)); |
|
1473 |
$i8n_string_object->set_context($cached_context); |
|
1474 |
$this->cache_multiple[$cache_key][$cached_context] = $i8n_string_object; |
|
1475 |
} |
|
1476 |
} |
|
1477 |
} |
|
1478 |
else { |
|
1479 |
// Now we try more generic keys. For instance, if we are searching 'term:1:*' |
|
1480 |
// we may try too 'term:*:*' and filter out the results. |
|
1481 |
foreach ($context as $key => $value) { |
|
1482 |
if ($value != '*') { |
|
1483 |
$try = array_merge($context, array($key => '*')); |
|
1484 |
return $this->multiple_cache_get($try); |
|
1485 |
} |
|
1486 |
} |
|
1487 |
} |
|
1488 |
return parent::multiple_cache_get($context); |
|
1489 |
} |
|
1490 |
|
|
1491 |
public function string_update($i18nstring, $options = array()) { |
|
1492 |
// Flush persistent cache. |
|
1493 |
cache_clear_all($i18nstring->get_cid(), 'cache', TRUE); |
|
1494 |
return parent::string_update($i18nstring, $options); |
|
1495 |
} |
|
1496 |
|
|
1497 |
public function string_remove($i18nstring, $options = array()) { |
|
1498 |
// Flush persistent cache. |
|
1499 |
cache_clear_all($i18nstring->get_cid(), 'cache', TRUE); |
|
1500 |
return parent::string_remove($i18nstring, $options); |
|
1501 |
} |
|
1502 |
} |
drupal7/sites/all/modules/i18n/i18n_string/i18n_string.info | ||
---|---|---|
10 | 10 |
files[] = i18n_string.test |
11 | 11 |
configure = admin/config/regional/i18n/strings |
12 | 12 |
|
13 |
; Information added by drupal.org packaging script on 2013-08-21
|
|
14 |
version = "7.x-1.10"
|
|
13 |
; Information added by Drupal.org packaging script on 2014-04-16
|
|
14 |
version = "7.x-1.11"
|
|
15 | 15 |
core = "7.x" |
16 | 16 |
project = "i18n" |
17 |
datestamp = "1377069696"
|
|
17 |
datestamp = "1397666996"
|
|
18 | 18 |
|
drupal7/sites/all/modules/i18n/i18n_string/i18n_string.pages.inc | ||
---|---|---|
398 | 398 |
// Invoke locale submission. |
399 | 399 |
locale_translate_edit_form_submit($form, $form_state); |
400 | 400 |
$lid = $form_state['values']['lid']; |
401 |
$i18n_string_object = i18n_string_get_by_lid($lid); |
|
402 |
$i18n_string_object->cache_reset(); |
|
401 | 403 |
foreach ($form_state['values']['translations'] as $key => $value) { |
402 | 404 |
if (!empty($value)) { |
403 | 405 |
// An update has been made, so we assume the translation is now current. |
drupal7/sites/all/modules/i18n/i18n_string/i18n_string.test | ||
---|---|---|
24 | 24 |
|
25 | 25 |
function setUp() { |
26 | 26 |
// We can use any of the modules that define a text group, to use it for testing |
27 |
parent::setUp('i18n_string', 'i18n_menu'); |
|
27 |
parent::setUp('i18n_string', 'i18n_menu', 'i18n_test');
|
|
28 | 28 |
parent::setUpLanguages(); |
29 | 29 |
$this->translator = $this->drupalCreateUser(array('translate interface', 'translate user-defined strings')); |
30 | 30 |
} |
... | ... | |
55 | 55 |
} |
56 | 56 |
} |
57 | 57 |
|
58 |
/** |
|
59 |
* Test base i18n_string caching. |
|
60 |
*/ |
|
61 |
function testCaching() { |
|
62 |
// Create a bunch of strings for all languages. |
|
63 |
$textgroup = 'test_cached'; |
|
64 |
$strings = $this->stringCreateArray(2); |
|
65 |
$translations = array(); |
|
66 |
$textgroup_object = i18n_string_textgroup($textgroup); |
|
67 |
// Save source strings and store translations. |
|
68 |
foreach ($strings as $key => $string) { |
|
69 |
$name = "$textgroup:item:$key:title"; |
|
70 |
i18n_string_update($name, $string); |
|
71 |
$translations[$key] = $this->createStringTranslation($textgroup, $string); |
|
72 |
} |
|
73 |
|
|
74 |
// Now fetch the strings to fill the cache. |
|
75 |
foreach ($textgroup_object->strings as $context => $string_object) { |
|
76 |
$this->drupalGet('tests/i18n/i18n_string_build/' . $textgroup . ':' . $context); |
|
77 |
} |
|
78 |
foreach ($strings as $key => $string) { |
|
79 |
$this->drupalGet('tests/i18n/i18n_string_translation_search/' . $textgroup . ':item:' . $key . ':*/es'); |
|
80 |
} |
|
81 |
|
|
82 |
// Check the persistent cache for contents. |
|
83 |
$cache = cache_get('i18n:string:tgroup:' . $textgroup . ':strings'); |
|
84 |
if ($this->assertNotEqual($cache, FALSE, 'Textgroup strings cache found')) { |
|
85 |
foreach ($textgroup_object->strings as $context => $string_object) { |
|
86 |
if ($this->assertTrue(isset($cache->data[$context]), format_string('Cached string %context found', array('%context' => $context)))) { |
|
87 |
$this->assertEqual($cache->data[$context], $context, 'Cached string is a string and not an object'); |
|
88 |
} |
|
89 |
// Check if the string object cache is also available. |
|
90 |
$string_cache = cache_get($string_object->get_cid()); |
|
91 |
if ($this->assertNotEqual($string_cache, FALSE, format_string('Cached string object %cid found', array('%cid' => $string_object->get_cid())))) { |
|
92 |
$this->assertTrue(is_array($string_cache->data), 'Cached string object is an array.'); |
|
93 |
} |
|
94 |
} |
|
95 |
} |
|
96 |
$cache = cache_get('i18n:string:tgroup:' . $textgroup . ':cache_multiple'); |
|
97 |
if ($this->assertNotEqual($cache, FALSE, 'Textgroup cache_multiple cache found')) { |
|
98 |
foreach ($strings as $key => $string) { |
|
99 |
$pattern = 'item:' . $key . ':*:es'; |
|
100 |
if ($this->assertTrue(isset($cache->data[$pattern]), format_string('Cached multiple cache for pattern %pattern found', array('%pattern_key' => $pattern)))) { |
|
101 |
$property_pattern = 'item:' . $key . ':title'; |
|
102 |
if ($this->assertTrue(isset($cache->data[$pattern][$property_pattern]), format_string('Cached multiple property title found', array('%pattern_key' => $pattern)))) { |
|
103 |
$this->assertEqual($cache->data[$pattern][$property_pattern], $property_pattern); |
|
104 |
} |
|
105 |
} |
|
106 |
} |
|
107 |
} |
|
108 |
|
|
109 |
// Test cache injection. |
|
110 |
foreach ($textgroup_object->strings as $context => $string_object) { |
|
111 |
// Check if the string object cache is also available. |
|
112 |
$string_cache = cache_get($string_object->get_cid()); |
|
113 |
if (isset($string_cache->data)) { |
|
114 |
// Modify cache. |
|
115 |
$string_cache->data['string'] = "Injected value."; |
|
116 |
cache_set($string_object->get_cid(), $string_cache->data, 'cache', CACHE_TEMPORARY); |
|
117 |
|
|
118 |
// Check if modification is reflected on the next page call. |
|
119 |
$this->drupalGet('tests/i18n/i18n_string_build/' . $textgroup . ':' . $context); |
|
120 |
$this->assertText($string_cache->data['string']); |
|
121 |
} |
|
122 |
} |
|
123 |
} |
|
124 |
|
|
125 |
|
|
58 | 126 |
/** |
59 | 127 |
* Create strings for all languages |
60 | 128 |
*/ |
... | ... | |
76 | 144 |
/** |
77 | 145 |
* Create and store one translation into the db |
78 | 146 |
*/ |
79 |
public static function stringCreateTranslation($name, $lang, $length = 20) {
|
|
147 |
public function stringCreateTranslation($name, $lang, $length = 20) { |
|
80 | 148 |
$translation = $this->randomName($length); |
81 | 149 |
if (self::stringSaveTranslation($name, $lang, $translation)) { |
82 | 150 |
return $translation; |
drupal7/sites/all/modules/i18n/i18n_sync/i18n_sync.info | ||
---|---|---|
10 | 10 |
files[] = i18n_sync.module.inc |
11 | 11 |
files[] = i18n_sync.node.inc |
12 | 12 |
files[] = i18n_sync.test |
13 |
; Information added by drupal.org packaging script on 2013-08-21
|
|
14 |
version = "7.x-1.10"
|
|
13 |
; Information added by Drupal.org packaging script on 2014-04-16
|
|
14 |
version = "7.x-1.11"
|
|
15 | 15 |
core = "7.x" |
16 | 16 |
project = "i18n" |
17 |
datestamp = "1377069696"
|
|
17 |
datestamp = "1397666996"
|
|
18 | 18 |
|
drupal7/sites/all/modules/i18n/i18n_sync/i18n_sync.module | ||
---|---|---|
80 | 80 |
} |
81 | 81 |
} |
82 | 82 |
|
83 |
/** |
|
84 |
* Implements hook_form_FORM_ID_alter(). |
|
85 |
*/ |
|
86 |
function i18n_sync_form_node_delete_confirm_alter(&$form, &$form_state) { |
|
87 |
// Intercept form submission so we can handle uploads, replace callback |
|
88 |
$form['#submit'] = array_merge(array('i18n_sync_node_delete_submit'), $form['#submit']); |
|
89 |
} |
|
90 |
|
|
91 |
|
|
92 |
|
|
93 | 83 |
/** |
94 | 84 |
* Implements hook_form_FORM_ID_alter(). |
95 | 85 |
*/ |
... | ... | |
145 | 135 |
} |
146 | 136 |
} |
147 | 137 |
|
148 |
/** |
|
149 |
* Submit callback for |
|
150 |
* - node delete confirm |
|
151 |
* - node multiple delete confirm |
|
152 |
*/ |
|
153 |
function i18n_sync_node_delete_submit($form, $form_state) { |
|
154 |
if ($form_state['values']['confirm']) { |
|
155 |
if (!empty($form_state['values']['nid'])) { |
|
156 |
// Single node |
|
157 |
i18n_sync_node_delete_prepare($form_state['values']['nid']); |
|
158 |
} |
|
159 |
elseif (!empty($form_state['values']['nodes'])) { |
|
160 |
// Multiple nodes |
|
161 |
foreach ($form_state['values']['nodes'] as $nid => $value) { |
|
162 |
i18n_sync_node_delete_prepare($nid); |
|
163 |
} |
|
164 |
} |
|
165 |
} |
|
166 |
// Then it will go through normal form submission |
|
167 |
} |
|
168 |
|
|
169 |
/** |
|
170 |
* Prepare node for deletion, work out synchronization issues |
|
171 |
*/ |
|
172 |
function i18n_sync_node_delete_prepare($nid) { |
|
173 |
$node = node_load($nid); |
|
174 |
// Delete file associations when files are shared with existing translations |
|
175 |
// so they are not removed by upload module |
|
176 |
if (!empty($node->tnid) && module_exists('upload')) { |
|
177 |
$result = db_query('SELECT u.* FROM {upload} u WHERE u.nid = %d AND u.fid IN (SELECT t.fid FROM {upload} t WHERE t.fid = u.fid AND t.nid <> u.nid)', $nid); |
|
178 |
while ($up = db_fetch_object($result)) { |
|
179 |
db_query("DELETE FROM {upload} WHERE fid = %d AND vid = %d", $up->fid, $up->vid); |
|
180 |
} |
|
181 |
} |
|
182 |
} |
|
183 |
|
|
184 | 138 |
/** |
185 | 139 |
* Check whether this node is to be synced |
186 | 140 |
*/ |
drupal7/sites/all/modules/i18n/i18n_sync/i18n_sync.node.inc | ||
---|---|---|
39 | 39 |
continue; |
40 | 40 |
} |
41 | 41 |
// Load full node, we need all data here. |
42 |
entity_get_controller('node')->resetCache(array($translation->nid)); |
|
42 | 43 |
$translation = node_load($translation->nid); |
43 | 44 |
$i18n_options = i18n_sync_node_options($node->type); |
44 | 45 |
// Invoke callback for each field, the default is just copy over |
drupal7/sites/all/modules/i18n/i18n_taxonomy/i18n_taxonomy.admin.inc | ||
---|---|---|
199 | 199 |
$path = 'taxonomy/term/' . $translation_term->tid; |
200 | 200 |
$title = l($translation_term->name, $path); |
201 | 201 |
|
202 |
$options[] = l(t('edit'), $path . '/edit'); |
|
202 |
$options['edit'] = array( |
|
203 |
'#type' => 'link', |
|
204 |
'#title' => t('edit'), |
|
205 |
'#href' => $path . '/edit', |
|
206 |
'#options' => array( |
|
207 |
'query' => drupal_get_destination(), |
|
208 |
), |
|
209 |
); |
|
203 | 210 |
|
204 | 211 |
if ($translation_term->tid == $i18n_tsid) { |
205 | 212 |
$language_name = t('<strong>@language_name</strong> (source)', array('@language_name' => $language_name)); |
... | ... | |
208 | 215 |
else { |
209 | 216 |
// No such translation in the set yet: help user to create it. |
210 | 217 |
$title = t('n/a'); |
211 |
$options[] = l(t('add translation'), 'admin/structure/taxonomy/' . $term->vocabulary_machine_name . '/add', array('query' => array('translation' => $term->tid, 'target' => $langcode) + drupal_get_destination())); |
|
218 |
$options['add'] = array( |
|
219 |
'#type' => 'link', |
|
220 |
'#title' => t('add translation'), |
|
221 |
'#href' => 'admin/structure/taxonomy/' . $term->vocabulary_machine_name . '/add', |
|
222 |
'#options' => array( |
|
223 |
'query' => array('translation' => $term->tid, 'target' => $langcode) + drupal_get_destination() |
|
224 |
), |
|
225 |
); |
|
212 | 226 |
} |
213 |
$rows[] = array($language_name, $title, implode(" | ", $options)); |
|
227 |
$rows[$langcode] = array( |
|
228 |
'language' => $language_name, |
|
229 |
'title' => $title, |
|
230 |
'operations' => array('data' => $options), |
|
231 |
); |
|
214 | 232 |
} |
215 | 233 |
|
216 | 234 |
drupal_set_title(t('Translations of term %title', array('%title' => $term->name)), PASS_THROUGH); |
217 | 235 |
|
218 |
$build['translation_node_overview'] = array(
|
|
236 |
$build['translation_overview'] = array( |
|
219 | 237 |
'#theme' => 'table', |
220 | 238 |
'#header' => $header, |
221 | 239 |
'#rows' => $rows, |
drupal7/sites/all/modules/i18n/i18n_taxonomy/i18n_taxonomy.info | ||
---|---|---|
11 | 11 |
files[] = i18n_taxonomy.admin.inc |
12 | 12 |
files[] = i18n_taxonomy.test |
13 | 13 |
|
14 |
; Information added by drupal.org packaging script on 2013-08-21
|
|
15 |
version = "7.x-1.10"
|
|
14 |
; Information added by Drupal.org packaging script on 2014-04-16
|
|
15 |
version = "7.x-1.11"
|
|
16 | 16 |
core = "7.x" |
17 | 17 |
project = "i18n" |
18 |
datestamp = "1377069696"
|
|
18 |
datestamp = "1397666996"
|
|
19 | 19 |
|
drupal7/sites/all/modules/i18n/i18n_taxonomy/i18n_taxonomy.install | ||
---|---|---|
12 | 12 |
*/ |
13 | 13 |
function i18n_taxonomy_install() { |
14 | 14 |
module_load_install('i18n'); |
15 |
i18n_install_create_fields('taxonomy_vocabulary', array('language', 'i18n_mode')); |
|
15 |
i18n_install_create_fields('taxonomy_vocabulary', array('language', 'i18n_mode'), TRUE);
|
|
16 | 16 |
i18n_install_create_fields('taxonomy_term_data', array('language', 'i18n_tsid')); |
17 | 17 |
// Set module weight for it to run after core modules, but before views. |
18 | 18 |
db_query("UPDATE {system} SET weight = 5 WHERE name = 'i18n_taxonomy' AND type = 'module'"); |
drupal7/sites/all/modules/i18n/i18n_taxonomy/i18n_taxonomy.module | ||
---|---|---|
452 | 452 |
return $links; |
453 | 453 |
} |
454 | 454 |
} |
455 |
/** |
|
456 |
* Implements hook_theme(). |
|
457 |
*/ |
|
458 |
function i18n_taxonomy_theme() { |
|
459 |
return array( |
|
460 |
'i18n_taxonomy_term_page' => array( |
|
461 |
'arguments' => array('tids' => array(), 'result' => NULL), |
|
462 |
'file' => 'i18n_taxonomy.pages.inc', |
|
463 |
), |
|
464 |
); |
|
465 |
} |
|
466 | 455 |
|
467 | 456 |
/** |
468 | 457 |
* Get localized term name unfiltered. |
... | ... | |
1231 | 1220 |
// Core doesn't provide a label callback for taxonomy terms. By setting one |
1232 | 1221 |
// we can use it to return the correct localized term name. |
1233 | 1222 |
$entity_info['taxonomy_term']['label callback'] = 'i18n_taxonomy_taxonomy_term_label'; |
1223 |
|
|
1224 |
// Also let core know terms have languages, now. |
|
1225 |
$entity_info['taxonomy_term']['entity keys']['language'] = 'language'; |
|
1234 | 1226 |
} |
1235 | 1227 |
} |
1236 | 1228 |
|
drupal7/sites/all/modules/i18n/i18n_taxonomy/i18n_taxonomy.pages.inc | ||
---|---|---|
62 | 62 |
return $build; |
63 | 63 |
} |
64 | 64 |
|
65 |
/** |
|
66 |
* Render a taxonomy term page HTML output. |
|
67 |
* |
|
68 |
* @param $tids |
|
69 |
* An array of term ids. |
|
70 |
* @param $result |
|
71 |
* A pager_query() result, such as that performed by taxonomy_select_nodes(). |
|
72 |
* |
|
73 |
* @ingroup themeable |
|
74 |
*/ |
|
75 |
function theme_i18n_taxonomy_term_page($tids, $result) { |
|
76 |
drupal_add_css(drupal_get_path('module', 'taxonomy') . '/taxonomy.css'); |
|
77 |
|
|
78 |
$output = ''; |
|
79 |
|
|
80 |
// Only display the description if we have a single term, to avoid clutter and confusion. |
|
81 |
if (count($tids) == 1) { |
|
82 |
$term = i18n_taxonomy_localize_terms(taxonomy_term_load($tids[0])); |
|
83 |
// Check that a description is set. |
|
84 |
if (!empty($term->description)) { |
|
85 |
$output .= '<div class="taxonomy-term-description">'; |
|
86 |
$output .= filter_xss_admin($term->description); |
|
87 |
$output .= '</div>'; |
|
88 |
} |
|
89 |
} |
|
90 |
|
|
91 |
$output .= taxonomy_render_nodes($result); |
|
92 |
|
|
93 |
return $output; |
|
94 |
} |
|
95 |
|
|
96 | 65 |
/** |
97 | 66 |
* Helper function for autocompletion. Replacement for taxonomy_autocomplete |
98 | 67 |
*/ |
drupal7/sites/all/modules/i18n/i18n_translation/i18n_translation.info | ||
---|---|---|
6 | 6 |
|
7 | 7 |
files[] = i18n_translation.inc |
8 | 8 |
|
9 |
; Information added by drupal.org packaging script on 2013-08-21
|
|
10 |
version = "7.x-1.10"
|
|
9 |
; Information added by Drupal.org packaging script on 2014-04-16
|
|
10 |
version = "7.x-1.11"
|
|
11 | 11 |
core = "7.x" |
12 | 12 |
project = "i18n" |
13 |
datestamp = "1377069696"
|
|
13 |
datestamp = "1397666996"
|
|
14 | 14 |
|
drupal7/sites/all/modules/i18n/i18n_user/i18n_user.info | ||
---|---|---|
4 | 4 |
package = Multilingual - Internationalization |
5 | 5 |
dependencies[] = i18n_variable |
6 | 6 |
|
7 |
; Information added by drupal.org packaging script on 2013-08-21
|
|
8 |
version = "7.x-1.10"
|
|
7 |
; Information added by Drupal.org packaging script on 2014-04-16
|
|
8 |
version = "7.x-1.11"
|
|
9 | 9 |
core = "7.x" |
10 | 10 |
project = "i18n" |
11 |
datestamp = "1377069696"
|
|
11 |
datestamp = "1397666996"
|
|
12 | 12 |
|
drupal7/sites/all/modules/i18n/i18n_variable/i18n_variable.info | ||
---|---|---|
10 | 10 |
files[] = i18n_variable.class.inc |
11 | 11 |
files[] = i18n_variable.test |
12 | 12 |
|
13 |
; Information added by drupal.org packaging script on 2013-08-21
|
|
14 |
version = "7.x-1.10"
|
|
13 |
; Information added by Drupal.org packaging script on 2014-04-16
|
|
14 |
version = "7.x-1.11"
|
|
15 | 15 |
core = "7.x" |
16 | 16 |
project = "i18n" |
17 |
datestamp = "1377069696"
|
|
17 |
datestamp = "1397666996"
|
|
18 | 18 |
|
drupal7/sites/all/modules/i18n/tests/i18n_test.info | ||
---|---|---|
7 | 7 |
core = 6.x |
8 | 8 |
hidden = TRUE |
9 | 9 |
|
10 |
; Information added by drupal.org packaging script on 2013-08-21
|
|
11 |
version = "7.x-1.10"
|
|
10 |
; Information added by Drupal.org packaging script on 2014-04-16
|
|
11 |
version = "7.x-1.11"
|
|
12 | 12 |
core = "7.x" |
13 | 13 |
project = "i18n" |
14 |
datestamp = "1377069696"
|
|
14 |
datestamp = "1397666996"
|
|
15 | 15 |
|
drupal7/sites/all/modules/i18n/tests/i18n_test.module | ||
---|---|---|
36 | 36 |
'format' => FALSE, // This group doesn't have strings with format |
37 | 37 |
'refresh callback' => 'i18n_test_i18n_string_refresh', |
38 | 38 |
); |
39 |
$groups['test_cached'] = array( |
|
40 |
'title' => t('Test Cached Strings'), |
|
41 |
'description' => t('Translatable items of a textgroup with caching enabled.'), |
|
42 |
'format' => FALSE, // This group doesn't have strings with format |
|
43 |
'class' => 'i18n_string_textgroup_cached', |
|
44 |
); |
|
39 | 45 |
return $groups; |
40 | 46 |
} |
41 | 47 |
/** |
... | ... | |
43 | 49 |
*/ |
44 | 50 |
function i18n_test_i18n_string_refresh() { |
45 | 51 |
return TRUE; |
52 |
} |
|
53 |
|
|
54 |
/** |
|
55 |
* Implements hook_menu(). |
|
56 |
*/ |
|
57 |
function i18n_test_menu() { |
|
58 |
// Required for the i18n_string caching tests. |
|
59 |
$items['tests/i18n/i18n_string_build/%'] = array( |
|
60 |
'title' => 'Load string', |
|
61 |
'access callback' => TRUE, |
|
62 |
'page callback' => 'i18n_string_build', |
|
63 |
'page arguments' => array(3), |
|
64 |
'type' => MENU_CALLBACK, |
|
65 |
'delivery callback' => 'drupal_json_output', |
|
66 |
); |
|
67 |
$items['tests/i18n/i18n_string_build/%/%'] = array( |
|
68 |
'title' => 'Load string', |
|
69 |
'access callback' => TRUE, |
|
70 |
'page callback' => 'i18n_string_build', |
|
71 |
'page arguments' => array(3, 4), |
|
72 |
'type' => MENU_CALLBACK, |
|
73 |
'delivery callback' => 'drupal_json_output', |
|
74 |
); |
|
75 |
$items['tests/i18n/i18n_string_translation_search/%'] = array( |
|
76 |
'title' => 'Search string translations', |
|
77 |
'access callback' => TRUE, |
|
78 |
'page callback' => 'i18n_string_translation_search', |
|
79 |
'page arguments' => array(3), |
|
80 |
'type' => MENU_CALLBACK, |
|
81 |
'delivery callback' => 'drupal_json_output', |
|
82 |
); |
|
83 |
$items['tests/i18n/i18n_string_translation_search/%/%'] = array( |
|
84 |
'title' => 'Search string translations', |
|
85 |
'access callback' => TRUE, |
|
86 |
'page callback' => 'i18n_string_translation_search', |
|
87 |
'page arguments' => array(3, 4), |
|
88 |
'type' => MENU_CALLBACK, |
|
89 |
'delivery callback' => 'drupal_json_output', |
|
90 |
); |
|
91 |
return $items; |
|
46 | 92 |
} |
drupal7/sites/all/modules/remote_stream_wrapper/remote_stream_wrapper.info | ||
---|---|---|
8 | 8 |
suggests[] = media |
9 | 9 |
suggests[] = image |
10 | 10 |
|
11 |
; Information added by drupal.org packaging script on 2012-03-13
|
|
12 |
version = "7.x-1.0-beta4"
|
|
11 |
; Information added by Drupal.org packaging script on 2014-04-22
|
|
12 |
version = "7.x-1.0-rc1"
|
|
13 | 13 |
core = "7.x" |
14 | 14 |
project = "remote_stream_wrapper" |
15 |
datestamp = "1331680243"
|
|
15 |
datestamp = "1398126831"
|
|
16 | 16 |
|
drupal7/sites/all/modules/remote_stream_wrapper/remote_stream_wrapper.module | ||
---|---|---|
104 | 104 |
} |
105 | 105 |
|
106 | 106 |
/** |
107 |
* Implements hook_preprocess_image().
|
|
107 |
* Implements hook_file_url_alter().
|
|
108 | 108 |
*/ |
109 |
function remote_stream_wrapper_preprocess_image(&$variables) { |
|
110 |
static $regex; |
|
111 |
|
|
112 |
if (!empty($variables['style_name'])) { |
|
113 |
if (!isset($regex)) { |
|
114 |
$wrappers = file_get_remote_stream_wrappers(); |
|
115 |
$schemes = implode('|', array_keys($wrappers)); |
|
116 |
$regex = "#^($schemes)://styles/#"; |
|
117 |
} |
|
118 |
$variables['path'] = preg_replace($regex, file_default_scheme() . '://styles/', $variables['path'], 1); |
|
109 |
function remote_stream_wrapper_file_url_alter(&$uri) { |
|
110 |
$scheme = file_uri_scheme($uri); |
|
111 |
$wrappers = file_get_remote_stream_wrappers(); |
|
112 |
if ($scheme && isset($wrappers[$scheme]) && strpos($uri, "$scheme://styles/") === 0) { |
|
113 |
$uri = file_default_scheme() . '://' . file_uri_target($uri); |
|
119 | 114 |
} |
120 | 115 |
} |
121 | 116 |
|
drupal7/sites/all/modules/remote_stream_wrapper/remote_stream_wrapper.test | ||
---|---|---|
9 | 9 |
return array( |
10 | 10 |
'name' => 'Remote stream wrapper', |
11 | 11 |
'description' => 'Tests functionality for remote stream wrappers.', |
12 |
'group' => 'Remote steam wrapper', |
|
12 |
'group' => 'Remote stream wrapper',
|
|
13 | 13 |
); |
14 | 14 |
} |
15 | 15 |
|
drupal7/sites/all/modules/variable/variable.api.php | ||
---|---|---|
84 | 84 |
* - "repeat": Array of variable properties for children variables. |
85 | 85 |
* - "localize": Boolean value, TRUE for variables that should be localized. This may be used by other modules. |
86 | 86 |
* - "validate callback": Callback to validate the variable value, it will be added to form element #validate. |
87 |
* |
|
88 |
* @see hook_variable_info_alter() |
|
87 | 89 |
*/ |
88 | 90 |
function hook_variable_info($options) { |
89 | 91 |
$variables['site_name'] = array( |
... | ... | |
102 | 104 |
return $variables; |
103 | 105 |
} |
104 | 106 |
|
107 |
/** |
|
108 |
* Alter the variable definitions. |
|
109 |
* |
|
110 |
* @param $info |
|
111 |
* The variable info array, keyed by variable name. |
|
112 |
* |
|
113 |
* @see hook_variable_info() |
|
114 |
*/ |
|
115 |
function hook_variable_info_alter(&$info) { |
|
116 |
} |
|
117 |
|
|
105 | 118 |
/** |
106 | 119 |
* Define types of variables or list of values used by a module. |
107 | 120 |
* |
... | ... | |
145 | 158 |
* |
146 | 159 |
* A special attribute: |
147 | 160 |
* - "type": Variable subtype, the properties for the subtype will be added to these ones. |
161 |
* |
|
162 |
* @see hook_variable_type_info_alter() |
|
148 | 163 |
*/ |
149 | 164 |
function hook_variable_type_info() { |
150 | 165 |
$type['mail_address'] = array( |
... | ... | |
162 | 177 |
return $type; |
163 | 178 |
} |
164 | 179 |
|
180 |
/** |
|
181 |
* Alter the variable type definitions. |
|
182 |
* |
|
183 |
* @param $info |
|
184 |
* The variable type info array, keyed by variable type name. |
|
185 |
* |
|
186 |
* @see hook_variable_type_info() |
|
187 |
*/ |
|
188 |
function hook_variable_type_info_alter(&$info) { |
|
189 |
} |
|
190 |
|
|
165 | 191 |
/** |
166 | 192 |
* Define groups of variables used by a module. |
167 | 193 |
* |
... | ... | |
181 | 207 |
* - "description": The human readable description of the group. Must be localized. |
182 | 208 |
* - "access": Permission required to edit group's variables. Will default to 'administer site configuration'. |
183 | 209 |
* - "path": Array of administration paths where these variables can be accessed. |
210 |
* |
|
211 |
* @see hook_variable_group_info_alter() |
|
184 | 212 |
*/ |
185 | 213 |
function hook_variable_group_info() { |
186 | 214 |
$groups['system_site_information'] = array( |
... | ... | |
197 | 225 |
return $groups; |
198 | 226 |
} |
199 | 227 |
|
228 |
/** |
|
229 |
* Alter the variable group definitions. |
|
230 |
* |
|
231 |
* @param $info |
|
232 |
* The variable type info array, keyed by variable group name. |
|
233 |
* |
|
234 |
* @see hook_variable_group_info() |
|
235 |
*/ |
|
236 |
function hook_variable_group_info_alter(&$info) { |
|
237 |
} |
|
238 |
|
|
200 | 239 |
/** |
201 | 240 |
* Alter system settings forms. |
202 | 241 |
* |
drupal7/sites/all/modules/variable/variable.info | ||
---|---|---|
12 | 12 |
files[] = includes/translation.variable.inc |
13 | 13 |
files[] = includes/user.variable.inc |
14 | 14 |
files[] = variable.test |
15 |
; Information added by Drupal.org packaging script on 2014-01-21
|
|
16 |
version = "7.x-2.4"
|
|
15 |
; Information added by Drupal.org packaging script on 2014-04-23
|
|
16 |
version = "7.x-2.5"
|
|
17 | 17 |
core = "7.x" |
18 | 18 |
project = "variable" |
19 |
datestamp = "1390310315"
|
|
19 |
datestamp = "1398250128"
|
|
20 | 20 |
|
drupal7/sites/all/modules/variable/variable.variable.inc | ||
---|---|---|
376 | 376 |
* Validate numeric variable. |
377 | 377 |
*/ |
378 | 378 |
function variable_validate_number($variable) { |
379 |
if (!is_numeric($variable['value'])) { |
|
379 |
if (empty($variable['required']) && empty($variable['value'])) { |
|
380 |
return; |
|
381 |
} |
|
382 |
elseif (!is_numeric($variable['value'])) { |
|
380 | 383 |
return t('The value is not a number.'); |
381 | 384 |
} |
382 | 385 |
} |
drupal7/sites/all/modules/variable/variable_admin/variable_admin.info | ||
---|---|---|
3 | 3 |
dependencies[] = variable |
4 | 4 |
package = Variable |
5 | 5 |
core = 7.x |
6 |
; Information added by Drupal.org packaging script on 2014-01-21
|
|
7 |
version = "7.x-2.4"
|
|
6 |
; Information added by Drupal.org packaging script on 2014-04-23
|
|
7 |
version = "7.x-2.5"
|
|
8 | 8 |
core = "7.x" |
9 | 9 |
project = "variable" |
Formats disponibles : Unified diff
Weekly update of contrib modules