Separate ValidatePlant and CheckSyntax
authorlseed <mail@joachim-breitner.de>
Thu, 25 Jun 2009 19:34:19 +0000 (21:34 +0200)
committerJoachim Breitner <mail@joachim-breitner.de>
Fri, 26 Jun 2009 08:42:49 +0000 (10:42 +0200)
The former is to validate an existing plant, the latter to validate code that
is being edited, but not present in the database.

web/js/communication.js
web/php/Controller.php
web/php/Plant.php
web/php/page/createplant.pg

index 2c1ea6e..2e18914 100644 (file)
@@ -580,7 +580,7 @@ Lseed.Editor = function() {
                }
                
                communication.sendMessage(Lseed.MessageCommands.RPC, { 
-                       func: 'ValidatePlant'
+                       func: 'CheckSyntax'
                        ,plant: plant.data.Name
                        ,code: plant.data.Code
                });
index 3c3505e..7638696 100644 (file)
                                        $res = $plant->Validate();
                                        break;
 
+                               case "CheckSyntax":
+                                       # Create a temporary plant              
+                                       $plant = new Plant(0,0,$plantname,$code,0);
+                                       $res = $plant->Validate();
+                                       break;
+
                                default:
                                        $res = "{ success : false, msg: \"Unkown RPC call '".$func."'\"}";
                        }
index 7c97090..2fd5b28 100644 (file)
                        $this->IsActive = false;
                        $this->m_Database = $database;
                        if (!isset($GLOBALS['ValidatorFile'])) {
-                               $GLOBALS['ValidatorFile'] = '../cgi/validate';
-                               if ($GLOBALS['WINDOWS']) {
-                                       $GLOBALS['ValidatorFile'] = '../cgi/validate.exe';
-                               }
+                               $GLOBALS['ValidatorFile'] = '/home/lseed/.cabal/bin/validate';
+                               #if ($GLOBALS['WINDOWS']) {
+                               #       $GLOBALS['ValidatorFile'] = '../cgi/validate.exe';
+                               #}
                        }
                }
 
@@ -84,7 +84,7 @@
                           2 => array("pipe", "w")   // STDERR
                        );
 
-                       $cwd = realpath("..\\cgi");
+                       $cwd = realpath(".");
 
                        $process = proc_open($GLOBALS['ValidatorFile'], $descriptorspec, $pipes, $cwd, array());
 
index a0559a2..e078057 100644 (file)
@@ -41,7 +41,7 @@
                        if (pdEditor && pnEditor) {
                                var name = pnEditor.getValue();
                                var code = pdEditor.getValue();
-                               editor.CheckSyntax({data:{Code:code, Name:name}}, editor.HandleSyntaxCheckAnswerForEditor); 
+                               editor.CheckSyntax({data:{Code:code, Name:name}});
                        } else {
                                console.error("Lseed.Editor.CheckSyntaxCallback_Callback: 'plantdefinitioneditor' Could not be found.");
                        }