php7 fixes
[Pman.Builder] / Dump.php
1 <?php
2
3 require_once 'Pman.php';
4
5 class Pman_Builder_Dump extends Pman
6 {
7   
8     // getAuth - everyone allowed in...
9     function getAuth() {
10         return true;
11         exit;
12     }
13   
14     function get($app, $opts = array()) {
15         die("DISABLED");
16         $b = DB_DataObject::Factory('Builder');
17         $b->find();
18         echo '<PRE>';
19         $dir = "/home/gitlive/";
20         
21         $map = array(
22             'Clipping' => 'web.MediaOutreach/Pman/Clipping',
23             'PressRelease' => 'web.MediaOutreach/Pman/PressRelease',
24             'Ris' => 'web.Ris/Pman/Ris',
25             'TestApp' => false,
26             'Hex' => false,
27             'Example' => false,
28             'ExampleOld' => false,
29             'Deleted' => false,
30             'DealFlow' => 'web.Dealflow/Pman/DealFlow',
31             'Aviation' => 'web.Aviation/Pman/Aviation',
32             
33         );
34         $dirs = array();
35         while ($b->fetch()) {
36           //  print_r($b);
37             
38             
39             $data = json_decode($b->json);
40             $data->title = $data->name;
41             $data->name = $data->{'|module'};
42             if (empty($data->name)) {
43                 continue;
44             }
45             
46             
47            // {"id":"roo-file-1","name":"layout test.bjs","parent":"","title":false,"path":"/h
48                 //ome/alan/buildertest/layout test.bjs"
49             $fn = $dir ."Pman.". trim($data->app) . '/' . $data->name . '.bjs';
50             if (isseT($map[trim($data->app)])) {
51                 if ($map[trim($data->app)] === false) {
52                     continue;
53                 }
54                 $fn = $dir .$map[$data->app]. '/' . $data->name . '.bjs';
55             }
56             
57             
58             
59             
60             if (!file_exists(dirname($fn))) {
61                 print "<B>SKIP " . $fn . "</B>\n";
62                 continue;
63             }
64             
65             $dirs[dirname($fn)] = true;
66             echo "WRITE : " . $fn . "\n";
67             //echo "                          " .htmlspecialchars(json_encode($data)) . "\n";
68             file_put_contents($fn, json_encode($data));
69             
70              
71         }
72         print_r($dirs);
73         foreach($dirs as $d => $n)
74         {
75             
76             chdir($d);
77             $cmd  = 'git pull 2>&1';
78             echo $cmd ."\n" . `$cmd`;
79             
80             $cmd  = 'git add --all 2>&1';
81             echo $cmd ."\n" . `$cmd`;
82             $cmd  = "git commit -m 'add bjs' -a --author='Alan Knowles <alan@akbkhome.com>' 2>&1";
83             echo $cmd ."\n" . `$cmd`;
84             $cmd  = "git push  2>&1";
85             echo $cmd ."\n" . `$cmd`;
86         }
87         exit;
88         
89     }
90     
91 }