true) if the original array contained non-integers * array( int_key => true) if the original array was OK */ function validateListArray($array) { if(is_array($array)) { $tmp = array(); foreach ($array as $value) { $iVal = (int)$value; if($iVal != $value) return array(0 => true); $tmp[$iVal] = true; } $array = $tmp; } return count($array) <= 0 || isset($array[0]) ? array(0 => true) : $array; } function findLangStrings( $searchText, $groupWords = SEARCH_COMBINE_WORDS_AS_EXACT, $searchInKeys = true, $searchInStrings = true, $searchInParams = true, $arrCategoryIDs = null, $arrLanguageIDs = null ) { function sqlLikeClause($fieldName, $arrWords, $groupWords) { if (!is_array($arrWords) || strlen($fieldName) <= 0) return ''; switch ($groupWords) { case SEARCH_COMBINE_WORDS_AS_AND: $sql = implode("%' AND $fieldName LIKE '%", $arrWords); break; case SEARCH_COMBINE_WORDS_AS_OR: $sql = implode("%' OR $fieldName LIKE '%", $arrWords); break; default: $sql = implode(' ', $arrWords); } $sql = "($fieldName LIKE '%$sql%')"; return $sql; } function sqlInClause($fieldName, $arrIDs) { $sql = ''; $sqlValid = false; if(is_array($arrIDs)) { $sql = "($fieldName IN("; foreach ($arrIDs as $ID => $val) { $ID = (int)$ID; if($ID <= 0) continue; $sqlValid = true; $sql .= $ID.','; } $sql = trim($sql,','); $sql .= '))'; } return $sqlValid ? $sql : ''; } function implodeNonEmpty($strGlue, $arr) { foreach ($arr as $key => $val) if (strlen($val) <= 0) unset($arr[$key]); return implode($strGlue, $arr); } if ( strlen($searchText) > 0 ) { $searchText = addslashes($searchText); $likeWildcards = array ('%', '_'); $likeWildcardsEscaped = array('\%', '\_'); $searchText = str_replace($likeWildcards, $likeWildcardsEscaped, $searchText); $arrWords = preg_split("/\s+/", $searchText, -1, PREG_SPLIT_NO_EMPTY); foreach( $arrWords as $key => $val ) $arrWords[$key] = strtoupper( $val ); $sqlSearchInKeys = $searchInKeys ? sqlLikeClause('UPPER(`LocalizationKeys`.`Key`)', $arrWords, $groupWords) : ''; $sqlSearchInStrings = $searchInStrings ? sqlLikeClause('UPPER(`LocalizationStrings`.`String`)', $arrWords, $groupWords) : ''; $sqlSearchInParams = $searchInParams ? sqlLikeClause('UPPER(`LocalizationStringParams`.`Description`)', $arrWords, $groupWords) : ''; $sqlSearchClause = implodeNonEmpty(' OR ', array($sqlSearchInKeys, $sqlSearchInStrings, $sqlSearchInParams)); $sqlSearchClause = "($sqlSearchClause)"; } else $sqlSearchClause = ''; $sqlSearchInCategories = sqlInClause('`LocalizationCategories`.`ID`', $arrCategoryIDs); $sqlSearchInLanguages = sqlInClause('`LocalizationLanguages`.`ID`', $arrLanguageIDs); $sqlWhereClause = implodeNonEmpty(' AND ', array($sqlSearchClause, $sqlSearchInCategories, $sqlSearchInLanguages)); if ( strlen($sqlWhereClause) ) $sqlWhereClause = "WHERE $sqlWhereClause "; else $sqlWhereClause = ''; $sql = " SELECT DISTINCT `LocalizationStrings`.`IDKey` AS `IDKey`, `LocalizationStrings`.`IDLanguage` AS `IDLanguage`, `LocalizationKeys`.`Key` AS `Key`, `LocalizationStrings`.`String` AS `String`, `LocalizationLanguages`.`Title` AS `Language`, `LocalizationCategories`.`Name` AS `Category` FROM `LocalizationStringParams` RIGHT JOIN `LocalizationKeys` ON (`LocalizationStringParams`.`IDKey` = `LocalizationKeys`.`ID`) LEFT JOIN `LocalizationStrings` ON (`LocalizationStrings`.`IDKey` = `LocalizationKeys`.`ID`) LEFT JOIN `LocalizationCategories` ON (`LocalizationKeys`.`IDCategory` = `LocalizationCategories`.`ID`) LEFT JOIN `LocalizationLanguages` ON (`LocalizationStrings`.`IDLanguage` = `LocalizationLanguages`.`ID`) $sqlWhereClause ORDER BY `Language`, `Category`, `Key`"; $resSearchResult = db_res($sql); return $resSearchResult; } function searchBlock() { global $searchString, $searchCombineWordsAs, $searchShowAdvancedSettings, $searchInKeys, $searchInStrings, $searchInParams, $searchCategories, $searchLanguages; ob_start(); ?>
Look for: /> /> />
Search in:
/>
/>
/>
Show strings from categories:
Show strings from languages:
Error: wrong form data.'; foreach ($langStrings as $key => $value) $langStrings[$key] = process_db_input($value); if ( strlen($newKeyName) <= 0 ) return 'Error: Key name is not specified.'; if ( strlen($newCategoryName) > 0 ) { db_res("INSERT INTO `LocalizationCategories` (`Name`) VALUES ('$newCategoryName')"); $categoryID = mysql_insert_id(); if ( !$categoryID ) return 'Error: Could not create a new category.'; } else { $cnt = db_res('SELECT COUNT(*) FROM `LocalizationCategories` WHERE `ID`='.$categoryID); $cnt = mysql_fetch_row($cnt); if ( $cnt[0] <= 0 ) return 'Error: Wrong category specified.'; } db_res("INSERT INTO `LocalizationKeys` (`IDCategory`, `Key`) VALUES ($categoryID, '$newKeyName')", 0); $newKeyID = mysql_insert_id(); if ( $newKeyID <= 0 ) return 'Error: Could not insert a new language key.'; // parse string params $arrParams = array(); preg_match_all('/([0-9]+) - (\S+[^\\n\\r]*)/', $newStringParams, $arrParams); foreach ($arrParams[1] as $key => $paramID) { $paramID = (int)$paramID; $paramDescription = $arrParams[2][$key]; $paramDescription = process_db_input($paramDescription); db_res(" INSERT INTO `LocalizationStringParams` (`IDKey`, `IDParam`, `Description`) VALUES ($newKeyID, $paramID, '$paramDescription')" ); if( !mysql_affected_rows() ) return 'Could not insert a string parameter.'; } foreach( $langStrings as $langKey => $langString ) { //NOTE: This piece of code can potentially // insert language strings that don't belong // to any language in case if a client generates // his POST data himself in an unusual way. // As this issue is not in fact dangerous for the script's // security, no checks have been added to prevent this. $langKey = (int)$langKey; db_res(" INSERT INTO `LocalizationStrings` (`IDKey`, `IDLanguage`, `String`) VALUES ($newKeyID, $langKey, '$langString') "); if (mysql_affected_rows() <= 0) return 'Error: could not add a language string.'; } if ( $_POST['RecompileLangFiles'] == 'on' ) { if ( !compileLanguage() ) { return 'Error: could not recompile language files.'; } } return 'A new language key has been successfully created.'; } ob_start(); ?> Add a new language key









Close
New language key name:
Category: Use existing: or create a new one:
Language string parameters: Describe string parameters, each on a separate line. Follow the example below:
0 - member's nickname
1 - current membership name
Note that, if you don't exactly follow this format, parameters won't be saved.
String texts for available languages: $langTitle) { $langID = db_value( "SELECT `ID` FROM `LocalizationLanguages` WHERE `Name` = '$langName'" ); echo ''.htmlspecialchars($langTitle).':'; ?>

Recompile language files to apply changes.

The string has NOT been updated.'; } if ( $_POST['RecompileLangFile'] == 'on' ) { if ( !compileLanguage($langID) ) { return 'Error: could not recompile language file.'; } } return 'The string has been successfully updated.'; } $IDKey = (int)$_GET['editStringKeyID']; $IDLanguage = (int)$_GET['editStringLangID']; ob_start(); $script = " function insertParam(strTextAreaID, strSelectParamsID) { textArea = document.getElementById(strTextAreaID); selectParams = document.getElementById(strSelectParamsID); if( !selectParams.options.length || selectParams.selectedIndex == -1 ) return false; selectedOption = selectParams.options[selectParams.selectedIndex]; textArea.value = '' + textArea.value + selectedOption.value; textArea.focus(); } "; if ( isset($_POST['UpdateLangString']) ) { $body = messageTemplate(updateLanguageString().'

Close'); return PopupPageTemplate('Edit Language String', $body, $script); } $sql = " SELECT `LocalizationStrings`.`IDKey` AS `IDKey`, `LocalizationStrings`.`IDLanguage` AS `IDLanguage`, `LocalizationKeys`.`Key` AS `Key`, `LocalizationStrings`.`String` AS `String`, `LocalizationLanguages`.`Title` AS `Language`, `LocalizationCategories`.`Name` AS `Category` FROM `LocalizationStringParams` RIGHT JOIN `LocalizationKeys` ON (`LocalizationStringParams`.`IDKey` = `LocalizationKeys`.`ID`) LEFT JOIN `LocalizationStrings` ON (`LocalizationStrings`.`IDKey` = `LocalizationKeys`.`ID`) LEFT JOIN `LocalizationCategories` ON (`LocalizationKeys`.`IDCategory` = `LocalizationCategories`.`ID`) LEFT JOIN `LocalizationLanguages` ON (`LocalizationStrings`.`IDLanguage` = `LocalizationLanguages`.`ID`) WHERE `LocalizationStrings`.`IDKey` = $IDKey AND `LocalizationStrings`.`IDLanguage` = $IDLanguage "; $resLangString = db_res($sql); if ( !mysql_num_rows($resLangString) ) return PopupPageTemplate('Edit Language String', messageTemplate('Error: specified string not found.')); else { $arrLangString = mysql_fetch_assoc($resLangString); ob_start(); ?>
Key:
String:
Parameters: Available string parameters (click on a parameter to insert it at the end of the string):
Category:
Language:
Recompile corresponding language file to apply changes.

$prefixLen ) $prefix .= '...'; return $prefix; } function deleteLanguageKey() { $langKeyID = (int)$_POST['DeleteLangKey']; $resKey = db_res('SELECT `Key` FROM `LocalizationKeys` WHERE `ID` = '.$langKeyID); if ( !mysql_num_rows($resKey) ) return 'Error: language key not found.'; db_res('DELETE FROM `LocalizationKeys` WHERE `ID`='.$langKeyID); db_res('DELETE FROM `LocalizationStrings` WHERE `IDKey` = '.$langKeyID); db_res('DELETE FROM `LocalizationStringParams` WHERE `IDKey` = '.$langKeyID); if (!compileLanguage()) return 'Error: could not recompile language files.'; $arrKey = mysql_fetch_assoc($resKey); return 'The '.htmlspecialchars($arrKey['Key']).' language key has been successfully removed.'; } if ( isset($_POST['DeleteLangKey']) ) $resultMsg = deleteLanguageKey(); global $searchString, $searchCombineWordsAs, $searchInKeys, $searchInStrings, $searchInParams, $searchCategories, $searchLanguages; $res = findLangStrings( $searchString, $searchCombineWordsAs, $searchInKeys, $searchInStrings, $searchInParams, $searchCategories, $searchLanguages); ob_start(); ?> Add a new language key

'; $numRows = mysql_num_rows($res); if ( $numRows > $maxRowsToShow && !$showMoreThanMax) { $getQuery = $_SERVER["QUERY_STRING"]; if(strlen($getQuery) > 0) $getQuery .= '&'; $getQuery .= 'showMoreThanMax=yes'; ?>
Your search criteria result in strings.
Are you sure you want to show all of them?
Yes
Key String Category Language  
No strings found matching your criteria.
Edit
Delete

Error: language does not exist.')); function updateLanguage($langID) { $langID = (int)$langID; $newLanguageName = process_db_input($_POST['LanguageName']); $sNewFlag = process_db_input($_POST['Flag']); $newLanguageTitle = process_db_input($_POST['LanguageTitle']); if ( !strlen($newLanguageName) ) return 'Error: language name not specified.'; $sQuery = " UPDATE `LocalizationLanguages` SET `Name`='$newLanguageName', `Title`='$newLanguageTitle', `Flag` = '$sNewFlag' WHERE `ID` = $langID"; db_res( $sQuery ); if ( mysql_affected_rows() ) return 'Language has been successfully updated.'; return 'Error: language could not be updated.'; } if ( isset($_POST['UpdateLanguage']) ) return PopupPageTemplate('Edit Language', messageTemplate(updateLanguage($langID))); $arrLang = mysql_fetch_assoc($resLang); ob_start(); $isLangDefault = getParam('lang_default') == $arrLang['Name']; ?>
Language title:
Language code ?: />
Flag:

