home *** CD-ROM | disk | FTP | other *** search
/ ftp.ee.pdx.edu / 2014.02.ftp.ee.pdx.edu.tar / ftp.ee.pdx.edu / oss / cvs-2004 / bahasa / web / update.php,v < prev    next >
Text File  |  2003-10-20  |  24KB  |  1,235 lines

  1. head    1.9;
  2. access;
  3. symbols
  4.     Initial:1.1.1.1 bule:1.1.1;
  5. locks; strict;
  6. comment    @# @;
  7.  
  8.  
  9. 1.9
  10. date    2003.10.20.00.21.46;    author bule;    state Exp;
  11. branches;
  12. next    1.8;
  13.  
  14. 1.8
  15. date    2003.10.18.00.33.42;    author bule;    state Exp;
  16. branches;
  17. next    1.7;
  18.  
  19. 1.7
  20. date    2003.10.06.00.39.27;    author bule;    state Exp;
  21. branches;
  22. next    1.6;
  23.  
  24. 1.6
  25. date    2003.10.01.06.51.30;    author bule;    state Exp;
  26. branches;
  27. next    1.5;
  28.  
  29. 1.5
  30. date    2003.09.04.07.27.00;    author bule;    state Exp;
  31. branches;
  32. next    1.4;
  33.  
  34. 1.4
  35. date    2003.09.03.07.11.10;    author bule;    state Exp;
  36. branches;
  37. next    1.3;
  38.  
  39. 1.3
  40. date    2003.08.31.18.48.47;    author bule;    state Exp;
  41. branches;
  42. next    1.2;
  43.  
  44. 1.2
  45. date    2003.08.19.19.24.21;    author bule;    state Exp;
  46. branches;
  47. next    1.1;
  48.  
  49. 1.1
  50. date    2003.08.12.19.18.23;    author bule;    state Exp;
  51. branches
  52.     1.1.1.1;
  53. next    ;
  54.  
  55. 1.1.1.1
  56. date    2003.08.12.19.18.23;    author bule;    state Exp;
  57. branches;
  58. next    ;
  59.  
  60.  
  61. desc
  62. @@
  63.  
  64.  
  65. 1.9
  66. log
  67. @*** empty log message ***
  68. @
  69. text
  70. @<?
  71. session_start();
  72. require_once("../php/Indonesia.php");
  73. require_once("../php/Web.php");
  74. //////////////////////////////////////////////////////////////////////////////
  75. //////////////////////////////////////////////////////////////////////////////
  76. // Project Name: Bahasa Indonesia Dictionary
  77. // Directory:    bahasa/web
  78. // File Name:    update.php
  79. // Author(s):    John L. Whiteman
  80. // Created:      June 23, 2003  
  81. // Modified:     October 19, 2003
  82. // Description:  The purpose of this restricted access PHP web 
  83. //               client page is to allow an administrator to update
  84. //               an existing entry in the dictionary table of the 
  85. //               the database. 
  86. // 
  87. // Copyright (c) 2003 John L. Whiteman
  88. //
  89. // Permission is herby granted, free of charge, to any person obtaining a 
  90. // copy of this software, data, and associated documentation files 
  91. // (the "Software"), to deal in the Software without restriction, 
  92. // including without limitation the rights to use, copy, modify, merge, 
  93. // publish, distribute, sublicense, and/or sell copies of Software, and to
  94. // permit persons to whom the Software is furnished to do so, subject to 
  95. // the following conditions:
  96. //
  97. // The above copyright notice and this permission notice shall be 
  98. // included in all copies or substantial portions of the Software.
  99. //
  100. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
  101. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
  102. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  103. // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 
  104. // ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHERE IN AN ACTION OF CONTRACT,
  105. // TORT OR OTHERWISE, ARISING IN THE SOFTWARE.  
  106. //////////////////////////////////////////////////////////////////////////////
  107. //////////////////////////////////////////////////////////////////////////////
  108.  
  109. $web = new Web();
  110.  
  111. if (!$_SESSION['ADMIN']) {
  112.  
  113.     $web->redirect("login.php");
  114.  
  115.     exit;
  116. }
  117.  
  118. $indonesia = new Indonesia();
  119.  
  120. $status = $indonesia->get_dictionary_status();
  121.  
  122. if ($status["status"] == 1 || $status["status"] == 2) {
  123.  
  124.     $web->redirect("admin.php");
  125.  
  126.     exit;
  127. }
  128.  
  129. ?>
  130. <html>
  131. <head>
  132. <title>Bahasa Indonesia Dictionary: Update Word(s)</title>
  133.  
  134. <link href="bahasa.css" rel="stylesheet" type="text/css">
  135.  
  136. <script type="text/javascript" src="bahasa.js"></script>
  137.  
  138. <script language="Javascript" type="text/javascript"> 
  139. <!--
  140. //////////////////////////////////////////////////////////////////////////////
  141. function verify_search() {
  142.  
  143.     stoken = document.search.stoken.value;
  144.  
  145.     stoken = trim(stoken);
  146.  
  147.     if (is_white_space(stoken)) {
  148.  
  149.         alert("You need to specify a search word value!");
  150.  
  151.         document.search.stoken.focus();
  152.  
  153.         return(false);
  154.     }
  155.  
  156.     if (stoken.length > 255) {
  157.  
  158.         alert(
  159.         "You need to specify a search word 1 to 255 characters " +
  160.         "in length!");
  161.  
  162.         document.search.stoken.focus();
  163.  
  164.         return(false);
  165.     }
  166.  
  167.     return(true);
  168. }
  169. //////////////////////////////////////////////////////////////////////////////
  170. function verify_update() {
  171.  
  172.     english = document.update.english.value;
  173.  
  174.     english = trim(english);
  175.  
  176.     if (is_white_space(english)) {
  177.  
  178.         alert(
  179.         "You must enter an English value!");
  180.  
  181.         document.update.english.focus();
  182.  
  183.         return(false);
  184.     }
  185.  
  186.     if (english.length > 255) {
  187.  
  188.         alert(
  189.         "The English value must be 255 characters or less!");
  190.  
  191.         document.update.english.focus();
  192.  
  193.         return(false);
  194.     }
  195.  
  196.     indonesian = document.update.indonesian.value;
  197.  
  198.     indonesian = trim(indonesian);
  199.  
  200.     if (is_white_space(indonesian)) {
  201.  
  202.         alert(
  203.         "You must enter an Indonesian value!");
  204.  
  205.         document.update.indonesian.focus();
  206.  
  207.         return(false);
  208.     }
  209.  
  210.     if (indonesian.length > 255) {
  211.  
  212.         alert(
  213.         "The Indonesian value must be 255 characters or less!");
  214.  
  215.         document.update.indonesian.focus();
  216.  
  217.         return(false);
  218.     }
  219.  
  220.     if (document.update.pos.value == "") {
  221.  
  222.         alert(
  223.         "You must select a Part of Speech Category!");
  224.  
  225.         document.update.pos.focus();
  226.  
  227.         return(false);
  228.     }
  229.  
  230.     pronunciation = document.update.pronunciation.value;
  231.     
  232.     if (pronunciation.length > 255) {
  233.  
  234.         alert(
  235.         "The Pronunciation value must be 255 characters or less!");
  236.  
  237.         document.update.pronunciation.focus();
  238.  
  239.         return(false);
  240.     }
  241.  
  242.     ipa = document.update.pronunciation_ipa.value;
  243.  
  244.     if (ipa.length > 255) {
  245.  
  246.         alert(
  247.         "The International Phonetic Alphabet (IPA) value " +
  248.         "must be 255 characters or less!"); 
  249.  
  250.         document.update.pronunciation_ipa.focus();
  251.  
  252.         return(false);
  253.     }
  254.  
  255.     password = document.update.password.value;
  256.  
  257.     if (is_white_space(password)) {
  258.  
  259.         alert(
  260.         "You must enter a password value!");
  261.  
  262.         document.update.password.focus();
  263.  
  264.         return(false);
  265.     }
  266.  
  267.     return(true);
  268. }
  269. //////////////////////////////////////////////////////////////////////////////
  270. // -->
  271. </script>
  272. </head>
  273. <body>
  274. <?
  275. $web->show_logo("Update Word(s)");
  276. ?>
  277.  
  278. <a href="admin.php">Administration</a>
  279.  | 
  280. <a href="editor.php">Search</a>
  281.  
  282. <?
  283.  
  284. show_search_form($web, $indonesia);
  285.  
  286. if (
  287. ($_SESSION['NODUP_UPDATES']) &&
  288. (isset($_POST['id'])) &&
  289. (isset($_POST['update_entry'])) &&
  290. ($_SESSION['NODUP_UPDATES'] == $_POST['id'])) {
  291.  
  292.         //Do nothing...prevents refresh duplication of last action
  293.  
  294. } else if (isset($_POST['stoken'])) {
  295.  
  296.     search_all($web, $indonesia, $_POST['stoken']);
  297.  
  298. } else if (
  299. (isset($_POST['password'])) &&
  300. (isset($_POST['pkey'])) &&
  301. (isset($_POST['english'])) &&
  302. (isset($_POST['indonesian'])) &&
  303. (isset($_POST['pos'])) &&
  304. (isset($_POST['id'])) &&
  305. (isset($_POST['spelling_flag'])) &&
  306. (isset($_POST['update_entry']))) {
  307.  
  308.     if ($_SESSION['NODUP_UPDATES']) {
  309.  
  310.         unset($_SESSION['NODUP_UPDATES']);
  311.     }
  312.  
  313.     $errstr = $indonesia->login($_SESSION['ADMIN'], $_POST['password']);
  314.  
  315.     if ($errstr != "") {
  316.  
  317.         print
  318.         "<br><hr><b>Permission denied!</b><hr><br>\n";
  319.  
  320.     } else {
  321.  
  322.         $rc =
  323.         update(
  324.         $web, $indonesia, $_POST['pkey'],
  325.         $_POST['english'], $_POST['indonesian'],
  326.         $_POST['pos'], $_POST['spelling_flag'],
  327.         $_POST['pronunciation'], $_POST['pronunciation_ipa'],
  328.         $_POST['comments']);
  329.  
  330.         if (!$rc) {
  331.  
  332.             $_SESSION['NODUP_UPDATES'] = $_POST['id'];
  333.         }
  334.     }
  335.  
  336. } else if (isset($_POST['pkey'])) {
  337.  
  338.  
  339.     show_update_form($web, $indonesia, $_POST['pkey']);
  340. }
  341. ?>
  342.  
  343. </body>
  344. </html>
  345.  
  346. <?
  347. ///////////////////////////////////////////////////////////////////////////////
  348. function search_all($web, $indonesia, $stoken) {
  349.  
  350.     $results = array();
  351.  
  352.     $stoken = $web->strip($stoken);
  353.  
  354.     if ($stoken == "") {
  355.  
  356.         print
  357.         "<hr><b>You must specify a search value!" .
  358.         "</b><hr><br>\n" .
  359.         "<script language=\"Javascript\" type=\"text/javascript\">\n" .
  360.         "document.search.stoken.focus();\n" .
  361.         "</script>\n";
  362.  
  363.         return;
  364.     }  
  365.  
  366.     $errstr = $indonesia->search_all($results, $stoken);
  367.  
  368.     if ($errstr != "") {
  369.  
  370.         print "<hr><b>${errstr}</b><hr><br>\n";
  371.  
  372.         return;
  373.     }
  374.  
  375.     $total_results = count($results);
  376.  
  377.     print 
  378.     "<hr><b>Found ${total_results} match(es) for search entry: " .
  379.     "'${stoken}'</b>" .
  380.     "<hr>\n";
  381.  
  382.     if ($total_results == 0) {
  383.  
  384.         return;
  385.     }
  386.  
  387.     $results_str = "";
  388.  
  389.     $pkeys = "";
  390.  
  391.     $results_str .=
  392.     "<form name=\"delete_entries\" method=\"post\" " .
  393.     "onSubmit='return verify_delete_selected()'>\n" .
  394.     "<table cellpadding=\"3\" cellspacing=\"3\" border=\"1\">\n";
  395.  
  396.     for($i = 0; $i < $total_results; $i++) {
  397.  
  398.         if ($i == 0) {
  399.  
  400.             $results_str .=    
  401.             "<tr>\n" .
  402.             "<th>PKEY</th>\n" .
  403.             "<th>Language</th>\n" .
  404.             "<th>English</th>\n" .
  405.             "<th>Indonesian</th>\n" .
  406.             "<th>Part of Speech</th>\n" .
  407.             "<th>Pronunciation</th>\n" .
  408.             "<th>IPA</th>\n" .
  409.             "<th>Comments</th>\n" .
  410.             "<th>Created</th>\n" .
  411.             "<th>Modified</th>\n" .
  412.             "<th>Action</th>\n" .
  413.             "</tr>\n";
  414.                 }
  415.  
  416.         $pkey = $web->tohtml($results[$i]["pkey"]);
  417.         $language = $web->tohtml($results[$i]["language"]);
  418.         $english = $web->tohtml($results[$i]["english"]);
  419.         $indonesian = $web->tohtml($results[$i]["indonesian"]);
  420.         $pos = $web->tohtml($results[$i]["pos"]);
  421.         $pronunciation = $web->tohtml($results[$i]["pronunciation"]);
  422.         $ipa = $web->tohtml($results[$i]["ipa"]);
  423.         $comments = $web->tohtml($results[$i]["comments"]);
  424.         $created = $web->tohtml($results[$i]["created"]);
  425.         $modified = $web->tohtml($results[$i]["modified"]);
  426.  
  427.         $pkeys .= 
  428.         "<input type=\"hidden\" name=\"${pkey}\" " .
  429.         "value=\"delete_entry\">\n";
  430.  
  431.         $results_str .=
  432.         "<tr>\n" .
  433.         "<td>${pkey} </td>\n" .
  434.         "<td>${language} </td>\n" .
  435.         "<td>${english} </td>\n" .
  436.         "<td>${indonesian} </td>\n" .
  437.         "<td>${pos} </td>\n" .
  438.         "<td>${pronunciation} </td>\n" .
  439.         "<td>${ipa} </td>\n" .
  440.         "<td>${comments} </td>\n" .
  441.         "<td>${created} </td>\n" .
  442.         "<td>${modified} </td>\n" .
  443.         "<td>\n" .
  444.         "<form name=\"update_entry\" method=\"post\">\n" .
  445.         "<input type=\"submit\" value=\"Update!\">\n" .
  446.         "<input type=\"hidden\" name=\"pkey\" \n" .
  447.         "value=\"${pkey}\">\n" .
  448.         "</form>\n" .
  449.         "</td>\n" .
  450.         "</tr>\n";
  451.         }
  452.  
  453.     $results_str .= "</table></form>\n";
  454.  
  455.     print $results_str;
  456.  
  457.     return;
  458. }
  459. ///////////////////////////////////////////////////////////////////////////////
  460. function show_search_form($web, $indonesia) {
  461.  
  462.     print <<<EOFSSF
  463. <form name="search" method="post" onSubmit='return verify_search()'>
  464. <table cellpadding="3" cellspacing="3" border="0">
  465. <tr>
  466. <td>Enter search entry to update:</td>
  467. <td>
  468. <input type="text" name="stoken" maxlength="255" size="30">
  469. </td>
  470. </tr><tr>
  471. <td colspan="2" align="right">
  472. <input type="submit" value="Search Dictionary!">
  473. </td>
  474. </tr>
  475. </table>
  476. </form>
  477. <script language="Javascript" type="text/javascript">
  478. document.search.stoken.focus();
  479. </script>
  480. EOFSSF;
  481.  
  482.     return;
  483. }
  484. ///////////////////////////////////////////////////////////////////////////////
  485. function show_update_form($web, $indonesia, $spkey) {
  486.  
  487.     $results = array();
  488.  
  489.     $id = uniqid(rand(), true);
  490.  
  491.     $spkey = $web->strip($spkey);
  492.  
  493.         if ($spkey == "") {
  494.  
  495.         print
  496.         "<hr><b>No primary key specified!" .
  497.         "</b><hr><br>\n" .
  498.         "<script language=\"Javascript\" type=\"text/javascript\">\n" .
  499.         "document.search.stoken.focus();\n" .
  500.         "</script>\n";
  501.  
  502.                 return;
  503.         }
  504.  
  505.     $errstr = $indonesia->search_pkey($results, $spkey);
  506.  
  507.     if ($errstr != "") {
  508.  
  509.         print "<hr><b>${errstr}</b><hr><br>\n";
  510.  
  511.         return;
  512.     }
  513.  
  514.         $total_results = count($results);
  515.  
  516.     if ($total_results != 1) {
  517.  
  518.         print 
  519.         "<hr><b>Primary key $pkey not found!</b><hr><br>\n";
  520.  
  521.         return;
  522.     }
  523.  
  524.     $pkey = $web->tohtml($results[0]["pkey"]);
  525.     $english = $web->tohtml($results[0]["english"]);
  526.     $indonesian = $web->tohtml($results[0]["indonesian"]);
  527.     $pos = $web->tohtml($results[0]["part_of_speech"]);
  528.     $created = $web->tohtml($results[0]["created"]);
  529.     $modified = $web->tohtml($results[0]["modified"]);
  530.     $spelling_flag = $web->tohtml($results[0]["spelling_flag"]);
  531.     $pronunciation = $web->tohtml($results[0]["pronunciation"]);
  532.     $pronunciation_ipa = $web->tohtml($results[0]["pronunciation_ipa"]);
  533.     $comments = $web->tohtml($results[0]["comments"]);
  534.  
  535.     $spelling_html = "";
  536.  
  537.     if ($spelling_flag == 0) {
  538.  
  539.         $spelling_html =
  540.         "<input type=\"radio\" name=\"spelling_flag\" value=\"1\">" .
  541.         "Before 1972" .
  542.         "  " .
  543.         "<input type=\"radio\" name=\"spelling_flag\" value=\"0\" " .
  544.         "checked>Modern\n";
  545.  
  546.     } else {
  547.  
  548.         $spelling_html =
  549.         "<input type=\"radio\" name=\"spelling_flag\" value=\"1\" " .
  550.         "checked>Before 1972" .
  551.         "  " .
  552.         "<input type=\"radio\" name=\"spelling_flag\" value=\"0\">" .
  553.         "Modern\n";
  554.     }
  555.  
  556.     $parts_of_speech = array();
  557.  
  558.     $errstr = $indonesia->get_parts_of_speech($parts_of_speech);
  559.  
  560.     if ($errstr != "") {
  561.  
  562.         return(
  563.         "Can't get parts of speech categories.");
  564.     }
  565.  
  566.     $pos_total = count($parts_of_speech);
  567.  
  568.     $pos_html =
  569.     "<select name=\"pos\">\n"; 
  570.  
  571.     for($i = 0; $i < $pos_total; $i++) {
  572.  
  573.         $pos_pkey = $web->tohtml($parts_of_speech[$i]["pkey"]);
  574.  
  575.         $pos_pos = $web->tohtml($parts_of_speech[$i]["part_of_speech"]);
  576.  
  577.         if ($pos_pkey != $pos) {
  578.  
  579.             $pos_html .= 
  580.             "<option value=\"${pos_pkey}\">${pos_pos}\n";
  581.         
  582.         } else {
  583.  
  584.             $pos_html .=
  585.             "<option value=\"${pos_pkey}\" selected>${pos_pos}\n";
  586.         } 
  587.     }
  588.  
  589.     $pos_html .= "</select>\n";
  590.  
  591.     print <<<EOFSUF
  592. <hr>
  593. <form name="update" method="post" onsubmit='return verify_update()'>
  594. <table cellpadding="3" cellspacing="5" border="0">
  595.  
  596. <tr>
  597. <td>English (1 to 255 characters):</td>
  598. </tr><tr>
  599. <td>
  600. <input type="text" name="english" value="${english}" 
  601. maxlength="255" size="50">
  602. </td>
  603.  
  604. </tr><tr>
  605. <td><hr></td>
  606.  
  607. </tr><tr>
  608. <td>Indonesian (1 to 255 characters):</td>
  609. </tr><tr>
  610. <td>
  611. <input type="text" name="indonesian" value="${indonesian}" 
  612. maxlength="255" size="50">
  613. </td>
  614.  
  615. </tr><tr>
  616. <td><hr></td>
  617.  
  618. </tr><tr>
  619. <td>Spelling Convention:</td>
  620. </tr><tr>
  621. <td>${spelling_html}</td>
  622.  
  623. </tr><tr>
  624. <td><hr></td>
  625.  
  626. </tr><tr>
  627. <td>Part of Speech:</td>
  628. </tr><tr>
  629. <td>
  630. ${pos_html}
  631. </td>
  632.  
  633. </tr><tr>
  634. <td><hr></td>
  635.  
  636. </tr><tr>
  637. <td>Pronunciation (1 to 255 characters):</td>
  638. </tr><tr>
  639. <td>
  640. <input type="text" name="pronunciation" value="${pronunciation}" 
  641. maxlength="255" size="50">
  642. </td>
  643.  
  644. </tr><tr>
  645. <td><hr></td>
  646.  
  647. </tr><tr>
  648. <td>International Phonetic Alphabet (1 to 255 characters):</td>
  649. </tr><tr>
  650. <td>
  651. <input type="text" name="pronunciation_ipa" value="${pronunciation_ipa}" 
  652. maxlength="255" size="50">
  653. </td>
  654.  
  655. </tr><tr>
  656. <td><hr></td>
  657.  
  658. </tr><tr>
  659. <td>Comments:</td>
  660. </tr><tr>
  661. <td>
  662. <textarea name="comments" wrap="soft" 
  663. rows="5" cols="55">${comments}</textarea>
  664. </td>
  665.  
  666. </tr><tr>
  667. <td><hr></td>
  668.  
  669. </tr><tr>
  670. <td>Password:</td>
  671. </tr><tr>
  672. <td>
  673. <input type="password" name="password" size="50">
  674. </td>
  675.  
  676. </tr><tr>
  677. <td><hr></td>
  678.  
  679. </tr><tr>
  680. <td align="right">
  681. <input type="reset" value="Reset Form">
  682.   
  683. <input type="submit" value="Update Entry!">
  684. </td></tr>
  685. </table>
  686. <input type="hidden" name="pkey" value="${pkey}">
  687. <input type="hidden" name="update_entry" value="1">
  688. <input type="hidden" name="id" value="${id}">
  689. </form>
  690. <script language="Javascript" type="text/javascript">
  691. document.update.english.focus();
  692. </script>
  693. EOFSUF;
  694.  
  695.     return("");
  696. }
  697. ///////////////////////////////////////////////////////////////////////////////
  698. function update($web, $indonesia, $pkey,
  699. $english, $indonesian, $pos, $spelling_flag,
  700. $pronunciation, $pronunciation_ip, $comments) {
  701.  
  702.     $errstr =
  703.     $indonesia->update_entry($pkey,
  704.     $english, $indonesian, $spelling_flag,
  705.     $pos, $pronunciation, 
  706.     $pronunciation_ipa, $comments); 
  707.  
  708.     if ($errstr != "") {
  709.  
  710.         print "<hr><b>${errstr}</b><hr>\n";
  711.  
  712.         return(1);
  713.  
  714.     }
  715.  
  716.     print "<hr><b>Successful Update!</b><hr>\n";
  717.  
  718.     return(0);
  719. }
  720. ///////////////////////////////////////////////////////////////////////////////
  721. ///////////////////////////////////////////////////////////////////////////////
  722. ?>
  723.  
  724. @
  725.  
  726.  
  727. 1.8
  728. log
  729. @*** empty log message ***
  730. @
  731. text
  732. @d12 1
  733. a12 1
  734. // Modified:     October 17, 2003
  735. d64 2
  736. @
  737.  
  738.  
  739. 1.7
  740. log
  741. @*** empty log message ***
  742. @
  743. text
  744. @d12 1
  745. a12 1
  746. // Modified:     October 05, 2003
  747. d65 2
  748. d68 1
  749. a68 25
  750. //////////////////////////////////////////////////////////////////////////////
  751. function is_white_space(stoken) {
  752.  
  753.     if (stoken == null) return(true);
  754.  
  755.     if (stoken == '') return(true);
  756.  
  757.     if (stoken == "") return(true);
  758.  
  759.     return(false);
  760. }
  761. //////////////////////////////////////////////////////////////////////////////
  762. function trim(stoken) {
  763.  
  764.     if (is_white_space(stoken)) {
  765.  
  766.         return(stoken);
  767.     }
  768.  
  769.     stoken = stoken.replace(/^\s*/, "");
  770.  
  771.     stoken = stoken.replace(/\s*$/, "");
  772.  
  773.     return(stoken);
  774. }
  775. d198 2
  776. @
  777.  
  778.  
  779. 1.6
  780. log
  781. @*** empty log message ***
  782. @
  783. text
  784. @d12 1
  785. a12 1
  786. // Modified:     September 30, 2003
  787. d223 3
  788. a225 1
  789. <h2>Bahasa Indonesia Dictionary: Update Word(s)</h2>
  790. @
  791.  
  792.  
  793. 1.5
  794. log
  795. @*** empty log message ***
  796. @
  797. text
  798. @d12 1
  799. a12 1
  800. // Modified:     September 03, 2003
  801. d42 1
  802. a42 1
  803. if (!session_is_registered("ADMIN")) {
  804. d234 1
  805. a234 1
  806. (session_is_registered("NODUP_UPDATES")) &&
  807. d255 1
  808. a255 1
  809.     if (session_is_registered("NODUP_UPDATES")) {
  810. d257 1
  811. a257 1
  812.         session_unregister("NODUP_UPDATES");
  813. d279 1
  814. a279 3
  815.             $NODUP_UPDATES = $_POST['id'];
  816.  
  817.             session_register("NODUP_UPDATES");
  818. @
  819.  
  820.  
  821. 1.4
  822. log
  823. @*** empty log message ***
  824. @
  825. text
  826. @d12 1
  827. a12 1
  828. // Modified:     September 02, 2003
  829. d255 5
  830. d515 2
  831. d520 1
  832. a520 1
  833.     foreach($parts_of_speech as $p) {
  834. d522 1
  835. a522 1
  836.         if ($p->pkey != $pos) {
  837. d524 6
  838. a529 2
  839.             $pos_html .=
  840.             "<option value=\"$p->pkey\">$p->part_of_speech\n";
  841. d534 1
  842. a534 2
  843.             "<option value=\"$p->pkey\" " .
  844.             "selected>$p->part_of_speech\n";
  845. @
  846.  
  847.  
  848. 1.3
  849. log
  850. @*** empty log message ***
  851. @
  852. text
  853. @d12 1
  854. a12 1
  855. // Modified:     August 31, 2003
  856. a48 9
  857. if (session_is_registered("NODUP_UPDATE_ENTRY")) {
  858.  
  859.     session_unregister("NODUP_UPDATE_ENTRY");
  860.  
  861.     $web->redirect("admin.php");
  862.  
  863.     exit;    
  864. }
  865.  
  866. d63 1
  867. a63 1
  868. <title>Bahasa Indonesia Dictionary: Update Entry</title>
  869. d94 1
  870. a94 1
  871.     stoken = document.update.stoken.value;
  872. d100 12
  873. a111 1
  874.         alert("You must enter a search word(s) value!");
  875. d113 1
  876. a113 1
  877.         document.update.stoken.focus();
  878. d193 1
  879. a193 1
  880.     ipa = document.update.ipa.value;
  881. d201 1
  882. a201 1
  883.         document.update.ipa.focus();
  884. d223 1
  885. a223 1
  886. <h2>Bahasa Indonesia Dictionary: Update Entry</h2>
  887. d226 2
  888. d231 2
  889. d234 12
  890. d250 2
  891. a251 1
  892. (isset($_POST['pos'])) && 
  893. d253 1
  894. a253 1
  895. (isset($_POST['update_entry']))) { 
  896. d259 1
  897. a259 1
  898.         print 
  899. d264 1
  900. a264 1
  901.         $rc = 
  902. d270 1
  903. a270 1
  904.         $_POST['comments']); 
  905. d274 1
  906. a274 1
  907.             $NODUP_UPDATE_ENTRY = 1;
  908. d276 1
  909. a276 1
  910.             session_register("NODUP_UPDATE_ENTRY");
  911. d282 1
  912. a282 1
  913.     $errstr =
  914. a283 23
  915.  
  916.     if ($errstr != "") {
  917.  
  918.         show_search_form();
  919.  
  920.         print 
  921.         "<br><hr><b>${errstr}</b><hr><br>";
  922.     }
  923.  
  924. } else if (
  925. (isset($_POST['stoken'])) &&
  926. (isset($_POST['method'])) &&
  927. (isset($_POST['language']))) {
  928.  
  929.     show_search_form();
  930.  
  931.     search(
  932.     $web, $indonesia,
  933.     $_POST['stoken'], $_POST['method'], $_POST['language']);
  934.  
  935. } else {
  936.  
  937.     show_search_form();
  938. d292 1
  939. a292 2
  940. ///////////////////////////////////////////////////////////////////////////////
  941. function search($web, $indonesia, $stoken, $method, $language) {
  942. d294 3
  943. a296 1
  944.     $stoken = trim($stoken);
  945. d300 6
  946. a305 1
  947.         print "You must enter a search value.";
  948. d308 1
  949. a308 1
  950.     }
  951. d310 1
  952. a310 1
  953.     $method = trim($method);
  954. d312 1
  955. a312 1
  956.     if ($method == "") {
  957. d314 1
  958. a314 1
  959.         print "You must choose a search method.";
  960. d319 1
  961. a319 1
  962.     $language = trim($language);
  963. d321 4
  964. a324 16
  965.     if ($method == "exact") {
  966.  
  967.         search_exact($web, $indonesia, $stoken, $language);
  968.  
  969.     } else if ($method == "fuzzy") {
  970.  
  971.         print "This feature has not been implemented yet.";
  972.     }
  973.  
  974.     return;
  975. }
  976. ///////////////////////////////////////////////////////////////////////////////
  977. ///////////////////////////////////////////////////////////////////////////////
  978. function search_exact($web, $indonesia, $stoken, $language) {
  979.  
  980.     $results = array();
  981. d326 1
  982. a326 10
  983.     $language = strtolower($language);
  984.  
  985.     $sql = 
  986.     "SELECT * FROM dictionary WHERE ${language}=\"$stoken\"";
  987.  
  988.     $errstr = $indonesia->search($sql, $results);
  989.  
  990.     if ($errstr != "") {
  991.  
  992.         print "$errstr";
  993. d331 1
  994. a331 3
  995.     $matches = count($results);
  996.  
  997.     if (!$matches) {
  998. d333 1
  999. a333 2
  1000.         print 
  1001.         "<hr><b>Found ${matches} matches!</b><hr><br>"; 
  1002. d335 4
  1003. a338 11
  1004.         return;
  1005.     }
  1006.  
  1007.     print 
  1008.     "<hr><b>Found ${matches} exact " .
  1009.     "matches for ${language} word(s) ${stoken}!</b><hr>\n"; 
  1010.  
  1011.     print 
  1012.     "<hr>" .
  1013.     "<table cellpadding=\"3\" cellspacing=\"3\" border=\"1\" " .
  1014.     "width=\"50%\">\n";
  1015. d340 1
  1016. a340 1
  1017.     for($i = 0; $i < $matches; $i++) {
  1018. d344 1
  1019. a344 1
  1020.             print
  1021. d347 1
  1022. a350 3
  1023.             "<th>Created</th>\n" .
  1024.             "<th>Modified</th>\n" .
  1025.             "<th>Spelling Flag</th>\n" .
  1026. d354 2
  1027. d358 1
  1028. a358 1
  1029.         }
  1030. d360 14
  1031. a373 10
  1032.         $pkey = $web->tohtml($results[$i]->pkey);
  1033.         $eng = $web->tohtml($results[$i]->english);
  1034.         $indo = $web->tohtml($results[$i]->indonesian);
  1035.         $pos = $web->tohtml($results[$i]->part_of_speech);
  1036.         $created = $web->tohtml($results[$i]->created);
  1037.         $modified = $web->tohtml($results[$i]->modified);
  1038.         $spelling_flag = $web->tohtml($results[$i]->spelling_flag);
  1039.         $p = $web->tohtml($results[$i]->pronunciation);
  1040.         $pipa = $web->tohtml($results[$i]->pronunciation_ipa);
  1041.         $comments = $web->tohtml($results[$i]->comments);
  1042. d375 1
  1043. a375 1
  1044.         print 
  1045. d378 3
  1046. a380 2
  1047.         "<td>${eng} </td>\n" .
  1048.         "<td>${indo} </td>\n" .
  1049. d382 3
  1050. a386 4
  1051.         "<td>${spelling_flag} </td>\n" .
  1052.         "<td>${p} </td>\n" .
  1053.         "<td>${pipa} </td>\n" .
  1054.         "<td>${comments} </td>\n" .
  1055. d388 1
  1056. a388 1
  1057.         "<form name=\"update\" method=\"post\">\n" .
  1058. d390 4
  1059. a393 3
  1060.         "<input type=\"hidden\" name=\"pkey\" " .
  1061.         "value=\"${pkey}\"> " .
  1062.         "</form></td>\n" .    
  1063. d395 3
  1064. a397 1
  1065.     }
  1066. d399 1
  1067. a399 1
  1068.     print "</table><hr>\n";
  1069. d402 1
  1070. a402 2
  1071. ///////////////////////////////////////////////////////////////////////////////
  1072. d404 1
  1073. a404 1
  1074. function show_search_form() {
  1075. d407 1
  1076. a407 1
  1077. <form name="update" method="post"  onsubmit='return verify_search()'>
  1078. d410 1
  1079. a410 10
  1080. <td colspan="2">Enter Search Word(s) to UPDATE:
  1081. </td>
  1082. </tr><tr>
  1083. <td colspan="2">
  1084. <textarea name="stoken" rows="5" cols="50" wrap="soft"></textarea>
  1085. </td>
  1086. </tr><tr>
  1087. <td>
  1088. <input type="radio" name="method" value="exact" checked>
  1089. </td>
  1090. d412 1
  1091. a412 1
  1092. Search dictionary for exact matches only
  1093. d415 2
  1094. a416 13
  1095. <td>
  1096. <input type="radio" name="method" value="fuzzy">
  1097. </td>
  1098. <td>
  1099. Search dictionary for exact and/or close matches 
  1100. </td>
  1101. </tr><tr>
  1102. <td colspan="2"></td>
  1103. </tr><tr>
  1104. <td align="right" colspan="2">
  1105. <input type="submit" name="language" value="English"> 
  1106.    
  1107. <input type="submit" name="language" value="Indonesian">
  1108. d422 2
  1109. a423 2
  1110. document.update.stoken.focus();
  1111. </script> 
  1112. d429 1
  1113. a429 2
  1114. ///////////////////////////////////////////////////////////////////////////////
  1115. function show_update_form($web, $indonesia, $pkey) {
  1116. d433 3
  1117. a435 1
  1118.     $pkey = addslashes($pkey);
  1119. d437 1
  1120. a437 2
  1121.     $sql = 
  1122.     "SELECT * FROM dictionary WHERE pkey=\"${pkey}\"";
  1123. d439 11
  1124. a449 1
  1125.     $errstr = $indonesia->search($sql, $results);
  1126. d453 3
  1127. a455 1
  1128.         return("$errstr");
  1129. d458 3
  1130. a460 1
  1131.     $matches = count($results);
  1132. d462 2
  1133. a463 1
  1134.     if ($matches != 1) {
  1135. d465 1
  1136. a465 2
  1137.         return(
  1138.         "Found ${matches} matches!  Should be 1 only.");
  1139. d468 10
  1140. a477 10
  1141.     $pkey = $web->tohtml($results[0]->pkey);
  1142.     $english = $web->tohtml($results[0]->english);
  1143.     $indonesian = $web->tohtml($results[0]->indonesian);
  1144.     $pos = $web->tohtml($results[0]->part_of_speech);
  1145.     $created = $web->tohtml($results[0]->created);
  1146.     $modified = $web->tohtml($results[0]->modified);
  1147.     $spelling_flag = $web->tohtml($results[0]->spelling_flag);
  1148.     $pronunciation = $web->tohtml($results[0]->pronunciation);
  1149.     $pronunciation_ipa = $web->tohtml($results[0]->pronunciation_ipa);
  1150.     $comments = $web->tohtml($results[0]->comments);
  1151. d531 1
  1152. d536 1
  1153. a536 1
  1154. <td>English (255 characters maximum):</td>
  1155. d539 2
  1156. a540 2
  1157. <textarea name="english" wrap="soft" rows="2"
  1158. cols="55">${english}</textarea>
  1159. d547 1
  1160. a547 1
  1161. <td>Indonesian (255 characters maximum):</td>
  1162. d550 2
  1163. a551 2
  1164. <textarea name="indonesian" wrap="soft" rows="2"
  1165. cols="55">${indonesian}</textarea> 
  1166. d576 1
  1167. a576 1
  1168. <td>Pronunciation (255 characters maximum):</td>
  1169. d579 2
  1170. a580 2
  1171. <textarea name="pronunciation" wrap="soft" 
  1172. rows="2" cols="55">${pronunciation}</textarea>
  1173. d587 1
  1174. a587 1
  1175. <td>International Phonetic Alphabet (255 characters maximum):</td>
  1176. d590 2
  1177. a591 2
  1178. <textarea name="ipa" wrap="soft" 
  1179. rows="2" cols="55">$pronunciation_ipa</textarea>
  1180. d612 1
  1181. a612 1
  1182. <input type="password" name="password">
  1183. d627 1
  1184. d649 1
  1185. a649 1
  1186.         print "<br><hr><b>${errstr}</b><hr><br>\n";
  1187. d655 1
  1188. a655 1
  1189.     print "<br><hr><b>Successful Update!</b><hr><br>\n";
  1190. d662 1
  1191. @
  1192.  
  1193.  
  1194. 1.2
  1195. log
  1196. @*** empty log message ***
  1197. @
  1198. text
  1199. @d12 1
  1200. a12 1
  1201. // Modified:     August 19, 2003
  1202. a223 1
  1203. <br><br>
  1204. d354 2
  1205. a355 1
  1206.         print "<h3>Found ${matches} matches!</h3>"; 
  1207. d361 2
  1208. a362 2
  1209.     "<h3>Found ${matches} exact " .
  1210.     "matches for ${language} word(s) ${stoken}!</h3>\n"; 
  1211. d383 1
  1212. a383 1
  1213.             "<th>IPA Pronunciation</th>\n" .
  1214. @
  1215.  
  1216.  
  1217. 1.1
  1218. log
  1219. @Initial revision
  1220. @
  1221. text
  1222. @d5 34
  1223. a688 1
  1224.  
  1225. @
  1226.  
  1227.  
  1228. 1.1.1.1
  1229. log
  1230. @Bahasa Indonesia Dictionary
  1231. @
  1232. text
  1233. @@
  1234.