| 
									
										
										
										
											2014-04-19 15:11:53 -05:00
										 |  |  | <?php | 
					
						
							|  |  |  | class HF_Controller | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     protected $config; | 
					
						
							|  |  |  |     protected $tpl; | 
					
						
							| 
									
										
										
										
											2014-12-23 22:51:45 -06:00
										 |  |  |     /** @var HF_Core  */ | 
					
						
							| 
									
										
										
										
											2014-04-19 15:11:53 -05:00
										 |  |  |     protected $core; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function __construct($config, $core, $tpl = null) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $this->config = $config; | 
					
						
							|  |  |  |         $this->tpl = $tpl; | 
					
						
							|  |  |  |         $this->core = $core; | 
					
						
							| 
									
										
										
										
											2014-12-23 22:51:45 -06:00
										 |  |  |         $this->initdb(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     protected function initdb() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (isvarset($this->config["MYSQL_DBNAME"]) && isvarset($this->config["MYSQL_USER"])) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             $pdo = new PDO( | 
					
						
							|  |  |  |                 "mysql:dbname={$this->config['MYSQL_DBNAME']};host={$this->config['MYSQL_HOST']}", | 
					
						
							|  |  |  |                 $this->config['MYSQL_USER'], | 
					
						
							|  |  |  |                 $this->config['MYSQL_PASS'], | 
					
						
							|  |  |  |                 array( | 
					
						
							|  |  |  |                     PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8", | 
					
						
							|  |  |  |                     PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ, | 
					
						
							|  |  |  |                     PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION | 
					
						
							|  |  |  |                 ) | 
					
						
							|  |  |  |             ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             DB::$c = $pdo; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2014-04-19 15:11:53 -05:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-27 21:05:19 -05:00
										 |  |  |     public function loadRender($template, $parameters=array()) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $this->tpl->loadTemplate($template); | 
					
						
							|  |  |  |         return $this->tpl->render($parameters); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-19 15:11:53 -05:00
										 |  |  | } |