Index: config.php =================================================================== RCS file: /cvsroot/gnuheter/gnuheter/config.php,v retrieving revision 1.2 diff -u -r1.2 config.php --- config.php 10 Aug 2002 15:53:12 -0000 1.2 +++ config.php 31 Aug 2002 22:47:51 -0000 @@ -71,6 +71,29 @@ $meta_description = "Gnuheter - Fria nyheter om fri programvara"; ###################################################################### +# +# Speller options +# +# $speling: Enable spell checking (1=Yes 0=No) +# $php_speller: Use the internal php hooks to pspell. (1=Yes 0=No) +# $external_speller: External spell checker that returns a +# spellchecked version of the given text. +# Takes to args -s "string-to-spellcheck" +# -d "dictionary" +# +# $dictionary: If php_speller is used: sv or en +# If external_speller is used: svenska or english +# +# +# If both external- and php-speller is set the php speller is chosen. +# + +$speling = 1; +$php_speller = 1; +$external_speller = "tools/speller.pl"; +$dictionary = "sv"; + +###################################################################### # General Stories Options # # $top: How many items in Top Page? Index: mainfile.php =================================================================== RCS file: /cvsroot/gnuheter/gnuheter/mainfile.php,v retrieving revision 1.11 diff -u -r1.11 mainfile.php --- mainfile.php 28 Aug 2002 17:12:32 -0000 1.11 +++ mainfile.php 31 Aug 2002 22:47:51 -0000 @@ -647,4 +647,59 @@ } +/*********************************************************/ +/* Spell check functions */ +/*********************************************************/ + +function spellcheck ($text="") { + global $speling, $external_speller, $dictionary, $php_speller, $spellcheckbox; + + if ($speling == 0) + return $text . $spellcheckbox; + + if ($php_speller) { + $result = php_speller($text, $dictionary); + } else if ($external_speller) { + $spell_text = escapeshellarg($text); + $result = shell_exec("$external_speller -d $dictionary -s $spell_text"); + } else { + $result = $text; + } + + if (! $result) + $result = $text; + + return $result; +} + +function php_speller($text="", $dictionary="sv") { + $spell_text = $text; + $pspell_link = pspell_new($dictionary); + $allwords = array(); + + $spell_text = preg_replace("/<[^>]+>/", "", $spell_text); // Remove html + if (preg_match_all('/([A-Za-zÅÄÖåäö]+)/', $spell_text, $matches)) { + foreach ($matches[0] as $match) { + if ($match == "SPELLWORD") { + continue; + } + if (! pspell_check ($pspell_link, $match)) { + $tooltip = "Inga förslag."; + if ($suggestions = join(', ', pspell_suggest($pspell_link, $match))) { + $tooltip = " title='Förslag: $suggestions'"; + $allwords[$match] = $tooltip; + } + $text = preg_replace("/(^|[^A-Za-zÅÄÖåäö]+)($match)([^A-Za-zÅÄÖåäö]+|$)/", "$1$2$3", $text); + } + } + } + + foreach (array_keys($allwords) as $word) { + $text = preg_replace("/$word/", "$word", $text); + } + + return $text; +} + + ?> Index: main.css =================================================================== RCS file: /cvsroot/gnuheter/gnuheter/main.css,v retrieving revision 1.4 diff -u -r1.4 main.css --- main.css 24 Jul 2002 08:12:17 -0000 1.4 +++ main.css 31 Aug 2002 22:47:51 -0000 @@ -85,3 +85,9 @@ border-width: thin; font-weight: bold; } + +.speling +{ + color: #FF3333; + font-style: italic; +} Index: main_ns.css =================================================================== RCS file: /cvsroot/gnuheter/gnuheter/main_ns.css,v retrieving revision 1.4 diff -u -r1.4 main_ns.css --- main_ns.css 24 Jul 2002 08:12:17 -0000 1.4 +++ main_ns.css 31 Aug 2002 22:47:51 -0000 @@ -73,3 +73,9 @@ border-width: thin; font-weight: bold; } + +.speling +{ + color: #FF3333; + font-style: italic; +} Index: submit.php =================================================================== RCS file: /cvsroot/gnuheter/gnuheter/submit.php,v retrieving revision 1.5 diff -u -r1.5 submit.php --- submit.php 23 Aug 2002 00:12:51 -0000 1.5 +++ submit.php 31 Aug 2002 22:47:51 -0000 @@ -61,6 +61,7 @@ (HTML går bra, men dubbelkolla dina URL:ar och HTML-taggar!)

(Testade du dina länkar om de fungerade? Skrev du in dem korrekt?)

