PluginProbe
CSS & JavaScript Toolbox / 8.0.3
CSS & JavaScript Toolbox v8.0.3
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/block.php +57 -0 6.0.118.0.3 View file →
@@ -140,8 +140,65 @@
140 140
141 141 /**
142 142 * put your comment there...
143 143 *
144 + * @param mixed $blockData
145 + */
146 + public static function arrangePins(& $blockData) {
147 + // Initialize
148 + $pinsGroupNames = array_flip(array('pages', 'posts', 'categories', 'pinPoint'));
149 + $dbDriver = cssJSToolbox::getInstance()->getDBDriver();
150 + $mdlBlock = new CJTBlocksModel();
151 + $block = $mdlBlock->getBlock($blockData->id, array(), array('id', 'pinPoint'));
152 + $submittedPins = array_intersect_key(((array) $blockData), $pinsGroupNames);
153 + $assignedPins = array_intersect_key(((array) $block), $pinsGroupNames);
154 + // Transfer assigned PinPoint from "FLAGGED INTEGER" TO "ARRAY" like
155 + // the other pins.
156 + $assignedPins['pinPoint'] = array_keys(CJT_Models_Block_Assignmentpanel_Helpers_Auxiliary
157 + ::getInstance()
158 + ->getPinsArray($assignedPins['pinPoint']));
159 + // Walk through all assigned pins.
160 + // Unassigned any item with 'value=false'.
161 + // Whenever an item is found on the submitted
162 + // pins it should be removed from the submitted list
163 + foreach ($submittedPins as $groupName => $submittedGroup) {
164 + // Get assigned pins group if found
165 + if (!isset($assignedPins[$groupName])) {
166 + // Initialize new assigned group array.
167 + $assignedPins[$groupName] = array();
168 + }
169 + // Get assigned group array reference.
170 + $assignedGroup =& $assignedPins[$groupName];
171 + // For every submitted item there is three types.
172 + // 1. Already assigned :WHEN: (sync == true and value == true)
173 + // 2. Unassigned :WHEN: (value == false)
174 + // 3. Newly assigned :WHEN: (sync = false).
175 + foreach ($submittedGroup as $submittedPinId => $submittedPin) {
176 + // Unassigned pin
177 + if (!$submittedPin['value']) {
178 + // Find the submittedPinId AssignedPins index.
179 + $assignedIndex = array_search($submittedPinId, $assignedGroup);
180 + // Unassigned it :REMOVE FROM ARRAY:
181 + unset($assignedGroup[$assignedIndex]);
182 + }
183 + else if (!$submittedPin['sync']) {
184 + // Add newly assigned item.
185 + $assignedGroup[] = $submittedPinId;
186 + }
187 + }
188 + }
189 + // Copy all assigned pins back to the block object.
190 + foreach ($assignedPins as $groupName => $finalGroupAssigns) {
191 + // Copy the group back to the block object.
192 + $blockData->{$groupName} = $finalGroupAssigns;
193 + }
194 + // Important for caller short-circle condition.
195 + return true;
196 + }
197 +
198 + /**
199 + * put your comment there...
200 + *
144 201 * @deprecated Use calculatePinpoint
145 202 */
146 203 public static function calculateBlockPinPoint(& $block) {
147 204 // Generate PinPoint Value.