diff options
| author | Lester Caine <lester@lsces.co.uk> | 2026-05-14 09:54:15 +0100 |
|---|---|---|
| committer | Lester Caine <lester@lsces.co.uk> | 2026-05-14 09:54:15 +0100 |
| commit | 974ca7dd01b899652a5ddee850ab3ec2a483527e (patch) | |
| tree | 55af98860bfd7db4d9885975ed77088369430677 /includes | |
| parent | f1e7aea6a7a18869a96052da37a642e93f89d01a (diff) | |
| download | languages-974ca7dd01b899652a5ddee850ab3ec2a483527e.tar.gz languages-974ca7dd01b899652a5ddee850ab3ec2a483527e.tar.bz2 languages-974ca7dd01b899652a5ddee850ab3ec2a483527e.zip | |
php-cs-fixer tidies to php8.5 standards
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'includes')
| -rwxr-xr-x | includes/classes/Babelfish.php | 50 | ||||
| -rwxr-xr-x | includes/classes/Bablotron.php | 278 | ||||
| -rwxr-xr-x | includes/classes/BitLanguage.php | 67 | ||||
| -rwxr-xr-x | includes/classes/LibertyTranslations.php | 9 |
4 files changed, 202 insertions, 202 deletions
diff --git a/includes/classes/Babelfish.php b/includes/classes/Babelfish.php index 8029db5..bcf1b73 100755 --- a/includes/classes/Babelfish.php +++ b/includes/classes/Babelfish.php @@ -34,7 +34,7 @@ class Babelfish { if (!isset($_SERVER['SERVER_PORT'])) { return $rv; } - + if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on')) { if ($_SERVER['SERVER_PORT'] != 443) { $rv .= ':' . $_SERVER['SERVER_PORT']; @@ -47,7 +47,7 @@ class Babelfish { return $rv; } - + /** * Return babelfish URL to translate \c $lang_from to \c $lang_to * @@ -55,22 +55,22 @@ class Babelfish { * @param lang_to */ function url($lang_from, $lang_to) { - static $url_map = array( + static $url_map = [ 'en' => 'english', 'fr' => 'french', 'de' => 'german', 'it' => 'italian', 'es' => 'spanish', 'pt' => 'portugese', - ); + ]; $lang_from = strtolower($lang_from); $lang_to = strtolower($lang_to); - + if (!isset($url_map[$lang_from])) { return ''; } - + $url = 'http://jump.altavista.com/translate_' . $url_map[$lang_from] . '.go' . '?http://babelfish.altavista.com/babelfish/tr?doit=done' . '&lp=' . $lang_from . '_' . $lang_to . @@ -91,8 +91,8 @@ class Babelfish { * @param lang_from Language to translate from */ function links($lang_from = 'en') { - static $fishes = array( - 'en' => array( # English + static $fishes = [ + 'en' => [ # English 'de' => 'Übersetzen Sie diese Seite ins Deutsche', 'es' => 'Traduzca esta paginación a español', 'fr' => 'Traduisez cette page en français', @@ -101,28 +101,28 @@ class Babelfish { 'zh' => '翻译这页成汉语 (CN)', 'ja' => '日本語にこのページを翻訳しなさい (Nihongo)', 'ko' => '한국인으로 이 페이지를 번역하십시요 (Hangul)', - ), - 'fr' => array( # French + ], + 'fr' => [ # French 'de' => 'Übersetzen Sie diese Seite in Deutschen', 'en' => 'Translate this page into English', - ), - 'de' => array( # German + ], + 'de' => [ # German 'en' => 'Translate this page into English', 'fr' => 'Traduisez cette page en français', - ), - 'it' => array( # Italian + ], + 'it' => [ # Italian 'en' => 'Translate this page into English', - ), - 'es' => array( # Spanish + ], + 'es' => [ # Spanish 'en' => 'Translate this page into English', - ), - 'pt' => array( # Portugese + ], + 'pt' => [ # Portugese 'en' => 'Translate this page into English', - ), - 'ru' => array( # Russian + ], + 'ru' => [ # Russian 'en' => 'Translate this page into English', - ), - ); + ], + ]; // \todo Use phpsniff or PEAR's Net_UserAgent_Detect to detect the browser type // as Netscape 4.x and possibly others displays 'ꯍ' literally @@ -139,9 +139,9 @@ class Babelfish { $a = []; foreach ($fishes[$lang_from] as $lang_to => $msg) { - $a[] = array('target' => $lang_to, - 'href' => Babelfish::url($lang_from, $lang_to), - 'msg' => $msg); + $a[] = ['target' => $lang_to, + 'href' => Babelfish::url($lang_from, $lang_to), + 'msg' => $msg, ]; } return $a; diff --git a/includes/classes/Bablotron.php b/includes/classes/Bablotron.php index ca33be6..83c4be0 100755 --- a/includes/classes/Bablotron.php +++ b/includes/classes/Bablotron.php @@ -29,144 +29,144 @@ */ class Bablotron extends BitBase { - /** - * @todo Variable is scoped here but not really used in this scope below. - */ - public $words; - /** - * Used to store the current language. - * - * @todo Not sure where this gets set from. Is used in other libraries. - */ - public $lan; - /** - * @todo Empty variable - does nothing - */ - public $db; - /** - * Spellchecking and finding of alternative words - */ - function __construct( $lan ) - { - parent::__construct(); - $this->lan = $lan; - } - /** - * @todo Empty function - does nothing - */ - function sql_error($query, $result) - { - return; - } - /** - * Spellchecks a line of text - * @param text line of text - * @param threshold the similarity threshold - * @returns array a list of alternative words if spelt incorrectly - */ - function spellcheck_text($text, $threshold = 5) - { - $words = preg_split("/\s/", $text); - $results = []; - foreach ($words as $word) - { - if (!$this->word_exists($word)) - { - $results[$word] = $this->find_similar_words($word, $threshold); - } - } - return $results; - } - /** - * Spellchecks a word - * @param word the word - * @param threshold the similarity threshold - * @returns array a list of alternative words if spelt incorrectly - */ - function spellcheck_word($word, $threshold = 5) - { - $results = []; - if (!$this->word_exists($word)) - { - $results[$word] = $this->find_similar_words($word, $threshold); - } - return $results; - } - /** - * Spellchecks a line of text - * @param text line of text - * @param threshold Not used @todo param threshold Not used - * @return array a list of incorrectly spelt words or words not found in the database - */ - function quick_spellcheck_text($text, $threshold = 5) - { - $words = preg_split("/\s/", $text); - $results = []; - foreach ($words as $word) - { - if (!$this->word_exists($word)) - { - $results[] = $word; - } - } - return $results; - } - /** - * Lists similar words by relevance threshold. - * @param word the word - * @param threshold the similarity threshold - * @return array of similar words and Levenshtein distance - */ - function find_similar_words($word, $threshold) - { - $similar = []; - $tbl = 'babl_words_' . $this->lan; - $word = addslashes( ( trim( $word ) ) ); - $sndx = substr($word, 0, 2); - $query = "select `word` AS word from `$tbl` where `di`=?"; - @$result = $this->mDb->query($query, array($sndx)); - while ($res = $result->fetchRow() ) - { - $tword = $res["word"]; - $lev = levenshtein($tword, $word); - if (count($similar) < $threshold) - { - $similar[$tword] = $lev; - asort ($similar); - } - else - { - // If the array is full then if the lev is better than the worst lev - // then update $keys = array_keys($similar); - $last_key = $keys[count($keys) - 1]; - if ($lev < $similar[$last_key]) - { - unset ($similar[$last_key]); - $similar[$tword] = $lev; - asort ($similar); - } - } - } - return $similar; - } - /** - * Checks if a word exists - * @param word the word - * @return int number of matches - */ - function word_exists($word) - { - $tbl = 'babl_words_' . $this->lan; - $word = addslashes( ( trim( $word ) ) ); - $query = "select `word` AS word from `$tbl` where `word`=?"; - $result = $this->mDb->query($query,array($word)); - return $result->numRows(); - } - /** - * @todo Empty function - does nothing - */ - function find_similar($word, $threshold) - { - } + /** + * @todo Variable is scoped here but not really used in this scope below. + */ + public $words; + /** + * Used to store the current language. + * + * @todo Not sure where this gets set from. Is used in other libraries. + */ + public $lan; + /** + * @todo Empty variable - does nothing + */ + public $db; + /** + * Spellchecking and finding of alternative words + */ + function __construct( $lan ) + { + parent::__construct(); + $this->lan = $lan; + } + /** + * @todo Empty function - does nothing + */ + function sql_error($query, $result) + { + + } + /** + * Spellchecks a line of text + * @param text line of text + * @param threshold the similarity threshold + * @returns array a list of alternative words if spelt incorrectly + */ + function spellcheck_text($text, $threshold = 5) + { + $words = preg_split("/\s/", $text); + $results = []; + foreach ($words as $word) + { + if (!$this->word_exists($word)) + { + $results[$word] = $this->find_similar_words($word, $threshold); + } + } + return $results; + } + /** + * Spellchecks a word + * @param word the word + * @param threshold the similarity threshold + * @returns array a list of alternative words if spelt incorrectly + */ + function spellcheck_word($word, $threshold = 5) + { + $results = []; + if (!$this->word_exists($word)) + { + $results[$word] = $this->find_similar_words($word, $threshold); + } + return $results; + } + /** + * Spellchecks a line of text + * @param text line of text + * @param threshold Not used @todo param threshold Not used + * @return array a list of incorrectly spelt words or words not found in the database + */ + function quick_spellcheck_text($text, $threshold = 5) + { + $words = preg_split("/\s/", $text); + $results = []; + foreach ($words as $word) + { + if (!$this->word_exists($word)) + { + $results[] = $word; + } + } + return $results; + } + /** + * Lists similar words by relevance threshold. + * @param word the word + * @param threshold the similarity threshold + * @return array of similar words and Levenshtein distance + */ + function find_similar_words($word, $threshold) + { + $similar = []; + $tbl = 'babl_words_' . $this->lan; + $word = addslashes( ( trim( $word ) ) ); + $sndx = substr($word, 0, 2); + $query = "select `word` AS word from `$tbl` where `di`=?"; + @$result = $this->mDb->query($query, [$sndx]); + while ($res = $result->fetchRow() ) + { + $tword = $res["word"]; + $lev = levenshtein($tword, $word); + if (count($similar) < $threshold) + { + $similar[$tword] = $lev; + asort ($similar); + } + else + { + // If the array is full then if the lev is better than the worst lev + // then update $keys = array_keys($similar); + $last_key = $keys[count($keys) - 1]; + if ($lev < $similar[$last_key]) + { + unset ($similar[$last_key]); + $similar[$tword] = $lev; + asort ($similar); + } + } + } + return $similar; + } + /** + * Checks if a word exists + * @param word the word + * @return int number of matches + */ + function word_exists($word) + { + $tbl = 'babl_words_' . $this->lan; + $word = addslashes( ( trim( $word ) ) ); + $query = "select `word` AS word from `$tbl` where `word`=?"; + $result = $this->mDb->query($query,[$word]); + return $result->numRows(); + } + /** + * @todo Empty function - does nothing + */ + function find_similar($word, $threshold) + { + } } ?> diff --git a/includes/classes/BitLanguage.php b/includes/classes/BitLanguage.php index 616cf66..0a31ae3 100755 --- a/includes/classes/BitLanguage.php +++ b/includes/classes/BitLanguage.php @@ -15,6 +15,7 @@ */ namespace Bitweaver\Languages; + use Bitweaver\BitSingleton; use Bitweaver\KernelTools; @@ -83,7 +84,7 @@ class BitLanguage extends BitSingleton { } public function __sleep() { - return array_merge( parent::__sleep(), array( 'mLanguageList' ) ); + return array_merge( parent::__sleep(), [ 'mLanguageList' ] ); } /** @@ -145,10 +146,10 @@ class BitLanguage extends BitSingleton { if( $this->verifyLanguage( $pParamHash ) ) { if( empty( $pParamHash['update_lang_code'] ) ) { $query = "INSERT INTO `".BIT_DB_PREFIX."i18n_languages` (`lang_code`,`english_name`,`native_name`,`is_disabled`) values (?,?,?,?)"; - $result = $this->mDb->query( $query, array( $pParamHash['lang_code'], $pParamHash['english_name'], $pParamHash['native_name'], $pParamHash['is_disabled'] ) ); + $result = $this->mDb->query( $query, [ $pParamHash['lang_code'], $pParamHash['english_name'], $pParamHash['native_name'], $pParamHash['is_disabled'] ] ); } else { $query = "UPDATE `".BIT_DB_PREFIX."i18n_languages` SET `lang_code`=?, `english_name`=?, `native_name`=?, `is_disabled`=? WHERE `lang_code`=?"; - $result = $this->mDb->query( $query, array( $pParamHash['lang_code'], $pParamHash['english_name'], $pParamHash['native_name'], $pParamHash['is_disabled'], $pParamHash['update_lang_code'] ) ); + $result = $this->mDb->query( $query, [ $pParamHash['lang_code'], $pParamHash['english_name'], $pParamHash['native_name'], $pParamHash['is_disabled'], $pParamHash['update_lang_code'] ] ); } } return count( $this->mErrors ) == 0; @@ -165,9 +166,9 @@ class BitLanguage extends BitSingleton { if( !empty( $pLangCode ) ) { $this->StartTrans(); $query = "DELETE FROM `".BIT_DB_PREFIX."i18n_strings` WHERE `lang_code`=?"; - $result = $this->mDb->query( $query, array( $pLangCode ) ); + $result = $this->mDb->query( $query, [ $pLangCode ] ); $query = "DELETE FROM `".BIT_DB_PREFIX."i18n_languages` WHERE `lang_code`=?"; - $result = $this->mDb->query( $query, array( $pLangCode ) ); + $result = $this->mDb->query( $query, [ $pLangCode ] ); $this->CompleteTrans(); } } @@ -182,9 +183,9 @@ class BitLanguage extends BitSingleton { if( !empty( $pSourceHash ) ) { $this->StartTrans(); $query = "DELETE FROM `".BIT_DB_PREFIX."i18n_strings` WHERE `source_hash`=?"; - $result = $this->mDb->query( $query, array( $pSourceHash ) ); + $result = $this->mDb->query( $query, [ $pSourceHash ] ); $query = "DELETE FROM `".BIT_DB_PREFIX."i18n_masters` WHERE `source_hash`=?"; - $result = $this->mDb->query( $query, array( $pSourceHash ) ); + $result = $this->mDb->query( $query, [ $pSourceHash ] ); $this->CompleteTrans(); } } @@ -236,7 +237,6 @@ class BitLanguage extends BitSingleton { return $langs; } - /** * verifyMastersLoaded verify that master strings are loaded * @@ -272,7 +272,7 @@ class BitLanguage extends BitSingleton { SELECT im.`source_hash` AS `hash_key`, `source`, `package`, im.`source_hash` FROM `".BIT_DB_PREFIX."i18n_masters` im WHERE UPPER( `source` ) LIKE ? ORDER BY im.`source`"; - return $this->mDb->getAssoc( $query, array( '%'.strtoupper( $pQuerySource ).'%' ) ); + return $this->mDb->getAssoc( $query, [ '%'.strtoupper( $pQuerySource ).'%' ] ); } /** @@ -332,26 +332,26 @@ class BitLanguage extends BitSingleton { $this->StartTrans(); $newSourceHash = $this->getSourceHash( $pParamHash['new_source'] ); if( $this->masterStringExists( $newSourceHash ) ) { - $oldCount = $this->mDb->getOne( "SELECT COUNT(`source_hash`) FROM `".BIT_DB_PREFIX."i18n_strings` WHERE `source_hash`=?", array( $pParamHash['source_hash'] ) ); - $newCount = $this->mDb->getOne( "SELECT COUNT(`source_hash`) FROM `".BIT_DB_PREFIX."i18n_strings` WHERE `source_hash`=?", array( $newSourceHash ) ); + $oldCount = $this->mDb->getOne( "SELECT COUNT(`source_hash`) FROM `".BIT_DB_PREFIX."i18n_strings` WHERE `source_hash`=?", [ $pParamHash['source_hash'] ] ); + $newCount = $this->mDb->getOne( "SELECT COUNT(`source_hash`) FROM `".BIT_DB_PREFIX."i18n_strings` WHERE `source_hash`=?", [ $newSourceHash ] ); if( $newCount ) { $this->mErrors['master'] = 'There was a conflict updating the master string. The new string already has translations entered.'; } else { // we have updated a master string to an existing master string $query = "UPDATE `".BIT_DB_PREFIX."i18n_strings` SET `source_hash`=?, `last_modified`=? WHERE `source_hash`=?"; - $trans = $this->mDb->query($query, array( $newSourceHash, time(), $pParamHash['source_hash'] ) ); + $trans = $this->mDb->query($query, [ $newSourceHash, time(), $pParamHash['source_hash'] ] ); $query = "DELETE FROM `".BIT_DB_PREFIX."i18n_masters` WHERE `source_hash`=?"; - $trans = $this->mDb->query($query, array( $pParamHash['source_hash'] ) ); + $trans = $this->mDb->query($query, [ $pParamHash['source_hash'] ] ); } } elseif( $this->masterStringExists( $pParamHash['source_hash'] ) ) { $query = "UPDATE `".BIT_DB_PREFIX."i18n_strings` SET `source_hash`=?, `last_modified`=? WHERE `source_hash`=?"; - $trans = $this->mDb->query($query, array( $newSourceHash, time(), $pParamHash['source_hash'] ) ); + $trans = $this->mDb->query($query, [ $newSourceHash, time(), $pParamHash['source_hash'] ] ); $query = "UPDATE `".BIT_DB_PREFIX."i18n_masters` SET `source_hash`=?, `source`=?, `created`=? WHERE `source_hash`=?"; - $trans = $this->mDb->query($query, array( $newSourceHash, $pParamHash['new_source'], time(), $pParamHash['source_hash'] ) ); + $trans = $this->mDb->query($query, [ $newSourceHash, $pParamHash['new_source'], time(), $pParamHash['source_hash'] ] ); unset( $this->mStrings[$pParamHash['source_hash']] ); } else { $query = "INSERT INTO `".BIT_DB_PREFIX."i18n_masters` (`source`,`source_hash`, `created`, `package`) VALUES (?,?,?,?)"; - $trans = $this->mDb->query($query, array( $pParamHash['new_source'], $newSourceHash, time(), $package ) ); + $trans = $this->mDb->query($query, [ $pParamHash['new_source'], $newSourceHash, time(), $package ] ); } if( count( $this->mErrors ) == 0 ) { $this->mStrings['master'][$newSourceHash]['source'] = $pParamHash['new_source']; @@ -361,7 +361,6 @@ class BitLanguage extends BitSingleton { return count( $this->mErrors ) == 0; } - /** * importMasterStrings * @@ -376,15 +375,15 @@ class BitLanguage extends BitSingleton { foreach( $lang as $key=>$val ) { $sourceHash = $this->getSourceHash( $key ); $query = "SELECT * FROM `".BIT_DB_PREFIX."i18n_masters` WHERE `source_hash`=?"; - $trans = $this->mDb->getAssoc($query, array( $sourceHash ) ); + $trans = $this->mDb->getAssoc($query, [ $sourceHash ] ); if( $trans ) { if( $pOverwrite ) { $query = "UPDATE `".BIT_DB_PREFIX."i18n_masters` SET `source`=?, `created`=? WHERE `source_hash`=?"; - $trans = $this->mDb->query($query, array( $val, time(), $sourceHash ) ); + $trans = $this->mDb->query($query, [ $val, time(), $sourceHash ] ); $count++; } } else { - $this->storeMasterString( array( 'new_source' => $val, 'source_hash' => $sourceHash ) ); + $this->storeMasterString( [ 'new_source' => $val, 'source_hash' => $sourceHash ] ); $count++; } } @@ -401,13 +400,13 @@ class BitLanguage extends BitSingleton { */ public function storeTranslationString( $pLangCode, $pString, $pSourceHash ) { $query = "DELETE FROM `".BIT_DB_PREFIX."i18n_strings` WHERE `source_hash`=? AND `lang_code`=?"; - $result = $this->mDb->query( $query, array( $pSourceHash, $pLangCode ) ); + $result = $this->mDb->query( $query, [ $pSourceHash, $pLangCode ] ); // we don't need things where '{$menu.menu_title}' is the full string in the database // if you change this regexp, please modify the one in kernel/smarty_bit/prefilter.tr.php as well (approx line 76) if( !empty( $pString ) && !preg_match( '!^(\{\$[^\}]*\})+$!', $pString ) ) { $query = "INSERT INTO `".BIT_DB_PREFIX."i18n_strings` (`lang_code`,`trans`,`source_hash`, `last_modified`) values (?,?,?,?)"; - $result = $this->mDb->query( $query, array( $pLangCode, $pString, $pSourceHash, time() ) ); + $result = $this->mDb->query( $query, [ $pLangCode, $pString, $pSourceHash, time() ] ); } // pretty brutal on mass-saving, but cache always needs purging after translation saved. $this->clearCache(); @@ -426,7 +425,7 @@ class BitLanguage extends BitSingleton { FROM `".BIT_DB_PREFIX."i18n_strings` ist WHERE ist.`source_hash`=? ORDER BY ist.`lang_code`"; - return $this->mDb->getAssoc( $query, array( $pSourceHash ) ); + return $this->mDb->getAssoc( $query, [ $pSourceHash ] ); } /** @@ -504,13 +503,13 @@ class BitLanguage extends BitSingleton { foreach( $lang as $key=>$val ) { $hashKey = $this->getSourceHash( $key ); if( !$this->masterStringExists( $hashKey ) ) { - $this->storeMasterString( array( 'source_hash' => $hashKey, 'new_source' => $key ) ); + $this->storeMasterString( [ 'source_hash' => $hashKey, 'new_source' => $key ] ); } $trans = $this->lookupTranslation( $key, $pLangCode, false ); if( !is_null( $trans ) ) { if( $pOverwrite ) { $query = "UPDATE `".BIT_DB_PREFIX."i18n_strings` SET `trans`=?, `last_modified`=? WHERE `source_hash`=? AND `lang_code`=?"; - $trans = $this->mDb->query($query, array( $val, time(), $hashKey, $pLangCode ) ); + $trans = $this->mDb->query($query, [ $val, time(), $hashKey, $pLangCode ] ); $count++; } elseif( !empty( $val ) && strtolower( $trans ) != strtolower( $val ) ) { $this->mImportConflicts[$pLangCode][$hashKey]['import'] = $val; @@ -521,7 +520,7 @@ class BitLanguage extends BitSingleton { } } elseif( !empty( $val ) && (strtolower( $key ) != strtolower( $val )) ) { $query = "INSERT INTO `".BIT_DB_PREFIX."i18n_strings` (`trans`,`source_hash`,`lang_code`,`last_modified`) VALUES (?,?,?,?)"; - $trans = $this->mDb->query($query, array( $val, $hashKey, $pLangCode, time() ) ); + $trans = $this->mDb->query($query, [ $val, $hashKey, $pLangCode, time() ] ); $count++; } } @@ -540,7 +539,7 @@ class BitLanguage extends BitSingleton { if ( $pLangCode ) { // see if there is anything in the table $query = "SELECT COUNT(`source_hash`) FROM `".BIT_DB_PREFIX."i18n_strings` ist WHERE ist.`lang_code`=?"; - $count = $this->mDb->getOne($query, array( $pLangCode ) ); + $count = $this->mDb->getOne($query, [ $pLangCode ] ); if( empty( $count ) ) { $this->importTranslationStrings( $pLangCode ); } @@ -562,7 +561,7 @@ class BitLanguage extends BitSingleton { LEFT OUTER JOIN `".BIT_DB_PREFIX."i18n_strings` ist ON( ist.`source_hash`=im.`source_hash` AND ist.`lang_code`=? ) LEFT OUTER JOIN `".BIT_DB_PREFIX."i18n_version_map` ivm ON( im.`source_hash`=ivm.`source_hash` ) ORDER BY im.`source`"; - $this->mStrings[$pLangCode] = $this->mDb->getAssoc( $query, array( $pLangCode ) ); + $this->mStrings[$pLangCode] = $this->mDb->getAssoc( $query, [ $pLangCode ] ); } /** @@ -641,22 +640,22 @@ class BitLanguage extends BitSingleton { LEFT OUTER JOIN `".BIT_DB_PREFIX."i18n_version_map` ivm ON( ivm.`source_hash`=im.`source_hash` AND ivm.`version`=? ) LEFT OUTER JOIN `".BIT_DB_PREFIX."i18n_strings` ist ON( im.`source_hash`=ist.`source_hash` AND `lang_code`=? ) WHERE im.`source_hash`=?"; - $ret = $this->mDb->getRow($query, array( BIT_MAJOR_VERSION, $pLangCode, $sourceHash ) ); + $ret = $this->mDb->getRow($query, [ BIT_MAJOR_VERSION, $pLangCode, $sourceHash ] ); if( $pOverrideUsage && $gBitSystem->isFeatureActive( 'i18n_record_untranslated' ) ) { $query = "SELECT `source_hash` FROM `".BIT_DB_PREFIX."i18n_masters` WHERE `source_hash`=?"; - $source = $this->mDb->getOne($query, array( $sourceHash ) ); + $source = $this->mDb->getOne($query, [ $sourceHash ] ); if( empty( $source ) ) { - $this->storeMasterString( array( 'source_hash' => $sourceHash, 'new_source' => $pString ) ); + $this->storeMasterString( [ 'source_hash' => $sourceHash, 'new_source' => $pString ] ); } } if( $pOverrideUsage && $gBitSystem->isFeatureActive( 'i18n_track_translation_usage' ) ) { if( empty( $ret['usage_source_hash'] ) ) { $query = "INSERT INTO `".BIT_DB_PREFIX."i18n_version_map` (`source_hash`,`version`) VALUES (?,?)"; - $trans = $this->mDb->query($query, array( $sourceHash, BIT_MAJOR_VERSION ) ); + $trans = $this->mDb->query($query, [ $sourceHash, BIT_MAJOR_VERSION ] ); } } } - return isset( $ret['trans'] ) ? $ret['trans'] : null; + return $ret['trans'] ?? null; } /** @@ -667,7 +666,7 @@ class BitLanguage extends BitSingleton { * @return string master string with given source hash */ public function getMasterString( $pSourceHash ) { - return $this->mDb->getOne( "SELECT `source` FROM `" . BIT_DB_PREFIX . "i18n_masters` WHERE `source_hash` = ? ", array( $pSourceHash ) ); + return $this->mDb->getOne( "SELECT `source` FROM `" . BIT_DB_PREFIX . "i18n_masters` WHERE `source_hash` = ? ", [ $pSourceHash ] ); } /** diff --git a/includes/classes/LibertyTranslations.php b/includes/classes/LibertyTranslations.php index 0527b9b..ad69b03 100755 --- a/includes/classes/LibertyTranslations.php +++ b/includes/classes/LibertyTranslations.php @@ -7,6 +7,7 @@ */ namespace Bitweaver\Languages; + use Bitweaver\BitBase; use Bitweaver\Liberty\LibertyBase; @@ -23,13 +24,13 @@ use Bitweaver\Liberty\LibertyBase; global $gBitSystem, $gBitLanguage; $ret = []; if( BitBase::verifyId( $this->mContentId ) ) { - $translationId = $this->mDb->getOne( "SELECT `translation_id` FROM `".BIT_DB_PREFIX."i18n_content_trans_map` WHERE `content_id`=?", array( $this->mContentId ) ); + $translationId = $this->mDb->getOne( "SELECT `translation_id` FROM `".BIT_DB_PREFIX."i18n_content_trans_map` WHERE `content_id`=?", [ $this->mContentId ] ); if( BitBase::verifyId( $translationId ) ) { $query = "SELECT lc.`content_id`, lc.`title`, lc.`lang_code`, ictm.`translation_id` FROM `".BIT_DB_PREFIX."i18n_content_trans_map` ictm INNER JOIN `".BIT_DB_PREFIX."liberty_content` lc ON( lc.`content_id`=ictm.`content_id` ) WHERE ictm.`translation_id`=?"; - $result = $this->mDb->query( $query, array( $translationId ) ); + $result = $this->mDb->query( $query, [ $translationId ] ); while( $aux = $result->fetchRow() ) { // default to site language if( empty( $aux['lang_code'] )) { @@ -60,7 +61,7 @@ use Bitweaver\Liberty\LibertyBase; // make sure we don't have a translation_id for this content yet if( BitBase::verifyId( $pParamHash['from_id'] ?? 0 ) ) { - $pParamHash['translation_id'] = $this->mDb->getOne( "SELECT `translation_id` FROM `".BIT_DB_PREFIX."i18n_content_trans_map` WHERE `content_id`=?", array( $pParamHash['from_id'] ) ); + $pParamHash['translation_id'] = $this->mDb->getOne( "SELECT `translation_id` FROM `".BIT_DB_PREFIX."i18n_content_trans_map` WHERE `content_id`=?", [ $pParamHash['from_id'] ] ); } // if we have this page in this translation, we should inform the user somehow. @@ -157,7 +158,7 @@ die; function translation_content_store( $pObject, $pParamHash ) { // if we are creating this content and we have a from_id, we know that we're translating a page // mInfo['content_id'] isn't set when content is created - if( empty( $pObject->mInfo['content_id'] ) && BitBase::verifyId( $_REQUEST['i18n']['from_id'] ?? 0 ) ) { + if( empty( $pObject->mInfo['content_id'] ) && BitBase::verifyId( $_REQUEST['i18n']['from_id'] ?? 0 ) ) { $trans = new LibertyTranslations(); $storeHash = $_REQUEST['i18n']; $storeHash['content_id'] = $pParamHash['content_id']; |
