<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>4's symfony blog &#187; TinyMCE</title>
	<atom:link href="http://www.foolbirds.com/t/tinymce/feed" rel="self" type="application/rss+xml" />
	<link>http://www.foolbirds.com</link>
	<description>all about symfony</description>
	<lastBuildDate>Fri, 14 Oct 2011 12:36:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>在symfony项目中应用TinyMCE（续）</title>
		<link>http://www.foolbirds.com/add-tinymce-to-symfony-2.html</link>
		<comments>http://www.foolbirds.com/add-tinymce-to-symfony-2.html#comments</comments>
		<pubDate>Thu, 15 Jan 2009 01:25:12 +0000</pubDate>
		<dc:creator>zhuozi</dc:creator>
				<category><![CDATA[symfony]]></category>
		<category><![CDATA[TinyMCE]]></category>

		<guid isPermaLink="false">http://www.foolbirds.com/?p=363</guid>
		<description><![CDATA[通过上一篇《在symfony项目中应用TinyMCE》文章，我们知道了，如何在symfony配置TinyMCE，如何在模板中应用TinyMCE，
可是，如果我们想在apps/backend中应用应该如何办呢？
通过在google的搜索，有两个方法。
1、配置genertor.yml文件，和config下面的app.yml、setting.yml文件，在网上一搜可以搜索到很多，可是，昨天试了一上午
也没有测试出来，这里就不讲了，主要说一下第二种方法。
2、定义form
我们在lib下面新建一个sfWidgetFormTextareaTinyMCE.class.php文件

&#60;?php
/*
* This file is part of the symfony package.
* (c) Fabien Potencier &#60;fabien.potencier@symfony-project.com&#62;
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

/**
* sfWidgetFormTextareaTinyMCE represents a Tiny MCE widget.
*
* You must include the Tiny MCE JavaScript file by yourself.
*
* @package    symfony
* @subpackage widget
* @author     Fabien Potencier [...]]]></description>
			<content:encoded><![CDATA[<p>通过上一篇《<a href="http://www.foolbirds.com/add-tinymce-to-symfony.html">在symfony项目中应用TinyMCE</a>》文章，我们知道了，如何在symfony配置TinyMCE，如何在模板中应用TinyMCE，<br />
可是，如果我们想在apps/backend中应用应该如何办呢？<br />
通过在google的搜索，有两个方法。<br />
1、配置genertor.yml文件，和config下面的app.yml、setting.yml文件，在网上一搜可以搜索到很多，可是，昨天试了一上午<br />
也没有测试出来，这里就不讲了，主要说一下第二种方法。<br />
2、定义form<br />
我们在lib下面新建一个sfWidgetFormTextareaTinyMCE.class.php文件</p>
<pre class="php" name='code'>
&lt;?php
/*
* This file is part of the symfony package.
* (c) Fabien Potencier &lt;fabien.potencier@symfony-project.com&gt;
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

/**
* sfWidgetFormTextareaTinyMCE represents a Tiny MCE widget.
*
* You must include the Tiny MCE JavaScript file by yourself.
*
* @package    symfony
* @subpackage widget
* @author     Fabien Potencier &lt;fabien.potencier@symfony-project.com&gt;
* @version    SVN: $Id: sfWidgetFormTextareaTinyMCE.class.php 11894
2008-10-01 16:36:53Z fabien $
*/
class sfWidgetFormTextareaTinyMCE extends sfWidgetFormTextarea
{
/**
* Constructor.
*
* Available options:
*
*  * theme:  The Tiny MCE theme
*  * width:  Width
*  * height: Height
*  * config: The javascript configuration
*
* @param array $options     An array of options
* @param array $attributes  An array of default HTML attributes
*
* @see sfWidgetForm
*/
protected function configure($options = array(), $attributes = array())
{
$this-&gt;addOption('theme', 'advanced');
$this-&gt;addOption('width');
$this-&gt;addOption('height');
$this-&gt;addOption('config', '');
}

/**
* @param  string $name        The element name
* @param  string $value       The value selected in this
widget
* @param  array  $attributes  An array of HTML attributes to
be merged with the default HTML attributes
* @param  array  $errors      An array of errors for the
field
*
* @return string An HTML tag string
*
* @see sfWidgetForm
*/
public function render($name, $value = null, $attributes = array(),
$errors = array())
{
$textarea = parent::render($name, $value, $attributes, $errors);

$js = sprintf(&lt;&lt;&lt;EOF
&lt;script type="text/javascript"&gt;
tinyMCE.init({
mode:                              "exact",
elements: "%s",
theme:                             "%s",
%s
%s
theme_advanced_toolbar_location:   "top",
theme_advanced_toolbar_align:      "left",
theme_advanced_statusbar_location: "bottom",
theme_advanced_resizing:           true
%s
});
&lt;/script&gt;
EOF
,
$this-&gt;generateId($name),
$this-&gt;getOption('theme'),
$this-&gt;getOption('width')  ? sprintf('width:
"%spx",', $this-&gt;getOption('width')) : '',
$this-&gt;getOption('height') ? sprintf('height:
"%spx",', $this-&gt;getOption('height')) : '',
$this-&gt;getOption('config') ?
",\n".$this-&gt;getOption('config') : ''
);

return $textarea.$js;
}
}
</pre>
<p>接下来我们需要重新定义lib/form下我们需要的form（e.g. 我们定义的description字段)</p>
<pre class="php" name='code'>
public function configure()
{
$this-&gt;widgetSchema['description'] = new sfWidgetFormTextareaTinyMCE(array(
'width'  =&gt; 450,
'height' =&gt; 350,
'config' =&gt; 'theme_advanced_disable: "anchor,image,cleanup,help"',
));
}
</pre>
<p>最后大家别忘记在layout.php 中定义js的路径</p>
<pre class="php" name='code'>
javascripts:    [js/tiny_mce.js]
</pre>
<ul class="related_post"><li><a href="http://www.foolbirds.com/add-tinymce-to-symfony.html" title="在symfony项目中应用TinyMCE">在symfony项目中应用TinyMCE</a></li><li><a href="http://www.foolbirds.com/use_symfony_filter_to_filteredurl.html" title="使用symfony filter 过滤URL">使用symfony filter 过滤URL</a></li><li><a href="http://www.foolbirds.com/%e4%bb%bfsymfony%e6%9c%ba%e5%88%b6%e5%ae%9e%e7%8e%b0%e4%b8%8d%e7%94%a8require%e6%88%96%e8%80%85include%e6%9d%a5%e5%ae%9e%e4%be%8b%e5%8c%96%e7%b1%bb.html" title="仿symfony机制实现不用require或者include来实例化类">仿symfony机制实现不用require或者include来实例化类</a></li><li><a href="http://www.foolbirds.com/use-datetime-in-php5-1-x-with-symfony.html" title="symfony1.4 DateTime对于PHP低版本的兼容问题">symfony1.4 DateTime对于PHP低版本的兼容问题</a></li><li><a href="http://www.foolbirds.com/%e5%a6%82%e4%bd%95%e5%9c%a8fixtures-yml%e5%86%99%e5%be%aa%e7%8e%af%e6%b7%bb%e5%8a%a0%e6%95%b0%e6%8d%ae.html" title="如何在fixtures.yml写循环添加数据">如何在fixtures.yml写循环添加数据</a></li><li><a href="http://www.foolbirds.com/symfony-1-4-database-utf8.html" title="symfony 1.4 数据库 utf8设置">symfony 1.4 数据库 utf8设置</a></li><li><a href="http://www.foolbirds.com/symfony-cheat-sheet.html" title="symfony cheat sheet">symfony cheat sheet</a></li><li><a href="http://www.foolbirds.com/cheat-sheets.html" title="Cheat Sheets!">Cheat Sheets!</a></li><li><a href="http://www.foolbirds.com/how-to-use-swift-to-send-mail-in-symfon.html" title="如何使用swift发送邮件">如何使用swift发送邮件</a></li><li><a href="http://www.foolbirds.com/batch-in-symfony12.html" title="symfony1.2下的命令行程序(batch)">symfony1.2下的命令行程序(batch)</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.foolbirds.com/add-tinymce-to-symfony-2.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>在symfony项目中应用TinyMCE</title>
		<link>http://www.foolbirds.com/add-tinymce-to-symfony.html</link>
		<comments>http://www.foolbirds.com/add-tinymce-to-symfony.html#comments</comments>
		<pubDate>Thu, 08 Jan 2009 07:30:41 +0000</pubDate>
		<dc:creator>zhuozi</dc:creator>
				<category><![CDATA[symfony]]></category>
		<category><![CDATA[TinyMCE]]></category>

		<guid isPermaLink="false">http://www.foolbirds.com/?p=331</guid>
		<description><![CDATA[文章参考自Add TinyMCE to a Symfony project，为了使用方便，简单翻译成了中文，英文不好，凑合看吧，其实不看也行，粘贴代码复制就行。
这个方法在Ubuntu下测试成功。
TinyMCE是所见即所得的html编辑器（还可以叫做rich text 富文本），它可以很好的于Symfony整合在一起。然而，如果你想使用它，你需要下载第三方的源码包。这篇文章可以帮助你解决这个问题。
注意：你需要安装解压缩工具，如果你使用的是Debian和Ubuntu,你可以用apt-get的方法进行安装
/usr/bin/sudo /usr/bin/apt-get install unzip
安装TinyMCE
首先，在你项目的目录下进行配置
PROJECT_HOME=/home/sfprojects/myProject
选择你想使用的app入口(有些地方我就简写了，如果接触过symfony，我想你会明白的)
PROJECT_APP=frontend
设置你想要使用的版本
TINYMCE_VERSION=3.0.5
我们移出TinyMCE版本中的点
TINYMCE_CLEANED_VERSION=`echo $TINYMCE_VERSION &#124; sed -e &#8217;s/\./_/g&#8217;`
我们下载TinyMCE的源码包
/usr/bin/wget http://ovh.dl.sourceforge.net/sourceforge/tinymce/tinymce_$TINYMCE_CLEANED_VERSION.zip \
&#8211;output-document=/tmp/tinymce_$TINYMCE_VERSION.zip
解压已经下载完的文件
/usr/bin/unzip -o /tmp/tinymce_$TINYMCE_VERSION.zip -d /tmp
如果你愿意，你也可以下载多语言包
/usr/bin/wget http://services.moxiecode.com/i18n/download.aspx?format=zip\&#38;product=tinymce \
&#8211;output-document=/tmp/tinymce_language_pack.zip
解压多语言包
/usr/bin/unzip -o /tmp/tinymce_language_pack.zip -d /tmp/tinymce/jscripts/tiny_mce
And move the TinyMCE source folder to the target emplacement in your Symfony project :
把TinyMCE源码文件复制到你的symfony项目中 （$PROJECT_HOME 替换你的目录）
/bin/cp -r /tmp/tinymce/jscripts/tiny_mce/ &#8220;$PROJECT_HOME/web/js/&#8221;
现在，我们开始配置symfony以便可以使用TinyMCE （$PROJECT_HOME 替换你的目录，$PROJECT_APP替换你的app）
/bin/sed -i -e &#8216;/^  .settings:/a\
rich_text_js_dir:  [...]]]></description>
			<content:encoded><![CDATA[<p>文章参考自<a href="http://howto.landure.fr/symfony/add-tinymce-to-a-symfony-project">Add TinyMCE to a Symfony project</a>，为了使用方便，简单翻译成了中文，英文不好，凑合看吧，其实不看也行，粘贴代码复制就行。<br />
这个方法在Ubuntu下测试成功。</p>
<p>TinyMCE是所见即所得的html编辑器（还可以叫做rich text 富文本），它可以很好的于Symfony整合在一起。然而，如果你想使用它，你需要下载第三方的源码包。这篇文章可以帮助你解决这个问题。</p>
<p>注意：你需要安装解压缩工具，如果你使用的是Debian和Ubuntu,你可以用apt-get的方法进行安装</p>
<blockquote><p>/usr/bin/sudo /usr/bin/apt-get install unzip</p></blockquote>
<p>安装TinyMCE</p>
<p>首先，在你项目的目录下进行配置</p>
<blockquote><p>PROJECT_HOME=/home/sfprojects/myProject</p></blockquote>
<p>选择你想使用的app入口(有些地方我就简写了，如果接触过symfony，我想你会明白的)</p>
<blockquote><p>PROJECT_APP=frontend</p></blockquote>
<p>设置你想要使用的版本</p>
<blockquote><p>TINYMCE_VERSION=3.0.5</p></blockquote>
<p>我们移出TinyMCE版本中的点</p>
<blockquote><p>TINYMCE_CLEANED_VERSION=`echo $TINYMCE_VERSION | sed -e &#8217;s/\./_/g&#8217;`</p></blockquote>
<p>我们下载TinyMCE的源码包</p>
<blockquote><p>/usr/bin/wget http://ovh.dl.sourceforge.net/sourceforge/tinymce/tinymce_$TINYMCE_CLEANED_VERSION.zip \<br />
&#8211;output-document=/tmp/tinymce_$TINYMCE_VERSION.zip</p></blockquote>
<p>解压已经下载完的文件</p>
<blockquote><p>/usr/bin/unzip -o /tmp/tinymce_$TINYMCE_VERSION.zip -d /tmp</p></blockquote>
<p>如果你愿意，你也可以下载多语言包</p>
<blockquote><p>/usr/bin/wget http://services.moxiecode.com/i18n/download.aspx?format=zip\&amp;product=tinymce \<br />
&#8211;output-document=/tmp/tinymce_language_pack.zip</p></blockquote>
<p>解压多语言包</p>
<blockquote><p>/usr/bin/unzip -o /tmp/tinymce_language_pack.zip -d /tmp/tinymce/jscripts/tiny_mce</p></blockquote>
<p>And move the TinyMCE source folder to the target emplacement in your Symfony project :<br />
把TinyMCE源码文件复制到你的symfony项目中 （$PROJECT_HOME 替换你的目录）</p>
<blockquote><p>/bin/cp -r /tmp/tinymce/jscripts/tiny_mce/ &#8220;$PROJECT_HOME/web/js/&#8221;</p></blockquote>
<p>现在，我们开始配置symfony以便可以使用TinyMCE （$PROJECT_HOME 替换你的目录，$PROJECT_APP替换你的app）</p>
<blockquote><p>/bin/sed -i -e &#8216;/^  .settings:/a\<br />
rich_text_js_dir:  js/tiny_mce&#8217; &#8220;$PROJECT_HOME/apps/$PROJECT_APP/config/settings.yml&#8221;</p></blockquote>
<p>警告：查看你的setting.yml文件以确保一切正常</p>
<blockquote><p>/usr/bin/vim &#8220;$PROJECT_HOME/apps/$PROJECT_APP/config/settings.yml&#8221;</p></blockquote>
<p>你现在可以删除下载的那些文件了</p>
<blockquote><p>/bin/rm -r /tmp/tinymce<br />
/bin/rm /tmp/tinymce_language_pack.zip<br />
/bin/rm /tmp/tinymce_$TINYMCE_VERSION.zip</p></blockquote>
<p>你现在可以使用下面的代码来使用TinyMCE了</p>
<pre class="php" name='code'>
&lt;?php echo textarea_tag('name', 'default content', 'rich=true size=10x20') ?&gt;
&lt;?php echo textarea_tag('name', 'default content', array(
'rich' =&gt; true,
'size' =&gt; '10x20',
'tinymce_options' =&gt; 'language:"fr",theme_advanced_buttons2:"separator"',
)) ?&gt;
</pre>
<p>第一个参数， 是name 用于在表单提交<br />
第二个参数， 是内容<br />
第三个参数， 是一个数组，里面包含了多种信息，可以对TinyMCE进行详细的配置<br />
size  大小<br />
language 语言<br />
theme_advanced_buttons2:&#8221;separator&#8221; 代表不显示第二行工具条<br />
如果你想第2行只显示几个按钮，你可以这样做theme_advanced_buttons2:&#8221;加粗,斜体&#8221;<br />
（当然你要用它本身定义好的英文名字的功能）<br />
PS:上面直接复制的代码，如果出现错误，打开原始那个英文的连接，复制，出现错误的原因是blog编辑器自动隐藏了部分空格</p>
<ul class="related_post"><li><a href="http://www.foolbirds.com/add-tinymce-to-symfony-2.html" title="在symfony项目中应用TinyMCE（续）">在symfony项目中应用TinyMCE（续）</a></li><li><a href="http://www.foolbirds.com/use_symfony_filter_to_filteredurl.html" title="使用symfony filter 过滤URL">使用symfony filter 过滤URL</a></li><li><a href="http://www.foolbirds.com/%e4%bb%bfsymfony%e6%9c%ba%e5%88%b6%e5%ae%9e%e7%8e%b0%e4%b8%8d%e7%94%a8require%e6%88%96%e8%80%85include%e6%9d%a5%e5%ae%9e%e4%be%8b%e5%8c%96%e7%b1%bb.html" title="仿symfony机制实现不用require或者include来实例化类">仿symfony机制实现不用require或者include来实例化类</a></li><li><a href="http://www.foolbirds.com/use-datetime-in-php5-1-x-with-symfony.html" title="symfony1.4 DateTime对于PHP低版本的兼容问题">symfony1.4 DateTime对于PHP低版本的兼容问题</a></li><li><a href="http://www.foolbirds.com/%e5%a6%82%e4%bd%95%e5%9c%a8fixtures-yml%e5%86%99%e5%be%aa%e7%8e%af%e6%b7%bb%e5%8a%a0%e6%95%b0%e6%8d%ae.html" title="如何在fixtures.yml写循环添加数据">如何在fixtures.yml写循环添加数据</a></li><li><a href="http://www.foolbirds.com/symfony-1-4-database-utf8.html" title="symfony 1.4 数据库 utf8设置">symfony 1.4 数据库 utf8设置</a></li><li><a href="http://www.foolbirds.com/symfony-cheat-sheet.html" title="symfony cheat sheet">symfony cheat sheet</a></li><li><a href="http://www.foolbirds.com/cheat-sheets.html" title="Cheat Sheets!">Cheat Sheets!</a></li><li><a href="http://www.foolbirds.com/how-to-use-swift-to-send-mail-in-symfon.html" title="如何使用swift发送邮件">如何使用swift发送邮件</a></li><li><a href="http://www.foolbirds.com/batch-in-symfony12.html" title="symfony1.2下的命令行程序(batch)">symfony1.2下的命令行程序(batch)</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.foolbirds.com/add-tinymce-to-symfony.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

