Now all modules are in core modules folder
This commit is contained in:
parent
5ba1cdfa0b
commit
05b6a91b0c
1907 changed files with 0 additions and 0 deletions
148
modules/i18n/i18nstrings/i18nstrings.admin.inc
Normal file
148
modules/i18n/i18nstrings/i18nstrings.admin.inc
Normal file
|
@ -0,0 +1,148 @@
|
|||
<?php
|
||||
|
||||
// Load locale library
|
||||
include_once './includes/locale.inc';
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Admin page callbacks for the i18nstrings module.
|
||||
*/
|
||||
function i18nstrings_admin_refresh_page() {
|
||||
$output = '';
|
||||
$output .= drupal_get_form('i18nstrings_admin_refresh');
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Form callback. Refresh textgroups.
|
||||
*/
|
||||
function i18nstrings_admin_refresh() {
|
||||
// Select textgroup/s. Just the ones that have a 'refresh callback'
|
||||
$groups = module_invoke_all('locale', 'groups');
|
||||
unset($groups['default']);
|
||||
foreach (array_keys($groups) as $key) {
|
||||
if (!i18nstrings_group_info($key, 'refresh callback')) {
|
||||
unset($groups[$key]);
|
||||
}
|
||||
}
|
||||
$form['groups'] = array(
|
||||
'#type' => 'checkboxes',
|
||||
'#title' => t('Select text groups'),
|
||||
'#options' => $groups,
|
||||
'#description' => t('If a text group is no showing up here it means this feature is not implemented for it.'),
|
||||
);
|
||||
$form['refresh'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Refresh strings'),
|
||||
'#suffix' => '<p>'. t('This will create all the missing strings for the selected text groups.') .'</p>',
|
||||
);
|
||||
// Get all languages, except default language.
|
||||
$languages = locale_language_list('name', TRUE);
|
||||
unset($languages[language_default('language')]);
|
||||
$form['languages'] = array(
|
||||
'#type' => 'checkboxes',
|
||||
'#title' => t('Select languages'),
|
||||
'#options' => $languages,
|
||||
);
|
||||
$form['update'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Update translations'),
|
||||
'#suffix' => '<p>'. t('This will fetch all existing translations from the localization tables for the selected text groups and languages.') .'</p>',
|
||||
);
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Form submission.
|
||||
*/
|
||||
function i18nstrings_admin_refresh_submit($form, &$form_state) {
|
||||
$op = isset($form_state['values']['op']) ? $form_state['values']['op'] : '';
|
||||
$groups = array_filter($form_state['values']['groups']);
|
||||
$languages = array_filter($form_state['values']['languages']);
|
||||
$group_names = module_invoke_all('locale', 'groups');
|
||||
if ($op == t('Refresh strings') && $groups) {
|
||||
foreach ($groups as $group) {
|
||||
if (i18nstrings_refresh_group($group, TRUE)) {
|
||||
drupal_set_message(t("Successfully refreshed strings for %group", array('%group' => $group_names[$group])));
|
||||
}
|
||||
else {
|
||||
drupal_set_message(t("Cannot refresh strings for %group.", array('%group' => $group_names[$group])), 'warning');
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ($op == t('Update translations') && $groups && $languages) {
|
||||
$count = 0;
|
||||
foreach ($languages as $language) {
|
||||
$count += i18nstrings_admin_update($language, $groups);
|
||||
}
|
||||
drupal_set_message(format_plural($count, '1 string has been updated.', '@count strings have been updated.'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update strings for language.
|
||||
*/
|
||||
function i18nstrings_admin_update($language, $groups) {
|
||||
$params = $groups;
|
||||
$params[] = $language;
|
||||
$sql = 'SELECT g.*, t.translation, t.lid as tlid, i.format FROM {locales_source} g INNER JOIN {locales_source} s ON g.source = s.source AND s.lid <> g.lid ';
|
||||
$sql .= 'INNER JOIN {locales_target} t ON s.lid = t.lid LEFT JOIN {locales_target} t2 ON g.lid = t2.lid ';
|
||||
$sql .= 'INNER JOIN {i18n_strings} i ON i.lid = g.lid ';
|
||||
$sql .= 'WHERE t2.lid IS NULL AND g.textgroup IN ('. db_placeholders($groups, 'varchar') .") AND t.language = '%s'";
|
||||
$result = db_query($sql, $params);
|
||||
$count = 0;
|
||||
while ($string = db_fetch_object($result)) {
|
||||
// Just update strings when no input format, otherwise it could be dangerous under some circumstances.
|
||||
if (empty($string->format) && !empty($string->translation)) {
|
||||
$count++;
|
||||
db_query("INSERT INTO {locales_target} (translation, lid, language) VALUES('%s', %d, '%s')", $string->translation, $string->lid, $language);
|
||||
}
|
||||
}
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure filters for string translation.
|
||||
*
|
||||
* This has serious security implications so this form needs the 'administer filters' permission
|
||||
*/
|
||||
function i18nstrings_admin_settings() {
|
||||
include_once './includes/locale.inc';
|
||||
// As the user has administer filters permissions we get a full list here
|
||||
foreach (filter_formats() as $fid => $format) {
|
||||
$format_list[$fid] = $format->name;
|
||||
}
|
||||
$form['i18nstrings_allowed_formats'] = array(
|
||||
'#title' => t('Translatable input formats'),
|
||||
'#options' => $format_list,
|
||||
'#type' => 'checkboxes',
|
||||
'#default_value' => variable_get('i18nstrings_allowed_formats', array(variable_get('filter_default_format', 1))),
|
||||
'#description' => t('Only the strings that have the input formats selected will be allowed by the translation system. All the others will be deleted next time the strings are refreshed.'),
|
||||
);
|
||||
// Whitelist text groups without formatted strings for backwards compatibility
|
||||
$textgroups = module_invoke_all('locale', 'groups');
|
||||
unset($textgroups['default']);
|
||||
foreach (array_keys($textgroups) as $group) {
|
||||
$format = i18nstrings_group_info($group, 'format');
|
||||
if (isset($format)) {
|
||||
// This one already has format information, so remove from list
|
||||
unset($textgroups[$group]);
|
||||
}
|
||||
}
|
||||
// If there are 'old' textgroups, display the bypass option
|
||||
if ($textgroups) {
|
||||
$form['i18nstrings_allowed_textgroups'] = array(
|
||||
'#title' => t('Safe text groups'),
|
||||
'#options' => $textgroups,
|
||||
'#type' => 'checkboxes',
|
||||
'#default_value' => variable_get('i18nstrings_allowed_textgroups', array()),
|
||||
'#description' => t('Select text groups to bypass filter format checking. . <strong>It is unsafe to check this option unless you are sure all the strings from that text groups are safe for translators</strong>. This option is just for backwards compatibility until all the contributed modules implement the new strings API.'),
|
||||
);
|
||||
}
|
||||
elseif (variable_get('i18nstrings_allowed_textgroups', 0)) {
|
||||
// Just in case there's a leftover variable before we updated some of the modules
|
||||
variable_del('i18nstrings_allowed_textgroups');
|
||||
}
|
||||
$form['array_filter'] = array('#type' => 'value', '#value' => TRUE);
|
||||
return system_settings_form($form);
|
||||
}
|
12
modules/i18n/i18nstrings/i18nstrings.info
Normal file
12
modules/i18n/i18nstrings/i18nstrings.info
Normal file
|
@ -0,0 +1,12 @@
|
|||
name = String translation
|
||||
description = Provides support for translation of user defined strings.
|
||||
dependencies[] = locale
|
||||
package = Multilanguage
|
||||
core = 6.x
|
||||
|
||||
; Information added by drupal.org packaging script on 2011-10-11
|
||||
version = "6.x-1.10"
|
||||
core = "6.x"
|
||||
project = "i18n"
|
||||
datestamp = "1318336004"
|
||||
|
219
modules/i18n/i18nstrings/i18nstrings.install
Normal file
219
modules/i18n/i18nstrings/i18nstrings.install
Normal file
|
@ -0,0 +1,219 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Installation file for i18nstrings module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of hook_install().
|
||||
*/
|
||||
function i18nstrings_install() {
|
||||
// Create database tables.
|
||||
drupal_install_schema('i18nstrings');
|
||||
|
||||
// Set module weight for it to run after core modules.
|
||||
db_query("UPDATE {system} SET weight = 10 WHERE name = 'i18nstrings' AND type = 'module'");
|
||||
|
||||
$ret = array();
|
||||
|
||||
// Add a field to track whether a translation needs updating.
|
||||
db_add_field($ret, 'locales_target', 'i18n_status', array('type' => 'int', 'not null' => TRUE, 'default' => 0));
|
||||
|
||||
// Add custom index to locales_source table.
|
||||
db_add_index($ret, 'locales_source', 'textgroup_location', array(array('textgroup', 30), 'location'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_uninstall().
|
||||
*/
|
||||
function i18nstrings_uninstall() {
|
||||
$ret = array();
|
||||
|
||||
// Create database tables.
|
||||
drupal_uninstall_schema('i18nstrings');
|
||||
// @TODO locale table cleanup, think about it.
|
||||
// Should we drop all strings for groups other than 'default' ?
|
||||
|
||||
// Drop custom field.
|
||||
db_drop_field($ret, 'locales_target', 'i18n_status');
|
||||
// Drop custom index.
|
||||
db_drop_index($ret, 'locales_source', 'textgroup_location');
|
||||
// May be a left over variable
|
||||
variable_del('i18nstrings_update_skip');
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_schema().
|
||||
*/
|
||||
function i18nstrings_schema() {
|
||||
$schema['i18n_strings'] = array(
|
||||
'description' => 'Metadata for source strings.',
|
||||
'fields' => array(
|
||||
'lid' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'description' => 'Source string ID. References {locales_source}.lid.',
|
||||
),
|
||||
'objectid' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
'description' => 'Object ID.',
|
||||
),
|
||||
'type' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
'description' => 'Object type for this string.',
|
||||
),
|
||||
'property' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
'description' => 'Object property for this string.',
|
||||
),
|
||||
'objectindex' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'description' => 'Integer value of Object ID.',
|
||||
),
|
||||
'format' => array(
|
||||
'description' => "The input format used by this string.",
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'default' => 0
|
||||
),
|
||||
|
||||
),
|
||||
'primary key' => array('lid'),
|
||||
);
|
||||
return $schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_schema_alter().
|
||||
*/
|
||||
function i18nstrings_schema_alter(&$schema) {
|
||||
// Add index for textgroup and location to {locales_source}.
|
||||
$schema['locales_source']['indexes']['textgroup_location'] = array(array('textgroup', 30), 'location');
|
||||
// Add field for tracking whether translations need updating.
|
||||
$schema['locales_target']['fields']['i18n_status'] = array(
|
||||
'description' => 'A boolean indicating whether this translation needs to be updated.',
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update from 5.x version
|
||||
*/
|
||||
function i18nstrings_update_5900() {
|
||||
i18nstrings_install();
|
||||
// Mark next update to be skipped
|
||||
variable_set('i18nstrings_update_skip', 1);
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add new 'oid' column to i18n_strings table.
|
||||
*/
|
||||
/*
|
||||
function i18nstrings_update_6000() {
|
||||
$ret = array();
|
||||
db_add_field($ret, 'i18n_strings', 'oid', array('type' => 'int', 'not null' => TRUE, 'default' => 0));
|
||||
return $ret;
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Drupal 6 update. Change field name, 'oid' was psql reserved name.
|
||||
*
|
||||
* ALTER TABLE `drupal6_i18n`.`i18n_strings` CHANGE COLUMN `oid` `objectid` INTEGER NOT NULL DEFAULT 0;
|
||||
*/
|
||||
function i18nstrings_update_6001() {
|
||||
$ret = array();
|
||||
if (!variable_get('i18nstrings_update_skip', 0)) {
|
||||
db_change_field($ret, 'i18n_strings', 'oid', 'objectid', array('type' => 'int', 'not null' => TRUE, 'default' => 0));
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add index to {locales_source}.
|
||||
*/
|
||||
function i18nstrings_update_6002() {
|
||||
$ret = array();
|
||||
if (!variable_get('i18nstrings_update_skip', 0)) {
|
||||
db_add_index($ret, 'locales_source', 'textgroup_location', array(array('textgroup', 30), 'location'));
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create i18n_strings_status schema.
|
||||
* Add a field to track whether a translation needs updating.
|
||||
*/
|
||||
function i18nstrings_update_6003() {
|
||||
$ret = array();
|
||||
if (!variable_get('i18nstrings_update_skip', 0)) {
|
||||
db_add_field($ret, 'locales_target', 'status', array('type' => 'int', 'not null' => TRUE, 'default' => 0));
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Add new D6 columns to i18n_strings table.
|
||||
*/
|
||||
/*
|
||||
function i18nstrings_update_6004() {
|
||||
$ret = array();
|
||||
|
||||
// Remove D5 primary keys (`strid`,`locale`).
|
||||
db_drop_primary_key($ret, 'i18n_strings');
|
||||
|
||||
// Add new lid field and add primary key back.
|
||||
db_add_field($ret, 'i18n_strings', 'lid', array('type' => 'int', 'not null' => TRUE, 'default' => 0));
|
||||
db_add_primary_key($ret, 'i18n_strings', array('lid'));
|
||||
|
||||
db_add_field($ret, 'i18n_strings', 'type', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
|
||||
db_add_field($ret, 'i18n_strings', 'property', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => 'default'));
|
||||
|
||||
return $ret;
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Add objectindex, format fields, change objectid to varchar
|
||||
*/
|
||||
function i18nstrings_update_6005() {
|
||||
$ret = array();
|
||||
if (!variable_get('i18nstrings_update_skip', 0)) {
|
||||
db_add_field($ret, 'i18n_strings', 'objectindex', array('type' => 'int', 'not null' => TRUE, 'default' => 0));
|
||||
// Populate new field from objectid before changing objectid to varchar
|
||||
$ret[] = update_sql('UPDATE {i18n_strings} SET objectindex = objectid');
|
||||
db_change_field($ret, 'i18n_strings', 'objectid', 'objectid', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
|
||||
// Add format field
|
||||
db_add_field($ret, 'i18n_strings', 'format', array('type' => 'int', 'not null' => TRUE, 'default' => 0));
|
||||
// Change wrong default value for property (was 'default')
|
||||
db_change_field($ret, 'i18n_strings', 'property', 'property', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename status field so it doesn't clash with other l10n modules
|
||||
*/
|
||||
function i18nstrings_update_6006() {
|
||||
$ret = array();
|
||||
if (!variable_get('i18nstrings_update_skip', 0)) {
|
||||
db_change_field($ret, 'locales_target', 'status', 'i18n_status', array('type' => 'int', 'not null' => TRUE, 'default' => 0));
|
||||
}
|
||||
return $ret;
|
||||
}
|
1230
modules/i18n/i18nstrings/i18nstrings.module
Normal file
1230
modules/i18n/i18nstrings/i18nstrings.module
Normal file
File diff suppressed because it is too large
Load diff
Reference in a new issue