PluginProbe
CSS & JavaScript Toolbox / 11
CSS & JavaScript Toolbox v11
trunk 0.3 0.8 10 10.1 11 11.2 11.3 11.4 11.5 11.6 11.7 11.8 11.9 11.9.1 12 12.0 12.0.1 12.0.3 12.0.4 12.0.5 12.0.6 12.0.7 6.0 6.0.11 All 60 releases
css-javascript-toolbox / views / blocks / block / view.php

view.php in CSS & JavaScript Toolbox 11, at views/blocks/block/view.php

229 lines 5.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 public $isClosed;
30
31 /**
32 * put your comment there...
33 *
34 * @var mixed
35 */
36 protected $localization;
37
38 /**
39 * put your comment there...
40 *
41 * @var mixed
42 */
43 protected $ontoolbox = array('parameters' => array('block'));
44
45 /**
46 * put your comment there...
47 *
48 * @var mixed
49 */
50 protected $params = array();
51
52 /**
53 * put your comment there...
54 *
55 * @var mixed
56 */
57 public $templateName = 'edit';
58
59 /**
60 * put your comment there...
61 *
62 */
63 public function __construct($viewInfo) {
64 parent::__construct($viewInfo);
65 // Enqueue Styles & Scripts.
66 add_action('admin_print_styles', array(__CLASS__, 'enqueueStyles'));
67 add_action('admin_print_scripts', array(__CLASS__, 'enqueueScripts'));
68 // Cast params to object
69 $this->params = (object) $this->params;
70 // Load localization text.
71 $this->localization = require($this->getPath('public/js/jquery.block/jquery.block.localization.php'));
72 }
73
74 /**
75 * put your comment there...
76 *
77 */
78 public function display($template = null) {
79 // Import template.
80 echo $this->getTemplate($template ? $template : $this->templateName);
81 }
82
83 /**
84 * put your comment there...
85 *
86 */
87 public static function enqueueScripts() {
88 // Use related scripts.
89 self::useScripts(__CLASS__,
90 'jquery',
91 'common',
92 'wp-lists',
93 'postbox',
94 'thickbox',
95 'framework:js:hash:{CJT-}md5',
96 'framework:js:cookies:{CJT-}jquery.cookies.2.2.0',
97 'framework:js:ajax:{CJT-}cjt-server',
98 'framework:js:ajax:{CJT-}cjt-server-queue',
99 'framework:js:ui:{CJT-}jquery.toolbox',
100 'framework:js:ace(loadMethod=Tag, lookFor=ace)',
101 'framework:js:ace:{CJT-}pluggable',
102 'views:blocks:block:public:js:{CJT-}ajax',
103 'views:blocks:block:public:js:{CJT-}blockproperty',
104 'views:blocks:block:public:js:optional:{CJT-}revision',
105 'views:blocks:block:public:js:{CJT-}codefile-manager',
106 'views:blocks:block:public:js:{CJT-}codefile',
107 'views:blocks:block:public:js:{CJT-}block',
108 'views:blocks:block:public:js:plugins:{CJT-}_dockmodule',
109 'views:blocks:block:public:js:{CJT-}jquery.block'
110 );
111 }
112
113 /**
114 * put your comment there...
115 *
116 */
117 public static function enqueueStyles() {
118 // Initialize style.
119 $styles = array(
120 'thickbox',
121 'views:blocks:block:public:css:{CJT-}block',
122 'views:blocks:block:public:css:{CJT-}codefile'
123 );
124 // IF WP < 3.8 add compatibility CSS file.
125 $wpVersion = new CJT_Framework_Wordpress_Currentversion();
126 if ($wpVersion->isLess('3.8')) {
127 $styles[] = 'views:blocks:block:public:css:{CJT-}block-wp-lt-3.8';
128 }
129 // Include styles.
130 self::useStyles(__CLASS__, $styles);
131 }
132
133 /**
134 * put your comment there...
135 *
136 * @param mixed $block
137 */
138 public function getAllAssignments() {
139
140 return CJTBlocksModel::getAllAssignments($this->block);
141 }
142
143 /**
144 * put your comment there...
145 *
146 */
147 public function getBlock() {
148 return $this->block;
149 }
150
151 /**
152 * put your comment there...
153 *
154 */
155 public function getHookStatus() {
156
157 $hooksAttacher =& CJTBlocksCouplingController::theInstance()->getHooksAttacher();
158
159 $locationText = $hooksAttacher->getHookText($this->block->location);
160 $locationTitle = $hooksAttacher->getHookText($this->block->location, 'title');
161 $badLocationClass = '';
162
163 if(!$locationText) {
164
165 $badLocationClass = 'bad-location-specified';
166 $locationText = cssJSToolbox::getText('Hook is not supported, it might be assigned by some kind of CJT hooks extensions. You either need to re-enable/re-install that extension or change the hook value to one of the supported hooks');
167 }
168
169 $text = compact('badLocationClass', 'locationText', 'locationTitle');
170
171 return $text;
172 }
173
174 /**
175 * put your comment there...
176 *
177 */
178 public function getMetaboxName() {
179 $tip = cssJSToolbox::getText('Click to update Block name');
180 return "<input name='cjtoolbox[{$this->block->id}][name]' type='text' class='block-name' value='{$this->block->name}' title='{$tip}' maxlength='50' />";
181 }
182
183 /**
184 * put your comment there...
185 *
186 * @param mixed $id
187 */
188 public function getMetaboxId() {
189 return self::META_BOX_PREFIX ."-{$this->block->id}";
190 }
191
192 /**
193 * put your comment there...
194 *
195 * @param mixed $name
196 */
197 public function getOption($name) {
198 return $this->params->{$name};
199 }
200
201 /**
202 *
203 *
204 */
205 public function setBlock($block) {
206 // Set block.
207 $this->block = $block;
208 // Get block state (opened/closes)
209 $closedBlockId = "cjtoolbox-{$this->block->id}";
210 $closedMetaboxes = get_user_meta(get_current_user_id(), 'closedpostboxes_cjtoolbox', true);
211 $this->isClosed = in_array($closedBlockId, ((array) $closedMetaboxes));
212 }
213
214 /**
215 * put your comment there...
216 *
217 * @param mixed $name
218 * @param mixed $value
219 */
220 public function setOption($name, $value) {
221 $this->params->{$name} = $value;
222 // Chains!
223 return $this;
224 }
225
226 } // End class.
227
228 // Hookable!
229 CJTBlocksBlockView::define('CJTBlocksBlockView');