Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Other - Discussion
Author Message
mengesb
New Member
New Member



Joined: Jan 20, 2004
Posts: 15

PostPosted: Sat Nov 21, 2009 11:42 pm Reply with quote

Hello all,

I'm trying to find a modification to PHP-Nuke that allows BBcode to be posted as part of the articles on the front page. I saw a site's method as an example: [ Only registered users can see links on this board! Get registered or login! ]

a demo of the above mentioned hack is here: [ Only registered users can see links on this board! Get registered or login! ]

I tried contacting this author, but it appears that the module may even be too old for 8.1 versions of phpnuke. I wanted to ask if anyone here is familiar with enabling BBCode as part of the default editor for php-nuke either in raven or my distro - php-nuke 8.1?
 
View user's profile Send private message
mengesb







PostPosted: Sat Nov 21, 2009 11:50 pm Reply with quote

Also, I manged to find this module on some random german site... and the installation documentation mentioned php-nuke version 7.5 and the likes (7.x). I'm also interested if anyone is willing to update the installation instructions, or if someone could modify this so it could be included cleanly as module if possible without any hacks to existing files. I've tried to simulate installation given the files are off a little, but the differences between 7.x and 8.x are significant enough to cause me pain. help appreciated
 
kguske
Site Admin



Joined: Jun 04, 2004
Posts: 6432

PostPosted: Sun Nov 22, 2009 8:00 am Reply with quote

Just to confirm: you want to disable WYSIWYG and replace with BBcode?

_________________
I search, therefore I exist...
nukeSEO - nukeFEED - nukePIE - nukeSPAM - nukeWYSIWYG
 
View user's profile Send private message
mengesb







PostPosted: Sun Nov 22, 2009 1:54 pm Reply with quote

Disabling WYSIWYG is fine by me ultimately. The above plugin was in addition to WYSIWYG, basically it would parse out the contents and catch bbcode, but if disabling WYSIWYG for BBCode is easier then I'm game for that as well.

Ultimately this is for the ease of my significant other posting to my site... she's always posting to forums and wants the same syntax.

Thanks for your reply kguske.
 
spasticdonkey
RavenNuke(tm) Development Team



Joined: Dec 02, 2006
Posts: 1693
Location: Texas, USA

PostPosted: Sun Nov 22, 2009 11:23 pm Reply with quote

here's a jquery editor add-on, looks cool but never really tried it out too much [ Only registered users can see links on this board! Get registered or login! ]

it does except bbcode. not sure what would be involved in integrating it, but worth a look.
 
View user's profile Send private message Visit poster's website
Palbin
Site Admin



Joined: Mar 30, 2006
Posts: 2583
Location: Pittsburgh, Pennsylvania

PostPosted: Mon Nov 23, 2009 12:47 am Reply with quote

I can make it parse and display the bbcode easy. Adding the buttons/editor for it would be harder. If you want to keep the wysiwyg editor, and just have it parse hand entered bbcode let me know I can do that easy.

_________________
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan. 
View user's profile Send private message
mengesb







PostPosted: Mon Nov 23, 2009 3:26 am Reply with quote

Palbin wrote:
I can make it parse and display the bbcode easy. Adding the buttons/editor for it would be harder. If you want to keep the wysiwyg editor, and just have it parse hand entered bbcode let me know I can do that easy.


Actually, if keeping WYSIWYG and parsing BBCode is an option, that's just fine by me (don't need the fancy buttons or a switch for which editor is being used). Often its just the one image tag that's used:

Code:
[img]--- link here ---[/img]


but there's a chance that she could use all the BBCode syntax, or some other options like italics or bold... but those are ultimately trivial (its the IMG tags that she wants most).

I can upload my index files for the news module on my php-nuke 8.1 install or I can provide download links from the site if you wish. I don't recall my patch level on php-nuke, but I don't think much has been done to the News module since 8.1's release.

spasticdonkey wrote:
here's a jquery editor add-on, looks cool but never really tried it out too much [ Only registered users can see links on this board! Get registered or login! ]

