From 3b289dfbfd66fe63b1b596d9c451c848d1302840 Mon Sep 17 00:00:00 2001 From: Antonio Gallo Date: Mon, 31 Jan 2011 18:36:25 +0000 Subject: improved search page --- .../Application/Controllers/SearchController.php | 39 ++++++++++++++-------- 1 file changed, 26 insertions(+), 13 deletions(-) (limited to 'h-source/Application/Controllers') diff --git a/h-source/Application/Controllers/SearchController.php b/h-source/Application/Controllers/SearchController.php index b35ee45..21b3a2e 100644 --- a/h-source/Application/Controllers/SearchController.php +++ b/h-source/Application/Controllers/SearchController.php @@ -110,13 +110,13 @@ class SearchController extends BaseController $data['notice'] = null; $lspci = $this->request->post('lspci','','sanitizeHtml'); + $lspciResult = array(); + $flag = false; + if (strlen($lspci)<10000) { - $flag = false; - $lspci = nl2br($lspci); $lspciArray = explode('
',$lspci); - $lspciResult = array(); reset($lspciArray); while(current($lspciArray) !== false) { @@ -208,25 +208,38 @@ class SearchController extends BaseController } next($lspciArray); } + if (count($lspciResult) === 0) + { + $data['notice'] = "
".gtext('the text submitted by you does not seem the lspci -vmmnn output. Please check the text and try again')."
\n"; + } } else { $data['notice'] = "
the lspci output is too long
\n"; } + + $data['flag'] = $flag; + + $data['table'] = array(); if ($flag) { - echo "
";
-				print_r($lspciResult);
-				echo "
"; + $lspciFiltered = array(); + $vendorIDProductIDArray = array(); + foreach ($lspciResult as $device) + { + if (array_key_exists($device['classId'],Hardware::$deviceClasses)) + { + $vendorIDProductIDArray[] = sanitizePciid($device['vendorId'].":".$device['deviceId']); + $lspciFiltered[] = $device; + } + } + $whereString = "'".implode("','",$vendorIDProductIDArray)."'"; + $data['table'] = $this->m['HardwareModel']->select()->where(array('pci_id'=>"in($whereString)"))->send(); } -// $clean['pciid'] = $this->request->post('lspci','','sanitizePciid'); -// $data['table'] = $this->m['HardwareModel']->clear()->select()->where(array('pci_id'=>$clean['pciid']))->send(); -// $data['recordNumber'] = 0; -// -// $this->append($data); -// $this->cleverLoad('results'); -// $this->right(); + $this->append($data); + $this->cleverLoad('lspci_results'); + $this->right(); } } } \ No newline at end of file -- cgit v1.2.3