| 1 |
<?php |
| 2 |
/** |
| 3 |
* |
| 4 |
*/ |
| 5 |
|
| 6 |
/** |
| 7 |
* |
| 8 |
*/ |
| 9 |
class CJTTinymceParamsView extends CJTView { |
| 10 |
|
| 11 |
/** |
| 12 |
* put your comment there... |
| 13 |
* |
| 14 |
* @var mixed |
| 15 |
*/ |
| 16 |
protected $grouper = null; |
| 17 |
|
| 18 |
/** |
| 19 |
* put your comment there... |
| 20 |
* |
| 21 |
* @var mixed |
| 22 |
*/ |
| 23 |
protected $groups = null; |
| 24 |
|
| 25 |
/** |
| 26 |
* put your comment there... |
| 27 |
* |
| 28 |
* @var mixed |
| 29 |
*/ |
| 30 |
protected $packageInfo = null; |
| 31 |
|
| 32 |
/** |
| 33 |
* put your comment there... |
| 34 |
* |
| 35 |
* @param mixed $viewInfo |
| 36 |
* @return CJTTinymceParamsView |
| 37 |
*/ |
| 38 |
public function __construct($viewInfo, $params) { |
| 39 |
// Parent procedure! |
| 40 |
parent::__construct($viewInfo, $params); |
| 41 |
// Prepare groups array. |
| 42 |
foreach ($params['groups'] as $group) { |
| 43 |
// Initialize group info array. |
| 44 |
$group['params'] = array(); |
| 45 |
// Group Key. |
| 46 |
$group['key'] = strtolower(str_replace(array(' '), '-', $group['name'])); |
| 47 |
// Get group data cxopy. |
| 48 |
$this->groups[$group['id']] = $group; |
| 49 |
} |
| 50 |
// Put the Group woth the loest ID first, |
| 51 |
// Display in the same order they're added! |
| 52 |
ksort($this->groups); |
| 53 |
// Prepare groups from the passed parameters. |
| 54 |
foreach ($params['params'] as $param) { |
| 55 |
// Add parameter under its group! |
| 56 |
$this->groups[$param->getDefinition()->getGroupId()]['params'][] = $param; |
| 57 |
} |
| 58 |
// Instantiate grouper. |
| 59 |
// Only tab grouper is supported for now! |
| 60 |
$grouperFactory = new CJT_Framework_View_Block_Parameter_Grouper_Factory(); |
| 61 |
$this->grouper = $grouperFactory->create( |
| 62 |
$params['form']->groupType, |
| 63 |
$this->groups |
| 64 |
); |
| 65 |
} |
| 66 |
|
| 67 |
/** |
| 68 |
* Output Javascript files requirred to Add-New-Block view to run. |
| 69 |
* |
| 70 |
* @return void |
| 71 |
*/ |
| 72 |
public function enqueueScripts() { |
| 73 |
// Scripts required by the form to run. |
| 74 |
$scripts = array( |
| 75 |
'jquery', |
| 76 |
'jquery-serialize-object', |
| 77 |
'views:tinymce:params:public:js:{CJT_TINYMCE_PARAMS-}form', |
| 78 |
'framework:js:misc:{CJT-}simple-error-dialog' |
| 79 |
); |
| 80 |
// Scripts required by the grouper. |
| 81 |
$scripts = array_merge($scripts, $this->getGrouper()->enqueueScripts()); |
| 82 |
// Use related scripts. |
| 83 |
self::useScripts(__CLASS__, $scripts); |
| 84 |
} |
| 85 |
|
| 86 |
/** |
| 87 |
* Output CSS files required to Add-New-Block view. |
| 88 |
* |
| 89 |
* @return void |
| 90 |
*/ |
| 91 |
public function enqueueStyles() { |
| 92 |
// Styles required by the params form. |
| 93 |
$styles = array( |
| 94 |
'framework:css:{CJT-}forms', |
| 95 |
'framework:css:{CJT-}error-dialog', |
| 96 |
'views:tinymce:params:public:css:{CJT_TINY_MCE_PARAMS_FORM-}style' |
| 97 |
); |
| 98 |
// Groupe styles. |
| 99 |
$styles = array_merge($styles, $this->getGrouper()->enqueueStyles()); |
| 100 |
// Use related styles. |
| 101 |
self::useStyles(__CLASS__, $styles); |
| 102 |
} |
| 103 |
|
| 104 |
/** |
| 105 |
* put your comment there... |
| 106 |
* |
| 107 |
*/ |
| 108 |
public function getGrouper() { |
| 109 |
return $this->grouper; |
| 110 |
} |
| 111 |
|
| 112 |
} // End class. |
| 113 |
|