Error: please specify a title for the new language.'; if(strlen($newLangName) <= 0) return 'Error: please specify a code for the new language.'; db_res(" INSERT INTO `LocalizationLanguages` (`Name`, `Flag`, `Title`) VALUES ('{$newLangName}', '{$sFlag}', '{$newLangTitle}') "); if(mysql_affected_rows() <= 0) return 'Error: could not add a new language to the database.'; $newLangID = mysql_insert_id(); $resSourceLangStrings = db_res(" SELECT `IDKey`, `String` FROM `LocalizationStrings` WHERE `IDLanguage` = $sourceLangID "); while($arr = mysql_fetch_assoc($resSourceLangStrings)) { $arr['String'] = addslashes($arr['String']); db_res(" INSERT INTO `LocalizationStrings` (`IDKey`, `IDLanguage`, `String`) VALUES ('{$arr['IDKey']}', $newLangID, '{$arr['String']}') ", 0); if( !mysql_affected_rows() ) return 'Error: could not add a language string to the database.'; } return ''.htmlspecialchars(stripslashes($newLangName)).' language has been successfully created.'; } function getLangName($langID) { $langName = db_res('SELECT `Name` FROM `LocalizationLanguages` WHERE `ID` = '.(int)$langID); $langName = mysql_fetch_row($langName); return $langName[0]; } if ( $_POST['CopyLanguage'] ) $resultMsg = copyLanguage(); else if ( isset($_POST['CompileLanguage']) ) { $langName = getLangName($_POST['CompileLanguage']); if ( compileLanguage((int)$_POST['CompileLanguage']) ) $resultMsg = ''.htmlspecialchars($langName).' language has been successfully compiled.'; else $resultMsg = 'Cannot delete the default language. You have to set another default language for the site in global settings -> Change language settings to be able to delete this one.'; else { if ( deleteLanguage((int)$_POST['DeleteLanguage']) ) $resultMsg = ''.htmlspecialchars($langName).' language has been successfully removed.'; else $resultMsg = 'Error: could not delete a language.'; } } ob_start(); displayLanguageSettings(); $sCon1 = panelSection('Language', ob_get_clean()); $arrLangs = getLangsArr(false, true); ob_start(); ?>
New language: Code: Copy from: Flag:



