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 / manager / view.php

view.php in CSS & JavaScript Toolbox 10.1, at views/blocks/manager/view.php

158 lines 3.5 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 //
7 require_once CJTOOLBOX_MODELS_PATH . '/block.php';
8
9 // Disallow direct access.
10 defined('ABSPATH') or die("Access denied");
11
12 /**
13 * Blocks view.
14 */
15 class CJTBlocksManagerView extends CJTView {
16
17 /**
18 * put your comment there...
19 *
20 * @var mixed
21 */
22 public $backupId;
23
24 /**
25 * put your comment there...
26 *
27 * @var mixed
28 */
29 public $blocks = array();
30
31 /**
32 * put your comment there...
33 *
34 * @var mixed
35 */
36 public $hasBlocks = false;
37
38 /**
39 * put your comment there...
40 *
41 * @var mixed
42 */
43 protected static $onloadglobalcomponents = array(
44 'hookType' => CJTWordpressEvents::HOOK_FILTER,
45 'parameters' => array('content')
46 );
47
48 /**
49 * put your comment there...
50 *
51 * @var mixed
52 */
53 public $order;
54
55 /**
56 * put your comment there...
57 *
58 * @var mixed
59 */
60 public $pageHook;
61
62 /**
63 * put your comment there...
64 *
65 * @var mixed
66 */
67 public $securityToken;
68
69 /**
70 * put your comment there...
71 *
72 */
73 public function __construct($parameters) {
74 parent::__construct($parameters);
75 // Import other dependencies views.
76 self::Import('blocks/cjt-block');
77 // register callback to show styles needed for the admin page
78 add_action('admin_print_styles', array(__CLASS__, 'enququeStyles'));
79 // Load scripts for admin panel working
80 add_action('admin_print_scripts', array(__CLASS__, 'enququeScripts'));
81 // Blocks order is common for all users, override user meta-boxes order
82 // by meta-box-order site option.
83 add_filter('get_user_option_meta-box-order_cjtoolbox', array(&$this, 'getBlocksOrder'));
84 }
85
86 /**
87 * put your comment there...
88 *
89 */
90 public function display() {
91 // Initialize view vars.
92 $this->hasBlocks = !empty($this->blocks);
93 // Add metabox for each block.
94 foreach ($this->blocks as $block) {
95 $block = new CJTBlockModel($block);
96 // Create cjt-block view.
97 $view = self::create('blocks/cjt-block');
98 $blockView =& $view->getBlockView();
99 // Initialize block view.
100 $blockView->setBlock($block);
101 // Add metabox
102 add_meta_box($blockView->getMetaboxId(), $blockView->getMetaboxName(), array($view, 'display'), $this->pageHook, 'normal', 'core');
103 }
104 // Display the view.
105 echo $this->getTemplate('blocks');
106 }
107
108 /**
109 * put your comment there...
110 *
111 * As result of do_meta_boxes this filter will be called.
112 *
113 * Callback for apply_filters("get_user_option_{$option}", $result, $option, $user).
114 *
115 */
116 public function getBlocksOrder() {
117 return $this->order;
118 }
119
120 /**
121 * Enqueue scripts.
122 *
123 * Callback for admin_print_scripts-[$hook_manage].
124 */
125 public static function enququeScripts() {
126 // Enquque single block scripts.
127 CJTBlocksCjtBlockView::enqueueScripts();
128 // Use blocks page scripts.
129 self::useScripts(__CLASS__,
130 'views:blocks:manager:public:js:{CJT-}blocks',
131 'views:blocks:manager:public:js:{CJT-}blocks-page',
132 'views:blocks:manager:public:js:{CJT-}ajax-multioperation'
133 );
134 }
135
136 /**
137 * Enqueue styles.
138 *
139 * Callback for admin_print_styles-[$hook_manage].
140 */
141 public static function enququeStyles() {
142 // Enquque single block styles.
143 CJTBlocksCjtBlockView::enqueueStyles();
144 // Styles list.
145 $styles = array('framework:css:{CJT-}toolbox', 'views:blocks:manager:public:css:{CJT-}blocks');
146 // IF WP < 3.8 add compatibility CSS file.
147 $wpVersion = new CJT_Framework_Wordpress_Currentversion();
148 if ($wpVersion->isLess('3.8')) {
149 $styles[] = 'views:blocks:manager:public:css:{CJT-}blocks-wp-lt-3.8';
150 }
151 // Include styles.
152 self::useStyles(__CLASS__, $styles);
153 }
154
155 } // End class.
156
157 // Hookable!!
158 CJTBlocksManagerView::define('CJTBlocksManagerView');