summaryrefslogtreecommitdiff
path: root/buildscripts/index/build.php
blob: a2e57286f420019d09de779a14d8f7fc3263fc20 (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
<?php
/*
 * Created on 10/05/2006
 */

/**
 * Building search index for quickstart tutorials and the API documentation.
 */


//quickstart source and the index data target directories.
$quickstart_source = realpath(dirname(__FILE__).'/../texbuilder/quickstart/pages.php');
$quickstart_base = realpath(dirname(__FILE__).'/../../demos/quickstart/protected/pages/');
$quickstart_target = realpath(dirname(__FILE__).'/../../demos/quickstart/protected/index/quickstart/');

//API source and the index data target directories.
$api_source = realpath(dirname(__FILE__).'/../../build/docs/manual/');
$api_target = realpath(dirname(__FILE__).'/../../demos/quickstart/protected/index/api/');

//get the ZEND framework
$zend_path = realpath(dirname(__FILE__).'/../../demos/quickstart/protected/index');
set_include_path(get_include_path().';'.$zend_path);
require_once ('Zend/Search/Lucene.php');

//get the indexers.
include('quickstart_index.php');
include('api_index.php');

if(isset($argv[1]))
{
	if(strtolower($argv[1]) == "quickstart")
	{
		$quickstart = new quickstart_index($quickstart_target, $quickstart_base, $quickstart_source);
		$quickstart->create_index();
	}
	else if(strtolower($argv[1]) == "api")
	{
		$api = new api_index($api_target, $api_source);
		$api->create_index();
	}
	else
	{
		$q = new Zend_Search_Lucene($quickstart_target);
		$query = $argv[1];
		$hits = $q->find(strtolower($query));
		echo "Found ".count($hits)." for ".$query." in quick start\n";
		foreach($hits as $hit)
			echo "   ".$hit->title."\n";

		$a = new Zend_Search_Lucene($api_target);
		$query = $argv[1];
		$hits = $a->find(strtolower($query));
		echo "\nFound ".count($hits)." for ".$query." in API\n";
		foreach($hits as $hit)
		{
			echo "   ".$hit->link."\n";
		}
	}
}
else
{
	echo "Usage: 'php build.php quickstart' or 'php build.php api'\n";
}