<?php
class FileController extends MainController implements ControllerInterface
{

	/**
	  * (non-PHPdoc)
	  * @see class/ControllerInterface#IndexAction($param)
	  */
	public function IndexAction($param) {


		$data = array();
		$data['lang']= $param['lang'] ;
		$data['mf_file.publication']= 1 ;

		$date = Utils::GetNowDate();
		$data[' '] = array('value' => " mf_file.date_publication <= '$date' " ,'condition' => '');

		$dalData = MfFileDAL::GetDalDataObj();
		$dalData->setCondition($data);
		//$dalData->setLimit(10);
		$dalData->setSortBy('title');


		$arrayFile = MfFileDAL::GetResult($dalData);

		$arrayFileType = Utils::GetArrayList('mf_file_type', 'id_mf_file_type', 'name');
		$arrayFileByCategory = array();
		foreach ($arrayFileType as $idCategory => $categoryName) {
			foreach ($arrayFile as $file) {
				if ($idCategory == $file->GetType()) {
					$arrayFileByCategory[$categoryName][] = $file;
				}

			}
		}
//				Utils::ArrayDisplay($param['urlParam']);
//				Utils::ArrayDisplay(Router::GenerateUrl('PlikiLabel'));


		//$this->RunShared('FormDownload', $param);
		if (SessionProxy::IsSetValue('sendFormInfo')) {
			$this->addRedirectInfo( Dictionary::Translate('message_sent'),null, Router::GenerateUrl('PlikiLabel'),array(),0);
		}



		$this->smarty->assign('arrayFileByCategory', $arrayFileByCategory);
		$this->smarty->assign('arrayFileType', $arrayFileType);
		$this->smarty->assign('arrayFile', $arrayFile);
	}



	/**
	 * 
	 * @param unknown_type $param
	 * @return unknown_type
	 */
	public function preDispatch($param) {
		$this->smarty->assign('lang', $param['lang']);

		$this->Run($param);
		//$this->AddTitle('');
		//		$this->RunShared('Banner', $param);
	}
	/**
	 * 
	 * @param unknown_type $param
	 * @return unknown_type
	 */
	public function postDispatch($param) {
	}
}