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 = "Update SQL or Generate DataObjects";
15   
16     var $cli = false;
17     function getAuth() {
18         
19         
20         $ff = HTML_FlexyFramework::get();
21         if (!empty($ff->cli)) {
22             $this->cli = true;
23             return true;
24         }
25         
26         parent::getAuth(); // load company!
27         $au = $this->getAuthUser();
28         if (!$au || $au->company()->comptype != 'OWNER') {
29             $this->jerr("Not authenticated", array('authFailure' => true));
30         }
31         $this->authUser = $au;
32         return true;
33     }
34      
35     function get($args)
36     {
37         require_once 'Pman/Core/Generator.php';
38         ini_set('pcre.backtrack_limit', 2000000);
39         ini_set('pcre.recursion_limit', 2000000);
40         $this->init();
41          
42         $lastarg = $this->cli  ? array_pop($_SERVER['argv']) : '';
43         if (preg_match('/RunGenerator/', $lastarg)) {
44             $lastarg  = '';
45         }
46         $x = new Pman_Core_Generator();
47        // $x->page = clone($this);
48         $x->start($this->cli, $args, $lastarg);
49         
50         // technically it would be good to trash the cached ini files here.. 
51         // however we can not really do that, as the ownships are off..
52         //we can however regen our own files..
53         HTML_FlexyFramework::get()->generateDataobjectsCache(true);
54         
55         die("done!");
56     }
57     
58 }