Raised This Month: $51 Target: $400
 12% 

SMA block code (JTP)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Prowler
Senior Member
Join Date: Nov 2004
Old 01-25-2005 , 06:46   SMA block code (JTP)
Reply With Quote #1

Allo chaps, sorry i havent been around of late i've been busy with other things.

IN any case im directing this at JTP, was wondering how you implement that SMA code block that you have? I'm aware i most likely have to fiddle around with php internal codeing, but if you could give me the gist of how you did it and the code required so i can implement it into my code (its not a phpbb forum so a direct copy of the file won't work unfortunatly, it is however based off of phpbb)

To avoid confusion you can go here http://prowler.egn.com.au and check out the forums to get a better idea of what they look like, in the end i am just looking for that bit of code so that i can post my heroes code in easier to read text

Thanks
Prowler is offline
jtp10181
Veteran Member
Join Date: May 2004
Location: Madison, WI
Old 01-25-2005 , 08:08  
Reply With Quote #2

heres the code that does it....

Code:
function bbencode_second_pass_small($text, $uid, $bbcode_tpl)
{
	$code_start_html = $bbcode_tpl['small_open'];
	$code_middle_html = $bbcode_tpl['small_middle'];
	$code_end_html =  $bbcode_tpl['small_close'];
	$matches = array();
	$match_count = preg_match_all("#\[small:1:$uid\](.*?)\[/small:1:$uid\]#si", $text, $matches);

	for ($i = 0; $i < $match_count; $i++)
	{
		$before_replace = $matches[1][$i];
		$after_replace = trim($matches[1][$i]);
		$str_to_match = "[small:1:$uid]" . $before_replace . "[/small:1:$uid]";
		$replacement = $code_start_html;
		$after_replace = str_replace('&lt;', '<', $after_replace);
		$after_replace = str_replace('&gt;', '>', $after_replace);
		$after_replace = str_replace('&amp;', '&', $after_replace);
		$after_replace = "$uid<?php $after_replace ?>$uid";
		$after_replace = highlight_string($after_replace, TRUE);
		$after_replace = str_replace($uid . '<font color="#0000CC">&lt;?php', '<font color="#0000CC">', $after_replace);
		$after_replace = str_replace('?&gt;</font>' . $uid, '</font>', $after_replace);
		$after_replace = preg_replace('/<font color="(.*?)">/si', '<span style="color: \\1;">', $after_replace);
		$after_replace = str_replace('</font>', '</span>', $after_replace);
		$after_replace = str_replace("\n", '', $after_replace);
		
		//Put line numbers in - JTP10181
		$numoflines = count( explode("\n",$str_to_match));
		$linenums_html = '<code>';
		for ($x = 1; $x <= $numoflines; $x++) {
			if ($x > 1) $linenums_html .= '
';
			$linenums_html .= $x . ':';
		}
		$linenums_html .= '</code>';
		$linenums_html .= $code_middle_html;
		$replacement .= $linenums_html;
		//End of adding line numbers
		
		$replacement .= $after_replace;
		$replacement .= $code_end_html;

		$text = str_replace($str_to_match, $replacement, $text);
	}

	$text = str_replace("[small:$uid]", $code_start_html, $text);
	$text = str_replace("[/small:$uid]", $code_end_html, $text);

	return $text;
}
__________________
jtp10181 is offline
Send a message via ICQ to jtp10181 Send a message via AIM to jtp10181 Send a message via MSN to jtp10181 Send a message via Yahoo to jtp10181
Prowler
Senior Member
Join Date: Nov 2004
Old 01-25-2005 , 22:47  
Reply With Quote #3

Thank you sir
Prowler is offline
Prowler
Senior Member
Join Date: Nov 2004
Old 01-26-2005 , 01:16  
Reply With Quote #4

Hmmm, well it would seem that my forums and the phpbb ones are coded differntly, seeing as lack the underlying knowledge of php i'm unable to convert it... If it's not to much hassle could you tell me how to convert it to match my forums?

Here is what i found (after alot of searching) for where one would put in the code blocks

