Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // /cakephp/app/View/Helper/TinymceHelper.php
- App::uses('AppHelper', 'View/Helper');
- class TinymceHelper extends AppHelper {
- public $helpers = array('Js', 'Html', 'Form');
- public $_script = false;
- function _build($fieldName, $tinyoptions = array()){
- if(!$this->_script){
- $this->_script = true;
- $this->Html->script('tiny_mce/tinymce.min', array('inline' => false));
- $this->Html->script('tiny_mce/jquery.tinymce.min', array('inline' => false));
- }
- $tinyoptions['elements'] = $this->domId($fieldName);
- $value_arr = array();
- $replace_keys = array();
- foreach($tinyoptions as $key => &$value){
- if(strpos($value, 'function(') === 0){
- $value_arr[] = $value;
- $value = '%' . $key . '%';
- $replace_keys[] = '"' . $value . '"';
- }
- }
- $this->Html->scriptStart(array('inline' => false));
- echo 'tinymce.init({
- selector: "textarea",
- theme: "modern",
- mode: "textareas",
- plugins: [
- "advlist autolink lists link image charmap print preview hr anchor pagebreak",
- "searchreplace wordcount visualblocks visualchars code fullscreen",
- "insertdatetime media nonbreaking save table contextmenu directionality",
- "emoticons template paste"
- ],
- toolbar1: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",
- toolbar2: "print preview media | forecolor backcolor emoticons",
- templates: [
- {title: \'Test template 1\', content: \'Test 1\'},
- {title: \'Test template 2\', content: \'Test 2\'}
- ]
- });';
- $this->Html->scriptEnd();
- }
- function textarea($fieldName, $options = array(), $tinyoptions = array()){
- return $this->Form->textarea($fieldName, $options) . $this->_build($fieldName, $tinyoptions);
- }
- function input($fieldName, $options = array(), $tinyoptions = array()){
- $options['type'] = 'textarea';
- return $this->Form->input($fieldName, $options) . $this->_build($fieldName, $tinyoptions);
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment