| 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 $templateName = 'default'; |
| 27 |
|
| 28 |
/** |
| 29 |
* put your comment there... |
| 30 |
* |
| 31 |
* @param mixed $viewInfo |
| 32 |
* @return CJTBlocksCjtBlock |
| 33 |
*/ |
| 34 |
public function __construct($viewInfo) { |
| 35 |
parent::__construct($viewInfo); |
| 36 |
// Aggregate block view object! |
| 37 |
$this->blockView = self::create('blocks/block'); |
| 38 |
// Register actions. |
| 39 |
add_action('admin_print_scripts', array(__CLASS__, 'enqueueScripts')); |
| 40 |
add_action('admin_print_styles', array(__CLASS__, 'enqueueStyles')); |
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
* put your comment there... |
| 45 |
* |
| 46 |
* @param mixed $tpl |
| 47 |
*/ |
| 48 |
public function display() { |
| 49 |
// Display block view |
| 50 |
echo $this->getTemplate($this->templateName); |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* put your comment there... |
| 55 |
* |
| 56 |
*/ |
| 57 |
public static function enqueueScripts() { |
| 58 |
// Import related JScripts. |
| 59 |
CJTBlocksBlockView::enqueueScripts(); |
| 60 |
self::useScripts(__CLASS__, |
| 61 |
'jquery-ui-tabs', |
| 62 |
'jquery-ui-accordion', |
| 63 |
'views:blocks:cjt-block:public:js:{CJT_CJT_BLOCK-}jquery.block' |
| 64 |
); |
| 65 |
} |
| 66 |
|
| 67 |
/** |
| 68 |
* put your comment there... |
| 69 |
* |
| 70 |
*/ |
| 71 |
public static function enqueueStyles() { |
| 72 |
// Import related styles. |
| 73 |
CJTBlocksBlockView::enqueueStyles(); |
| 74 |
self::useStyles(__CLASS__, |
| 75 |
'views:blocks:cjt-block:public:css:{CJT_BLOCKS_PAGE_BLOCK-}block' |
| 76 |
); |
| 77 |
} |
| 78 |
|
| 79 |
/** |
| 80 |
* put your comment there... |
| 81 |
* |
| 82 |
*/ |
| 83 |
public function & getBlockView() { |
| 84 |
return $this->blockView; |
| 85 |
} |
| 86 |
|
| 87 |
/** |
| 88 |
* put your comment there... |
| 89 |
* |
| 90 |
* @param mixed $pin |
| 91 |
* @param mixed $type |
| 92 |
*/ |
| 93 |
public function getPinCheckbox($name, $pin) { |
| 94 |
$checked = ($this->getBlockView()->getBlock()->pinPoint & $pin) ? 'checked=checked' : ''; |
| 95 |
// Get checkbox value from pin. |
| 96 |
$value = dechex($pin); |
| 97 |
$checkbox = "<input type='checkbox' name='cjtoolbox[{$this->getBlockView()->getBlock()->id}][{$name}][]' value='{$value}' {$checked} />"; |
| 98 |
return $checkbox; |
| 99 |
} |
| 100 |
|
| 101 |
/** |
| 102 |
* |
| 103 |
* |
| 104 |
*/ |
| 105 |
public function setBlock($block) { |
| 106 |
$this->blockView->setBlock($block); |
| 107 |
} |
| 108 |
|
| 109 |
} // End class. |
| 110 |
|
| 111 |
// Hookable!! |
| 112 |
CJTBlocksCjtBlockView::define('CJTBlocksCjtBlockView'); |