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