Author: sid.gbf
Date: 2010-02-23 21:06:54 +0100 (Tue, 23 Feb 2010)
New Revision: 28226

Added:
   plugins/sfFCKEditorPlugin/lib/helper/
   plugins/sfFCKEditorPlugin/lib/helper/FormHelper.php
   plugins/sfFCKEditorPlugin/lib/helper/sfRichTextEditor.class.php
   plugins/sfFCKEditorPlugin/lib/helper/sfRichTextEditorFCK.class.php
   plugins/sfFCKEditorPlugin/lib/widget/
   plugins/sfFCKEditorPlugin/lib/widget/sfWidgetFormFCKEditor.class.php
Modified:
   plugins/sfFCKEditorPlugin/README
   plugins/sfFCKEditorPlugin/package.xml
Log:


Modified: plugins/sfFCKEditorPlugin/README
===================================================================
--- plugins/sfFCKEditorPlugin/README    2010-02-23 20:02:22 UTC (rev 28225)
+++ plugins/sfFCKEditorPlugin/README    2010-02-23 20:06:54 UTC (rev 28226)
@@ -8,5 +8,4 @@
 
 FCKeditor Documentation
 
-You can find the official documentation for FCKeditor online, at
-http://docs.fckeditor.net/.
\ No newline at end of file
+You can find the official documentation for FCKeditor online, at 
http://docs.fckeditor.net/.
\ No newline at end of file

Added: plugins/sfFCKEditorPlugin/lib/helper/FormHelper.php
===================================================================
--- plugins/sfFCKEditorPlugin/lib/helper/FormHelper.php                         
(rev 0)
+++ plugins/sfFCKEditorPlugin/lib/helper/FormHelper.php 2010-02-23 20:06:54 UTC 
(rev 28226)
@@ -0,0 +1,15 @@
+<?php
+
+function submit_image_tag($source, $options = array())
+{
+  if (!isset($options['alt']))
+  {
+    $path_pos = strrpos($source, '/');
+    $dot_pos = strrpos($source, '.');
+    $begin = $path_pos ? $path_pos + 1 : 0;
+    $nb_str = ($dot_pos ? $dot_pos : strlen($source)) - $begin;
+    $options['alt'] = ucfirst(substr($source, $begin, $nb_str));
+  }
+
+  return tag('input', array_merge(array('type' => 'image', 'name' => 'commit', 
'src' => image_path($source)), 
_convert_options_to_javascript(_convert_options($options))));
+}
\ No newline at end of file

Added: plugins/sfFCKEditorPlugin/lib/helper/sfRichTextEditor.class.php
===================================================================
--- plugins/sfFCKEditorPlugin/lib/helper/sfRichTextEditor.class.php             
                (rev 0)
+++ plugins/sfFCKEditorPlugin/lib/helper/sfRichTextEditor.class.php     
2010-02-23 20:06:54 UTC (rev 28226)
@@ -0,0 +1,46 @@
+<?php
+
+/*
+ * This file is part of the symfony package.
+ * (c) 2004-2006 Fabien Potencier <[email protected]>
+ * 
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * sfRichTextEditor is an abstract class for rich text editor classes.
+ *
+ * @package    symfony
+ * @subpackage helper
+ * @author     Fabien Potencier <[email protected]>
+ * @version    SVN: $Id: sfRichTextEditor.class.php 9101 2008-05-20 08:38:20Z 
FabianLange $
+ */
+abstract class sfRichTextEditor
+{
+  protected
+    $name = '',
+    $content = '',
+    $options = array();
+
+  /**
+   * Initializes this rich text editor.
+   *
+   * @param string $name     The tag name
+   * @param string $content  The rich text editor content
+   * @param array  $options  An array of options
+   */
+  public function initialize($name, $content, $options = array())
+  {
+    $this->name = $name;
+    $this->content = $content;
+    $this->options = $options;
+  }
+
+  /**
+   * Returns the rich text editor as HTML.
+   *
+   * @return string Rich text editor HTML representation
+   */
+  abstract public function toHTML();
+}

Added: plugins/sfFCKEditorPlugin/lib/helper/sfRichTextEditorFCK.class.php
===================================================================
--- plugins/sfFCKEditorPlugin/lib/helper/sfRichTextEditorFCK.class.php          
                (rev 0)
