PluginProbe
CSS & JavaScript Toolbox / 7.2
CSS & JavaScript Toolbox v7.2
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
← All changes | models/metabox.php +29 -29 11.87.2 View file →
@@ -1,7 +1,7 @@
1 1 <?php
2 2 /**
3 -*
3 +*
4 4 */
5 5
6 6 // No direct access allowed.
7 7 defined('ABSPATH') or die("Access denied");
@@ -9,35 +9,35 @@
9 9 // Import dependencies.
10 10 cssJSToolbox::import('tables:blocks.php');
11 11
12 12 /**
13 -*
13 +*
14 14 */
15 15 class CJTMetaboxModel {
16 -
16 +
17 17 /** */
18 18 const STATE_CREATED = 'created';
19 19
20 20 /** */
21 21 const STATE_DELETED = 'deleted';
22 -
22 +
23 23 /**
24 24 * put your comment there...
25 - *
25 + *
26 26 * @var mixed
27 27 */
28 28 private $dbDriver = null;
29 -
29 +
30 30 /**
31 31 * put your comment there...
32 - *
32 + *
33 33 * @var mixed
34 34 */
35 35 protected $post = null;
36 -
36 +
37 37 /**
38 38 * put your comment there...
39 - *
39 + *
40 40 * @param mixed $post
41 41 * @return CJTPostModel
42 42 */
43 43 public function __construct($params) {
@@ -47,12 +47,12 @@
47 47 cssJSToolbox::import('framework:db:mysql:queue-driver.inc.php', 'framework:db:mysql:table.inc.php');
48 48 // Instantiate MYSQL DB Driver object.
49 49 $this->dbDriver = new CJTMYSQLQueueDriver($GLOBALS['wpdb']);
50 50 }
51 -
51 +
52 52 /**
53 53 * put your comment there...
54 - *
54 + *
55 55 * @param mixed $blockId
56 56 */
57 57 public function create(& $pin = null) {
58 58 // Import dependecnes.
@@ -81,21 +81,21 @@
81 81 $blockPinsTable->insertRaw($this->getMetaboxId(), array($pin));
82 82 // Chains!
83 83 return $this;
84 84 }
85 -
85 +
86 86 /**
87 87 * put your comment there...
88 - *
88 + *
89 89 */
90 90 public function delete() {
91 91 return $this->setState(self::STATE_DELETED);
92 92 }
93 -
93 +
94 94 /**
95 95 * Check whether is the current post type
96 96 * can has CJT Block metabox?
97 - *
97 + *
98 98 */
99 99 public function doPost() {
100 100 // Get all post types selected by user.
101 101 $metaboxSettings = CJTModel::create('settings')->loadPage('metabox');
@@ -102,12 +102,12 @@
102 102 // Return true is post types selected, otherwise return false.
103 103 $allowedPostTypes = $metaboxSettings->postTypes;
104 104 return in_array($this->getPost()->post_type, $allowedPostTypes);
105 105 }
106 -
106 +
107 107 /**
108 108 * put your comment there...
109 - *
109 + *
110 110 */
111 111 public function getMetaboxId() {
112 112 $metaboxId = get_post_meta($this->getPost()->ID, CJTBlocksTable::BLOCK_META_BOX_ID_META_NAME, true);
113 113 // Cast Metabox to integer.
@@ -113,20 +113,20 @@
113 113 // Cast Metabox to integer.
114 114 $metaboxId = (int) $metaboxId;
115 115 return $metaboxId;
116 116 }
117 -
117 +
118 118 /**
119 119 * put your comment there...
120 - *
120 + *
121 121 */
122 122 public function getPost() {
123 - return $this->post;
123 + return $this->post;
124 124 }
125 -
125 +
126 126 /**
127 127 * put your comment there...
128 - *
128 + *
129 129 */
130 130 public function hasBlock() {
131 131 // If $postMeta seto to a blockId then it has block otherwise(0) it hasn't.
132 132 $metaboxStatus = get_post_meta($this->getPost()->ID, CJTBlocksTable::BLOCK_META_BOX_STATUS_META_NAME, true);
@@ -131,12 +131,12 @@
131 131 // If $postMeta seto to a blockId then it has block otherwise(0) it hasn't.
132 132 $metaboxStatus = get_post_meta($this->getPost()->ID, CJTBlocksTable::BLOCK_META_BOX_STATUS_META_NAME, true);
133 133 return ($metaboxStatus == self::STATE_CREATED);
134 134 }
135 -
135 +
136 136 /**
137 137 * put your comment there...
138 - *
138 + *
139 139 */
140 140 public function reservedMetaboxBlockId() {
141 141 // Reserved if only if not already taken!
142 142 if (!$reservedId = $this->getMetaboxId()) {
@@ -148,12 +148,12 @@
148 148 update_post_meta($this->getPost()->ID, CJTBlocksTable::BLOCK_META_BOX_ID_META_NAME, $reservedId);
149 149 }
150 150 return $reservedId;
151 151 }
152 -
152 +
153 153 /**
154 154 * put your comment there...
155 - *
155 + *
156 156 */
157 157 public function save() {
158 158 $this->dbDriver->processQueue();
159 159 // Chains
@@ -158,12 +158,12 @@
158 158 $this->dbDriver->processQueue();
159 159 // Chains
160 160 return $this;
161 161 }
162 -
162 +
163 163 /**
164 164 * put your comment there...
165 - *
165 + *
166 166 * @param mixed $state
167 167 */
168 168 public function setState($state) {
169 169 // Update state post meta var.
@@ -170,6 +170,6 @@
170 170 update_post_meta($this->getPost()->ID, CJTBlocksTable::BLOCK_META_BOX_STATUS_META_NAME, $state);
171 171 // Chaining!
172 172 return $this;
173 173 }
174 -
174 +
175 175 } // End class.