it does except bbcode. not sure what would be involved in integrating it, but worth a look.

I appreciate the offer spasticdonkey, but another application on her desktop would not be the right incentive - it should be integrated into the site when submitting news to make it easier. I also have an editor, and I have made a visual basic code hunter (search for all instances of [IMG]|[img] and replace with '<img src="' && search for all instances of [/IMG]|[/img] and replace with '" border=0>') but the copy, open app, paste, copy conversion, paste to our site just didn't spur the desired outcome. The following question was asked, "Can't you just make it take the BBCode instead of having to convert the code?"

... Rolling Eyes you can imagine the plight =)

Palbin, if you could provide instructions on how to modify my news module to take hand input bbcode, that would be totally awesome, or if I have to provide files that would work too. Let me know, this sounds like it'll do the trick.
 
kguske







PostPosted: Mon Nov 23, 2009 5:51 am Reply with quote

Just to confirm: the jquery isn't a desktop editor. It would work through the browser, just like the WYSIWYG editor does.
 
Palbin







PostPosted: Mon Nov 23, 2009 8:07 am Reply with quote

mengesb, it will be just like the forums as I will be using the same functions. Since you are not using RavenNuke we may have to do a little trial and error.

I'll post back after I get something together.
 
mengesb







PostPosted: Tue Nov 24, 2009 12:54 am Reply with quote

Palbin wrote:
mengesb, it will be just like the forums as I will be using the same functions. Since you are not using RavenNuke we may have to do a little trial and error.

I'll post back after I get something together.


Thanks for the help.
 
Palbin







PostPosted: Wed Nov 25, 2009 3:58 pm Reply with quote

Open module/News/index.php and look for this:
Code:
themeindex($aid, $informant, $datetime, $title, $counter, $topic, $hometext, $notes, $morelink, $topicname, $topicimage, $topictext);

Right before it add the following:
Code:
include_once 'modules/News/phpbb_bbstuff.php';

$hometext = parse_bbcode($hometext);



Now take the below code and make a file called phpbb_stuff.php and place it on modules/News/phpbb_bbstuff.php:
Code:
<?php


