PageRenderTime 40ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/syntax_highlighter/blocks/syntax_highlighter/controller.php

https://bitbucket.org/remolaubacher/concrete5-syntax-highlighter
PHP | 174 lines | 159 code | 15 blank | 0 comment | 1 complexity | 8bc390094ffe86267f1611afed25fc5e MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. defined('C5_EXECUTE') or die('Access Denied.');
  3. class SyntaxHighlighterBlockController extends BlockController {
  4. protected $btTable = 'btSyntaxHighlighter';
  5. protected $btInterfaceWidth = '600';
  6. protected $btInterfaceHeight = '465';
  7. public function getBlockTypeDescription() {
  8. return t("Insert an hightlighted code block.");
  9. }
  10. public function getBlockTypeName() {
  11. return t("Syntax Highlighter");
  12. }
  13. public function add() {
  14. $this->set('languages', $this->getLanguages());
  15. }
  16. public function edit() {
  17. $this->set('languages', $this->getLanguages());
  18. }
  19. public function getLanguages() {
  20. return array(
  21. 'avisynth' => 'AviSynth',
  22. 'bash' => 'Bash',
  23. 'basic4gl' => 'Basic4GL',
  24. 'bf' => 'Brainfuck',
  25. 'blitzbasic' => 'BlitzBasic',
  26. 'bnf' => 'bnf',
  27. 'boo' => 'Boo',
  28. 'c' => 'C',
  29. 'c_mac' => 'C (Mac)',
  30. 'caddcl' => 'CAD DCL',
  31. 'cadlisp' => 'CAD Lisp',
  32. 'cfdg' => 'CFDG',
  33. 'cfm' => 'ColdFusion',
  34. 'cil' => 'CIL',
  35. 'cmake' => 'CMake',
  36. 'cobol' => 'COBOL',
  37. 'cpp' => 'C++',
  38. 'cpp-qt' => 'C++ (QT)',
  39. 'csharp' => 'C#',
  40. 'css' => 'CSS',
  41. 'd' => 'D',
  42. 'dcs' => 'DCS',
  43. 'delphi' => 'Delphi',
  44. 'diff' => 'Diff',
  45. 'div' => 'DIV',
  46. 'dos' => 'DOS',
  47. 'dot' => 'dot',
  48. 'eiffel' => 'Eiffel',
  49. 'email' => 'eMail (mbox)',
  50. 'fo' => 'FO (abas-ERP)',
  51. 'fortran' => 'Fortran',
  52. 'freebasic' => 'FreeBasic',
  53. 'genero' => 'genero',
  54. 'gettext' => 'GNU Gettext',
  55. 'glsl' => 'glSlang',
  56. 'gml' => 'GML',
  57. 'gnuplot' => 'Gnuplot',
  58. 'groovy' => 'Groovy',
  59. 'haskell' => 'Haskell',
  60. 'hq9plus' => 'HQ9+',
  61. 'html4strict' => 'HTML',
  62. 'idl' => 'Uno Idl',
  63. 'ini' => 'INI',
  64. 'inno' => 'Inno',
  65. 'intercal' => 'INTERCAL',
  66. 'io' => 'Io',
  67. 'java' => 'Java',
  68. 'java5' => 'Java(TM) 2 Platform Standard Edition 5.0',
  69. 'javascript' => 'Javascript',
  70. 'kixtart' => 'KiXtart',
  71. 'klonec' => 'KLone C',
  72. 'klonecpp' => 'KLone C++',
  73. 'latex' => 'LaTeX',
  74. 'lisp' => 'Lisp',
  75. 'locobasic' => 'Locomotive Basic',
  76. 'lolcode' => 'LOLcode',
  77. 'lotusformulas' => 'Lotus Notes @Formulas',
  78. 'lotusscript' => 'LotusScript',
  79. 'lscript' => 'LScript',
  80. 'lsl2' => 'LSL2',
  81. 'lua' => 'Lua',
  82. 'm68k' => 'Motorola 68000 Assembler',
  83. 'make' => 'GNU make',
  84. 'matlab' => 'Matlab M',
  85. 'mirc' => 'mIRC Scripting',
  86. 'modula3' => 'Modula-3',
  87. 'mpasm' => 'Microchip Assembler',
  88. 'mxml' => 'MXML',
  89. 'mysql' => 'MySQL',
  90. 'nsis' => 'NSIS',
  91. 'oberon2' => 'Oberon-2',
  92. 'objc' => 'Objective-C',
  93. 'ocaml' => 'OCaml',
  94. 'ocaml-brief' => 'OCaml (brief)',
  95. 'oobas' => 'OpenOffice.org Basic',
  96. 'oracle11' => 'Oracle 11 SQL',
  97. 'oracle8' => 'Oracle 8 SQL',
  98. 'pascal' => 'Pascal',
  99. 'per' => 'per',
  100. 'perl' => 'Perl',
  101. 'php' => 'PHP',
  102. 'php-brief' => 'PHP (brief)',
  103. 'pic16' => 'PIC16',
  104. 'pixelbender' => 'Pixel Bender 1.0',
  105. 'plsql' => 'PL/SQL',
  106. 'povray' => 'POVRAY',
  107. 'powershell' => 'posh',
  108. 'progress' => 'Progress',
  109. 'prolog' => 'Prolog',
  110. 'properties' => 'PROPERTIES',
  111. 'providex' => 'ProvideX',
  112. 'python' => 'Python',
  113. 'qbasic' => 'QBasic/QuickBASIC',
  114. 'qbasic' => 'QBasic/QuickBASIC',
  115. 'rails' => 'Rails',
  116. 'rebol' => 'REBOL',
  117. 'reg' => 'Microsoft Registry',
  118. 'robots' => 'robots.txt',
  119. 'ruby' => 'Ruby',
  120. 'sas' => 'SAS',
  121. 'scala' => 'Scala',
  122. 'scheme' => 'Scheme',
  123. 'scilab' => 'SciLab',
  124. 'sdlbasic' => 'sdlBasic',
  125. 'smalltalk' => 'Smalltalk',
  126. 'smarty' => 'Smarty',
  127. 'sql' => 'SQL',
  128. 'tcl' => 'TCL',
  129. 'teraterm' => 'Tera Term Macro',
  130. 'text' => 'Text',
  131. 'thinbasic' => 'thinBasic',
  132. 'tsql' => 'T-SQL',
  133. 'typoscript' => 'TypoScript',
  134. 'vb' => 'Visual Basic',
  135. 'vbnet' => 'vb.net',
  136. 'verilog' => 'Verilog',
  137. 'vhdl' => 'VHDL',
  138. 'vim' => 'Vim Script',
  139. 'visualfoxpro' => 'Visual Fox Pro',
  140. 'visualprolog' => 'Visual Prolog',
  141. 'whitespace' => 'Whitespace',
  142. 'whois' => 'Whois (RPSL format)',
  143. 'winbatch' => 'Winbatch',
  144. 'xml' => 'XML',
  145. 'xorg_conf' => 'Xorg configuration',
  146. 'xpp' => 'X++',
  147. 'z80' => 'ZiLOG Z80 Assembler');
  148. }
  149. public function view() {
  150. Loader::library("geshi", "syntax_highlighter");
  151. $geshi = new GeSHi($this->code, $this->language);
  152. if ($this->showLineNumbers) {
  153. $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
  154. }
  155. $geshi->enable_strict_mode($this->strictMode);
  156. $geshi->set_tab_width($this->tabWidth);
  157. $this->set('highlightedCode', $geshi->parse_code());
  158. }
  159. }