? config.php.spell ? spell-patch.diff Index: comments.php =================================================================== RCS file: /cvsroot/gnuheter/gnuheter/comments.php,v retrieving revision 1.8 diff -u -r1.8 comments.php --- comments.php 28 Oct 2002 18:03:35 -0000 1.8 +++ comments.php 28 Oct 2002 23:59:15 -0000 @@ -319,7 +319,11 @@ echo "
\n"; if ($user) { echo " Posta anonymt
\n"; - echo " Infoga signatur
\n";} + echo " Infoga signatur
\n"; + } + if($speling) { + echo " 
\n"; + } echo "\n" ."\n" ."\n" @@ -329,7 +333,7 @@ include('footer.php'); } -function replyPreview ($medsig, $pid, $sid, $subject, $comment, $postanon, $mode, $order, $thold, $posttype) { +function replyPreview ($medsig, $pid, $sid, $subject, $comment, $postanon, $mode, $order, $thold, $posttype, $spell) { global $mainfile,$dbhost,$dbuname,$dbpass,$dbname,$REQUEST_URI; if(address@hidden) include('header.php'); @@ -356,8 +360,8 @@ else $viewcomment = $comment.$usersig; - 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"; @@ -375,7 +379,11 @@ if ($medsig) $medsig_check = " checked"; else $medsig_check = ""; if ($user) { echo " Posta anonymt
\n"; - echo " Infoga signatur
\n";} + echo " Infoga signatur
\n"; + } + if ($speling) { + echo " 
\n"; + } echo "" ."\n" ."\n" @@ -459,7 +467,7 @@ reply($pid, $sid, $mode, $order, $thold); break; case "Preview": - replyPreview($medsig, $pid, $sid, $subject, $comment, $postanon, $mode, $order, $thold, $posttype); + replyPreview($medsig, $pid, $sid, $subject, $comment, $postanon, $mode, $order, $thold, $posttype, $spell); break; case "Ok!": CreateTopic($medsig, $postanon, $subject, $comment, $pid, $sid, $host_name, $mode, $order, $thold, $posttype); Index: config.php =================================================================== RCS file: /cvsroot/gnuheter/gnuheter/config.php,v retrieving revision 1.5 diff -u -r1.5 config.php --- config.php 24 Sep 2002 17:18:17 -0000 1.5 +++ config.php 28 Oct 2002 23:59:15 -0000 @@ -71,6 +71,30 @@ $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 = 0; +$php_speller = 1; +$external_speller = "tools/speller.pl"; +$dictionary = "sv"; + + +###################################################################### # General Stories Options # # $top: How many items in Top Page? Index: diary.php =================================================================== RCS file: /cvsroot/gnuheter/gnuheter/diary.php,v retrieving revision 1.7 diff -u -r1.7 diary.php --- diary.php 24 Sep 2002 17:18:17 -0000 1.7 +++ diary.php 28 Oct 2002 23:59:15 -0000 @@ -207,7 +207,7 @@ if ($REQUEST_METHOD == "POST") $diary = stripslashes_array($diary); include('header.php'); if ($diary['title'] or $diary['bodytext']) { - themearticle($loggeduser,$loggeduser,"<inget datum ännu>",$diary['title'],wordlinks($diary['bodytext']),0,"Dabok","diary.png","Dagbok"); + themearticle($loggeduser,$loggeduser,"<inget datum ännu>",($diary['spell']) ? spellcheck($diary['title']) : $diary['title'], wordlinks(($diary['spell'] ) ? spellcheck($diary['bodytext']) : $diary['bodytext']),0,"Dabok","diary.png","Dagbok"); echo "
\n"; } diary_form($diary); @@ -219,11 +219,16 @@ } } -function diary_form ($diary=array()) { ?> +function diary_form ($diary=array()) { + global $speling; + ?>
Titel:


Inlägget:


+ +
+
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 28 Oct 2002 23:59:15 -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 28 Oct 2002 23:59:15 -0000 @@ -73,3 +73,9 @@ border-width: thin; font-weight: bold; } + +.speling +{ + color: #FF3333; + font-style: italic; +} Index: mainfile.php =================================================================== RCS file: /cvsroot/gnuheter/gnuheter/mainfile.php,v retrieving revision 1.15 diff -u -r1.15 mainfile.php --- mainfile.php 28 Oct 2002 18:03:35 -0000 1.15 +++ mainfile.php 28 Oct 2002 23:59:15 -0000 @@ -690,4 +690,60 @@ } +/*********************************************************/ +/* 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: pollcomments.php =================================================================== RCS file: /cvsroot/gnuheter/gnuheter/pollcomments.php,v retrieving revision 1.7 diff -u -r1.7 pollcomments.php --- pollcomments.php 28 Oct 2002 18:03:35 -0000 1.7 +++ pollcomments.php 28 Oct 2002 23:59:15 -0000 @@ -320,7 +320,12 @@ echo "
\n"; if ($user) { echo " Posta anonymt
\n"; - echo " Infoga signatur
\n";} + echo " Infoga signatur
\n"; + } + if($speling) { + echo " 
\n"; + } + echo "\n" ."\n" ."\n" @@ -330,7 +335,7 @@ include('footer.php'); } -function replyPreview ($medsig, $pid, $sid, $subject, $comment, $postanon, $mode, $order, $thold, $posttype) { +function replyPreview ($medsig, $pid, $sid, $subject, $comment, $postanon, $mode, $order, $thold, $posttype, $spell) { global $mainfile,$dbhost,$dbuname,$dbpass,$dbname,$REQUEST_URI; if(address@hidden) include('header.php'); @@ -357,8 +362,8 @@ else $viewcomment = $comment.$usersig; - 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"; @@ -376,7 +381,11 @@ if ($medsig) $medsig_check = " checked"; else $medsig_check = ""; if ($user) { echo " Posta anonymt
\n"; - echo " Infoga signatur
\n";} + echo " Infoga signatur
\n"; + } + if($speling) { + echo " 
\n"; + } echo "" ."\n" ."\n" @@ -463,7 +472,7 @@ reply($pid, $pollID, $mode, $order, $thold); break; case "Preview": - replyPreview($medsig, $pid, $pollID, $subject, $comment, $postanon, $mode, $order, $thold, $posttype); + replyPreview($medsig, $pid, $pollID, $subject, $comment, $postanon, $mode, $order, $thold, $posttype, $spell); break; case "Ok!": CreateTopic($medsig, $postanon, $subject, $comment, $pid, $pollID, $host_name, $mode, $order, $thold, $posttype); 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 28 Oct 2002 23:59:16 -0000 @@ -61,6 +61,9 @@ (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?)

+ +
+