'; ?>
Language Flag  
[] (default)' : '') ?> Edit
Compile
Delete
'; if (strlen($sCurLang)) $sDefC = $sCurLang; else $sDefC = strtolower(getParam( 'default_country' )); while($aList = mysql_fetch_array($rCountryList)) { $sFlagCode = strtolower($aList['ISO2']); $sSelect = $sDefC == $sFlagCode ? 'selected="selected"' : '' ; $sCode .= ''; $sSelect = ''; } $sCode .= ''; $sImageCode = 'flag'; $sCode .= ' '.$sImageCode; return $sCode; } function displayLanguageSettings() { ?>
:

What you should know about the new Dolphin language management system.

The new Dolphin language management system is developed to ease your work with language strings by managing them via this specially designed web interface rather than editing them directly in a language file, unlike it was in previous Dolphin versions. Note that, in Dolphin, you should NOT edit language files manually – they’re now used by the script as temporary files with partial language information only for the sake of performance. All necessary language information is now stored in the database and can be managed via this web interface.

You can see an option of compiling languages in the top section of the language management interface. Compiling a language means creating and writing a fresh version of a corresponding language file in the langs folder of the script with the updated information about language strings and keys stored in the database. After you change/add a language string or a language key, a corresponding language file (or files) needs to be recompiled so the changes are applied and shown on the pages where that string is used. At the bottom of the forms for editing and adding language strings/keys there are checkboxes that specify whether to recompile corresponding language files automatically after the changes are saved. These checkboxes are checked by default. You can uncheck them before submitting a form not to recompile language files every time in case you’re editing a lot of language strings one by one. This option is available because compiling a language file is a relatively resource-intensive process, so you better recompile language files once after you’ve finished with editing language strings rather than loading your server by recompiling language files after editing each string.
IMPORTANT: What you should know about the Dolphin language management system.