I have enahnced the [code] bbcode tag adding the possibility to get the code "online" besides the normal "code box", with this you can have a solution like this

http://img374.imageshack.us/img374/5564/codetagcf5.png

The logic is:

- [code]text[/code] -> online code
- [code]
  text
  [/code] -> code box

The text used is

Write [i](code box)[/i]
[code]
function Foo()
{
    echo("Foo");
}
[/code]
[i]("online" code)[/i]
And then call [code]Foo();[/code] in your code.

These are the modifies done:

- file: uieforum.module
function: uieforum_filter
line: 2412

  $text = preg_replace("#\[(code|pre|php)\](.*?)\[/\\1\](\r\n?|\n?)#si", "{{uie-code}}\n", $text);
  
  replaced with
  
  $text = preg_replace("#\[(code|pre|php)\](.*?)\[/\\1\](\r\n?|\n?)#si", "{{uie-code}}", $text);

The final \n for the code text is useless, since it is used by a

that fill the whole space and let the following text on the new line, this avoid the new line for the "online" code.

- file: bbcode-filter.inc
function: _uieforum_bbcode_pre_tag

  return '<div class="uie_pre"><pre>'.$text.'</pre></div>';
  
  become conditional to the fact that the text is on its own lines.
  
  if ((substr($text, 0, 2) == "\r\n") && (substr($text, strlen($text) - 2, 2) == "\r\n"))
	return '<div class="uie_pre"><pre>'.$text.'</pre></div>';
  else
	return '&#039;.$text.&#039;';

- file: css/style.css
you can define the class code.uie_pre in addition to the div.uie_pre present.

CommentFileSizeAuthor
code_tag.png7.77 KBdevbox

Comments

daniel.hunt’s picture

Assigned: Unassigned » daniel.hunt
Status: Active » Fixed

Very nice addition there - Thanks! :)

Anonymous’s picture

Status: Fixed » Closed (fixed)