From a993ee2a3cea5d98e7e22ed00506699ed14f87d0 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 2 Sep 2016 19:10:12 +0200 Subject: [PATCH] ace modes --- htdocs/application/config/ace_languages.php | 581 ++++++++++++++++++ htdocs/application/controllers/Main.php | 51 +- .../themes/default/views/defaults/footer.php | 5 + .../themes/default/views/view/view_footer.php | 9 +- 4 files changed, 632 insertions(+), 14 deletions(-) create mode 100644 htdocs/application/config/ace_languages.php diff --git a/htdocs/application/config/ace_languages.php b/htdocs/application/config/ace_languages.php new file mode 100644 index 0000000..ea80c18 --- /dev/null +++ b/htdocs/application/config/ace_languages.php @@ -0,0 +1,581 @@ + array( + 'mode' => 'htmlmixed', + 'js' => array( + array( + 'codemirror/mode/xml/xml.js' + ) , + array( + 'codemirror/mode/javascript/javascript.js' + ) , + array( + 'codemirror/mode/css/css.js' + ) , + array( + 'codemirror/mode/htmlmixed/htmlmixed.js' + ) , + ) , + ) , + 'css' => array( + 'mode' => 'css', + 'js' => array( + array( + 'codemirror/mode/css/css.js' + ) , + ) , + ) , + 'javascript' => array( + 'mode' => 'javascript', + 'js' => array( + array( + 'codemirror/mode/javascript/javascript.js' + ) , + ) , + ) , + 'php' => array( + 'mode' => 'php', + 'js' => array( + array( + 'codemirror/mode/xml/xml.js' + ) , + array( + 'codemirror/mode/javascript/javascript.js' + ) , + array( + 'codemirror/mode/css/css.js' + ) , + array( + 'codemirror/mode/clike/clike.js' + ) , + array( + 'codemirror/mode/php/php.js' + ) , + ) , + ) , + 'python' => array( + 'mode' => 'python', + 'js' => array( + array( + 'codemirror/mode/python/python.js' + ) , + ) , + ) , + 'ruby' => array( + 'mode' => 'ruby', + 'js' => array( + array( + 'codemirror/mode/ruby/ruby.js' + ) , + ) , + ) , + 'lua' => array( + 'mode' => 'text/x-lua', + 'js' => array( + array( + 'codemirror/mode/lua/lua.js' + ) , + ) , + ) , + 'bash' => array( + 'mode' => 'text/x-sh', + 'js' => array( + array( + 'codemirror/mode/shell/shell.js' + ) , + ) , + ) , + 'go' => array( + 'mode' => 'text/x-go', + 'js' => array( + array( + 'codemirror/mode/go/go.js' + ) , + ) , + ) , + 'c' => array( + 'mode' => 'text/x-csrc', + 'js' => array( + array( + 'codemirror/mode/clike/clike.js' + ) , + ) , + ) , + 'cpp' => array( + 'mode' => 'text/x-c++src', + 'js' => array( + array( + 'codemirror/mode/clike/clike.js' + ) , + ) , + ) , + 'diff' => array( + 'mode' => 'diff', + 'js' => array( + array( + 'codemirror/mode/diff/diff.js' + ) , + ) , + ) , + 'latex' => array( + 'mode' => 'stex', + 'js' => array( + array( + 'codemirror/mode/stex/stex.js' + ) , + ) , + ) , + 'sql' => array( + 'mode' => 'sql', + 'js' => array( + array( + 'codemirror/mode/sql/sql.js' + ) , + ) , + ) , + 'xml' => array( + 'mode' => 'xml', + 'js' => array( + array( + 'codemirror/mode/xml/xml.js' + ) , + ) , + ) , + 'text' => 'Plain Text', + '4cs' => '4CS', + '6502acme' => 'MOS 6502', + '6502kickass' => 'MOS 6502 Kick Assembler', + '6502tasm' => 'MOS 6502 TASM/64TASS', + '68000devpac' => 'Motorola 68000 Devpac Assembler', + 'abap' => 'ABAP', + 'apl' => array( + 'mode' => 'apl', + 'js' => array( + array( + 'codemirror/mode/apl/apl.js' + ) , + ) , + ) , + 'asterisk' => array( + 'mode' => 'asterisk', + 'js' => array( + array( + 'codemirror/mode/asterisk/asterisk.js' + ) , + ) , + ) , + 'actionscript' => 'Actionscript', + 'actionscript3' => 'ActionScript3', + 'ada' => 'Ada', + 'algol68' => 'ALGOL 68', + 'apache' => 'Apache', + 'applescript' => 'AppleScript', + 'apt_sources' => 'Apt sources.list', + 'asm' => 'x86 Assembler', + 'asp' => 'ASP', + 'autoconf' => 'autoconf', + 'autohotkey' => 'Autohotkey', + 'autoit' => 'AutoIT', + 'avisynth' => 'AviSynth', + 'awk' => 'Awk', + 'bascomavr' => 'BASCOM AVR', + 'basic4gl' => 'Basic4GL', + 'bf' => 'Brainfuck', + 'bibtex' => 'BibTeX', + 'blitzbasic' => 'BlitzBasic', + 'bnf' => 'BNF (Backus-Naur form)', + 'boo' => 'Boo', + 'c_loadrunner' => array( + 'mode' => 'text/x-csrc', + 'js' => array( + array( + 'codemirror/mode/clike/clike.js' + ) , + ) , + ) , + 'c_mac' => array( + 'mode' => 'text/x-csrc', + 'js' => array( + array( + 'codemirror/mode/clike/clike.js' + ) , + ) , + ) , + 'caddcl' => 'CAD DCL (Dialog Control Language)', + 'cadlisp' => 'AutoCAD/IntelliCAD Lisp', + 'cfdg' => 'CFDG', + 'cfm' => 'ColdFusion', + 'chaiscript' => 'ChaiScript', + 'cil' => 'CIL (Common Intermediate Language)', + 'clojure' => 'Clojure', + 'cmake' => 'CMake', + 'cobol' => 'COBOL', + 'coffeescript' => 'CoffeeScript', + 'coffeescript' => array( + 'mode' => 'text/x-coffeescript', + 'js' => array( + array( + 'codemirror/mode/coffeescript/coffeescript.js' + ) , + ) , + ) , + 'csharp' => array( + 'mode' => 'text/x-csharp', + 'js' => array( + array( + 'codemirror/mode/clike/clike.js' + ) , + ) , + ) , + 'cuesheet' => 'Cuesheet', + 'd' => array( + 'mode' => 'd', + 'js' => array( + array( + 'codemirror/mode/d/d.js' + ) , + ) , + ) , + 'dcs' => 'DCS', + 'delphi' => 'Delphi (Object Pascal)', + 'div' => 'DIV', + 'dos' => 'DOS', + 'dot' => 'dot', + 'e' => 'E', + 'ecmascript' => array( + 'mode' => 'javascript', + 'js' => array( + array( + 'codemirror/mode/javascript/javascript.js' + ) , + ) , + ) , + 'eiffel' => 'Eiffel', + 'email' => 'Email (mbox/eml/RFC format)', + 'epc' => 'Enerscript', + 'erlang' => array( + 'mode' => 'erlang', + 'js' => array( + array( + 'codemirror/mode/erlang/erlang.js' + ) , + ) , + ) , + 'euphoria' => 'Euphoria', + 'f1' => 'Formula One', + 'falcon' => 'Falcon', + 'fo' => 'fo', + 'fortran' => 'Fortran', + 'freebasic' => 'FreeBasic', + 'fsharp' => 'F#', + 'gambas' => 'GAMBAS', + 'gdb' => 'GDB', + 'genero' => 'Genero', + 'genie' => 'Genie', + 'gettext' => 'GNU Gettext .po/.pot', + 'glsl' => 'glSlang', + 'gml' => 'GML', + 'gnuplot' => 'Gnuplot script', + 'go' => array( + 'mode' => 'go', + 'js' => array( + array( + 'codemirror/mode/go/go.js' + ) , + ) , + ) , + 'groovy' => array( + 'mode' => 'text/x-groovy', + 'js' => array( + array( + 'codemirror/mode/groovy/groovy.js' + ) , + ) , + ) , + 'gwbasic' => 'GwBasic', + 'haskell' => array( + 'mode' => 'text/x-haskell', + 'js' => array( + array( + 'codemirror/mode/haskell/haskell.js' + ) , + ) , + ) , + 'haxe' => array( + 'mode' => 'text/x-haxe', + 'js' => array( + array( + 'codemirror/mode/haxe/haxe.js' + ) , + ) , + ) , + 'hicest' => 'HicEst', + 'hq9plus' => 'HQ9+', + 'html4strict' => array( + 'mode' => 'htmlmixed', + 'js' => array( + array( + 'codemirror/mode/xml/xml.js' + ) , + array( + 'codemirror/mode/javascript/javascript.js' + ) , + array( + 'codemirror/mode/css/css.js' + ) , + array( + 'codemirror/mode/htmlmixed/htmlmixed.js' + ) , + ) , + ) , + 'icon' => 'Icon', + 'idl' => 'Unoidl', + 'ini' => 'INI', + 'inno' => 'Inno Script', + 'intercal' => 'INTERCAL', + 'io' => 'Io', + 'j' => 'J', + 'java' => array( + 'mode' => 'text/x-java', + 'js' => array( + array( + 'codemirror/mode/clike/clike.js' + ) , + ) , + ) , + 'java5' => array( + 'mode' => 'text/x-java', + 'js' => array( + array( + 'codemirror/mode/clike/clike.js' + ) , + ) , + ) , + 'jquery' => array( + 'mode' => 'javascript', + 'js' => array( + array( + 'codemirror/mode/javascript/javascript.js' + ) , + ) , + ) , + + //'kixtart' => 'PHP', + 'klonec' => 'KLone with C', + 'klonecpp' => 'KLone with C++', + 'lb' => 'Liberty BASIC', + 'lisp' => 'Generic Lisp', + 'llvm' => 'LLVM', + 'locobasic' => 'Locomotive Basic (Amstrad CPC series)', + 'logtalk' => 'Logtalk', + 'lolcode' => 'LOLcode', + 'lotusformulas' => '@Formula/@Command', + 'lotusscript' => 'LotusScript', + 'lscript' => 'Lightwave Script', + 'lsl2' => 'Linden Scripting', + 'm68k' => 'Motorola 68000 Assembler', + 'magiksf' => 'MagikSF', + 'make' => 'Make', + 'mapbasic' => 'MapBasic', + 'matlab' => 'Matlab M-file', + 'mirc' => array( + 'mode' => 'mirc', + 'js' => array( + array( + 'codemirror/mode/mirc/mirc.js' + ) , + ) , + ) , + 'mmix' => 'MMIX Assembler', + 'modula2' => 'Modula-2', + 'modula3' => 'Modula-3', + 'mpasm' => 'Microchip Assembler', + 'mxml' => 'MXML', + 'mysql' => array( + 'mode' => 'sql', + 'js' => array( + array( + 'codemirror/mode/sql/sql.js' + ) , + ) , + ) , + 'newlisp' => 'newLISP', + 'nsis' => 'Nullsoft Scriptable Install System', + 'oberon2' => 'Oberon-2', + 'objc' => 'Objective-C', + 'objeck' => 'Objeck Programming Language', + 'ocaml' => 'OCaml (Objective Caml)', + 'ocaml' => array( + 'mode' => 'text/x-ocaml', + 'js' => array( + array( + 'codemirror/mode/ocaml/ocaml.js' + ) , + ) , + ) , + 'oobas' => 'OpenOffice.org Basic', + 'oracle11' => 'Oracle 11i', + 'oracle8' => 'Oracle 8', + 'oxygene' => 'Delphi Prism (Oxygene)', + 'oz' => 'Oz', + 'pascal' => array( + 'mode' => 'text/x-pascal', + 'js' => array( + array( + 'codemirror/mode/pascal/pascal.js' + ) , + ) , + ) , + 'pcre' => 'PCRE', + 'per' => 'Per (forms)', + 'perl' => array( + 'mode' => 'perl', + 'js' => array( + array( + 'codemirror/mode/perl/perl.js' + ) , + ) , + ) , + 'perl6' => array( + 'mode' => 'perl', + 'js' => array( + array( + 'codemirror/mode/perl/perl.js' + ) , + ) , + ) , + 'pf' => 'OpenBSD packet filter', + 'pic16' => 'PIC16 Assembler', + 'pike' => 'Pike', + 'pixelbender' => 'Pixel Bender 1.0', + 'pli' => 'PL/I', + 'plsql' => array( + 'mode' => 'sql', + 'js' => array( + array( + 'codemirror/mode/sql/sql.js' + ) , + ) , + ) , + 'postgresql' => 'PostgreSQL', + 'povray' => 'Povray', + 'powerbuilder' => 'PowerBuilder (PowerScript)', + 'powershell' => 'PowerShell', + 'proftpd' => 'ProFTPd', + 'progress' => 'Progress', + 'prolog' => 'Prolog', + 'properties' => array( + 'mode' => 'text/x-properties', + 'js' => array( + array( + 'codemirror/mode/properties/properties.js' + ) , + ) , + ) , + 'providex' => 'ProvideX', + 'purebasic' => 'PureBasic', + 'q' => array( + 'mode' => 'text/x-q', + 'js' => array( + array( + 'codemirror/mode/q/q.js' + ) , + ) , + ) , + 'qbasic' => 'QBasic/QuickBASIC', + 'rails' => 'Ruby (with Ruby on Rails Framework)', + 'rebol' => 'Rebol', + 'reg' => 'Microsoft Registry Editor', + 'robots' => 'robots.txt', + 'rpmspec' => 'RPM Spec', + 'rsplus' => 'R', + 'sas' => 'SAS', + 'scala' => array( + 'mode' => 'scala', + 'js' => array( + array( + 'codemirror/mode/clike/clike.js' + ) , + ) , + ) , + 'scheme' => array( + 'mode' => 'text/x-scheme', + 'js' => array( + array( + 'codemirror/mode/scheme/scheme.js' + ) , + ) , + ) , + 'scilab' => 'SciLab', + 'sdlbasic' => 'sdlBasic', + 'smalltalk' => 'Smalltalk', + 'smarty' => 'Smarty template', + 'systemverilog' => 'SystemVerilog IEEE 1800-2009(draft8)', + 'tcl' => array( + 'mode' => 'text/x-tcl', + 'js' => array( + array( + 'codemirror/mode/tcl/tcl.js' + ) , + ) , + ) , + 'teraterm' => 'Tera Term Macro', + 'thinbasic' => 'thinBasic', + 'tsql' => 'T-SQL', + 'typoscript' => 'TypoScript', + 'unicon' => 'Unicon', + 'uscript' => 'UnrealScript', + 'vala' => 'Vala', + 'vb' => array( + 'mode' => 'text/x-vb', + 'js' => array( + array( + 'codemirror/mode/vb/vb.js' + ) , + ) , + ) , + 'verilog' => array( + 'mode' => 'text/x-verilog', + 'js' => array( + array( + 'codemirror/mode/verilog/verilog.js' + ) , + ) , + ) , + 'vhdl' => 'VHDL', + 'vim' => 'Vim scripting', + 'visualfoxpro' => 'Visual FoxPro', + 'visualprolog' => 'Visual Prolog', + 'whitespace' => 'Whitespace', + 'whois' => 'Whois response (RPSL format)', + 'winbatch' => 'WinBatch', + 'xbasic' => 'XBasic', + 'xorg_conf' => 'xorg.conf', + 'xpp' => 'Axapta/Dynamics Ax X++', + 'yaml' => array( + 'mode' => 'text/x-yaml', + 'js' => array( + array( + 'codemirror/mode/yaml/yaml.js' + ) , + ) , + ) , + 'z80' => array( + 'mode' => 'text/x-z80', + 'js' => array( + array( + 'codemirror/mode/z80/z80.js' + ) , + ) , + ) , + 'zxbasic' => 'ZXBasic', +); diff --git a/htdocs/application/controllers/Main.php b/htdocs/application/controllers/Main.php index 595417b..655b5a3 100644 --- a/htdocs/application/controllers/Main.php +++ b/htdocs/application/controllers/Main.php @@ -316,23 +316,48 @@ class Main extends CI_Controller $this->load->model('languages'); $this->load->helper('form'); $data['languages'] = $this->languages->get_languages(); - - //codemirror languages - $this->load->config('codemirror_languages'); - $codemirror_languages = config_item('codemirror_languages'); - $data['codemirror_languages'] = $codemirror_languages; - - //codemirror modes - $cmm = array(); - foreach ($codemirror_languages as $geshi_name => $l) + + if (config_item('js_editor') == 'codemirror') { - - if (gettype($l) == 'array') + + //codemirror languages + $this->load->config('codemirror_languages'); + $codemirror_languages = config_item('codemirror_languages'); + $data['codemirror_languages'] = $codemirror_languages; + + //codemirror modes + $cmm = array(); + foreach ($codemirror_languages as $geshi_name => $l) { - $cmm[$geshi_name] = $l['mode']; + + if (gettype($l) == 'array') + { + $cmm[$geshi_name] = $l['mode']; + } } + $data['codemirror_modes'] = $cmm; + } + + if (config_item('js_editor') == 'ace') + { + + //ace languages + $this->load->config('ace_languages'); + $ace_languages = config_item('ace_languages'); + $data['ace_languages'] = $ace_languages; + + //ace modes + $acem = array(); + foreach ($ace_languages as $geshi_name => $l) + { + + if (gettype($l) == 'array') + { + $acem[$geshi_name] = $l['mode']; + } + } + $data['ace_modes'] = $acem; } - $data['codemirror_modes'] = $cmm; //recaptcha $data['use_recaptcha'] = $this->use_recaptcha; diff --git a/htdocs/themes/default/views/defaults/footer.php b/htdocs/themes/default/views/defaults/footer.php index 5262fe9..0e63d8a 100644 --- a/htdocs/themes/default/views/defaults/footer.php +++ b/htdocs/themes/default/views/defaults/footer.php @@ -10,6 +10,11 @@ if(isset($codemirror_modes)){ echo ''; } +//ace modes +if(isset($ace_modes)){ + echo ''; +} + //Javascript $this->carabiner->js('jquery.js'); $this->carabiner->js('jquery.timers.js'); diff --git a/htdocs/themes/default/views/view/view_footer.php b/htdocs/themes/default/views/view/view_footer.php index a19e55b..a8462dd 100644 --- a/htdocs/themes/default/views/view/view_footer.php +++ b/htdocs/themes/default/views/view/view_footer.php @@ -2,7 +2,14 @@ ' . json_encode($codemirror_modes) . ''; +if(isset($codemirror_modes)){ + echo ''; +} + +//ace modes +if(isset($ace_modes)){ + echo ''; +} //Javascript $this->carabiner->js('jquery.js');