summaryrefslogtreecommitdiff
path: root/protected/controllers/SearchController.php
blob: 275fc6a08ecf4f8ef02e329e2cbb644b6aa395b2 (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
<?php

class SearchController extends Controller
{
	public static $Searchables = array('Veranstaltung'=>array('titel','beschreibung'),'Angebot'=> array('name','beschreibung'),'Verein' => array('beschreibung','name'),'Sitecontent'=>array('content','title'));
	public function actionIndex()
	{
		$this->render('index');
	}

	public function actionSearch($search)
	{
		
		foreach (SearchController::$Searchables as $searchable => $columns) {
			$q = new CDbCriteria();
			foreach ($columns as $col) {
				$q->addSearchCondition($col,$search,true,'OR');
			}
			$results[$searchable]=CActiveRecord::model($searchable)->published()->findAll($q);
		}
		
		
		
		$this->render('results', array(
				'results' => $results,
				'search' => $search));
	}

	// Uncomment the following methods and override them if needed
	 
	public function filters()
	{
		// return the filter configuration for this controller, e.g.:
		return array(
			array('COutputCache','duration'=>3600,'varyByParam'=>array('search','page')),
		);
	}
 /*
	public function actions()
	{
		// return external action classes, e.g.:
		return array(
			'action1'=>'path.to.ActionClass',
			'action2'=>array(
				'class'=>'path.to.AnotherActionClass',
				'propertyName'=>'propertyValue',
			),
		);
	}
	*/
}