summaryrefslogtreecommitdiff
path: root/demos/quickstart/protected/index/ZendSearch.php
blob: 70aef41445871120f06c40d9f31130059ef4b53d (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
<?php
/*
 * Created on 7/05/2006
 */

class ZendSearch extends TModule
{
	private $_data;
	private $_ZF;
	private $_search;
	
	public function setIndexDataDirectory($path)
	{
		$this->_data = Prado::getPathOfNamespace($path);
	}
	
	public function getIndexDataDirectory()
	{
		return $this->_data;
	}
	
	public function setZendFramework($path)
	{
		$this->_ZF = Prado::getPathOfNamespace($path);
	}
	
	protected function importZendNamespace()
	{
		if(is_null(Prado::getPathOfAlias('Zend')))
		{
			$zendBase = !is_null($this->_ZF) ? $this->_ZF.'.*' : 'Application.index.*';
			$path = !is_null($this->_ZF) ? $this->_ZF.'.Zend.*' : 'Application.index.Zend.*';
			Prado::using($zendBase);
			Prado::setPathOfAlias('Zend', Prado::getPathOfNamespace($path));
		}
	}
	
	protected function getZendSearch()
	{
		if(is_null($this->_search))
		{
			$this->importZendNamespace();
			Prado::using('Zend.Search.Lucene');
		 	$this->_search = new Zend_Search_Lucene($this->_data);
		}
		return $this->_search;
	}
	
	public function find($query)
	{
		return $this->getZendSearch()->find(strtolower($query));
	}
} 

?>