Skip to content

Instantly share code, notes, and snippets.

@damusnet
Created October 9, 2010 12:24
Show Gist options
  • Save damusnet/618139 to your computer and use it in GitHub Desktop.
Save damusnet/618139 to your computer and use it in GitHub Desktop.
CKEditor Helper for CakePHP v1.3.4
<?php
/**
* Helper CKEditor pour CakePHP v1.3.4
* Code Original par Pierre-Emmanuel Fringant
* URL : http://www.formation-cakephp.com/388/ckeditor-helper
* Modifié par Damien Varron, 09/10/2010
*/
class CkHelper extends AppHelper
{
var $helpers = array('Html', 'Js');
function replace($fieldName, $options = array())
{
$defaults = array(
'customConfig' => '/js/ckeditor/app.config.js',
'loadFinder' => true
);
$options = array_merge($defaults, $options);
$fieldId = $this->domId($fieldName);
$loadFinder = $options['loadFinder'];
unset($options['loadFinder']);
$script = "\tvar ck_$fieldId = CKEDITOR.replace('$fieldId', {$this->Js->object($options)});";
if($loadFinder)
{
$script .= "\n\tCKFinder.setupCKEditor(ck_$fieldId, '/js/ckfinder/');";
}
return $this->Html->scriptBlock($script, array('inline' => false));
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment