PageRenderTime 52ms CodeModel.GetById 48ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/framework/core/zap/ZoneCreate.php

http://zoop.googlecode.com/
PHP | 62 lines | 53 code | 9 blank | 0 comment | 9 complexity | 97a7be099eb676e4b2d2ac108fe87b71 MD5 | raw file
 1<?php
 2class ZoneCreate
 3{
 4	function subProject($p, $s)
 5	{
 6		$stationaryName = $p[3];
 7		if(isset($p[4]))
 8			$projectName = $p[4];
 9		else
10			$projectName = $stationaryName;
11		
12		$command = "svn export http://zoop.googlecode.com/svn/trunk/stationary/$stationaryName $projectName";
13		echo $command . "\n";
14		passthru($command);
15	}
16	
17	function subMigration($p, $s)
18	{
19		if(!isset($s['v']))
20			trigger_error("no version passed in.  use -v migration_version");
21		else
22			$version = $s['v'];
23		
24		if(!isset($s['n']))
25			trigger_error("no name passed in.  use -n migration_name");
26		else
27			$name = $s['n'];
28		
29		if(!isset($s['s']))
30			$stationaryFilename = 'migration.tpl';
31		else
32			$stationaryFilename = $s['s'];
33		
34		if(isset($s['m']))
35			$moduleName = $s['m'];
36		
37		$gui = new Gui();
38		$gui->left_delimiter = '[[';
39		$gui->right_delimiter = ']]';
40		
41		if(isset($s['m']))
42			$stationaryFilename = 'file:' . zoop_dir . "/$moduleName/stationary/$stationaryFilename";
43		else if(strpos($stationaryFilename, ':') === false)
44			$stationaryFilename = 'file:' . getcwd() . "/stationary/$stationaryFilename";
45		else
46		{
47			$parts = explode(':', $stationaryFilename);
48			$modName = $parts[0];
49			$filename = $parts[1];
50			$stationaryFilename = 'file:' . zoop_dir . "/$modName/stationary/$filename";
51		}
52			
53		$gui->assign('version', str_replace('.', '_', $version));
54		$contents = $gui->fetch($stationaryFilename);
55		
56		$dir = getcwd() . '/migrations';
57		$newFilename = $dir . '/' . $version . '_' . $name . '.php';
58		if(!file_exists($dir))
59			mkdir($dir, 0775, true);
60		file_put_contents($newFilename, $contents);
61	}
62}