function parse_bbcode($hometext) {

      $bbcode_tpl = array();
      $bbcode_tpl['b'] = '<span style="font-weight: bold;">';
      $bbcode_tpl['b_close'] = '</span>';
      $bbcode_tpl['i'] = '<span style="font-style: italic;">';
      $bbcode_tpl['i_close'] = '</span>';
      $bbcode_tpl['u'] = '<span style="text-decoration: underline;">';
      $bbcode_tpl['u_close'] = '</span>';
      $bbcode_tpl['size_open'] = '<span style="font-size: $1px; line-height: normal">';
      $bbcode_tpl['size_close'] = '</span>';
      $bbcode_tpl['color_open'] = '<span style="color: $1;">';
      $bbcode_tpl['color_close'] = '</span>';
      $bbcode_tpl['img'] = '<img src="$1" border="0" />';
      $bbcode_tpl['url1'] = '<a href="$1$2" target="_blank" class="postlink">$1$2</a>';
      $bbcode_tpl['url2'] = '<a href="http://$1" target="_blank" class="postlink">$1</a>';
      $bbcode_tpl['url3'] = '<a href="$1$2" target="_blank" class="postlink">$6</a>';
      $bbcode_tpl['url4'] = '<a href="http://$1" target="_blank" class="postlink">$5</a>';
      $bbcode_tpl['email'] = '<a href="mailto:$1" class="postlink">$1</a>';
      $bbcode_tpl['code_open'] = '</span><table width="85%" cellspacing="1" cellpadding="3" border="0" align="center"><tr><td><span class="genmed"><b>' . _CODE . ':</b></span></td></tr><tr><td class="code">';
      $bbcode_tpl['code_close'] = '</td></tr></table><span class="postbody">';
      $bbcode_tpl['quote_open'] = '</span><table width="85%" cellspacing="1" cellpadding="3" border="0" align="center"><tr><td><span class="genmed"><b>' . _QUOTE . ':</b></span></td></tr><tr><td class="quote">';
      $bbcode_tpl['quote_close'] = '</td></tr></table><span class="postbody">';
      $bbcode_tpl['quote_username_open'] = '</span><table width="85%" cellspacing="1" cellpadding="3" border="0" align="center"><tr><td><span class="genmed"><b>$1 ' . _WROTE . ':</b></span></td></tr><tr><td class="quote">';
      $bbcode_tpl['ulist_open'] = '<ul>';
      $bbcode_tpl['ulist_close'] = '</ul>';
      $bbcode_tpl['olist_open'] = '<ol type="$1">';
      $bbcode_tpl['olist_close'] = '</ol>';
      $bbcode_tpl['list_item'] = '<li>';

      $patterns = array();
      $replacements = array();
      $patterns[] = "#\[img\](.*?)\[/img\]#si";
      $replacements[] = $bbcode_tpl['img'];
      $patterns[] = "#\[url\]([a-z0-9]+?://){1}([\w\-]+\.([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^ \"\n\r\t<]*)?)\[/url\]#is";
      $replacements[] = $bbcode_tpl['url1'];
      $patterns[] = "#\[url\]((www|ftp)\.([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^ \"\n\r\t<]*?)?)\[/url\]#si";
      $replacements[] = $bbcode_tpl['url2'];
      $patterns[] = "#\[url=([a-z0-9]+://)([\w\-]+\.([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^ \"\n\r\t<]*?)?)\](.*?)\[/url\]#si";
      $replacements[] = $bbcode_tpl['url3'];
      $patterns[] = "#\[url=(([\w\-]+\.)*?[\w]+(:[0-9]+)?(/[^ \"\n\r\t<]*)?)\](.*?)\[/url\]#si";
      $replacements[] = $bbcode_tpl['url4'];
      $patterns[] = "#\[email\]([a-z0-9\-_.]+?@[\w\-]+\.([\w\-\.]+\.)?[\w]+)\[/email\]#si";
      $replacements[] = $bbcode_tpl['email'];

      $hometext = preg_replace($patterns, $replacements, $hometext);

      $code_start_html = $bbcode_tpl['code_open'];
      $code_end_html =  $bbcode_tpl['code_close'];

      $match_count = preg_match_all("#\[code:1\](.*?)\[/code:1\]#si", $hometext, $matches);
      for ($i = 0; $i < $match_count; $i++) {
         $before_replace = $matches[1][$i];
         $after_replace = $matches[1][$i];
         $after_replace = str_replace("  ", "&nbsp; ", $after_replace);
         $after_replace = str_replace("  ", " &nbsp;", $after_replace);
         $after_replace = str_replace("\t", "&nbsp; &nbsp;", $after_replace);
         $str_to_match = "[code:1]" . $before_replace . "[/code:1]";
         $replacement = $code_start_html;
         $replacement .= $after_replace;
         $replacement .= $code_end_html;
         $hometext = str_replace($str_to_match, $replacement, $hometext);
      }

      $hometext = str_replace("[code]", $code_start_html, $hometext);
      $hometext = str_replace("[/code]", $code_end_html, $hometext);
      $hometext = str_replace("[quote]", $bbcode_tpl['quote_open'], $hometext);
      $hometext = str_replace("[/quote]", $bbcode_tpl['quote_close'], $hometext);
      $hometext = preg_replace("/\[quote=\"(.*?)\"\]/si", $bbcode_tpl['quote_username_open'], $hometext);
      $hometext = str_replace("[list]", $bbcode_tpl['ulist_open'], $hometext);
      $hometext = str_replace("[*]", $bbcode_tpl['list_item'], $hometext);
      $hometext = str_replace("[/list:u]", $bbcode_tpl['ulist_close'], $hometext);
      $hometext = str_replace("[/list:o]", $bbcode_tpl['olist_close'], $hometext);
      $hometext = preg_replace("/\[list=([a1])\]/si", $bbcode_tpl['olist_open'], $hometext);
      $hometext = str_replace("[b]", $bbcode_tpl['b'], $hometext);
      $hometext = str_replace("[/b]", $bbcode_tpl['b_close'], $hometext);
      $hometext = str_replace("[u]", $bbcode_tpl['u'], $hometext);
      $hometext = str_replace("[i]", $bbcode_tpl['i'], $hometext);
      $hometext = str_replace("[/u]", $bbcode_tpl['u_close'], $hometext);
      $hometext = str_replace("[/i]", $bbcode_tpl['i_close'], $hometext);
      $hometext = preg_replace("/\[size=([1-2]?[0-9])\]/si", $bbcode_tpl['size_open'], $hometext);
      $hometext = str_replace("[/size]", $bbcode_tpl['size_close'], $hometext);
      $hometext = preg_replace("/\[color=(\#[0-9A-F]{6}|[a-z]+)\]/si", $bbcode_tpl['color_open'], $hometext);
      $hometext = str_replace("[/color]", $bbcode_tpl['color_close'], $hometext);

      return $hometext;
}

