Skip to content

Instantly share code, notes, and snippets.

@joeartsea
Last active December 18, 2015 23:49
Show Gist options
  • Save joeartsea/5864728 to your computer and use it in GitHub Desktop.
Save joeartsea/5864728 to your computer and use it in GitHub Desktop.
Fckeditor Helper (CakePHP1.1x) http://www.artsnet.jp/archives/711
<?php
vendor('fckeditor/fckeditor');
class FckHelper extends Helper {
var $helpers = array('Html', 'Form');
function textarea($fieldName, $options = array()) {
$defaultOptions = array(
'value' => $this->Html->tagValue($fieldName),
'width' => '100%',
'height' => '300',
'toolbar' => 'Basic',
);
$options = array_merge($defaultOptions, $options);
$fieldName = explode('/', $fieldName);
$editor_name = "data";
if(count($fieldName) > 1) {
foreach ($fieldName as $key) {
$editor_name .= "[{$key}]";
}
} else {
$model = $this->Form->params['models'][0];
$editor_name .= "[{$model}][{$fieldName[0]}]";
}
$oFCKeditor = new FCKeditor($editor_name);
$oFCKeditor->BasePath = '/js/fckeditor/';
$oFCKeditor->Value = $options['value'];
$oFCKeditor->Width = $options['width'];
$oFCKeditor->Height = $options['height'];
$oFCKeditor->ToolbarSet = $options['toolbar'];
return $oFCKeditor->CreateHtml();
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment