PluginProbe
CSS & JavaScript Toolbox / 6.0
CSS & JavaScript Toolbox v6.0
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 +21 -36 trunk6.0 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
@@ -54,9 +54,9 @@
54 54 * @param mixed $filters
55 55 * @deprecated @param mixed $returnType
56 56 * @param mixed $orderBy
57 57 */
58 - public function get($ids = array(), $fields = array('*'), $filters = array(), $returnType = OBJECT_K, $orderBy = array(), $useDefaultBackupFltr = true) {
58 + public function get($ids = array(), $fields = array('*'), $filters = array(), $returnType = OBJECT_K, $orderBy = array()) {
59 59 // Warn if $returnTypes is used
60 60 if ($returnType != OBJECT_K) {
61 61 die('Warning! Using $returnType with value other than OBJECT_K from the caller!!!');
62 62 }
@@ -68,20 +68,18 @@
68 68 $ids = implode(',', $ids);
69 69 $where[] = " `id` IN ({$ids})";
70 70 }
71 71 // Filter by backup name.
72 - if ($useDefaultBackupFltr) {
73 - $where[] = (!isset($filters['backupId']) ? ' `backupId` IS NULL' : " `backupId` = {$filters['backupId']}");
74 - unset($filters['backupId']);
75 - }
72 + $where[] = (($filters['backupId'] == null) ? ' `backupId` IS NULL' : " `backupId` = {$filters['backupId']}");
73 + unset($filters['backupId']);
76 74 // Filter by parent.
77 - if (isset($filters['parent'])) {
75 + if ($filters['parent'] != null) {
78 76 $filters['parent'] = implode(',', ((array) $filters['parent']));
79 77 $where[] = " `parent` IN ({$filters['parent']})";
80 78 unset($filters['parent']);
81 79 }
82 80 // Types filter.
83 - if (isset($filters['types'])) {
81 + if ($filters['types']) {
84 82 $types = '"' . implode('", "', $filters['types']) . '"';
85 83 $where[] = " `type` IN ({$types})";
86 84 unset($filters['types']);
87 85 }
@@ -103,22 +101,9 @@
103 101 $blocks[$block->id] = $block;
104 102 }
105 103 return $blocks;
106 104 }
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 - }
105 +
121 106 /**
122 107 * Override Parent::getNextId().
123 108 */
124 109 public function getNextId($offset = 0) {
@@ -129,9 +114,9 @@
129 114 $query = "SELECT meta_value as `value`
130 115 FROM {$postMetaTable}
131 116 WHERE meta_key = '{$postMetaName}';";
132 117 // Get all ids.
133 - $reservedIds = array_keys($this->dbDriver->select($query, OBJECT_K));
118 + $reservedIds = array_keys($this->dbDriver->select($query, OBJECT_K));
134 119 // Find a unique Id for the new block.
135 120 do {
136 121 // Increase by one until finding new unique id.
137 122 $nextId = parent::getNextId($offset++);
@@ -138,12 +123,12 @@
138 123 } while(in_array($nextId, $reservedIds));
139 124 // Return new id.
140 125 return $nextId;
141 126 }
142 -
127 +
143 128 /**
144 129 * put your comment there...
145 - *
130 + *
146 131 */
147 132 public function insert($data) {
148 133 // Prepare New Record data.
149 134 $data = $this->prepareQueryParameters($data);
@@ -151,12 +136,12 @@
151 136 // Insert statement.
152 137 $query = "INSERT INTO {$this->table} SET {$data};";
153 138 $this->dbDriver->insert($query);
154 139 }
155 -
140 +
156 141 /**
157 142 * put your comment there...
158 - *
143 + *
159 144 * @param mixed $data
160 145 */
161 146 public function update($block) {
162 147 // Get block id copy.
@@ -172,6 +157,6 @@
172 157 $this->dbDriver->update($query);
173 158 }
174 159 return $this;
175 160 }
176 -
161 +
177 162 } // End class.