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

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

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

	// Uncomment the following methods and override them if needed
	/*
	public function filters()
	{
		// return the filter configuration for this controller, e.g.:
		return array(
			'inlineFilterName',
			array(
				'class'=>'path.to.FilterClass',
				'propertyName'=>'propertyValue',
			),
		);
	}

	public function actions()
	{
		// return external action classes, e.g.:
		return array(
			'action1'=>'path.to.ActionClass',
			'action2'=>array(
				'class'=>'path.to.AnotherActionClass',
				'propertyName'=>'propertyValue',
			),
		);
	}
	*/
}