+++ plugins/sfFCKEditorPlugin/lib/helper/sfRichTextEditorFCK.class.php  
2010-02-23 20:06:54 UTC (rev 28226)
@@ -0,0 +1,104 @@
+<?php
+
+/*
+ * This file is part of the symfony package.
+ * (c) 2004-2006 Fabien Potencier <[email protected]>
+ * 
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * sfRichTextEditorFCK implements the FCK rich text editor.
+ *
+ * <b>Options:</b>
+ *  - tool   - Sets the FCKEditor toolbar style
+ *  - config - Sets custom path to the FCKEditor configuration file
+ *
+ * @package    symfony
+ * @subpackage helper
+ * @author     Fabien Potencier <[email protected]>
+ * @version    SVN: $Id: sfRichTextEditorFCK.class.php 17860 2009-05-01 
22:33:31Z FabianLange $
+ */
+class sfRichTextEditorFCK extends sfRichTextEditor
+{
+  /**
+   * Returns the rich text editor as HTML.
+   *
+   * @return string Rich text editor HTML representation
+   */
+  public function toHTML()
+  {
+    $options = $this->options;
+
+    // we need to know the id for things the rich text editor
+    // in advance of building the tag
+    $id = _get_option($options, 'id', $this->name);
+
+    $php_file = 
sfConfig::get('sf_rich_text_fck_js_dir').DIRECTORY_SEPARATOR.'fckeditor.php';
+
+    if 
(!is_readable(sfConfig::get('sf_web_dir').DIRECTORY_SEPARATOR.$php_file))
+    {
+      throw new sfConfigurationException('You must install FCKEditor to use 
this helper (see rich_text_fck_js_dir settings).');
+    }
+
+    // FCKEditor.php class is written with backward compatibility of PHP4.
+    // This reportings are to turn off errors with public properties and 
already declared constructor
+    $error_reporting = error_reporting(E_ALL);
+
+/*    $ckfinder_upload_url = _compute_public_path('', 'uploads/extras/', '');
+    setcookie('ckfinder_upload_url', $ckfinder_upload_url, time()+3600, '/');
+
+    $ckfinder_upload_path = 
sfConfig::get('sf_upload_dir').DIRECTORY_SEPARATOR.'extras/';
+    setcookie('ckfinder_upload_path', $ckfinder_upload_path, time()+3600, '/');
+
+    require_once(sfConfig::get('sf_web_dir').DIRECTORY_SEPARATOR.$php_file);*/
+
+    // turn error reporting back to your settings
+    error_reporting($error_reporting);
+
+    $fckeditor           = new FCKeditor($this->name);
+    $fckeditor->BasePath = 
sfContext::getInstance()->getRequest()->getRelativeUrlRoot().'/'.sfConfig::get('sf_rich_text_fck_js_dir').'/';
+    $fckeditor->Value    = $this->content;
+
+    if (isset($options['width']))
+    {
+      $fckeditor->Width = $options['width'];
+    }
+    elseif (isset($options['cols']))
+    {
+      $fckeditor->Width = (string)((int) $options['cols'] * 10).'px';
+    }
+
+    if (isset($options['height']))
+    {
+      $fckeditor->Height = $options['height'];
+    }
+    elseif (isset($options['rows']))
+    {
+      $fckeditor->Height = (string)((int) $options['rows'] * 10).'px';
+    }
+
+    if (isset($options['tool']))
+    {
+      $fckeditor->ToolbarSet = $options['tool'];
+    }
+
+    if (isset($options['config']))
+    {
+      $fckeditor->Config['CustomConfigurationsPath'] = 
javascript_path($options['config']);
+    }
+
+    $content = $fckeditor->CreateHtml();
+
+    if (sfConfig::get('sf_compat_10'))
+    {
+      // fix for http://trac.symfony-project.com/ticket/732
+      // fields need to be of type text to be picked up by fillin. they are 
hidden by inline css anyway:
+      // <input type="hidden" id="name" name="name" style="display:none" 
value="&lt;p&gt;default&lt;/p&gt;">
+      $content = str_replace('type="hidden"','type="text"',$content);
+    }
+
+    return $content;
+  }
+}

Added: plugins/sfFCKEditorPlugin/lib/widget/sfWidgetFormFCKEditor.class.php
===================================================================
--- plugins/sfFCKEditorPlugin/lib/widget/sfWidgetFormFCKEditor.class.php        
                        (rev 0)
+++ plugins/sfFCKEditorPlugin/lib/widget/sfWidgetFormFCKEditor.class.php        
2010-02-23 20:06:54 UTC (rev 28226)
@@ -0,0 +1,71 @@
+<?php
+
+/**
+ * Represents a FCK Editor widget.
+ *
+ * @package    sfFCKEditorPlugin
+ * @subpackage widget
+ * @version    SVN: $Id$
+ */
+class sfWidgetFormFCKEditor extends sfWidgetForm
+{
+
+  /**
+   * Constructor.
+   *
+   * Available options:
+   *
+   *  * config: Sets custom path to the FCKEditor configuration file
+   *  * tool:   Sets the FCKEditor toolbar style
+   *  * rows:   number of rows
+   *  * width:  editor width
+   *  * height: editor height
+   *
+   * @param array $options     An array of options
+   * @param array $attributes  Attributes not supported. FCK editor rendering 
can be influenced by options.
+   *
+   * @see sfWidget
+   * @see sfWidgetForm
+   */
+  public function __construct($options = array(), $attributes = array())
+  {
+    if (!empty($attributes)) {
+      throw new Exception('Attributes not supported.');
+    }
+    
+    $this->addOption('config', null);
+    $this->addOption('rows', null);
+    $this->addOption('width', null);
+    $this->addOption('height', null);
+    $this->addOption('tool', null);
+    
+    parent::__construct($options, $attributes);
+  }
+       
+  /**
+   * Render the widget
+   * 
+   * @param  string $name        The element name
+   * @param  string $value       The value displayed in this widget
+   * @param  array  $attributes  Attributes not supported. FCK editor 
rendering can be influenced by options.
+   * @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())
+  {
+    if (!empty($attributes)) {
+      throw new Exception('Attributes not supported.');
+    }
+    
+    $editor = new sfRichTextEditorFCK();
+    $options = $this->getOptions();
+
+    $editor->initialize($name, $value, $options);
+    
+    return $editor->toHTML();
+  }
+  
+}

Modified: plugins/sfFCKEditorPlugin/package.xml
===================================================================
--- plugins/sfFCKEditorPlugin/package.xml       2010-02-23 20:02:22 UTC (rev 
28225)
+++ plugins/sfFCKEditorPlugin/package.xml       2010-02-23 20:06:54 UTC (rev 
28226)
@@ -3,7 +3,7 @@
  <name>sfFCKEditorPlugin</name>
  <channel>plugins.symfony-project.org</channel>
  <summary>A FCKEditor Plugin</summary>
- <description>A new sfForm widget that handles FCKEditor</description>
+ <description>A new sfForm widget that handles FCKEditor (doesn't work with 
CKEditor)</description>
  <lead>
   <name>Sidney Ferreira</name>
   <user>SidGBF</user>
@@ -13,8 +13,8 @@
  <date>2009-03-31</date>
  <time>09:00:00</time>
  <version>
-  <release>0.0.2</release>
-  <api>0.0.2</api>
+  <release>0.4.0</release>
+  <api>0.4.0</api>
  </version>
  <stability>
   <release>alpha</release>
@@ -27,14 +27,21 @@
    <file role="data" name="README" />
    <file role="data" name="LICENSE" />
    <dir name="lib">
-    <file role="data" name="sfWidgetFormFCKEditor.class.php" />
+    <dir name="helper">
+      <file role="data" name="FormHelper.php" />
+      <file role="data" name="sfRichTextEditor.class.php" />
+      <file role="data" name="sfRichTextEditorFCK.class.php" />
+    </dir>
+    <dir name="widget">
+      <file role="data" name="sfWidgetFormFCKEditor.class.php" />
+    </dir>
    </dir>
   </dir>
  </contents>
  <dependencies>
   <required>
    <php>
-    <min>5.1.0</min>
+    <min>5.2.0</min>
    </php>
    <pearinstaller>
     <min>1.4.1</min>
@@ -42,9 +49,8 @@
    <package>
     <name>symfony</name>
     <channel>pear.symfony-project.com</channel>
-    <min>1.1.0</min>
-    <max>1.3.0</max>
-    <exclude>1.3.0</exclude>
+    <min>1.3.0</min>
+    <max>1.4.0</max>
    </package>
   </required>
  </dependencies>
@@ -52,18 +58,18 @@
  <changelog>
    <release>
     <version>
-      <release>0.0.2</release>
-      <api>0.0.2</api>
+      <release>0.4.0</release>
+      <api>0.4.0</api>
     </version>
     <stability>
      <release>alpha</release>
      <api>alpha</api>
     </stability>
     <license uri="http://www.fckeditor.net/license";>LGPL/GPL/MPL</license>
-    <date>2009-03-31</date>
+    <date>2010-02-23</date>
     <license>LGPL</license>
     <notes>
-      * First post. I'll detail it ASAP.
+      * After 1 year, Im porting it to 1.4 and dropping 1.2
     </notes>
   </release>
  </changelog>

-- 
You received this message because you are subscribed to the Google Groups 
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/symfony-svn?hl=en.

Reply via email to