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 | controllers/blocks-coupling.php +154 -315 108.0.3 View file →
@@ -1,28 +1,28 @@
1 1 <?php
2 2 /**
3 3 * @version $ Id; blocks-coupling.php 21-03-2012 03:22:10 Ahmed Said $
4 4 */
5 -
5 +
6 6 // Disallow direct access.
7 7 defined('ABSPATH') or die("Access denied");
8 8
9 9 /**
10 10 * Applying Code blocks for the curren request.
11 -*
11 +*
12 12 * This controller is always loaded.
13 -*
13 +*
14 14 * The class resposibility is to output the code blocks
15 15 * tha associated with current request.
16 -*
16 +*
17 17 * @author Ahmed Said
18 18 * @version 6
19 19 */
20 20 class CJTBlocksCouplingController extends CJTController {
21 -
21 +
22 22 /**
23 23 * put your comment there...
24 - *
24 + *
25 25 * @var mixed
26 26 */
27 27 protected $blocks = array(
28 28 'code' => array('header' => '', 'footer' => ''),
@@ -27,40 +27,40 @@
27 27 protected $blocks = array(
28 28 'code' => array('header' => '', 'footer' => ''),
29 29 'scripts' => array('header' => array(), 'footer' => array()),
30 30 );
31 -
31 +
32 32 /**
33 33 * put your comment there...
34 - *
34 + *
35 35 * @var mixed
36 36 */
37 37 protected $controllerInfo = array('model' => 'coupling');
38 -
38 +
39 39 /**
40 40 * put your comment there...
41 - *
41 + *
42 42 * @var mixed
43 43 */
44 44 protected $filters = null;
45 -
45 +
46 46 /**
47 47 * put your comment there...
48 - *
48 + *
49 49 * @var mixed
50 50 */
51 51 protected static $instance = null;
52 -
52 +
53 53 /**
54 54 * put your comment there...
55 - *
55 + *
56 56 * @var mixed
57 57 */
58 58 private $onActionIds = array();
59 -
59 +
60 60 /**
61 61 * put your comment there...
62 - *
62 + *
63 63 * @var mixed
64 64 */
65 65 protected $onassigncouplingcallback = array('parameters' => array('callback'));
66 66
@@ -65,44 +65,44 @@
65 65 protected $onassigncouplingcallback = array('parameters' => array('callback'));
66 66
67 67 /**
68 68 * put your comment there...
69 - *
69 + *
70 70 * @var mixed
71 71 */
72 72 protected $onappendcode = array('parameters' => array('code'));
73 -
73 +
74 74 /**
75 75 * put your comment there...
76 - *
76 + *
77 77 * @var mixed
78 78 */
79 79 protected $onblockmatched = array('parameters' => array('block'));
80 -
80 +
81 81 /**
82 82 * put your comment there...
83 - *
83 + *
84 84 * @var mixed
85 85 */
86 86 protected $oncancelmatching = array('parameters' => array('matched'));
87 -
87 +
88 88 /**
89 89 * put your comment there...
90 - *
90 + *
91 91 * @var mixed
92 92 */
93 93 protected $ondefaultfilters = array('parameters' => array('filters'));
94 -
94 +
95 95 /**
96 96 * put your comment there...
97 - *
97 + *
98 98 * @var mixed
99 99 */
100 100 protected $ondo = array('parameters' => array('data', 'method', 'condition'));
101 -
101 +
102 102 /**
103 103 * put your comment there...
104 - *
104 + *
105 105 * @var mixed
106 106 */
107 107 protected $onblocksorder = array('parameters' => array('order'));
108 108
@@ -107,23 +107,16 @@
107 107 protected $onblocksorder = array('parameters' => array('order'));
108 108
109 109 /**
110 110 * put your comment there...
111 - *
111 + *
112 112 * @var mixed
113 113 */
114 - protected $onevalcodeblock = array( 'parameters' => array( 'keep', 'block' ) );
115 -
116 - /**
117 - * put your comment there...
118 - *
119 - * @var mixed
120 - */
121 114 protected $ongetblocks = array('parameters' => array('blocks'));
122 115
123 116 /**
124 117 * put your comment there...
125 - *
118 + *
126 119 * @var mixed
127 120 */
128 121 protected $ongetcache = array('parameters' => array('cache'));
129 122
@@ -128,23 +121,23 @@
128 121 protected $ongetcache = array('parameters' => array('cache'));
129 122
130 123 /**
131 124 * put your comment there...
132 - *
125 + *
133 126 * @var mixed
134 127 */
135 128 protected $ongetfilters = array('parameters' => array('filters'));
136 -
129 +
137 130 /**
138 131 * put your comment there...
139 - *
132 + *
140 133 * @var mixed
141 134 */
142 135 protected $onlinkedtemplates = array('parameters' => array('templates'));
143 -
136 +
144 137 /**
145 138 * put your comment there...
146 - *
139 + *
147 140 * @var mixed
148 141 */
149 142 protected $onlinkscripts = array('parameters' => array('templates'));
150 143
@@ -149,23 +142,23 @@
149 142 protected $onlinkscripts = array('parameters' => array('templates'));
150 143
151 144 /**
152 145 * put your comment there...
153 - *
146 + *
154 147 * @var mixed
155 148 */
156 149 protected $onlinkstyles = array('parameters' => array('templates'));
157 -
150 +
158 151 /**
159 152 * put your comment there...
160 - *
153 + *
161 154 * @var mixed
162 155 */
163 156 protected $onlinktemplate = array('parameters' => array('template'));
164 -
157 +
165 158 /**
166 159 * put your comment there...
167 - *
160 + *
168 161 * @var mixed
169 162 */
170 163 protected $onmatchingurls = array('parameters' => array('urls'));
171 164
@@ -170,9 +163,9 @@
170 163 protected $onmatchingurls = array('parameters' => array('urls'));
171 164
172 165 /**
173 166 * put your comment there...
174 - *
167 + *
175 168 * @var mixed
176 169 */
177 170 protected $onnoblocks = array('hookType' => CJTWordpressEvents::HOOK_ACTION);
178 171
@@ -177,16 +170,16 @@
177 170 protected $onnoblocks = array('hookType' => CJTWordpressEvents::HOOK_ACTION);
178 171
179 172 /**
180 173 * put your comment there...
181 - *
174 + *
182 175 * @var mixed
183 176 */
184 177 protected $onoutput = array('parameters' => array('code', 'location'));
185 -
178 +
186 179 /**
187 180 * put your comment there...
188 - *
181 + *
189 182 * @var mixed
190 183 */
191 184 protected $onprocess = array('hookType' => CJTWordpressEvents::HOOK_ACTION);
192 185
@@ -191,44 +184,44 @@
191 184 protected $onprocess = array('hookType' => CJTWordpressEvents::HOOK_ACTION);
192 185
193 186 /**
194 187 * put your comment there...
195 - *
188 + *
196 189 * @var mixed
197 190 */
198 191 protected $onprocessblock = array('parameters' => array('block'));
199 -
192 +
200 193 /**
201 194 * put your comment there...
202 - *
195 + *
203 196 * @var mixed
204 197 */
205 198 protected $onqueuecss = array('parameters' => array('style'));
206 -
199 +
207 200 /**
208 201 * put your comment there...
209 - *
202 + *
210 203 * @var mixed
211 204 */
212 205 protected $onqueuejavascript = array('parameters' => array('script'));
213 -
206 +
214 207 /**
215 208 * put your comment there...
216 - *
209 + *
217 210 * @var mixed
218 211 */
219 212 protected $onsetfilters = array('parameters' => array('filters'));
220 -
213 +
221 214 /**
222 215 * put your comment there...
223 - *
216 + *
224 217 * @var mixed
225 218 */
226 219 protected $templates = array();
227 -
220 +
228 221 /**
229 222 * Initialize controller object.
230 - *
223 + *
231 224 * @see CJTController for more details
232 225 * @return void
233 226 */
234 227 public function __construct() {
@@ -251,18 +244,18 @@
251 244 add_action($siteHook->tag, $initCouplingCallback, $siteHook->priority);
252 245 // Add Shortcode callbacks.
253 246 add_shortcode('cjtoolbox', array(&$this, 'shortcode'));
254 247 }
255 -
248 +
256 249 /**
257 250 * put your comment there...
258 - *
251 + *
259 252 * @param mixed $id
260 253 */
261 254 public function addOnActionIds($id) {
262 255 // Add ID is not exists.
263 256 if (!in_array($id, $this->onActionIds)) {
264 - $this->onActionIds[] = $id;
257 + $this->onActionIds[] = $id;
265 258 }
266 259 // Chaining.
267 260 return $this;
268 261 }
@@ -268,85 +261,52 @@
268 261 }
269 262
270 263 /**
271 264 * put your comment there...
272 - *
265 + *
273 266 */
274 - public function getBlocks()
275 - {
267 + public function getBlocks() {
276 268 // Set request view filters used for querying database.
277 269 $this->setRequestFilters();
278 -
279 270 // Get blocks order. NOTE: This is all blocks order not only the queried/target blocks.
280 271 $blocksOrder = array();
281 - $metaBoxesOrder = $this->onblocksorder( $this->model->getOrder() );
282 -
272 + $metaBoxesOrder = $this->onblocksorder($this->model->getOrder());
283 273 // Get ORDER-INDEX <TO> BLOCK-ID mapping.
284 - preg_match_all( '/cjtoolbox-(\d+)/', $metaBoxesOrder[ 'normal' ], $blocksOrder, PREG_SET_ORDER );
285 -
274 + preg_match_all('/cjtoolbox-(\d+)/', $metaBoxesOrder['normal'], $blocksOrder, PREG_SET_ORDER);
286 275 /**
287 276 * append more to orders produced by CJTBlocksCouplingController::setRequestFilter().
288 277 * More to orders may allow other blocks to bein the output (e.g metaboxe blocks).
289 278 */
290 - $blocksOrder = array_merge( $blocksOrder, $this->getFilters()->moreToOrder );
291 -
279 + $blocksOrder = array_merge($blocksOrder, $this->getFilters()->moreToOrder);
292 280 // Prepare request URL to match against Links & Expressions.
293 281 $linksRequestURL = self::getRequestURL();
294 282 $expressionsRequestURL = "{$linksRequestURL}?{$_SERVER['QUERY_STRING']}";
295 -
296 - extract( $this->onmatchingurls( compact( 'linksRequestURL', 'expressionsRequestURL' ) ) );
297 -
283 + extract($this->onmatchingurls(compact('linksRequestURL', 'expressionsRequestURL')));
298 284 // Get all blocks including (Links & Expressions Blocks).
299 - $blocks = $this->ongetblocks(
300 -
301 - $this->model->getPinsBlocks(
302 -
303 - CJTBlockModel::PINS_LINK_EXPRESSION,
304 -
305 - $this->getFilters()->pinPoint,
306 -
307 - $this->getFilters()->customPins,
308 -
309 - $this->getFilters()
310 -
311 - )
312 -
313 - );
314 -
315 -
316 - if ( empty( $blocks ) )
317 - {
285 + $blocks = $this->ongetblocks($this->model->getPinsBlocks(CJTBlockModel::PINS_LINK_EXPRESSION,
286 + $this->getFilters()->pinPoint,
287 + $this->getFilters()->customPins));
288 + if (empty($blocks)) {
318 289 $this->onnoblocks();
319 -
320 290 return false;
321 -
322 291 }
323 -
324 292 // Import related libraries.
325 - cssJSToolbox::import( 'framework:php:evaluator:evaluator.inc.php' );
326 -
293 + cssJSToolbox::import('framework:php:evaluator:evaluator.inc.php');
327 294 /**
328 295 * Iterator over all blocks by using they order.
329 296 * For each block get code and scripts.
330 297 */
331 298 $this->onprocess();
332 -
333 - foreach ( $blocksOrder as $blockOrder )
334 - {
299 + foreach ($blocksOrder as $blockOrder) {
335 300 $blockId = (int) $blockOrder[1];
336 -
337 301 // As mentioned above. Orders is for all blocks not just those queried from db.
338 - if ( isset($blocks[ $blockId ] ) )
339 - {
340 -
341 - $block = $this->onprocessblock( $blocks[ $blockId ] );
342 -
302 + if (isset($blocks[$blockId])) {
303 + $block = $this->onprocessblock($blocks[$blockId]);
343 304 /**
344 305 * Process Links & Expressions blocks.
345 306 * For better performace check only those with links and expressions flags.
346 307 */
347 - if ( $block->blocksGroup & CJTBlockModel::PINS_LINK_EXPRESSION )
348 - {
308 + if ($block->blocksGroup & CJTBlockModel::PINS_LINK_EXPRESSION) {
349 309 /**
350 310 * Initiliaze $matchedLink and $matchedExpression inside IF statment.
351 311 * Those variables need to refresh state at each block.
352 312 * If there is no link or expression flags, they will be FALSE.
@@ -352,120 +312,79 @@
352 312 * If there is no link or expression flags, they will be FALSE.
353 313 * Otherwise they'll get the correct value inside each statement.
354 314 */
355 315 /// Check if there is a matched link.
356 - if ( $matchedLink = ( $block->blocksGroup & CJTBlockModel::PINS_LINKS ) )
357 - {
358 - $links = explode( "\n", trim( $block->links ) );
359 - $matchedLink = in_array( $linksRequestURL, $links );
316 + if ($matchedLink = ($block->blocksGroup & CJTBlockModel::PINS_LINKS)) {
317 + $links = explode("\n", trim($block->links));
318 + $matchedLink = in_array($linksRequestURL, $links);
360 319 }
361 -
362 320 /// Check if there is a matched expression.
363 - if ( $matchedExpression = ( $block->blocksGroup & CJTBlockModel::PINS_EXPRESSIONS ) )
364 - {
321 + if ($matchedExpression = ($block->blocksGroup & CJTBlockModel::PINS_EXPRESSIONS)) {
365 322 $expressions = explode("\n", $block->expressions);
366 -
367 - foreach ( $expressions as $expression )
368 - {
323 + foreach ($expressions as $expression) {
369 324 /// @TODO: Matches may be used later to evaulate variables inside code block.
370 - if( $matchedExpression = @ preg_match( "/{$expression}/", $expressionsRequestURL ) )
371 - {
325 + if($matchedExpression = @preg_match("/{$expression}/", $expressionsRequestURL)) {
372 326 break;
373 327 }
374 -
375 328 }
376 -
377 329 }
378 -
379 330 /**
380 331 * Exclude Links & Expressions Blocks that doesn't has a match.
381 332 * If there is no matched link or expression then exclude block.
382 333 */
383 - if ( $this->oncancelmatching( ! ( $matchedExpression || $matchedLink ) ) )
384 - {
334 + if ($this->oncancelmatching(!($matchedExpression || $matchedLink))) {
385 335 continue;
386 336 }
387 -
388 337 }
389 338 // Allow extensions to control to prevent block from being in the output
390 - if ( $block = $this->onblockmatched( $block ) )
391 - {
339 + if ($block = $this->onblockmatched($block)) {
392 340 // Retrieve block code-files.
393 - $block->code = $this->model->getBlockCode( $block->id );
394 -
341 + $block->code = $this->model->getBlockCode($block->id);
395 342 // Import Executable (PHP and HTML) templates.
396 - $block->code = $block->code . $this->model->getExecTemplatesCode( $block->id );
397 -
343 + $block->code = $block->code . $this->model->getExecTemplatesCode($block->id);
398 344 // For every location store blocks code into single string
399 -
400 - if ( ! $evaluatedCode = $this->onevalcodeblock( false, $block ) )
401 - {
402 - $evaluatedCode = CJTPHPCodeEvaluator::getInstance( $block )->exec()->getOutput();
403 - }
404 -
345 + $evaluatedCode = CJTPHPCodeEvaluator::getInstance($block)->exec()->getOutput();
405 346 /** @todo Include Debuging info only if we're in debuging mode! */
406 - if ( 1 ) {
407 - // CODE UPDATED BY RBJ -- START
408 - if (trim($evaluatedCode) != ''):
409 - global $post;
410 - $checkMetaBlock = get_post_meta($post->ID, '__CJT-BLOCK-ID', true);
411 -
412 - if (!empty($checkMetaBlock) && $checkMetaBlock == $blockId):
413 - $evaluatedCode = "\n\n<!-- CJT Meta Block ({$blockId}) - {$block->name} - START -->\n{$evaluatedCode}\n<!-- CJT Meta Block ({$blockId}) - {$block->name} - END -->\n\n";
414 - else:
415 - $evaluatedCode = "\n\n<!-- CJT Global Block ({$blockId}) - {$block->name} - START -->\n{$evaluatedCode}\n<!-- CJT Global Block ({$blockId}) - {$block->name} - END -->\n\n";
416 - endif;
417 - endif;
418 - // CODE UPDATED BY RBJ -- END
347 + if (1) {
348 + $evaluatedCode = "\n<!-- Block ({$blockId}) START-->\n{$evaluatedCode}\n<!-- Block ({$blockId}) END -->\n";
419 349 }
420 -
421 - $this->blocks[ 'code' ][ $block->location ] .= $this->onappendcode( $evaluatedCode );
422 -
350 + $this->blocks['code'][$block->location] .= $this->onappendcode($evaluatedCode);
423 351 // Store all used Ids in the CORRECT ORDER.
424 - $this->addOnActionIds( $blockId );
352 + $this->addOnActionIds($blockId);
425 353 }
426 -
427 354 }
428 -
429 355 }
430 -
431 - $templates = $this->onActionIds ?
432 - $this->model->getLinkedTemplates( $this->onActionIds ) :
433 - array();
434 -
356 + $templates = $this->onActionIds ? $this->model->getLinkedTemplates($this->onActionIds) : array();
435 357 // Classisfy as we process Scripts and Styles separatly (different hooks!).
436 - foreach ( $this->onlinkedtemplates( $templates ) as $id => $template )
437 - {
358 + foreach ($this->onlinkedtemplates($templates) as $id => $template) {
438 359 // Filer template!
439 - extract( $this->onlinktemplate( compact( 'template', 'id' ) ) );
440 -
441 - $this->templates[ $template->type ][ $id ] = $template;
360 + extract($this->onlinktemplate(compact('template', 'id')));
361 + $this->templates[$template->type][$id] = $template;
442 362 }
443 -
444 -
363 + // Return true if there is at least 1 block return within the set.
445 364 return true;
446 365 }
447 -
366 +
448 367 /**
449 368 * put your comment there...
450 - *
369 + *
451 370 */
452 371 public function getCached() {
453 372 // Cache is not implemented yet might be supported by extenal Extensions!
454 373 return $this->ongetcache(false);
455 374 }
456 -
375 +
457 376 /**
458 377 * put your comment there...
459 - *
378 + *
460 379 */
461 380 public function getFilters() {
462 - return $this->ongetfilters($this->filters);
381 + return $this->ongetfilters($this->filters);
463 382 }
464 383
465 384 /**
466 385 * put your comment there...
467 - *
386 + *
468 387 */
469 388 public function getOnActionIds() {
470 389 return $this->onActionIds;
471 390 }
@@ -471,9 +390,9 @@
471 390 }
472 391
473 392 /**
474 393 * put your comment there...
475 - *
394 + *
476 395 */
477 396 public static function getRequestURL() {
478 397 // URL Protocol.
479 398 $protocol = 'http' . ((isset($_SERVER["HTTPS"]) && ($_SERVER["HTTPS"] == "on")) ? 's' : '') . '://';
@@ -485,20 +404,20 @@
485 404 // Final URL.
486 405 $url = "{$protocol}{$host}{$port}{$requestURI}";
487 406 return $url;
488 407 }
489 -
408 +
490 409 /**
491 410 * put your comment there...
492 - *
411 + *
493 412 */
494 413 public function hasOnActionIds() {
495 414 return !empty($this->onActionIds);
496 415 }
497 -
416 +
498 417 /**
499 418 * put your comment there...
500 - *
419 + *
501 420 */
502 421 public function initCoupling() {
503 422 // For some reasons wp action is fired twice.
504 423 // The wrong call won't has $wp_query object set,
@@ -527,12 +446,12 @@
527 446 // Simply remove all hooks to ensure its run only one time.
528 447 remove_action('wp', array(&$this, 'initCoupling'));
529 448 remove_action('admin_init', array(&$this, 'initCoupling'));
530 449 }
531 -
450 +
532 451 /**
533 452 * put your comment there...
534 - *
453 + *
535 454 */
536 455 public function linkFooterStyleSheets() {
537 456 // Initialize.
538 457 $styles = array();
@@ -556,9 +475,9 @@
556 475 // jQuery is dpendency object required by the loader.
557 476 wp_enqueue_script('jquery');
558 477 // Enqueue footer style sheet loader.
559 478 wp_enqueue_script('cjt-coupling-footer-css-loader', cssJSToolbox::getURI('controllers:coupling:js:footer-stylesheet-loader.js'));
560 - // Output JavaScript array to be filled with the styles!
479 + // Output Javascript array to be filled with the styles!
561 480 $jsStyleSheetsList = json_encode($styles);
562 481 require cssJSToolbox::resolvePath('controllers:coupling:html:load-footer-style.html.php');
563 482 }
564 483 }
@@ -564,9 +483,9 @@
564 483 }
565 484
566 485 /**
567 486 * put your comment there...
568 - *
487 + *
569 488 */
570 489 public function linkTemplates() {
571 490 $currentFilter = current_filter();
572 491 // Derived template Type from Wordpress filter.
@@ -590,12 +509,12 @@
590 509 // Always make sure the template is queued.
591 510 $queue->enqueue($template->queueName);
592 511 }
593 512 }
594 -
513 +
595 514 /**
596 515 * put your comment there...
597 - *
516 + *
598 517 */
599 518 public function outputBlocks() {
600 519 // Derived location name from wordpress filter name.
601 520 $currentFilter = current_filter();
@@ -608,108 +527,63 @@
608 527 // Map to block location.
609 528 $location = $locationsMap[$location];
610 529 echo $this->onoutput($this->blocks['code'][$location], $location);
611 530 }
612 -
531 +
613 532 /**
614 533 * put your comment there...
615 - *
534 + *
616 535 */
617 - protected function setRequestFilters()
618 - {
536 + protected function setRequestFilters() {
619 537 // Get request blocks.
620 - $filters = $this->ondefaultfilters( ( object ) array
621 - (
622 -
538 + $filters = $this->ondefaultfilters((object) array(
623 539 'pinPoint' => 0x00000000,
624 -
625 540 'customPins' => array(),
626 -
627 541 'moreToOrder' => array(),
628 -
629 - 'currentObject' => null,
630 -
631 - 'currentCustomPin' => 0,
632 -
633 - 'params' => array(),
634 -
635 - ) );
636 -
637 - if ( is_admin() )
638 - {
542 + ));
543 + if (is_admin()) {
639 544 // Include all backend blocks.
640 545 $filters->pinPoint |= CJTBlockModel::PINS_BACKEND;
641 546 }
642 - else
643 - {
547 + else {
644 548 $filters->pinPoint |= CJTBlockModel::PINS_FRONTEND;
645 -
646 549 // Pages.
647 - if ( is_page() )
648 - {
550 + if (is_page()) {
649 551 // Blocks with ALL PAGES selected.
650 552 $filters->pinPoint |= CJTBlockModel::PINS_PAGES_ALL_PAGES;
651 -
652 - $filters->currentObject = $GLOBALS[ 'post' ];
653 - $filters->currentCustomPin = CJTBlockModel::PINS_PAGES_CUSTOM_PAGE;
654 -
655 553 // Blocks with PAGE-ID selected.
656 - $filters->customPins[ ] = array
657 - (
554 + $filters->customPins[] = array(
658 555 'pin' => 'pages',
659 -
660 - 'pins' => array( $filters->currentObject->ID ),
661 -
556 + 'pins' => array($GLOBALS['post']->ID),
662 557 'flag' => CJTBlockModel::PINS_PAGES_CUSTOM_PAGE,
663 -
664 558 );
665 -
666 559 // Blocks with FRONT-PAGE selected.
667 - if ( is_front_page() )
668 - {
560 + if (is_front_page()) {
669 561 $filters->pinPoint |= CJTBlockModel::PINS_PAGES_FRONT_PAGE;
670 562 }
671 -
672 563 /**
673 564 * In order for metabox block to get in the output we need
674 565 * to add metabox order for it.
675 566 * @see CJTBlocksCouplingController::getBlocks.
676 567 */
677 - $metabox = CJTModel::create( 'metabox', array( $filters->currentObject->ID ) );
678 -
679 - $filters->moreToOrder[ ][ 1 ] = $metabox->getMetaboxId();
680 -
568 + $metabox = CJTModel::create('metabox', array($GLOBALS['post']->ID));
569 + $filters->moreToOrder[][1] = $metabox->getMetaboxId();
681 570 } // End is_page()
682 -
683 - else if ( is_attachment() )
684 - {
571 + else if (is_attachment()) {
685 572 $filters->pinPoint |= CJTBlockModel::PINS_ATTACHMENT;
686 573 }
687 574 // Posts.
688 - else if ( is_single() )
689 - {
575 + else if (is_single()) {
690 576 // Blocks with ALL POSTS & ALL CATEGORIES selected.
691 577 $filters->pinPoint |= CJTBlockModel::PINS_POSTS_ALL_POSTS | CJTBlockModel::PINS_CATEGORIES_ALL_CATEGORIES;
692 -
693 - $filters->currentObject = $GLOBALS[ 'post' ];
694 - $filters->currentCustomPin = CJTBlockModel::PINS_POSTS_CUSTOM_POST;
695 -
696 578 // Blocks with POST-ID selected.
697 -
698 - $filters->customPins[ ] = array
699 - (
700 -
579 + $filters->customPins[] = array(
701 580 'pin' => 'posts',
702 -
703 - 'pins' => array( $filters->currentObject->ID ),
704 -
581 + 'pins' => array($GLOBALS['post']->ID),
705 582 'flag' => CJTBlockModel::PINS_POSTS_CUSTOM_POST,
706 -
707 583 );
708 -
709 - // Include POST PARENT CATRGORIES blocks.
710 - $parentCategoriesIds = wp_get_post_categories( $filters->currentObject->ID, array( 'fields' => 'ids' ) );
711 -
584 + // Include POST PARENT CATRGORIES blocks.
585 + $parentCategoriesIds = wp_get_post_categories($GLOBALS['post']->ID, array('fields' => 'ids'));
712 586 /**
713 587 * Custom-Posts just added "ON THE RUN/FLY"
714 588 * Need simple fix by confirming that the post is belong to
715 589 * specific category or not.
@@ -715,110 +589,75 @@
715 589 * specific category or not.
716 590 * Custom posts NOW unlike Posts, it doesn't inherit parent
717 591 * taxonomis Code Blocks!!
718 592 */
719 - if ( ! empty( $parentCategoriesIds ) )
720 - {
721 -
722 - $filters->params[ 'hasCategories' ] = true;
723 - $filters->params[ 'parentCategories' ] = $parentCategoriesIds;
724 -
725 - $filters->customPins[ ] = array
726 - (
727 -
593 + if (!empty($parentCategoriesIds)) {
594 + $filters->customPins[] = array(
728 595 'pin' => 'categories',
729 -
730 596 'pins' => $parentCategoriesIds,
731 -
732 597 'flag' => CJTBlockModel::PINS_CATEGORIES_CUSTOM_CATEGORY,
733 -
734 598 );
735 -
736 599 }
737 -
738 600 /**
739 601 * In order for metabox block to get in the output we need
740 602 * to add metabox order for it.
741 603 * @see CJTBlocksCouplingController::getBlocks.
742 604 */
743 - $metabox = CJTModel::create( 'metabox', array( $filters->currentObject->ID ) );
744 -
745 - $filters->moreToOrder[][ 1 ] = $metabox->getMetaboxId();
746 -
747 - /**
605 + $metabox = CJTModel::create('metabox', array($GLOBALS['post']->ID));
606 + $filters->moreToOrder[][1] = $metabox->getMetaboxId();
607 + /**
748 608 * @TODO check for recent posts Based on user configuration.
749 609 * Recent posts should be detcted by comparing
750 610 * user condifguration with post date.
751 611 */
752 - if ( 0 ) {
753 -
612 + if (0) {
613 +
754 614 }
755 615 } // End is_single()
756 -
757 616 // Categories.
758 - else if( is_category() )
759 - {
617 + else if(is_category()) {
760 618 // Blocks with ALL CATEGORIES selected.
761 619 $filters->pinPoint |= CJTBlockModel::PINS_CATEGORIES_ALL_CATEGORIES;
762 -
763 - $filters->currentObject = get_queried_object();
764 - $filters->currentCustomPin = CJTBlockModel::PINS_CATEGORIES_CUSTOM_CATEGORY;
765 -
766 620 // Blocks with CATEGORY-ID selected.
767 - $filters->customPins[] = array
768 - (
621 + $filters->customPins[] = array(
769 622 'pin' => 'categories',
770 -
771 - 'pins' => array( $filters->currentObject->term_id ),
772 -
623 + 'pins' => array(get_queried_object()->term_id),
773 624 'flag' => CJTBlockModel::PINS_CATEGORIES_CUSTOM_CATEGORY,
774 -
775 - );
776 -
625 + );
777 626 } // End is_category()
778 -
779 627 // Blocks with BLOG-INDEX selected.
780 - else if ( is_home() )
781 - {
628 + else if (is_home()) {
782 629 $filters->pinPoint |= CJTBlockModel::PINS_POSTS_BLOG_INDEX;
783 630 }
784 - else if ( is_search() )
785 - {
631 + else if (is_search()) {
786 632 $filters->pinPoint |= CJTBlockModel::PINS_SEARCH;
787 633 }
788 - else if ( is_tag() )
789 - {
634 + else if (is_tag()) {
790 635 $filters->pinPoint |= CJTBlockModel::PINS_TAG;
791 636 }
792 - else if ( is_author() )
793 - {
637 + else if (is_author()) {
794 638 $filters->pinPoint |= CJTBlockModel::PINS_AUTHOR;
795 639 }
796 - else if ( is_archive() )
797 - {
640 + else if (is_archive()) {
798 641 $filters->pinPoint |= CJTBlockModel::PINS_ARCHIVE;
799 642 }
800 - else if ( is_404() )
801 - {
643 + else if (is_404()) {
802 644 $filters->pinPoint |= CJTBlockModel::PINS_404_ERROR;
803 645 }
804 -
805 646 }
806 -
807 - $this->filters = $this->onsetfilters( $filters );
808 -
647 + $this->filters = $this->onsetfilters($filters);
809 648 }
810 -
649 +
811 650 /**
812 651 * Wordpress do shortcode callback for
813 - * CJT Shortcodes ([cjtoolbox ....])!
814 - *
652 + * CJT Shortcodes ([cjtoolbox ....])!
653 + *
815 654 * This method role is to load the shortcode routines
816 655 * in order to handle the request.
817 - *
656 + *
818 657 * It doesn't do anything except deferring the shortcode
819 658 * codes from loaded until shortcode is really used!
820 - *
659 + *
821 660 * @param mixed $attributes
822 661 */
823 662 public function shortcode($attributes, $content) {
824 663 // Instantiate Shortcode handler class.
@@ -826,17 +665,17 @@
826 665 $shortcode = new CJT_Controllers_Coupling_Shortcode($attributes, $content);
827 666 // Return Shortcode replacement!
828 667 return ((string) $shortcode);
829 668 }
830 -
669 +
831 670 /**
832 671 * put your comment there...
833 - *
672 + *
834 673 */
835 674 public static function & theInstance() {
836 675 return self::$instance;
837 676 }
838 -
677 +
839 678 } // End class.
840 679
841 680 // Hookable!
842 681 CJTBlocksCouplingController::define('CJTBlocksCouplingController', array('hookType' => CJTWordpressEvents::HOOK_FILTER));