Wicher Site Admin
Joined: 16 Dec 2005 Posts: 1144 User's local time: 2023 Sep 30 - 2:15 PM Country IP :  Country of choice: 
Was This Post Helpful?

Users postingpoints:
Posts points:
Post gradiation:
|
Posted: Fri Feb 24, 2006 3:40 am Post subject: |
Wicher
*Delete this user
Items with prefix * are permanent. | Close |
|
|
The linenumber mod that is installed at this forum is NOT the one i created, the one installed is available at http://www.amigalink.de/phpbb2/viewtopic.php?t=96
The one i created is posted below and handles numbering slitly different that the one from amigalink.de.
My version uses images to create the numbers. Amigalink's does not.
Full mod is attached as an attachment at the bottom of this post.
Code: |
- ########################################################
- ##
- ## MOD Title: Linenumbers in BBcode code
- ## MOD Version: 1.0.0
- ## Author: Wicher (http://www.wichersmods.nl)
- ##
- ## Description:
- ## Displays linenumbers when the BBcode code is used in a message.
- ##
- ##
- ## Installation Level: easy
- ## Installation Time: 10 minutes
- ##
- ## Files To Edit: 2
- ## - includes/bbcode.php
- ## - templates/subSilver/bbcode.tpl
- ##
- ## Included Files: 4
- ## - Codenum/.htaccess
- ## - Codenum/codenum.png
- ## - Codenum/numblank.png
- ## - Codenum/codetemp.txt
- ##
- ########################################################
- ## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
- ##############################################################
-
- #
- #-----[ COPY ]------------------------------------------
- # codetemp.txt is an empty file that is used for writing and reading.
- copy Codenum/*.* TO Codenum/*.*
- #
- #-----[ OPEN ]------------------------------------------
- #
- includes/bbcode.php
- #
- #-----[ FIND ]------------------------------------------
- #
- function bbencode_second_pass_code($text, $uid, $bbcode_tpl)
- {
- global $lang;
-
- $code_start_html = $bbcode_tpl['code_open'];
- $code_end_html = $bbcode_tpl['code_close'];
-
- // First, do all the 1st-level matches. These need an htmlspecialchars() run,
- // so they have to be handled differently.
- $match_count = preg_match_all("#\[code:1:$uid\](.*?)\[/code:1:$uid\]#si", $text, $matches);
-
- for ($i = 0; $i < $match_count; $i++)
- {
- $before_replace = $matches[1][$i];
- $after_replace = $matches[1][$i];
-
- // Replace 2 spaces with " " so non-tabbed code indents without making huge long lines.
- $after_replace = str_replace(" ", " ", $after_replace);
- // now Replace 2 spaces with " " to catch odd #s of spaces.
- $after_replace = str_replace(" ", " ", $after_replace);
-
- // Replace tabs with " " so tabbed code indents sorta right without making huge long lines.
- $after_replace = str_replace("\t", " ", $after_replace);
-
- // now Replace space occurring at the beginning of a line
- $after_replace = preg_replace("/^ {1}/m", ' ', $after_replace);
-
- $str_to_match = "[code:1:$uid]" . $before_replace . "[/code:1:$uid]";
-
- $replacement = $code_start_html;
- $replacement .= $after_replace;
- $replacement .= $code_end_html;
-
- $text = str_replace($str_to_match, $replacement, $text);
- }
-
- // Now, do all the non-first-level matches. These are simple.
- $text = str_replace("[code:$uid]", $code_start_html, $text);
- $text = str_replace("[/code:$uid]", $code_end_html, $text);
-
- return $text;
-
- } // bbencode_second_pass_code()
- #
- #-----[ REPLACE, WITH ]------------------------------------------
- #
- function bbencode_second_pass_code($text, $uid, $bbcode_tpl)
- {
- global $lang;
-
- // First, do all the 1st-level matches. These need an htmlspecialchars() run,
- // so they have to be handled differently.
- $match_count = preg_match_all("#\[code:1:$uid\](.*?)\[/code:1:$uid\]#si", $text, $matches);
- $code_start_html = $bbcode_tpl['code_open'];
- $code_end_html = $bbcode_tpl['code_close'];
-
- for ($i = 0; $i < $match_count; $i++)
- {
- $tdnumbers = "";
- $before_replace = $matches[1][$i];
- $after_replace = $matches[1][$i];
-
- $codetemp = fopen('Codenum/codetemp.txt', 'w');
- fwrite($codetemp, $before_replace);
- fclose($codetemp);
- $tempfile = file('Codenum/codetemp.txt');
- foreach ($tempfile as $line_num => $line) {
- // Replace 2 spaces with " " so non-tabbed code indents without making huge long lines.
- $line = str_replace(" ", " ", $line);
- // now Replace 2 spaces with " " to catch odd #s of spaces.
- $line = str_replace(" ", " ", $line);
- // Replace tabs with " " so tabbed code indents sorta right without making huge long lines.
- $line = str_replace("\t", " ", $line);
- // now Replace space occurring at the beginning of a line
- $line = preg_replace("/^ {1}/m", ' ', $line);
- if ($line_num > 0){
- $tdnumbers = $tdnumbers. '<tr><td width="36" background="Codenum/codenum.png?number='.$line_num.'" valign="top"><span class="gensmall"></span></td> <td valign="top" style="border-left:1px dotted gray;"><span class="gensmall">' . $line . "</span></td></tr>";
- $tdlines = $tdlines . $line . '<br >';
- }
- }
-
- $str_to_match = "[code:1:$uid]" . $before_replace . "[/code:1:$uid]";
-
- $replacement = $code_start_html;
- $replacement .= '<table cellpadding="0" cellspacing="0" border="0">'.$tdnumbers.'</table>';
- $replacement .= $code_end_html;
-
- $text = str_replace($str_to_match, $replacement, $text);
- }
-
- return $text;
-
- } // bbencode_second_pass_code()
- #
- #-----[ OPEN ]------------------------------------------
- #
- templates/subSilver/bbcode.tpl
- #
- #-----[ FIND ]------------------------------------------
- #
- <!-- BEGIN code_open --></span>
- <table width="90%" cellspacing="1" cellpadding="3" border="0" align="center">
- <tr>
- <td><span class="genmed"><b>{L_CODE}:</b></span></td>
- </tr>
- <tr>
- <td class="code"><!-- END code_open -->
- #
- #-----[ REPLACE, WITH ]------------------------------------------
- #
- <!-- BEGIN code_open --></span>
- <table width="90%" cellspacing="2" cellpadding="0" border="0" align="center">
- <tr>
- <td colspan="2"><span class="genmed"><b>{L_CODE}:</b></span></td>
- </tr>
- <tr>
- <td class="code" valign="top"><!-- END code_open -->
- #
- #-----[ CHMOD ]------------------------------------------
- chmod Codenum/codetemp.txt to 666
- #
- #-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
- #
- # EoM
|
_________________
Wicher's phpBB2 Mods | Wicher's phpBB3 Mods | Statistics Mod 4.x.x
Last edited by Wicher on Thu Apr 20, 2006 8:59 am; edited 2 times in total |
|