Updated Rico 2 and Rico 3 with all patches submitted on Sourceforge.
authorMatt Brown <dowdybrown@yahoo.com>
Mon, 27 Jun 2011 02:34:12 +0000 (02:34 +0000)
committerMatt Brown <dowdybrown@yahoo.com>
Mon, 27 Jun 2011 02:34:12 +0000 (02:34 +0000)
git-svn-id: svn://svn.code.sf.net/p/openrico/code/trunk/rico3@92 53df2df2-7ab5-4331-af62-ea79255fa4e2

bin/Rico.dll
documentation/InstallNotes.html
examples/php/dbConnect.php
minsrc/ricoLiveGrid.js
minsrc/ricoLiveGridAjax.js
plugins/php/dbClass3.php
plugins/php/ricoResponse.php
ricoClient/js/ricoLocale_de.js
ricoClient/js/rico_min.js

index 6d6fa1a..6f25d9e 100644 (file)
Binary files a/bin/Rico.dll and b/bin/Rico.dll differ
index e75fad2..c5f20c0 100644 (file)
@@ -148,7 +148,6 @@ If you are using a later ODBC driver, such as 5.1, then you will need to add thi
 \r
 <tr><th>SQL Server</th>\r
 <td>\r
 \r
 <tr><th>SQL Server</th>\r
 <td>\r
-$oDB->Dialect="TSQL";\r
 <p>return $GLOBALS['oDB']->MSSqlLogon( "ServerName\InstanceName", "Northwind", "userid", "password");\r
 <p class='comment'>Omit InstanceName when connecting to the default instance\r
 </td>\r
 <p>return $GLOBALS['oDB']->MSSqlLogon( "ServerName\InstanceName", "Northwind", "userid", "password");\r
 <p class='comment'>Omit InstanceName when connecting to the default instance\r
 </td>\r
@@ -185,6 +184,16 @@ $oDB->Dialect="Oracle";
 <td>Public const dbDialect = "DB2"\r
 <p class='comment'>Set the server name, user id, and password in OpenDB()</td>\r
 <td>&nbsp;</td>\r
 <td>Public const dbDialect = "DB2"\r
 <p class='comment'>Set the server name, user id, and password in OpenDB()</td>\r
 <td>&nbsp;</td>\r
+\r
+<tr><th>PostgreSQL</th>\r
+<td>return $GLOBALS['oDB']->PostgreSqlLogon(<i>connection_string</i>);\r
+<p class='comment'>The connection_string can be empty to use all default parameters, or it can contain one or more parameter settings separated by whitespace. Each parameter setting is in the form keyword = value. Spaces around the equal sign are optional. To write an empty value or a value containing spaces, surround it with single quotes, e.g., keyword = 'a value'. Single quotes and backslashes within the value must be escaped with a backslash, i.e., \' and \\.\r
+<p class='comment'>The currently recognized parameter keywords are: host, hostaddr, port, dbname (defaults to value of user), user, password, connect_timeout, options, tty (ignored), sslmode, requiressl (deprecated in favor of sslmode), and service. Which of these arguments exist depends on your PostgreSQL version. \r
+</td>\r
+<td>&nbsp;</td>\r
+<td>&nbsp;</td>\r
+<td>&nbsp;</td>\r
+\r
 </tbody>\r
 </table>\r
 \r
 </tbody>\r
 </table>\r
 \r
