1
0

Added Searching

This commit is contained in:
2014-08-04 14:57:13 +02:00
parent 193c9f376d
commit 2af3e05fe1
14 changed files with 242 additions and 10 deletions

View File

@@ -113,4 +113,41 @@ class Log extends CActiveRecord
public function getLink() {
return '/log/' . $this->ID;
}
/**
* @param $search string[]
* @return array()
*/
public static function getSearchResults($search)
{
/* @var $all Log[] */
/* @var $resultarr Log[] */
$all = Log::model()->findAll();
$resultarr = array();
foreach($search as $searchpart)
{
foreach($all as $post)
{
if (stripos($post->title, $searchpart) !== false && ! in_array($post, $resultarr))
$resultarr []= $post;
}
}
$result = array();
foreach($resultarr as $post)
{
$result []=
[
'Name' => $post->title,
'Description' => null,
'Link' => $post->GetLink(),
'Image' => '/images/search/sresult_log.png',
];
}
return $result;
}
}