fix #8131 - chinese translations
[Pman.Core] / RunGenerator.php
index f31f1d6..3911255 100644 (file)
 require_once 'Pman.php';
 class Pman_Core_RunGenerator extends Pman
 {     
+    static $cli_desc = "Generate DataObjects (runs updatedatabase first)  
+                     does not change files, just shows you want would happen";
+        
+        
+    static $cli_opts = array(
+        'module' => array(
+            'desc' => 'Module (if new tables are found, they will be put in the modules database directory',
+            'short' => 'm',
+            'default' => '',
+            'min' => 1,
+            'max' => 1,
+            
+        ),
+        'overwrite' => array(
+            'desc' => 'Files to Overwrite (use _all_ to create everything)',
+            'default' => '',
+            'short' => 'o',
+            'min' => 1,
+            'max' => -1,
+            
+        ),
+        'noupdate' => array(
+            'desc' => 'Do not update the database using sql',
+            'default' => '',
+            'short' => 'n',
+            'min' => 1,
+            'max' => -1,
+            
+        )
+        
+    );
+    
     var $cli = false;
     function getAuth() {
         
@@ -24,26 +56,36 @@ class Pman_Core_RunGenerator extends Pman
         parent::getAuth(); // load company!
         $au = $this->getAuthUser();
         if (!$au || $au->company()->comptype != 'OWNER') {
-            $this->jerr("Not authenticated", array('authFailure' => true));
+            $this->jerror("LOGIN-NOAUTH", "Not authenticated", array('authFailure' => true));
         }
         $this->authUser = $au;
         return true;
     }
      
-    function get($args)
+    function get($args, $opts=array())
     {
+        //print_r($opts);exit;
+        if (empty($opts['noupdate'])) {
+            HTML_FlexyFramework::run('Core/UpdateDatabase');
+        }
+        
+        
+         
+        
         require_once 'Pman/Core/Generator.php';
         ini_set('pcre.backtrack_limit', 2000000);
         ini_set('pcre.recursion_limit', 2000000);
         $this->init();
-         
-        $lastarg = $this->cli  ? array_pop($_SERVER['argv']) : '';
-        if (preg_match('/RunGenerator/', $lastarg)) {
-            $lastarg  = '';
-        }
+        
         $x = new Pman_Core_Generator();
        // $x->page = clone($this);
-        $x->start($this->cli, $args, $lastarg);
+       
+        
+        $modules = $opts['module'];
+        // overwrite can be multiple
+        $overwrite = is_string($opts['overwrite']) ? array($opts['overwrite']) : $opts['overwrite'];
+
+        $x->start($this->cli, $modules, $overwrite);
         
         // technically it would be good to trash the cached ini files here.. 
         // however we can not really do that, as the ownships are off..