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

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

148 lines 3.3 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 public $order;
44
45 /**
46 * put your comment there...
47 *
48 * @var mixed
49 */
50 public $pageHook;
51
52 /**
53 * put your comment there...
54 *
55 * @var mixed
56 */
57 public $securityToken;
58
59 /**
60 * put your comment there...
61 *
62 */
63 public function __construct($parameters) {
64 parent::__construct($parameters);
65 // Import other dependencies views.
66 self::Import('blocks/cjt-block');
67 // register callback to show styles needed for the admin page
68 add_action('admin_print_styles', array(__CLASS__, 'enququeStyles'));
69 // Load scripts for admin panel working
70 add_action('admin_print_scripts', array(__CLASS__, 'enququeScripts'));
71 // Blocks order is common for all users, override user meta-boxes order
72 // by meta-box-order site option.
73 add_filter('get_user_option_meta-box-order_cjtoolbox', array(&$this, 'getBlocksOrder'));
74 }
75
76 /**
77 * put your comment there...
78 *
79 */
80 public function display() {
81 // Initialize view vars.
82 $this->hasBlocks = !empty($this->blocks);
83 // Add metabox for each block.
84 foreach ($this->blocks as $block) {
85 $block = new CJTBlockModel($block);
86 // Create cjt-block view.
87 $view = self::create('blocks/cjt-block');
88 $blockView =& $view->getBlockView();
89 // Initialize block view.
90 $blockView->setBlock($block);
91 // Add metabox
92 add_meta_box($blockView->getMetaboxId(), $blockView->getMetaboxName(), array($view, 'display'), $this->pageHook, 'normal', 'core');
93 }
94 // Display the view.
95 echo $this->getTemplate('blocks');
96 }
97
98 /**
99 * put your comment there...
100 *
101 * As result of do_meta_boxes this filter will be called.
102 *
103 * Callback for apply_filters("get_user_option_{$option}", $result, $option, $user).
104 *
105 */
106 public function getBlocksOrder() {
107 return $this->order;
108 }
109
110 /**
111 * Enqueue scripts.
112 *
113 * Callback for admin_print_scripts-[$hook_manage].
114 */
115 public static function enququeScripts() {
116 // Enquque single block scripts.
117 CJTBlocksCjtBlockView::enqueueScripts();
118 // Use blocks page scripts.
119 self::useScripts(__CLASS__,
120 'views:blocks:manager:public:js:{CJT-}blocks',
121 'views:blocks:manager:public:js:{CJT-}blocks-page',
122 'views:blocks:manager:public:js:{CJT-}ajax-multioperation'
123 );
124 }
125
126 /**
127 * Enqueue styles.
128 *
129 * Callback for admin_print_styles-[$hook_manage].
130 */
131 public static function enququeStyles() {
132 // Enquque single block styles.
133 CJTBlocksCjtBlockView::enqueueStyles();
134 // Styles list.
135 $styles = array('framework:css:{CJT-}toolbox', 'views:blocks:manager:public:css:{CJT-}blocks');
136 // IF WP < 3.8 add compatibility CSS file.
137 $wpVersion = new CJT_Framework_Wordpress_Currentversion();
138 if ($wpVersion->isLess('3.8')) {
139 $styles[] = 'views:blocks:manager:public:css:{CJT-}blocks-wp-lt-3.8';
140 }
141 // Include styles.
142 self::useStyles(__CLASS__, $styles);
143 }
144
145 } // End class.
146
147 // Hookable!!
148 CJTBlocksManagerView::define('CJTBlocksManagerView');