formdhtmltextarea.js.php
Code:
<script type="text/javascript">
<!--
function xoopsCodeUrl(id) {
var text = prompt("<?php echo _ENTERURL;?>", "");
var dom  = xoopsGetElementById(id);

if ( text != null && text != "" ) {
	var text2 = prompt("<?php echo _ENTERWEBTITLE;?>", "");
	if (text2 != null) {
		if (text2 == "") {
			var result = "[url=" + text + "]" + text + "[/url]";
			} else {
				var result = "[url=" + text + "]" + text2 + "[/url]";
			}
		dom.focus();
		dom.value += result;
	}
}
}


function xoopsCodeImg(id) {
var dom  = xoopsGetElementById(id);
var text = prompt("<?php echo _ENTERIMGURL;?>", "");

if ( text != null && text != "" ) {
	var text2 = prompt("<?php echo _ENTERIMGPOS;?>\n<?php echo _IMGPOSRORL;?>", "");
	while ( ( text2 != "" ) && ( text2 != "r" ) && ( text2 != "R" ) && ( text2 != "l" ) && ( text2 != "L" ) && ( text2 != null ) ) {
		text2 = prompt("<?php echo _ERRORIMGPOS;?>\n<?php echo _IMGPOSRORL;?>","");
	}
	if ( text2 == "l" || text2 == "L" ) {
		text2 = " align=left";
		} else if ( text2 == "r" || text2 == "R" ) {
			text2 = " align=right";
			} else {
				text2 = "";
			}
		var result = "[img" + text2 + "]" + text + "[/img]";
		dom.focus();
		dom.value += result;
	}
}


function xoopsCodeEmail(id) {
var text = prompt("<?php echo _ENTEREMAIL;?>", "");
var dom  = xoopsGetElementById(id);

if ( text != null && text != "" ) {
	var result = "[email]" + text + "[/email]";
	dom.focus();
	dom.value += result;
	}
}


function xoopsCodeQuote(id) {
var text = prompt("<?php echo _ENTERQUOTE;?>", "");
var dom  = xoopsGetElementById(id);

if ( text != null && text != "" ) {
	var result = "[quote]" + text + "[/quote]";
	dom.focus();
	dom.value += result;
	}
}


function xoopsCodeCode(id) {
var text = prompt("<?php echo _ENTERCODE;?>", "");
var dom  = xoopsGetElementById(id);

if ( text != null && text != "" ) {
	var result = "[code]" + text + "[/code]";
	dom.focus();
	dom.value += result;
	}
}


function xoopsCodeText(id) {
var textareaDom        = xoopsGetElementById(id);
var textDom            = xoopsGetElementById(id + "Addtext");
var fontDom            = xoopsGetElementById(id + "Font");
var colorDom           = xoopsGetElementById(id + "Color");
var sizeDom            = xoopsGetElementById(id + "Size");
var hiddenTextDomStyle = xoopsGetElementById(id + "hiddenText").style;
var textDomValue       = textDom.value;
var fontDomValue       = fontDom.options[fontDom.options.selectedIndex].value;
var colorDomValue      = colorDom.options[colorDom.options.selectedIndex].value;
var sizeDomValue       = sizeDom.options[sizeDom.options.selectedIndex].value;

if (textDomValue == "") {
	alert("<?php echo _ENTERTEXTBOX;?>");
	textDom.focus();
	} else {
		if ( fontDomValue != "FONT") {
			textDomValue = "[font=" + fontDomValue + "]" + textDomValue + "[/font]";
			fontDom.options[0].selected = true;
		}
		if ( colorDomValue != "COLOR") {
			textDomValue = "[color=" + colorDomValue + "]" + textDomValue + "[/color]";
			colorDom.options[0].selected = true;
		}
		if ( sizeDomValue != "SIZE") {
			textDomValue = "[size=" + sizeDomValue + "]" + textDomValue + "[/size]";
			sizeDom.options[0].selected = true;
		}
		if ( xoopsGetElementById(id + "Bold").checked == true ) {
			textDomValue = "[b]" + textDomValue + "[/b]";
			xoopsGetElementById(id + "Bold").checked = false;
		}
		if ( xoopsGetElementById(id + "Italic").checked == true ) {
			textDomValue = "[i]" + textDomValue + "[/i]";
			xoopsGetElementById(id + "Italic").checked = false;
		}
		if ( xoopsGetElementById(id + "Underline").checked == true ) {
			textDomValue = "[u]" + textDomValue + "[/u]";
			xoopsGetElementById(id + "Underline").checked = false;
		}
		textareaDom.focus();
		textareaDom.value += textDomValue;
		textDom.value = "";
	}
}

