| 1 |
<?php |
| 2 |
/** |
| 3 |
* |
| 4 |
*/ |
| 5 |
|
| 6 |
// Disallow direct access. |
| 7 |
defined('ABSPATH') or die("Access denied"); |
| 8 |
|
| 9 |
// Import dependencies. |
| 10 |
cssJSToolbox::import('tables:blocks.php'); |
| 11 |
|
| 12 |
/** |
| 13 |
* |
| 14 |
*/ |
| 15 |
class CJTCouplingModel extends CJTHookableClass { |
| 16 |
|
| 17 |
/** |
| 18 |
* put your comment there... |
| 19 |
* |
| 20 |
* @var mixed |
| 21 |
*/ |
| 22 |
protected $onexpressionsandlinkedblocks = array('parameters' => array('blocks')); |
| 23 |
|
| 24 |
/** |
| 25 |
* put your comment there... |
| 26 |
* |
| 27 |
* @var mixed |
| 28 |
*/ |
| 29 |
protected $ongetorder = array('parameters' => array('order')); |
| 30 |
|
| 31 |
/** |
| 32 |
* put your comment there... |
| 33 |
* |
| 34 |
* @var mixed |
| 35 |
*/ |
| 36 |
protected $onpinsblockfilters = array('parameters' => array( |
| 37 |
'params' => array('linksExpressionFlag', 'pinPoint', 'customPins') |
| 38 |
) |
| 39 |
); |
| 40 |
|
| 41 |
/** |
| 42 |
* put your comment there... |
| 43 |
* |
| 44 |
* @var mixed |
| 45 |
*/ |
| 46 |
protected $onrequestblocks = array('parameters' => array('blocks')); |
| 47 |
|
| 48 |
/** |
| 49 |
* put your comment there... |
| 50 |
* |
| 51 |
*/ |
| 52 |
public function getOrder() { |
| 53 |
return $this->ongetorder(get_option('meta-box-order_cjtoolbox')); |
| 54 |
} |
| 55 |
|
| 56 |
/** |
| 57 |
* put your comment there... |
| 58 |
* |
| 59 |
* @param mixed $linksExpressionFlag |
| 60 |
* @param mixed $pinPoint |
| 61 |
* @param mixed $customPins |
| 62 |
*/ |
| 63 |
public function getPinsBlocks($linksExpressionFlag, $pinPoint, $customPins) { |
| 64 |
// Extendable! |
| 65 |
extract($this->onpinsblockfilters(compact('linksExpressionFlag', 'pinPoint', 'customPins'))); |
| 66 |
// Import required libraries for CJTPinsBlockSQLView. |
| 67 |
require_once CJTOOLBOX_TABLES_PATH . '/pins-blocks-view.php'; |
| 68 |
// Initialize new CJTPinsBlockSQLView view object. |
| 69 |
$dbDriver = new CJTMYSQLQueueDriver($GLOBALS['wpdb']); |
| 70 |
$view = new CJTPinsBlockSQLView($dbDriver); |
| 71 |
// Apply filter to view. |
| 72 |
$view->filters($pinPoint, $customPins); |
| 73 |
// retreiving blocks data associated with current request. |
| 74 |
$blocks = $this->onrequestblocks($view->exec()); |
| 75 |
// Get links & expressions Blocks. |
| 76 |
// NOTE: We need only blocks not presented in $blocks var -- exclude their id. |
| 77 |
$view->filters($linksExpressionFlag, array(), 'active', array_keys($blocks)); |
| 78 |
// We'll process all blocks inside single loop. |
| 79 |
$blocks = $blocks + $this->onexpressionsandlinkedblocks($view->exec()); |
| 80 |
return $blocks; |
| 81 |
} |
| 82 |
|
| 83 |
} // End class. |
| 84 |
|
| 85 |
|
| 86 |
// Hookable! |
| 87 |
CJTCouplingModel::define('CJTCouplingModel', array('hookType' => CJTWordpressEvents::HOOK_FILTER)); |