Ignore:
Timestamp:
Sep 5, 2018, 4:02:55 PM (15 months ago)
Author:
marcimat@…
Message:

Et tant qu’à faire, on met à jour GESHI en 1.0.9

File:
1 edited

Legend:

Unmodified
Added
Removed
  • _plugins_/coloration_code/trunk/geshi/geshi.php

    r95058 r111500  
    3131 * @copyright  (C) 2004 - 2007 Nigel McNie, (C) 2007 - 2014 Benny Baumann
    3232 * @license    http://gnu.org/copyleft/gpl.html GNU GPL
    33  *
    3433 */
    3534
     
    4241
    4342/** The version of this GeSHi file */
    44 define('GESHI_VERSION', '1.0.8.12');
     43define('GESHI_VERSION', '1.0.9.0');
    4544
    4645// Define the root directory for the GeSHi code tree
     
    149148/** Used in language files to mark comments */
    150149define('GESHI_COMMENTS', 0);
    151 
    152 /** Used to work around missing PHP features **/
    153 define('GESHI_PHP_PRE_433', !(version_compare(PHP_VERSION, '4.3.3') === 1));
    154 
    155 /** make sure we can call stripos **/
    156 if (!function_exists('stripos')) {
    157     // the offset param of preg_match is not supported below PHP 4.3.3
    158     if (GESHI_PHP_PRE_433) {
    159         /**
    160          * @ignore
    161          */
    162         function stripos($haystack, $needle, $offset = null) {
    163             if (!is_null($offset)) {
    164                 $haystack = substr($haystack, $offset);
    165             }
    166             if (preg_match('/'. preg_quote($needle, '/') . '/', $haystack, $match, PREG_OFFSET_CAPTURE)) {
    167                 return $match[0][1];
    168             }
    169             return false;
    170         }
    171     }
    172     else {
    173         /**
    174          * @ignore
    175          */
    176         function stripos($haystack, $needle, $offset = null) {
    177             if (preg_match('/'. preg_quote($needle, '/') . '/', $haystack, $match, PREG_OFFSET_CAPTURE, $offset)) {
    178                 return $match[0][1];
    179             }
    180             return false;
    181         }
    182     }
    183 }
    184150
    185151/** some old PHP / PCRE subpatterns only support up to xxx subpatterns in
     
    254220 *
    255221 * @package   geshi
    256  * @author    Nigel McNie <nigel@geshi.org>, Benny Baumann <BenBE@omorphia.de>
     222 * @author    Nigel McNie <nigel@geshi.org>
     223 * @author    Benny Baumann <BenBE@omorphia.de>
    257224 * @copyright (C) 2004 - 2007 Nigel McNie, (C) 2007 - 2014 Benny Baumann
    258225 */
    259226class GeSHi {
    260     /**#@+
    261      * @access private
    262      */
     227
    263228    /**
    264229     * The source code to highlight
    265230     * @var string
    266231     */
    267     var $source = '';
     232    protected $source = '';
    268233
    269234    /**
     
    271236     * @var string
    272237     */
    273     var $language = '';
     238    protected $language = '';
    274239
    275240    /**
     
    277242     * @var array
    278243     */
    279     var $language_data = array();
     244    protected $language_data = array();
    280245
    281246    /**
     
    283248     * @var string
    284249     */
    285     var $language_path = GESHI_LANG_ROOT;
     250    protected $language_path = GESHI_LANG_ROOT;
    286251
    287252    /**
     
    290255     * @todo check err reporting works
    291256     */
    292     var $error = false;
     257    protected $error = false;
    293258
    294259    /**
     
    296261     * @var array
    297262     */
    298     var $error_messages = array(
     263    protected $error_messages = array(
    299264        GESHI_ERROR_NO_SUCH_LANG => 'GeSHi could not find the language {LANGUAGE} (using path {PATH})',
    300265        GESHI_ERROR_FILE_NOT_READABLE => 'The file specified for load_from_file was not readable',
     
    307272     * @var boolean
    308273     */
    309     var $strict_mode = false;
     274    protected $strict_mode = false;
    310275
    311276    /**
     
    313278     * @var boolean
    314279     */
    315     var $use_classes = false;
     280    protected $use_classes = false;
    316281
    317282    /**
     
    325290     * @var int
    326291     */
    327     var $header_type = GESHI_HEADER_PRE;
     292    protected $header_type = GESHI_HEADER_PRE;
    328293
    329294    /**
     
    331296     * @var array
    332297     */
    333     var $lexic_permissions = array(
     298    protected $lexic_permissions = array(
    334299        'KEYWORDS' =>    array(),
    335300        'COMMENTS' =>    array('MULTI' => true),
     
    348313     * @var double
    349314     */
    350     var $time = 0;
     315    protected $time = 0;
    351316
    352317    /**
     
    354319     * @var string
    355320     */
    356     var $header_content = '';
     321    protected $header_content = '';
    357322
    358323    /**
     
    360325     * @var string
    361326     */
    362     var $footer_content = '';
     327    protected $footer_content = '';
    363328
    364329    /**
     
    366331     * @var string
    367332     */
    368     var $header_content_style = '';
     333    protected $header_content_style = '';
    369334
    370335    /**
     
    372337     * @var string
    373338     */
    374     var $footer_content_style = '';
     339    protected $footer_content_style = '';
    375340
    376341    /**
     
    379344     * @var boolean
    380345     */
    381     var $force_code_block = false;
     346    protected $force_code_block = false;
    382347
    383348    /**
     
    385350     * @var array
    386351     */
    387     var $link_styles = array();
     352    protected $link_styles = array();
    388353
    389354    /**
     
    393358     * @todo REMOVE THIS FUNCTIONALITY!
    394359     */
    395     var $enable_important_blocks = false;
     360    protected $enable_important_blocks = false;
    396361
    397362    /**
     
    402367     * will be hard to implement in 1.2
    403368     */
    404     var $important_styles = 'font-weight: bold; color: red;'; // Styles for important parts of the code
     369    protected $important_styles = 'font-weight: bold; color: red;'; // Styles for important parts of the code
    405370
    406371    /**
     
    408373     * @var boolean
    409374     */
    410     var $add_ids = false;
     375    protected $add_ids = false;
    411376
    412377    /**
     
    414379     * @var array
    415380     */
    416     var $highlight_extra_lines = array();
     381    protected $highlight_extra_lines = array();
    417382
    418383    /**
     
    420385     * @var array
    421386     */
    422     var $highlight_extra_lines_styles = array();
     387    protected $highlight_extra_lines_styles = array();
    423388
    424389    /**
     
    426391     * @var string
    427392     */
    428     var $highlight_extra_lines_style = 'background-color: #ffc;';
     393    protected $highlight_extra_lines_style = 'background-color: #ffc;';
    429394
    430395    /**
     
    434399     * @var string
    435400     */
    436     var $line_ending = null;
     401    protected $line_ending = null;
    437402
    438403    /**
     
    440405     * @var int
    441406     */
    442     var $line_numbers_start = 1;
     407    protected $line_numbers_start = 1;
    443408
    444409    /**
     
    446411     * @var string
    447412     */
    448     var $overall_style = 'font-family:monospace;';
     413    protected $overall_style = 'font-family:monospace;';
    449414
    450415    /**
     
    452417     * @var string
    453418     */
    454     var $code_style = 'font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;';
     419    protected $code_style = 'font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;';
    455420
    456421    /**
     
    458423     * @var string
    459424     */
    460     var $overall_class = '';
     425    protected $overall_class = '';
    461426
    462427    /**
     
    464429     * @var string
    465430     */
    466     var $overall_id = '';
     431    protected $overall_id = '';
    467432
    468433    /**
     
    470435     * @var string
    471436     */
    472     var $line_style1 = 'font-weight: normal; vertical-align:top;';
     437    protected $line_style1 = 'font-weight: normal; vertical-align:top;';
    473438
    474439    /**
     
    476441     * @var string
    477442     */
    478     var $line_style2 = 'font-weight: bold; vertical-align:top;';
     443    protected $line_style2 = 'font-weight: bold; vertical-align:top;';
    479444
    480445    /**
     
    482447     * @var string
    483448     */
    484     var $table_linenumber_style = 'width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;';
     449    protected $table_linenumber_style = 'width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;';
    485450
    486451    /**
     
    488453     * @var boolean
    489454     */
    490     var $line_numbers = GESHI_NO_LINE_NUMBERS;
     455    protected $line_numbers = GESHI_NO_LINE_NUMBERS;
    491456
    492457    /**
     
    495460     * @var boolean
    496461     */
    497     var $allow_multiline_span = true;
     462    protected $allow_multiline_span = true;
    498463
    499464    /**
     
    501466     * @var int
    502467     */
    503     var $line_nth_row = 0;
     468    protected $line_nth_row = 0;
    504469
    505470    /**
     
    507472     * @var int
    508473     */
    509     var $tab_width = 8;
     474    protected $tab_width = 8;
    510475
    511476    /**
     
    513478     * @var int
    514479     */
    515     var $use_language_tab_width = false;
     480    protected $use_language_tab_width = false;
    516481
    517482    /**
     
    519484     * @var string
    520485     */
    521     var $link_target = '';
     486    protected $link_target = '';
    522487
    523488    /**
     
    526491     * @var string
    527492     */
    528     var $encoding = 'utf-8';
     493    protected $encoding = 'utf-8';
    529494
    530495    /**
     
    532497     * @var boolean
    533498     */
    534     var $keyword_links = true;
     499    protected $keyword_links = true;
    535500
    536501    /**
    537502     * Currently loaded language file
    538      * @var string
     503     * @var    string
    539504     * @since 1.0.7.22
    540505     */
    541     var $loaded_language = '';
     506    protected $loaded_language = '';
    542507
    543508    /**
    544509     * Wether the caches needed for parsing are built or not
    545510     *
    546      * @var bool
     511     * @var   bool
    547512     * @since 1.0.8
    548513     */
    549     var $parse_cache_built = false;
     514    protected $parse_cache_built = false;
    550515
    551516    /**
     
    561526     * </blockquote>
    562527     *
    563      * @var array
     528     * @var   array
    564529     * @since 1.0.8
    565530     */
    566     var $_kw_replace_group = 0;
    567     var $_rx_key = 0;
     531    protected $_kw_replace_group = 0;
     532    protected $_rx_key = 0;
    568533
    569534    /**
    570535     * some "callback parameters" for handle_multiline_regexps
    571536     *
    572      * @since 1.0.8
     537     * @since  1.0.8
    573538     * @access private
    574      * @var string
    575      */
    576     var $_hmr_before = '';
    577     var $_hmr_replace = '';
    578     var $_hmr_after = '';
    579     var $_hmr_key = 0;
    580 
    581     /**#@-*/
     539     * @var    string
     540     */
     541    protected $_hmr_before = '';
     542    protected $_hmr_replace = '';
     543    protected $_hmr_after = '';
     544    protected $_hmr_key = 0;
    582545
    583546    /**
    584547     * Creates a new GeSHi object, with source and language
    585548     *
    586      * @param string The source code to highlight
    587      * @param string The language to highlight the source with
    588      * @param string The path to the language file directory. <b>This
     549     * @param string $source   The source code to highlight
     550     * @param string $language The language to highlight the source with
     551     * @param string $path     The path to the language file directory. <b>This
    589552     *               is deprecated!</b> I've backported the auto path
    590553     *               detection from the 1.1.X dev branch, so now it
     
    595558     * @since 1.0.0
    596559     */
    597     function __construct($source = '', $language = '', $path = '') {
    598         if (!empty($source)) {
     560    public function __construct($source = '', $language = '', $path = '') {
     561        if ( is_string($source) && ($source !== '') ) {
    599562            $this->set_source($source);
    600563        }
    601         if (!empty($language)) {
     564        if ( is_string($language) && ($language !== '') ) {
    602565            $this->set_language($language);
    603566        }
     
    609572     *
    610573     * @return string
    611      * @since 1 0.8.11
    612      */
    613     function get_version()
     574     * @since  1.0.8.11
     575     */
     576    public function get_version()
    614577    {
    615578        return GESHI_VERSION;
     
    623586     * @since  1.0.0
    624587     */
    625     function error() {
     588    public function error() {
    626589        if ($this->error) {
    627590            //Put some template variables for debugging here ...
     
    647610     * @since  1.0.2
    648611     */
    649     function get_language_name() {
     612    public function get_language_name() {
    650613        if (GESHI_ERROR_NO_SUCH_LANG == $this->error) {
    651614            return $this->language_data['LANG_NAME'] . ' (Unknown Language)';
     
    657620     * Sets the source code for this object
    658621     *
    659      * @param string The source code to highlight
     622     * @param string $source The source code to highlight
    660623     * @since 1.0.0
    661624     */
    662     function set_source($source) {
     625    public function set_source($source) {
    663626        $this->source = $source;
    664627        $this->highlight_extra_lines = array();
     
    671634     *       if you need this set $force_reset = true
    672635     *
    673      * @param string The name of the language to use
     636     * @param string $language    The name of the language to use
     637     * @param bool   $force_reset
    674638     * @since 1.0.0
    675639     */
    676     function set_language($language, $force_reset = false) {
     640    public function set_language($language, $force_reset = false) {
     641        $this->error = false;
     642        $this->strict_mode = GESHI_NEVER;
     643
    677644        if ($force_reset) {
    678645            $this->loaded_language = false;
     
    693660        $this->language = $language;
    694661
    695         $this->error = false;
    696         $this->strict_mode = GESHI_NEVER;
    697 
    698662        //Check if we can read the desired file
    699663        if (!is_readable($file_name)) {
     
    711675     * geshi.php, NOT geshi.php itself.
    712676     *
    713      * @param string The path to the language directory
     677     * @param string $path The path to the language directory
    714678     * @since 1.0.0
    715679     * @deprecated The path to the language files should now be automatically
     
    718682     *             so this method will disappear in 1.2.0.
    719683     */
    720     function set_language_path($path) {
     684    public function set_language_path($path) {
    721685        if(strpos($path,':')) {
    722686            //Security Fix to prevent external directories using fopen wrappers.
     
    749713    /**
    750714     * Get supported langs or an associative array lang=>full_name.
    751      * @param boolean $longnames
     715     * @param boolean $full_names
    752716     * @return array
    753717     */
    754     function get_supported_languages($full_names=false)
     718    public function get_supported_languages($full_names=false)
    755719    {
    756720        // return array
     
    803767     * @return mixed
    804768     */
    805     function get_language_fullname($language)
     769    public function get_language_fullname($language)
    806770    {
    807771        //Clean up the language name to prevent malicious code injection
     
    840804     * should be outputted.
    841805     *
    842      * @param int The type of header to be used
     806     * @param int $type The type of header to be used
    843807     * @since 1.0.0
    844808     */
    845     function set_header_type($type) {
     809    public function set_header_type($type) {
    846810        //Check if we got a valid header type
    847811        if (!in_array($type, array(GESHI_HEADER_NONE, GESHI_HEADER_DIV,
     
    860824     * string of valid stylesheet declarations
    861825     *
    862      * @param string  The overall style for the outputted code block
    863      * @param boolean Whether to merge the styles with the current styles or not
     826     * @param string  $style             The overall style for the outputted code block
     827     * @param boolean $preserve_defaults Whether to merge the styles with the current styles or not
    864828     * @since 1.0.0
    865829     */
    866     function set_overall_style($style, $preserve_defaults = false) {
     830    public function set_overall_style($style, $preserve_defaults = false) {
    867831        if (!$preserve_defaults) {
    868832            $this->overall_style = $style;
     
    877841     * output
    878842     *
    879      * @param string The class name to use for this block of code
     843     * @param string $class The class name to use for this block of code
    880844     * @since 1.0.0
    881845     */
    882     function set_overall_class($class) {
     846    public function set_overall_class($class) {
    883847        $this->overall_class = $class;
    884848    }
     
    888852     * be used in a stylesheet to style this object's output
    889853     *
    890      * @param string The ID to use for this block of code
     854     * @param string $id The ID to use for this block of code
    891855     * @since 1.0.0
    892856     */
    893     function set_overall_id($id) {
     857    public function set_overall_id($id) {
    894858        $this->overall_id = $id;
    895859    }
     
    899863     * is off, calling this method with no arguments will turn it on
    900864     *
    901      * @param boolean Whether to turn classes on or not
     865     * @param boolean $flag Whether to turn classes on or not
    902866     * @since 1.0.0
    903867     */
    904     function enable_classes($flag = true) {
     868    public function enable_classes($flag = true) {
    905869        $this->use_classes = ($flag) ? true : false;
    906870    }
     
    917881     * GeSHi documentation for more information about this.
    918882     *
    919      * @param string  The style to use for actual code
    920      * @param boolean Whether to merge the current styles with the new styles
     883     * @param string  $style             The style to use for actual code
     884     * @param boolean $preserve_defaults Whether to merge the current styles with the new styles
    921885     * @since 1.0.2
    922886     */
    923     function set_code_style($style, $preserve_defaults = false) {
     887    public function set_code_style($style, $preserve_defaults = false) {
    924888        if (!$preserve_defaults) {
    925889            $this->code_style = $style;
     
    932896     * Sets the styles for the line numbers.
    933897     *
    934      * @param string The style for the line numbers that are "normal"
    935      * @param string|boolean If a string, this is the style of the line
     898     * @param string         $style1 The style for the line numbers that are "normal"
     899     * @param string|boolean $style2 If a string, this is the style of the line
    936900     *        numbers that are "fancy", otherwise if boolean then this
    937901     *        defines whether the normal styles should be merged with the
    938902     *        new normal styles or not
    939      * @param boolean If set, is the flag for whether to merge the "fancy"
     903     * @param boolean        $preserve_defaults If set, is the flag for whether to merge the "fancy"
    940904     *        styles with the current styles or not
    941905     * @since 1.0.2
    942906     */
    943     function set_line_style($style1, $style2 = '', $preserve_defaults = false) {
     907    public function set_line_style($style1, $style2 = '', $preserve_defaults = false) {
    944908        //Check if we got 2 or three parameters
    945909        if (is_bool($style2)) {
     
    971935     * 5th line will be fancy.
    972936     *
    973      * @param int How line numbers should be displayed
    974      * @param int Defines which lines are fancy
     937     * @param int $flag    How line numbers should be displayed
     938     * @param int $nth_row Defines which lines are fancy
    975939     * @since 1.0.0
    976940     */
    977     function enable_line_numbers($flag, $nth_row = 5) {
     941    public function enable_line_numbers($flag, $nth_row = 5) {
    978942        if (GESHI_NO_LINE_NUMBERS != $flag && GESHI_NORMAL_LINE_NUMBERS != $flag
    979943            && GESHI_FANCY_LINE_NUMBERS != $flag) {
     
    990954     * the code in an ordered list.
    991955     *
    992      * @param boolean Wether multiline spans are allowed or not
     956     * @param boolean $flag Wether multiline spans are allowed or not
    993957     * @since 1.0.7.22
    994958     */
    995     function enable_multiline_span($flag) {
     959    public function enable_multiline_span($flag) {
    996960        $this->allow_multiline_span = (bool) $flag;
    997961    }
     
    1003967     * @return bool
    1004968     */
    1005     function get_multiline_span() {
     969    public function get_multiline_span() {
    1006970        return $this->allow_multiline_span;
    1007971    }
     
    1012976     * user defined styles having priority
    1013977     *
    1014      * @param int     The key of the keyword group to change the styles of
    1015      * @param string  The style to make the keywords
    1016      * @param boolean Whether to merge the new styles with the old or just
     978     * @param int     $key               The key of the keyword group to change the styles of
     979     * @param string  $style             The style to make the keywords
     980     * @param boolean $preserve_defaults Whether to merge the new styles with the old or just
    1017981     *                to overwrite them
    1018982     * @since 1.0.0
    1019983     */
    1020     function set_keyword_group_style($key, $style, $preserve_defaults = false) {
     984    public function set_keyword_group_style($key, $style, $preserve_defaults = false) {
    1021985        //Set the style for this keyword group
    1022986        if('*' == $key) {
     
    10451009     * Turns highlighting on/off for a keyword group
    10461010     *
    1047      * @param int     The key of the keyword group to turn on or off
    1048      * @param boolean Whether to turn highlighting for that group on or off
     1011     * @param int     $key  The key of the keyword group to turn on or off
     1012     * @param boolean $flag Whether to turn highlighting for that group on or off
    10491013     * @since 1.0.0
    10501014     */
    1051     function set_keyword_group_highlighting($key, $flag = true) {
     1015    public function set_keyword_group_highlighting($key, $flag = true) {
    10521016        $this->lexic_permissions['KEYWORDS'][$key] = ($flag) ? true : false;
    10531017    }
     
    10581022     * user defined styles having priority
    10591023     *
    1060      * @param int     The key of the comment group to change the styles of
    1061      * @param string  The style to make the comments
    1062      * @param boolean Whether to merge the new styles with the old or just
     1024     * @param int     $key               The key of the comment group to change the styles of
     1025     * @param string  $style             The style to make the comments
     1026     * @param boolean $preserve_defaults Whether to merge the new styles with the old or just
    10631027     *                to overwrite them
    10641028     * @since 1.0.0
    10651029     */
    1066     function set_comments_style($key, $style, $preserve_defaults = false) {
     1030    public function set_comments_style($key, $style, $preserve_defaults = false) {
    10671031        if('*' == $key) {
    10681032            foreach($this->language_data['STYLES']['COMMENTS'] as $_key => $_value) {
     
    10851049     * Turns highlighting on/off for comment groups
    10861050     *
    1087      * @param int     The key of the comment group to turn on or off
    1088      * @param boolean Whether to turn highlighting for that group on or off
     1051     * @param int     $key  The key of the comment group to turn on or off
     1052     * @param boolean $flag Whether to turn highlighting for that group on or off
    10891053     * @since 1.0.0
    10901054     */
    1091     function set_comments_highlighting($key, $flag = true) {
     1055    public function set_comments_highlighting($key, $flag = true) {
    10921056        $this->lexic_permissions['COMMENTS'][$key] = ($flag) ? true : false;
    10931057    }
     
    10981062     * user defined styles having priority
    10991063     *
    1100      * @param string  The style to make the escape characters
    1101      * @param boolean Whether to merge the new styles with the old or just
    1102      *                to overwrite them
     1064     * @param string  $style             The style to make the escape characters
     1065     * @param boolean $preserve_defaults Whether to merge the new styles with the old or just
     1066     *                                   to overwrite them
     1067     * @param int     $group             Tells the group of symbols for which style should be set.
    11031068     * @since 1.0.0
    11041069     */
    1105     function set_escape_characters_style($style, $preserve_defaults = false, $group = 0) {
     1070    public function set_escape_characters_style($style, $preserve_defaults = false, $group = 0) {
    11061071        if (!$preserve_defaults) {
    11071072            $this->language_data['STYLES']['ESCAPE_CHAR'][$group] = $style;
     
    11141079     * Turns highlighting on/off for escaped characters
    11151080     *
    1116      * @param boolean Whether to turn highlighting for escape characters on or off
     1081     * @param boolean $flag Whether to turn highlighting for escape characters on or off
    11171082     * @since 1.0.0
    11181083     */
    1119     function set_escape_characters_highlighting($flag = true) {
     1084    public function set_escape_characters_highlighting($flag = true) {
    11201085        $this->lexic_permissions['ESCAPE_CHAR'] = ($flag) ? true : false;
    11211086    }
     
    11291094     * This method will be removed in 1.2.X
    11301095     *
    1131      * @param string  The style to make the brackets
    1132      * @param boolean Whether to merge the new styles with the old or just
     1096     * @param string  $style             The style to make the brackets
     1097     * @param boolean $preserve_defaults Whether to merge the new styles with the old or just
    11331098     *                to overwrite them
    11341099     * @since 1.0.0
    11351100     * @deprecated In favour of set_symbols_style
    11361101     */
    1137     function set_brackets_style($style, $preserve_defaults = false) {
     1102    public function set_brackets_style($style, $preserve_defaults = false) {
    11381103        if (!$preserve_defaults) {
    11391104            $this->language_data['STYLES']['BRACKETS'][0] = $style;
     
    11491114     * This method will be remove in 1.2.X
    11501115     *
    1151      * @param boolean Whether to turn highlighting for brackets on or off
     1116     * @param boolean $flag Whether to turn highlighting for brackets on or off
    11521117     * @since 1.0.0
    11531118     * @deprecated In favour of set_symbols_highlighting
    11541119     */
    1155     function set_brackets_highlighting($flag) {
     1120    public function set_brackets_highlighting($flag) {
    11561121        $this->lexic_permissions['BRACKETS'] = ($flag) ? true : false;
    11571122    }
     
    11621127     * user defined styles having priority
    11631128     *
    1164      * @param string  The style to make the symbols
    1165      * @param boolean Whether to merge the new styles with the old or just
    1166      *                to overwrite them
    1167      * @param int     Tells the group of symbols for which style should be set.
     1129     * @param string  $style             The style to make the symbols
     1130     * @param boolean $preserve_defaults Whether to merge the new styles with the old or just
     1131     *                                   to overwrite them
     1132     * @param int     $group             Tells the group of symbols for which style should be set.
    11681133     * @since 1.0.1
    11691134     */
    1170     function set_symbols_style($style, $preserve_defaults = false, $group = 0) {
     1135    public function set_symbols_style($style, $preserve_defaults = false, $group = 0) {
    11711136        // Update the style of symbols
    11721137        if (!$preserve_defaults) {
     
    11851150     * Turns highlighting on/off for symbols
    11861151     *
    1187      * @param boolean Whether to turn highlighting for symbols on or off
     1152     * @param boolean $flag Whether to turn highlighting for symbols on or off
    11881153     * @since 1.0.0
    11891154     */
    1190     function set_symbols_highlighting($flag) {
     1155    public function set_symbols_highlighting($flag) {
    11911156        // Update lexic permissions for this symbol group
    11921157        $this->lexic_permissions['SYMBOLS'] = ($flag) ? true : false;
     
    12011166     * user defined styles having priority
    12021167     *
    1203      * @param string  The style to make the escape characters
    1204      * @param boolean Whether to merge the new styles with the old or just
    1205      *                to overwrite them
    1206      * @param int     Tells the group of strings for which style should be set.
     1168     * @param string  $style             The style to make the escape characters
     1169     * @param boolean $preserve_defaults Whether to merge the new styles with the old or just
     1170     *                                   to overwrite them
     1171     * @param int     $group             Tells the group of strings for which style should be set.
    12071172     * @since 1.0.0
    12081173     */
    1209     function set_strings_style($style, $preserve_defaults = false, $group = 0) {
     1174    public function set_strings_style($style, $preserve_defaults = false, $group = 0) {
    12101175        if (!$preserve_defaults) {
    12111176            $this->language_data['STYLES']['STRINGS'][$group] = $style;
     
    12181183     * Turns highlighting on/off for strings
    12191184     *
    1220      * @param boolean Whether to turn highlighting for strings on or off
     1185     * @param boolean $flag Whether to turn highlighting for strings on or off
    12211186     * @since 1.0.0
    12221187     */
    1223     function set_strings_highlighting($flag) {
     1188    public function set_strings_highlighting($flag) {
    12241189        $this->lexic_permissions['STRINGS'] = ($flag) ? true : false;
    12251190    }
     
    12301195     * user defined styles having priority
    12311196     *
    1232      * @param string  The style to make the script blocks
    1233      * @param boolean Whether to merge the new styles with the old or just
    1234      *                to overwrite them
    1235      * @param int     Tells the group of script blocks for which style should be set.
     1197     * @param string  $style             The style to make the script blocks
     1198     * @param boolean $preserve_defaults Whether to merge the new styles with the old or just
     1199     *                                   to overwrite them
     1200     * @param int     $group             Tells the group of script blocks for which style should be set.
    12361201     * @since 1.0.8.4
    12371202     */
    1238     function set_script_style($style, $preserve_defaults = false, $group = 0) {
     1203    public function set_script_style($style, $preserve_defaults = false, $group = 0) {
    12391204        // Update the style of symbols
    12401205        if (!$preserve_defaults) {
     
    12501215     * user defined styles having priority
    12511216     *
    1252      * @param string  The style to make the numbers
    1253      * @param boolean Whether to merge the new styles with the old or just
    1254      *                to overwrite them
    1255      * @param int     Tells the group of numbers for which style should be set.
     1217     * @param string  $style             The style to make the numbers
     1218     * @param boolean $preserve_defaults Whether to merge the new styles with the old or just
     1219     *                                   to overwrite them
     1220     * @param int     $group             Tells the group of numbers for which style should be set.
    12561221     * @since 1.0.0
    12571222     */
    1258     function set_numbers_style($style, $preserve_defaults = false, $group = 0) {
     1223    public function set_numbers_style($style, $preserve_defaults = false, $group = 0) {
    12591224        if (!$preserve_defaults) {
    12601225            $this->language_data['STYLES']['NUMBERS'][$group] = $style;
     
    12671232     * Turns highlighting on/off for numbers
    12681233     *
    1269      * @param boolean Whether to turn highlighting for numbers on or off
     1234     * @param boolean $flag Whether to turn highlighting for numbers on or off
    12701235     * @since 1.0.0
    12711236     */
    1272     function set_numbers_highlighting($flag) {
     1237    public function set_numbers_highlighting($flag) {
    12731238        $this->lexic_permissions['NUMBERS'] = ($flag) ? true : false;
    12741239    }
     
    12811246     * user defined styles having priority
    12821247     *
    1283      * @param int     The key of the object splitter to change the styles of
    1284      * @param string  The style to make the methods
    1285      * @param boolean Whether to merge the new styles with the old or just
    1286      *                to overwrite them
     1248     * @param int     $key               The key of the object splitter to change the styles of
     1249     * @param string  $style             The style to make the methods
     1250     * @param boolean $preserve_defaults Whether to merge the new styles with the old or just
     1251     *                                   to overwrite them
    12871252     * @since 1.0.0
    12881253     */
    1289     function set_methods_style($key, $style, $preserve_defaults = false) {
     1254    public function set_methods_style($key, $style, $preserve_defaults = false) {
    12901255        if (!$preserve_defaults) {
    12911256            $this->language_data['STYLES']['METHODS'][$key] = $style;
     
    12981263     * Turns highlighting on/off for methods
    12991264     *
    1300      * @param boolean Whether to turn highlighting for methods on or off
     1265     * @param boolean $flag Whether to turn highlighting for methods on or off
    13011266     * @since 1.0.0
    13021267     */
    1303     function set_methods_highlighting($flag) {
     1268    public function set_methods_highlighting($flag) {
    13041269        $this->lexic_permissions['METHODS'] = ($flag) ? true : false;
    13051270    }
     
    13101275     * user defined styles having priority
    13111276     *
    1312      * @param string  The style to make the regular expression matches
    1313      * @param boolean Whether to merge the new styles with the old or just
    1314      *                to overwrite them
     1277     * @param string  $key               The style to make the regular expression matches
     1278     * @param boolean $style             Whether to merge the new styles with the old or just
     1279     *                                   to overwrite them
     1280     * @param bool    $preserve_defaults Whether to merge the new styles with the old or just
     1281     *                                to overwrite them
    13151282     * @since 1.0.0
    13161283     */
    1317     function set_regexps_style($key, $style, $preserve_defaults = false) {
     1284    public function set_regexps_style($key, $style, $preserve_defaults = false) {
    13181285        if (!$preserve_defaults) {
    13191286            $this->language_data['STYLES']['REGEXPS'][$key] = $style;
     
    13261293     * Turns highlighting on/off for regexps
    13271294     *
    1328      * @param int     The key of the regular expression group to turn on or off
    1329      * @param boolean Whether to turn highlighting for the regular expression group on or off
     1295     * @param int     $key  The key of the regular expression group to turn on or off
     1296     * @param boolean $flag Whether to turn highlighting for the regular expression group on or off
    13301297     * @since 1.0.0
    13311298     */
    1332     function set_regexps_highlighting($key, $flag) {
     1299    public function set_regexps_highlighting($key, $flag) {
    13331300        $this->lexic_permissions['REGEXPS'][$key] = ($flag) ? true : false;
    13341301    }
     
    13371304     * Sets whether a set of keywords are checked for in a case sensitive manner
    13381305     *
    1339      * @param int The key of the keyword group to change the case sensitivity of
    1340      * @param boolean Whether to check in a case sensitive manner or not
     1306     * @param int     $key  The key of the keyword group to change the case sensitivity of
     1307     * @param boolean $case Whether to check in a case sensitive manner or not
    13411308     * @since 1.0.0
    13421309     */
    1343     function set_case_sensitivity($key, $case) {
     1310    public function set_case_sensitivity($key, $case) {
    13441311        $this->language_data['CASE_SENSITIVE'][$key] = ($case) ? true : false;
    13451312    }
     
    13521319     *  - GESHI_CAPS_LOWER: convert all keywords to lowercase where found
    13531320     *
    1354      * @param int A constant specifying what to do with matched keywords
     1321     * @param int $case A constant specifying what to do with matched keywords
    13551322     * @since 1.0.1
    13561323     */
    1357     function set_case_keywords($case) {
     1324    public function set_case_keywords($case) {
    13581325        if (in_array($case, array(
    13591326            GESHI_CAPS_NO_CHANGE, GESHI_CAPS_UPPER, GESHI_CAPS_LOWER))) {
     
    13671334     * Widths below zero are ignored
    13681335     *
    1369      * @param int The tab width
     1336     * @param int $width The tab width
    13701337     * @since 1.0.0
    13711338     */
    1372     function set_tab_width($width) {
     1339    public function set_tab_width($width) {
    13731340        $this->tab_width = intval($width);
    13741341
     
    13831350     * Sets whether or not to use tab-stop width specifed by language
    13841351     *
    1385      * @param boolean Whether to use language-specific tab-stop widths
     1352     * @param boolean $use Whether to use language-specific tab-stop widths
    13861353     * @since 1.0.7.20
    13871354     */
    1388     function set_use_language_tab_width($use) {
     1355    public function set_use_language_tab_width($use) {
    13891356        $this->use_language_tab_width = (bool) $use;
    13901357    }
     
    13971364     * @since 1.0.7.20
    13981365     */
    1399     function get_real_tab_width() {
     1366    public function get_real_tab_width() {
    14001367        if (!$this->use_language_tab_width ||
    14011368            !isset($this->language_data['TAB_WIDTH'])) {
     
    14111378     * for more details on strict mode and where to use it.
    14121379     *
    1413      * @param boolean Whether to enable strict mode or not
     1380     * @param boolean $mode Whether to enable strict mode or not
    14141381     * @since 1.0.0
    14151382     */
    1416     function enable_strict_mode($mode = true) {
     1383    public function enable_strict_mode($mode = true) {
    14171384        if (GESHI_MAYBE == $this->language_data['STRICT_MODE_APPLIES']) {
    14181385            $this->strict_mode = ($mode) ? GESHI_ALWAYS : GESHI_NEVER;
     
    14271394     * @deprecated In favour of enable_highlighting
    14281395     */
    1429     function disable_highlighting() {
     1396    public function disable_highlighting() {
    14301397        $this->enable_highlighting(false);
    14311398    }
     
    14381405     *
    14391406     * @since 1.0.0
    1440      * @param boolean A flag specifying whether to enable or disable all highlighting
     1407     * @param boolean $flag A flag specifying whether to enable or disable all highlighting
    14411408     * @todo  Rewrite with array traversal
    14421409     */
    1443     function enable_highlighting($flag = true) {
     1410    public function enable_highlighting($flag = true) {
    14441411        $flag = $flag ? true : false;
    14451412        foreach ($this->lexic_permissions as $key => $value) {
     
    14611428     * name, or the empty string if it couldn't be found
    14621429     *
    1463      * @param string The extension to get a language name for
    1464      * @param array  A lookup array to use instead of the default one
     1430     * @param string $extension The extension to get a language name for
     1431     * @param array  $lookup    A lookup array to use instead of the default one
    14651432     * @since 1.0.5
    14661433     * @todo Re-think about how this method works (maybe make it private and/or make it
    14671434     *       a extension->lang lookup?)
    1468      */
    1469     static function get_language_name_from_extension( $extension, $lookup = array() ) {
     1435     * @return int|string
     1436     */
     1437    public static function get_language_name_from_extension( $extension, $lookup = array() ) {
    14701438        $extension = strtolower($extension);
    14711439
     
    15691537     * );</pre>
    15701538     *
    1571      * @param string The filename to load the source from
    1572      * @param array  A lookup array to use instead of the default one
     1539     * @param string $file_name The filename to load the source from
     1540     * @param array  $lookup    A lookup array to use instead of the default one
    15731541     * @todo Complete rethink of this and above method
    15741542     * @since 1.0.5
    15751543     */
    1576     function load_from_file($file_name, $lookup = array()) {
     1544    public function load_from_file($file_name, $lookup = array()) {
    15771545        if (is_readable($file_name)) {
    15781546            $this->set_source(file_get_contents($file_name));
     
    15861554     * Adds a keyword to a keyword group for highlighting
    15871555     *
    1588      * @param int    The key of the keyword group to add the keyword to
    1589      * @param string The word to add to the keyword group
     1556     * @param int    $key  The key of the keyword group to add the keyword to
     1557     * @param string $word The word to add to the keyword group
    15901558     * @since 1.0.0
    15911559     */
    1592     function add_keyword($key, $word) {
     1560    public function add_keyword($key, $word) {
    15931561        if (!is_array($this->language_data['KEYWORDS'][$key])) {
    15941562            $this->language_data['KEYWORDS'][$key] = array();
     
    16081576     * Removes a keyword from a keyword group
    16091577     *
    1610      * @param int    The key of the keyword group to remove the keyword from
    1611      * @param string The word to remove from the keyword group
    1612      * @param bool   Wether to automatically recompile the optimized regexp list or not.
     1578     * @param int    $key       The key of the keyword group to remove the keyword from
     1579     * @param string $word      The word to remove from the keyword group
     1580     * @param bool   $recompile Wether to automatically recompile the optimized regexp list or not.
    16131581     *               Note: if you set this to false and @see GeSHi->parse_code() was already called once,
    16141582     *               for the current language, you have to manually call @see GeSHi->optimize_keyword_group()
     
    16181586     * @since 1.0.0
    16191587     */
    1620     function remove_keyword($key, $word, $recompile = true) {
     1588    public function remove_keyword($key, $word, $recompile = true) {
    16211589        $key_to_remove = array_search($word, $this->language_data['KEYWORDS'][$key]);
    16221590        if ($key_to_remove !== false) {
     
    16331601     * Creates a new keyword group
    16341602     *
    1635      * @param int    The key of the keyword group to create
    1636      * @param string The styles for the keyword group
    1637      * @param boolean Whether the keyword group is case sensitive ornot
    1638      * @param array  The words to use for the keyword group
     1603     * @param int     $key            The key of the keyword group to create
     1604     * @param string  $styles         The styles for the keyword group
     1605     * @param boolean $case_sensitive Whether the keyword group is case sensitive ornot
     1606     * @param array   $words          The words to use for the keyword group
    16391607     * @since 1.0.0
    1640      */
    1641     function add_keyword_group($key, $styles, $case_sensitive = true, $words = array()) {
     1608     * @return bool
     1609     */
     1610    public function add_keyword_group($key, $styles, $case_sensitive = true, $words = array()) {
    16421611        $words = (array) $words;
    16431612        if  (empty($words)) {
     
    16561625            $this->optimize_keyword_group($key);
    16571626        }
     1627        return true;
    16581628    }
    16591629
     
    16611631     * Removes a keyword group
    16621632     *
    1663      * @param int   The key of the keyword group to remove
     1633     * @param int $key The key of the keyword group to remove
    16641634     * @since 1.0.0
    16651635     */
    1666     function remove_keyword_group ($key) {
     1636    public function remove_keyword_group ($key) {
    16671637        //Remove the keyword group internally
    16681638        unset($this->language_data['KEYWORDS'][$key]);
     
    16781648     * compile optimized regexp list for keyword group
    16791649     *
    1680      * @param int   The key of the keyword group to compile & optimize
     1650     * @param int $key The key of the keyword group to compile & optimize
    16811651     * @since 1.0.8
    16821652     */
    1683     function optimize_keyword_group($key) {
     1653    public function optimize_keyword_group($key) {
    16841654        $this->language_data['CACHED_KEYWORD_LISTS'][$key] =
    16851655            $this->optimize_regexp_list($this->language_data['KEYWORDS'][$key]);
     
    17081678     * Sets the content of the header block
    17091679     *
    1710      * @param string The content of the header block
     1680     * @param string $content The content of the header block
    17111681     * @since 1.0.2
    17121682     */
    1713     function set_header_content($content) {
     1683    public function set_header_content($content) {
    17141684        $this->header_content = $content;
    17151685    }
     
    17181688     * Sets the content of the footer block
    17191689     *
    1720      * @param string The content of the footer block
     1690     * @param string $content The content of the footer block
    17211691     * @since 1.0.2
    17221692     */
    1723     function set_footer_content($content) {
     1693    public function set_footer_content($content) {
    17241694        $this->footer_content = $content;
    17251695    }
     
    17281698     * Sets the style for the header content
    17291699     *
    1730      * @param string The style for the header content
     1700     * @param string $style The style for the header content
    17311701     * @since 1.0.2
    17321702     */
    1733     function set_header_content_style($style) {
     1703    public function set_header_content_style($style) {
    17341704        $this->header_content_style = $style;
    17351705    }
     
    17381708     * Sets the style for the footer content
    17391709     *
    1740      * @param string The style for the footer content
     1710     * @param string $style The style for the footer content
    17411711     * @since 1.0.2
    17421712     */
    1743     function set_footer_content_style($style) {
     1713    public function set_footer_content_style($style) {
    17441714        $this->footer_content_style = $style;
    17451715    }
     
    17491719     * the highlighted code or not
    17501720     *
    1751      * @param boolean Tells whether to enable or disable this feature
     1721     * @param boolean $flag Tells whether to enable or disable this feature
    17521722     * @since 1.0.7.20
    17531723     */
    1754     function enable_inner_code_block($flag) {
     1724    public function enable_inner_code_block($flag) {
    17551725        $this->force_code_block = (bool)$flag;
    17561726    }
     
    17591729     * Sets the base URL to be used for keywords
    17601730     *
    1761      * @param int The key of the keyword group to set the URL for
    1762      * @param string The URL to set for the group. If {FNAME} is in
    1763      *               the url somewhere, it is replaced by the keyword
    1764      *               that the URL is being made for
     1731     * @param int    $group The key of the keyword group to set the URL for
     1732     * @param string $url   The URL to set for the group. If {FNAME} is in
     1733     *                      the url somewhere, it is replaced by the keyword
     1734     *                      that the URL is being made for
    17651735     * @since 1.0.2
    17661736     */
    1767     function set_url_for_keyword_group($group, $url) {
     1737    public function set_url_for_keyword_group($group, $url) {
    17681738        $this->language_data['URLS'][$group] = $url;
    17691739    }
     
    17721742     * Sets styles for links in code
    17731743     *
    1774      * @param int A constant that specifies what state the style is being
    1775      *            set for - e.g. :hover or :visited
    1776      * @param string The styles to use for that state
     1744     * @param int    $type   A constant that specifies what state the style is being
     1745     *                       set for - e.g. :hover or :visited
     1746     * @param string $styles The styles to use for that state
    17771747     * @since 1.0.2
    17781748     */
    1779     function set_link_styles($type, $styles) {
     1749    public function set_link_styles($type, $styles) {
    17801750        $this->link_styles[$type] = $styles;
    17811751    }
     
    17841754     * Sets the target for links in code
    17851755     *
    1786      * @param string The target for links in the code, e.g. _blank
     1756     * @param string $target The target for links in the code, e.g. _blank
    17871757     * @since 1.0.3
    17881758     */
    1789     function set_link_target($target) {
     1759    public function set_link_target($target) {
    17901760        if (!$target) {
    17911761            $this->link_target = '';
     
    17981768     * Sets styles for important parts of the code
    17991769     *
    1800      * @param string The styles to use on important parts of the code
     1770     * @param string $styles The styles to use on important parts of the code
    18011771     * @since 1.0.2
    18021772     */
    1803     function set_important_styles($styles) {
     1773    public function set_important_styles($styles) {
    18041774        $this->important_styles = $styles;
    18051775    }
     
    18081778     * Sets whether context-important blocks are highlighted
    18091779     *
    1810      * @param boolean Tells whether to enable or disable highlighting of important blocks
     1780     * @param boolean $flag Tells whether to enable or disable highlighting of important blocks
    18111781     * @todo REMOVE THIS SHIZ FROM GESHI!
    18121782     * @deprecated
    18131783     * @since 1.0.2
    18141784     */
    1815     function enable_important_blocks($flag) {
     1785    public function enable_important_blocks($flag) {
    18161786        $this->enable_important_blocks = ( $flag ) ? true : false;
    18171787    }
     
    18201790     * Whether CSS IDs should be added to each line
    18211791     *
    1822      * @param boolean If true, IDs will be added to each line.
     1792     * @param boolean $flag If true, IDs will be added to each line.
    18231793     * @since 1.0.2
    18241794     */
    1825     function enable_ids($flag = true) {
     1795    public function enable_ids($flag = true) {
    18261796        $this->add_ids = ($flag) ? true : false;
    18271797    }
     
    18321802     * The extra style parameter was added in 1.0.7.21.
    18331803     *
    1834      * @param mixed An array of line numbers to highlight, or just a line
    1835      *              number on its own.
    1836      * @param string A string specifying the style to use for this line.
    1837      *              If null is specified, the default style is used.
    1838      *              If false is specified, the line will be removed from
    1839      *              special highlighting
     1804     * @param mixed  $lines An array of line numbers to highlight, or just a line
     1805     *                      number on its own.
     1806     * @param string $style A string specifying the style to use for this line.
     1807     *                      If null is specified, the default style is used.
     1808     *                      If false is specified, the line will be removed from
     1809     *                      special highlighting
    18401810     * @since 1.0.2
    18411811     * @todo  Some data replication here that could be cut down on
    18421812     */
    1843     function highlight_lines_extra($lines, $style = null) {
     1813    public function highlight_lines_extra($lines, $style = null) {
    18441814        if (is_array($lines)) {
    18451815            //Split up the job using single lines at a time
     
    18671837     * Sets the style for extra-highlighted lines
    18681838     *
    1869      * @param string The style for extra-highlighted lines
     1839     * @param string $styles The style for extra-highlighted lines
    18701840     * @since 1.0.2
    18711841     */
    1872     function set_highlight_lines_extra_style($styles) {
     1842    public function set_highlight_lines_extra_style($styles) {
    18731843        $this->highlight_extra_lines_style = $styles;
    18741844    }
     
    18771847     * Sets the line-ending
    18781848     *
    1879      * @param string The new line-ending
     1849     * @param string $line_ending The new line-ending
    18801850     * @since 1.0.2
    18811851     */
    1882     function set_line_ending($line_ending) {
     1852    public function set_line_ending($line_ending) {
    18831853        $this->line_ending = (string)$line_ending;
    18841854    }
     
    18961866     * so it's not worth doing it the CSS way yet.
    18971867     *
    1898      * @param int The number to start line numbers at
     1868     * @param int $number The number to start line numbers at
    18991869     * @since 1.0.2
    19001870     */
    1901     function start_line_numbers_at($number) {
     1871    public function start_line_numbers_at($number) {
    19021872        $this->line_numbers_start = abs(intval($number));
    19031873    }
     
    19121882     * I doubt it.
    19131883     *
    1914      * @param string The encoding to use for the source
     1884     * @param string $encoding The encoding to use for the source
    19151885     * @since 1.0.3
    19161886     */
    1917     function set_encoding($encoding) {
     1887    public function set_encoding($encoding) {
    19181888        if ($encoding) {
    19191889          $this->encoding = strtolower($encoding);
     
    19241894     * Turns linking of keywords on or off.
    19251895     *
    1926      * @param boolean If true, links will be added to keywords
     1896     * @param boolean $enable If true, links will be added to keywords
    19271897     * @since 1.0.2
    19281898     */
    1929     function enable_keyword_links($enable = true) {
     1899    public function enable_keyword_links($enable = true) {
    19301900        $this->keyword_links = (bool) $enable;
    19311901    }
     
    19381908     *
    19391909     * @since 1.0.8
    1940      * @access private
    1941      */
    1942     function build_style_cache() {
     1910     */
     1911    protected function build_style_cache() {
    19431912        //Build the style cache needed to highlight numbers appropriate
    19441913        if($this->lexic_permissions['NUMBERS']) {
     
    19891958     *
    19901959     * @since 1.0.8
    1991      * @access private
    1992      */
    1993     function build_parse_cache() {
     1960     */
     1961    protected function build_parse_cache() {
    19941962        // cache symbol regexp
    19951963        //As this is a costy operation, we avoid doing it for multiple groups ...
     
    21522120
    21532121                $this->language_data['NUMBERS_RXCACHE'][$key] =
    2154                     "/(?<!<\|\/)(?<!<\|!REG3XP)(?<!<\|\/NUM!)(?<!\d\/>)($regexp)(?!(?:<DOT>|(?>[^\<]))+>)(?![^<]*>)(?!\|>)(?!\/>)/i"; //
     2122                    "/(?<!<\|\/)(?<!<\|!REG3XP)(?<!<\|\/NUM!)(?<!\d\/>)($regexp)(?!(?:<DOT>|(?>[^\<]))+>)(?![^<]*>)(?!\|>)(?!\/>)/i";
    21552123            }
    21562124
     
    21732141     * @since 1.0.0
    21742142     */
    2175     function parse_code () {
     2143    public function parse_code () {
    21762144        // Start the timer
    21772145        $start_time = microtime();
     
    22692237                         *  - Group 2 is the closer
    22702238                         */
    2271                         if(!GESHI_PHP_PRE_433 && //Needs proper rewrite to work with PHP >=4.3.0; 4.3.3 is guaranteed to work.
    2272                             preg_match($delimiters, $code, $matches_rx, PREG_OFFSET_CAPTURE, $i)) {
     2239                        if(preg_match($delimiters, $code, $matches_rx, PREG_OFFSET_CAPTURE, $i)) {
    22732240                            //We got a match ...
    22742241                            if(isset($matches_rx['start']) && isset($matches_rx['end']))
     
    25172484                                }
    25182485                                $match_i = $comment_regexp_cache_per_key[$comment_key]['pos'];
    2519                             } elseif (
    2520                                 //This is to allow use of the offset parameter in preg_match and stay as compatible with older PHP versions as possible
    2521                                 (GESHI_PHP_PRE_433 && preg_match($regexp, substr($part, $i), $match, PREG_OFFSET_CAPTURE)) ||
    2522                                 (!GESHI_PHP_PRE_433 && preg_match($regexp, $part, $match, PREG_OFFSET_CAPTURE, $i))
    2523                                 ) {
     2486                            } elseif (preg_match($regexp, $part, $match, PREG_OFFSET_CAPTURE, $i)) {
    25242487                                $match_i = $match[0][1];
    2525                                 if (GESHI_PHP_PRE_433) {
    2526                                     $match_i += $i;
    2527                                 }
    25282488
    25292489                                $comment_regexp_cache_per_key[$comment_key] = array(
     
    26252585                                            }
    26262586                                            $match_i = $escape_regexp_cache_per_key[$escape_key]['pos'];
    2627                                         } elseif (
    2628                                             //This is to allow use of the offset parameter in preg_match and stay as compatible with older PHP versions as possible
    2629                                             (GESHI_PHP_PRE_433 && preg_match($regexp, substr($part, $start), $match, PREG_OFFSET_CAPTURE)) ||
    2630                                             (!GESHI_PHP_PRE_433 && preg_match($regexp, $part, $match, PREG_OFFSET_CAPTURE, $start))
    2631                                             ) {
     2587                                        } elseif (preg_match($regexp, $part, $match, PREG_OFFSET_CAPTURE, $start)) {
    26322588                                            $match_i = $match[0][1];
    2633                                             if (GESHI_PHP_PRE_433) {
    2634                                                 $match_i += $start;
    2635                                             }
    26362589
    26372590                                            $escape_regexp_cache_per_key[$escape_key] = array(
     
    27012654                                        $es_char_m = mb_substr(substr($part, $es_pos+1, 16), 0, 1, $this->encoding);
    27022655                                        $string .= $es_char_m . '</span>';
    2703                                     } elseif (!GESHI_PHP_PRE_433 && 'utf-8' == $this->encoding) {
     2656                                    } elseif ('utf-8' == $this->encoding) {
    27042657                                        if(preg_match("/[\xC2-\xDF][\x80-\xBF]".
    27052658                                            "|\xE0[\xA0-\xBF][\x80-\xBF]".
     
    31423095     * the code is in a pre block...
    31433096     *
    3144      * @param  string The source to indent (reference!)
     3097     * @param  string $result The source to indent (reference!)
    31453098     * @since  1.0.0
    3146      * @access private
    3147      */
    3148     function indent(&$result) {
     3099     */
     3100    protected function indent(&$result) {
    31493101        /// Replace tabs with the correct number of spaces
    31503102        if (false !== strpos($result, "\t")) {
     
    32413193     * Changes the case of a keyword for those languages where a change is asked for
    32423194     *
    3243      * @param  string The keyword to change the case of
     3195     * @param  string $instr The keyword to change the case of
    32443196     * @return string The keyword with its case changed
    32453197     * @since  1.0.0
    3246      * @access private
    3247      */
    3248     function change_case($instr) {
     3198     */
     3199    protected function change_case($instr) {
    32493200        switch ($this->language_data['CASE_KEYWORDS']) {
    32503201            case GESHI_CAPS_UPPER:
     
    32603211     * Handles replacements of keywords to include markup and links if requested
    32613212     *
    3262      * @param  string The keyword to add the Markup to
    3263      * @return The HTML for the match found
     3213     * @param  string $match The keyword to add the Markup to
     3214     * @return string The HTML for the match found
    32643215     * @since  1.0.8
    3265      * @access private
    32663216     *
    32673217     * @todo   Get rid of ender in keyword links
    32683218     */
    3269     function handle_keyword_replace($match) {
     3219    protected function handle_keyword_replace($match) {
    32703220        $k = $this->_kw_replace_group;
    32713221        $keyword = $match[0];
     
    33023252                            '{FNAMEL}',
    33033253                            '{FNAMEU}',
     3254                            '{FNAMEUF}',
    33043255                            '.'),
    33053256                        array(
     
    33073258                            str_replace('+', '%20', urlencode($this->hsc(strtolower($word)))),
    33083259                            str_replace('+', '%20', urlencode($this->hsc(strtoupper($word)))),
     3260                            str_replace('+', '%20', urlencode($this->hsc(ucfirst($word)))),
    33093261                            '<DOT>'),
    33103262                        $this->language_data['URLS'][$k]
     
    33173269    }
    33183270
    3319     /**
    3320     * [Surcharge de Geshi] 
    3321     *
    3322     **/
    3323     function handle_singleline_regexps($stuff_to_parse, $regexp, $key) {
    3324         $stuff_to_parse = preg_replace(
    3325                 '/' . $regexp[GESHI_SEARCH] . '/' . $regexp[GESHI_MODIFIERS],
    3326                 $regexp[GESHI_BEFORE] . '<|!REG3XP'. $key .'!>' . $regexp[GESHI_REPLACE] . '|>' . $regexp[GESHI_AFTER],
    3327                 $stuff_to_parse);
    3328         return $stuff_to_parse;
    3329     }
    3330 
    3331     /**
    3332     * handles regular expressions highlighting-definitions with callback functions
     3271    /**
     3272     * handles regular expressions highlighting-definitions with callback functions
    33333273     *
    33343274     * @note this is a callback, don't use it directly
    33353275     *
    3336      * @param array the matches array
    3337      * @return The highlighted string
     3276     * @param array $matches the matches array
     3277     * @return string The highlighted string
    33383278     * @since 1.0.8
    3339      * @access private
    3340      */
    3341     function handle_regexps_callback($matches) {
     3279     */
     3280    protected function handle_regexps_callback($matches) {
    33423281        // before: "' style=\"' . call_user_func(\"$func\", '\\1') . '\"\\1|>'",
    33433282        return  ' style="' . call_user_func($this->language_data['STYLES']['REGEXPS'][$this->_rx_key], $matches[1]) . '"'. $matches[1] . '|>';
     
    33493288     * @note this is a callback, don't use it directly
    33503289     *
    3351      * @param array the matches array
     3290     * @param array $matches the matches array
    33523291     * @return string
    33533292     * @since 1.0.8
    3354      * @access private
    3355      */
    3356     function handle_multiline_regexps($matches) {
     3293     */
     3294    protected function handle_multiline_regexps($matches) {
    33573295        $before = $this->_hmr_before;
    33583296        $after = $this->_hmr_after;
     
    33823320     * stuff like keywords, numbers and methods.
    33833321     *
    3384      * @param string The string to parse for keyword, numbers etc.
     3322     * @param string $stuff_to_parse The string to parse for keyword, numbers etc.
    33853323     * @since 1.0.0
    3386      * @access private
    33873324     * @todo BUGGY! Why? Why not build string and return?
    3388      */
    3389     function parse_non_string_part($stuff_to_parse) {
     3325     * @return string
     3326     */
     3327    protected function parse_non_string_part($stuff_to_parse) {
    33903328        $stuff_to_parse = ' ' . $this->hsc($stuff_to_parse);
    33913329
     
    34753413                        $this->_hmr_after = '';
    34763414                    } else {
    3477                         // [surcharge de GESHI]
    3478                         // pour passer dans une methode
    3479                         // (qui permet donc une surcharge de juste la methode)
    3480                         /*
    3481                             $stuff_to_parse = preg_replace(
    3482                                 '/' . $regexp[GESHI_SEARCH] . '/' . $regexp[GESHI_MODIFIERS],
    3483                                 $regexp[GESHI_BEFORE] . '<|!REG3XP'. $key .'!>' . $regexp[GESHI_REPLACE] . '|>' . $regexp[GESHI_AFTER],
    3484                                 $stuff_to_parse);
    3485                         */
    3486                         $stuff_to_parse = $this->handle_singleline_regexps($stuff_to_parse, $regexp, $key);
     3415                        $stuff_to_parse = preg_replace(
     3416                            '/' . $regexp[GESHI_SEARCH] . '/' . $regexp[GESHI_MODIFIERS],
     3417                            $regexp[GESHI_BEFORE] . '<|!REG3XP'. $key .'!>' . $regexp[GESHI_REPLACE] . '|>' . $regexp[GESHI_AFTER],
     3418                            $stuff_to_parse);
    34873419                    }
    34883420                } else {
     
    37093641     * Sets the time taken to parse the code
    37103642     *
    3711      * @param microtime The time when parsing started
    3712      * @param microtime The time when parsing ended
     3643     * @param string $start_time The time when parsing started as returned by @see microtime()
     3644     * @param string $end_time   The time when parsing ended as returned by @see microtime()
    37133645     * @since 1.0.2
    3714      * @access private
    3715      */
    3716     function set_time($start_time, $end_time) {
     3646     */
     3647    protected function set_time($start_time, $end_time) {
    37173648        $start = explode(' ', $start_time);
    37183649        $end = explode(' ', $end_time);
     
    37263657     * @since  1.0.2
    37273658     */
    3728     function get_time() {
     3659    public function get_time() {
    37293660        return $this->time;
    37303661    }
     
    37343665     *
    37353666     * @since 1.0.8
    3736      * @access private
    3737      */
    3738     function merge_arrays() {
     3667     */
     3668    protected function merge_arrays() {
    37393669        $arrays = func_get_args();
    37403670        $narrays = count($arrays);
     
    37723702     * Gets language information and stores it for later use
    37733703     *
    3774      * @param string The filename of the language file you want to load
     3704     * @param string $file_name The filename of the language file you want to load
    37753705     * @since 1.0.0
    3776      * @access private
    37773706     * @todo Needs to load keys for lexic permissions for keywords, regexps etc
    37783707     */
    3779     function load_language($file_name) {
     3708    protected function load_language($file_name) {
    37803709        if ($file_name == $this->loaded_language) {
    37813710            // this file is already loaded!
     
    38723801     * surrounding it to make it look nice.
    38733802     *
    3874      * @param  string The code already parsed (reference!)
     3803     * @param  string $parsed_code The code already parsed (reference!)
    38753804     * @since  1.0.0
    3876      * @access private
    3877      */
    3878     function finalise(&$parsed_code) {
     3805     */
     3806    protected function finalise(&$parsed_code) {
    38793807        // Remove end parts of important declarations
    38803808        // This is BUGGY!! My fault for bad code: fix coming in 1.2
     
    41194047     * @return string The header for the code block
    41204048     * @since  1.0.0
    4121      * @access private
    4122      */
    4123     function header() {
     4049     */
     4050    protected function header() {
    41244051        // Get attributes needed
    41254052        /**
     
    41994126     * @return string The footer for the code block
    42004127     * @since  1.0.0
    4201      * @access private
    4202      */
    4203     function footer() {
     4128     */
     4129    protected function footer() {
    42044130        $footer = $this->footer_content;
    42054131        if ($footer) {
     
    42524178     * certain configuration values
    42534179     *
    4254      * @param  string The header or footer content to do replacement on
     4180     * @param  string $instr The header or footer content to do replacement on
    42554181     * @return string The header or footer with replaced keywords
    42564182     * @since  1.0.2
    4257      * @access private
    4258      */
    4259     function replace_keywords($instr) {
     4183     */
     4184    protected function replace_keywords($instr) {
    42604185        $keywords = $replacements = array();
    42614186
     
    43334258     *              Wikka Development Team}
    43344259     *
    4335      * @access      private
    43364260     * @param       string  $string string to be converted
    43374261     * @param       integer $quote_style
     
    43424266     * @since       1.0.7.18
    43434267     */
    4344     function hsc($string, $quote_style = ENT_COMPAT) {
     4268    protected function hsc($string, $quote_style = ENT_COMPAT) {
    43454269        // init
    43464270        static $aTransSpecchar = array(
     
    43734297    }
    43744298
    4375     function _genCSSName($name){
     4299    /**
     4300     * Generate a CSS class name from a given string.
     4301     * Prevents invalid CSS classes.
     4302     *
     4303     * @param string $name Proposed class name
     4304     *
     4305     * @return string Safe CSS class name
     4306     */
     4307    protected function _genCSSName($name) {
    43764308        return (is_numeric($name[0]) ? '_' : '') . $name;
    43774309    }
     
    43824314     * this code block instead of the whole thing
    43834315     *
    4384      * @param  boolean Whether to use economy mode or not
     4316     * @param  boolean $economy_mode Whether to use economy mode or not
    43854317     * @return string A stylesheet built on the data for the current language
    43864318     * @since  1.0.0
    43874319     */
    4388     function get_stylesheet($economy_mode = true) {
     4320    public function get_stylesheet($economy_mode = true) {
    43894321        // If there's an error, chances are that the language file
    43904322        // won't have populated the language data file, so we can't
     
    45864518     * Get's the style that is used for the specified line
    45874519     *
    4588      * @param int The line number information is requested for
    4589      * @access private
     4520     * @param int $line The line number information is requested for
    45904521     * @since 1.0.7.21
    45914522     */
    4592     function get_line_style($line) {
    4593         //$style = null;
     4523    protected function get_line_style($line) {
    45944524        $style = null;
    45954525        if (isset($this->highlight_extra_lines_styles[$line])) {
     
    46104540    *          => string 'f(aa|oo(bar)?)'</code>
    46114541    *
    4612     * @param $list array of (unquoted) strings
    4613     * @param $regexp_delimiter your regular expression delimiter, @see preg_quote()
     4542    * @param array  $list            array of (unquoted) strings
     4543    * @param string $regexp_delimiter your regular expression delimiter, @see preg_quote()
    46144544    * @return string for regular expression
    46154545    * @author Milian Wolff <mail@milianw.de>
    46164546    * @since 1.0.8
    4617     * @access private
    46184547    */
    4619     function optimize_regexp_list($list, $regexp_delimiter = '/') {
     4548    protected function optimize_regexp_list($list, $regexp_delimiter = '/') {
    46204549        $regex_chars = array('.', '\\', '+', '-', '*', '?', '[', '^', ']', '$',
    46214550            '(', ')', '{', '}', '=', '!', '<', '>', '|', ':', $regexp_delimiter);
     
    47294658        return $regexp_list;
    47304659    }
     4660
    47314661    /**
    47324662    * this function creates the appropriate regexp string of an token array
    47334663    * you should not call this function directly, @see $this->optimize_regexp_list().
    47344664    *
    4735     * @param &$tokens array of tokens
    4736     * @param $recursed bool to know wether we recursed or not
     4665    * @param array $tokens  array of tokens
     4666    * @param bool  $recursed to know wether we recursed or not
    47374667    * @return string
    47384668    * @author Milian Wolff <mail@milianw.de>
    47394669    * @since 1.0.8
    4740     * @access private
    47414670    */
    4742     function _optimize_regexp_list_tokens_to_string(&$tokens, $recursed = false) {
     4671    protected function _optimize_regexp_list_tokens_to_string(&$tokens, $recursed = false) {
    47434672        $list = '';
    47444673        foreach ($tokens as $token => $sub_tokens) {
     
    47814710     * Easy way to highlight stuff. Behaves just like highlight_string
    47824711     *
    4783      * @param string The code to highlight
    4784      * @param string The language to highlight the code in
    4785      * @param string The path to the language files. You can leave this blank if you need
    4786      *               as from version 1.0.7 the path should be automatically detected
    4787      * @param boolean Whether to return the result or to echo
     4712     * @param string $string   The code to highlight
     4713     * @param string $language The language to highlight the code in
     4714     * @param string $path     The path to the language files. You can leave this blank if you need
     4715     *                         as from version 1.0.7 the path should be automatically detected
     4716     * @param boolean $return  Whether to return the result or to echo
    47884717     * @return string The code highlighted (if $return is true)
    47894718     * @since 1.0.2
Note: See TracChangeset for help on using the changeset viewer.