?>



Now all the bbcode (I think) that are available in standard PHPBB 2 can be used in the news Smile
 
mengesb







PostPosted: Wed Nov 25, 2009 9:16 pm Reply with quote

Well, I was hopful, but the change didn't take successfully. I also noticed, that when I went in to post news now, I don't see the WYSIWYG editor items at the bottom (strange... I saw them before... I swear). I'm wondering if I'm going to have to re-install PHPNuke or convert... the DB schema should be the same right?

I'm trying to figure this out... I'll probably try a demo/test install on another site just to make sure I cover clean code working with this.
 
mengesb







PostPosted: Wed Nov 25, 2009 9:54 pm Reply with quote

Yeah, didn't make the change.

On a different note, I got the WYSIWYG editor back displayed, but now my article lists (when you go to the main administration page, at the bottom) no longer exists. I can edit my articles via the stories archive module, but its really strange that it just decided to disappear... don't know what that's all about. Kinda drives me nuts.
 
Palbin







PostPosted: Wed Nov 25, 2009 10:13 pm Reply with quote

What do you mean by the changes didn't take successfully?
 
eldorado
Involved
Involved



Joined: Sep 10, 2008
Posts: 424
Location: France,Translator

PostPosted: Thu Nov 26, 2009 11:52 am Reply with quote

would this one work , palbin?
Code:


function bb2html($hometext)
{
  $bbcode = array("<", ">",
                "[list]", "[*]", "[/list]",
                "[img]", "[/img]",
                "[b]", "[/b]",
                "[u]", "[/u]",
                "[i]", "[/i]",
                '[color="', "[/color]",
                "[size=\"", "[/size]",
                '[url="', "[/url]",
                "[mail=\"", "[/mail]",
                "[code]", "[/code]",
                "[quote]", "[/quote]",
                '"]');
  $htmlcode = array("&lt;", "&gt;",
                "<ul>", "<li>", "</ul>",
                "<img src=\"", "\">",
                "<b>", "</b>",
                "<u>", "</u>",
                "<i>", "</i>",
                "<span style=\"color:", "</span>",
                "<span style=\"font-size:", "</span>",
                '<a href="', "</a>",
                "<a href=\"mailto:", "</a>",
                "<code>", "</code>",
                "<table width=100% bgcolor=lightgray><tr><td bgcolor=white>", "</td></tr></table>",
                '">');
  $hometext = str_replace($bbcode, $htmlcode, $hometext);
  $hometext = nl2br($hometext);//second pass
  return $hometext;
}

_________________
United-holy-dragons.net (My RN site)- Rejekz(cod4 clan) - gamerslounge

Last edited by eldorado on Fri Nov 27, 2009 4:53 pm; edited 1 time in total 
View user's profile Send private message Visit poster's website MSN Messenger
mengesb







PostPosted: Thu Nov 26, 2009 1:50 pm Reply with quote

Palbin wrote:
What do you mean by the changes didn't take successfully?


