<?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 cakephp en español por Hospedaxes &#187; fck</title>
	<atom:link href="http://cakephp.hospedaxes.com/tag/fck/feed" rel="self" type="application/rss+xml" />
	<link>http://cakephp.hospedaxes.com</link>
	<description>Blog sobre desarrollo web con cakephp en español por Hospedaxes</description>
	<lastBuildDate>Mon, 26 Apr 2010 07:11:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Integración de FCKeditor con CakePHP 1.2</title>
		<link>http://cakephp.hospedaxes.com/integracion-de-fckeditor-con-cakephp-12</link>
		<comments>http://cakephp.hospedaxes.com/integracion-de-fckeditor-con-cakephp-12#comments</comments>
		<pubDate>Wed, 27 Aug 2008 11:20:55 +0000</pubDate>
		<dc:creator>nuria</dc:creator>
				<category><![CDATA[Noticias]]></category>
		<category><![CDATA[cakephp-1.2]]></category>
		<category><![CDATA[cakephp]]></category>
		<category><![CDATA[fck]]></category>
		<category><![CDATA[fckeditor]]></category>
		<category><![CDATA[integración]]></category>

		<guid isPermaLink="false">http://cakephp.hospedaxes.com/?p=67</guid>
		<description><![CDATA[En el desarrollo de páginas web muchas veces tenemos la necesidad de introducir un editor de texto, sobre todo cuando es un usuario que no tiene conocimientos de html y css el que tiene que editar un campo o valor que será visible en una página web.
Para ello utilizaremos el editor FCKeditor. Es un software [...]]]></description>
			<content:encoded><![CDATA[<p>En el <a title="Hospedaxes" href="http://www.hospedaxes.com">desarrollo de páginas web</a> muchas veces tenemos la necesidad de introducir un editor de texto, sobre todo cuando es un usuario que no tiene conocimientos de <a title="HTML Wikipedia" href="http://es.wikipedia.org/wiki/C%C3%B3digo_HTML">html</a> y <a title="CSS Guía Breve W3C" href="http://www.w3c.es/divulgacion/guiasbreves/HojasEstilo">css</a> el que tiene que editar un campo o valor que será visible en una página web.</p>
<p>Para ello utilizaremos el editor <a title="FCKeditor" href="http://www.fckeditor.net">FCKeditor.</a> Es un software gratuito, aunque también existe versión comercial, y que permite manipular el texto como si se tratase de MS Word o OpenOffice Writer, conocidos por la mayoría de los usuarios.</p>
<p>Haremos la integración de la siguiente manera:</p>
<p>1. Descargamos de la página web de <a title="Descarga FCKeditor" href="http://www.fckeditor.net/download">FCKEditor</a> el editor, lo descomprimimos y copiamos su contenido en /app/webroot/js. No es necesario copiar la carpeta <em>samples</em>, si no queremos. De esta manera hemos copiado en <em>/app/webroot/js</em> varios ficheros y una carpeta llamada <em>editor</em>.</p>
<p>2. Copiamos en <em>/app/views/helpers</em> el <a href="http://cakephp.hospedaxes.com/wp-content/uploads/2008/08/fck.php.tar.gz">FckHelper</a> y lo importamos en el controlador en el que queramos que se vea el editor. Necesitamos también importar el helper Ajax.</p>
<p>- <strong>FCKHelper</strong> (<em>/app/views/helpers/fck.php</em>):</p>
<pre class="prettyprint"><code >class FckHelper extends HtmlHelper {

var $Width = 500;
var $Height = 300;

function load($id, $width=null, $height=null, $toolbar = 'Default') {
$did = Inflector::camelize(str_replace('/', '_', $id));
if($width){ $this-&gt;Width = $width; }
if($height){ $this-&gt;Height = $height; }
$js = $this-&gt;webroot.'js/';
return&lt;&lt;&lt;FCK_CODE
&lt;script type="text/javascript"&gt;
fckLoader_$did = function () {
var bFCKeditor_$did = new FCKeditor('$did');
bFCKeditor_$did.BasePath = '$js';
bFCKeditor_$did.ToolbarSet = '$toolbar';
bFCKeditor_$did.Width = $this-&gt;Width;
bFCKeditor_$did.Height = $this-&gt;Height;
bFCKeditor_$did.ReplaceTextarea();
}
fckLoader_$did();
&lt;/script&gt;
FCK_CODE;
}
function fileBrowserInput($fieldName, $htmlAttributes = array(), $return = false) {
$output = $this-&gt;input($fieldName, $htmlAttributes, $return);
if (!isset($htmlAttributes['id'])) {
$htmlAttributes['id'] = $this-&gt;model . Inflector::camelize($this-&gt;field);
}
$output .= '&lt;script type="text/javascript"&gt;';
$output .= "//&lt;![CDATA[\n";
$output .= "function openFileBrowser(id){\n";
$output .= "var fck = new FCKeditor(id);\n";
$output .= "fck.BasePath = '".$this-&gt;webroot."js/'\n";
$output .= "var url = fck.BasePath + 'editor/filemanager/browser/default/browser.html?Type=Image&amp;amp;Connector=connectors/php/connector.php';\n";
$output .= "var sOptions = 'toolbar=no,status=no,resizable=yes,dependent=yes,scrollbars=yes';\n";
$output .= "sOptions += ',width=640';\n";
$output .= "sOptions += ',height=480';\n";
$output .= "window.SetUrl = function(fileUrl){\n";
$output .= "\$(id).value = fileUrl;\n";
$output .= "}\n";
$output .= "var oWindow = window.open( url, 'FCKBrowseWindow', sOptions ) ;\n";
$output .= "}\n";
$output .= "//]]&gt;\n";
$output .= '&lt;/script&gt;';
$output .= '&lt;a href="#" onclick="openFileBrowser(\''.$htmlAttributes['id'].'\'); return false;"&gt;select an image...&lt;/a&gt;';
return $output;
}
}</code></pre>
<p>- <strong>En el controlador</strong>:</p>
<pre class="prettyprint">var $helpers = array('Fck', 'Ajax');</pre>
<p>3. Y en la <strong>vista</strong>, lo asociamos con el input que queramos a través de su identificador, enlazando previamente el fichero javascript correspondiente:</p>
<pre class="prettyprint">echo $javascript->link('fckeditor');
echo <code >'&lt;h1&gt;Integración de FCKeditor con CakePHP 1.2&lt;/h1&gt;'</code>;
echo $form->create('Cliente',array('action'=>''));
	echo $form->input('contenido',array('type'=>'textarea', 'label'=>'', 'id' => 'Contenido'));
	echo $fck->load('Contenido', 600, 300);
echo $form->end();</pre>
<p>Ya tenemos nuestro editor, que podemos ver en este <a href="/pruebas/editor">ejemplo</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://cakephp.hospedaxes.com/integracion-de-fckeditor-con-cakephp-12/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
