summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlsces <lester@lsces.co.uk>2025-08-27 15:03:14 +0100
committerlsces <lester@lsces.co.uk>2025-08-27 15:03:14 +0100
commit5f6a9c555cff03720076a241b2e0dab026f111f6 (patch)
tree9ce57bf4c000b3b28bdb617eeaa152dbaa9514b6
parent6e24ce632d3bfaf09bf6aaffe2055fb1d485c17e (diff)
downloadlanguages-5f6a9c555cff03720076a241b2e0dab026f111f6.tar.gz
languages-5f6a9c555cff03720076a241b2e0dab026f111f6.tar.bz2
languages-5f6a9c555cff03720076a241b2e0dab026f111f6.zip
Kernel functions changes to cover uninitialized variables and style changes for PHP8.4
-rwxr-xr-x[-rw-r--r--]ajax_translate.php6
-rwxr-xr-x[-rw-r--r--]edit_languages.php28
-rwxr-xr-x[-rw-r--r--]get_strings.php37
-rwxr-xr-x[-rw-r--r--]import.php12
-rwxr-xr-x[-rw-r--r--]master_strings.php28
-rwxr-xr-x[-rw-r--r--]switch_lang.php2
-rwxr-xr-x[-rw-r--r--]translate_strings.php18
7 files changed, 65 insertions, 66 deletions
diff --git a/ajax_translate.php b/ajax_translate.php
index 91763e6..06a8975 100644..100755
--- a/ajax_translate.php
+++ b/ajax_translate.php
@@ -13,10 +13,10 @@
/**
* Initialization
*/
-$gLightweightScan = TRUE;
-require_once( '../kernel/includes/setup_inc.php' );
+$gLightweightScan = true;
+require_once '../kernel/includes/setup_inc.php';
-$translation = NULL;
+$translation = null;
if( !empty( $_REQUEST['lang'] ) && !empty( $_REQUEST['source_hash'] ) ) {
if( $masterString = $gBitLanguage->getMasterString( $_REQUEST['source_hash'] ) ) {
diff --git a/edit_languages.php b/edit_languages.php
index fb0e97e..b3921f8 100644..100755
--- a/edit_languages.php
+++ b/edit_languages.php
@@ -13,13 +13,13 @@
/**
* Initialization
*/
-require_once( '../kernel/includes/setup_inc.php' );
+require_once '../kernel/includes/setup_inc.php';
$gBitSystem->verifyPermission( 'p_languages_edit' );
// Get available languages from DB
$languages = $gBitLanguage->listLanguages();
-$gBitSmarty->assignByRef('languages', $languages);
+$gBitSmarty->assign('languages', $languages);
if( !empty( $_REQUEST['all_trans'] ) ) {
$gBitSmarty->assign( 'allTrans', 1 );
@@ -36,10 +36,10 @@ if( !empty( $_REQUEST['clear_cache'] ) ) {
} elseif( !empty( $_REQUEST['translate'] ) ) {
$editLang = $_REQUEST['lang'];
$gBitSmarty->assign( 'lang', $editLang );
- $gBitSmarty->assign( 'translate', TRUE );
+ $gBitSmarty->assign( 'translate', true );
if( !empty( $_REQUEST['hash'] ) ) {
$tranStrings = $gBitLanguage->getTranslationString( $_REQUEST['hash'], $editLang );
- $gBitSmarty->assignByRef('tranStrings', $tranStrings );
+ $gBitSmarty->assign('tranStrings', $tranStrings );
} else {
// what strings do we want to display?
if( empty( $_REQUEST['char'] ) ) {
@@ -61,13 +61,13 @@ if( !empty( $_REQUEST['clear_cache'] ) ) {
if( preg_match( $pattern, $tran['source'] ) ) {
$tranStrings[$key] = $tran;
if( strlen( $tran['source'] ) > 70 ) {
- $tranStrings[$key]['textarea'] = TRUE;
+ $tranStrings[$key]['textarea'] = true;
}
}
}
}
$gBitSmarty->assign( 'char', empty( $_REQUEST['char'] ) ? '' : $_REQUEST['char'] );
- $gBitSmarty->assignByRef( 'tranStrings', $tranStrings );
+ $gBitSmarty->assign( 'tranStrings', $tranStrings );
}
} elseif( isset($_REQUEST["delete_language"] ) ) {
if( $gBitUser->hasPermission( 'p_languages_delete' ) ) {
@@ -76,7 +76,7 @@ if( !empty( $_REQUEST['clear_cache'] ) ) {
unset( $languages[$_REQUEST['delete_lang_code']] );
} else {
$formHash['delete_lang_code'] = $_REQUEST['lang'];
- $formHash['delete_language'] = TRUE;
+ $formHash['delete_language'] = true;
$msgHash = array(
'label' => tra('Delete Language'),
'confirm_item' => tra('Are you sure you want to remove this language?') . ' ' . $languages[$_REQUEST['lang']]['native_name'],
@@ -89,19 +89,19 @@ if( !empty( $_REQUEST['clear_cache'] ) ) {
if( $gBitLanguage->storeLanguage( $_REQUEST ) ) {
$languages = $gBitLanguage->listLanguages();
$gBitSmarty->assign( 'saveSuccess', tra( 'The language has been saved.' ) );
- $gBitSmarty->assignByRef( 'defaults', $_REQUEST );
+ $gBitSmarty->assign( 'defaults', $_REQUEST );
} else {
- $gBitSmarty->assignByRef( 'saveErrors', $gBitLanguage->mErrors );
- $gBitSmarty->assignByRef( 'defaults', $_REQUEST );
- $gBitSmarty->assign( 'editDescription', TRUE );
+ $gBitSmarty->assign( 'saveErrors', $gBitLanguage->mErrors );
+ $gBitSmarty->assign( 'defaults', $_REQUEST );
+ $gBitSmarty->assign( 'editDescription', true );
}
} elseif( isset($_REQUEST["new_language"] ) ) {
- $gBitSmarty->assign( 'editDescription', TRUE );
+ $gBitSmarty->assign( 'editDescription', true );
} elseif( isset($_REQUEST["edit_language"] ) ) {
if( !empty( $languages[$_REQUEST['lang']] ) ) {
- $gBitSmarty->assignByRef( 'defaults', $languages[$_REQUEST['lang']] );
+ $gBitSmarty->assign( 'defaults', $languages[$_REQUEST['lang']] );
}
- $gBitSmarty->assign( 'editDescription', TRUE );
+ $gBitSmarty->assign( 'editDescription', true );
}
$gBitSystem->display( 'bitpackage:languages/edit_languages.tpl', tra( 'Edit Languages' ) , array( 'display_mode' => 'edit' ));
diff --git a/get_strings.php b/get_strings.php
index b3e4f4a..0c7760b 100644..100755
--- a/get_strings.php
+++ b/get_strings.php
@@ -17,13 +17,13 @@
/**
* Update the language.php files
* call example: get_strings.php?lang=fr&close
- * @param lang=xx : only translate lang 'xx' - if the parameter is not given all languages are translated
- * @param comments : generate all comments (equal to close&module)
- * @param close : look for similar strings that are allready translated and generate a commet if a 'match' is made
- * @param module : generate comments that describes in which .php and/or .tpl\n module(s) a certain string was found (useful for checking translations in context)
- * @param patch : looks for the file 'language.patch' in the same directory as the corresponding language.php and overrides any strings in language.php - good if a user does not agree with some translations or if only changes are sent to the maintaner
- * @param spelling : generate a file spellcheck_me.txt in the applicable languages directory that contains all the words used in the translated text. This makes it simple to use a spellchecker on the resulting file
- * @param groupwrite : Sets the generated files permissions to allow the generated language.php also be group writable. This is good for translators if they do not have root access to tiki but are in the same group as the webserver. Please remember to have write access removed when translation is finished for security reasons. (Run script again whithout this parameter)
+ * @var string lang=xx : only translate lang 'xx' - if the parameter is not given all languages are translated
+ * @var string comments : generate all comments (equal to close&module)
+ * @var string close : look for similar strings that are allready translated and generate a commet if a 'match' is made
+ * @var string module : generate comments that describes in which .php and/or .tpl\n module(s) a certain string was found (useful for checking translations in context)
+ * @var string patch : looks for the file 'language.patch' in the same directory as the corresponding language.php and overrides any strings in language.php - good if a user does not agree with some translations or if only changes are sent to the maintaner
+ * @var string spelling : generate a file spellcheck_me.txt in the applicable languages directory that contains all the words used in the translated text. This makes it simple to use a spellchecker on the resulting file
+ * @var string groupwrite : Sets the generated files permissions to allow the generated language.php also be group writable. This is good for translators if they do not have root access to tiki but are in the same group as the webserver. Please remember to have write access removed when translation is finished for security reasons. (Run script again whithout this parameter)
*/
@@ -147,7 +147,7 @@ function writeTranslationPair ($fd, $key, $val) {
////////////////////////////////////////////////////////////////////////////
-require_once( '../kernel/includes/setup_inc.php' );
+require_once '../kernel/includes/setup_inc.php';
if(!$gBitUser->isAdmin()) {
die("You need to be admin to run this script");
@@ -166,7 +166,7 @@ $nosections = isset ($_REQUEST['nosections']);
// Get the language(s)
$languages = Array();
-print("Languages: ");
+print "Languages: ";
if (isset ($_REQUEST["lang"])) {
$lang = $_REQUEST["lang"];
$languages[] = $lang;
@@ -182,7 +182,7 @@ else {
}
closedir ($handle);
}
-print("<br />");
+print "<br />";
$files = Array();
@@ -217,12 +217,12 @@ foreach ($languages as $sel) {
if (!file_exists ($origPatch)) {
die ("No patch file .../$origPatch exisits");
}
- require ($origPatch);
+ require $origPatch;
$patchLang = $lang;
unset ($lang);
}
- require("lang/$sel/language.php");
+ require "lang/$sel/language.php";
if (isset ($lang[$oldEndMarker])) {
unset ($lang[$oldEndMarker]);
@@ -243,7 +243,7 @@ foreach ($languages as $sel) {
$fw = fopen( LANGUAGES_PKG_PATH."lang/$sel/new_language.php",'w');
- print("&lt;");
+ print "&lt;";
fwrite($fw,"<");
writeFile_and_User ($fw, "?php");
// The comment coding:utf-8 is for the benefit of emacs
@@ -344,11 +344,11 @@ foreach ($languages as $sel) {
// Do not translate text in Smarty comments: {* Smarty comment *}
$data = preg_replace ('/(?s)\{\*.*?\*\}/', '', $data); // Smarty comment
- // Strings of the type {tr}{$perms[user].type}{/tr} need (should)
+ // Strings of the type {$perms[user].type} need (should)
// not be translated
$data = preg_replace ('/(?s)\{tr\}\s*\{[$][^\}]*?\}\s*\{\/tr\}/','',$data);
- // Only extract {tr} ... {/tr} in .tpl-files
+ // Only extract ... in .tpl-files
preg_match_all ('/(?s)\{tr\}(.+?)\{\/tr\}/', $data, $uqwords);
}
@@ -479,7 +479,7 @@ foreach ($languages as $sel) {
$moduleText = " // ## MODULES " . $modulename[$key];
}
- writeFile_and_User ($fw, "${closeText}${moduleText}");
+ writeFile_and_User ($fw, "{$closeText}{$moduleText}");
}
writeFile_and_User ($fw, "\n");
}
@@ -521,7 +521,7 @@ foreach ($languages as $sel) {
}
}
writeFile_and_User ($fw, '"'.$endMarker.'"=>"'.$endMarker.'");'."\n");
- print ("?&gt;<br />\n");
+ print "?&gt;<br />\n";
fwrite ($fw, '?>'."\n");
fclose ($fw);
@@ -547,5 +547,4 @@ foreach ($languages as $sel) {
umask($old_umask); // Reset umask back to original value
}
-}
-?>
+} \ No newline at end of file
diff --git a/import.php b/import.php
index 12b2cec..7d2c200 100644..100755
--- a/import.php
+++ b/import.php
@@ -12,22 +12,22 @@
/**
* Initialization
*/
-require_once( '../kernel/includes/setup_inc.php' );
+require_once '../kernel/includes/setup_inc.php';
$gBitSystem->verifyPermission( 'p_languages_import' );
-$impMsg = array();
+$impMsg = [];
$mid = 'bitpackage:languages/import_languages.tpl';
// Lookup translated names for the languages
-$impLanguages = $gBitLanguage->listLanguages( TRUE, TRUE );
+$impLanguages = $gBitLanguage->listLanguages( true, true );
foreach( array_keys($impLanguages) as $langCode ) {
if( !$gBitLanguage->isImportFileAvailable( $langCode ) ) {
unset( $impLanguages[$langCode] );
}
}
-$gBitSmarty->assignByRef('impLanguages', $impLanguages );
+$gBitSmarty->assign('impLanguages', $impLanguages );
if (isset($_REQUEST["exp_language"])) {
$exp_language = $_REQUEST["exp_language"];
@@ -58,7 +58,7 @@ if (isset($_REQUEST["import"])) {
if( ($_REQUEST['overwrite'] == 'r') && !empty( $gBitLanguage->mImportConflicts ) ) {
unset( $impMsg['error'] );
$impMsg['warning'][] = tra( "Conflicts occured during language import" );
- $gBitSmarty->assignByRef( 'impConflicts', $gBitLanguage->mImportConflicts );
+ $gBitSmarty->assign( 'impConflicts', $gBitLanguage->mImportConflicts );
$mid = 'bitpackage:languages/import_resolve.tpl';
}
@@ -112,7 +112,7 @@ if (isset($_REQUEST["import"])) {
// Get languages that can be exported
$expLanguages = $gBitLanguage->getImportedLanguages();
-$gBitSmarty->assignByRef('expLanguages', $expLanguages );
+$gBitSmarty->assign('expLanguages', $expLanguages );
$gBitSmarty->assign( 'impmsg', $impMsg );
diff --git a/master_strings.php b/master_strings.php
index 151fbf8..dca0f6f 100644..100755
--- a/master_strings.php
+++ b/master_strings.php
@@ -11,13 +11,13 @@
/**
* Initialization
*/
-require_once( '../kernel/includes/setup_inc.php' );
+require_once '../kernel/includes/setup_inc.php';
$gBitSystem->verifyPermission( 'p_languages_edit_master' );
$languages = $gBitLanguage->listLanguages();
-$gBitSmarty->assignByRef( 'languages', $languages );
-$feedback = $masterMsg = array();
+$gBitSmarty->assign( 'languages', $languages );
+$feedback = $masterMsg = [];
if( !empty( $_REQUEST['source_hash'] ) && !is_array( $_REQUEST['source_hash'] ) ) {
$_REQUEST['source_hash'] = array( $_REQUEST['source_hash'] );
@@ -26,7 +26,7 @@ if( !empty( $_REQUEST['source_hash'] ) && !is_array( $_REQUEST['source_hash'] )
if( !empty( $_REQUEST['delete_master'] ) && !empty( $_REQUEST['source_hash'] ) ) {
if( empty( $_REQUEST['confirm'] ) ) {
$gBitSystem->setBrowserTitle( tra( 'Confirm Delete' ) );
- $formHash['delete_master'] = TRUE;
+ $formHash['delete_master'] = true;
$msgHash = array(
'label' => tra( 'Delete Master Strings' ),
'warning' => tra( 'This will remove the language master string. If you are tracking translations and the string is still used, it will be inserted again, however, any translations associated with it will be lost.' ),
@@ -40,9 +40,9 @@ if( !empty( $_REQUEST['delete_master'] ) && !empty( $_REQUEST['source_hash'] ) )
} else {
foreach( $_REQUEST['source_hash'] as $source_hash ) {
if( $gBitLanguage->expungeMasterString( $source_hash ) ) {
- $success = TRUE;
+ $success = true;
} else {
- $error = TRUE;
+ $error = true;
}
}
@@ -80,12 +80,12 @@ if( !empty( $_REQUEST['delete_master'] ) && !empty( $_REQUEST['source_hash'] ) )
}
$masterMsg['success'][] = 'Translation strings have been updated';
} elseif( !empty( $_REQUEST['find'] ) && !empty( $_REQUEST['search'] ) ) {
- $gBitSmarty->assignByRef( 'masterStrings', $gBitLanguage->searchMasterStrings( $_REQUEST['find'] ) );
+ $gBitSmarty->assign( 'masterStrings', $gBitLanguage->searchMasterStrings( $_REQUEST['find'] ) );
} else {
$gBitLanguage->loadMasterStrings(
- NULL,
- ( !empty( $_REQUEST['filter'] ) ? $_REQUEST['filter'] : NULL ),
- ( !empty( $_REQUEST['filter_lang'] ) ? $_REQUEST['filter_lang'] : NULL )
+ null,
+ ( !empty( $_REQUEST['filter'] ) ? $_REQUEST['filter'] : null ),
+ ( !empty( $_REQUEST['filter_lang'] ) ? $_REQUEST['filter_lang'] : null )
);
// work out what strings to display
@@ -107,7 +107,7 @@ if( !empty( $_REQUEST['delete_master'] ) && !empty( $_REQUEST['source_hash'] ) )
}
}
$gBitSmarty->assign( 'char', empty( $_REQUEST['char'] ) ? '' : $_REQUEST['char'] );
- $gBitSmarty->assignByRef( 'masterStrings', $masterStrings );
+ $gBitSmarty->assign( 'masterStrings', $masterStrings );
}
@@ -115,12 +115,12 @@ if( !empty( $_REQUEST['source_hash'] ) && empty( $_REQUEST['cancel'] ) ) {
foreach( $_REQUEST['source_hash'] as $reqSourceHash ) {
$gBitLanguage->loadMasterStrings( $reqSourceHash );
if( strlen( $gBitLanguage->mStrings['master'][$reqSourceHash]['source'] ) > 100 ) {
- $gBitLanguage->mStrings['master'][$reqSourceHash]['textarea'] = TRUE;
+ $gBitLanguage->mStrings['master'][$reqSourceHash]['textarea'] = true;
}
$translate[$reqSourceHash] = $gBitLanguage->getTranslatedStrings( $_REQUEST['source_hash'] );
}
- $gBitSmarty->assignByRef( 'masterStrings', $gBitLanguage->mStrings['master'] );
- $gBitSmarty->assignByRef( 'tranStrings', $translate );
+ $gBitSmarty->assign( 'masterStrings', $gBitLanguage->mStrings['master'] );
+ $gBitSmarty->assign( 'tranStrings', $translate );
$gBitSmarty->assign( 'sources', $_REQUEST['source_hash'] );
}
diff --git a/switch_lang.php b/switch_lang.php
index d0ebd3d..f8db1ef 100644..100755
--- a/switch_lang.php
+++ b/switch_lang.php
@@ -8,7 +8,7 @@
/**
* Initialization
*/
-require_once( '../kernel/includes/setup_inc.php' );
+require_once '../kernel/includes/setup_inc.php';
include_once( KERNEL_PKG_CLASS_PATH.'BitBase.php' );
if (isset($_SERVER['HTTP_REFERER'])) {
diff --git a/translate_strings.php b/translate_strings.php
index c34db76..574c00c 100644..100755
--- a/translate_strings.php
+++ b/translate_strings.php
@@ -13,13 +13,13 @@
/**
* Initialization
*/
-require_once( '../kernel/includes/setup_inc.php' );
+require_once '../kernel/includes/setup_inc.php';
$gBitSystem->verifyPermission( 'p_languages_edit' );
// Get available languages from DB
$languages = $gBitLanguage->listLanguages();
-$gBitSmarty->assignByRef('languages', $languages);
+$gBitSmarty->assign('languages', $languages);
if( !empty( $_REQUEST['all_trans'] ) ) {
$gBitSmarty->assign( 'allTrans', 1 );
@@ -33,7 +33,7 @@ if( !empty( $_REQUEST['un_trans'] ) ) {
if( isset( $_REQUEST['save_translations'] ) ) {
$editLang = $_REQUEST['lang'];
$gBitLanguage->loadLanguage( $editLang );
- $storedStrings = NULL;
+ $storedStrings = null;
foreach( $_REQUEST['edit_trans'] as $sourceHash => $string ) {
if( $string != $gBitLanguage->mStrings[$editLang][$sourceHash]['trans'] ) {
// we need to remove the $_REQUEST slashes here to avoid stuff like:
@@ -51,16 +51,16 @@ if( isset( $_REQUEST['save_translations'] ) ) {
}
}
$tranStrings = $gBitLanguage->getTranslationString( $sourceHash, $editLang );
- $gBitSmarty->assignByRef('tranStrings', $tranStrings );
+ $gBitSmarty->assign('tranStrings', $tranStrings );
$gBitSmarty->assign( 'lang', $editLang );
- $gBitSmarty->assign( 'translate', TRUE );
+ $gBitSmarty->assign( 'translate', true );
$gBitSmarty->assign( 'saveSuccess', tra( "The following items have been saved successfully" ).":" );
$gBitSmarty->assign( 'storedStrings', $storedStrings );
}
if( !empty( $_REQUEST['hash'] ) ) {
$tranStrings = $gBitLanguage->getTranslationString( $_REQUEST['hash'], $editLang );
- $gBitSmarty->assignByRef('tranStrings', $tranStrings );
+ $gBitSmarty->assign('tranStrings', $tranStrings );
} elseif( !empty( $_REQUEST['choose_lang'] ) ) {
$editLang = $_REQUEST['choose_lang'];
$gBitSmarty->assign( 'editLang', $editLang );
@@ -72,7 +72,7 @@ if( !empty( $_REQUEST['hash'] ) ) {
} elseif ( $_REQUEST['char'] == '+' ) {
$pattern = "/^[^a-zA-Z]/";
} elseif ( $_REQUEST['char'] == 'all' ) {
- $pattern = NULL;
+ $pattern = null;
} else {
$pattern = "/^".$_REQUEST['char']."/i";
}
@@ -85,13 +85,13 @@ if( !empty( $_REQUEST['hash'] ) ) {
if( empty( $pattern ) || preg_match( $pattern, $tran['source'] ) ) {
$tranStrings[$key] = $tran;
if( strlen( $tran['source'] ) > 50 ) {
- $tranStrings[$key]['textarea'] = TRUE;
+ $tranStrings[$key]['textarea'] = true;
}
}
}
}
$gBitSmarty->assign( 'char', empty( $_REQUEST['char'] ) ? '' : $_REQUEST['char'] );
- $gBitSmarty->assignByRef( 'tranStrings', $tranStrings );
+ $gBitSmarty->assign( 'tranStrings', $tranStrings );
}
$gBitSystem->display( 'bitpackage:languages/translate_strings.tpl', tra( 'Edit Translations' ) , array( 'display_mode' => 'edit' ));