This repository has been archived on 2020-05-04. You can view files and clone it, but cannot push or open issues or pull requests.
phunk/modules/editor/classes/kohana/editor/ckeditor.php
2013-04-17 09:00:16 +07:00

91 lines
1.9 KiB
PHP

<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* @link http://ckeditor.com
*
* CKEditor driver library
*
* @package Editor
* @author Brotkin Ivan (BIakaVeron) <BIakaVeron@gmail.com>
* @copyright Copyright (c) 2009 Brotkin Ivan
*/
class Kohana_Editor_Ckeditor extends Editor
{
public static $path = 'media/ckeditor';
public static $scriptname = 'ckeditor.js';
public static $configfile = 'config.js';
public $skin = 'kama';
public $theme = 'default';
public $toolbar = 'Basic';
public function js()
{
return array(self::$path.'/'.self::$scriptname);
}
public function render($print = TRUE, $create_field = TRUE)
{
if ( FALSE === self::$language)
{
self::$language = substr(I18n::$lang, 0, 2);
}
$result = '';
if (TRUE == $create_field)
{
// Create textarea with some config values
$result.= form::textarea($this->fieldname, $this->value, array('width'=>$this->width, 'height'=>$this->height, 'id'=>$this->fieldname))."\r\n";
}
$result .= '<script type="text/javascript">
//<![CDATA[
CKEDITOR.replace( "'.$this->fieldname.'",
{
language: "'.self::$language.'",
skin : "'.$this->skin.'",
theme: "'.$this->theme.'",
toolbar: "'.ucfirst($this->toolbar).'",
width: "'.intval($this->width).'",
height: "'.intval($this->height).'",
customConfig: "'.url::base().self::$path.'/'.self::$configfile.'"
});
//]]>
</script>';
if ($print===TRUE)
{
// Echo code
echo $result;
}
// return generated code
return $result;
}
public function set($field, $value)
{
if (in_array($field, array('skin', 'theme', 'toolbar')))
{
$this->$field = $value;
}
elseif ($field == 'configfile')
{
self::$$field = $value;
}
else
{
return parent::set($field, $value);
}
return $this;
}
}