index 2edccda..6634874 100644 (file)
@@ -19,6 +19,11 @@ function OpenDB() {
   //$oDB->Dialect="TSQL";\r
   //return $oDB->MSSqlLogon("computer/instance", $appDB, "userid", "password");\r
 \r
   //$oDB->Dialect="TSQL";\r
   //return $oDB->MSSqlLogon("computer/instance", $appDB, "userid", "password");\r
 \r
+  // PostgreSQL\r
+  // The connection_string can be empty to use all default parameters, or it can contain one or more parameter settings separated by whitespace. Each parameter setting is in the form keyword = value. Spaces around the equal sign are optional. To write an empty value or a value containing spaces, surround it with single quotes, e.g., keyword = 'a value'. Single quotes and backslashes within the value must be escaped with a backslash, i.e., \' and \\.\r
+  // The currently recognized parameter keywords are: host, hostaddr, port, dbname (defaults to value of user), user, password, connect_timeout, options, tty (ignored), sslmode, requiressl (deprecated in favor of sslmode), and service. Which of these arguments exist depends on your PostgreSQL version. \r
+  //return $oDB->PostgreSqlLogon($connection_string);\r
+  \r
   // ODBC - MS Access\r
   //$oDB->Dialect="Access";\r
   //return $oDB->OdbcLogon("northwindDSN","Northwind","userid","password");\r
   // ODBC - MS Access\r
   //$oDB->Dialect="Access";\r
   //return $oDB->OdbcLogon("northwindDSN","Northwind","userid","password");\r
index c69d93a..d550aaf 100644 (file)
@@ -1216,11 +1216,13 @@ Rico.LiveGridMethods = {
       newdiv.className = 'ricoLG_cell '+cls;
       newdiv.id=this.tableId+'_'+this.pageSize+'_'+c;
       this.columns[c].dataColDiv.appendChild(newdiv);
       newdiv.className = 'ricoLG_cell '+cls;
       newdiv.id=this.tableId+'_'+this.pageSize+'_'+c;
       this.columns[c].dataColDiv.appendChild(newdiv);
-      if (this.columns[c].format.canDrag && Rico.registerDraggable)
-        Rico.registerDraggable( new Rico.LiveGridDraggable(this, this.pageSize, c), this.options.dndMgrIdx );
-      newdiv.innerHTML='&nbsp;';   // this seems to be required by IE
       if (this.columns[c]._create) {
         this.columns[c]._create(newdiv,this.pageSize);
       if (this.columns[c]._create) {
         this.columns[c]._create(newdiv,this.pageSize);
+      } else {
+        newdiv.innerHTML='&nbsp;';   // this seems to be required by IE
+      }
+      if (this.columns[c].format.canDrag && Rico.registerDraggable) {
+        Rico.registerDraggable( new Rico.LiveGridDraggable(this, this.pageSize, c), this.options.dndMgrIdx );
       }
     }
     this.pageSize++;
       }
     }
     this.pageSize++;
index 748ca55..14d345c 100644 (file)
@@ -426,7 +426,7 @@ Rico.Buffer.AjaxSQLMethods = {
       this.pendingRequest=offset;
       return;
     }
       this.pendingRequest=offset;
       return;
     }