function xoopsCodeSmilie(id, smilieCode) {
var textareaDom = xoopsGetElementById(id);

textareaDom.focus();
textareaDom.value += smilieCode;
}


function xoopsValidate(subjectId, textareaId, submitId) {
var maxchars    = 65535;
var subjectDom  = xoopsGetElementById(subjectId);
var textareaDom = xoopsGetElementById(textareaId);
var submitDom   = xoopsGetElementById(submitId);

if (textareaDom.value == "") {
	alert("<?php echo _PLZCOMPLETE;?>");
	textareaDom.focus();
	return false;
}

if (subjectDom.value == "") {
	alert("<?php echo _PLZCOMPLETE;?>");
	subjectDom.focus();
	return false;
}

if (maxchars != 0) {
	if (textareaDom.value.length > maxchars) {
		alert("<?php echo _MESSAGETOOLONG;?>\n\n<?php echo _ALLOWEDCHAR;?>" + maxchars + "\n<?php echo _CURRCHAR;?>" + textareaDom.value.length + "");
		textareaDom.focus();
		return false;
		} else {
			submitDom.disabled = true;
			return true;
		}
	} else {
		submitDom.disabled = true;
		return true;
	}
}
//-->
</script>
and formdhtmltextarea.php

Code:
<?php
// $Id: formdhtmltextarea.php,v 1.1 2004/07/11 10:27:19 Farsus Exp $
// -------------------------------------------------------------------------//
//			                 RUNCMS                                         //
//                                                                          //
//	 reliable - Unique - Nocost &  Simplicity & ease off use                //
//                       < http://www.runcms.org >                          //
// -------------------------------------------------------------------------//
// Original Author: Kazumi Ono
// Author Website : http://www.mywebaddons.com/ , http://www.myweb.ne.jp
// License Type   : GPL: See /manual/LICENSES/GPL.txt
// ------------------------------------------------------------------------- //

