From fc719bca8175a7990757c8764e046d0c9526cbc9 Mon Sep 17 00:00:00 2001 From: Christian Date: Sun, 3 Jul 2016 18:06:19 +0200 Subject: [PATCH] * Added the ability to configure the favorite languages --- htdocs/application/config/config.php | 10 ++++++ htdocs/application/config/geshi_languages.php | 35 +++++++++---------- htdocs/application/models/Languages.php | 21 ++++++++--- 3 files changed, 43 insertions(+), 23 deletions(-) diff --git a/htdocs/application/config/config.php b/htdocs/application/config/config.php index d4f655b..f798d56 100644 --- a/htdocs/application/config/config.php +++ b/htdocs/application/config/config.php @@ -414,6 +414,16 @@ $config['rewrite_short_tags'] = FALSE; */ $config['proxy_ips'] = ''; +/* +|-------------------------------------------------------------------------- +| Favorite Languages +|-------------------------------------------------------------------------- +| +| The favorite languages, that's at the beginning of the list. +| +*/ +$config['favorite_languages'] = array('text', 'html5', 'css', 'javascript', 'php', 'python', 'ruby', + 'lua', 'bash', 'erlang', 'go', 'c', 'cpp', 'diff', 'latex', 'sql', 'xml'); /* End of file config.php */ /* Location: ./application/config/config.php */ diff --git a/htdocs/application/config/geshi_languages.php b/htdocs/application/config/geshi_languages.php index dec0437..37d435d 100644 --- a/htdocs/application/config/geshi_languages.php +++ b/htdocs/application/config/geshi_languages.php @@ -9,24 +9,6 @@ if (!defined('BASEPATH')) exit('No direct script access allowed'); //geshi languages $config['geshi_languages'] = array( - 'text' => 'Plain Text', - 'html5' => 'HTML5', - 'css' => 'CSS', - 'javascript' => 'JavaScript', - 'php' => 'PHP', - 'python' => 'Python', - 'ruby' => 'Ruby', - 'lua' => 'Lua', - 'bash' => 'Bash', - 'erlang' => 'Erlang', - 'go' => 'Go', - 'c' => 'C', - 'cpp' => 'C++', - 'diff' => 'Diff-output', - 'latex' => 'LaTeX', - 'sql' => 'SQL', - 'xml' => 'XML', - '' => '', // separator '4cs' => '4CS', '6502acme' => 'MOS 6502', '6502kickass' => 'MOS 6502 Kick Assembler', @@ -51,6 +33,7 @@ $config['geshi_languages'] = array( 'avisynth' => 'AviSynth', 'awk' => 'Awk', 'bascomavr' => 'BASCOM AVR', + 'bash' => 'Bash', 'basic4gl' => 'Basic4GL', 'bbcode' => 'BBCode', 'bf' => 'Brainfuck', @@ -58,9 +41,11 @@ $config['geshi_languages'] = array( 'blitzbasic' => 'BlitzBasic', 'bnf' => 'BNF (Backus-Naur form)', 'boo' => 'Boo', + 'c' => 'C', 'c_loadrunner' => 'C (for LoadRunner)', 'c_mac' => 'C for Macs', 'c_winapi' => 'C with WiAPI', + 'cpp' => 'C++', 'caddcl' => 'CAD DCL (Dialog Control Language)', 'cadlisp' => 'AutoCAD/IntelliCAD Lisp', 'cfdg' => 'CFDG', @@ -74,6 +59,7 @@ $config['geshi_languages'] = array( 'coffeescript' => 'CoffeeScript', 'cpp-winapi' => 'C++ with WinAPI', 'csharp' => 'C#', + 'css' => 'CSS', 'cuesheet' => 'Cuesheet', 'd' => 'D', 'dart' => 'Dart', @@ -81,6 +67,7 @@ $config['geshi_languages'] = array( 'dcl' => 'DCL', 'dcpu16' => 'DCPU/16 Assembly', 'delphi' => 'Delphi (Object Pascal)', + 'diff' => 'Diff-output', 'div' => 'DIV', 'dos' => 'DOS', 'dot' => 'dot', @@ -89,6 +76,7 @@ $config['geshi_languages'] = array( 'eiffel' => 'Eiffel', 'email' => 'Email (mbox/eml/RFC format)', 'epc' => 'Enerscript', + 'erlang' => 'Erlang', 'euphoria' => 'Euphoria', 'ezt' => 'EZT', 'f1' => 'Formula One', @@ -106,6 +94,7 @@ $config['geshi_languages'] = array( 'glsl' => 'glSlang', 'gml' => 'GML', 'gnuplot' => 'Gnuplot script', + 'go' => 'Go', 'groovy' => 'Groovy', 'gwbasic' => 'GwBasic', 'haskell' => 'Haskell', @@ -113,6 +102,7 @@ $config['geshi_languages'] = array( 'hicest' => 'HicEst', 'hq9plus' => 'HQ9+', 'html4strict' => 'HTML 4.01 strict', + 'html5' => 'HTML5', 'icon' => 'Icon', 'idl' => 'Unoidl', 'ini' => 'INI', @@ -123,12 +113,14 @@ $config['geshi_languages'] = array( 'j' => 'J', 'java' => 'Java', 'java5' => 'Java 5', + 'javascript' => 'JavaScript', 'jcl' => 'Job Control Language', 'jquery' => 'jQuery 1.3', //'kixtart' => 'PHP', 'klonec' => 'KLone with C', 'klonecpp' => 'KLone with C++', + 'latex' => 'LaTeX', 'lb' => 'Liberty BASIC', 'ldif' => 'LDIF', 'lisp' => 'Generic Lisp', @@ -141,6 +133,7 @@ $config['geshi_languages'] = array( 'lotusscript' => 'LotusScript', 'lscript' => 'Lightwave Script', 'lsl2' => 'Linden Scripting', + 'lua' => 'Lua', 'm68k' => 'Motorola 68000 Assembler', 'magiksf' => 'MagikSF', 'make' => 'Make', @@ -178,6 +171,7 @@ $config['geshi_languages'] = array( 'perl' => 'Perl', 'perl6' => 'Perl 6', 'pf' => 'OpenBSD packet filter', + 'php' => 'PHP', 'pic16' => 'PIC16 Assembler', 'pike' => 'Pike', 'pixelbender' => 'Pixel Bender 1.0', @@ -195,6 +189,7 @@ $config['geshi_languages'] = array( 'providex' => 'ProvideX', 'purebasic' => 'PureBasic', 'pys60' => 'Python for S60', + 'python' => 'Python', 'q' => 'q/kdb+', 'qbasic' => 'QBasic/QuickBASIC', 'qml' => 'QML', @@ -207,6 +202,7 @@ $config['geshi_languages'] = array( 'robots' => 'robots.txt', 'rpmspec' => 'RPM Spec', 'rsplus' => 'R', + 'ruby' => 'Ruby', 'rust' => 'Rust', 'sas' => 'SAS', 'scala' => 'Scala', @@ -218,11 +214,13 @@ $config['geshi_languages'] = array( 'smarty' => 'Smarty template', 'spark' => 'SPARK', 'sparql' => 'SPARQL', + 'sql' => 'SQL', 'standardml' => 'StandardML', 'stonescript' => 'StoneScript', 'systemverilog' => 'SystemVerilog IEEE 1800-2009(draft8)', 'tcl' => 'TCL/iTCL', 'teraterm' => 'Tera Term Macro', + 'text' => 'Plain Text', 'thinbasic' => 'thinBasic', 'tsql' => 'T-SQL', 'typoscript' => 'TypoScript', @@ -244,6 +242,7 @@ $config['geshi_languages'] = array( 'whois' => 'Whois response (RPSL format)', 'winbatch' => 'WinBatch', 'xbasic' => 'XBasic', + 'xml' => 'XML', 'xorg_conf' => 'xorg.conf', 'xpp' => 'Axapta/Dynamics Ax X++', 'yaml' => 'YAML', diff --git a/htdocs/application/models/Languages.php b/htdocs/application/models/Languages.php index 8575561..e93834a 100644 --- a/htdocs/application/models/Languages.php +++ b/htdocs/application/models/Languages.php @@ -16,8 +16,12 @@ class Languages extends CI_Model function __construct() { parent::__construct(); + $this->load->config('geshi_languages'); $this->geshi_languages = $this->config->item('geshi_languages'); + + $this->load->config('config'); + $this->favorite_languages = $this->config->item('favorite_languages'); } function valid_language($lang) @@ -28,13 +32,20 @@ class Languages extends CI_Model function get_languages() { $data = array(); + + if(is_array($this->favorite_languages)) + { + foreach ($this->favorite_languages as $key) + { + $data[$key] = $this->geshi_languages[$key]; + } + + $data["0"] = "-----------------"; + } + foreach ($this->geshi_languages as $key => $value) { - if ($key == '') - { - $data["0"] = "-----------------"; - } - else + if (!in_array($key, $a)) { $data[$key] = $value; }