Dotclear

Changeset 948:206fd3d17d64


Ignore:
Timestamp:
11/01/12 07:54:41 (13 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Add syntax color option to theme editor plugin, using CodeMirror? ( http://codemirror.net/), fixes #628

Files:
9 added
4 edited

Legend:

Unmodified
Added
Removed
  • locales/fr/plugins.po

    r945 r948  
    14071407msgstr "Éditeur de thème" 
    14081408 
     1409msgid "Syntax color" 
     1410msgstr "Coloration syntaxique" 
     1411 
    14091412msgid "No file" 
    14101413msgstr "Aucun fichier" 
  • plugins/themeEditor/_admin.php

    r270 r948  
    1616} 
    1717 
    18 $core->addBehavior('adminCurrentThemeDetails','theme_editor_details'); 
     18$core->addBehavior('adminCurrentThemeDetails', array('themeEditorBehaviors','theme_editor_details')); 
    1919 
    20 function theme_editor_details($core,$id) 
     20$core->addBehavior('adminBeforeUserOptionsUpdate',array('themeEditorBehaviors','adminBeforeUserUpdate')); 
     21$core->addBehavior('adminPreferencesForm',array('themeEditorBehaviors','adminPreferencesForm')); 
     22 
     23class themeEditorBehaviors 
    2124{ 
    22      if ($id != 'default' && $core->auth->isSuperAdmin()) { 
    23           return '<p><a href="plugin.php?p=themeEditor" class="button">'.__('Theme Editor').'</a></p>'; 
     25     function theme_editor_details($core,$id) 
     26     { 
     27          if ($id != 'default' && $core->auth->isSuperAdmin()) { 
     28               return '<p><a href="plugin.php?p=themeEditor" class="button">'.__('Theme Editor').'</a></p>'; 
     29          } 
     30     } 
     31 
     32     public static function adminBeforeUserUpdate($cur,$userID) 
     33     { 
     34          global $core; 
     35 
     36          // Get and store user's prefs for plugin options 
     37          $core->auth->user_prefs->addWorkspace('interface'); 
     38          try { 
     39               $core->auth->user_prefs->interface->put('colorsyntax',!empty($_POST['colorsyntax']),'boolean'); 
     40          }  
     41          catch (Exception $e) 
     42          { 
     43               $core->error->add($e->getMessage()); 
     44          } 
     45     } 
     46      
     47     public static function adminPreferencesForm($core) 
     48     { 
     49          // Add fieldset for plugin options 
     50          $core->auth->user_prefs->addWorkspace('interface'); 
     51 
     52          echo 
     53          '<fieldset><legend>'.__('Theme Editor').'</legend>'. 
     54           
     55          '<p><label for"colorsyntax" class="classic">'. 
     56          form::checkbox('colorsyntax',1,$core->auth->user_prefs->interface->colorsyntax).' '. 
     57          __('Syntax color').'</label></p>'. 
     58 
     59          '<br class="clear" />'. //Opera sucks 
     60          '</fieldset>'; 
    2461     } 
    2562} 
  • plugins/themeEditor/index.php

    r500 r948  
    1515 
    1616$file_default = $file = array('c'=>null, 'w'=>false, 'type'=>null, 'f'=>null, 'default_file'=>false); 
     17 
     18# Get interface setting 
     19$core->auth->user_prefs->addWorkspace('interface'); 
     20$user_ui_colorsyntax = $core->auth->user_prefs->interface->colorsyntax; 
    1721 
    1822# Loading themes 
     
    6266  <?php echo dcPage::jsVar('dotclear.msg.document_saved',__("Document saved")); ?> 
    6367  <?php echo dcPage::jsVar('dotclear.msg.error_occurred',__("An error occurred:")); ?> 
     68  <?php echo dcPage::jsVar('dotclear.colorsyntax',$user_ui_colorsyntax); ?> 
    6469  //]]> 
    6570  </script> 
    6671  <script type="text/javascript" src="index.php?pf=themeEditor/script.js"></script> 
     72<?php if ($user_ui_colorsyntax) { ?> 
     73  <link rel="stylesheet" type="text/css" href="index.php?pf=themeEditor/codemirror/codemirror.css" /> 
     74  <link rel="stylesheet" type="text/css" href="index.php?pf=themeEditor/codemirror.css" /> 
     75  <script type="text/JavaScript" src="index.php?pf=themeEditor/codemirror/codemirror.js"></script> 
     76  <script type="text/JavaScript" src="index.php?pf=themeEditor/codemirror/xml.js"></script> 
     77  <script type="text/JavaScript" src="index.php?pf=themeEditor/codemirror/javascript.js"></script> 
     78  <script type="text/JavaScript" src="index.php?pf=themeEditor/codemirror/css.js"></script> 
     79  <script type="text/JavaScript" src="index.php?pf=themeEditor/codemirror/php.js"></script> 
     80  <script type="text/JavaScript" src="index.php?pf=themeEditor/codemirror/htmlmixed.js"></script> 
     81<?php } ?> 
    6782</head> 
    6883 
     
    108123     echo 
    109124     '</fieldset></form>'; 
     125 
     126     if ($user_ui_colorsyntax) { 
     127          $editorMode = (!empty($_REQUEST['css']) ? "css" : (!empty($_REQUEST['js']) ? "javascript" : "text/html")); 
     128          echo  
     129          '<script> 
     130          var editor = CodeMirror.fromTextArea(document.getElementById("file_content"), { 
     131               mode: "'.$editorMode.'", 
     132                    tabMode: "indent", 
     133                    lineWrapping: "true", 
     134                    lineNumbers: "true", 
     135                    matchBrackets: "true" 
     136               }); 
     137         </script>'; 
     138     } 
    110139} 
    111140?> 
  • plugins/themeEditor/script.js

    r0 r948  
    55           
    66          var data = { 
    7                file_content: $(f).find('#file_content').get(0).value, 
     7               file_content: (!dotclear.colorsyntax ? $(f).find('#file_content').get(0).value : editor.getValue()), 
    88               xd_check: $(f).find('input[name="xd_check"]').get(0).value, 
    99               write: 1 
Note: See TracChangeset for help on using the changeset viewer.

Sites map