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 | controllers/blocks-ajax.php +40 -58 10.17.2 View file →
@@ -10,13 +10,13 @@
10 10 cssJSToolbox::import('framework:mvc:controller-ajax.inc.php');
11 11
12 12 /**
13 13 * Serve blocks page Ajax requests.
14 -*
14 +*
15 15 * The Actions resident here is global for only the blocks page, its not
16 16 * for a specific/single block. You can find single block
17 17 * actions in block-ajax.php file.
18 -*
18 +*
19 19 * @deprecated DONT ADD MORE ACTIONS HERE!
20 20 * @author Ahmed Said
21 21 * @version 6
22 22 */
@@ -23,16 +23,16 @@
23 23 class CJTBlocksAjaxController extends CJTAjaxController {
24 24
25 25 /**
26 26 * put your comment there...
27 - *
27 + *
28 28 * @var mixed
29 29 */
30 30 protected $controllerInfo = array('model' => 'blocks');
31 -
31 +
32 32 /**
33 33 * Initialize controller object.
34 - *
34 + *
35 35 * @see CJTController for more details
36 36 * @return void
37 37 */
38 38 public function __construct() {
@@ -43,25 +43,25 @@
43 43 $this->registryAction('save_blocks');
44 44 $this->registryAction('saveOrder');
45 45 $this->registryAction('loadBlock');
46 46 }
47 -
47 +
48 48 /**
49 49 * Create new block.
50 - *
50 + *
51 51 * Once this method is called a new block is saved into
52 52 * the database.
53 - *
53 + *
54 54 * Call this method using GET method with the following parameters.
55 55 * - array ids Ids for all the available blocks.
56 56 * - [name] string Block name.
57 57 * - [state] string Block state.
58 58 * - [location] string Block hook location.
59 - *
59 + *
60 60 * Response body is array with the following elements.
61 61 * - integer id New block id.
62 62 * - string view Block HTML code.
63 - *
63 + *
64 64 * @return void
65 65 */
66 66 public function createBlockAction($blockId = null, $blockType = null, $pinPoint = null, $viewName = null) {
67 67 $response = array();
@@ -95,13 +95,13 @@
95 95 require_once CJTOOLBOX_MODELS_PATH . '/block.php';
96 96 $block = new CJTBlockModel($blockData);
97 97 // Add block.
98 98 $blocksModel =& $this->model;
99 - $blockId = $blocksModel->add($block->getValues(), true);
99 + $blockId = $blocksModel->add($block->getValues());
100 100 $blocksModel->save();
101 101 // Read newly added block from database.
102 102 $newBlockData = $blocksModel->getBlock($blockId, array('returnCodeFile' => true));
103 -
103 +
104 104 if ($newBlockData === null) {
105 105 throw new Exception('Could not add new block!!!');
106 106 }
107 107 else {
@@ -112,25 +112,25 @@
112 112 // Push vars into the view.
113 113 $blockView->setBlock($block);
114 114 $response['view'] = $blockView->getTemplate('new');
115 115 }
116 - $response['id'] = $blockId;
116 + $response['id'] = $blockId;
117 117 // Set response object.
118 - $this->response = $response;
118 + $this->response = $response;
119 119 }
120 120 }
121 -
121 +
122 122 /**
123 123 * Get view content through ajax request.
124 - *
124 + *
125 125 * The method is useful for requesting Popup forms through ajax (e.g ThickBox).
126 126 * You can request any view specified in the $allowedViews array.
127 - *
127 + *
128 128 * Call this method using GET method with the following parameters.
129 129 * - viewName string Name of the view.
130 - *
130 + *
131 131 * Response body is the view content string.
132 - *
132 + *
133 133 * @return void
134 134 */
135 135 public function getViewAction() {
136 136 // Some views required objects to be pushed into it before displaying
@@ -167,9 +167,9 @@
167 167 }
168 168
169 169 /**
170 170 * put your comment there...
171 - *
171 + *
172 172 */
173 173 public function loadBlockAction() {
174 174 // Block Id.
175 175 $blockId = (int) $_GET['blockId'];
@@ -179,70 +179,52 @@
179 179 // Return View content.
180 180 $view->getTemplate('default');
181 181 $this->response = $view->structuredContent;
182 182 }
183 -
183 +
184 184 /**
185 185 * put your comment there...
186 - *
186 + *
187 187 */
188 - public function saveBlocksAction()
189 - {
188 + public function saveBlocksAction() {
190 189 $response = array();
191 -
192 190 // Blocks are sent ins single array list.
193 - $blocksToSave = filter_input( INPUT_POST, 'blocks', FILTER_UNSAFE_RAW, FILTER_REQUIRE_ARRAY );
194 - $calculatePinPoint = ( bool ) filter_input( INPUT_POST, 'calculatePinPoint', FILTER_SANITIZE_NUMBER_INT );
195 - $createRevision = ( bool ) filter_input( INPUT_POST, 'createRevision', FILTER_SANITIZE_NUMBER_INT );
196 -
197 - // For any reason that cause Client/JavaScript to send empty blocks,
191 + $blocksToSave = filter_input(INPUT_POST, 'blocks', FILTER_UNSAFE_RAW, FILTER_REQUIRE_ARRAY);
192 + $calculatePinPoint = (bool) filter_input(INPUT_POST, 'calculatePinPoint', FILTER_SANITIZE_NUMBER_INT);
193 + $createRevision = (bool) filter_input(INPUT_POST, 'createRevision', FILTER_SANITIZE_NUMBER_INT);
194 + // For any reason that cause Client/Javascript to send empty blocks,
198 195 // make sure we're save.
199 - if ( is_array( $blocksToSave ) && ! empty( $blocksToSave ) )
200 - {
201 -
202 - foreach ( $blocksToSave as $id => $postedblockPartialData )
203 - {
196 + if (is_array($blocksToSave) && !empty($blocksToSave)) {
197 + foreach ($blocksToSave as $id => $postedblockPartialData) {
204 198 // Push block id into block data.
205 - $blockData = ( object ) $postedblockPartialData;
199 + $blockData = (object) $postedblockPartialData;
206 200 $blockData->id = $id;
207 -
208 201 // Recalculate pinPoint field value.
209 - ! $calculatePinPoint or ( CJTBlockModel::arrangePins( $blockData ) && CJTBlockModel::calculateBlockPinPoint( $blockData ) );
210 -
202 + !$calculatePinPoint or (CJTBlockModel::arrangePins($blockData) && CJTBlockModel::calculateBlockPinPoint($blockData));
211 203 // Create block revision.
212 - ! $createRevision or $this->model->addRevision( $id, $blockData->activeFileId );
213 -
204 + !$createRevision or $this->model->addRevision($id, $blockData->activeFileId);
214 205 // Set lastModified field to current time.
215 - $blockData->lastModified = current_time( 'mysql' );
216 -
206 + $blockData->lastModified = current_time('mysql');
217 207 // Update database.
218 - $this->model->update( $blockData, $calculatePinPoint );
208 + $this->model->update($blockData, $calculatePinPoint);
219 209 $this->model->save();
220 -
221 210 // Send the changes properties back to client.
222 - foreach ( $postedblockPartialData as $property => $value )
223 - {
224 - $response[ $id ][ $property ][ 'value' ] = $value;
211 + foreach ($postedblockPartialData as $property => $value) {
212 + $response[$id][$property]['value'] = $value;
225 213 }
226 -
227 214 }
228 -
229 215 }
230 -
231 216 // Delete other blocks.
232 - empty( $_POST[ 'deletedBlocks' ] ) or $this->model->delete( $_POST[ 'deletedBlocks' ] );
233 -
217 + empty($_POST['deletedBlocks']) or $this->model->delete($_POST['deletedBlocks']);
234 218 // Save changes.
235 219 $this->model->save();
236 -
237 220 // Set response.
238 221 $this->response = $response;
239 -
240 222 }
241 -
223 +
242 224 /**
243 225 * put your comment there...
244 - *
226 + *
245 227 */
246 228 public function saveOrderAction() {
247 229 // Read order.
248 230 $order = array('normal' => $_GET['order']);
@@ -249,6 +231,6 @@
249 231 // Centralized orders to be shared between all users!
250 232 $this->model->setOrder($order);
251 233 $this->response = array('order' => $order, 'state' => 'saved');
252 234 }
253 -
235 +
254 236 } // End class.