<?php
							 | 
						|
								/** 
							 | 
						|
								* @package		uForum2
							 | 
						|
								* @file		inc/askModel.class.php
							 | 
						|
								* @copyright	2007-2015 (c) PioDer <[email protected]>
							 | 
						|
								* @link    		http://www.pioder.pl/
							 | 
						|
								* @license		see LICENSE.txt
							 | 
						|
								**/
							 | 
						|
								
							 | 
						|
								require_once('./inc/model.class.php');
							 | 
						|
								
							 | 
						|
								abstract class AskModel
							 | 
						|
								{
							 | 
						|
									protected $models = array();
							 | 
						|
									
							 | 
						|
									function loadModel($model)
							 | 
						|
									{
							 | 
						|
										if (file_exists('./inc/models/'.$model.'.class.php') && !array_key_exists($model, $this->models)) //singleton
							 | 
						|
										{
							 | 
						|
											require_once('./inc/models/'.$model.'.class.php');
							 | 
						|
											$this->models[$model] = new $model($this->db);
							 | 
						|
										}
							 | 
						|
										else
							 | 
						|
										{
							 | 
						|
											throw new Exception('Could not load selected model: '.$model);
							 | 
						|
										}
							 | 
						|
									}
							 | 
						|
									
							 | 
						|
									function getModel($model)
							 | 
						|
									{
							 | 
						|
										if (array_key_exists($model, $this->models))
							 | 
						|
											return $this->models[$model];
							 | 
						|
										else
							 | 
						|
											throw new Exception('Could not get selected model: '.$model);
							 | 
						|
									}
							 | 
						|
									
							 | 
						|
									function putExistingModel($model, &$model_ptr)
							 | 
						|
									{
							 | 
						|
										$this->models[$model] = $model_ptr;
							 | 
						|
									}
							 | 
						|
								}
							 | 
						|
								?>
							 |