| 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 |
parent::__construct($viewInfo); |
| 50 |
// Aggregate block view object! |
| 51 |
$this->blockView = self::create('blocks/block'); |
| 52 |
// Register actions. |
| 53 |
add_action('admin_print_scripts', array(__CLASS__, 'enqueueScripts')); |
| 54 |
add_action('admin_print_styles', array(__CLASS__, 'enqueueStyles')); |
| 55 |
// Read input params. |
| 56 |
$this->isLoading = isset($_REQUEST['isLoading']) ? true : false; |
| 57 |
} |
| 58 |
|
| 59 |
/** |
| 60 |
* put your comment there... |
| 61 |
* |
| 62 |
* @param mixed $tpl |
| 63 |
*/ |
| 64 |
public function display() { |
| 65 |
// Display block view |
| 66 |
echo $this->getTemplate($this->templateName); |
| 67 |
} |
| 68 |
|
| 69 |
/** |
| 70 |
* put your comment there... |
| 71 |
* |
| 72 |
*/ |
| 73 |
public static function enqueueScripts() { |
| 74 |
// Import related JScripts. |
| 75 |
CJTBlocksBlockView::enqueueScripts(); |
| 76 |
self::useScripts(__CLASS__, |
| 77 |
'jquery-ui-tabs', |
| 78 |
'jquery-ui-accordion', |
| 79 |
'views:blocks:cjt-block:public:js:{CJT_CJT_BLOCK-}jquery.assignpanel', |
| 80 |
'views:blocks:cjt-block:public:js:{CJT_CJT_BLOCK-}blockproperty', |
| 81 |
'views:blocks:cjt-block:public:js:optional:{CJT_CJT_BLOCK-}pagination.list', |
| 82 |
'views:blocks:cjt-block:public:js:optional:{CJT_CJT_BLOCK-}revision', |
| 83 |
'views:blocks:cjt-block:public:js:{CJT_CJT_BLOCK-}block', |
| 84 |
'views:blocks:cjt-block:public:js:{CJT_CJT_BLOCK-}jquery.block' |
| 85 |
); |
| 86 |
} |
| 87 |
|
| 88 |
/** |
| 89 |
* put your comment there... |
| 90 |
* |
| 91 |
*/ |
| 92 |
public static function enqueueStyles() { |
| 93 |
// Import related styles. |
| 94 |
CJTBlocksBlockView::enqueueStyles(); |
| 95 |
// Initialize style. |
| 96 |
$styles = array('views:blocks:cjt-block:public:css:{CJT_BLOCKS_PAGE_BLOCK-}block'); |
| 97 |
// IF WP < 3.8 add compatibility CSS file. |
| 98 |
$wpVersion = new CJT_Framework_Wordpress_Currentversion(); |
| 99 |
if ($wpVersion->isLess('3.8')) { |
| 100 |
$styles[] = 'views:blocks:cjt-block:public:css:{CJT_BLOCKS_PAGE_BLOCK-}block-wp-lt-3.8'; |
| 101 |
} |
| 102 |
// Include styles. |
| 103 |
self::useStyles(__CLASS__, $styles); |
| 104 |
} |
| 105 |
|
| 106 |
/** |
| 107 |
* put your comment there... |
| 108 |
* |
| 109 |
*/ |
| 110 |
public function & getBlockView() { |
| 111 |
return $this->blockView; |
| 112 |
} |
| 113 |
|
| 114 |
/** |
| 115 |
* put your comment there... |
| 116 |
* |
| 117 |
* @param mixed $pin |
| 118 |
* @param mixed $type |
| 119 |
*/ |
| 120 |
public function getPinCheckbox($name, $pin) { |
| 121 |
$checked = ($this->getBlockView()->getBlock()->pinPoint & $pin) ? 'checked=checked' : ''; |
| 122 |
// Get checkbox value from pin. |
| 123 |
$value = dechex($pin); |
| 124 |
$checkbox = "<input type='checkbox' name='cjtoolbox[{$this->getBlockView()->getBlock()->id}][{$name}][]' value='{$value}' {$checked} />"; |
| 125 |
return $checkbox; |
| 126 |
} |
| 127 |
|
| 128 |
/** |
| 129 |
* |
| 130 |
* |
| 131 |
*/ |
| 132 |
public function setBlock($block) { |
| 133 |
$this->blockView->setBlock($block); |
| 134 |
} |
| 135 |
|
| 136 |
} // End class. |
| 137 |
|
| 138 |
// Hookable!! |
| 139 |
CJTBlocksCjtBlockView::define('CJTBlocksCjtBlockView'); |