Skip to content

Commit e8a164c

Browse files
committed
First dirty try of usage
1 parent 2bef25a commit e8a164c

4 files changed

Lines changed: 24 additions & 103 deletions

File tree

controller/main.php

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@ class main
6666
/** @var \phpbb\captcha\factory */
6767
protected $captcha_factory;
6868

69-
/** @var string */
70-
protected $geshi_lang;
71-
7269
/** @var string */
7370
protected $pastebin_table;
7471

@@ -105,7 +102,6 @@ public function __construct(
105102
\phpbbde\pastebin\functions\pastebin $pastebin,
106103
$root_path,
107104
$php_ext,
108-
$geshi_lang,
109105
$pastebin_table)
110106
{
111107
$this->auth = $auth;
@@ -125,7 +121,6 @@ public function __construct(
125121
$this->captcha_factory = $captcha_factory;
126122

127123
$this->pastebin_table = $pastebin_table;
128-
$this->geshi_lang = $geshi_lang;
129124
}
130125

131126
public function handle()
@@ -294,10 +289,10 @@ private function display_pb()
294289
$error[] = $this->language->lang('PASTEBIN_ERR_NO_TITLE');
295290
}
296291

297-
if (!$this->util->geshi_check($data['snippet_highlight']))
292+
/*if (!$this->util->geshi_check($data['snippet_highlight']))
298293
{
299294
$data['snippet_highlight'] = 'text';
300-
}
295+
}*/
301296

302297
$filedata = $this->request->file('fileupload');
303298

@@ -415,21 +410,15 @@ private function display_pb()
415410

416411
$highlight = ($this->request->is_set('highlight')) ? $this->request->variable('highlight', '') : $data['snippet_highlight'];
417412

418-
if (!$this->util->geshi_check($highlight))
419-
{
420-
$highlight = 'php';
421-
}
422-
423413
$code = $snippet_text;
424414

425-
$geshi = new \GeSHi($code, $highlight, $this->util->geshi_dir);
426-
$geshi->set_header_type(GESHI_HEADER_NONE);
427-
$geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS, 100);
428-
429-
$code = $geshi->parse_code();
415+
$highlighter = new \Tempest\Highlight\Highlighter();
416+
// TODO: Add option to change language used at this point html,css etc.
417+
$code = $highlighter->parse($code, 'php');
430418

431419
$snippet_text_display = &$code;
432420

421+
433422
$s_hidden_fields = array_merge($s_hidden_fields, array(
434423
's' => $snippet_id,
435424
));

functions/pastebin.php

Lines changed: 14 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -38,90 +38,21 @@ function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\user $user, $
3838
$this->empty_data();
3939

4040
$this->file_ext = array(
41-
'text' => 'txt',
42-
'php' => 'php',
43-
'sql' => 'sql',
44-
'html4strict' => 'htm',
45-
'css' => 'css',
46-
'javascript' => 'js',
47-
'java' => 'java',
48-
'xml' => 'xml',
49-
'asp' => 'asp',
50-
'c' => 'c',
51-
'cpp' => 'cpp',
52-
'csharp' => 'cs',
53-
'perl' => 'pl',
54-
'vb' => 'vbs',
55-
'diff' => 'diff',
56-
'robots' => 'txt',
57-
'smarty' => 'html',
58-
59-
'actionscript' => 'as',
60-
'ada' => 'ada',
61-
'apache' => 'txt',
62-
'applescript' => 'scrpt',
63-
'asm' => 'asm',
64-
'autoit' => 'txt',
65-
'bash' => 'sh',
66-
'blitzbasic' => 'bas',
67-
'bnf' => 'bnf',
68-
'c_mac' => 'c',
69-
'caddcl' => 'dcl',
70-
'cadlisp' => 'lisp',
71-
'cfdg' => 'cfd',
72-
'cfm' => 'cfm',
73-
'cpp-qt' => 'cpp',
74-
'css-gen.cfg' => 'cfg',
75-
'd' => 'd',
76-
'delphi' => 'dpr',
77-
'div' => 'div',
78-
'dos' => 'bat',
79-
'eiffel' => 'E',
80-
'fortran' => 'F',
81-
'freebasic' => 'bas',
82-
'gml' => 'gml',
83-
'groovy' => 'groovy',
84-
'idl' => 'idl',
85-
'ini' => 'ini',
86-
'inno' => 'ino',
87-
'io' => 'io',
88-
'java5' => 'java',
89-
'latex' => 'tex',
90-
'lisp' => 'lsp',
91-
'lua' => 'lua',
92-
'matlab' => 'm',
93-
'mirc' => 'mrc',
94-
'mpasm' => 'asm',
95-
'mysql' => 'sql',
96-
'nsis' => 'nsh',
97-
'objc' => 'C',
98-
'ocaml-brief' => 'ml',
99-
'ocaml' => 'ml',
100-
'oobas' => 'bas',
101-
'oracle8' => 'sql',
102-
'pascal' => 'p',
103-
'php-brief' => 'php',
104-
'ruby' => 'rb',
105-
'sas' => 'sas',
106-
'scheme' => 's',
107-
'sdlbasic' => 'bas',
108-
'smalltalk' => 'st',
109-
'tcl' => 'tcl',
110-
'thinbasic' => 'bas',
111-
'tsql' => 'sql',
112-
'plsql' => 'sql',
113-
'python' => 'py',
114-
'qbasic' => 'bas',
115-
'rails' => 'rb',
116-
'reg' => 'reg',
117-
'vbnet' => 'vbs',
118-
'vhdl' => 'vhdl',
119-
'visualfoxpro' => 'fky',
120-
'winbatch' => 'bat',
121-
'xpp' => 'xpp',
122-
'z80' => 'z80',
41+
'base' => '',
42+
'blade' => '',
43+
'css' => 'css',
44+
'DocComment' => '',
45+
'gdscript' => '',
46+
'html' => 'html',
47+
'javascript' => 'js',
48+
'json' => 'json',
49+
'php' => 'php',
50+
'mysql' => 'sql',
51+
'text' => 'txt',
52+
'twig' => 'html',
53+
'xml' => 'xml',
54+
'yaml' => 'yml',
12355
);
124-
12556
}
12657

12758
/**

functions/utility.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ function highlight_select($default = 'text')
7979
'base',
8080
'blade',
8181
'css',
82-
'doccoment',
82+
'doccomment',
8383
'gdscript',
8484
'javascript',
8585
'json',
@@ -90,9 +90,9 @@ function highlight_select($default = 'text')
9090
'yaml',
9191
);
9292
// Make no highlighting as text as default
93-
if (!in_array($default, $this->geshi_list))
93+
if ($default)
9494
{
95-
$default = 'text';
95+
9696
}
9797

9898
$output = '';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
{% INCLUDECSS '@phpbbde_pastebin/pastebin.css' %}
2+
{% INCLUDECSS './ext/phpbbde/pastebin/vendor/tempest/highlight/src/Themes/github-light-default.css' %}

0 commit comments

Comments
 (0)