Dotclear


Ignore:
Timestamp:
03/22/15 15:10:20 (10 years ago)
Author:
Nicolas <nikrou77@…>
Branch:
default
Message:

Allow customizing CKEditor formats
Fixes #2070

Location:
plugins/dcCKEditor
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • plugins/dcCKEditor/_define.php

    r2894 r2972  
    44# This file is part of Dotclear 2. 
    55# 
    6 # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear 
     6# Copyright (c) 2003-2015 Olivier Meunier & Association Dotclear 
    77# Licensed under the GPL version 2.0 license. 
    88# See LICENSE file or 
     
    1616     /* Description*/         "dotclear CKEditor integration", 
    1717     /* Author */             "dotclear Team", 
    18      /* Version */            "0.9.0", 
     18     /* Version */            "1.0.0", 
    1919     array( 
    2020          'permissions' =>    'usage,contentadmin', 
  • plugins/dcCKEditor/_install.php

    r2854 r2972  
    2727$settings->dcckeditor->put('cancollapse_button', false, 'boolean', 'Add collapse button?', false, true); 
    2828$settings->dcckeditor->put('format_select', false, 'boolean', 'Add format selection?', false, true); 
     29$settings->dcckeditor->put('format_tags', 'p;h1;h2;h3;h4;h5;h6;pre;address', 'string', 'Custom formats', false, true); 
    2930$settings->dcckeditor->put('table_button', false, 'boolean', 'Add table button?', false, true); 
    3031$settings->dcckeditor->put('clipboard_buttons', false, 'boolean', 'Add clipboard buttons?', false, true); 
  • plugins/dcCKEditor/_post_config.php

    r2962 r2972  
    44# This file is part of Dotclear 2. 
    55# 
    6 # Copyright (c) 2003-2014 Olivier Meunier & Association Dotclear 
     6# Copyright (c) 2003-2015 Olivier Meunier & Association Dotclear 
    77# Licensed under the GPL version 2.0 license. 
    88# See LICENSE file or 
     
    113113          <?php if (!empty($dcckeditor_format_select)):?> 
    114114          // format tags 
     115<?php if (!empty($dcckeditor_format_tags)):?> 
     116        format_tags: '<?php echo $dcckeditor_format_tags;?>', 
     117<?php else:?> 
    115118          format_tags: 'p;h1;h2;h3;h4;h5;h6;pre;address', 
    116  
     119<?php endif;?> 
    117120          // following definition are needed to be specialized 
    118121          format_p: { element: 'p' }, 
  • plugins/dcCKEditor/inc/_config.php

    r2854 r2972  
    44# This file is part of Dotclear 2. 
    55# 
    6 # Copyright (c) 2003-2014 Olivier Meunier & Association Dotclear 
     6# Copyright (c) 2003-2015 Olivier Meunier & Association Dotclear 
    77# Licensed under the GPL version 2.0 license. 
    88# See LICENSE file or 
     
    1616 
    1717if (!empty($_POST['saveconfig'])) { 
    18     try { 
    19         $dcckeditor_active = (empty($_POST['dcckeditor_active']))?false:true; 
    20         $core->blog->settings->dcckeditor->put('active', $dcckeditor_active, 'boolean'); 
     18     try { 
     19          $dcckeditor_active = (empty($_POST['dcckeditor_active']))?false:true; 
     20          $core->blog->settings->dcckeditor->put('active', $dcckeditor_active, 'boolean'); 
    2121 
    22         // change other settings only if they were in html page 
    23         if ($dcckeditor_was_actived) { 
    24             $dcckeditor_alignement_buttons = (empty($_POST['dcckeditor_alignment_buttons']))?false:true; 
    25             $core->blog->settings->dcckeditor->put('alignment_buttons', $dcckeditor_alignement_buttons, 'boolean'); 
     22          // change other settings only if they were in html page 
     23          if ($dcckeditor_was_actived) { 
     24               $dcckeditor_alignement_buttons = (empty($_POST['dcckeditor_alignment_buttons']))?false:true; 
     25               $core->blog->settings->dcckeditor->put('alignment_buttons', $dcckeditor_alignement_buttons, 'boolean'); 
    2626 
    27             $dcckeditor_list_buttons = (empty($_POST['dcckeditor_list_buttons']))?false:true; 
    28             $core->blog->settings->dcckeditor->put('list_buttons', $dcckeditor_list_buttons, 'boolean'); 
     27               $dcckeditor_list_buttons = (empty($_POST['dcckeditor_list_buttons']))?false:true; 
     28               $core->blog->settings->dcckeditor->put('list_buttons', $dcckeditor_list_buttons, 'boolean'); 
    2929 
    30             $dcckeditor_textcolor_button = (empty($_POST['dcckeditor_textcolor_button']))?false:true; 
    31             $core->blog->settings->dcckeditor->put('textcolor_button', $dcckeditor_textcolor_button, 'boolean'); 
     30               $dcckeditor_textcolor_button = (empty($_POST['dcckeditor_textcolor_button']))?false:true; 
     31               $core->blog->settings->dcckeditor->put('textcolor_button', $dcckeditor_textcolor_button, 'boolean'); 
    3232 
    33             $dcckeditor_cancollapse_button = (empty($_POST['dcckeditor_cancollapse_button']))?false:true; 
    34             $core->blog->settings->dcckeditor->put('cancollapse_button', $dcckeditor_cancollapse_button, 'boolean'); 
     33               $dcckeditor_cancollapse_button = (empty($_POST['dcckeditor_cancollapse_button']))?false:true; 
     34               $core->blog->settings->dcckeditor->put('cancollapse_button', $dcckeditor_cancollapse_button, 'boolean'); 
    3535 
    36             $dcckeditor_format_select = (empty($_POST['dcckeditor_format_select']))?false:true; 
    37             $core->blog->settings->dcckeditor->put('format_select', $dcckeditor_format_select, 'boolean'); 
     36               $dcckeditor_format_select = (empty($_POST['dcckeditor_format_select']))?false:true; 
     37               $core->blog->settings->dcckeditor->put('format_select', $dcckeditor_format_select, 'boolean'); 
    3838 
    39             $dcckeditor_table_button = (empty($_POST['dcckeditor_table_button']))?false:true; 
    40             $core->blog->settings->dcckeditor->put('table_button', $dcckeditor_table_button, 'boolean'); 
     39               // default tags : p;h1;h2;h3;h4;h5;h6;pre;address 
     40               $allowed_tags = array('p','h1','h2','h3','h4','h5','h6','pre','address'); 
     41               if (!empty($_POST['dcckeditor_format_tags'])) { 
     42                    $tags = explode(';', $_POST['dcckeditor_format_tags']); 
     43                    $new_tags = true; 
     44                    foreach ($tags as $tag) { 
     45                         if (!in_array($tag, $allowed_tags)) { 
     46                              $new_tags = false; 
     47                              break; 
     48                         } 
     49                    } 
     50                    if ($new_tags) { 
     51                         $dcckeditor_format_tags = $_POST['dcckeditor_format_tags']; 
     52                    } 
     53               } else { 
     54                    $dcckeditor_format_tags = 'p;h1;h2;h3;h4;h5;h6;pre;address'; 
     55               } 
     56               $core->blog->settings->dcckeditor->put('format_tags', $dcckeditor_format_tags, 'string'); 
    4157 
    42             $dcckeditor_clipboard_buttons = (empty($_POST['dcckeditor_clipboard_buttons']))?false:true; 
    43             $core->blog->settings->dcckeditor->put('clipboard_buttons', $dcckeditor_clipboard_buttons, 'boolean'); 
    44         } 
    4558 
    46         dcPage::addSuccessNotice(__('The configuration has been updated.')); 
    47         http::redirect($p_url); 
    48     } catch(Exception $e) { 
     59               $dcckeditor_table_button = (empty($_POST['dcckeditor_table_button']))?false:true; 
     60               $core->blog->settings->dcckeditor->put('table_button', $dcckeditor_table_button, 'boolean'); 
     61 
     62               $dcckeditor_clipboard_buttons = (empty($_POST['dcckeditor_clipboard_buttons']))?false:true; 
     63               $core->blog->settings->dcckeditor->put('clipboard_buttons', $dcckeditor_clipboard_buttons, 'boolean'); 
     64          } 
     65 
     66          dcPage::addSuccessNotice(__('The configuration has been updated.')); 
     67          http::redirect($p_url); 
     68     } catch(Exception $e) { 
    4969          $core->error->add($e->getMessage()); 
    50     } 
     70     } 
    5171} 
    5272 
  • plugins/dcCKEditor/index.php

    r2855 r2972  
    44# This file is part of Dotclear 2. 
    55# 
    6 # Copyright (c) 2003-2014 Olivier Meunier & Association Dotclear 
     6# Copyright (c) 2003-2015 Olivier Meunier & Association Dotclear 
    77# Licensed under the GPL version 2.0 license. 
    88# See LICENSE file or 
     
    2222$dcckeditor_cancollapse_button = $core->blog->settings->dcckeditor->cancollapse_button; 
    2323$dcckeditor_format_select = $core->blog->settings->dcckeditor->format_select; 
     24$dcckeditor_format_tags = $core->blog->settings->dcckeditor->format_tags; 
    2425$dcckeditor_table_button = $core->blog->settings->dcckeditor->table_button; 
    2526$dcckeditor_clipboard_buttons = $core->blog->settings->dcckeditor->clipboard_buttons; 
  • plugins/dcCKEditor/tpl/index.tpl

    r2855 r2972  
    11<html> 
    2      <head> 
    3           <title>dcCKEditor</title> 
    4      </head> 
    5      <body> 
    6           <?php echo dcPage::breadcrumb(array(__('Plugins') => '',__('dcCKEditor') => '')).dcPage::notices(); ?> 
     2  <head> 
     3    <title>dcCKEditor</title> 
     4  </head> 
     5  <body> 
     6    <?php echo dcPage::breadcrumb(array(__('Plugins') => '',__('dcCKEditor') => '')).dcPage::notices(); ?> 
    77 
    8           <?php if ($is_admin):?> 
    9                <h3 class="hidden-if-js"><?php echo __('Settings');?></h3> 
    10                <form action="<?php echo $p_url;?>" method="post" enctype="multipart/form-data"> 
    11                     <div class="fieldset"> 
    12                          <h3><?php echo __('Plugin activation');?></h3> 
    13                          <p> 
    14                               <label class="classic" for="dcckeditor_active"> 
    15                                    <?php echo form::checkbox('dcckeditor_active', 1, $dcckeditor_active);?> 
    16                                    <?php echo __('Enable dcCKEditor plugin');?> 
    17                               </label> 
    18                          </p> 
    19                     </div> 
     8    <?php if ($is_admin):?> 
     9    <h3 class="hidden-if-js"><?php echo __('Settings');?></h3> 
     10    <form action="<?php echo $p_url;?>" method="post" enctype="multipart/form-data"> 
     11      <div class="fieldset"> 
     12     <h3><?php echo __('Plugin activation');?></h3> 
     13     <p> 
     14       <label class="classic" for="dcckeditor_active"> 
     15         <?php echo form::checkbox('dcckeditor_active', 1, $dcckeditor_active);?> 
     16         <?php echo __('Enable dcCKEditor plugin');?> 
     17       </label> 
     18     </p> 
     19      </div> 
    2020 
    21                     <?php if ($dcckeditor_active):?> 
    22                          <div class="fieldset"> 
    23                               <h3><?php echo __('Options'); ?></h3> 
    24                               <p> 
    25                                    <?php echo form::checkbox('dcckeditor_alignment_buttons', 1, $dcckeditor_alignment_buttons); ?> 
    26                                    <label class="classic" for="dcckeditor_alignment_buttons">&nbsp;<?php echo __('Add alignment buttons');?></label> 
    27                               </p> 
    28                               <p> 
    29                                    <?php echo form::checkbox('dcckeditor_list_buttons', 1, $dcckeditor_list_buttons); ?> 
    30                                    <label class="classic" for="dcckeditor_list_buttons">&nbsp;<?php echo __('Add lists buttons');?></label> 
    31                               </p> 
    32                               <p> 
    33                                    <?php echo form::checkbox('dcckeditor_textcolor_button', 1, $dcckeditor_textcolor_button); ?> 
    34                                    <label class="classic" for="dcckeditor_textcolor_button">&nbsp;<?php echo __('Add text color button');?></label> 
    35                               </p> 
    36                               <p> 
    37                                    <?php echo form::checkbox('dcckeditor_cancollapse_button', 1, $dcckeditor_cancollapse_button); ?> 
    38                                    <label class="classic" for="dcckeditor_cancollapse_button">&nbsp;<?php echo __('Add collapse button');?></label> 
    39                               </p> 
    40                               <p> 
    41                                    <?php echo form::checkbox('dcckeditor_format_select', 1, $dcckeditor_format_select);?> 
    42                                    <label class="classic" for="dcckeditor_format_select">&nbsp;<?php echo __('Add format selection');?></label> 
    43                               </p> 
    44                               <p> 
    45                                    <?php echo form::checkbox('dcckeditor_table_button', 1, $dcckeditor_table_button);?> 
    46                                    <label class="classic" for="dcckeditor_table_button">&nbsp;<?php echo __('Add table button');?></label> 
    47                               </p> 
    48                               <p> 
    49                                    <?php echo form::checkbox('dcckeditor_clipboard_buttons', 1, $dcckeditor_clipboard_buttons);?> 
    50                                    <label class="classic" for="dcckeditor_clipboard_buttons">&nbsp;<?php echo __('Add clipboard buttons');?></label> 
    51                               </p> 
    52                               <p class="clear form-note"> 
    53                                    <?php echo __('Copy, Paste, Paste Text, Paste from Word');?> 
    54                               </p> 
    55                          </div> 
    56                     <?php endif;?> 
     21      <?php if ($dcckeditor_active):?> 
     22      <div class="fieldset"> 
     23     <h3><?php echo __('Options'); ?></h3> 
     24     <p> 
     25       <?php echo form::checkbox('dcckeditor_alignment_buttons', 1, $dcckeditor_alignment_buttons); ?> 
     26       <label class="classic" for="dcckeditor_alignment_buttons">&nbsp;<?php echo __('Add alignment buttons');?></label> 
     27     </p> 
     28     <p> 
     29       <?php echo form::checkbox('dcckeditor_list_buttons', 1, $dcckeditor_list_buttons); ?> 
     30       <label class="classic" for="dcckeditor_list_buttons">&nbsp;<?php echo __('Add lists buttons');?></label> 
     31     </p> 
     32     <p> 
     33       <?php echo form::checkbox('dcckeditor_textcolor_button', 1, $dcckeditor_textcolor_button); ?> 
     34       <label class="classic" for="dcckeditor_textcolor_button">&nbsp;<?php echo __('Add text color button');?></label> 
     35     </p> 
     36     <p> 
     37       <?php echo form::checkbox('dcckeditor_cancollapse_button', 1, $dcckeditor_cancollapse_button); ?> 
     38       <label class="classic" for="dcckeditor_cancollapse_button">&nbsp;<?php echo __('Add collapse button');?></label> 
     39     </p> 
     40     <p> 
     41       <?php echo form::checkbox('dcckeditor_format_select', 1, $dcckeditor_format_select);?> 
     42       <label class="classic" for="dcckeditor_format_select">&nbsp;<?php echo __('Add format selection');?></label> 
     43     </p> 
     44     <p> 
     45       <label class="classic" for="dcckeditor_format_tags">&nbsp;<?php echo __('Custom formats');?></label> 
     46       <?php echo form::field('dcckeditor_format_tags',100,255, $dcckeditor_format_tags);?> 
     47     </p> 
     48     <p class="clear form-note"> 
     49       <?php echo __('Default formats are p;h1;h2;h3;h4;h5;h6;pre;address');?> 
     50     </p> 
     51     <p> 
     52       <?php echo form::checkbox('dcckeditor_table_button', 1, $dcckeditor_table_button);?> 
     53       <label class="classic" for="dcckeditor_table_button">&nbsp;<?php echo __('Add table button');?></label> 
     54     </p> 
     55     <p> 
     56       <?php echo form::checkbox('dcckeditor_clipboard_buttons', 1, $dcckeditor_clipboard_buttons);?> 
     57       <label class="classic" for="dcckeditor_clipboard_buttons">&nbsp;<?php echo __('Add clipboard buttons');?></label> 
     58     </p> 
     59     <p class="clear form-note"> 
     60       <?php echo __('Copy, Paste, Paste Text, Paste from Word');?> 
     61     </p> 
     62      </div> 
     63      <?php endif;?> 
    5764 
    58                     <p> 
    59                          <input type="hidden" name="p" value="dcCKEditor"/> 
    60                          <?php echo $core->formNonce();?> 
    61                          <input type="submit" name="saveconfig" value="<?php echo __('Save configuration');?>" /> 
    62                     </p> 
    63                </form> 
    64           <?php endif;?> 
     65      <p> 
     66     <input type="hidden" name="p" value="dcCKEditor"/> 
     67     <?php echo $core->formNonce();?> 
     68     <input type="submit" name="saveconfig" value="<?php echo __('Save configuration');?>" /> 
     69      </p> 
     70    </form> 
     71    <?php endif;?> 
    6572 
    66           <?php dcPage::helpBlock('dcCKEditor');?> 
    67      </body> 
     73    <?php dcPage::helpBlock('dcCKEditor');?> 
     74  </body> 
    6875</html> 
Note: See TracChangeset for help on using the changeset viewer.

Sites map