| 1 |
<?php |
| 2 |
/** |
| 3 |
* |
| 4 |
*/ |
| 5 |
|
| 6 |
// No direct access. |
| 7 |
defined('ABSPATH') or die('Access denied'); |
| 8 |
|
| 9 |
/** |
| 10 |
* |
| 11 |
*/ |
| 12 |
class CJTTemplatesTemplateView extends CJTView { |
| 13 |
|
| 14 |
/** |
| 15 |
* put your comment there... |
| 16 |
* |
| 17 |
* @var mixed |
| 18 |
*/ |
| 19 |
protected $isNew; |
| 20 |
|
| 21 |
/** |
| 22 |
* put your comment there... |
| 23 |
* |
| 24 |
* @var mixed |
| 25 |
*/ |
| 26 |
public $item; |
| 27 |
|
| 28 |
/** |
| 29 |
* put your comment there... |
| 30 |
* |
| 31 |
* @var mixed |
| 32 |
*/ |
| 33 |
protected $onprepareitem = array('parameters' => array('item', 'isNew')); |
| 34 |
|
| 35 |
/** |
| 36 |
* put your comment there... |
| 37 |
* |
| 38 |
* @param mixed $tpl |
| 39 |
*/ |
| 40 |
public function display($tpl = null) { |
| 41 |
// Is it a new template or just editing exists one? |
| 42 |
$this->isNew = empty($_REQUEST['id']); |
| 43 |
// If editing exists on read it from database. |
| 44 |
if (!$this->isNew) { |
| 45 |
$this->item = $this->getModel()->getItem(); |
| 46 |
} |
| 47 |
else { |
| 48 |
// E_ALL complain/Default values for new record if needed! |
| 49 |
$this->item = (object) array( |
| 50 |
'name' => '', |
| 51 |
'type' => '', |
| 52 |
'state' => '', |
| 53 |
'code' => '', |
| 54 |
'description' => '', |
| 55 |
'keywords' => '', |
| 56 |
'version' => '', |
| 57 |
'developmentState' => '', |
| 58 |
'changeLog' => '', |
| 59 |
'id' => '', |
| 60 |
); |
| 61 |
} |
| 62 |
$this->item = $this->onprepareitem($this->item, $this->isNew); |
| 63 |
echo $this->getTemplate($tpl) ; |
| 64 |
} |
| 65 |
|
| 66 |
/** |
| 67 |
* Output JavaScript files requirred to Add-New-Block view to run. |
| 68 |
* |
| 69 |
* @return void |
| 70 |
*/ |
| 71 |
public function enququeScripts() { |
| 72 |
// Use related scripts. |
| 73 |
self::useScripts(__CLASS__, |
| 74 |
'jquery', |
| 75 |
'thickbox', |
| 76 |
'jquery-serialize-object', |
| 77 |
'jquery-ui-tabs', |
| 78 |
'framework:js:misc:{CJT-}simple-error-dialog', |
| 79 |
'framework:js:ace(loadMethod=Tag, lookFor=ace)', |
| 80 |
'framework:js:ace:{CJT-}pluggable', |
| 81 |
'views:templates:template:public:js:{CJT-}template' |
| 82 |
); |
| 83 |
} |
| 84 |
|
| 85 |
/** |
| 86 |
* Output CSS files required to Add-New-Block view. |
| 87 |
* |
| 88 |
* @return void |
| 89 |
*/ |
| 90 |
public function enququeStyles() { |
| 91 |
// Use related styles. |
| 92 |
self::useStyles(__CLASS__, |
| 93 |
'thickbox', |
| 94 |
'framework:css:jquery-ui-1.8.21.custom', |
| 95 |
'framework:css:{CJT-}forms', |
| 96 |
'framework:css:{CJT-}error-dialog', |
| 97 |
'views:templates:template:public:css:{CJT-}default' |
| 98 |
); |
| 99 |
} |
| 100 |
|
| 101 |
} // End class. |
| 102 |
|
| 103 |
// Hookable!! |
| 104 |
CJTTemplatesTemplateView::define('CJTTemplatesTemplateView', array('hookType' => CJTWordpressEvents::HOOK_FILTER)); |