Wicher's phpBB2 Mods Forum Index Wicher's phpBB2 Mods
On this board you will find all phpBB2 mods that i have created over the years. Most mods are on this board installed. Before asking for support, be sure to have your board updated to the latest phpBB2 version.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Simple db_update generatorSimple db_update generator   Advanced db_update generatorAdvanced db_update generator 
 This board is protected by Phpbbantispam 

Linenumbers in BBcode code

 
Board Alert Board Message
There are in this topic 14 posts to view if you are logged in.

You can log in or register via the login / registerlink here or in the header.
Back to top  Login here and be redirected to this TopicLogin here and be redirected to this Topic RegisterRegister
Reply to topic    Wicher's phpBB2 Mods Forum Index -> Wicher's phpBB Mods Was this Topic Helpful?  
Points for this topic: 1
Topic gradiation: 
View previous topic :: View next topic  
Author Linenumbers in BBcode code
Wicher
Site Admin


Joined: 16 Dec 2005
Posts: 1144
User's local time:
2024 Mar 28 - 1:24 PM
Country IP         : Netherlands
Country of choice: Netherlands


Was This Post Helpful?

 
Users postingpoints:
58
Posts points:
1
Post gradiation:
PostPosted: Fri Feb 24, 2006 3:40 am    Post subject: Reply with quote

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:
  1. ########################################################
  2. ##
  3. ## MOD Title:   Linenumbers in BBcode code
  4. ## MOD Version: 1.0.0
  5. ## Author:     Wicher (http://www.wichersmods.nl)
  6. ##
  7. ## Description: 
  8. ##    Displays linenumbers when the BBcode code is used in a message.
  9. ## 
  10. ##
  11. ## Installation Level:  easy
  12. ## Installation Time:  10 minutes
  13. ##
  14. ## Files To Edit:    2
  15. ##                   - includes/bbcode.php
  16. ##                   - templates/subSilver/bbcode.tpl
  17. ##
  18. ## Included Files:   4
  19. ##                - Codenum/.htaccess
  20. ##                - Codenum/codenum.png
  21. ##                - Codenum/numblank.png
  22. ##                - Codenum/codetemp.txt
  23. ##
  24. ########################################################
  25. ## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
  26. ##############################################################
  27. #
  28. #-----[ COPY ]------------------------------------------
  29. # codetemp.txt is an empty file that is used for writing and reading.
  30. copy Codenum/*.* TO Codenum/*.*
  31. #
  32. #-----[ OPEN ]------------------------------------------
  33. #
  34. includes/bbcode.php
  35. #
  36. #-----[ FIND ]------------------------------------------
  37. #
  38. function bbencode_second_pass_code($text, $uid, $bbcode_tpl)
  39. {
  40.    global $lang;
  41.    $code_start_html = $bbcode_tpl['code_open'];
  42.    $code_end_html =  $bbcode_tpl['code_close'];
  43.    // First, do all the 1st-level matches. These need an htmlspecialchars() run,
  44.    // so they have to be handled differently.
  45.    $match_count = preg_match_all("#\[code:1:$uid\](.*?)\[/code:1:$uid\]#si", $text, $matches);
  46.    for ($i = 0; $i < $match_count; $i++)
  47.    {
  48.       $before_replace = $matches[1][$i];
  49.       $after_replace = $matches[1][$i];
  50.       // Replace 2 spaces with "&nbsp; " so non-tabbed code indents without making huge long lines.
  51.       $after_replace = str_replace("  ", "&nbsp; ", $after_replace);
  52.       // now Replace 2 spaces with " &nbsp;" to catch odd #s of spaces.
  53.       $after_replace = str_replace("  ", " &nbsp;", $after_replace);
  54.       // Replace tabs with "&nbsp; &nbsp;" so tabbed code indents sorta right without making huge long lines.
  55.       $after_replace = str_replace("\t", "&nbsp; &nbsp;", $after_replace);
  56.       // now Replace space occurring at the beginning of a line
  57.       $after_replace = preg_replace("/^ {1}/m", '&nbsp;', $after_replace);
  58.       $str_to_match = "[code:1:$uid]" . $before_replace . "[/code:1:$uid]";
  59.       $replacement = $code_start_html;
  60.       $replacement .= $after_replace;
  61.       $replacement .= $code_end_html;
  62.       $text = str_replace($str_to_match, $replacement, $text);
  63.    }
  64.    // Now, do all the non-first-level matches. These are simple.
  65.    $text = str_replace("[code:$uid]", $code_start_html, $text);
  66.    $text = str_replace("[/code:$uid]", $code_end_html, $text);
  67.    return $text;
  68. } // bbencode_second_pass_code()
  69. #
  70. #-----[ REPLACE, WITH ]------------------------------------------
  71. #
  72. function bbencode_second_pass_code($text, $uid, $bbcode_tpl)
  73. {
  74.    global $lang;
  75.    // First, do all the 1st-level matches. These need an htmlspecialchars() run,
  76.    // so they have to be handled differently.
  77.    $match_count = preg_match_all("#\[code:1:$uid\](.*?)\[/code:1:$uid\]#si", $text, $matches);
  78.    $code_start_html = $bbcode_tpl['code_open'];
  79.    $code_end_html =  $bbcode_tpl['code_close'];
  80.    for ($i = 0; $i < $match_count; $i++)
  81.    {
  82.       $tdnumbers = "";
  83.       $before_replace = $matches[1][$i];
  84.       $after_replace = $matches[1][$i];
  85.       $codetemp = fopen('Codenum/codetemp.txt', 'w');
  86.       fwrite($codetemp, $before_replace);
  87.       fclose($codetemp);
  88.       $tempfile = file('Codenum/codetemp.txt');
  89.       foreach ($tempfile as $line_num => $line) {
  90.          // Replace 2 spaces with "&nbsp; " so non-tabbed code indents without making huge long lines.
  91.          $line = str_replace("  ", "&nbsp; ", $line);
  92.          // now Replace 2 spaces with " &nbsp;" to catch odd #s of spaces.
  93.          $line = str_replace("  ", " &nbsp;", $line);
  94.          // Replace tabs with "&nbsp; &nbsp;" so tabbed code indents sorta right without making huge long lines.
  95.          $line = str_replace("\t", "&nbsp; &nbsp;", $line);
  96.          // now Replace space occurring at the beginning of a line
  97.          $line = preg_replace("/^ {1}/m", '&nbsp;', $line);
  98.            if ($line_num > 0){
  99.          $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>";
  100.          $tdlines = $tdlines . $line . '<br >';
  101.          }
  102.       }
  103.       $str_to_match = "[code:1:$uid]" . $before_replace . "[/code:1:$uid]";
  104.       $replacement = $code_start_html;
  105.       $replacement .= '<table cellpadding="0" cellspacing="0" border="0">'.$tdnumbers.'</table>';
  106.       $replacement .= $code_end_html;
  107.       $text = str_replace($str_to_match, $replacement, $text);
  108.    }
  109.    return $text;
  110. } // bbencode_second_pass_code()
  111. #
  112. #-----[ OPEN ]------------------------------------------
  113. #
  114. templates/subSilver/bbcode.tpl
  115. #
  116. #-----[ FIND ]------------------------------------------
  117. #
  118. <!-- BEGIN code_open --></span>
  119. <table width="90%" cellspacing="1" cellpadding="3" border="0" align="center">
  120. <tr>
  121.      <td><span class="genmed"><b>{L_CODE}:</b></span></td>
  122.    </tr>
  123.    <tr>
  124.      <td class="code"><!-- END code_open -->
  125. #
  126. #-----[ REPLACE, WITH ]------------------------------------------
  127. #
  128. <!-- BEGIN code_open --></span>
  129. <table width="90%" cellspacing="2" cellpadding="0" border="0" align="center">
  130. <tr>
  131.      <td colspan="2"><span class="genmed"><b>{L_CODE}:</b></span></td>
  132.    </tr>
  133.    <tr>
  134.      <td class="code" valign="top"><!-- END code_open -->
  135. #
  136. #-----[ CHMOD ]------------------------------------------
  137. chmod Codenum/codetemp.txt to 666
  138. #
  139. #-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
  140. #
  141. # 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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Post new topic    Reply to topic    Wicher's phpBB2 Mods Forum Index -> Wicher's phpBB Mods
Author Linenumbers in BBcode code Replies
Display posts from previous:   
Post new topic   Reply to topic    Wicher's phpBB2 Mods Forum Index -> Wicher's phpBB Mods All times are GMT

Was this Topic Helpful?  
Points for this topic: 1
Topic gradiation: 
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

This board is protected by Phpbbantispam
Powered by phpBB © 2001, 2005 phpBB Group

Googlepage: GooglePullerPage
IP Country Flag 2.9.4 © 2005, 2007 - 3Di (aka 3D)