summaryrefslogtreecommitdiff
path: root/buildscripts/phing/tasks/PradoQuickStartDocs.php
blob: 06c30a148a80aabf66bf93a832656ea9aaff55b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
require_once 'phing/Task.php';

require_once(dirname(__FILE__).'/../../chmbuilder/ChmQuickstartBuilder.php');
include(dirname(__FILE__).'/../../../framework/PradoBase.php');
class Prado extends PradoBase
{
	protected static $app;

	public static function setApplication($application)
	{
		self::$app=$application;
	}

	public static function getApplication()
	{
		return self::$app;
	}

	public static function setPathOfAlias($alias,$path)
	{
		$aliases = self::getPathAliases();
		if(!isset($aliases[$alias]))
			parent::setPathOfAlias($alias,$path);
	}
}

include(dirname(__FILE__).'/../../../framework/prado.php');

/**
 * Task to run phpDocumentor for PRADO API docs.
 */
class PradoQuickStartDocs extends Task
{
	private $base_dir;

	private $destdir;

	private $page;

	/**
	 * Set the destination directory for the generated documentation
	 */
	function setOutput(PhingFile $destdir)
	{
		$this->destdir = $destdir;
	}

	function setPages($page)
	{
		$this->page = $page;
	}

	/**
	 * Main entrypoint of the task
	 */
	function main()
	{
		$output = $this->destdir->getAbsolutePath();
		$base = dirname(__FILE__).'/../../../demos/quickstart/protected/';
		error_reporting(0);
		$quickstart= new ChmQuickstartBuilder($base,$output);

		foreach(preg_split('/\s*[, ]+\s*/', $this->page) as $page)
		{
			$file = str_replace(array('/','.page'), array('_','.html'),$page);
			$this->log("Parsing $page");
			file_put_contents($output.'/'.$file, $this->parsePage($quickstart,$page));
			$this->log("Writing $file");
		}
	}

	protected function parsePage($quickstart, $page)
	{
		$_GET['page'] = str_replace(array('/','.page'),array('.',''),$page);
		$_GET['notheme'] = 'true';
		$content = $quickstart->parseHtmlContent($quickstart->getApplicationContent());
		//hide prado specific content
		$content = str_replace('<body>', '<style type="text/css">.prado-specific {display:none;}</style><body>', $content);
		return $content;
	}

}

?>