RunGenerator.php
[Pman.Builder] / RunGenerator.php
1 <?php
2
3 /**
4  * 
5  * this is technically a cli wrapper for the generator..
6  * 
7  * we will test it on the web initially..
8  * 
9  * 
10  */
11 require_once 'Pman.php';
12 class Pman_Builder_RunGenerator extends Pman
13 {     
14     var $cli = false;
15     
16     
17     static $cli_description  = "Creates Database Tables for modules"
18     
19     static $cli_opts  = array(
20         'test' => array(
21             'short' => 't',
22             'min' => 1,
23             'max' => 1,
24             //'default' => 0, -- no default if it is required..
25             'desc' => 'A test argument that has to be set..'  
26         ),
27         
28         
29         
30         
31     );
32     
33     
34     
35     
36     
37     
38     
39     
40     
41     function getAuth() {
42         
43         $o = PEAR::getStaticProperty('HTML_FlexyFramework', 'options');
44         if (!empty($o['cli'])) {
45             $this->cli = true;
46             return true;
47         }
48         
49         parent::getAuth(); // load company!
50         $au = $this->getAuthUser();
51         if (!$au || $au->company()->comptype != 'OWNER') {
52             $this->jerr("Not authenticated", array('authFailure' => true));
53         }
54         $this->authUser = $au;
55         return true;
56     }
57      
58     function get($args)
59     {
60         require_once 'Pman/Builder/Generator.php';
61         ini_set('pcre.backtrack_limit', 2000000);
62         ini_set('pcre.recursion_limit', 2000000);
63         $this->init();
64          
65         $lastarg = $this->cli  ? array_pop($_SERVER['argv']) : '';
66         if (preg_match('/RunGenerator/', $lastarg)) {
67             $lastarg  = '';
68         }
69         $x = new Pman_Builder_Generator();
70        // $x->page = clone($this);
71         $x->start($this->cli, $args, $lastarg);
72         die("done!");
73     }
74     
75 }