PluginProbe
CSS & JavaScript Toolbox / 11.8
CSS & JavaScript Toolbox v11.8
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 | tables/blocks.php +29 -16 1111.8 View file →
@@ -11,31 +11,31 @@
11 11 // CJTTable class.
12 12 require_once CJTOOLBOX_FRAMEWORK . '/db/mysql/table.inc.php';
13 13
14 14 /**
15 -*
15 +*
16 16 * @deprecated Use CJTBlockTable instead!
17 17 */
18 18 class CJTBlocksTable extends CJTTable {
19 -
19 +
20 20 /** */
21 21 const BLOCK_META_BOX_ID_META_NAME = '__CJT-BLOCK-ID';
22 -
22 +
23 23 /** */
24 24 const BLOCK_META_BOX_STATUS_META_NAME = '__CJT-BLOCK-STATUS';
25 -
25 +
26 26 /**
27 27 * put your comment there...
28 - *
28 + *
29 29 */
30 30 public function __construct(&$dbDriver) {
31 31 // Inirialize parent class.
32 32 parent::__construct($dbDriver, cssJSToolbox::$config->database->tables->blocks);
33 33 }
34 -
34 +
35 35 /**
36 36 * put your comment there...
37 - *
37 + *
38 38 * @param mixed $ids
39 39 */
40 40 public function delete($ids = array()) {
41 41 $where = '';
@@ -44,12 +44,12 @@
44 44 }
45 45 $query = "DELETE FROM {$this->table}{$where};";
46 46 $this->dbDriver->delete($query);
47 47 }
48 -
48 +
49 49 /**
50 50 * put your comment there...
51 - *
51 + *
52 52 * @param mixed $ids
53 53 * @param mixed $fields
54 54 * @param mixed $filters
55 55 * @deprecated @param mixed $returnType
@@ -103,9 +103,22 @@
103 103 $blocks[$block->id] = $block;
104 104 }
105 105 return $blocks;
106 106 }
107 -
107 +
108 + public function getNextIdNEW($offset = 0)
109 + {
110 + // Get post meta table name.
111 + $blocksTable = $this->dbDriver->getTableName('cjtoolbox_blocks');
112 +
113 + // Get all reserved blocks/metaboxes id associated with posts.
114 + $postMetaName = self::BLOCK_META_BOX_ID_META_NAME;
115 + $query = "SELECT id FROM {$blocksTable} ORDER BY id DESC LIMIT 1;";
116 + // Get all ids.
117 + $currentID = current( array_keys( $this->dbDriver->select($query) ) );
118 +
119 + return $currentID + 1;
120 + }
108 121 /**
109 122 * Override Parent::getNextId().
110 123 */
111 124 public function getNextId($offset = 0) {
@@ -116,9 +129,9 @@
116 129 $query = "SELECT meta_value as `value`
117 130 FROM {$postMetaTable}
118 131 WHERE meta_key = '{$postMetaName}';";
119 132 // Get all ids.
120 - $reservedIds = array_keys($this->dbDriver->select($query, OBJECT_K));
133 + $reservedIds = array_keys($this->dbDriver->select($query, OBJECT_K));
121 134 // Find a unique Id for the new block.
122 135 do {
123 136 // Increase by one until finding new unique id.
124 137 $nextId = parent::getNextId($offset++);
@@ -125,12 +138,12 @@
125 138 } while(in_array($nextId, $reservedIds));
126 139 // Return new id.
127 140 return $nextId;
128 141 }
129 -
142 +
130 143 /**
131 144 * put your comment there...
132 - *
145 + *
133 146 */
134 147 public function insert($data) {
135 148 // Prepare New Record data.
136 149 $data = $this->prepareQueryParameters($data);
@@ -138,12 +151,12 @@
138 151 // Insert statement.
139 152 $query = "INSERT INTO {$this->table} SET {$data};";
140 153 $this->dbDriver->insert($query);
141 154 }
142 -
155 +
143 156 /**
144 157 * put your comment there...
145 - *
158 + *
146 159 * @param mixed $data
147 160 */
148 161 public function update($block) {
149 162 // Get block id copy.
@@ -159,6 +172,6 @@
159 172 $this->dbDriver->update($query);
160 173 }
161 174 return $this;
162 175 }
163 -
176 +
164 177 } // End class.