Severity: 8192
Message: Function create_function() is deprecated
Filename: geshi/geshi.php
Line Number: 4698
Backtrace:
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 4698
Function: _error_handler
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 4621
Function: _optimize_regexp_list_tokens_to_string
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 1655
Function: optimize_regexp_list
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 2029
Function: optimize_keyword_group
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 2168
Function: build_parse_cache
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/Process.php
Line: 45
Function: parse_code
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/models/Pastes.php
Line: 517
Function: syntax
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/controllers/Main.php
Line: 624
Function: getPaste
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/index.php
Line: 315
Function: require_once
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/system/core/Exceptions.php:271)
Filename: view/download.php
Line Number: 2
Backtrace:
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/themes/geocities/views/view/download.php
Line: 2
Function: header
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/core/MY_Loader.php
Line: 173
Function: include
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/core/MY_Loader.php
Line: 43
Function: _ci_load
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/controllers/Main.php
Line: 625
Function: view
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/index.php
Line: 315
Function: require_once
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/system/core/Exceptions.php:271)
Filename: view/download.php
Line Number: 3
Backtrace:
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/themes/geocities/views/view/download.php
Line: 3
Function: header
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/core/MY_Loader.php
Line: 173
Function: include
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/core/MY_Loader.php
Line: 43
Function: _ci_load
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/controllers/Main.php
Line: 625
Function: view
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/index.php
Line: 315
Function: require_once
| $header | |
$linenumbers | $code> |
| $footer | |
* The /e modifier inside* * @var array * @since 1.0.8 */ var $_kw_replace_group = 0; var $_rx_key = 0; /** * some "callback parameters" for handle_multiline_regexps * * @since 1.0.8 * @access private * @var string */ var $_hmr_before = ''; var $_hmr_replace = ''; var $_hmr_after = ''; var $_hmr_key = 0; /**#@-*/ /** * Creates a new GeSHi object, with source and language * * @param string The source code to highlight * @param string The language to highlight the source with * @param string The path to the language file directory. This * is deprecated! I've backported the auto path * detection from the 1.1.X dev branch, so now it * should be automatically set correctly. If you have * renamed the language directory however, you will * still need to set the path using this parameter or * {@link GeSHi->set_language_path()} * @since 1.0.0 */ function GeSHi($source = '', $language = '', $path = '') { if (!empty($source)) { $this->set_source($source); } if (!empty($language)) { $this->set_language($language); } $this->set_language_path($path); } /** * Returns the version of GeSHi * * @return string * @since 1 0.8.11 */ function get_version() { return GESHI_VERSION; } /** * Returns an error message associated with the last GeSHi operation, * or false if no error has occured * * @return string|false An error message if there has been an error, else false * @since 1.0.0 */ function error() { if ($this->error) { //Put some template variables for debugging here ... $debug_tpl_vars = array( '{LANGUAGE}' => $this->language, '{PATH}' => $this->language_path ); $msg = str_replace( array_keys($debug_tpl_vars), array_values($debug_tpl_vars), $this->error_messages[$this->error]); return "preg_replace()allows code execution. * Often it is the cause for remote code execution exploits. It is wise to * deactivate this feature and test where in the application it is used. * The developer using the /e modifier should be made aware that he should * usepreg_replace_callback()instead *
array(
* 'lang_name' => array('extension', 'extension', ...),
* 'lang_name' ...
* );
*
* @param string The filename to load the source from
* @param array A lookup array to use instead of the default one
* @todo Complete rethink of this and above method
* @since 1.0.5
*/
function load_from_file($file_name, $lookup = array()) {
if (is_readable($file_name)) {
$this->set_source(file_get_contents($file_name));
$this->set_language($this->get_language_name_from_extension(substr(strrchr($file_name, '.'), 1), $lookup));
} else {
$this->error = GESHI_ERROR_FILE_NOT_READABLE;
}
}
/**
* Adds a keyword to a keyword group for highlighting
*
* @param int The key of the keyword group to add the keyword to
* @param string The word to add to the keyword group
* @since 1.0.0
*/
function add_keyword($key, $word) {
if (!is_array($this->language_data['KEYWORDS'][$key])) {
$this->language_data['KEYWORDS'][$key] = array();
}
if (!in_array($word, $this->language_data['KEYWORDS'][$key])) {
$this->language_data['KEYWORDS'][$key][] = $word;
//NEW in 1.0.8 don't recompile the whole optimized regexp, simply append it
if ($this->parse_cache_built) {
$subkey = count($this->language_data['CACHED_KEYWORD_LISTS'][$key]) - 1;
$this->language_data['CACHED_KEYWORD_LISTS'][$key][$subkey] .= '|' . preg_quote($word, '/');
}
}
}
/**
* Removes a keyword from a keyword group
*
* @param int The key of the keyword group to remove the keyword from
* @param string The word to remove from the keyword group
* @param bool Wether to automatically recompile the optimized regexp list or not.
* Note: if you set this to false and @see GeSHi->parse_code() was already called once,
* for the current language, you have to manually call @see GeSHi->optimize_keyword_group()
* or the removed keyword will stay in cache and still be highlighted! On the other hand
* it might be too expensive to recompile the regexp list for every removal if you want to
* remove a lot of keywords.
* @since 1.0.0
*/
function remove_keyword($key, $word, $recompile = true) {
$key_to_remove = array_search($word, $this->language_data['KEYWORDS'][$key]);
if ($key_to_remove !== false) {
unset($this->language_data['KEYWORDS'][$key][$key_to_remove]);
//NEW in 1.0.8, optionally recompile keyword group
if ($recompile && $this->parse_cache_built) {
$this->optimize_keyword_group($key);
}
}
}
/**
* Creates a new keyword group
*
* @param int The key of the keyword group to create
* @param string The styles for the keyword group
* @param boolean Whether the keyword group is case sensitive ornot
* @param array The words to use for the keyword group
* @since 1.0.0
*/
function add_keyword_group($key, $styles, $case_sensitive = true, $words = array()) {
$words = (array) $words;
if (empty($words)) {
// empty word lists mess up highlighting
return false;
}
//Add the new keyword group internally
$this->language_data['KEYWORDS'][$key] = $words;
$this->lexic_permissions['KEYWORDS'][$key] = true;
$this->language_data['CASE_SENSITIVE'][$key] = $case_sensitive;
$this->language_data['STYLES']['KEYWORDS'][$key] = $styles;
//NEW in 1.0.8, cache keyword regexp
if ($this->parse_cache_built) {
$this->optimize_keyword_group($key);
}
}
/**
* Removes a keyword group
*
* @param int The key of the keyword group to remove
* @since 1.0.0
*/
function remove_keyword_group ($key) {
//Remove the keyword group internally
unset($this->language_data['KEYWORDS'][$key]);
unset($this->lexic_permissions['KEYWORDS'][$key]);
unset($this->language_data['CASE_SENSITIVE'][$key]);
unset($this->language_data['STYLES']['KEYWORDS'][$key]);
//NEW in 1.0.8
unset($this->language_data['CACHED_KEYWORD_LISTS'][$key]);
}
/**
* compile optimized regexp list for keyword group
*
* @param int The key of the keyword group to compile & optimize
* @since 1.0.8
*/
function optimize_keyword_group($key) {
$this->language_data['CACHED_KEYWORD_LISTS'][$key] =
$this->optimize_regexp_list($this->language_data['KEYWORDS'][$key]);
$space_as_whitespace = false;
if(isset($this->language_data['PARSER_CONTROL'])) {
if(isset($this->language_data['PARSER_CONTROL']['KEYWORDS'])) {
if(isset($this->language_data['PARSER_CONTROL']['KEYWORDS']['SPACE_AS_WHITESPACE'])) {
$space_as_whitespace = $this->language_data['PARSER_CONTROL']['KEYWORDS']['SPACE_AS_WHITESPACE'];
}
if(isset($this->language_data['PARSER_CONTROL']['KEYWORDS'][$key]['SPACE_AS_WHITESPACE'])) {
if(isset($this->language_data['PARSER_CONTROL']['KEYWORDS'][$key]['SPACE_AS_WHITESPACE'])) {
$space_as_whitespace = $this->language_data['PARSER_CONTROL']['KEYWORDS'][$key]['SPACE_AS_WHITESPACE'];
}
}
}
}
if($space_as_whitespace) {
foreach($this->language_data['CACHED_KEYWORD_LISTS'][$key] as $rxk => $rxv) {
$this->language_data['CACHED_KEYWORD_LISTS'][$key][$rxk] =
str_replace(" ", "\\s+", $rxv);
}
}
}
/**
* Sets the content of the header block
*
* @param string The content of the header block
* @since 1.0.2
*/
function set_header_content($content) {
$this->header_content = $content;
}
/**
* Sets the content of the footer block
*
* @param string The content of the footer block
* @since 1.0.2
*/
function set_footer_content($content) {
$this->footer_content = $content;
}
/**
* Sets the style for the header content
*
* @param string The style for the header content
* @since 1.0.2
*/
function set_header_content_style($style) {
$this->header_content_style = $style;
}
/**
* Sets the style for the footer content
*
* @param string The style for the footer content
* @since 1.0.2
*/
function set_footer_content_style($style) {
$this->footer_content_style = $style;
}
/**
* Sets whether to force a surrounding block around
* the highlighted code or not
*
* @param boolean Tells whether to enable or disable this feature
* @since 1.0.7.20
*/
function enable_inner_code_block($flag) {
$this->force_code_block = (bool)$flag;
}
/**
* Sets the base URL to be used for keywords
*
* @param int The key of the keyword group to set the URL for
* @param string The URL to set for the group. If {FNAME} is in
* the url somewhere, it is replaced by the keyword
* that the URL is being made for
* @since 1.0.2
*/
function set_url_for_keyword_group($group, $url) {
$this->language_data['URLS'][$group] = $url;
}
/**
* Sets styles for links in code
*
* @param int A constant that specifies what state the style is being
* set for - e.g. :hover or :visited
* @param string The styles to use for that state
* @since 1.0.2
*/
function set_link_styles($type, $styles) {
$this->link_styles[$type] = $styles;
}
/**
* Sets the target for links in code
*
* @param string The target for links in the code, e.g. _blank
* @since 1.0.3
*/
function set_link_target($target) {
if (!$target) {
$this->link_target = '';
} else {
$this->link_target = ' target="' . $target . '"';
}
}
/**
* Sets styles for important parts of the code
*
* @param string The styles to use on important parts of the code
* @since 1.0.2
*/
function set_important_styles($styles) {
$this->important_styles = $styles;
}
/**
* Sets whether context-important blocks are highlighted
*
* @param boolean Tells whether to enable or disable highlighting of important blocks
* @todo REMOVE THIS SHIZ FROM GESHI!
* @deprecated
* @since 1.0.2
*/
function enable_important_blocks($flag) {
$this->enable_important_blocks = ( $flag ) ? true : false;
}
/**
* Whether CSS IDs should be added to each line
*
* @param boolean If true, IDs will be added to each line.
* @since 1.0.2
*/
function enable_ids($flag = true) {
$this->add_ids = ($flag) ? true : false;
}
/**
* Specifies which lines to highlight extra
*
* The extra style parameter was added in 1.0.7.21.
*
* @param mixed An array of line numbers to highlight, or just a line
* number on its own.
* @param string A string specifying the style to use for this line.
* If null is specified, the default style is used.
* If false is specified, the line will be removed from
* special highlighting
* @since 1.0.2
* @todo Some data replication here that could be cut down on
*/
function highlight_lines_extra($lines, $style = null) {
if (is_array($lines)) {
//Split up the job using single lines at a time
foreach ($lines as $line) {
$this->highlight_lines_extra($line, $style);
}
} else {
//Mark the line as being highlighted specially
$lines = intval($lines);
$this->highlight_extra_lines[$lines] = $lines;
//Decide on which style to use
if ($style === null) { //Check if we should use default style
unset($this->highlight_extra_lines_styles[$lines]);
} elseif ($style === false) { //Check if to remove this line
unset($this->highlight_extra_lines[$lines]);
unset($this->highlight_extra_lines_styles[$lines]);
} else {
$this->highlight_extra_lines_styles[$lines] = $style;
}
}
}
/**
* Sets the style for extra-highlighted lines
*
* @param string The style for extra-highlighted lines
* @since 1.0.2
*/
function set_highlight_lines_extra_style($styles) {
$this->highlight_extra_lines_style = $styles;
}
/**
* Sets the line-ending
*
* @param string The new line-ending
* @since 1.0.2
*/
function set_line_ending($line_ending) {
$this->line_ending = (string)$line_ending;
}
/**
* Sets what number line numbers should start at. Should
* be a positive integer, and will be converted to one.
*
* Warning: Using this method will add the "start"
* attribute to the <ol> that is used for line numbering.
* This is not valid XHTML strict, so if that's what you
* care about then don't use this method. Firefox is getting
* support for the CSS method of doing this in 1.1 and Opera
* has support for the CSS method, but (of course) IE doesn't
* so it's not worth doing it the CSS way yet.
*
* @param int The number to start line numbers at
* @since 1.0.2
*/
function start_line_numbers_at($number) {
$this->line_numbers_start = abs(intval($number));
}
/**
* Sets the encoding used for htmlspecialchars(), for international
* support.
*
* NOTE: This is not needed for now because htmlspecialchars() is not
* being used (it has a security hole in PHP4 that has not been patched).
* Maybe in a future version it may make a return for speed reasons, but
* I doubt it.
*
* @param string The encoding to use for the source
* @since 1.0.3
*/
function set_encoding($encoding) {
if ($encoding) {
$this->encoding = strtolower($encoding);
}
}
/**
* Turns linking of keywords on or off.
*
* @param boolean If true, links will be added to keywords
* @since 1.0.2
*/
function enable_keyword_links($enable = true) {
$this->keyword_links = (bool) $enable;
}
/**
* Setup caches needed for styling. This is automatically called in
* parse_code() and get_stylesheet() when appropriate. This function helps
* stylesheet generators as they rely on some style information being
* preprocessed
*
* @since 1.0.8
* @access private
*/
function build_style_cache() {
//Build the style cache needed to highlight numbers appropriate
if($this->lexic_permissions['NUMBERS']) {
//First check what way highlighting information for numbers are given
if(!isset($this->language_data['NUMBERS'])) {
$this->language_data['NUMBERS'] = 0;
}
if(is_array($this->language_data['NUMBERS'])) {
$this->language_data['NUMBERS_CACHE'] = $this->language_data['NUMBERS'];
} else {
$this->language_data['NUMBERS_CACHE'] = array();
if(!$this->language_data['NUMBERS']) {
$this->language_data['NUMBERS'] =
GESHI_NUMBER_INT_BASIC |
GESHI_NUMBER_FLT_NONSCI;
}
for($i = 0, $j = $this->language_data['NUMBERS']; $j > 0; ++$i, $j>>=1) {
//Rearrange style indices if required ...
if(isset($this->language_data['STYLES']['NUMBERS'][1<<$i])) {
$this->language_data['STYLES']['NUMBERS'][$i] =
$this->language_data['STYLES']['NUMBERS'][1<<$i];
unset($this->language_data['STYLES']['NUMBERS'][1<<$i]);
}
//Check if this bit is set for highlighting
if($j&1) {
//So this bit is set ...
//Check if it belongs to group 0 or the actual stylegroup
if(isset($this->language_data['STYLES']['NUMBERS'][$i])) {
$this->language_data['NUMBERS_CACHE'][$i] = 1 << $i;
} else {
if(!isset($this->language_data['NUMBERS_CACHE'][0])) {
$this->language_data['NUMBERS_CACHE'][0] = 0;
}
$this->language_data['NUMBERS_CACHE'][0] |= 1 << $i;
}
}
}
}
}
}
/**
* Setup caches needed for parsing. This is automatically called in parse_code() when appropriate.
* This function makes stylesheet generators much faster as they do not need these caches.
*
* @since 1.0.8
* @access private
*/
function build_parse_cache() {
// cache symbol regexp
//As this is a costy operation, we avoid doing it for multiple groups ...
//Instead we perform it for all symbols at once.
//
//For this to work, we need to reorganize the data arrays.
if ($this->lexic_permissions['SYMBOLS'] && !empty($this->language_data['SYMBOLS'])) {
$this->language_data['MULTIPLE_SYMBOL_GROUPS'] = count($this->language_data['STYLES']['SYMBOLS']) > 1;
$this->language_data['SYMBOL_DATA'] = array();
$symbol_preg_multi = array(); // multi char symbols
$symbol_preg_single = array(); // single char symbols
foreach ($this->language_data['SYMBOLS'] as $key => $symbols) {
if (is_array($symbols)) {
foreach ($symbols as $sym) {
$sym = $this->hsc($sym);
if (!isset($this->language_data['SYMBOL_DATA'][$sym])) {
$this->language_data['SYMBOL_DATA'][$sym] = $key;
if (isset($sym[1])) { // multiple chars
$symbol_preg_multi[] = preg_quote($sym, '/');
} else { // single char
if ($sym == '-') {
// don't trigger range out of order error
$symbol_preg_single[] = '\-';
} else {
$symbol_preg_single[] = preg_quote($sym, '/');
}
}
}
}
} else {
$symbols = $this->hsc($symbols);
if (!isset($this->language_data['SYMBOL_DATA'][$symbols])) {
$this->language_data['SYMBOL_DATA'][$symbols] = 0;
if (isset($symbols[1])) { // multiple chars
$symbol_preg_multi[] = preg_quote($symbols, '/');
} elseif ($symbols == '-') {
// don't trigger range out of order error
$symbol_preg_single[] = '\-';
} else { // single char
$symbol_preg_single[] = preg_quote($symbols, '/');
}
}
}
}
//Now we have an array with each possible symbol as the key and the style as the actual data.
//This way we can set the correct style just the moment we highlight ...
//
//Now we need to rewrite our array to get a search string that
$symbol_preg = array();
if (!empty($symbol_preg_multi)) {
rsort($symbol_preg_multi);
$symbol_preg[] = implode('|', $symbol_preg_multi);
}
if (!empty($symbol_preg_single)) {
rsort($symbol_preg_single);
$symbol_preg[] = '[' . implode('', $symbol_preg_single) . ']';
}
$this->language_data['SYMBOL_SEARCH'] = implode("|", $symbol_preg);
}
// cache optimized regexp for keyword matching
// remove old cache
$this->language_data['CACHED_KEYWORD_LISTS'] = array();
foreach (array_keys($this->language_data['KEYWORDS']) as $key) {
if (!isset($this->lexic_permissions['KEYWORDS'][$key]) ||
$this->lexic_permissions['KEYWORDS'][$key]) {
$this->optimize_keyword_group($key);
}
}
// brackets
if ($this->lexic_permissions['BRACKETS']) {
$this->language_data['CACHE_BRACKET_MATCH'] = array('[', ']', '(', ')', '{', '}');
if (!$this->use_classes && isset($this->language_data['STYLES']['BRACKETS'][0])) {
$this->language_data['CACHE_BRACKET_REPLACE'] = array(
'<| style="' . $this->language_data['STYLES']['BRACKETS'][0] . '">[|>',
'<| style="' . $this->language_data['STYLES']['BRACKETS'][0] . '">]|>',
'<| style="' . $this->language_data['STYLES']['BRACKETS'][0] . '">(|>',
'<| style="' . $this->language_data['STYLES']['BRACKETS'][0] . '">)|>',
'<| style="' . $this->language_data['STYLES']['BRACKETS'][0] . '">{|>',
'<| style="' . $this->language_data['STYLES']['BRACKETS'][0] . '">}|>',
);
}
else {
$this->language_data['CACHE_BRACKET_REPLACE'] = array(
'<| class="br0">[|>',
'<| class="br0">]|>',
'<| class="br0">(|>',
'<| class="br0">)|>',
'<| class="br0">{|>',
'<| class="br0">}|>',
);
}
}
//Build the parse cache needed to highlight numbers appropriate
if($this->lexic_permissions['NUMBERS']) {
//Check if the style rearrangements have been processed ...
//This also does some preprocessing to check which style groups are useable ...
if(!isset($this->language_data['NUMBERS_CACHE'])) {
$this->build_style_cache();
}
//Number format specification
//All this formats are matched case-insensitively!
static $numbers_format = array(
GESHI_NUMBER_INT_BASIC =>
'(?:(?
'(?
'(?
'(?
'(?
'(?
'(?
'(?
'(?
'(?
'(?
'(?
'(?
'(?
'(?
'(?language_data['NUMBERS_RXCACHE'] = array();
foreach($this->language_data['NUMBERS_CACHE'] as $key => $rxdata) {
if(is_string($rxdata)) {
$regexp = $rxdata;
} else {
//This is a bitfield of number flags to highlight:
//Build an array, implode them together and make this the actual RX
$rxuse = array();
for($i = 1; $i <= $rxdata; $i<<=1) {
if($rxdata & $i) {
$rxuse[] = $numbers_format[$i];
}
}
$regexp = implode("|", $rxuse);
}
$this->language_data['NUMBERS_RXCACHE'][$key] =
"/(?)($regexp)(?!(?: header, we shouldn't add newlines because
// the will line-break them (and the
";
$end = '';
} else {
// Span or div?
$start = "';
} elseif ($this->header_type == GESHI_HEADER_PRE_TABLE) {
if ($this->line_numbers != GESHI_NO_LINE_NUMBERS) {
if ($this->use_classes) {
$attrs = ' class="ln"';
} else {
$attrs = ' style="'. $this->table_linenumber_style .'"';
}
$parsed_code .= '';
// get linenumbers
// we don't merge it with the for below, since it should be better for
// memory consumption this way
// @todo: but... actually it would still be somewhat nice to merge the two loops
// the mem peaks are at different positions
for ($i = 0; $i < $n; ++$i) {
$close = 0;
// fancy lines
if ($this->line_numbers == GESHI_FANCY_LINE_NUMBERS &&
$i % $this->line_nth_row == ($this->line_nth_row - 1)) {
// Set the attributes to style the line
if ($this->use_classes) {
$parsed_code .= '';
} else {
// This style "covers up" the special styles set for special lines
// so that styles applied to special lines don't apply to the actual
// code on that line
$parsed_code .= ''
.'';
}
$close += 2;
}
//Is this some line with extra styles???
if (in_array($i + 1, $this->highlight_extra_lines)) {
if ($this->use_classes) {
if (isset($this->highlight_extra_lines_styles[$i])) {
$parsed_code .= "";
} else {
$parsed_code .= "";
}
} else {
$parsed_code .= "get_line_style($i) . "\">";
}
++$close;
}
$parsed_code .= $this->line_numbers_start + $i;
if ($close) {
$parsed_code .= str_repeat('', $close);
} elseif ($i != $n) {
$parsed_code .= "\n";
}
}
$parsed_code .= '';
}
$parsed_code .= '';
}
// No line numbers, but still need to handle highlighting lines extra.
// Have to use divs so the full width of the code is highlighted
$close = 0;
for ($i = 0; $i < $n; ++$i) {
// Make lines have at least one space in them if they're empty
// BenBE: Checking emptiness using trim instead of relying on blanks
if ('' == trim($code[$i])) {
$code[$i] = ' ';
}
// fancy lines
if ($this->line_numbers == GESHI_FANCY_LINE_NUMBERS &&
$i % $this->line_nth_row == ($this->line_nth_row - 1)) {
// Set the attributes to style the line
if ($this->use_classes) {
$parsed_code .= '';
} else {
// This style "covers up" the special styles set for special lines
// so that styles applied to special lines don't apply to the actual
// code on that line
$parsed_code .= ''
.'';
}
$close += 2;
}
//Is this some line with extra styles???
if (in_array($i + 1, $this->highlight_extra_lines)) {
if ($this->use_classes) {
if (isset($this->highlight_extra_lines_styles[$i])) {
$parsed_code .= "";
} else {
$parsed_code .= "";
}
} else {
$parsed_code .= "get_line_style($i) . "\">";
}
++$close;
}
$parsed_code .= $code[$i];
if ($close) {
$parsed_code .= str_repeat('', $close);
$close = 0;
}
elseif ($i + 1 < $n) {
$parsed_code .= "\n";
}
unset($code[$i]);
}
if ($this->header_type == GESHI_HEADER_PRE_VALID || $this->header_type == GESHI_HEADER_PRE_TABLE) {
$parsed_code .= '';
}
if ($this->header_type == GESHI_HEADER_PRE_TABLE && $this->line_numbers != GESHI_NO_LINE_NUMBERS) {
$parsed_code .= ' ';
}
}
$parsed_code .= $this->footer();
}
/**
* Creates the header for the code block (with correct attributes)
*
* @return string The header for the code block
* @since 1.0.0
* @access private
*/
function header() {
// Get attributes needed
/**
* @todo Document behaviour change - class is outputted regardless of whether
* we're using classes or not. Same with style
*/
$attributes = ' class="' . $this->_genCSSName($this->language);
if ($this->overall_class != '') {
$attributes .= " ".$this->_genCSSName($this->overall_class);
}
$attributes .= '"';
if ($this->overall_id != '') {
$attributes .= " id=\"{$this->overall_id}\"";
}
if ($this->overall_style != '' && !$this->use_classes) {
$attributes .= ' style="' . $this->overall_style . '"';
}
$ol_attributes = '';
if ($this->line_numbers_start != 1) {
$ol_attributes .= ' start="' . $this->line_numbers_start . '"';
}
// Get the header HTML
$header = $this->header_content;
if ($header) {
if ($this->header_type == GESHI_HEADER_PRE || $this->header_type == GESHI_HEADER_PRE_VALID) {
$header = str_replace("\n", '', $header);
}
$header = $this->replace_keywords($header);
if ($this->use_classes) {
$attr = ' class="head"';
} else {
$attr = " style=\"{$this->header_content_style}\"";
}
if ($this->header_type == GESHI_HEADER_PRE_TABLE && $this->line_numbers != GESHI_NO_LINE_NUMBERS) {
$header = "$header ";
} else {
$header = "$header";
}
}
if (GESHI_HEADER_NONE == $this->header_type) {
if ($this->line_numbers != GESHI_NO_LINE_NUMBERS) {
return "$header";
}
return $header . ($this->force_code_block ? '' : '');
}
// Work out what to return and do it
if ($this->line_numbers != GESHI_NO_LINE_NUMBERS) {
if ($this->header_type == GESHI_HEADER_PRE) {
return "$header";
} elseif ($this->header_type == GESHI_HEADER_DIV ||
$this->header_type == GESHI_HEADER_PRE_VALID) {
return "$header";
} elseif ($this->header_type == GESHI_HEADER_PRE_TABLE) {
return "$header";
}
} else {
if ($this->header_type == GESHI_HEADER_PRE) {
return "$header" .
($this->force_code_block ? '' : '');
} else {
return "$header" .
($this->force_code_block ? '' : '');
}
}
}
/**
* Returns the footer for the code block.
*
* @return string The footer for the code block
* @since 1.0.0
* @access private
*/
function footer() {
$footer = $this->footer_content;
if ($footer) {
if ($this->header_type == GESHI_HEADER_PRE) {
$footer = str_replace("\n", '', $footer);;
}
$footer = $this->replace_keywords($footer);
if ($this->use_classes) {
$attr = ' class="foot"';
} else {
$attr = " style=\"{$this->footer_content_style}\"";
}
if ($this->header_type == GESHI_HEADER_PRE_TABLE && $this->line_numbers != GESHI_NO_LINE_NUMBERS) {
$footer = "$footer ";
} else {
$footer = "$footer";
}
}
if (GESHI_HEADER_NONE == $this->header_type) {
return ($this->line_numbers != GESHI_NO_LINE_NUMBERS) ? '' . $footer : $footer;
}
if ($this->header_type == GESHI_HEADER_DIV || $this->header_type == GESHI_HEADER_PRE_VALID) {
if ($this->line_numbers != GESHI_NO_LINE_NUMBERS) {
return "$footer";
}
return ($this->force_code_block ? '' : '') .
"$footer";
}
elseif ($this->header_type == GESHI_HEADER_PRE_TABLE) {
if ($this->line_numbers != GESHI_NO_LINE_NUMBERS) {
return " $footer
";
}
return ($this->force_code_block ? '
' : '') .
"$footer
";
}
else {
if ($this->line_numbers != GESHI_NO_LINE_NUMBERS) {
return "
$footer";
}
return ($this->force_code_block ? '