Jump to content
xisto Community
Sign in to follow this  
Houdini

Could A New BBCode Be Added To Astahost ? PHP with highlighted code specifically.

Recommended Posts

I enjoy this site but with only one option which is code to present code in a post I would like to see a new BB Code option either manually entered or as a button that would look like <> and surrpund my PHP code with PHP and actually highlight it, there is a MOD for it and I had it at one time on one of my sites, I can't remember if I wrote it myself or used and altered other code. vBulletin like at PHP builder or Dev Shed uses it, but it looks like there are variations in how their code is written.. If Microscopic Earthling is interested I think I still have the code that I used on my site before I took it down. Just wondering if other would like the same.

Share this post


Link to post
Share on other sites

Oh yeah microscopic earthling is highly interested :P I'd been meaning to get in touch with you anyways upon recommendation by quite a few other members - but it's been constantly skipping my mind...So out with your plan :D Am all ears..Regards,m^e

Share this post


Link to post
Share on other sites

OK right now I am testing the actual code that will in fact make the code come out highlighted, and am using the last free version 2.0 but it is returning errors about the .css I think. I have it where it works either with or without a button (a <> gif) for 1.2 and 1.3 but even though it produces these errors about an offset on line 925 which I will show, I am searching my hard drive for the proper .css to create a PHP box. Here is the code that produces the error:

function wrap_style( $type='quote', $extra="" )
{
	global $ibforums;

	$used = array(
				   'quote' => array( 'title' => 'QUOTE', 'css_top' => 'quotetop' , 'css_main' => 'quotemain' ),
				   'code'  => array( 'title' => 'CODE' , 'css_top' => 'codetop'  , 'css_main' => 'codemain'  ),
				   'sql'   => array( 'title' => 'SQL'  , 'css_top' => 'sqltop'   , 'css_main' => 'sqlmain'   ),
				   'html'  => array( 'title' => 'HTML' , 'css_top' => 'htmltop'  , 'css_main' => 'htmlmain'  ),
				   'php'   => array( 'title' => 'PHP'  , 'css_top' => 'phptop'   , 'css_main' => 'phpmain'   )
				 );


	return array( 'START' => "<div class='{$used[ $type ]['css_top']}'>{$used[ $type ]['title']}{$extra}</div><div class='{$used[ $type ]['css_main']}'>",
				  'END'   => "</div>"
				);
}

 

Note that I used the html BB Code but need to create a PHP code with the css I think to remove the errors in 2.0 and possibly newer versions. Here is a screen shot of what I have with 2.0 right now.

Posted Image

As you can see There is no code wrap and while many people might not know it you can use HTML BB Code and also SQL with IPB like this:

INSERT INTO ibf_categories (id, position, state, name, description, image, url) VALUES (-1, NULL, NULL, '-', NULL, NULL, NULL);
INSERT INTO ibf_categories (id, position, state, name, description, image, url) VALUES (1, 1, '1', 'A Test Category', '', '', '');

INSERT INTO ibf_css (cssid, css_name, css_text, css_comments) VALUES (1, 'Invision Style Sheet', 'form { display:inline }\r\nTABLE, TR, TD { font-family: Verdana, Tahoma, Arial; font-size: 8.5pt; color: #000000 }\r\na:link, a:visited, a:active { text-decoration: underline; color: #000000 }\r\na:hover { color: #465584 }\r\n.hlight { background-color: #DFE6EF }\r\n.dlight { background-color: #EEF2F7 }\r\n.mainbg { background-color: #FFFFFF }\r\n.mainfoot { background-color: #BCD0ED }\r\n.forum1 { background-color: #DFE6EF }\r\n.forum2 { background-color: #E4EAF2 }\r\n.post1 { background-color: #F5F9FD }\r\n.post2 { background-color: .....BLAHBLAH

If you want I can give the code changes that need to be made to the post_parser.php which will allow the above shown code minus the wraparound code box as shown in the screen shot and maybe by then I will also find what I need to change to make the css work and not throw the ugly error.

Edited by Houdini (see edit history)

Share this post


Link to post
Share on other sites

Well I went to the ACP and modified the CSS in those .htmlmain .htmltop css lines and just added a comma after the group and added .phptop and .phpmian even previewed it. but the line below

return array( 'START' => "<div class='{$used[ $type ]['css_top']}'>{$used[ $type ]['title']}{$extra}</div><div class='{$used[ $type ]['css_main']}'>",
'END' => "</div>"

is still showing the error so I don't really understand since I at least have the PHP code retruning in the message area only with the error

IPB WARNING [2] Illegal offset type (Line: 925 of \sources\lib\post_parser.php)

so not sure what can be done to correct this. I both saved the new CSS and also told it to save and reload in the ACP and not being the best with CSS am unsure. Also since the new definition is given for PHP in the array() definition I really dont know what is causing this unless when calling the function wrap_style() in the following line is missing something.
$html = $this->wrap_style( array( 'STYLE' => 'PHP' ) );


Share this post


Link to post
Share on other sites

:P Success has been achieved with the PHP BB Code as well I will release this on the Invisionize forums, but only after first releasing it here, since I once wrote this for 1.2 and 1.3 but 2.0 which I still have just needed to have the function called properly and after looking at the code for a little while and feeling really stupid I saw the problem. And to think I used to do this with no problem (make MODs for phpBB and IPB) this took almost a whole day. Basically it just involves one script which is the sources/lib/post_parser.php in 1.2 1.3 and 2.0 and probably the newer 2+ versions also (I don't have them so am not sure) Here is a screen shot off my local testbed for the 2.0 IPB. Give me a little time to properly edit and show changes needed to accomplish this here or on another IPB 2+ (possibly) I thought that this was already a MOD but I guess it is one I wrote and forgot about plus I removed the site I was using this code on but fortunately had downloaded all files from my Xisto for archival purposes and found the code and still have them. I will attach the post_parser.php that I used with this post and Microscopic Earthling can play with it and possibly use it here as well.

Posted Image:D Hope ya'll enjoy and see the ability to use this code as well as HTML or SQL which I have already demonstrated. Oh by the way I think for the PHP code block to work with IPB 2+ you must enter it using the ACP and save it that way but it is simple for Microscopic Earthling as he has experience with this. I can also develop the code to use a graphic button, but as it stand right now this is a manual entry only using case insensitive PHP or php as

 and 

or

 and 

. So the matter is right here and ready to go, just need a little change of one script or the changes that are in it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.