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