RunGenerator.php
[Pman.Core] / 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_Core_RunGenerator extends Pman
13 {     
14     static $cli_desc = "Generate DataObjects (runs updatedatabase first)";
15    
16     static $cli_opts = array(
17         'module' => array(
18             'desc' => 'Module',
19             'short' => 'm',
20             'default' => '',
21             'min' => 0,
22             'max' => 1,
23             
24         ),
25         'overwrite' => array(
26             'desc' => 'Files to Overwrite',
27             'default' => '',
28             'short' => 'o',
29             'min' => 0,
30             'max' => 999,
31             
32         )
33         
34     );
35     
36     var $cli = false;
37     function getAuth() {
38         
39         
40         $ff = HTML_FlexyFramework::get();
41         if (!empty($ff->cli)) {
42             $this->cli = true;
43             return true;
44         }
45         
46         parent::getAuth(); // load company!
47         $au = $this->getAuthUser();
48         if (!$au || $au->company()->comptype != 'OWNER') {
49             $this->jerr("Not authenticated", array('authFailure' => true));
50         }
51         $this->authUser = $au;
52         return true;
53     }
54      
55     function get($args, $opts)
56     {
57         
58         print_r($opts);exit;
59         HTML_FlexyFramework::run('Core/UpdateDatabase');
60         
61          
62         
63         require_once 'Pman/Core/Generator.php';
64         ini_set('pcre.backtrack_limit', 2000000);
65         ini_set('pcre.recursion_limit', 2000000);
66         $this->init();
67          
68         $lastarg = $this->cli  ? array_pop($_SERVER['argv']) : '';
69         if (preg_match('/RunGenerator/', $lastarg)) {
70             $lastarg  = '';
71         }
72         $x = new Pman_Core_Generator();
73        // $x->page = clone($this);
74         $x->start($this->cli, $args, $lastarg);
75         
76         // technically it would be good to trash the cached ini files here.. 
77         // however we can not really do that, as the ownships are off..
78         //we can however regen our own files..
79         HTML_FlexyFramework::get()->generateDataobjectsCache(true);
80         
81         die("done!");
82     }
83     
84 }