Merge branch 'master' of http://git.dirt.kz/igor/Metadata_PHP
# Conflicts: # metadata/dbms/records.php
This commit is contained in:
@ -153,8 +153,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Функция для перевода текста без применения GetText
|
//Функция для перевода текста без применения GetText
|
||||||
function trt($text)
|
/*
|
||||||
{
|
закоментил так как есть в tools.php
|
||||||
|
function trt($text) {
|
||||||
global $db,$lng,$Schema;
|
global $db,$lng,$Schema;
|
||||||
|
|
||||||
$language_id=1;
|
$language_id=1;
|
||||||
@ -182,29 +183,32 @@
|
|||||||
$result=str_replace("_", " ", $text);
|
$result=str_replace("_", " ", $text);
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
//Перевод для строки в которой встречаются подстроки вида: _('')
|
//Перевод для строки в которой встречаются подстроки вида: trt('')
|
||||||
function parseGT($text)
|
function parseGT($text)
|
||||||
{
|
{
|
||||||
$result='';
|
$result='';
|
||||||
|
$pLen=4; //Длина преамбулы trt(
|
||||||
$cut=0;
|
$cut=0;
|
||||||
$from = 0; // Позиция поиска для итерации
|
$from = 0; // Позиция поиска для итерации
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
$pos1 = strpos($text, '_(', $from);
|
$pos1 = strpos($text, 'trt(', $from);
|
||||||
if($pos1 !== false)
|
if($pos1 !== false)
|
||||||
{
|
{
|
||||||
$from = $pos1+3;
|
$from = $pos1+$pLen+1;
|
||||||
$pos2 = false;
|
$pos2 = false;
|
||||||
if($text[$pos1+2] == '"') $pos2 = strpos($text, '")', $from);
|
if($text[$pos1+$pLen] == '"') $pos2 = strpos($text, '")', $from);
|
||||||
if($text[$pos1+2] == '\'') $pos2 = strpos($text, '\')', $from);
|
if($text[$pos1+$pLen] == '\'') $pos2 = strpos($text, '\')', $from);
|
||||||
if($pos2 !== false)
|
if($pos2 !== false)
|
||||||
{
|
{
|
||||||
$result.=substr($text, $cut, $pos1 - $cut );
|
$result.=substr($text, $cut, $pos1 - $cut );
|
||||||
$result.=trt(substr($text, $pos1+3, $pos2 - $pos1 - 3 ));
|
$result.=__(substr($text, $pos1+3, $pos2 - $pos1 - 3 ));
|
||||||
|
$toTranslate=substr($text, $pos1+$pLen+1, $pos2 - $pos1 - $pLen-1 );
|
||||||
|
$result.=trt($toTranslate);
|
||||||
$cut=$pos2+2;
|
$cut=$pos2+2;
|
||||||
$from = $pos2 + 2;
|
$from = $pos2 + $pLen;
|
||||||
}
|
}
|
||||||
}else break;
|
}else break;
|
||||||
}
|
}
|
||||||
@ -1150,7 +1154,7 @@
|
|||||||
if ($fn==8)//Получить отчёт как Excel.xls файл (почти тоже самое что и функция 4)
|
if ($fn==8)//Получить отчёт как Excel.xls файл (почти тоже самое что и функция 4)
|
||||||
{
|
{
|
||||||
session_write_close(); //Разблокируем сессионный файл так как запросы могут быть достаточно долгими
|
session_write_close(); //Разблокируем сессионный файл так как запросы могут быть достаточно долгими
|
||||||
//if (!isset($_SESSION['USER_ID']) || $_SESSION['USER_ID']=='') sendError(_('You are not logged in!'));
|
//if (!isset($_SESSION['USER_ID']) || $_SESSION['USER_ID']=='') sendError(trt('You are not logged in!'));
|
||||||
|
|
||||||
//Выбираем информацию о текущем пользователе
|
//Выбираем информацию о текущем пользователе
|
||||||
$name='';
|
$name='';
|
||||||
@ -1197,7 +1201,7 @@
|
|||||||
setFilter($f1,$f2);//заменить все значения первого фильтра значениями из второго
|
setFilter($f1,$f2);//заменить все значения первого фильтра значениями из второго
|
||||||
|
|
||||||
//Выбираем параметры фильтра (Для информирования что было заполнено)
|
//Выбираем параметры фильтра (Для информирования что было заполнено)
|
||||||
$filter='<b>'._('Filter options').'</b><br>';
|
$filter='<b>'.trt('Filter options').'</b><br>';
|
||||||
$nextnode=$f1->firstChild;
|
$nextnode=$f1->firstChild;
|
||||||
while ($nextnode)
|
while ($nextnode)
|
||||||
{ if ($nextnode->nodeName=='column')
|
{ if ($nextnode->nodeName=='column')
|
||||||
@ -1235,7 +1239,7 @@
|
|||||||
} catch (Exception $e)
|
} catch (Exception $e)
|
||||||
{ sendError($e->getMessage());
|
{ sendError($e->getMessage());
|
||||||
}
|
}
|
||||||
if($res->rowCount()!=1) sendError(_('The number of records is not equal to one!').' '.$sql_query);
|
if($res->rowCount()!=1) sendError(trt('The number of records is not equal to one!').' '.$sql_query);
|
||||||
|
|
||||||
|
|
||||||
$columns=explode(",",$nextnode->getAttribute('FieldCaption'));
|
$columns=explode(",",$nextnode->getAttribute('FieldCaption'));
|
||||||
@ -1300,8 +1304,8 @@
|
|||||||
fwrite($fh, ' </head>'."\n");
|
fwrite($fh, ' </head>'."\n");
|
||||||
fwrite($fh, ' <body>'."\n");
|
fwrite($fh, ' <body>'."\n");
|
||||||
|
|
||||||
fwrite($fh, '<b>'._('Time and date of generation').': </b><i>'.date('H:i:s m.d.Y').'</i><br>');
|
fwrite($fh, '<b>'.trt('Time and date of generation').': </b><i>'.date('H:i:s m.d.Y').'</i><br>');
|
||||||
fwrite($fh, '<b>'._('Creator').': </b>'.$name);
|
fwrite($fh, '<b>'.trt('Creator').': </b>'.$name);
|
||||||
fwrite($fh, $filter);
|
fwrite($fh, $filter);
|
||||||
|
|
||||||
fwrite($fh, ' <table border="1" cellspacing="0">'."\n");
|
fwrite($fh, ' <table border="1" cellspacing="0">'."\n");
|
||||||
@ -1367,7 +1371,7 @@
|
|||||||
//deleteTempFiles($dir);
|
//deleteTempFiles($dir);
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
sendError(_('Not found the requested node:').' "'.$typename.'"!');
|
sendError(trt('Not found the requested node:').' "'.$typename.'"!');
|
||||||
}
|
}
|
||||||
|
|
||||||
}else
|
}else
|
||||||
|
|||||||
@ -1,4 +1,24 @@
|
|||||||
//Copyright (C) Ivanov I.M. irigm@mail.ru
|
/*jshint esversion: 6 */
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
//Массив g_translations подгружается отдельно
|
||||||
|
function trt(key)
|
||||||
|
{
|
||||||
|
if(key==null || key===undefined) return '';
|
||||||
|
let val=g_translations[key];
|
||||||
|
if(val==null || val===undefined)
|
||||||
|
{
|
||||||
|
for(let item in g_translations) {
|
||||||
|
if(item.toLowerCase()==key.toLowerCase())
|
||||||
|
{
|
||||||
|
val=g_translations[item];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(val==null || val===undefined) return key.replace(/_/g, ' ');
|
||||||
|
else return val;
|
||||||
|
}
|
||||||
|
|
||||||
//Расширить плитку чтобы она занимала всю штртну области
|
//Расширить плитку чтобы она занимала всю штртну области
|
||||||
function resizeDivTile(parent,minWidth)
|
function resizeDivTile(parent,minWidth)
|
||||||
@ -529,15 +549,13 @@ function setIframeSrc(iframeNode, src)
|
|||||||
// браузер хранится в объекте browser
|
// браузер хранится в объекте browser
|
||||||
function createIFrame(fname, fsrc, parent, debug)
|
function createIFrame(fname, fsrc, parent, debug)
|
||||||
{
|
{
|
||||||
var ifrstr = BrowserDetect.browser=='Explorer' ? '<iframe name="'+fname+'" src="'+src+'">' : 'iframe';
|
let ifrstr = BrowserDetect.browser=='Explorer' ? '<iframe name="'+fname+'" src="'+src+'">' : 'iframe';
|
||||||
var cframe = document.createElement(ifrstr);
|
let cframe = document.createElement(ifrstr);
|
||||||
|
|
||||||
with(cframe){
|
cframe.name = fname // это не для IE
|
||||||
name = fname // это не для IE
|
cframe.setAttribute("name", fname) // и это тоже, но вреда не будет
|
||||||
setAttribute("name", fname) // и это тоже, но вреда не будет
|
cframe.id = fname // а это везде ок
|
||||||
id = fname // а это везде ок
|
cframe.src = fsrc //Так ка setIframeSrc глючит если не задан родитель
|
||||||
src = fsrc //Так ка setIframeSrc глючит если не задан родитель
|
|
||||||
}
|
|
||||||
|
|
||||||
// можно добавлять сразу к document.body
|
// можно добавлять сразу к document.body
|
||||||
//document.body.appendChild(cframe);
|
//document.body.appendChild(cframe);
|
||||||
@ -558,27 +576,25 @@ function createIFrame(fname, fsrc, parent, debug)
|
|||||||
// прячем фрейм
|
// прячем фрейм
|
||||||
function hideIframe(iframeNode)
|
function hideIframe(iframeNode)
|
||||||
{
|
{
|
||||||
with(iframeNode.style) {
|
if(BrowserDetect.browser!='Safari'){
|
||||||
if(BrowserDetect.browser!='Safari'){
|
iframeNode.style.position = "absolute";
|
||||||
position = "absolute";
|
|
||||||
}
|
|
||||||
left = top = "0px";
|
|
||||||
height = width = "1px";
|
|
||||||
visibility = "hidden";
|
|
||||||
}
|
}
|
||||||
|
iframeNode.style.left = "0px";
|
||||||
|
iframeNode.style.height = "1px";
|
||||||
|
iframeNode.style.visibility = "hidden";
|
||||||
}
|
}
|
||||||
|
|
||||||
//вернуть строку до заданных символов
|
//вернуть строку до заданных символов
|
||||||
function BeforeFirst(str,sub)
|
function BeforeFirst(str,sub)
|
||||||
{
|
{
|
||||||
var pos=str.indexOf(sub);
|
let pos=str.indexOf(sub);
|
||||||
if (pos==-1) return null;
|
if (pos==-1) return null;
|
||||||
return str.substring(0, pos);
|
return str.substring(0, pos);
|
||||||
}
|
}
|
||||||
//вернуть строку до последнего найденого символа
|
//вернуть строку до последнего найденого символа
|
||||||
function BeforeLast(str,sub)
|
function BeforeLast(str,sub)
|
||||||
{
|
{
|
||||||
var pos=str.lastIndexOf(sub);
|
let pos=str.lastIndexOf(sub);
|
||||||
if (pos==-1) return null;
|
if (pos==-1) return null;
|
||||||
return str.substring(0, pos);
|
return str.substring(0, pos);
|
||||||
}
|
}
|
||||||
@ -586,14 +602,14 @@ function BeforeLast(str,sub)
|
|||||||
//вернуть строку после заданных символов
|
//вернуть строку после заданных символов
|
||||||
function AfterFirst(str,sub)
|
function AfterFirst(str,sub)
|
||||||
{
|
{
|
||||||
var pos=str.indexOf(sub);
|
let pos=str.indexOf(sub);
|
||||||
if (pos==-1) return null;
|
if (pos==-1) return null;
|
||||||
return str.substring(pos+sub.length, str.length);
|
return str.substring(pos+sub.length, str.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
function AfterLast(str,sub)
|
function AfterLast(str,sub)
|
||||||
{
|
{
|
||||||
var pos=str.lastIndexOf(sub);
|
let pos=str.lastIndexOf(sub);
|
||||||
if (pos==-1) return null;
|
if (pos==-1) return null;
|
||||||
return str.substring(pos+sub.length, str.length);
|
return str.substring(pos+sub.length, str.length);
|
||||||
}
|
}
|
||||||
@ -601,9 +617,9 @@ function AfterLast(str,sub)
|
|||||||
//взять параметры из строки запроса (раздел по ? и &)
|
//взять параметры из строки запроса (раздел по ? и &)
|
||||||
function getParam(sParamName,win)
|
function getParam(sParamName,win)
|
||||||
{
|
{
|
||||||
var Params = win.location.search.substring(1).split("&"); // отсекаем «?» и вносим переменные и их значения в массив
|
let Params = win.location.search.substring(1).split("&"); // отсекаем «?» и вносим переменные и их значения в массив
|
||||||
var variable = "";
|
let variable = "";
|
||||||
for (var i = 0; i < Params.length; i++)
|
for (let i = 0; i < Params.length; i++)
|
||||||
{
|
{
|
||||||
if (Params[i].split("=")[0] == sParamName)
|
if (Params[i].split("=")[0] == sParamName)
|
||||||
{
|
{
|
||||||
@ -870,7 +886,7 @@ function delChild(obj)
|
|||||||
{
|
{
|
||||||
while(true)
|
while(true)
|
||||||
{
|
{
|
||||||
c=obj.firstChild;
|
let c=obj.firstChild;
|
||||||
if(c!=null) obj.removeChild(c); else break;
|
if(c!=null) obj.removeChild(c); else break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1574,7 +1590,7 @@ class TSettings
|
|||||||
{ delete(this.mas[id]);
|
{ delete(this.mas[id]);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
Settings=new TSettings();
|
var Settings=new TSettings();
|
||||||
|
|
||||||
|
|
||||||
function isInt(value)
|
function isInt(value)
|
||||||
|
|||||||
@ -1,5 +1,70 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
// Из файла file.js делаем file_v123456789.js добавив время
|
||||||
|
function getScript($path)
|
||||||
|
{
|
||||||
|
if (file_exists($_SERVER['DOCUMENT_ROOT'].$path))
|
||||||
|
{
|
||||||
|
return '<script type="text/javascript" src="'.beforeLast($path,'.').'_v'.filectime($_SERVER['DOCUMENT_ROOT'].$path).'.'.afterLast($path,'.').'"></script>'."\n";
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
//Функция для перевода текста без применения GetText
|
||||||
|
function trt($text)
|
||||||
|
{
|
||||||
|
global $db;
|
||||||
|
|
||||||
|
$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.'\';';
|
||||||
|
$res = NULL;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$res = $db->query($sql);
|
||||||
|
}catch (Exception $e)
|
||||||
|
{
|
||||||
|
echo $e->getMessage();
|
||||||
|
}
|
||||||
|
if($res!=NULL && $res->rowCount()>0)
|
||||||
|
{
|
||||||
|
while ($row = $res->fetch(PDO::FETCH_NUM))
|
||||||
|
{
|
||||||
|
$result=$row[0];
|
||||||
|
}
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
$result=str_replace("_", " ", $text);
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Получить разрешения для текущего пользователя
|
||||||
|
function getAccess($key)
|
||||||
|
{
|
||||||
|
global $db;
|
||||||
|
|
||||||
|
$result=false;
|
||||||
|
if(isset($_SESSION['USER_ID']))
|
||||||
|
$sql="select main.p_getaccess(".$_SESSION['USER_ID'].",'".$key."') as acc;";
|
||||||
|
else
|
||||||
|
$sql="select main.p_getaccess(0,'".$key."') as acc;";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$res = $db->query($sql);
|
||||||
|
}catch (Exception $e)
|
||||||
|
{
|
||||||
|
echo $e->getMessage();
|
||||||
|
}
|
||||||
|
if($res!=NULL && $res->rowCount()>0)
|
||||||
|
{
|
||||||
|
while ($row = $res->fetch(PDO::FETCH_NUM))
|
||||||
|
{
|
||||||
|
$result=$row[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
function delPHPExt($fName)
|
function delPHPExt($fName)
|
||||||
{
|
{
|
||||||
$pos = strrpos($fName, '.')+1;
|
$pos = strrpos($fName, '.')+1;
|
||||||
|
|||||||
Reference in New Issue
Block a user