| 1 |
<?php |
| 2 |
/** |
| 3 |
* @version model.inc.php |
| 4 |
*/ |
| 5 |
|
| 6 |
/** |
| 7 |
* No direct access. |
| 8 |
*/ |
| 9 |
defined('ABSPATH') or die("Access denied"); |
| 10 |
|
| 11 |
/** |
| 12 |
* CJT model base class. |
| 13 |
*/ |
| 14 |
abstract class CJTModel { |
| 15 |
|
| 16 |
/** |
| 17 |
* put your comment there... |
| 18 |
* |
| 19 |
* @var mixed |
| 20 |
*/ |
| 21 |
protected $properties = array(); |
| 22 |
|
| 23 |
/** |
| 24 |
* put your comment there... |
| 25 |
* |
| 26 |
* @param mixed $values |
| 27 |
* @return CJTModel |
| 28 |
*/ |
| 29 |
public function __construct($values) { |
| 30 |
$this->setValues($values); |
| 31 |
} |
| 32 |
|
| 33 |
/** |
| 34 |
* put your comment there... |
| 35 |
* |
| 36 |
* @deprecated Use CJTModel::getInstance. |
| 37 |
*/ |
| 38 |
public static function create($model, $params = array(), $file = null) { |
| 39 |
return self::getInstance($model, $params, $file); |
| 40 |
} |
| 41 |
|
| 42 |
/** |
| 43 |
* put your comment there... |
| 44 |
* |
| 45 |
* @param mixed $model |
| 46 |
* @param mixed $params |
| 47 |
* @param mixed $file |
| 48 |
*/ |
| 49 |
public static function & getInstance($model, $params = array(), $file = null) { |
| 50 |
return CJTController::getModel($model, $params, $file); |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* put your comment there... |
| 55 |
* |
| 56 |
*/ |
| 57 |
public function getValues() { |
| 58 |
return ((object)$this->properties); |
| 59 |
} |
| 60 |
|
| 61 |
/** |
| 62 |
* put your comment there... |
| 63 |
* |
| 64 |
* @param mixed $model |
| 65 |
*/ |
| 66 |
public static function import($model) { |
| 67 |
$pathToModels = CJTOOLBOX_MODELS_PATH; |
| 68 |
// Import model file. |
| 69 |
$modelFile = "{$pathToModels}/{$model}.php"; |
| 70 |
require_once $modelFile; |
| 71 |
} |
| 72 |
|
| 73 |
/** |
| 74 |
* put your comment there... |
| 75 |
* |
| 76 |
* @param mixed $values |
| 77 |
*/ |
| 78 |
public function setValues($values) { |
| 79 |
foreach ($values as $name => $value) { |
| 80 |
$this->properties[$name] = $value; |
| 81 |
} |
| 82 |
} |
| 83 |
|
| 84 |
} // End class. |