Development

Changeset 14942

You must first sign up to be able to contribute.

Changeset 14942

Show
Ignore:
Timestamp:
01/25/09 04:15:03 (4 years ago)
Author:
jphilip
Message:

Removed dependency on Prototype.
Added an option to have no preview.
Added a widget for Symfony 1.1 and 1.2.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfWmdPlugin/README

    r11687 r14942  
    1313## Prerequisites ## 
    1414 
    15 PHP v 5.2.0+   
    16 Prototype, tested with v 1.6 
     15PHP v 5.2.0+  
    1716 
    1817## Features ## 
     
    4645        rich_text_wmd_image_browser_url: '@admin_images?action=list&select=url' 
    4746        rich_text_wmd_syntax_file:   <?php echo(SF_ROOT_DIR."/web/syntax.php\n") ?> 
     47        rich_text_no_preview: off 
    4848 
    49  - The first line simply sets Wmd as rich text editor for the application 
     49 - The first line simply sets Wmd as rich text editor for the application. This is only required for the helper in Symfony 1.0, not for the widget. 
    5050 - The second line defines a Url where the user can browse and select an image to be incorporated in the editor.    
    5151When it is defined, a Browser Server button is added to the Add Image Dialog.    
     
    5555 - The third line allows you to define a template to overwrite the default markdown syntax help that shows in the plugin.    
    5656You can copy/paste the one located in the lib/helper folder of the plugin. 
     57 - The fourth displays the editor without a preview pane. 
    5758 
    5859### Options in the helper function ### 
     
    101102The only modification I made was to add server browsing capability to the Add Image Dialog. 
    102103 
    103 ## Usage ## 
     104## Usage for Symfony 1.0 ## 
    104105 
    105106In a template: 
     
    117118      params: rich=true size=120x20 
    118119 
     120     
     121## sfWidgetFormTextareaWmd ## 
     122 
     123The sfWidgetFormTextareaWmd widget can be used with Symfony's forms in versions 1.1 or 1.2.    
     124The same options are available: 
     125 
     126    //In the form class 
     127    public function configure() 
     128    { 
     129      $this->widgetSchema['content'] = new sfWidgetFormTextareaWmd(array('cols' => 60, 'rows' => 30,  'wmd_no_preview' => true, 'wmd_image_browser_url' => 'image/browse', 'wmd_options_file' => 'wmd-options-no-image.js')); 
     130    } 
    119131  
    120132 
  • plugins/sfWmdPlugin/lib/helper/sfRichTextEditorWmd.class.php

    r14939 r14942  
    3030 
    3131    $wmd_options = isset($options['wmd_options']) ? $options['wmd_options'] : false; 
    32     if ($wmd_options) { 
     32     
     33    if (isset($options['wmd_options'])) { 
    3334        unset($options['wmd_options']); 
    3435    } 
    3536     
    3637    $rich_text_wmd_image_browser_url = sfConfig::get('sf_rich_text_wmd_image_browser_url'); 
    37     if ($wmd_options && isset($wmd_options['image_browser_url'])) 
    38         $rich_text_wmd_image_browser_url = $wmd_options['image_browser_url']; 
     38    if ($wmd_options && isset($wmd_options['wmd_image_browser_url'])) 
     39        $rich_text_wmd_image_browser_url = $wmd_options['wmd_image_browser_url']; 
     40         
     41    $noPreview = sfConfig::get('sf_rich_text_no_preview'); 
     42    if ($wmd_options && isset($wmd_options['wmd_no_preview'])) 
     43        $noPreview = $wmd_options['wmd_no_preview']; 
    3944     
    4045    if (!isset($options['cols'])) 
     
    4651    $result = content_tag('textarea', $this->content, array_merge(array('name' => $this->name, 'id' => get_id_from_name($id, null)), _convert_options($options))); 
    4752     
    48     $result .= '<div class="wmd-preview-labels">'; 
    49     $result .=  select_tag('wmd_preview_select_'.$this->name, options_for_select(array(0 => 'Preview', 1 => 'Syntax Guide', 2 => 'Hide')), array('id' => 'wmd_preview_select_'.get_id_from_name($id, null), 'style' => 'padding:3px;', 'onchange' => "if($('wmd_preview_select_".get_id_from_name($id, null)."').selectedIndex==2){Element.hide('wmd_preview_".get_id_from_name($id, null)."');Element.hide('wmd_syntax_".get_id_from_name($id, null)."');}else if($('wmd_preview_select_".get_id_from_name($id, null)."').selectedIndex==1){Element.hide('wmd_preview_".get_id_from_name($id, null)."');Element.show('wmd_syntax_".get_id_from_name($id, null)."');}else if($('wmd_preview_select_".get_id_from_name($id, null)."').selectedIndex==0){Element.show('wmd_preview_".get_id_from_name($id, null)."');Element.hide('wmd_syntax_".get_id_from_name($id, null)."')};")); 
    50     $result .= '</div>'; 
     53    if (!(true === $noPreview)) { 
     54      $result .= '<div class="wmd-preview-labels">'; 
     55      $result .=  select_tag('wmd_preview_select_'.$this->name, options_for_select(array(0 => 'Preview', 1 => 'Syntax Guide', 2 => 'Hide')), array('id' => 'wmd_preview_select_'.get_id_from_name($id, null), 'style' => 'padding:3px;', 'onchange' => "if(document.getElementById('wmd_preview_select_".get_id_from_name($id, null)."').selectedIndex==2){document.getElementById('wmd_preview_".get_id_from_name($id, null)."').style.display='none';document.getElementById('wmd_syntax_".get_id_from_name($id, null)."').style.display='none';}else if(document.getElementById('wmd_preview_select_".get_id_from_name($id, null)."').selectedIndex==1){document.getElementById('wmd_preview_".get_id_from_name($id, null)."').style.display='none';document.getElementById('wmd_syntax_".get_id_from_name($id, null)."').style.display='block';}else if(document.getElementById('wmd_preview_select_".get_id_from_name($id, null)."').selectedIndex==0){document.getElementById('wmd_preview_".get_id_from_name($id, null)."').style.display='block';document.getElementById('wmd_syntax_".get_id_from_name($id, null)."').style.display='none'};")); 
     56      $result .= '</div>'; 
    5157     
    52     $result .= '<div id="wmd_preview_'.get_id_from_name($id, null).'" class="wmd-preview"></div>'; 
    53          
    54     $result .= '<div id="wmd_syntax_'.get_id_from_name($id, null).'" class="wmd-syntax" style="display:none;"> 
    55 <textarea readonly="readonly" cols="80" rows="20" class="syntax-pane" id="syntax_pane_'.get_id_from_name($id, null).' style="display:block;overflow:auto;">'; 
    56      
    57     $syntax_path = sfConfig::get('sf_rich_text_wmd_syntax_file'); 
    58     if (!is_readable($syntax_path)) 
    59     { 
    60         $syntax_path = dirname(__file__).'/syntax.php'; 
     58      $result .= '<div id="wmd_preview_'.get_id_from_name($id, null).'" class="wmd-preview"></div>'; 
     59           
     60      $result .= '<div id="wmd_syntax_'.get_id_from_name($id, null).'" class="wmd-syntax" style="display:none;"> 
     61  <textarea readonly="readonly" cols="80" rows="20" class="syntax-pane" id="syntax_pane_'.get_id_from_name($id, null).' style="display:block;overflow:auto;">'; 
     62       
     63      $syntax_path = sfConfig::get('sf_rich_text_wmd_syntax_file'); 
     64      if (!is_readable($syntax_path)) 
     65      { 
     66          $syntax_path = dirname(__file__).'/syntax.php'; 
     67      } 
     68           
     69      $result .= file_get_contents($syntax_path); 
     70      $result .= '</textarea></div>'; 
    6171    } 
    62          
    63     $result .= file_get_contents($syntax_path); 
    64     $result .= '</textarea></div>'; 
    6572     
    6673    if (!function_exists('get_callbacks'))