From 94bdb31c204cdae3ca820828d4731f11f6ffeeae Mon Sep 17 00:00:00 2001 From: Patrick Seeger Date: Sun, 13 May 2012 16:51:28 +0200 Subject: Suche fast fertig --- .gitignore | 3 +- protected/controllers/SearchController.php | 55 ++++++++++++++++++++++ .../cms/controllers/SitecontentController.php | 3 ++ protected/modules/cms/views/sitecontent/_short.php | 34 +++++++++++++ protected/views/search/index.php | 10 ++++ protected/views/search/results.php | 22 +++++++++ protected/views/standort/view.php | 9 ++-- protected/views/verein/_short.php | 5 +- themes/astaf/views/layouts/main.php | 2 +- 9 files changed, 136 insertions(+), 7 deletions(-) create mode 100644 protected/controllers/SearchController.php create mode 100644 protected/modules/cms/views/sitecontent/_short.php create mode 100644 protected/views/search/index.php create mode 100644 protected/views/search/results.php diff --git a/.gitignore b/.gitignore index b95a88a..d79430b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /assets/**/* /protected/runtime/**/* -/protected/runtime/application.log \ No newline at end of file +/protected/runtime/application.log +/protected/extensions/egmap/.DS_Store \ No newline at end of file diff --git a/protected/controllers/SearchController.php b/protected/controllers/SearchController.php new file mode 100644 index 0000000..2cf87df --- /dev/null +++ b/protected/controllers/SearchController.php @@ -0,0 +1,55 @@ + 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', + ), + ); + } + */ +} \ No newline at end of file diff --git a/protected/modules/cms/controllers/SitecontentController.php b/protected/modules/cms/controllers/SitecontentController.php index a2a3906..e4f7a5f 100644 --- a/protected/modules/cms/controllers/SitecontentController.php +++ b/protected/modules/cms/controllers/SitecontentController.php @@ -17,6 +17,9 @@ class SitecontentController extends Controller $q = new CDbCriteria(); $q->addSearchCondition('content',$_POST['search']); $results = Sitecontent::model()->findAll($q); + $q = new CDbCriteria(); + $q->addSearchCondition('beschreibung',$_POST['search']); + $results = Verein::model()->findAll($q); $this->render('results', array( 'results' => $results, diff --git a/protected/modules/cms/views/sitecontent/_short.php b/protected/modules/cms/views/sitecontent/_short.php new file mode 100644 index 0000000..0352c04 --- /dev/null +++ b/protected/modules/cms/views/sitecontent/_short.php @@ -0,0 +1,34 @@ +
+ + getAttributeLabel('id')); ?>: + id), array('view', 'id'=>$data->id)); ?> +
+ + getAttributeLabel('position')); ?>: + position); ?> +
+ + getAttributeLabel('title')); ?>: + title); ?> +
+ + getAttributeLabel('content')); ?>: + content); ?> +
+ + getAttributeLabel('authorid')); ?>: + authorid); ?> +
+ + getAttributeLabel('createtime')); ?>: + createtime); ?> +
+ + getAttributeLabel('updatetime')); ?>: + updatetime); ?> +
+ + */ ?> + +
diff --git a/protected/views/search/index.php b/protected/views/search/index.php new file mode 100644 index 0000000..7b457ef --- /dev/null +++ b/protected/views/search/index.php @@ -0,0 +1,10 @@ +breadcrumbs=array( + 'Search', +);?> +

id . '/' . $this->action->id; ?>

+ +

+ You may change the content of this page by modifying + the file . +

diff --git a/protected/views/search/results.php b/protected/views/search/results.php new file mode 100644 index 0000000..c1d80e2 --- /dev/null +++ b/protected/views/search/results.php @@ -0,0 +1,22 @@ +breadcrumbs=array( + 'Search'=>array('/search'), + 'Results', +);?> +

id . '/' . $this->action->id; ?>

+ $res) {?> +
+ widget('zii.widgets.CListView', array( + 'dataProvider'=>$dataProvider, + 'itemView'=>'/cms/'.lcfirst($mod).'/_short', // refers to the partial view named '_post' + 'sortableAttributes'=>array( + 'name', + /*'create_time'=>'Post Time',*/ + ), + ));?> + +

+

+

diff --git a/protected/views/standort/view.php b/protected/views/standort/view.php index 26312a3..0674ce9 100644 --- a/protected/views/standort/view.php +++ b/protected/views/standort/view.php @@ -48,7 +48,7 @@ $gMap->enableMarkerClusterer(new EGMapMarkerClusterer()); $gMap->renderMap(); ?>

-

+

Folgende Vereine finden sich name?>
array( @@ -57,11 +57,12 @@ $dataProvider=new CActiveDataProvider('Verein', array( 'pagination'=>array( 'pageSize'=>20, ), + )); $this->widget('zii.widgets.CListView', array( 'dataProvider'=>$dataProvider, 'itemView'=>'/verein/_short', - + 'sortableAttributes'=>array( + 'name' + ) ));?> - -

\ No newline at end of file diff --git a/protected/views/verein/_short.php b/protected/views/verein/_short.php index e31ed34..0ff6284 100644 --- a/protected/views/verein/_short.php +++ b/protected/views/verein/_short.php @@ -1,4 +1,6 @@ +name,array("verein/view","id"=>$data->id)); ?> + */?> beschreibung))>300) { $tmp = str_split(strip_tags($data->beschreibung),297); @@ -6,6 +8,7 @@ if(strlen(strip_tags($data->beschreibung))>300) { } else { $myBeschreibung = strip_tags($data->beschreibung); }?> +$data->id)); ?>

- + */?> ".$data->name."

".$myBeschreibung."

" ,array("verein/view","id"=>$data->id)); ?> \ No newline at end of file diff --git a/themes/astaf/views/layouts/main.php b/themes/astaf/views/layouts/main.php index 025952f..1fec929 100644 --- a/themes/astaf/views/layouts/main.php +++ b/themes/astaf/views/layouts/main.php @@ -58,7 +58,7 @@ )); ?> - 'ym-searchform')); ?> + 'ym-searchform')); ?> -- cgit v1.0-28-g1787