<?php   
class ModuleCurrency extends Controller {
	function fetch() {
		$config   =& $this->locator->get('config');
		$currency =& $this->locator->get('currency');
		$database =& $this->locator->get('database');
		$language =& $this->locator->get('language');		
		$request  =& $this->locator->get('request');
		$response =& $this->locator->get('response');
		$url      =& $this->locator->get('url');
		
		if ($config->get('currency_status')) {	
			if (($request->isPost()) && ($request->has('currency', 'post'))) {
      			$currency->set($request->get('currency', 'post'));

  				$response->redirect($url->href('home'));
   			}
    	
			$language->load('extension/module/currency.php');
		
			$view = $this->locator->create('template');
		
   			$view->set('heading_title', $language->get('heading_title'));

   			$view->set('action', $url->href('home'));

   			$view->set('text_currency', $language->get('text_currency'));

   			$view->set('entry_currency', $language->get('entry_currency'));

   			$view->set('default', $currency->getCode());

   			$view->set('currencies', $database->cache('currency', "select * from currency order by title"));

   			return $view->fetch('module/currency.tpl'); 
		}
	} 
}
?>