summaryrefslogtreecommitdiff
path: root/tests/FunctionalTests/features/protected/pages/ActiveControls/AutoComplete.php
blob: ac08e4ed52adc1e1bf3240248f8b7416d6917b95 (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
<?php
/*
 * Created on 7/05/2006
 */

class AutoComplete extends TPage
{
	public function suggestCountries($sender, $param)
	{
		$sender->setDataSource($this->matchCountries($param->getParameter()));
		$sender->dataBind();
		$sender->render($param->getOutput());
	}
	
	protected function matchCountries($token)
	{
		$info = Prado::createComponent('System.I18N.core.CultureInfo', 'en');
		$list = array();
		$count = 0;
		$token = strtolower($token);
		foreach($info->getCountries() as $country)
		{
			if(strpos(strtolower($country), $token) === 0)
			{
				$list[] = $country;
				$count++;
				if($count > 10) break;
			}	
		}
		return $list;				 
	}
}

?>