<?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>Blog Symfony - Lexik Montpellier &#187; fckeditor</title>
	<atom:link href="http://www.lexik.fr/blog/symfony/tag/fckeditor/feed" rel="self" type="application/rss+xml" />
	<link>http://www.lexik.fr/blog/symfony</link>
	<description>Blog sur le développement Web PHP</description>
	<lastBuildDate>Tue, 20 Jul 2010 08:35:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>FCKeditor dans l&#8217;admin generator (Symfony 1.2, Doctrine)</title>
		<link>http://www.lexik.fr/blog/symfony/symfony/fck-editor-dans-ladmin-generator-symfony-12-doctrine-262</link>
		<comments>http://www.lexik.fr/blog/symfony/symfony/fck-editor-dans-ladmin-generator-symfony-12-doctrine-262#comments</comments>
		<pubDate>Sat, 14 Mar 2009 18:35:49 +0000</pubDate>
		<dc:creator>Samuel Breton</dc:creator>
				<category><![CDATA[1.2.x]]></category>
		<category><![CDATA[Admingenerator 1.2.x]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[admin generator]]></category>
		<category><![CDATA[fckeditor]]></category>
		<category><![CDATA[fichier]]></category>
		<category><![CDATA[upload]]></category>
		<category><![CDATA[widget]]></category>

		<guid isPermaLink="false">http://www.lexik.fr/sfblog/?p=262</guid>
		<description><![CDATA[Mise en place d&#8217;un &#171;&#160;éditeur de texte riche&#160;&#187; (FCKeditor) dans l&#8217;admin generator d&#8217;un projet Symfony 1.2 (Doctrine) Pré-requis : Le lien qui m&#8217;a permis de faire ce post : http://trac.symfony-project.org/wiki/HowToUseFCKeditor Un module admin doctrine nommé ici &#171;&#160;contenu&#160;&#187;, avec un champ nommé &#171;&#160;html&#160;&#187; de type CLOB Le plugin sfFormExtraPlugin installé (http://www.symfony-project.org/plugins/sfFormExtraPlugin) Intégrer FCK Télécharger les fichiers [...]]]></description>
			<content:encoded><![CDATA[<p>Mise en place d&#8217;un &laquo;&nbsp;éditeur de texte riche&nbsp;&raquo; (FCKeditor) dans l&#8217;admin generator d&#8217;un projet Symfony 1.2 (Doctrine)<br />
<span id="more-262"></span></p>
<h2>Pré-requis :</h2>
<ul>
<li> Le lien qui m&#8217;a permis de faire ce post :<br />
<a href="http://trac.symfony-project.org/wiki/HowToUseFCKeditor">http://trac.symfony-project.org/wiki/HowToUseFCKeditor</a></li>
<li> Un module admin doctrine nommé ici &laquo;&nbsp;contenu&nbsp;&raquo;, avec un champ nommé &laquo;&nbsp;html&nbsp;&raquo; de type CLOB</li>
<li> Le plugin sfFormExtraPlugin installé (<a href="http://www.symfony-project.org/plugins/sfFormExtraPlugin">http://www.symfony-project.org/plugins/sfFormExtraPlugin</a>)</li>
</ul>
<h2>Intégrer FCK</h2>
<ul>
<li> Télécharger les fichiers<br />
<a href="http://www.fckeditor.net/download">http://www.fckeditor.net/download</a></li>
<li> Copier les dans web/js/fckeditor</li>
<li> Modifier<br />
<blockquote><p>/apps/backend/config/settings.yml</p></blockquote>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p262code9'); return false;">View Code</a> YAML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2629"><td class="code" id="p262code9"><pre class="yaml" style="font-family:monospace;">...
.settings:
  rich_text_fck_js_dir: js/fckeditor
...</pre></td></tr></table></div>

</li>
</ul>
<h2>Créer un nouveau widget pour sfFormExtraPlugin</h2>
<p>Créer ce fichier :</p>
<blockquote><p>/plugin/sfFormExtraPlugin/lib/widget/sfWidgetFormTextareaFCK.class.php</p></blockquote>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p262code10'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p26210"><td class="code" id="p262code10"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
    * FCK Form widget
    *
    * @package    ***
    * @subpackage lib
    * @author     $LastChangedBy: PoWl $
    * @version    SVN: $Id: sfWidgetFormTextareaFCK.class.php 81 2008-12-08 00:39:59Z PoWl $
    */</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> sfWidgetFormTextareaFCK <span style="color: #000000; font-weight: bold;">extends</span> sfWidgetFormTextarea
<span style="color: #009900;">&#123;</span>
    <span style="color: #009933; font-style: italic;">/**
        * @param array $options     An array of options
        * @param array $attributes  An array of default HTML attributes
        *
        * @see sfWidgetForm
        */</span>
    protected <span style="color: #000000; font-weight: bold;">function</span> configure <span style="color: #009900;">&#40;</span><span style="color: #000088;">$options</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$attributes</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addOption</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'editor'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'fck'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addOption</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'css'</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        parent<span style="color: #339933;">::</span><span style="color: #004000;">configure</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$options</span><span style="color: #339933;">,</span> <span style="color: #000088;">$attributes</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
        * @param  string $name        The element name
        * @param  string $value       The value displayed 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
        */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> render <span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #339933;">,</span> <span style="color: #000088;">$value</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #000088;">$attributes</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$errors</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$editorClass</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'sfRichTextEditorFCK'</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">class_exists</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$editorClass</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            throw <span style="color: #000000; font-weight: bold;">new</span> sfConfigurationException <span style="color: #009900;">&#40;</span><span style="color: #990000;">sprintf</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'The rich text editor &quot;%s&quot; does not exist.'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$editorClass</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000088;">$editor</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000088;">$editorClass</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">in_array</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'sfRichTextEditor'</span><span style="color: #339933;">,</span> class_parents <span style="color: #009900;">&#40;</span><span style="color: #000088;">$editor</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            throw <span style="color: #000000; font-weight: bold;">new</span> sfConfigurationException <span style="color: #009900;">&#40;</span><span style="color: #990000;">sprintf</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'The editor &quot;%s&quot; must extend sfRichTextEditor.'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$editor</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000088;">$attributes</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_merge</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attributes</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getOptions</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$editor</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">initialize</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #339933;">,</span> <span style="color: #000088;">$value</span><span style="color: #339933;">,</span> <span style="color: #000088;">$attributes</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$editor</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">toHTML</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>J&#8217;ai fait trois modifications dans le fichier proposé par le site dont je donne le lien plus haut :</p>
<ol>
<li> Ligne 1 : Attention au cas ou le short tag n&#8217;est pas activé</li>
<li> Standardisation du nom de la classe (sfWidgetFormTextareaFCK)</li>
<li> Ligne 49 : Il faut modifier cette ligne pour pouvoir passer des attributs HTML par defaut au widget:

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p262code11'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p26211"><td class="code" id="p262code11"><pre class="php" style="font-family:monospace;"> <span style="color: #000088;">$attributes</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_merge</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attributes</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getOptions</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

</li>
</ol>
<h2>Utilisation</h2>
<p>Modifier le formulaire de Contenu :</p>
<blockquote><p>/lib/form/doctrine/ContenuForm.class.php</p></blockquote>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p262code12'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p26212"><td class="code" id="p262code12"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">widgetSchema</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'html'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> sfWidgetFormTextareaFCK<span style="color: #009900;">&#40;</span>
  <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
  <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'height'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'700'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'width'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'800'</span>
<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #339933;">...</span></pre></td></tr></table></div>

<h2>Configurer l&#8217;upload de fichiers</h2>
<p>Remplacer le fichier situé dans :</p>
<blockquote><p>/web/js/fckeditor/editor/filemanager/connectors/php/config.php</p></blockquote>
<p>Par celui-là :</p>
<p><a href="http://trac.symfony-project.org/attachment/wiki/HowToUseFCKeditor/config.new">http://trac.symfony-project.org/attachment/wiki/HowToUseFCKeditor/config.new</a></p>
<ol> Il y a 2 lignes importantes :</p>
<li> UserFilesPath

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p262code13'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p26213"><td class="code" id="p262code13"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$Config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'UserFilesPath'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> DIRECTORY_SEPARATOR <span style="color: #339933;">.</span> <span style="color: #0000ff;">'userfiles'</span> <span style="color: #339933;">.</span> DIRECTORY_SEPARATOR <span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>que l&#8217;on transforme comme ceci :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p262code14'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p26214"><td class="code" id="p262code14"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$Config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'UserFilesPath'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #339933;">/</span>uploads<span style="color: #339933;">/</span>fck<span style="color: #339933;">/</span> <span style="color: #339933;">;</span></pre></td></tr></table></div>

</li>
<li> UserFilesAbsolutePath

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p262code15'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p26215"><td class="code" id="p262code15"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$Config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'UserFilesAbsolutePath'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span>DOCUMENT_ROOT<span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$Config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'UserFilesPath'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Qu&#8217;il vous faut éventuellement modifier si la racine de votre projet n&#8217;est pas la même que celle de votre serveur:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p262code16'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p26216"><td class="code" id="p262code16"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$Config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'UserFilesAbsolutePath'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span>DOCUMENT_ROOT<span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #339933;">/</span>myProject<span style="color: #339933;">/</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$Config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'UserFilesPath'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">;</span></pre></td></tr></table></div>

</li>
</ol>
<hr /><em><br />
Sources :</em></p>
<ul>
<li> <em><a href="http://trac.symfony-project.org/wiki/HowToUseFCKeditor">http://trac.symfony-project.org/wiki/HowToUseFCKeditor</a> </em></li>
<li> <em><a href="http://www.symfony-project.org/plugins/sfFormExtraPlugin">http://www.symfony-project.org/plugins/sfFormExtraPlugin</a> </em></li>
<li> <em><a href="http://www.fckeditor.net/download">http://www.fckeditor.net/download</a> </em></li>
</ul>
<p><em> </em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lexik.fr/blog/symfony/symfony/fck-editor-dans-ladmin-generator-symfony-12-doctrine-262/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
