trt
This commit is contained in:
@ -152,36 +152,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Перевод для строки в которой встречаются подстроки вида: trt('')
|
|
||||||
function parseGT($text)
|
|
||||||
{
|
|
||||||
$result='';
|
|
||||||
$pLen=4; //Длина преамбулы trt(
|
|
||||||
$cut=0;
|
|
||||||
$from = 0; // Позиция поиска для итерации
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
$pos1 = strpos($text, 'trt(', $from);
|
|
||||||
if($pos1 !== false)
|
|
||||||
{
|
|
||||||
$from = $pos1+$pLen+1;
|
|
||||||
$pos2 = false;
|
|
||||||
if($text[$pos1+$pLen] == '"') $pos2 = strpos($text, '")', $from);
|
|
||||||
if($text[$pos1+$pLen] == '\'') $pos2 = strpos($text, '\')', $from);
|
|
||||||
if($pos2 !== false)
|
|
||||||
{
|
|
||||||
$result.=substr($text, $cut, $pos1 - $cut );
|
|
||||||
//$result.=__(substr($text, $pos1+3, $pos2 - $pos1 - 3 ));
|
|
||||||
$toTranslate=substr($text, $pos1+$pLen+1, $pos2 - $pos1 - $pLen-1 );
|
|
||||||
$result.=trt($toTranslate);
|
|
||||||
$cut=$pos2+2;
|
|
||||||
$from = $pos2 + $pLen;
|
|
||||||
}
|
|
||||||
}else break;
|
|
||||||
}
|
|
||||||
$result.=substr($text, $cut); //Копируем остатки
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
function special_handler($exception)
|
function special_handler($exception)
|
||||||
{
|
{
|
||||||
@ -273,7 +243,7 @@
|
|||||||
$resX = $db->query($sql);
|
$resX = $db->query($sql);
|
||||||
while ($rowX = $resX->fetch(PDO::FETCH_ASSOC))// $row - ассоциативный массив значений, ключи - названия столбцов
|
while ($rowX = $resX->fetch(PDO::FETCH_ASSOC))// $row - ассоциативный массив значений, ключи - названия столбцов
|
||||||
{
|
{
|
||||||
$xmls='<?xml version="1.0" encoding="UTF-8"?><metadata>'.parseGT($rowX['xml']).'</metadata>';
|
$xmls='<?xml version="1.0" encoding="UTF-8"?><metadata>'.trts($rowX['xml']).'</metadata>';
|
||||||
}
|
}
|
||||||
if($xmls=='')
|
if($xmls=='')
|
||||||
{
|
{
|
||||||
@ -361,7 +331,7 @@
|
|||||||
$resX = $db->query('select xml from '.$Schema.'_metadata where del=false and name=\''.$typename.'\';');
|
$resX = $db->query('select xml from '.$Schema.'_metadata where del=false and name=\''.$typename.'\';');
|
||||||
while ($rowX = $resX->fetch(PDO::FETCH_ASSOC))// $row - ассоциативный массив значений, ключи - названия столбцов
|
while ($rowX = $resX->fetch(PDO::FETCH_ASSOC))// $row - ассоциативный массив значений, ключи - названия столбцов
|
||||||
{
|
{
|
||||||
$xmls='<?xml version="1.0" encoding="UTF-8"?><metadata>'.parseGT($rowX['xml']).'</metadata>';
|
$xmls='<?xml version="1.0" encoding="UTF-8"?><metadata>'.trts($rowX['xml']).'</metadata>';
|
||||||
}
|
}
|
||||||
if($xmls=='')
|
if($xmls=='')
|
||||||
{
|
{
|
||||||
@ -482,7 +452,7 @@
|
|||||||
$resX = $db->query('select xml from '.$Schema.'_metadata where del=false and name=\''.$typename.'\';');
|
$resX = $db->query('select xml from '.$Schema.'_metadata where del=false and name=\''.$typename.'\';');
|
||||||
while ($rowX = $resX->fetch(PDO::FETCH_ASSOC))// $row - ассоциативный массив значений, ключи - названия столбцов
|
while ($rowX = $resX->fetch(PDO::FETCH_ASSOC))// $row - ассоциативный массив значений, ключи - названия столбцов
|
||||||
{
|
{
|
||||||
$xmls='<?xml version="1.0" encoding="UTF-8"?><metadata>'.parseGT($rowX['xml']).'</metadata>';
|
$xmls='<?xml version="1.0" encoding="UTF-8"?><metadata>'.trts($rowX['xml']).'</metadata>';
|
||||||
}
|
}
|
||||||
if($xmls=='')
|
if($xmls=='')
|
||||||
{
|
{
|
||||||
@ -606,7 +576,7 @@
|
|||||||
$resX = $db->query('select xml from '.$Schema.'_metadata where del=false and name=\''.$typename.'\';');
|
$resX = $db->query('select xml from '.$Schema.'_metadata where del=false and name=\''.$typename.'\';');
|
||||||
while ($rowX = $resX->fetch(PDO::FETCH_ASSOC))// $row - ассоциативный массив значений, ключи - названия столбцов
|
while ($rowX = $resX->fetch(PDO::FETCH_ASSOC))// $row - ассоциативный массив значений, ключи - названия столбцов
|
||||||
{
|
{
|
||||||
$xmls='<?xml version="1.0" encoding="UTF-8"?><metadata>'.parseGT($rowX['xml']).'</metadata>';
|
$xmls='<?xml version="1.0" encoding="UTF-8"?><metadata>'.trts($rowX['xml']).'</metadata>';
|
||||||
}
|
}
|
||||||
if($xmls=='')
|
if($xmls=='')
|
||||||
{
|
{
|
||||||
@ -661,7 +631,7 @@
|
|||||||
$resX = $db->query('select xml from '.$Schema.'_metadata where del=false and name=\''.$typename.'\';');
|
$resX = $db->query('select xml from '.$Schema.'_metadata where del=false and name=\''.$typename.'\';');
|
||||||
while ($rowX = $resX->fetch(PDO::FETCH_ASSOC))// $row - ассоциативный массив значений, ключи - названия столбцов
|
while ($rowX = $resX->fetch(PDO::FETCH_ASSOC))// $row - ассоциативный массив значений, ключи - названия столбцов
|
||||||
{
|
{
|
||||||
$xmls='<?xml version="1.0" encoding="UTF-8"?><metadata>'.parseGT($rowX['xml']).'</metadata>';
|
$xmls='<?xml version="1.0" encoding="UTF-8"?><metadata>'.trts($rowX['xml']).'</metadata>';
|
||||||
}
|
}
|
||||||
if($xmls=='')
|
if($xmls=='')
|
||||||
{
|
{
|
||||||
@ -828,7 +798,7 @@
|
|||||||
$resX = $db->query('select xml from '.$Schema.'_metadata where del=false and name=\''.$typename.'\';');
|
$resX = $db->query('select xml from '.$Schema.'_metadata where del=false and name=\''.$typename.'\';');
|
||||||
while ($rowX = $resX->fetch(PDO::FETCH_ASSOC))// $row - ассоциативный массив значений, ключи - названия столбцов
|
while ($rowX = $resX->fetch(PDO::FETCH_ASSOC))// $row - ассоциативный массив значений, ключи - названия столбцов
|
||||||
{
|
{
|
||||||
$xmls='<?xml version="1.0" encoding="UTF-8"?><metadata>'.parseGT($rowX['xml']).'</metadata>';
|
$xmls='<?xml version="1.0" encoding="UTF-8"?><metadata>'.trts($rowX['xml']).'</metadata>';
|
||||||
}
|
}
|
||||||
if($xmls=='')
|
if($xmls=='')
|
||||||
{
|
{
|
||||||
@ -872,7 +842,7 @@
|
|||||||
$resX = $db->query('select xml from '.$Schema.'_metadata where del=false and name=\''.$typename.'\';');
|
$resX = $db->query('select xml from '.$Schema.'_metadata where del=false and name=\''.$typename.'\';');
|
||||||
while ($rowX = $resX->fetch(PDO::FETCH_ASSOC))// $row - ассоциативный массив значений, ключи - названия столбцов
|
while ($rowX = $resX->fetch(PDO::FETCH_ASSOC))// $row - ассоциативный массив значений, ключи - названия столбцов
|
||||||
{
|
{
|
||||||
$xmls='<?xml version="1.0" encoding="UTF-8"?><metadata>'.parseGT($rowX['xml']).'</metadata>';
|
$xmls='<?xml version="1.0" encoding="UTF-8"?><metadata>'.trts($rowX['xml']).'</metadata>';
|
||||||
}
|
}
|
||||||
if($xmls=='')
|
if($xmls=='')
|
||||||
{
|
{
|
||||||
@ -944,7 +914,7 @@
|
|||||||
$resX = $db->query('select xml from '.$Schema.'_metadata where del=false and name=\''.$typename.'\';');
|
$resX = $db->query('select xml from '.$Schema.'_metadata where del=false and name=\''.$typename.'\';');
|
||||||
while ($rowX = $resX->fetch(PDO::FETCH_ASSOC))// $row - ассоциативный массив значений, ключи - названия столбцов
|
while ($rowX = $resX->fetch(PDO::FETCH_ASSOC))// $row - ассоциативный массив значений, ключи - названия столбцов
|
||||||
{
|
{
|
||||||
$xmls='<?xml version="1.0" encoding="UTF-8"?><metadata>'.parseGT($rowX['xml']).'</metadata>';
|
$xmls='<?xml version="1.0" encoding="UTF-8"?><metadata>'.trts($rowX['xml']).'</metadata>';
|
||||||
}
|
}
|
||||||
if(!$xmls){
|
if(!$xmls){
|
||||||
sendError("XML node \"".$typename."\" not find!");
|
sendError("XML node \"".$typename."\" not find!");
|
||||||
@ -1141,7 +1111,7 @@
|
|||||||
$resX = $db->query('select xml from '.$Schema.'_metadata where del=false and name=\''.$typename.'\';');
|
$resX = $db->query('select xml from '.$Schema.'_metadata where del=false and name=\''.$typename.'\';');
|
||||||
while ($rowX = $resX->fetch(PDO::FETCH_ASSOC))// $row - ассоциативный массив значений, ключи - названия столбцов
|
while ($rowX = $resX->fetch(PDO::FETCH_ASSOC))// $row - ассоциативный массив значений, ключи - названия столбцов
|
||||||
{
|
{
|
||||||
$xmls='<?xml version="1.0" encoding="UTF-8"?><metadata>'.parseGT($rowX['xml']).'</metadata>';
|
$xmls='<?xml version="1.0" encoding="UTF-8"?><metadata>'.trts($rowX['xml']).'</metadata>';
|
||||||
}
|
}
|
||||||
if($xmls=='')
|
if($xmls=='')
|
||||||
{
|
{
|
||||||
@ -1398,7 +1368,7 @@
|
|||||||
$resX = $db->query('select xml from '.$Schema.'_metadata where del=false and name=\''.$typename.'\';');
|
$resX = $db->query('select xml from '.$Schema.'_metadata where del=false and name=\''.$typename.'\';');
|
||||||
while ($rowX = $resX->fetch(PDO::FETCH_ASSOC))// $row - ассоциативный массив значений, ключи - названия столбцов
|
while ($rowX = $resX->fetch(PDO::FETCH_ASSOC))// $row - ассоциативный массив значений, ключи - названия столбцов
|
||||||
{
|
{
|
||||||
$xmls='<?xml version="1.0" encoding="UTF-8"?><metadata>'.parseGT($rowX['xml']).'</metadata>';
|
$xmls='<?xml version="1.0" encoding="UTF-8"?><metadata>'.trts($rowX['xml']).'</metadata>';
|
||||||
}
|
}
|
||||||
if($xmls=='')
|
if($xmls=='')
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1611,10 +1611,10 @@ function isInt(value)
|
|||||||
function isFloat(value)
|
function isFloat(value)
|
||||||
{
|
{
|
||||||
let num="-1234567890.,"
|
let num="-1234567890.,"
|
||||||
for (i=0;i<value.length;i++)
|
for(let i=0;i<value.length;i++)
|
||||||
{
|
{
|
||||||
let b=true;
|
let b=true;
|
||||||
for(j=0;j<num.length;j++)
|
for(let j=0;j<num.length;j++)
|
||||||
{
|
{
|
||||||
if(value.charAt(i)==num.charAt(j)) b=false;
|
if(value.charAt(i)==num.charAt(j)) b=false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,13 +10,14 @@ function getScript($path)
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
//Функция для перевода текста без применения GetText
|
//Функция для перевода текста без применения GetText "trt("
|
||||||
function trt($text)
|
function trt($text)
|
||||||
{
|
{
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
$result='';
|
$result='';
|
||||||
$sql='select translation from main._translations where del=false and language_id=(select id from main._languages where short_name=\''.$_SESSION["LNG"].'\') and identifier=\''.$text.'\';';
|
$sql='select translation from main._translations where del=false and language_id='.$_SESSION["LNG"].' and identifier=\''.$text.'\';';
|
||||||
|
//$sql='select translation from main._translations where del=false and language_id=(select id from main._languages where short_name=\''.$_SESSION["LNG"].'\') and identifier=\''.$text.'\';';
|
||||||
$res = NULL;
|
$res = NULL;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -38,6 +39,62 @@ function trt($text)
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Перевод для строки в которой встречаются подстроки вида: trt('')
|
||||||
|
function trts($text)
|
||||||
|
{
|
||||||
|
$result='';
|
||||||
|
$pLen=4; //Длина преамбулы trt(
|
||||||
|
$cut=0;
|
||||||
|
$from = 0; // Позиция поиска для итерации
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
$pos1 = strpos($text, 'trt(', $from);
|
||||||
|
if($pos1 !== false)
|
||||||
|
{
|
||||||
|
$from = $pos1+$pLen+1;
|
||||||
|
$pos2 = false;
|
||||||
|
if($text[$pos1+$pLen] == '"') $pos2 = strpos($text, '")', $from);
|
||||||
|
if($text[$pos1+$pLen] == '\'') $pos2 = strpos($text, '\')', $from);
|
||||||
|
if($pos2 !== false)
|
||||||
|
{
|
||||||
|
$result.=substr($text, $cut, $pos1 - $cut );
|
||||||
|
$toTranslate=substr($text, $pos1+$pLen+1, $pos2 - $pos1 - $pLen-1 );
|
||||||
|
$result.=trt($toTranslate);
|
||||||
|
$cut=$pos2+2;
|
||||||
|
$from = $pos2 + $pLen;
|
||||||
|
}
|
||||||
|
}else break;
|
||||||
|
}
|
||||||
|
$result.=substr($text, $cut); //Копируем остатки
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Выбираю из текста ${конкретные} слова для перевода
|
||||||
|
function trs($text)
|
||||||
|
{
|
||||||
|
$pos1=0;
|
||||||
|
while(true)
|
||||||
|
{
|
||||||
|
$pos1 = strpos($text, '${',$pos1);
|
||||||
|
if($pos1 !== false)
|
||||||
|
{
|
||||||
|
$pos2 = strpos($text, '}', $pos1);
|
||||||
|
if($pos1 !== false)
|
||||||
|
{
|
||||||
|
$sub=substr($text,$pos1+2,$pos2-$pos1-2);
|
||||||
|
$text=substr($text,0, $pos1).trt($sub).substr($text,$pos2+1);
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
|
|
||||||
//Получить разрешения для текущего пользователя
|
//Получить разрешения для текущего пользователя
|
||||||
function getAccess($key)
|
function getAccess($key)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user