Sorry, what I meant was that I cleaned up my module, and the edits didn't parse the bbcode in the news article.
 
Palbin







PostPosted: Sat Nov 28, 2009 2:43 pm Reply with quote

eldorado, I'm not sure if that would work or not without testing.

mengesb, I'll need to the latest version of phpnuke I can get becuase I am not sure why it doesn't work for you. I'll try to get to it sson.
 
mengesb







PostPosted: Sun Nov 29, 2009 1:58 am Reply with quote

As I said, I do have my source files which I can upload. Patches and all.
 
mengesb







PostPosted: Sun Nov 29, 2009 2:19 am Reply with quote

OK so I replaced my site files with unmodified ones (from source... just unpacked the whole modules directory because I had some site funniness going on).

The modifications worked for the root text, but for the extended text it wouldn't parse the BBCode (unsure why). Usually I have my wife push the pictures to the extended text on articles instead of the primary text so the articles aren't pages long on the front site.

Good news is, the code works, just not for the extended text (the text that shows when you click the 'read more' link, or the direct story link.

Anyway, thank you much for your continued help. If the extended text can be figured out that'll hit the spot. Noticed the 'preview' doesn't show the images like the HTML code will, but that's not a big problem because I can just tell her that it won't show up.
 
Palbin







PostPosted: Sun Nov 29, 2009 11:34 am Reply with quote

Ok sweet that makes it a lot easier. I will take a look at the other two issues.
 
Palbin







PostPosted: Sun Nov 29, 2009 1:09 pm Reply with quote

Open modules/News/article.php and look for something similar to this:
Code:


themearticle($aaid, $informant, $datetime, $title, $bodytext, $topic, $topicname, $topicimage, $topictext, $notes);

Before it add this:
Code:


include_once 'modules/News/phpbb_bbstuff.php';
$hometext = parse_bbcode($hometex);
$bodytext = parse_bbcode($bodytext);


Open modules/News/admin/index.php and look for all instances similar to this:
Code:


themepreview($subject, $hometext1, $bodytext1, $notes);

Add this before:
Code:


include_once '../modules/News/phpbb_bbstuff.php';
$hometext = parse_bbcode($hometext);
$bodytext = parse_bbcode($bodytext);


Last edited by Palbin on Sun Nov 29, 2009 10:44 pm; edited 1 time in total 
mengesb







PostPosted: Sun Nov 29, 2009 9:49 pm Reply with quote

Did you mean
Code:
$hometext = parse_bbcode($hometext);


as in $hometext for both variables, or did you specifically mean $hometex ?
 
mengesb







PostPosted: Sun Nov 29, 2009 9:52 pm Reply with quote

hmm... seems the preview still isn't working, but the extended text is working fine displaying pictures now! (I'm using $hometext with the extra T)
 
mengesb







PostPosted: Sat Dec 05, 2009 12:02 pm Reply with quote

Palbin,
Thank you much for the work and assistance you've given thus far, it has been a real help! Unfortunately the preview doesn't work still, but the full text is parsed of BBCode and it does what it should, so she can get along with that just fine. If you do happen to think of a way to get the preview to work, or that code should work and its just my funky site, then that's great.

Too bad this isn't a module that can just be separately installed into the sites... and the full BBCode editor selected as an option like WYSIWYG, or even the combination of both. Unfortunately I'm not versed well enough in the sites source.
 
Palbin







PostPosted: Sat Dec 05, 2009 3:04 pm Reply with quote

mengesb, in modules/News/admin/index.php look for this function:
Code:


function previewAdminStory(........

Within this function look for something like this:
Code:


themepreview($subject, $hometext, $bodytext);

Change it to:
Code:


include_once '../modules/News/phpbb_bbstuff.php';
$hometext = parse_bbcode($hometext);
$bodytext = parse_bbcode($bodytext);
themepreview($subject, $hometext, $bodytext);


Last edited by Palbin on Sat Dec 05, 2009 10:27 pm; edited 1 time in total 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Other - Discussion

View next topic
View previous topic
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 can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©