-    if (offset < 0) {
+    if ((typeof offset == 'undefined') || (offset < 0)) {
       this.clear();
       this.setTotalRows(0);
       this.foundRowCount = false;
       this.clear();
       this.setTotalRows(0);
       this.foundRowCount = false;
index 9dce42b..d7d7dc7 100644 (file)
@@ -1,10 +1,10 @@
 <?php\r
 /*****************************************************************\r
 <?php\r
 /*****************************************************************\r
- Page        : dbClass2.php\r
- Description : Routines to access MySQL, SQL Server, Oracle, & ODBC databases\r
+ Page        : dbClass3.php\r
+ Description : Routines to access MySQL, PostgreSQL, SQL Server, Oracle, & ODBC databases\r
  Date        : 25 May 2006\r
  Author      : Matt Brown (dowdybrown@yahoo.com)\r
  Date        : 25 May 2006\r
  Author      : Matt Brown (dowdybrown@yahoo.com)\r
- Copyright (C) 2006-2008 Matt Brown\r
+ Copyright (C) 2006-2011 Matt Brown\r
 \r
  Rico is licensed under the Apache License, Version 2.0 (the "License"); you may not use this
  file except in compliance with the License. You may obtain a copy of the License at
 \r
  Rico is licensed under the Apache License, Version 2.0 (the "License"); you may not use this
  file except in compliance with the License. You may obtain a copy of the License at
@@ -836,6 +836,86 @@ class dbClass_mssql
   }\r
 }\r
 \r
   }\r
 }\r
 \r
+// for PostgreSQL server\r
+class dbClass_postgresql\r
+{\r
+  var $lastQuery;\r
+  function dbClass_postgresql($conn) { $this->conn=$conn; }\r
+  function HasError() { return pg_last_error() !== ''; }\r
+  function ErrorMsg() { return pg_last_error(); }\r
+  function Close() { return pg_close(); }\r
+  function FreeResult($rsLookUp) { return pg_free_result($rsLookUp); }\r
+  function RunQuery($sqltext) { $this->lastQuery=$sqltext; return pg_query($sqltext); }\r
+  function NumFields($rsMain) { return pg_num_fields($rsMain); }\r
+  function NumRows($rsMain) { return pg_num_rows($rsMain); }\r
+  function FieldType($rsMain,$i) { return pg_field_type($rsMain,$i); }\r
+  function FetchRow($rsMain,&$result) { $result=pg_fetch_row($rsMain); return ($result==false) ? false : true; }\r
+  function FetchAssoc($rsMain,&$result) { $result=pg_fetch_assoc($rsMain); return ($result==false) ? false : true; }\r
+  function FetchArray($rsMain,&$result) { $result=pg_fetch_array($rsMain); return ($result==false) ? false : true; }\r
+  function AffectedRows($rsMain) { return pg_affected_rows($this->conn); }\r
+  function Seek($rsMain,$offset) { return pg_result_seek($rsMain,$offset); }\r
+  function RunParamQuery($query, $phs = array()) {\r
+    foreach ($phs as $ph) {   // from php.net\r
+      if ( isset($ph) ) {\r
+        $ph = "'" . pg_escape_string($ph) . "'";\r
+      } else {\r
+        $ph = "NULL" ;\r
+      }\r
+      $query = substr_replace($query, $ph, strpos($query, '?'), 1);\r
+    }\r
+    $this->lastQuery=$query;\r
+    return pg_query($query);\r
+  }\r
+  function GetColumnInfo($TableName) {\r
+    $rsMain=$this->RunQuery("SHOW COLUMNS FROM ".$TableName);\r
+    if (!$rsMain) return null;\r
+    $arColumns=array();\r
+    while($this->FetchAssoc($rsMain,$row)) {\r
+      $colinfo=new dbColumn;\r
+      $colinfo->IsPKey=($row["Key"]=="PRI");\r
+      $colinfo->ColName=$row["Field"];\r
+      $colinfo->ColType=$row["Type"];\r
+      $colinfo->Nullable=($row["Null"]=="YES");\r
+      if (preg_match("/\((\d+)\)/", $row["Type"], $matches))\r
+        $colinfo->ColLength=$matches[1];\r
+      else\r
+        $colinfo->ColLength=0;\r
+      $colinfo->Writeable=($row["Extra"] != 'auto_increment');\r
+      array_push($arColumns, $colinfo);\r
+    } \r
+    $this->FreeResult($rsMain);\r
+    return $arColumns;\r
+  }\r
+  function GetTableList($TableType) {\r
+    if ($TableType!='VIEW') $TableType='BASE TABLE';\r
+    $rsMain=$this->RunQuery("SHOW FULL TABLES WHERE Table_type='".$TableType."'");\r
+    if (!$rsMain) return null;\r
+    $arTables=array();\r
+    while($this->FetchRow($rsMain,$row)) {\r
+      array_push($arTables, $row[0]);\r
+    } \r
+    $this->FreeResult($rsMain);\r
+    return $arTables;\r
+  }\r
+  function Concat($arStrings) {\r
+    return "concat(".implode(",",$arStrings).")";\r
+  }\r
+  function Convert2Char($s) {\r
+    return $s; // implicit conversion\r
+  }\r
+  function SqlDay($s) {\r
+    return "dayofmonth(".$s.")";\r
+  }\r
+  function SqlMonth($s) {\r
+    return "month(".$s.")";\r
+  }\r
+  function SqlYear($s) {\r
+    return "year(".$s.")";\r
+  }\r
+  function CurrentTime() {\r
+    return "LOCALTIMESTAMP";\r
+  }\r
+}\r
 \r
 \r
 class dbClass\r
 \r
 \r
 class dbClass\r
@@ -939,6 +1019,19 @@ class dbClass
     return true;\r
   }\r
 \r
     return true;\r
   }\r
 \r
+//********************************************************************************************************\r
+// Attempts to connect to the Database. Returns true on success.\r
+//********************************************************************************************************\r
+  function PostgreSqlLogon($connection_string)\r
+  {\r
+    $this->Dialect="PostgreSQL";\r
+    $this->dbDefault = "";\r
+    $this->dbMain = pg_connect($connection_string);\r
+    $this->db =& new dbClass_postgresql($this->dbMain);\r
+    if ($this->CheckForError("opening connection")) return false;\r
+    return true;\r
+  }\r
+\r
 //********************************************************************************************************\r
 // Attempts to connect to the Database. Returns true on success.\r
 //********************************************************************************************************\r
 //********************************************************************************************************\r
 // Attempts to connect to the Database. Returns true on success.\r
 //********************************************************************************************************\r
index 4e98b6d..90898e7 100644 (file)
@@ -255,6 +255,11 @@ class ricoXmlResponse {
         $totcnt=$this->Query2xmlRaw_Limit($this->sqltext, $offset, $numrows, 0);\r
         break;\r
 \r
         $totcnt=$this->Query2xmlRaw_Limit($this->sqltext, $offset, $numrows, 0);\r
         break;\r
 \r
+      case "PostgreSQL":\r
+        $this->sqltext=$this->oParse->UnparseSelect()." LIMIT ".($numrows + 1) . " OFFSET ".$offset;\r
+        $totcnt=$this->Query2xmlRaw_Limit($this->sqltext, $offset, $numrows, 0);\r
+        break;\r
+\r
       default:\r
         $this->sqltext=$this->oParse->UnparseSelectSkip($this->HiddenCols);\r
         $totcnt=$this->Query2xmlRaw($this->sqltext, $offset, $numrows);\r
       default:\r
         $this->sqltext=$this->oParse->UnparseSelectSkip($this->HiddenCols);\r
         $totcnt=$this->Query2xmlRaw($this->sqltext, $offset, $numrows);\r
@@ -450,9 +455,7 @@ class ricoXmlResponse {
       print "\n[";\r
       for ($i=$firstcol; $i < $colcnt; $i++) {\r
         if ($i>$firstcol) echo ",";\r
       print "\n[";\r
       for ($i=$firstcol; $i < $colcnt; $i++) {\r
         if ($i>$firstcol) echo ",";\r
-        $value=$row[$i];\r
-        if ($this->convertCharSet) $value=utf8_encode($value);\r
-        print json_encode($value);\r
+        print json_encode($this->convertCharSet ? utf8_encode($row[$i]) : $row[$i]);\r
       }\r
       print "]";\r
     }\r
       }\r
       print "]";\r
     }\r
index 27b7477..c59bb69 100644 (file)
@@ -90,7 +90,7 @@ Rico.addPhraseId('clear',"Löschtaste");
 Rico.addPhraseId('close',"Schließen");
 Rico.addPhraseId('saveRecord',"Speichere");
 Rico.addPhraseId('cancel',"Abbrechen");
 Rico.addPhraseId('close',"Schließen");
 Rico.addPhraseId('saveRecord',"Speichere");
 Rico.addPhraseId('cancel',"Abbrechen");
-Rico.addPhraseId('editRecord',"Bearbeite Sie diesen Eintrag");
+Rico.addPhraseId('editRecord',"Bearbeiten Sie diesen Eintrag");
 Rico.addPhraseId('deleteRecord',"Löschen Sie diesen Eintrag");
 Rico.addPhraseId('cloneRecord',"Kopieren Sie diesen Eintrag");
 Rico.addPhraseId('addRecord',"Erstellen Sie einen neuen Eintrag");
 Rico.addPhraseId('deleteRecord',"Löschen Sie diesen Eintrag");
 Rico.addPhraseId('cloneRecord',"Kopieren Sie diesen Eintrag");
 Rico.addPhraseId('addRecord',"Erstellen Sie einen neuen Eintrag");
index 9215cf8..d6f785e 100644 (file)
@@ -3397,9 +3397,9 @@ d++){var b=document.createElement("div");
 b.className="ricoLG_cell "+a;
 b.id=this.tableId+"_"+this.pageSize+"_"+d;
 this.columns[d].dataColDiv.appendChild(b);
 b.className="ricoLG_cell "+a;
 b.id=this.tableId+"_"+this.pageSize+"_"+d;
 this.columns[d].dataColDiv.appendChild(b);
-if(this.columns[d].format.canDrag&&Rico.registerDraggable){Rico.registerDraggable(new Rico.LiveGridDraggable(this,this.pageSize,d),this.options.dndMgrIdx)
-}b.innerHTML="&nbsp;";
 if(this.columns[d]._create){this.columns[d]._create(b,this.pageSize)
 if(this.columns[d]._create){this.columns[d]._create(b,this.pageSize)
+}else{b.innerHTML="&nbsp;"
+}if(this.columns[d].format.canDrag&&Rico.registerDraggable){Rico.registerDraggable(new Rico.LiveGridDraggable(this,this.pageSize,d),this.options.dndMgrIdx)
 }}this.pageSize++
 },defaultRowClass:function(b){var a;
 if(b%2==0){a="ricoLG_evenRow"
 }}this.pageSize++
 },defaultRowClass:function(b){var a;
 if(b%2==0){a="ricoLG_evenRow"
@@ -4489,7 +4489,7 @@ this.fetch(a)
 if(this.processingRequest){Rico.log("AjaxSQL fetch: queue request");
 this.pendingRequest=e;
 return
 if(this.processingRequest){Rico.log("AjaxSQL fetch: queue request");
 this.pendingRequest=e;
 return
-}if(e<0){this.clear();
+}if((typeof e=="undefined")||(e<0)){this.clear();
 this.setTotalRows(0);
 this.foundRowCount=false;
 e=0
 this.setTotalRows(0);
 this.foundRowCount=false;
 e=0