Revision history for CommentsFormatting


Revision [20003]

Last edited on 2008-06-04 04:32:43 by MasinAlDujaili [working versions]
Additions:
>>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?
Deletions:
To make comments a little bit more flexible, why don't add a part of wikkas markup?


Revision [18891]

Edited on 2008-01-28 00:13:02 by MasinAlDujaili [Modified links pointing to docs server]

No Differences

Revision [14661]

Edited on 2006-06-21 08:04:02 by MasinAlDujaili [comments.php updated ...]
Additions:
static $br = 1;
if ((!is_array($things)) && ($things == 'closetags'))
// strikethrough
"\[\[[^\[]*?\]\]|". # 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
// $text = $this->Typography($text); // only needed for SmartyPants in comments (see there)
?>%%
Deletions:
static $br = 1;
if ((!is_array($things)) && ($things == 'closetags'))
// strikethrough
"<|>|". #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|". # CamelCaseWords
?>
%%


Revision [14660]

Edited on 2006-06-21 07:49:27 by MasinAlDujaili [made comment markup a configurable option, corrected some errors for 1.1.6.2]
Additions:
0. In ##handlers/page/addcomments.php## change the line:
$body = nl2br($this->htmlspecialchars_ent(trim($_POST["body"])));
into the following one:
1. Search in ##handlers/page/show.php## for //display comments themselves//:
There you can find these lines:
echo '<div class="comment">'."\n".
'<span id="comment_'.$comment['id'].'"></span>'.$comment['comment']."\n".
"\t".'<div class="commentinfo">'."\n-- ";
echo ($this->LoadUser($comment['user']))? $this->Format($comment['user']) : $comment['user']; // #84
''change these statements into these ones''!
echo '<div class="comment">'."\n".
"\t".'<div class="commentinfo">'."\n-- ";
echo ($this->LoadUser($comment['user']))? $this->Format($comment['user'],'comments') : $comment['user']; // #84
====Configurable comment markup====
1. Add the following line to ##wikka.config.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:
$body = nl2br($this->htmlspecialchars_ent(trim($_POST["body"])));
into the following statement:
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:
echo '<div class="comment">'."\n".
'<span id="comment_'.$comment['id'].'"></span>'.$comment['comment']."\n".
"\t".'<div class="commentinfo">'."\n-- ";
echo ($this->LoadUser($comment['user']))? $this->Format($comment['user']) : $comment['user']; // #84
''change these statements into these ones''!
if (($this->GetConfigValue('markup_comments') == 1) && file_exists('formatters/comments.php'))
{
echo '<div class="comment">'."\n".
'<span id="comment_'.$comment['id'].'"></span>'.$this->Format($comment['comment'], 'comments')."\n".
"\t".'<div class="commentinfo">'."\n-- ";
echo ($this->LoadUser($comment['user']))? $this->Format($comment['user'],'comments') : $comment['user']; // #84
}
else {
echo '<div class="comment">'."\n".
'<span id="comment_'.$comment['id'].'"></span>'.$comment['comment']."\n".
"\t".'<div class="commentinfo">'."\n-- ";
echo ($this->LoadUser($comment['user']))? $this->Format($comment['user']) : $comment['user']; // #84
}
3. Use the ##comments.php## from above.
Deletions:
0. change line 7 in ##formatters/page/addcomments.php## into the following one:
1. Search in the ##handlers/page/show.php## for //display comments themselves//:
There you can find a line:
%%(php) print("<div class=\"comment\">\n");%%
''change the two lines after that into these ones''!
"\t".'<div class="commentinfo">'."\n-- ".$this->Format($comment['user'], 'comments').' ('.$comment['time'].")\n";


Revision [14658]

Edited on 2006-06-21 05:59:31 by MasinAlDujaili [update to 1.1.6.2: print statements to echo statements]
Additions:
'<span id="comment_'.$comment['id'].'"></span>'.$this->Format($comment['comment'], 'comments')."\n".
"\t".'<div class="commentinfo">'."\n-- ".$this->Format($comment['user'], 'comments').' ('.$comment['time'].")\n";
$thing = $things[1];
$result='';
static $trigger_bold = 0;
static $trigger_italic = 0;
static $trigger_underline = 0;
static $trigger_monospace = 0;
static $trigger_notes = 0;
static $trigger_strike = 0;
static $trigger_sup = 0;
static $trigger_sub = 0;
static $br = 1;
global $wakka;
{
}
// convert HTML thingies
if ($thing == "<") return "<";
else if ($thing == ">") return ">";
// bold
else if ($thing == "**")
{
}
// italic
else if ($thing == "//")
{
}
// underlinue
else if ($thing == "__")
{
}
// monospace
else if ($thing == "##")
{
}
// notes
else if ($thing == "''")
{
}
else if ($thing == "++")
{
}
/*
// superscript
else if ($thing == "^^")
{
}
// subscript
else if ($thing == "vv")
{
}
*/
// interwiki links!
else if (preg_match("/^[A-ZÄÖÜ][A-Za-zÄÖÜßäöü]+[:]\S*$/s", $thing))
{
}
// wiki links!
else if (preg_match("/^[A-ZÄÖÜ]+[a-zßäöü]+[A-Z0-9ÄÖÜ][A-Za-z0-9ÄÖÜßäöü]*$/s", $thing))
{
}
// new lines
else if ($thing == "\n")
{
}
// if we reach this point, it must have been an accident.
return $thing;
Deletions:
print("<span id=\"comment_".$comment["id"]."\"></span>".$this->Format($comment["comment"], "comments")."\n");
print("\t<div class=\"commentinfo\">\n-- ".$this->Format($comment["user"], "comments")." (".$comment["time"].")\n");
$thing = $things[1];
$result='';

