=====Wikka-markup in Comments===== >>Working for 1.1.6.0 to 1.1.6.4 (latest)>>To make comments a little bit more flexible, why don't add a part of wikkas markup? I thought about: //italic//, **bold**, ##monospace##, ++strikethough++, __underlined__, ''notes'', WikiWords and InterWikiLinks ===1. Problem=== There is no backwards compatibility to older comments now because of the following problem: Since a formatter for comments does not exist, "handlers/page/addcomment.php", uses nl2br to store the html in the table itself. So older commenst will show up "
" at the end of every line. If you have a wiki without older comments, everything will work fine. ====The Code==== 0. In ##handlers/page/addcomments.php## change the line: %%(php) $body = nl2br($this->htmlspecialchars_ent(trim($_POST["body"]))); %% into the following one: %%(php) $body = $this->htmlspecialchars_ent(trim($_POST["body"])); %% Remaining problem: the
in the already existing comments remain, and will show up now (see above). 1. Search in ##handlers/page/show.php## for //display comments themselves//: There you can find these lines: %%(php) echo '
'."\n". ''.$comment['comment']."\n". "\t".'
'."\n-- "; echo ($this->LoadUser($comment['user']))? $this->Format($comment['user']) : $comment['user']; // #84 %% ''change these statements into these ones''! %%(php) echo '
'."\n". ''.$this->Format($comment['comment'], 'comments')."\n". "\t".'
'."\n-- "; echo ($this->LoadUser($comment['user']))? $this->Format($comment['user'],'comments') : $comment['user']; // #84 %% 2. Save the following as ##formatters/comments.php##: %%(php) '); if ($trigger_italic % 2) echo(''); if ($trigger_underline % 2) echo(''); if ($trigger_monospace % 2) echo(''); if ($trigger_notes % 2) echo (''); if ($trigger_strike % 2) echo (''); if ($trigger_sup % 2) echo ''; if ($trigger_sub % 2) echo ''; $trigger_bold = $trigger_italic = $trigger_underline = $trigger_monospace = $trigger_notes = $trigger_strike = $trigger_sup = $trigger_sub = 0; return; } // convert HTML thingies if ($thing == "<") return "<"; else if ($thing == ">") return ">"; // bold else if ($thing == "**") { return (++$trigger_bold % 2 ? "" : ""); } // italic else if ($thing == "//") { return (++$trigger_italic % 2 ? "" : ""); } // underlinue else if ($thing == "__") { return (++$trigger_underline % 2 ? "" : ""); } // monospace else if ($thing == "##") { return (++$trigger_monospace % 2 ? "" : ""); } // notes else if ($thing == "''") { return (++$trigger_notes % 2 ? "" : ""); } // strikethrough else if ($thing == "++") { return (++$trigger_strike % 2 ? "" : ""); } /* // superscript else if ($thing == "^^") { return (++$trigger_sup % 2 ? "" : ""); } // subscript else if ($thing == "vv") { return (++$trigger_sub % 2 ? "" : ""); } */ // interwiki links! else if (preg_match("/^[A-ZÄÖÜ][A-Za-zÄÖÜßäöü]+[:]\S*$/s", $thing)) { return $wakka->Link($thing); } // wiki links! else if (preg_match("/^[A-ZÄÖÜ]+[a-zßäöü]+[A-Z0-9ÄÖÜ][A-Za-z0-9ÄÖÜßäöü]*$/s", $thing)) { return $wakka->Link($thing); } // new lines else if ($thing == "\n") { $result .= ($br ? "
\n" : "\n"); $br = 1; return $result; } // if we reach this point, it must have been an accident. return $thing; } } $text = str_replace("\r\n", "\n", $text); // replacing part of urls so the don't get italic $text = preg_replace('#://#', "DUMPTEXT", $text); $text = preg_replace_callback( "/(". "\[\[[^\[]*?\]\]|". # forced link "<|>|". #html-tags "\*\*|\'\'|\#\#|\+\+|__|<|>|\/\/|". # Wiki markup "\b[A-ZÄÖÜ][A-Za-zÄÖÜßäöü]+[:](?![=_])\S*\b|". # InterWiki link "\b([A-ZÄÖÜ]+[a-zßäöü]+[A-Z0-9ÄÖÜ][A-Za-z0-9ÄÖÜßäöü]*)\b|". # CamelWords "\n". ")/ms", "comments2callback", $text); // we're cutting the last
$text = preg_replace("/
$/","", $text); // re-replacing the url-part $text = ereg_replace("DUMPTEXT", "://", $text); // $text = $this->Typography($text); // only needed for SmartyPants in comments (see there) echo ($text); comments2callback('closetags'); ?>%% ====Configurable comment markup==== 1. Add the following line to ##wikka.config.php##: %%(php) "markup_comments" => "1", %% where '1' means to allow markup and '0' means to disallow it. 2. In ##handlers/page/addcomments.php## change the line: %%(php) $body = nl2br($this->htmlspecialchars_ent(trim($_POST["body"]))); %% into the following statement: %%(php) if (($this->GetConfigValue('markup_comments') == 1) && file_exists('formatters/comments.php')) { $body = $this->htmlspecialchars_ent(trim($_POST["body"])); } else { $body = nl2br($this->htmlspecialchars_ent(trim($_POST["body"]))); } %% 3. Search in ##handlers/page/show.php## for //display comments themselves//: There you can find these lines: %%(php) echo '
'."\n". ''.$comment['comment']."\n". "\t".'
'."\n-- "; echo ($this->LoadUser($comment['user']))? $this->Format($comment['user']) : $comment['user']; // #84 %% ''change these statements into these ones''! %%(php) if (($this->GetConfigValue('markup_comments') == 1) && file_exists('formatters/comments.php')) { echo '
'."\n". ''.$this->Format($comment['comment'], 'comments')."\n". "\t".'
'."\n-- "; echo ($this->LoadUser($comment['user']))? $this->Format($comment['user'],'comments') : $comment['user']; // #84 } else { echo '
'."\n". ''.$comment['comment']."\n". "\t".'
'."\n-- "; echo ($this->LoadUser($comment['user']))? $this->Format($comment['user']) : $comment['user']; // #84 } %% 3. Use the ##comments.php## from above. ---- CategoryUsercontributions