11
Peekay
Re: Problem with Xoops CODE tag
  • 2010/8/4 21:32

  • Peekay

  • XOOPS is my life!

  • Posts: 2335

  • Since: 2004/11/20


Er... I spoke too soon.

The editor works, but the code tag still fails.

It seems to be the codeConv function. I suspect the syntax highlighter needs something newer to work with than whatever the antique module is giving it!

If I swap the funcs (as I did in an earlier test) it works, although without the syntax highlighting.

This is the 2.4.5 function:

le="color: #000000"><?php function codeConv($text, $xcode = 1) { if (empty($xcode)) { return $text; } $patterns = "/[code([^]]*?)](.*)[/code]/esU"; $replacements = "'<div class="xoopsCode"><code>'.$this->executeExtension('syntaxhighlight', str_replace('"', '"', base64_decode('$2')), '$1').'</code></div>'"; $text = preg_replace($patterns, $replacements, $text); return $text; }


This is the one from 2.0.18 (works)

le="color: #000000"><?php function codeConv($text, $xcode = 1, $image = 1){ if($xcode != 0){ $patterns = "/[code](.*)[/code]/esU"; if ($image != 0) { // image allowed $replacements = "'<div class="xoopsCode"><code><pre>'.MyTextSanitizer::codeSanitizer('$1').'</pre></code></div>'"; //$text =& $this->xoopsCodeDecode($text); } else { // image not allowed $replacements = "'<div class="xoopsCode"><code><pre>'.MyTextSanitizer::codeSanitizer('$1', 0).'</pre></code></div>'"; //$text =& $this->xoopsCodeDecode($text, 0); } $text = preg_replace($patterns, $replacements, $text); } return $text; }


Some more digging required.
A thread is for life. Not just for Christmas.

12
Catzwolf
Re: Problem with Xoops CODE tag
  • 2010/8/5 5:16

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


Is there any chance I can have a look at what you are trying to do here? Can I see the code please? Sometimes a fresh pair of eyes on something helps :)

Catz

13
Peekay
Re: Problem with Xoops CODE tag
  • 2010/8/5 9:48

  • Peekay

  • XOOPS is my life!

  • Posts: 2335

  • Since: 2004/11/20


Thx Catz.

The developer appears to have created a custom function to render the DHTML editor, rather than just adding it as an object. The buttons like 'xoopsCodeEmail' relied on methods in xoops.js which have since been moved, but I resolved that by adding the new JS (as mentioned before).

Everything now works except the code tag - unless I use the old 'codeConv' method from Xoops 2.0.18.

Here's the function

le="color: #000000"><?php function arms_text_area($textarea_id, $cols=60, $rows=15, $suffix=null, $tarea_text='') { // This function doesn`t prints data, it puts in one large string so you can // pass it as smarty variable... Like I said: I`m template junky :) $return = ''; $hiddentext = isset($suffix) ? 'xoopsHiddenText' . trim($suffix) : 'xoopsHiddenText'; //Hack for url, email ...., the anchor is for having a link on [_More...] $return .= "<a name='moresmiley'></a> <img src='".XOOPS_URL."/images/url.gif' alt='url' onmouseover='style.cursor="hand"' onclick='xoopsCodeUrl("$textarea_id");'/>&nbsp; <img src='".XOOPS_URL."/images/email.gif' alt='email' onmouseover='style.cursor="hand"' onclick='xoopsCodeEmail("$textarea_id");' />&nbsp; <img src='".XOOPS_URL."/images/imgsrc.gif' alt='imgsrc' onmouseover='style.cursor="hand"' onclick='xoopsCodeImg("$textarea_id");' />&nbsp; <img src='".XOOPS_URL."/images/image.gif' alt='image' onmouseover='style.cursor="hand"' onclick='openWithSelfMain("".XOOPS_URL."/imagemanager.php?target=".$textarea_id."","imgmanager",400,430);' />&nbsp; <img src='".XOOPS_URL."/images/code.gif' alt='code' onmouseover='style.cursor="hand"' onclick='xoopsCodeCode("$textarea_id");' />&nbsp; <img src='".XOOPS_URL."/images/quote.gif' alt='quote' onmouseover='style.cursor="hand"' onclick='xoopsCodeQuote("$textarea_id");'/><br />n"; $sizearray = array("xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large"); $return .= "<select id='".$textarea_id."Size' onchange='setVisible("xoopsHiddenText");setElementSize("".$hiddentext."",this.options[this.selectedIndex].value);'>n"; $return .= "<option value='SIZE'>"._SIZE."</option>n"; foreach ( $sizearray as $size ) { $return .= "<option value='$size'>$size</option>n"; } $return .= "</select>n"; $fontarray = array("Arial", "Courier", "Georgia", "Helvetica", "Impact", "Verdana"); $return .= "<select id='".$textarea_id."Font' onchange='setVisible("xoopsHiddenText");setElementFont("".$hiddentext."",this.options[this.selectedIndex].value);'>n"; $return .= "<option value='FONT'>"._FONT."</option>n"; foreach ( $fontarray as $font ) { $return .= "<option value='$font'>$font</option>n"; } $return .= "</select>n"; $colorarray = array("00", "33", "66", "99", "CC", "FF"); $return .= "<select id='".$textarea_id."Color' onchange='setVisible("xoopsHiddenText");setElementColor("".$hiddentext."",this.options[this.selectedIndex].value);'>n"; $return .= "<option value='COLOR'>"._COLOR."</option>n"; foreach ( $colorarray as $color1 ) { foreach ( $colorarray as $color2 ) { foreach ( $colorarray as $color3 ) { $return .= "<option value='".$color1.$color2.$color3."' style='background-color:#".$color1.$color2.$color3.";color:#".$color1.$color2.$color3.";'>#".$color1.$color2.$color3."</option>n"; } } } $return .= "</select><span id='".$hiddentext."'>"._EXAMPLE."</span>n"; $return .= "<br />n"; //Hack smilies move for bold, italic ... $return .= "<img src='".XOOPS_URL."/images/bold.gif' alt='bold' onmouseover='style.cursor="hand"' onclick='setVisible("".$hiddentext."");makeBold("".$hiddentext."");' />&nbsp;<img src='".XOOPS_URL."/images/italic.gif' alt='italic' onmouseover='style.cursor="hand"' onclick='setVisible("".$hiddentext."");makeItalic("".$hiddentext."");' />&nbsp;<img src='".XOOPS_URL."/images/underline.gif' alt='underline' onmouseover='style.cursor="hand"' onclick='setVisible("".$hiddentext."");makeUnderline("".$hiddentext."");'/>&nbsp;<img src='".XOOPS_URL."/images/linethrough.gif' alt='linethrough' onmouseover='style.cursor="hand"' onclick='setVisible("".$hiddentext."");makeLineThrough("".$hiddentext."");' /></a>&nbsp;<input type='text' id='".$textarea_id."Addtext' size='20' />&nbsp;<input type='button' onclick='xoopsCodeText("$textarea_id", "".$hiddentext."")' value='"._ADD."' /><br /><br />"; $return .= "<textarea id='".$textarea_id."' name='".$textarea_id."' cols='$cols' rows='$rows'>" . $tarea_text ."</textarea><br />n"; return $return; //Fin du hack } function amrs_emotions($textarea_id) { $return = ''; $myts =& MyTextSanitizer::getInstance(); $smiles =& $myts->getSmileys(); if (empty($smileys)) { $db =& Database::getInstance(); if ($result = $db->query('SELECT * FROM '.$db->prefix('smiles').' WHERE display=1')) { while ($smiles = $db->fetchArray($result)) { //hack smilies move for the smilies !! $return .= "<img src='".XOOPS_URL."/uploads/".htmlspecialchars($smiles['smile_url'])."' border='0' onmouseover='style.cursor="hand"' alt='' onclick='xoopsCodeSmilie("".$textarea_id."", " ".$smiles['code']." ");' />"; //fin du hack } } } else { $count = count($smiles); for ($i = 0; $i < $count; $i++) { if ($smiles[$i]['display'] == 1) { //hack bis $return .= "<img src='".XOOPS_URL."/uploads/".$myts->oopsHtmlSpecialChars($smiles['smile_url'])."' border='0' alt='' onclick='xoopsCodeSmilie("".$textarea_id."", " ".$smiles[$i]['code']." ");' onmouseover='style.cursor="hand"' />"; //fin du hack } } } //hack for more $return .= "&nbsp;[<a href='#moresmiley' onmouseover='style.cursor="hand"' alt='' onclick='openWithSelfMain("".XOOPS_URL."/misc.php?action=showpopups&type=smilies&target=".$textarea_id."","smilies",300,475);'>"._MORE."</a>]"; return $return; } //fin du hack


I could re-write the forms, but I would rather not if it can be avoided!
A thread is for life. Not just for Christmas.

Login

Donat-O-Meter

Stats
Goal: $15.00
Due Date: Jul 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $15.00
Make donations with PayPal!

Latest GitHub Commits