static $trigger_bold = 0;
static $trigger_italic = 0;
static $trigger_underline = 0;
static $trigger_monospace = 0;
static $trigger_notes = 0;
static $trigger_strike = 0;
static $trigger_sup = 0;
static $trigger_sub = 0;
static $br = 1;
global $wakka;
{
}
// convert HTML thingies
if ($thing == "<") return "<";
else if ($thing == ">") return ">";
// bold
else if ($thing == "**")
{
}
// italic
else if ($thing == "//")
{
}
// underlinue
else if ($thing == "__")
{
}
// monospace
else if ($thing == "##")
{
}
// notes
else if ($thing == "''")
{
}
else if ($thing == "++")
{
}
/*
// superscript
else if ($thing == "^^")
{
}
// subscript
else if ($thing == "vv")
{
}
*/
// interwiki links!
else if (preg_match("/^[A-ZÄÖÜ][A-Za-zÄÖÜßäöü]+[:]\S*$/s", $thing))
{
}
// wiki links!
else if (preg_match("/^[A-ZÄÖÜ]+[a-zßäöü]+[A-Z0-9ÄÖÜ][A-Za-z0-9ÄÖÜßäöü]*$/s", $thing))
{
}
// new lines
else if ($thing == "\n")
{
}
// if we reach this point, it must have been an accident.
return $thing;


Revision [6444]

Edited on 2005-03-03 14:19:20 by NilsLindenberg [explanation rewritten]
Additions:
===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 "<br />" at the end of every line.
If you have a wiki without older comments, everything will work fine.
0. change line 7 in ##formatters/page/addcomments.php## into the following one:
Remaining problem: the <br /> in the already existing comments remain, and will show up now (see above).
Deletions:
===1. Problems===
I used the code of wakka.php, but there is problem remaining:
==html in the comments-table==
A "forced" line-break (enter-key) leads to an <br />, which shouldn't be there. The source of this problem: since a formatter for comments does not exist, "handlers/page/addcomment.php", uses nl2br to store the html in the table itself.
Solution:
change line 7 in ##formatters/page/addcomments.php## into the following one:
Remaining problem: the <br /> in the already existing comments remain, and will show up now.


Revision [6009]

Edited on 2005-02-15 19:29:07 by NilsLindenberg [code update, solving little problem with WikiWords and first solution to italic]
Additions:
I used the code of wakka.php, but there is problem remaining:
$text = preg_replace('#://#', "DUMPTEXT", $text);
"\b(^[A-ZÄÖÜ]+[a-zßäöü]+[A-Z0-9ÄÖÜ][A-Za-z0-9ÄÖÜßäöü]*)\b|". # CamelCaseWords
$text = ereg_replace("DUMPTEXT", "://", $text);
%%
Deletions:
I used the code of wakka.php, but there are two problems remaining:
==urls getting "italic"==
- http://example.com gets "italic" => http: //www.example.com//. I want to replace ""://"" before the formatting, but cant get the regexp work. At the moment I use "/[:\/\/]/".
// $text = str_replace("/[:]\/\//", "DUMPTEXT", $text);
"\b([A-ZÄÖÜ]+[a-zßäöü]+[A-Z0-9ÄÖÜ][A-Za-z0-9ÄÖÜßäöü]*)\b|". # CamelCaseWords
// $text = ereg_replace("DUMPTEXT", "://", $text);


Revision [5990]

Edited on 2005-02-15 11:04:59 by NilsLindenberg [more on addcomments]
Additions:
A "forced" line-break (enter-key) leads to an <br />, which shouldn't be there. The source of this problem: since a formatter for comments does not exist, "handlers/page/addcomment.php", uses nl2br to store the html in the table itself.
Solution:
change line 7 in ##formatters/page/addcomments.php## into the following one:
$body = $this->htmlspecialchars_ent(trim($_POST["body"]));
Remaining problem: the <br /> in the already existing comments remain, and will show up now.
Deletions:
A "forced" line-break (enter-key) leads to an <br>, which shouldn't be there. The source of this problem: we dont have a formatter for comments, so "handlers/page/addcomment.php", has to use nl2br to store the html in the table itself.
It is easy to get rid of that, but a problem with older comments remains.


