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         'module' => array(
21             'short' => 'm',
22             'min' => 1,
23             'max' => 1,
24             'default' => '',
25             'desc' => 'Module to Generate'  
26         ),
27         'update-db' => array(
28             'short' => 'd',
29             'min' => 0,
30             'max' => 0,
31             'desc' => 'Flag to just run database updates'  
32         ),
33         
34         'update-files' => array(
35             'short' => 'f',
36             'min' => 1,
37             'max' => 99,
38             'default' => false
39             'desc' => 'Files to update, eg. -f pman.ini -f Mtrack_wiki.php ' 
40         ),
41         
42         
43         
44         
45     );
46     
47     
48     
49     
50     
51     
52     
53     
54     
55     function getAuth() {
56         
57         $o = PEAR::getStaticProperty('HTML_FlexyFramework', 'options');
58         if (!empty($o['cli'])) {
59             $this->cli = true;
60             return true;
61         }
62         
63         parent::getAuth(); // load company!
64         $au = $this->getAuthUser();
65         if (!$au || $au->company()->comptype != 'OWNER') {
66             $this->jerr("Not authenticated", array('authFailure' => true));
67         }
68         $this->authUser = $au;
69         return true;
70     }
71      
72     function get($args,$opts)
73     {
74         
75         print_R($opts); exit;
76         
77         require_once 'Pman/Builder/Generator.php';
78         ini_set('pcre.backtrack_limit', 2000000);
79         ini_set('pcre.recursion_limit', 2000000);
80         $this->init();
81          
82         $lastarg = $this->cli  ? array_pop($_SERVER['argv']) : '';
83         if (preg_match('/RunGenerator/', $lastarg)) {
84             $lastarg  = '';
85         }
86         $x = new Pman_Builder_Generator();
87        // $x->page = clone($this);
88         $x->start($this->cli, $args, $lastarg);
89         die("done!");
90     }
91     
92 }