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

192 lines 4.1 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 'jquery-ui-menu',
85 'common',
86 'wp-lists',
87 'postbox',
88 'thickbox',
89 'framework:js:hash:{CJT-}md5',
90 'framework:js:cookies:{CJT-}jquery.cookies.2.2.0',
91 'framework:js:ajax:{CJT-}cjt-server',
92 'framework:js:ajax:{CJT-}cjt-server-queue',
93 'framework:js:ui:{CJT-}jquery.toolbox',
94 'framework:js:ace(loadMethod=Tag, lookFor=ace)',
95 'framework:js:ace:{CJT-}pluggable',
96 'views:blocks:block:public:js:{CJT-}ajax',
97 'views:blocks:block:public:js:{CJT-}blockproperty',
98 'views:blocks:block:public:js:optional:{CJT-}revision',
99 'views:blocks:block:public:js:{CJT-}menu',
100 'views:blocks:block:public:js:menu:{CJT-}_block',
101 'views:blocks:block:public:js:{CJT-}codefile-manager',
102 'views:blocks:block:public:js:{CJT-}codefile',
103 'views:blocks:block:public:js:{CJT-}block',
104 'views:blocks:block:public:js:{CJT-}jquery.block'
105 );
106 }
107
108 /**
109 * put your comment there...
110 *
111 */
112 public static function enqueueStyles() {
113 // Initialize style.
114 $styles = array(
115 'thickbox',
116 'views:blocks:block:public:css:{CJT-}block',
117 'views:blocks:block:public:css:{CJT-}menu',
118 'views:blocks:block:public:css:{CJT-}codefile'
119 );
120 // IF WP < 3.8 add compatibility CSS file.
121 $wpVersion = new CJT_Framework_Wordpress_Currentversion();
122 if ($wpVersion->isLess('3.8')) {
123 $styles[] = 'views:blocks:block:public:css:{CJT-}block-wp-lt-3.8';
124 }
125 // Include styles.
126 self::useStyles(__CLASS__, $styles);
127 }
128
129 /**
130 * put your comment there...
131 *
132 */
133 public function getBlock() {
134 return $this->block;
135 }
136
137 /**
138 * put your comment there...
139 *
140 */
141 public function getMetaboxName() {
142 $tip = cssJSToolbox::getText('Click to update Block name');
143 return "<span class='block-name' title='{$tip}'>{$this->block->name}</span>";
144 }
145
146 /**
147 * put your comment there...
148 *
149 * @param mixed $id
150 */
151 public function getMetaboxId() {
152 return self::META_BOX_PREFIX ."-{$this->block->id}";
153 }
154
155 /**
156 * put your comment there...
157 *
158 * @param mixed $name
159 */
160 public function getOption($name) {
161 return $this->params->{$name};
162 }
163
164 /**
165 *
166 *
167 */
168 public function setBlock($block) {
169 // Set block.
170 $this->block = $block;
171 // Get block state (opened/closes)
172 $closedBlockId = "cjtoolbox-{$this->block->id}";
173 $closedMetaboxes = get_user_meta(get_current_user_id(), 'closedpostboxes_cjtoolbox', true);
174 $this->isClosed = in_array($closedBlockId, ((array) $closedMetaboxes));
175 }
176
177 /**
178 * put your comment there...
179 *
180 * @param mixed $name
181 * @param mixed $value
182 */
183 public function setOption($name, $value) {
184 $this->params->{$name} = $value;
185 // Chains!
186 return $this;
187 }
188
189 } // End class.
190
191 // Hookable!
192 CJTBlocksBlockView::define('CJTBlocksBlockView');