Subversion-Projekte lars-tiefland.prado

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/*
3
 * Created on 7/05/2006
4
 */
5
 
6
class ZendSearch extends TModule
7
{
8
	private $_data;
9
	private $_ZF;
10
	private $_search;
11
 
12
	public function setIndexDataDirectory($path)
13
	{
14
		$this->_data = Prado::getPathOfNamespace($path);
15
	}
16
 
17
	public function getIndexDataDirectory()
18
	{
19
		return $this->_data;
20
	}
21
 
22
	public function setZendFramework($path)
23
	{
24
		$this->_ZF = Prado::getPathOfNamespace($path);
25
	}
26
 
27
	protected function importZendNamespace()
28
	{
29
		if(is_null(Prado::getPathOfAlias('Zend')))
30
		{
31
			$zendBase = !is_null($this->_ZF) ? $this->_ZF.'.*' : 'Application.index.*';
32
			$path = !is_null($this->_ZF) ? $this->_ZF.'.Zend.*' : 'Application.index.Zend.*';
33
			Prado::using($zendBase);
34
			Prado::setPathOfAlias('Zend', Prado::getPathOfNamespace($path));
35
		}
36
	}
37
 
38
	protected function getZendSearch()
39
	{
40
		if(is_null($this->_search))
41
		{
42
			$this->importZendNamespace();
43
			Prado::using('Zend.Search.Lucene');
44
		 	$this->_search = new Zend_Search_Lucene($this->_data);
45
		}
46
		return $this->_search;
47
	}
48
 
49
	public function find($query)
50
	{
51
		return $this->getZendSearch()->find(strtolower($query));
52
	}
53
}
54
 
55
?>