| 1 |
<?php |
| 2 |
/** |
| 3 |
* |
| 4 |
*/ |
| 5 |
|
| 6 |
/** |
| 7 |
* |
| 8 |
*/ |
| 9 |
class CJTInstallerTemplate extends ArrayIterator { |
| 10 |
|
| 11 |
/** |
| 12 |
* put your comment there... |
| 13 |
* |
| 14 |
* @var mixed |
| 15 |
*/ |
| 16 |
protected $model; |
| 17 |
|
| 18 |
/** |
| 19 |
* put your comment there... |
| 20 |
* |
| 21 |
* @param mixed $templates |
| 22 |
* @return CJTInstallerTemplate |
| 23 |
*/ |
| 24 |
public function __construct($templates) { |
| 25 |
// Initialize! |
| 26 |
$this->model = CJTModel::getInstance('template'); |
| 27 |
// Initialize Iterator! |
| 28 |
parent::__construct(is_array($templates) ? $templates : array()); |
| 29 |
} |
| 30 |
|
| 31 |
/** |
| 32 |
* put your comment there... |
| 33 |
* |
| 34 |
*/ |
| 35 |
public function upgrade() { |
| 36 |
// Initiaize! |
| 37 |
$template = $this->current(); |
| 38 |
$item = array(); |
| 39 |
// Revision data! |
| 40 |
$revision['code'] = $template['code']; |
| 41 |
$revision['changeLog'] = 'Just created...'; |
| 42 |
$revision['state'] = 'release'; |
| 43 |
// Template data! |
| 44 |
unset($template['code']); |
| 45 |
// js type name changed to javascript! |
| 46 |
if ($template['type'] == 'js') { |
| 47 |
$template['type'] = 'javascript'; |
| 48 |
} |
| 49 |
// Build template-model template item sturture! |
| 50 |
$item['template'] = $template; |
| 51 |
$item['revision'] = $revision; |
| 52 |
// Save template into db! |
| 53 |
$this->model->inputs['item'] = $item; |
| 54 |
$this->model->save(); |
| 55 |
} |
| 56 |
|
| 57 |
} // End class. |
| 58 |
|