| 1 |
<?php |
| 2 |
/** |
| 3 |
* @version view.php |
| 4 |
*/ |
| 5 |
|
| 6 |
// Disallow direct access. |
| 7 |
defined('ABSPATH') or die("Access denied"); |
| 8 |
|
| 9 |
/** |
| 10 |
* Blocks view |
| 11 |
*/ |
| 12 |
class CJTBlocksBlockView extends CJTView { |
| 13 |
|
| 14 |
/** */ |
| 15 |
const META_BOX_PREFIX = 'cjtoolbox'; |
| 16 |
|
| 17 |
/** |
| 18 |
* put your comment there... |
| 19 |
* |
| 20 |
* @var mixed |
| 21 |
*/ |
| 22 |
public $block = null; |
| 23 |
|
| 24 |
/** |
| 25 |
* put your comment there... |
| 26 |
* |
| 27 |
* @var mixed |
| 28 |
*/ |
| 29 |
protected $localization; |
| 30 |
|
| 31 |
/** |
| 32 |
* put your comment there... |
| 33 |
* |
| 34 |
* @var mixed |
| 35 |
*/ |
| 36 |
protected $params = array(); |
| 37 |
|
| 38 |
/** |
| 39 |
* put your comment there... |
| 40 |
* |
| 41 |
* @var mixed |
| 42 |
*/ |
| 43 |
public $templateName = 'edit'; |
| 44 |
|
| 45 |
/** |
| 46 |
* put your comment there... |
| 47 |
* |
| 48 |
*/ |
| 49 |
public function __construct($viewInfo) { |
| 50 |
parent::__construct($viewInfo); |
| 51 |
// Enqueue Styles & Scripts. |
| 52 |
add_action('admin_print_styles', array(__CLASS__, 'enqueueStyles')); |
| 53 |
add_action('admin_print_scripts', array(__CLASS__, 'enqueueScripts')); |
| 54 |
// Cast params to object |
| 55 |
$this->params = (object) $this->params; |
| 56 |
// Load localization text. |
| 57 |
$this->localization = require($this->getPath('public/js/jquery.block/jquery.block.localization.php')); |
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* put your comment there... |
| 62 |
* |
| 63 |
*/ |
| 64 |
public function display() { |
| 65 |
// Import template. |
| 66 |
echo $this->getTemplate($this->templateName); |
| 67 |
} |
| 68 |
|
| 69 |
/** |
| 70 |
* put your comment there... |
| 71 |
* |
| 72 |
*/ |
| 73 |
public static function enqueueScripts() { |
| 74 |
// Use related scripts. |
| 75 |
self::useScripts(__CLASS__, |
| 76 |
'jquery', |
| 77 |
'common', |
| 78 |
'wp-lists', |
| 79 |
'postbox', |
| 80 |
'thickbox', |
| 81 |
'framework:js:hash:{CJT-}md5', |
| 82 |
'framework:js:cookies:{CJT-}jquery.cookies.2.2.0', |
| 83 |
'framework:js:ajax:{CJT-}cjt-server', |
| 84 |
'framework:js:ajax:{CJT-}cjt-server-queue', |
| 85 |
'framework:js:ui:{CJT-}jquery.toolbox', |
| 86 |
'framework:js:ace(loadMethod=Tag, lookFor=ace)', |
| 87 |
'framework:js:ace:{CJT-}pluggable', |
| 88 |
'views:blocks:block:public:js:{CJT-}ajax', |
| 89 |
'views:blocks:block:public:js:{CJT-}block', |
| 90 |
'views:blocks:block:public:js:{CJT-}jquery.block' |
| 91 |
); |
| 92 |
} |
| 93 |
|
| 94 |
/** |
| 95 |
* put your comment there... |
| 96 |
* |
| 97 |
*/ |
| 98 |
public static function enqueueStyles() { |
| 99 |
// Use related styles. |
| 100 |
self::useStyles(__CLASS__, |
| 101 |
'thickbox', |
| 102 |
'views:blocks:block:public:css:{CJT-}block' |
| 103 |
); |
| 104 |
} |
| 105 |
|
| 106 |
/** |
| 107 |
* put your comment there... |
| 108 |
* |
| 109 |
*/ |
| 110 |
public function getBlock() { |
| 111 |
return $this->block; |
| 112 |
} |
| 113 |
|
| 114 |
/** |
| 115 |
* put your comment there... |
| 116 |
* |
| 117 |
*/ |
| 118 |
public function getMetaboxName() { |
| 119 |
$tip = cssJSToolbox::getText('Click to update Block name'); |
| 120 |
return "<span class='block-name' title='{$tip}'>{$this->block->name}</span>"; |
| 121 |
} |
| 122 |
|
| 123 |
/** |
| 124 |
* put your comment there... |
| 125 |
* |
| 126 |
* @param mixed $id |
| 127 |
*/ |
| 128 |
public function getMetaboxId() { |
| 129 |
return self::META_BOX_PREFIX ."-{$this->block->id}"; |
| 130 |
} |
| 131 |
|
| 132 |
/** |
| 133 |
* put your comment there... |
| 134 |
* |
| 135 |
* @param mixed $name |
| 136 |
*/ |
| 137 |
public function getOption($name) { |
| 138 |
return $this->params->{$name}; |
| 139 |
} |
| 140 |
|
| 141 |
/** |
| 142 |
* |
| 143 |
* |
| 144 |
*/ |
| 145 |
public function setBlock($block) { |
| 146 |
$this->block = $block; |
| 147 |
} |
| 148 |
|
| 149 |
/** |
| 150 |
* put your comment there... |
| 151 |
* |
| 152 |
* @param mixed $name |
| 153 |
* @param mixed $value |
| 154 |
*/ |
| 155 |
public function setOption($name, $value) { |
| 156 |
$this->params->{$name} = $value; |
| 157 |
// Chains! |
| 158 |
return $this; |
| 159 |
} |
| 160 |
|
| 161 |
} // End class. |
| 162 |
|
| 163 |
// Hookable! |
| 164 |
CJTBlocksBlockView::define('CJTBlocksBlockView'); |