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             'min' => 1,
21             'max' => 1,
22             
23         ),
24         'overwrite' => array(
25             'desc' => 'Files to Overwrite',
26             'default' => '',
27             'short' => 'o',
28             'min' => 0,
29             'max' => 999,
30             
31         )
32         
33     );
34     
35     var $cli = false;
36     function getAuth() {
37         
38         
39         $ff = HTML_FlexyFramework::get();
40         if (!empty($ff->cli)) {
41             $this->cli = true;
42             return true;
43         }
44         
45         parent::getAuth(); // load company!
46         $au = $this->getAuthUser();
47         if (!$au || $au->company()->comptype != 'OWNER') {
48             $this->jerr("Not authenticated", array('authFailure' => true));
49         }
50         $this->authUser = $au;
51         return true;
52     }
53      
54     function get($args)
55     {
56         HTML_FlexyFramework::run('Core/UpdateDatabase');
57         
58         die("running generator");
59         
60         require_once 'Pman/Core/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_Core_Generator();
70        // $x->page = clone($this);
71         $x->start($this->cli, $args, $lastarg);
72         
73         // technically it would be good to trash the cached ini files here.. 
74         // however we can not really do that, as the ownships are off..
75         //we can however regen our own files..
76         HTML_FlexyFramework::get()->generateDataobjectsCache(true);
77         
78         die("done!");
79     }
80     
81 }