Dotclear


Ignore:
Timestamp:
03/08/18 17:58:39 (8 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Code formatting (PSR-2)

Location:
plugins/dcCKEditor/inc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • plugins/dcCKEditor/inc/_config.php

    r3090 r3730  
    1111# -- END LICENSE BLOCK ----------------------------------------- 
    1212 
    13 if (!defined('DC_CONTEXT_ADMIN')) { return; } 
     13if (!defined('DC_CONTEXT_ADMIN')) {return;} 
    1414 
    1515$dcckeditor_was_actived = $dcckeditor_active; 
    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_background_textcolor_button = (empty($_POST['dcckeditor_background_textcolor_button']))?false:true; 
    34                $core->blog->settings->dcckeditor->put('background_textcolor_button', $dcckeditor_background_textcolor_button, 'boolean'); 
     33            $dcckeditor_background_textcolor_button = (empty($_POST['dcckeditor_background_textcolor_button'])) ? false : true; 
     34            $core->blog->settings->dcckeditor->put('background_textcolor_button', $dcckeditor_background_textcolor_button, 'boolean'); 
    3535 
    36                $dcckeditor_cancollapse_button = (empty($_POST['dcckeditor_cancollapse_button']))?false:true; 
    37                $core->blog->settings->dcckeditor->put('cancollapse_button', $dcckeditor_cancollapse_button, 'boolean'); 
     36            $dcckeditor_cancollapse_button = (empty($_POST['dcckeditor_cancollapse_button'])) ? false : true; 
     37            $core->blog->settings->dcckeditor->put('cancollapse_button', $dcckeditor_cancollapse_button, 'boolean'); 
    3838 
    39                $dcckeditor_format_select = (empty($_POST['dcckeditor_format_select']))?false:true; 
    40                $core->blog->settings->dcckeditor->put('format_select', $dcckeditor_format_select, 'boolean'); 
     39            $dcckeditor_format_select = (empty($_POST['dcckeditor_format_select'])) ? false : true; 
     40            $core->blog->settings->dcckeditor->put('format_select', $dcckeditor_format_select, 'boolean'); 
    4141 
    42                // default tags : p;h1;h2;h3;h4;h5;h6;pre;address 
    43                $allowed_tags = array('p','h1','h2','h3','h4','h5','h6','pre','address'); 
    44                if (!empty($_POST['dcckeditor_format_tags'])) { 
    45                     $tags = explode(';', $_POST['dcckeditor_format_tags']); 
    46                     $new_tags = true; 
    47                     foreach ($tags as $tag) { 
    48                          if (!in_array($tag, $allowed_tags)) { 
    49                               $new_tags = false; 
    50                               break; 
    51                          } 
    52                     } 
    53                     if ($new_tags) { 
    54                          $dcckeditor_format_tags = $_POST['dcckeditor_format_tags']; 
    55                     } 
    56                } else { 
    57                     $dcckeditor_format_tags = 'p;h1;h2;h3;h4;h5;h6;pre;address'; 
    58                } 
    59                $core->blog->settings->dcckeditor->put('format_tags', $dcckeditor_format_tags, 'string'); 
     42            // default tags : p;h1;h2;h3;h4;h5;h6;pre;address 
     43            $allowed_tags = array('p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'pre', 'address'); 
     44            if (!empty($_POST['dcckeditor_format_tags'])) { 
     45                $tags    = explode(';', $_POST['dcckeditor_format_tags']); 
     46                $new_tags = true; 
     47                foreach ($tags as $tag) { 
     48                    if (!in_array($tag, $allowed_tags)) { 
     49                        $new_tags = false; 
     50                        break; 
     51                    } 
     52                } 
     53                if ($new_tags) { 
     54                    $dcckeditor_format_tags = $_POST['dcckeditor_format_tags']; 
     55                } 
     56            } else { 
     57                $dcckeditor_format_tags = 'p;h1;h2;h3;h4;h5;h6;pre;address'; 
     58            } 
     59            $core->blog->settings->dcckeditor->put('format_tags', $dcckeditor_format_tags, 'string'); 
    6060 
     61            $dcckeditor_table_button = (empty($_POST['dcckeditor_table_button'])) ? false : true; 
     62            $core->blog->settings->dcckeditor->put('table_button', $dcckeditor_table_button, 'boolean'); 
    6163 
    62                $dcckeditor_table_button = (empty($_POST['dcckeditor_table_button']))?false:true; 
    63                $core->blog->settings->dcckeditor->put('table_button', $dcckeditor_table_button, 'boolean'); 
     64            $dcckeditor_clipboard_buttons = (empty($_POST['dcckeditor_clipboard_buttons'])) ? false : true; 
     65            $core->blog->settings->dcckeditor->put('clipboard_buttons', $dcckeditor_clipboard_buttons, 'boolean'); 
    6466 
    65                $dcckeditor_clipboard_buttons = (empty($_POST['dcckeditor_clipboard_buttons']))?false:true; 
    66                $core->blog->settings->dcckeditor->put('clipboard_buttons', $dcckeditor_clipboard_buttons, 'boolean'); 
     67            $dcckeditor_disable_native_spellchecker = (empty($_POST['dcckeditor_disable_native_spellchecker'])) ? false : true; 
     68            $core->blog->settings->dcckeditor->put('disable_native_spellchecker', $dcckeditor_disable_native_spellchecker, 'boolean'); 
     69        } 
    6770 
    68                $dcckeditor_disable_native_spellchecker = (empty($_POST['dcckeditor_disable_native_spellchecker']))?false:true; 
    69                $core->blog->settings->dcckeditor->put('disable_native_spellchecker', $dcckeditor_disable_native_spellchecker, 'boolean'); 
    70           } 
    71  
    72           dcPage::addSuccessNotice(__('The configuration has been updated.')); 
    73           http::redirect($p_url); 
    74      } catch(Exception $e) { 
    75           $core->error->add($e->getMessage()); 
    76      } 
     71        dcPage::addSuccessNotice(__('The configuration has been updated.')); 
     72        http::redirect($p_url); 
     73    } catch (Exception $e) { 
     74        $core->error->add($e->getMessage()); 
     75    } 
    7776} 
    7877 
    79 include dirname(__FILE__).'/../tpl/index.tpl'; 
     78include dirname(__FILE__) . '/../tpl/index.tpl'; 
  • plugins/dcCKEditor/inc/dc.ckeditor.behaviors.php

    r3669 r3730  
    1313class dcCKEditorBehaviors 
    1414{ 
    15     protected static $p_url = 'index.php?pf=dcCKEditor'; 
     15    protected static $p_url      = 'index.php?pf=dcCKEditor'; 
    1616    protected static $config_url = 'plugin.php?p=dcCKEditor&config=1'; 
    1717 
     
    2424     * @param syntax   <b>string</b> wanted syntax (xhtml) 
    2525     */ 
    26     public static function adminPostEditor($editor='',$context='',array $tags=array(),$syntax='xhtml') { 
    27         if (empty($editor) || $editor != 'dcCKEditor' || $syntax != 'xhtml') { return;} 
     26    public static function adminPostEditor($editor = '', $context = '', array $tags = array(), $syntax = 'xhtml') 
     27    { 
     28        if (empty($editor) || $editor != 'dcCKEditor' || $syntax != 'xhtml') {return;} 
    2829 
    2930        $config_js = self::$config_url; 
    3031        if (!empty($context)) { 
    31             $config_js .= '&context='.$context; 
     32            $config_js .= '&context=' . $context; 
    3233        } 
    3334 
    3435        $res = 
    35             '<script type="text/javascript">'."\n". 
    36             dcPage::jsVar('dotclear.ckeditor_context', $context). 
    37             'dotclear.ckeditor_tags_context = '.sprintf('{%s:["%s"]};'."\n", $context, implode('","', $tags)). 
    38             'var CKEDITOR_BASEPATH = "'.DC_ADMIN_URL.self::$p_url.'/js/ckeditor/";'."\n". 
    39             dcPage::jsVar('dotclear.admin_base_url', DC_ADMIN_URL). 
    40             dcPage::jsVar('dotclear.base_url', $GLOBALS['core']->blog->host). 
    41             dcPage::jsVar('dotclear.dcckeditor_plugin_url',DC_ADMIN_URL.self::$p_url). 
    42             'CKEDITOR_GETURL = function(resource) { 
    43                  // If this is not a full or absolute path. 
    44                  if ( resource.indexOf(":/") == -1 && resource.indexOf("/") !== 0 ) { 
    45                       resource = this.basePath + resource; 
    46                  } 
    47                  return resource; 
    48              };'."\n". 
    49             "dotclear.msg.img_select_title = '".html::escapeJS(__('Media chooser'))."'; "."\n". 
    50             "dotclear.msg.img_select_accesskey = '".html::escapeJS(__('m'))."'; "."\n". 
    51             "dotclear.msg.post_link_title = '".html::escapeJS(__('Link to an entry'))."'; "."\n". 
    52             "dotclear.msg.link_title = '".html::escapeJS(__('Link'))."'; "."\n". 
    53             "dotclear.msg.link_accesskey = '".html::escapeJS(__('l'))."'; "."\n". 
    54             "dotclear.msg.img_title = '".html::escapeJS(__('External image'))."'; "."\n". 
    55             "dotclear.msg.url_cannot_be_empty = '".html::escapeJS(__('URL field cannot be empty.'))."';"."\n". 
    56             "</script>\n". 
    57             dcPage::jsLoad(self::$p_url.'/js/ckeditor/ckeditor.js'). 
    58             dcPage::jsLoad(self::$p_url.'/js/ckeditor/adapters/jquery.js'). 
    59             dcPage::jsLoad($config_js); 
     36        '<script type="text/javascript">' . "\n" . 
     37        dcPage::jsVar('dotclear.ckeditor_context', $context) . 
     38        'dotclear.ckeditor_tags_context = ' . sprintf('{%s:["%s"]};' . "\n", $context, implode('","', $tags)) . 
     39        'var CKEDITOR_BASEPATH = "' . DC_ADMIN_URL . self::$p_url . '/js/ckeditor/";' . "\n" . 
     40        dcPage::jsVar('dotclear.admin_base_url', DC_ADMIN_URL) . 
     41        dcPage::jsVar('dotclear.base_url', $GLOBALS['core']->blog->host) . 
     42        dcPage::jsVar('dotclear.dcckeditor_plugin_url', DC_ADMIN_URL . self::$p_url) . 
     43        'CKEDITOR_GETURL = function(resource) { 
     44                // If this is not a full or absolute path. 
     45                if ( resource.indexOf(":/") == -1 && resource.indexOf("/") !== 0 ) { 
     46                    resource = this.basePath + resource; 
     47                } 
     48                return resource; 
     49             };' . "\n" . 
     50        "dotclear.msg.img_select_title = '" . html::escapeJS(__('Media chooser')) . "'; " . "\n" . 
     51        "dotclear.msg.img_select_accesskey = '" . html::escapeJS(__('m')) . "'; " . "\n" . 
     52        "dotclear.msg.post_link_title = '" . html::escapeJS(__('Link to an entry')) . "'; " . "\n" . 
     53        "dotclear.msg.link_title = '" . html::escapeJS(__('Link')) . "'; " . "\n" . 
     54        "dotclear.msg.link_accesskey = '" . html::escapeJS(__('l')) . "'; " . "\n" . 
     55        "dotclear.msg.img_title = '" . html::escapeJS(__('External image')) . "'; " . "\n" . 
     56        "dotclear.msg.url_cannot_be_empty = '" . html::escapeJS(__('URL field cannot be empty.')) . "';" . "\n" . 
     57        "</script>\n" . 
     58        dcPage::jsLoad(self::$p_url . '/js/ckeditor/ckeditor.js') . 
     59        dcPage::jsLoad(self::$p_url . '/js/ckeditor/adapters/jquery.js') . 
     60        dcPage::jsLoad($config_js); 
    6061 
    61           if ($GLOBALS['core']->auth->user_prefs->interface->htmlfontsize) { 
    62                $res .= 
    63                '<script type="text/javascript">'."\n". 
    64                dcPage::jsVar('dotclear_htmlFontSize',$GLOBALS['core']->auth->user_prefs->interface->htmlfontsize)."\n". 
    65                "</script>\n"; 
    66           } 
     62        if ($GLOBALS['core']->auth->user_prefs->interface->htmlfontsize) { 
     63            $res .= 
     64            '<script type="text/javascript">' . "\n" . 
     65            dcPage::jsVar('dotclear_htmlFontSize', $GLOBALS['core']->auth->user_prefs->interface->htmlfontsize) . "\n" . 
     66                "</script>\n"; 
     67        } 
    6768 
    68           return $res; 
    69      } 
    70  
    71     public static function adminPopupMedia($editor='') { 
    72         if (empty($editor) || $editor!='dcCKEditor') { return;} 
    73  
    74      return dcPage::jsLoad(self::$p_url.'/js/popup_media.js'); 
     69        return $res; 
    7570    } 
    7671 
    77     public static function adminPopupLink($editor='') { 
    78         if (empty($editor) || $editor!='dcCKEditor') { return;} 
     72    public static function adminPopupMedia($editor = '') 
     73    { 
     74        if (empty($editor) || $editor != 'dcCKEditor') {return;} 
    7975 
    80      return dcPage::jsLoad(self::$p_url.'/js/popup_link.js'); 
     76        return dcPage::jsLoad(self::$p_url . '/js/popup_media.js'); 
    8177    } 
    8278 
    83     public static function adminPopupPosts($editor='') { 
    84         if (empty($editor) || $editor!='dcCKEditor') { return;} 
     79    public static function adminPopupLink($editor = '') 
     80    { 
     81        if (empty($editor) || $editor != 'dcCKEditor') {return;} 
    8582 
    86      return dcPage::jsLoad(self::$p_url.'/js/popup_posts.js'); 
     83        return dcPage::jsLoad(self::$p_url . '/js/popup_link.js'); 
    8784    } 
    8885 
    89     public static function adminMediaURLParams($p) { 
     86    public static function adminPopupPosts($editor = '') 
     87    { 
     88        if (empty($editor) || $editor != 'dcCKEditor') {return;} 
     89 
     90        return dcPage::jsLoad(self::$p_url . '/js/popup_posts.js'); 
     91    } 
     92 
     93    public static function adminMediaURLParams($p) 
     94    { 
    9095        if (!empty($_GET['editor'])) { 
    9196            $p['editor'] = html::sanitizeURL($_GET['editor']); 
     
    9398    } 
    9499 
    95     public static function getTagsContext() { 
     100    public static function getTagsContext() 
     101    { 
    96102        return self::$tagsContext; 
    97103    } 
Note: See TracChangeset for help on using the changeset viewer.

Sites map