| 1 |
<?php |
| 2 |
/** |
| 3 |
* |
| 4 |
*/ |
| 5 |
|
| 6 |
// Import dependencies. |
| 7 |
CJTView::Import('blocks/block'); |
| 8 |
|
| 9 |
/** |
| 10 |
* |
| 11 |
*/ |
| 12 |
class CJTBlocksCjtBlockView extends CJTView { |
| 13 |
|
| 14 |
/** |
| 15 |
* put your comment there... |
| 16 |
* |
| 17 |
* @var mixed |
| 18 |
*/ |
| 19 |
protected $blockView = null; |
| 20 |
|
| 21 |
/** |
| 22 |
* put your comment there... |
| 23 |
* |
| 24 |
* @var mixed |
| 25 |
*/ |
| 26 |
protected $isLoading; |
| 27 |
|
| 28 |
/** |
| 29 |
* put your comment there... |
| 30 |
* |
| 31 |
* @var mixed |
| 32 |
*/ |
| 33 |
public $structuredContent = array(); |
| 34 |
|
| 35 |
/** |
| 36 |
* put your comment there... |
| 37 |
* |
| 38 |
* @var mixed |
| 39 |
*/ |
| 40 |
protected $templateName = 'default'; |
| 41 |
|
| 42 |
/** |
| 43 |
* put your comment there... |
| 44 |
* |
| 45 |
* @param mixed $viewInfo |
| 46 |
* @return CJTBlocksCjtBlock |
| 47 |
*/ |
| 48 |
public function __construct($viewInfo) { |
| 49 |
|
| 50 |
parent::__construct($viewInfo); |
| 51 |
|
| 52 |
// Aggregate block view object! |
| 53 |
$this->blockView = self::create('blocks/block'); |
| 54 |
|
| 55 |
// Register actions. |
| 56 |
add_action('admin_print_scripts', array(__CLASS__, 'enqueueScripts')); |
| 57 |
add_action('admin_print_styles', array(__CLASS__, 'enqueueStyles')); |
| 58 |
|
| 59 |
// Read input params. |
| 60 |
$this->isLoading = isset($_REQUEST['isLoading']) ? true : false; |
| 61 |
|
| 62 |
// Inject Assignment Panel into THE BLOCK VIEW |
| 63 |
$this->blockView->setOption('isLoading', $this->isLoading) |
| 64 |
->setOption('assignPanelBlock', $this); |
| 65 |
|
| 66 |
} |
| 67 |
|
| 68 |
/** |
| 69 |
* put your comment there... |
| 70 |
* |
| 71 |
* @param mixed $tpl |
| 72 |
*/ |
| 73 |
public function display() { |
| 74 |
// Display block view |
| 75 |
echo $this->getTemplate($this->templateName); |
| 76 |
} |
| 77 |
|
| 78 |
/** |
| 79 |
* put your comment there... |
| 80 |
* |
| 81 |
*/ |
| 82 |
public static function enqueueScripts() { |
| 83 |
// Import related JScripts. |
| 84 |
CJTBlocksBlockView::enqueueScripts(); |
| 85 |
self::useScripts(__CLASS__, |
| 86 |
'jquery-ui-tabs', |
| 87 |
'jquery-ui-accordion', |
| 88 |
'views:blocks:cjt-block:public:js:{CJT_CJT_BLOCK-}jquery.assignpanel', |
| 89 |
'views:blocks:cjt-block:public:js:{CJT_CJT_BLOCK-}blockproperty', |
| 90 |
'views:blocks:cjt-block:public:js:optional:{CJT_CJT_BLOCK-}pagination.list', |
| 91 |
'views:blocks:cjt-block:public:js:optional:{CJT_CJT_BLOCK-}revision', |
| 92 |
'views:blocks:cjt-block:public:js:{CJT_CJT_BLOCK-}block', |
| 93 |
'views:blocks:cjt-block:public:js:{CJT_CJT_BLOCK-}jquery.block' |
| 94 |
); |
| 95 |
} |
| 96 |
|
| 97 |
/** |
| 98 |
* put your comment there... |
| 99 |
* |
| 100 |
*/ |
| 101 |
public static function enqueueStyles() { |
| 102 |
// Import related styles. |
| 103 |
CJTBlocksBlockView::enqueueStyles(); |
| 104 |
// Initialize style. |
| 105 |
$styles = array('views:blocks:cjt-block:public:css:{CJT_BLOCKS_PAGE_BLOCK-}block'); |
| 106 |
// IF WP < 3.8 add compatibility CSS file. |
| 107 |
$wpVersion = new CJT_Framework_Wordpress_Currentversion(); |
| 108 |
if ($wpVersion->isLess('3.8')) { |
| 109 |
$styles[] = 'views:blocks:cjt-block:public:css:{CJT_BLOCKS_PAGE_BLOCK-}block-wp-lt-3.8'; |
| 110 |
} |
| 111 |
// Include styles. |
| 112 |
self::useStyles(__CLASS__, $styles); |
| 113 |
} |
| 114 |
|
| 115 |
/** |
| 116 |
* put your comment there... |
| 117 |
* |
| 118 |
*/ |
| 119 |
public function & getBlockView() { |
| 120 |
return $this->blockView; |
| 121 |
} |
| 122 |
|
| 123 |
/** |
| 124 |
* put your comment there... |
| 125 |
* |
| 126 |
* @param mixed $pin |
| 127 |
* @param mixed $type |
| 128 |
*/ |
| 129 |
public function getPinCheckbox($name, $pin) { |
| 130 |
$checked = ($this->getBlockView()->getBlock()->pinPoint & $pin) ? esc_html('checked=checked') : ''; |
| 131 |
// Get checkbox value from pin. |
| 132 |
$value = dechex($pin); |
| 133 |
$checkbox = "<input type='checkbox' name='cjtoolbox[{$this->getBlockView()->getBlock()->id}][{$name}][]' value='{$value}' {$checked} />"; |
| 134 |
return $checkbox; |
| 135 |
} |
| 136 |
|
| 137 |
/** |
| 138 |
* |
| 139 |
* |
| 140 |
*/ |
| 141 |
public function setBlock($block) { |
| 142 |
$this->blockView->setBlock($block); |
| 143 |
} |
| 144 |
|
| 145 |
} // End class. |
| 146 |
|
| 147 |
// Hookable!! |
| 148 |
CJTBlocksCjtBlockView::define('CJTBlocksCjtBlockView'); |
| 149 |
|