Last active
December 18, 2015 23:49
-
-
Save joeartsea/5864728 to your computer and use it in GitHub Desktop.
Fckeditor Helper (CakePHP1.1x) http://www.artsnet.jp/archives/711
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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