diff --git a/metadata/dbms/records.php b/metadata/dbms/records.php index a7dcb14..7ba1e5c 100644 --- a/metadata/dbms/records.php +++ b/metadata/dbms/records.php @@ -208,20 +208,9 @@ $idType="object"; } - try - { - if(strpos($db_connection, 'sqlite')!==false) - { - $db = new PDO($db_connection); - }else - { - $db = new PDO($db_connection, $db_login, $db_password); - $db->exec("SET timezone TO 'UTC';"); //Пользователь должен сам передавать свою зону или она должна быть в настройках - } - $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - } catch (Exception $e) - { sendError(1,'Connect error '.$_SERVER['HTTP_HOST'].': "'.$e->getMessage().'"!'); - } + $db = connectToDB(); + if($db==null) + sendError(1,trt('Error_connection_to_DB')); //Пытаемся автоматически залогинется по GUID из COOKIE (TODO авторизация должна быть в отдельном файле! Смотри директорию password ) /*if($_SESSION['USER_ID']==null && $_COOKIE['GUID']!=null) @@ -633,7 +622,7 @@ $sql_query=str_replace('${_user_id}',getSQLValue(gettype($_SESSION['USER_ID']),$_SESSION['USER_ID']),$sql_query); if($objListR!=null && $objListR->getAttribute('order')!='' && $objListR->getAttribute('order')!=null && $objListR->getAttribute('order')!='null') { - $sql_query=str_replace('${_order}',findNodeOnAttribute(findFirstNode($currNode,'objects-list'), "column","n",$objListR->getAttribute("order"))->getAttribute("order"),$sql_query); + $sql_query=str_replace('${_order}',getSQLValue('i4',findNodeOnAttribute(findFirstNode($currNode,'objects-list'), "column","n",$objListR->getAttribute("order"))->getAttribute("order")),$sql_query); }else $sql_query=str_replace('${_order}','1',$sql_query); //sendError(1,$sql_query); @@ -677,66 +666,6 @@ } //перебираем RS и строим XML только из тех столбцов которые записанны в секци objects-list поля column в не зависимости от их видимости -/* - $xmlstring=''; - $xmlstring.=''."\n"; - $xmlstring.=''."\n"; - //Перечисляю название выбираемых столбцов через запятую - $xmlstring.=''; - $nextnode=findNode($currNode,'objects-list')->firstChild; - while ($nextnode) - { - if ($nextnode->nodeName=='column') - { - $xmlstring.=''; - } - $nextnode = $nextnode->nextSibling; - } - $xmlstring.=''; - - $node=findFirstNode($reqNode,'objects-list'); - $pos=-1; - while ($row = $res->fetch(PDO::FETCH_ASSOC))// $row - ассоциативный массив значений, ключи - названия столбцов - { - $pos++; - if (($pagepos!=-1)&&(($pos<($pagepos*$rowspagecount))||($pos>=$pagepos*$rowspagecount+$rowspagecount))) { continue; } - - //разрешать или запрещять редактировать запись надо проверять в хранимке а также запрещять либо разрешать редактировать колонку - //для каждой записи формируеться строка настроек со значениями что нужно запретить в таком виде "iuds" - //$access=$row["access"]; - $access=''; //u = enable update field, d = enable delete field - if(!array_key_exists("_u",$row)) { $access.="u"; } else { $access.=$row["_u"]; } - if(!array_key_exists("_d",$row)) { $access.="d"; } else { $access.=$row["_d"]; } - - if(array_key_exists($currNode->getAttribute("ObjectID"),$row)) - $xmlstring.=' '; - else - $xmlstring.=' '; - $nextnode=findNode($currNode,'objects-list')->firstChild; - while ($nextnode) - { - if ($nextnode->nodeName=='column') - { - if(array_key_exists($nextnode->getAttribute("n"),$row)) - { - $field = $nextnode->getAttribute("n"); - $xmlstring.=''; - }else - { - sendError(1,"Column \"".$nextnode->getAttribute("n")."\" not exists in \"$typename\" for select!"); - } - } - $nextnode = $nextnode->nextSibling; - } - $xmlstring.=''."\n"; - } - $res->closeCursor(); - $xmlstring.=''."\n"; - - header('Content-type: text/xml'); - echo $xmlstring; -*/ - $obj = new StdClass(); $obj->errorCode=0; $obj->errorMessage = ''; diff --git a/metadata/dbms/tools.js b/metadata/dbms/tools.js index 300a11b..2f38fc4 100644 --- a/metadata/dbms/tools.js +++ b/metadata/dbms/tools.js @@ -25,6 +25,35 @@ function trt(key) else return val; } +function trts(text) +{ + let result=''; + let pLen=4; //Длина преамбулы trt( + let cut=0; + let from = 0; // Позиция поиска для итерации + while (true) + { + let pos1 = text.indexOf('trt(', from); + if(pos1 >= 0) + { + from = pos1+pLen+1; + let pos2 = -1; + if(text[pos1+pLen] == '"') pos2 = text.indexOf('")', from); + if(text[pos1+pLen] == "'") pos2 = text.indexOf("')", from); + if(pos2 > 0) + { + result+=text.substring(cut, pos1); + let toTranslate=text.substring(pos1+pLen+1, pos2 ); + result+=trt(toTranslate); + cut=pos2+2; + from = pos2; + } + }else break; + } + result+=text.substring(cut); //Копируем остатки + return result; +} + function deleteOption(sel,id){ if(typeof sel == 'string') sel=document.getElementById(sel); let i=0; @@ -1691,7 +1720,7 @@ class TWin //Подгрузить содержимое окна из указаного места //json - объект который передастца в виде JSON строки по URL //func - функция которая выполниться после загрузки данных в форму - load(url,json,func) + load(url,json,func,tr) { this.showProgressBar(); var r=createRequestObject(); @@ -1699,7 +1728,8 @@ class TWin { return function(){ if(r.readyState == 4){ - w.innerHTML=r.responseText; + if(tr) w.innerHTML=trts(r.responseText); + else w.innerHTML=r.responseText; thiz.hideProgressBar(); if(func !== undefined && func!=null) func(); @@ -1710,7 +1740,7 @@ class TWin thiz.setCenter(); } } - }(r,this.co,this,func) + }(r,this.co,this,func,tr) r.open( "POST", url, true ); if(json!=null) r.send(JSON.stringify(json)); diff --git a/metadata/include/toExcell.php b/metadata/include/toExcell.php deleted file mode 100644 index 4cbae09..0000000 --- a/metadata/include/toExcell.php +++ /dev/null @@ -1,196 +0,0 @@ - -* Version : 0.1 -* Copyright : GNU LGPL -* URL : http://lio.kz -* Last modified : 08.07.2004 -* Description : xls . -* (, -* e-mail ..). "" -* Excell 5, - -* 255 , 65535 . -* -* -* 1. () -* 2. -* 3. -******************************************************************/ - - - class PhpToExcell { - var $data = ""; // - - // - function ExBOF() - { - // begin of the excel file header - $this->data = pack("c*", 0x09, 0x00, 0x04, 0x00, 0x02, 0x00, 0x10, 0x0); - } - - // - function ExEOF() - { - $this->data .= pack("cc", 0x0A, 0x00); - } - - // attr1..3 - function RowAttr($attr1,$attr2,$attr3) - { - return chr($attr1).chr($attr2).chr($attr3); - } - - // xls - function Rus() - { - $this->data .= (chr(0x42).chr(0x00).chr(0x02).chr(0x00).chr(0x01).chr(0x80)); - } - - // - // Col,Row - - // attr1 - - // attr2 - - // attr3 - - // - function WriteLabel($Col,$Row,$attr1=0,$attr2=0,$attr3=0,$value) // { String } - { - $i=strlen($value); - $this->data .= pack("v*",0x04,8+$i,$Col,$Row); - $this->data .= $this->RowAttr($attr1,$attr2,$attr3); - $this->data .= pack("c",$i); - $this->data .= $value; - } - - // Width*1/256 - // 3000 - 100% } - function ColWidth($ColFirst,$ColLast,$Width) - { - $this->data .= (CHR(0x24).CHR(00).Chr(04).CHR(00).chr($ColFirst).chr($ColLast).pack('s',$Width)); - } - - // - // ReferenceMode=1 = R1C1 - // ReferenceMode=0 A1... - function RefMode($ReferenceMode=1) - { - if ($ReferenceMode==1) - { - $this->data .= (CHR(0x0f).chr(0x00).chr(2).chr(0x00).chr(0x00).chr(0x00)); - } else - { - $this->data .= (CHR(0x0f).chr(0x00).chr(2).chr(0x00).chr(0x00).chr(0x01)); - } - } - - // - function WriteInteger($Col,$Row,$attr1,$attr2,$attr3,$value=0) - { - $this->data.=pack("v*",0x02,0x09,$Col,$Row); - $this->data.=$this->RowAttr($attr1,$attr2,$attr3); - $this->data.=pack("v",$value); - } - - // - function WriteNumber($Col,$Row,$attr1,$attr2,$attr3,$value=0.00) - { - $this->data.=pack("v*",0x03,0x0F,$Col,$Row); - $this->data.=$this->RowAttr($attr1,$attr2,$attr3); - $this->data.=pack("d",$value); - - } - // - function WriteBlank($Col,$Row,$attr1,$attr2,$attr3) - { - $this->data.=pack("v*",0x01,0x07,$Col,$Row); - $this->data.=$this->RowAttr($attr1,$attr2,$attr3); - } - - // . Height*1/20 - // 10 Height = 200 } - function Font($Height,$Bold=0,$Italic=0,$Underline=0,$StrikeOut=0,$FontName) - { - $i=strlen($FontName); - $this->data.=CHR(0x31).chr(0x00).Chr($i+5).chr(0x00); - $this->data.=pack("v",$Height); - $k=0; - if ($Bold==1) $k=$k|1; - if ($Italic==1) $k=$k|2; - if ($Underline==1) $k=$k|4; - if ($StrikeOut==1) $k=$k|8; - $this->data.=pack("v",$k); - $this->data.=chr($i); - $this->data.=$FontName; - } - - // 1 ($Attr1) - // $CellHidden - - // $CellLocked - - function Attr1($CellHidden=0,$CellLocked=0) - { - $r=0x0; - if ($CellHidden==1)$r=$r|128; - if ($CellLocked==1)$r=$r|64; - return $r; - } - - // 2 ($Attr2) - // $FontNumber 0..3 - function Attr2($FontNumber=0) - { - $r=0; - switch ($FontNumber) - { - case 1: - $r=64; - break; - case 2: - $r=128; - break; - case 3: - $r=129; - break; - } - return $r; - } - - // 3 ($Attr3) - // Alignment 0 - General - // 1 - left - // 2 - center - // 3 - Right - // 4 - Fill - function Attr3($Shaded=0,$BottomBorder=0,$TopBorder=0,$RightBorder=0,$LeftBorder=0,$Alignment=0) - { - $r=0; - if ($Shaded==1) $r=$r|128; - if ($BottomBorder==1) $r=$r|64; - if ($TopBorder==1) $r=$r|32; - if ($RightBorder==1) $r=$r|16; - if ($LeftBorder==1) $r= $r|8; - if ($Alignment<8) $r=$r|$Alignment; - return $r; - } - - // xls - function SaveToFileXls($FName='file.xls') - { - $fp = fopen( $FName, "wb" ); - fwrite( $fp,$this->data); - fclose( $fp ); - } - - // web - function SendFileToHTTP($FName='file.xls') - { - header ( "Expires: Mon, 1 Apr 1974 05:00:00 GMT" ); - header ( "Last-Modified: " . gmdate("D,d M YH:i:s") . " GMT" ); - header ( "Cache-Control: no-cache, must-revalidate" ); - header ( "Pragma: no-cache" ); - header ( "Content-type: application/x-msexcel" ); - header ( "Content-Disposition: attachment; filename=".$FName ); - print $this->data; - } - } - -?>