+

Ämne:
(Testade du dina länkar om de fungerade? Skrev du in dem korrekt?)

+
\n"; while (list($key,)= each($AllowableHTML)) echo " <".$key.">"; echo "
\n"; - if ($user) { echo " Posta anonymt
\n"; } + if ($user) { echo " 
\n"; } + + echo " 
\n"; + echo "\n" ."\n" ."\n" @@ -327,7 +330,7 @@ include('footer.php'); } -function replyPreview ($pid, $sid, $subject, $comment, $postanon, $mode, $order, $thold, $posttype) { +function replyPreview ($pid, $sid, $subject, $comment, $postanon, $mode, $order, $thold, $posttype, $spell) { global $mainfile,$dbhost,$dbuname,$dbpass,$dbname,$REQUEST_URI; if(address@hidden) include('header.php'); @@ -352,8 +355,8 @@ else $viewcomment = $comment; - echo format_comment_header($name,$subject,$tid,$date,"","",0); - echo format_comment_body($viewcomment,$sid,$tid,$thold,$order,$cookie[10]); + echo format_comment_header($name,($spell) ? spellcheck($subject) : $subject,$tid,$date,"","",0); + echo format_comment_body(($spell) ? spellcheck($viewcomment) : $viewcomment,$sid,$tid,$thold,$order,$cookie[10]); echo "


\n"; @@ -369,7 +372,10 @@ echo "
\n"; if ($postanon) $postanon_check = " checked"; else $postanon_check = ""; if ($user) - echo " Posta anonymt
\n"; + echo " 
\n"; + + echo " 
\n"; + echo "" ."\n" ."\n" @@ -451,7 +457,7 @@ reply($pid, $sid, $mode, $order, $thold); break; case "Preview": - replyPreview($pid, $sid, $subject, $comment, $postanon, $mode, $order, $thold, $posttype); + replyPreview($pid, $sid, $subject, $comment, $postanon, $mode, $order, $thold, $posttype, $spell); break; case "Ok!": CreateTopic($postanon, $subject, $comment, $pid, $sid, $host_name, $mode, $order, $thold, $posttype); Index: pollcomments.php =================================================================== RCS file: /cvsroot/gnuheter/gnuheter/pollcomments.php,v retrieving revision 1.5 diff -u -r1.5 pollcomments.php --- pollcomments.php 15 Aug 2002 20:31:24 -0000 1.5 +++ pollcomments.php 31 Aug 2002 22:47:52 -0000 @@ -318,7 +318,10 @@ echo "Tillåten HTML:
\n"; while (list($key,)= each($AllowableHTML)) echo " <".$key.">"; echo "
\n"; - if ($user) { echo " Posta anonymt
\n"; } + if ($user) { echo " 
\n"; } + + echo " 
\n"; + echo "\n" ."\n" ."\n" @@ -328,7 +331,7 @@ include('footer.php'); } -function replyPreview ($pid, $sid, $subject, $comment, $postanon, $mode, $order, $thold, $posttype) { +function replyPreview ($pid, $sid, $subject, $comment, $postanon, $mode, $order, $thold, $posttype, $spell) { global $mainfile,$dbhost,$dbuname,$dbpass,$dbname,$REQUEST_URI; if(address@hidden) include('header.php'); @@ -353,8 +356,9 @@ else $viewcomment = $comment; - echo format_comment_header($name,$subject,$tid,$date,"","",0); - echo format_comment_body($viewcomment,$sid,$tid,$thold,$order,$cookie[10]); + + echo format_comment_header($name,($spell) ? spellcheck($subject) : $subject, $tid,$date,"","",0); + echo format_comment_body(($spell) ? spellcheck($viewcomment) : $viewcomment, $sid,$tid,$thold,$order,$cookie[10]); echo "
\n"; @@ -370,7 +374,10 @@ echo "
\n"; if ($postanon) $postanon_check = " checked"; else $postanon_check = ""; if ($user) - echo " Posta anonymt
\n"; + echo " 
\n"; + + echo " 
\n"; + echo "" ."\n" ."\n" @@ -455,7 +462,7 @@ reply($pid, $pollID, $mode, $order, $thold); break; case "Preview": - replyPreview($pid, $pollID, $subject, $comment, $postanon, $mode, $order, $thold, $posttype); + replyPreview($pid, $pollID, $subject, $comment, $postanon, $mode, $order, $thold, $posttype, $spell); break; case "Ok!": CreateTopic($postanon, $subject, $comment, $pid, $pollID, $host_name, $mode, $order, $thold, $posttype);