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?)
+ >