r2345 - don't allow editing/deleting stock records in dictionary editor
authorDenis Ovsienko <infrastation@yandex.ru>
Fri, 16 Jan 2009 16:50:15 +0000 (16:50 +0000)
committerDenis Ovsienko <infrastation@yandex.ru>
Fri, 16 Jan 2009 16:50:15 +0000 (16:50 +0000)
inc/database.php
inc/interface.php

index 6dcd40a6f485c9b31d5572da953a21fbb940669a..372ad79eb1c5c146a66c58e988d42ebbd08f88d1 100644 (file)
@@ -1630,7 +1630,7 @@ function getDict ($parse_links = FALSE)
                }
                if ($row['dict_key'] != NULL)
                {
-                       $dict[$chapter_no]['word'][$row['dict_key']] = $parse_links ?
+                       $dict[$chapter_no]['word'][$row['dict_key']] = ($parse_links or $row['dict_key'] <= MAX_DICT_KEY) ?
                                parseWikiLink ($row['dict_value'], 'a') : $row['dict_value'];
                        $dict[$chapter_no]['refcnt'][$row['dict_key']] = 0;
                }
index d8be5db3da7df2ce4c4f5f2042377f502a3a1912..9973f71bd109bf0b7f41f7ce00699b9c54393e0f 100644 (file)
@@ -3533,36 +3533,47 @@ function renderDictionaryEditor ()
        foreach ($dict as $chapter_no => $chapter)
        {
                $order = 'odd';
-               echo "<tr><th>Chapter</th><th>&nbsp;</th><th>Word</th><th>&nbsp;</th></tr>\n";
+               echo "<tr><th>Chapter</th><th>&nbsp;</th><th>&nbsp;</th><th>Word</th><th>&nbsp;</th></tr>\n";
                $wc = count ($chapter['word']);
                // One extra span for the new record per each chapter block.
                echo "<tr class=row_${order}><td class=tdleft" . ($wc ? ' rowspan = ' . ($wc + 1) : '');
                echo "><div title='number=${chapter_no}'>${chapter['name']} (${wc} records)</div></td>";
                printOpFormIntro ('add', array ('chapter_no' => $chapter['no']));
-               echo "<td>";
+               echo "<td>&nbsp;</td><td>";
                printImageHREF ('add', 'Add new', TRUE);
                echo "</td>";
-               echo "<td class=tdright><input type=text name=dict_value size=32></td>";
+               echo "<td class=tdleft><input type=text name=dict_value size=32></td>";
                echo "<td>&nbsp;</td>";
                echo '</tr></form>';
                $order = $nextorder[$order];
                foreach ($chapter['word'] as $key => $value)
                {
-                       printOpFormIntro ('upd', array ('chapter_no' => $chapter['no'], 'dict_key' => $key));
                        echo "<tr class=row_${order}><td>";
-                       // Prevent deleting words currently used somewhere.
-                       if ($chapter['refcnt'][$key])
-                               printImageHREF ('nodelete', 'referenced ' . $chapter['refcnt'][$key] . ' time(s)');
+                       // Show plain row for stock records, render a form for user's ones.
+                       if ($key <= MAX_DICT_KEY)
+                       {
+                               printImageHREF ('computer');
+                               echo "</td><td>&nbsp;</td><td>${value}</td><td>&nbsp;</td></tr>";
+                       }
                        else
                        {
-                               echo "<a href='${root}process.php?page=${pageno}&tab=${tabno}&op=del&chapter_no=${chapter['no']}&dict_key=${key}'>";
-                               printImageHREF ('delete', 'Delete word');
-                               echo "</a>";
+                               printOpFormIntro ('upd', array ('chapter_no' => $chapter['no'], 'dict_key' => $key));
+                               printImageHREF ('favorite');
+                               echo "<td>";
+                               // Prevent deleting words currently used somewhere.
+                               if ($chapter['refcnt'][$key])
+                                       printImageHREF ('nodelete', 'referenced ' . $chapter['refcnt'][$key] . ' time(s)');
+                               else
+                               {
+                                       echo "<a href='${root}process.php?page=${pageno}&tab=${tabno}&op=del&chapter_no=${chapter['no']}&dict_key=${key}'>";
+                                       printImageHREF ('delete', 'Delete word');
+                                       echo "</a>";
+                               }
+                               echo '</td>';
+                               echo "<td class=tdright><input type=text name=dict_value size=64 value='${value}'></td><td>";
+                               printImageHREF ('save', 'Save changes', TRUE);
+                               echo "</td></tr></form>\n";
                        }
-                       echo '</td>';
-                       echo "<td class=tdright><input type=text name=dict_value size=32 value='${value}'></td><td>";
-                       printImageHREF ('save', 'Save changes', TRUE);
-                       echo "</td></tr></form>\n";
                        $order = $nextorder[$order];
                } // foreach ($chapter['word']
        } // foreach ($dict