Revision [5988]

Edited on 2005-02-15 11:00:21 by NilsLindenberg [code + explanation]
Additions:
===1. Problems===
I used the code of wakka.php, but there are two problems remaining:
==urls getting "italic"==
- http://example.com gets "italic" => http: //www.example.com//. I want to replace ""://"" before the formatting, but cant get the regexp work. At the moment I use "/[:\/\/]/".
==html in the comments-table==
A "forced" line-break (enter-key) leads to an <br>, which shouldn't be there. The source of this problem: we dont have a formatter for comments, so "handlers/page/addcomment.php", has to use nl2br to store the html in the table itself.
It is easy to get rid of that, but a problem with older comments remains.
====The Code====
1. Search in the ##handlers/page/show.php## for //display comments themselves//:
There you can find a line:
%%(php) print("<div class=\"comment\">\n");%%
''change the two lines after that into these ones''!
%%(php)
print("<span id=\"comment_".$comment["id"]."\"></span>".$this->Format($comment["comment"], "comments")."\n");
print("\t<div class=\"commentinfo\">\n-- ".$this->Format($comment["user"], "comments")." (".$comment["time"].")\n");
%%
2. Save the following as ##formatters/comments.php##:
%%(php)
<?php
// This may look a bit strange, but all possible formatting tags have to be in a single regular expression for this to work correctly. Yup!
//#dotmg [many lines] : Unclosed tags fix! For more info, m.randimbisoa@dotmg.net ((only indents? --NilsLindenberg))
if (!function_exists("comments2callback"))
{
function comments2callback($things)
{
$thing = $things[1];
$result='';

static $trigger_bold = 0;
static $trigger_italic = 0;
static $trigger_underline = 0;
static $trigger_monospace = 0;
static $trigger_notes = 0;
static $trigger_strike = 0;
static $trigger_sup = 0;
static $trigger_sub = 0;
static $br = 1;
global $wakka;
if ((!is_array($things)) && ($things == 'closetags'))
{
if ($trigger_bold % 2) echo('</strong>');
if ($trigger_italic % 2) echo('</em>');
if ($trigger_underline % 2) echo('</span>');
if ($trigger_monospace % 2) echo('</tt>');
if ($trigger_notes % 2) echo ('</span>');
if ($trigger_strike % 2) echo ('</span>');
if ($trigger_sup % 2) echo '</sup>';
if ($trigger_sub % 2) echo '</sub>';
$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 ? "<strong>" : "</strong>");
}

// italic
else if ($thing == "//")
{
return (++$trigger_italic % 2 ? "<em>" : "</em>");
}

// underlinue
else if ($thing == "__")
{
return (++$trigger_underline % 2 ? "<span class=\"underline\">" : "</span>");
}
// monospace
else if ($thing == "##")
{
return (++$trigger_monospace % 2 ? "<tt>" : "</tt>");
}

// notes
else if ($thing == "''")
{
return (++$trigger_notes % 2 ? "<span class=\"notes\">" : "</span>");
}
// strikethrough
else if ($thing == "++")
{
return (++$trigger_strike % 2 ? "<span class=\"strikethrough\">" : "</span>");
}
/*
// superscript
else if ($thing == "^^")
{
return (++$trigger_sup % 2 ? "<sup>" : "</sup>");
}

// subscript
else if ($thing == "vv")
{
return (++$trigger_sub % 2 ? "<sub>" : "</sub>");
}
*/
// 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 ? "<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 = str_replace("/[:]\/\//", "DUMPTEXT", $text);
$text = preg_replace_callback(
"/(".
"<|>|". #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|". # CamelCaseWords
"\n".
")/ms", "comments2callback", $text);
// we're cutting the last <br />
$text = preg_replace("/<br \/>$/","", $text);
// re-replacing the url-part
// $text = ereg_replace("DUMPTEXT", "://", $text);
echo ($text);
comments2callback('closetags');
?>
%%
Deletions:
===Problems===
I used the code of wakka.php, but there are some problems remaining:
- http://example.com gets "italiced" => http: //www.example.com//. I want to replace ""://"" before the formatting, but cant get the regexp work. At the moment I use "/[:\/\/]/".
- a "forced" line-break (enter-key) leads to an <br>, which shouldn't be there
//code follows//


Revision [5967]

The oldest known version of this page was created on 2005-02-14 15:23:44 by NilsLindenberg [code + explanation]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki