PluginProbe
CSS & JavaScript Toolbox / 10.1
CSS & JavaScript Toolbox v10.1
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 10.1, at views/blocks/block/view.php

189 lines 4.0 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 $params = array();
44
45 /**
46 * put your comment there...
47 *
48 * @var mixed
49 */
50 public $templateName = 'edit';
51
52 /**
53 * put your comment there...
54 *
55 */
56 public function __construct($viewInfo) {
57 parent::__construct($viewInfo);
58 // Enqueue Styles & Scripts.
59 add_action('admin_print_styles', array(__CLASS__, 'enqueueStyles'));
60 add_action('admin_print_scripts', array(__CLASS__, 'enqueueScripts'));
61 // Cast params to object
62 $this->params = (object) $this->params;
63 // Load localization text.
64 $this->localization = require($this->getPath('public/js/jquery.block/jquery.block.localization.php'));
65 }
66
67 /**
68 * put your comment there...
69 *
70 */
71 public function display($template = null) {
72 // Import template.
73 echo $this->getTemplate($template ? $template : $this->templateName);
74 }
75
76 /**
77 * put your comment there...
78 *
79 */
80 public static function enqueueScripts() {
81 // Use related scripts.
82 self::useScripts(__CLASS__,
83 'jquery',
84 'common',
85 'wp-lists',
86 'postbox',
87 'thickbox',
88 'framework:js:hash:{CJT-}md5',
89 'framework:js:cookies:{CJT-}jquery.cookies.2.2.0',
90 'framework:js:ajax:{CJT-}cjt-server',
91 'framework:js:ajax:{CJT-}cjt-server-queue',
92 'framework:js:ui:{CJT-}jquery.toolbox',
93 'framework:js:ace(loadMethod=Tag, lookFor=ace)',
94 'framework:js:ace:{CJT-}pluggable',
95 'views:blocks:block:public:js:{CJT-}ajax',
96 'views:blocks:block:public:js:{CJT-}blockproperty',
97 'views:blocks:block:public:js:optional:{CJT-}revision',
98 'views:blocks:block:public:js:{CJT-}codefile-manager',
99 'views:blocks:block:public:js:{CJT-}codefile',
100 'views:blocks:block:public:js:{CJT-}block',
101 'views:blocks:block:public:js:plugins:{CJT-}_dockmodule',
102 'views:blocks:block:public:js:{CJT-}jquery.block'
103 );
104 }
105
106 /**
107 * put your comment there...
108 *
109 */
110 public static function enqueueStyles() {
111 // Initialize style.
112 $styles = array(
113 'thickbox',
114 'views:blocks:block:public:css:{CJT-}block',
115 'views:blocks:block:public:css:{CJT-}codefile'
116 );
117 // IF WP < 3.8 add compatibility CSS file.
118 $wpVersion = new CJT_Framework_Wordpress_Currentversion();
119 if ($wpVersion->isLess('3.8')) {
120 $styles[] = 'views:blocks:block:public:css:{CJT-}block-wp-lt-3.8';
121 }
122 // Include styles.
123 self::useStyles(__CLASS__, $styles);
124 }
125
126 /**
127 * put your comment there...
128 *
129 */
130 public function getBlock() {
131 return $this->block;
132 }
133
134 /**
135 * put your comment there...
136 *
137 */
138 public function getMetaboxName() {
139 $tip = cssJSToolbox::getText('Click to update Block name');
140 return "<span class='block-name' title='{$tip}'>{$this->block->name}</span>";
141 }
142
143 /**
144 * put your comment there...
145 *
146 * @param mixed $id
147 */
148 public function getMetaboxId() {
149 return self::META_BOX_PREFIX ."-{$this->block->id}";
150 }
151
152 /**
153 * put your comment there...
154 *
155 * @param mixed $name
156 */
157 public function getOption($name) {
158 return $this->params->{$name};
159 }
160
161 /**
162 *
163 *
164 */
165 public function setBlock($block) {
166 // Set block.
167 $this->block = $block;
168 // Get block state (opened/closes)
169 $closedBlockId = "cjtoolbox-{$this->block->id}";
170 $closedMetaboxes = get_user_meta(get_current_user_id(), 'closedpostboxes_cjtoolbox', true);
171 $this->isClosed = in_array($closedBlockId, ((array) $closedMetaboxes));
172 }
173
174 /**
175 * put your comment there...
176 *
177 * @param mixed $name
178 * @param mixed $value
179 */
180 public function setOption($name, $value) {
181 $this->params->{$name} = $value;
182 // Chains!
183 return $this;
184 }
185
186 } // End class.
187
188 // Hookable!
189 CJTBlocksBlockView::define('CJTBlocksBlockView');