Happy New Year
[squirrelmail.git] / plugins / squirrelspell / modules / edit_dic.mod
index 3ef3988005823b6a69b42338015907e3400d736e..ed9fa534f0be13e294de3d4859b923644b512a7e 100644 (file)
 <?php
+
 /**
  * edit_dic.mod
- * -------------
- * Squirrelspell module
  *
- * Copyright (c) 1999-2002 The SquirrelMail development team
- * Licensed under the GNU GPL. For full terms see the file COPYING.
+ * Squirrelspell module
  *
  * This module lets the user edit his/her personal dictionary.
  *
- * $Id$
- *
- * @author Konstantin Riabitsev <icon@duke.edu> ($Author$)
- * @version $Date
+ * @author Konstantin Riabitsev <icon at duke.edu>
+ * @copyright 1999-2018 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ * @version $Id$
+ * @package plugins
+ * @subpackage squirrelspell
  */
 
 global $color;
+
+$pre_msg = '<p>'
+  . _("Please check any words you wish to delete from your dictionary.")
+  . "</p>\n";
+$pre_msg .= "<table border=\"0\" width=\"95%\" align=\"center\">\n";
+
 /**
- * Get the user dictionary and see if it's empty or not.
+ * Get how many dictionaries this user has defined.
  */
-$words=sqspell_getWords();
-if (!$words){
-  /**
-   * Agt. Smith: "You're empty."
-   * Neo: "So are you."
-   */
-  sqspell_makePage(_("Personal Dictionary"), null, 
-                  '<p>' . _("No words in your personal dictionary.") 
-                  . '</p>');
-} else {
-  /**
-   * We're loaded with booty.
-   */
-  $pre_msg = '<p>' 
-     . _("Please check any words you wish to delete from your dictionary.") 
-     . "</p>\n";
-  $pre_msg .= "<table border=\"0\" width=\"95%\" align=\"center\">\n";
+$langs=sqspell_getSettings();
+
+foreach ($langs as $lang) {
   /**
-   * Get how many dictionaries this user has defined.
+   * Get all words from this language dictionary.
    */
-  $langs=sqspell_getSettings($words);
-  for ($i=0; $i<sizeof($langs); $i++){
+  $lang_words = sqspell_getLang($lang);
+  if (! empty($lang_words)){
     /**
-     * Get all words from this language dictionary.
+     * There are words in this dictionary. If this is the first
+     * language we're processing, prepend the output with the
+     * "header" message.
      */
-    $lang_words = sqspell_getLang($words, $langs[$i]);
-    if ($lang_words){
-      /**
-       * There are words in this dictionary. If this is the first
-       * language we're processing, prepend the output with the
-       * "header" message.
-       */
-      if (!$msg) {
-       $msg = $pre_msg;
-      }
-      $msg .= "<tr bgcolor=\"$color[0]\" align=\"center\"><th>"
-        . sprintf( _("%s dictionary"), $langs[$i] ) . '</th></tr>'
-        . '<tr><td align="center">'
-        . '<form method="post">'
-        . '<input type="hidden" name="MOD" value="forget_me">'
-        . '<input type="hidden" name="sqspell_use_app" value="' 
-        . $langs[$i] . '">'
-        . '<table border="0" width="95%" align="center">'
-        . '<tr>'
-        . "<td valign=\"top\">\n";
-      $words_ary=explode("\n", $lang_words);
-      /**
-       * There are two lines we need to remove:
-       * 1st:  # Language
-       * last: # End
-       */
-      array_pop($words_ary);
-      array_shift($words_ary);
-      /**
-       * Do some fancy stuff to separate the words into three 
-       * columns.
-       */
-      for ($j=0; $j<sizeof($words_ary); $j++){
-       if ($j==intval(sizeof($words_ary)/3) 
-           || $j==intval(sizeof($words_ary)/3*2)){
-         $msg .= "</td><td valign=\"top\">\n";
-       }
-       $msg .= "<input type=\"checkbox\" name=\"words_ary[]\" "
-          . "value=\"$words_ary[$j]\"> $words_ary[$j]<br>";
+    if (!isset($msg) || !$msg) {
+      $msg = $pre_msg;
+    }
+    $msg .= "<tr bgcolor=\"$color[0]\" align=\"center\"><th>"
+      . sprintf( _("%s dictionary"), $lang ) . '</th></tr>'
+      . '<tr><td align="center">'
+      . '<form method="post">'
+      . '<input type="hidden" name="MOD" value="forget_me" />'
+      . '<input type="hidden" name="sqspell_use_app" value="'
+      . $lang . '" />'
+      . '<table border="0" width="95%" align="center">'
+      . '<tr>'
+      . "<td valign=\"top\">\n";
+    /**
+     * Do some fancy stuff to separate the words into three
+     * columns.
+     */
+    for ($j=0; $j<sizeof($lang_words); $j++){
+      if ($j==intval(sizeof($lang_words)/3)
+          || $j==intval(sizeof($lang_words)/3*2)){
+        $msg .= "</td><td valign=\"top\">\n";
       }
-      $msg .= '</td></tr></table></td></tr>'
-        . "<tr bgcolor=\"$color[0]\" align=\"center\"><td>"
-        . '<input type="submit" value="' . _("Delete checked words") 
-        . '"></form>'
-        . '</td></tr><tr><td><hr>'
-        . "</td></tr>\n";
+      $msg .= "<input type=\"checkbox\" name=\"words_ary[]\" "
+        . 'value="'.sm_encode_html_special_chars($lang_words[$j]). '" id="words_ary_'
+        . $j . '" /> <label for="words_ary_' . $j .'">'
+        . sm_encode_html_special_chars($lang_words[$j]) . "</label><br />\n";
     }
+    $msg .= '</td></tr></table></td></tr>'
+      . "<tr bgcolor=\"$color[0]\" align=\"center\"><td>"
+      . '<input type="submit" value="' . _("Delete checked words")
+      . '" /></form>'
+      . '</td></tr><tr><td><hr />'
+      . "</td></tr>\n";
   }
-  /**
-   * Check if all dictionaries were empty.
-   */
-  if (!$msg) {
-    $msg = '<p>' . _("No words in your personal dictionary.") . '</p>';
-  } else {
-    $msg .= '</table>';
-  }
-  sqspell_makePage(_("Edit your Personal Dictionary"), null, $msg);
 }
+/**
+ * Check if all dictionaries were empty.
+ */
+if (! isset($msg)) {
+  $msg = '<p>' . _("No words in your personal dictionary.") . '</p>';
+} else {
+  $msg .= '</table>';
+}
+sqspell_makePage(_("Edit your Personal Dictionary"), null, $msg);
 
 /**
  * For Emacs weenies:
  * Local variables:
  * mode: php
  * End:
+ * vim: syntax=php
  */
-
-?>