Location: PHPKode > projects > blog > blog/tinymce.php
<?php
/**
 *
 * @filesource
 * @copyright		Copyright 2008-2009, lesorb, Inc.
 * @link			http://www.lesorb.cn Blog Project
 * @package			app
 * @subpackage		app.view.helpers
 * @version			$Revision: 1.1 $
 * @author			WangLiJun
 * @lastmodified	$2009-4-20$
 */
/**
 * Tinymce 帮助类
 *
 * 这个类对 Tinymce 编辑器进行了封装
 */
class TinymceHelper extends Helper
{
/**
 * Helpers帮助类:javascript
 *
 * @var array
 * @access public
 */
	var $helpers = array('javascript');

/**
 * tinymce 存放地址
 *
 * @var string
 * @access public
 */
	var $tinymce_src = 'tiny_mce/tiny_mce.js';

/**
 * tinymce 选项
 *
 * @var array
 * @access public
 */
	var $options = array(
		'mode' => 'textareas',
		'theme' => 'advanced',
		'plugins' => '',
		'language' => 'en',
		'ask' => true,
		'editor_selector' => '',
		'editor_deselector' => '',
		'elements' => '',
		'debug' => false,
		'directionality' => 'ltr', // 文字默认书写顺序, 'ltr':从左到右, 'rtl':从右到左
		'nowrap' => false, // 控制文字是否换行,false:自动换行, true:不自动换行
		'content_css' => '',
		'visual' => true,
		'theme_advanced_layout_manager' => 'SimpleLayout',
		'theme_advanced_toolbar_location' => 'top',
	);

/**
 * 使用 tinymce
 *
 * @param array
 * @return string
 * @access public
 */
	function init($options = false)
	{
		$configs = '';

		if(isset($this->javascript)) {
			echo $this->javascript->link($this->tinymce_src);
		}

		if($options && is_array($options)) {
			$this->options = array_merge($this->$options, $options);
		}
		foreach($this->options as $key=>$value) {
			$configs .= "$key : \"$value\",\n";
		}
		return $this->javascript->codeBlock("
			tinyMCE.init({
				$configs
			});
		");
	}
}
?>
Return current item: blog