if (!defined("EXOOPS_XOOPSFORMDHTMLTEXTAREA_INCLUDED")) {
	define("EXOOPS_XOOPSFORMDHTMLTEXTAREA_INCLUDED", 1);

include_once(XOOPS_ROOT_PATH."/class/xoopsform/formtextarea.php");

class XoopsFormDhtmlTextArea extends XoopsFormTextArea {

	function XoopsFormDhtmlTextArea($caption, $name, $value="", $rows=10, $cols=50) {
		$this->XoopsFormTextArea($caption, $name, $value, $rows, $cols);
	}

//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function render() {
global $myts, $xoopsUser;

include_once(XOOPS_ROOT_PATH."/class/xoopsform/formdhtmltextarea.js.php");

$admin = 0;
if ($xoopsUser && $xoopsUser->isAdmin()) {
	$admin = 1;
}

$ret  = "[img]".XOOPS_URL."/images/editor/link.gif[/img]getName()."\");' />";
$ret .= " [img]".XOOPS_URL."/images/editor/image.gif[/img]getName()."\");' />";

if ($admin || $myts->allowLibrary == 1) {
	$ret .= " [img]".XOOPS_URL."/images/editor/image-m.gif[/img]getName()."\", \"images\", 350, 450);' />";
}

$ret .= "
	[img]".XOOPS_URL."/images/editor/email.gif[/img]getName()."\");' />
	[img]".XOOPS_URL."/images/editor/quote.gif[/img]getName()."\");' />
	[img]".XOOPS_URL."/images/editor/code.gif[/img]getName()."\");' />
	

";

$ret .= "<select class='select' id='".$this->getName()."Size' onchange='setVisible(\"".$this->getName()."hiddenText\");setElementSize(\"".$this->getName()."hiddenText\",this.options[this.selectedIndex].value);'></a>";
$ret .= "<option value='SIZE'>"._SIZE."</option>";

$sizearray = array("xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large");
foreach ($sizearray as $size) {
	$ret .=  "<option value='$size'>$size</option>";
}
$ret .= "</select> ";

$fontarray = array("Arial", "Courier", "Georgia", "Helvetica", "Impact", "Verdana");
$ret      .= "<select class='select' id='".$this->getName()."Font' onchange='setVisible(\"".$this->getName()."hiddenText\");setElementFont(\"".$this->getName()."hiddenText\",this.options[this.selectedIndex].value);'>";
$ret      .= "<option value='FONT'>"._FONT."</option>";

foreach ($fontarray as $font) {
	$ret .= "<option value='$font'>$font</option>";
}
$ret .= "</select> ";

$ret .= "<select class='select' id='".$this->getName()."Color' onchange='setVisible(\"".$this->getName()."hiddenText\"); setElementColor(\"".$this->getName()."hiddenText\", this.options[this.selectedIndex].value);'>";
$ret .= "<option value='COLOR'>"._COLOR."</option>";

$colorarray = array("00", "33", "66", "99", "CC", "FF");
foreach ($colorarray as $color1) {
	foreach ($colorarray as $color2) {
		foreach ($colorarray as $color3) {
			$ret .= "<option value='".$color1.$color2.$color3."' style='background-color:#".$color1.$color2.$color3.";color:#".$color1.$color2.$color3.";'>#".$color1.$color2.$color3."</option>";
		}
	}
}

$ret .= "
	</select>
	<span id='".$this->getName()."hiddenText' style='visibility: hidden;'>"._EXAMPLE."</span>
	

	<input type='checkbox' class='checkbox' id='".$this->getName()."Bold' onclick='setVisible(\"".$this->getName()."hiddenText\");makeBold(\"".$this->getName()."hiddenText\");' />B
	<input type='checkbox' class='checkbox' id='".$this->getName()."Italic' onclick='setVisible(\"".$this->getName()."hiddenText\");makeItalic(\"".$this->getName()."hiddenText\");' />I
	<input type='checkbox' class='checkbox' id='".$this->getName()."Underline' onclick='setVisible(\"".$this->getName()."hiddenText\");makeUnderline(\"".$this->getName()."hiddenText\");' /><u>U</u>
	<input type='text' class='text' id='".$this->getName()."Addtext' size='20' />
	<input type='button' class='button' onclick='xoopsCodeText(\"".$this->getName()."\")' value='"._ADD."'>
	


	<textarea class='textarea' id='".$this->getName()."' name='".$this->getName()."' cols='".$this->getCols()."' rows='".$this->getRows()."'".$this->getExtra().">".$this->getValue()."</textarea>
	
";

$ret .= $this->renderSmileys();

return $ret;
}

//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function renderSmileys() {

$smileyPath = "images/smilies";

$ret  = "getName()."\", \" :-) \");'>[img]".XOOPS_URL."/".$smileyPath."/icon_smile.gif[/img]";
$ret .= "getName()."\", \" :-( \");'>[img]".XOOPS_URL."/".$smileyPath."/icon_frown.gif[/img]";
$ret .= "getName()."\", \" :-D \");'>[img]".XOOPS_URL."/".$smileyPath."/icon_biggrin.gif[/img]";
$ret .= "getName()."\", \" ;-) \");'>[img]".XOOPS_URL."/".$smileyPath."/icon_wink.gif[/img]";
$ret .= "getName()."\", \" :-o \");'>[img]".XOOPS_URL."/".$smileyPath."/icon_eek.gif[/img]";
$ret .= "getName()."\", \" 8-) \");'>[img]".XOOPS_URL."/".$smileyPath."/icon_cool.gif[/img]";
$ret .= "getName()."\", \" :-? \");'>[img]".XOOPS_URL."/".$smileyPath."/icon_confused.gif[/img]";
$ret .= "getName()."\", \" :-P \");'>[img]".XOOPS_URL."/".$smileyPath."/icon_razz.gif[/img]";
$ret .= "getName()."\", \" :-x \");'>[img]".XOOPS_URL."/".$smileyPath."/icon_mad.gif[/img]";
$ret .= " ["._MORE."]";

return $ret;
}

//---------------------------------------------------------------------------------------//
} // END CLASS
} // END DEFINED
?>
any help would be greatly apprcieated, thanks
Prowler is offline
jtp10181
Veteran Member
Join Date: May 2004
Location: Madison, WI
Old 01-26-2005 , 07:51  
Reply With Quote #5

looks way too confusing to just do it, it would take days.
__________________
jtp10181 is offline
Send a message via ICQ to jtp10181 Send a message via AIM to jtp10181 Send a message via MSN to jtp10181 Send a message via Yahoo to jtp10181
Prowler
Senior Member
Join Date: Nov 2004
Old 01-26-2005 , 10:39  
Reply With Quote #6

curses, ahh well

thanks anyway
Prowler is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:21.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode