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 / pos.php,v < prev    next >
Text File  |  2003-10-20  |  14KB  |  698 lines

  1. head    1.8;
  2. access;
  3. symbols
  4.     Initial:1.1.1.1 bule:1.1.1;
  5. locks; strict;
  6. comment    @# @;
  7.  
  8.  
  9. 1.8
  10. date    2003.10.20.00.21.45;    author bule;    state Exp;
  11. branches;
  12. next    1.7;
  13.  
  14. 1.7
  15. date    2003.10.18.00.33.42;    author bule;    state Exp;
  16. branches;
  17. next    1.6;
  18.  
  19. 1.6
  20. date    2003.10.06.00.39.27;    author bule;    state Exp;
  21. branches;
  22. next    1.5;
  23.  
  24. 1.5
  25. date    2003.10.01.06.51.29;    author bule;    state Exp;
  26. branches;
  27. next    1.4;
  28.  
  29. 1.4
  30. date    2003.09.05.06.42.30;    author bule;    state Exp;
  31. branches;
  32. next    1.3;
  33.  
  34. 1.3
  35. date    2003.09.04.07.27.00;    author bule;    state Exp;
  36. branches;
  37. next    1.2;
  38.  
  39. 1.2
  40. date    2003.08.19.19.05.16;    author bule;    state Exp;
  41. branches;
  42. next    1.1;
  43.  
  44. 1.1
  45. date    2003.08.12.19.18.23;    author bule;    state Exp;
  46. branches
  47.     1.1.1.1;
  48. next    ;
  49.  
  50. 1.1.1.1
  51. date    2003.08.12.19.18.23;    author bule;    state Exp;
  52. branches;
  53. next    ;
  54.  
  55.  
  56. desc
  57. @@
  58.  
  59.  
  60. 1.8
  61. log
  62. @*** empty log message ***
  63. @
  64. text
  65. @<?
  66. session_start();
  67. require_once("../php/Indonesia.php");
  68. require_once("../php/Web.php");
  69. //////////////////////////////////////////////////////////////////////////////
  70. //////////////////////////////////////////////////////////////////////////////
  71. // Project Name: Bahasa Indonesia Dictionary
  72. // Directory:    bahasa/web
  73. // File Name:    pos.php
  74. // Author(s):    John L. Whiteman
  75. // Created:      June 23, 2003  
  76. // Modified:     October 19, 2003
  77. // Description:  The purpose of this restricted access PHP web 
  78. //               client page is to allow the administrator view, 
  79. //               edit, and add parts of speech entries. 
  80. // 
  81. // Copyright (c) 2003 John L. Whiteman
  82. //
  83. // Permission is herby granted, free of charge, to any person obtaining a 
  84. // copy of this software, data, and associated documentation files 
  85. // (the "Software"), to deal in the Software without restriction, 
  86. // including without limitation the rights to use, copy, modify, merge, 
  87. // publish, distribute, sublicense, and/or sell copies of Software, and to
  88. // permit persons to whom the Software is furnished to do so, subject to 
  89. // the following conditions:
  90. //
  91. // The above copyright notice and this permission notice shall be 
  92. // included in all copies or substantial portions of the Software.
  93. //
  94. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
  95. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
  96. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  97. // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 
  98. // ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHERE IN AN ACTION OF CONTRACT,
  99. // TORT OR OTHERWISE, ARISING IN THE SOFTWARE.  
  100. //////////////////////////////////////////////////////////////////////////////
  101. //////////////////////////////////////////////////////////////////////////////
  102. $web = new Web();
  103.  
  104. if (!$_SESSION['ADMIN']) {
  105.  
  106.     $web->redirect("login.php");
  107.  
  108.     exit;
  109. }
  110.  
  111. $indonesia = new Indonesia(); 
  112.  
  113. $status = $indonesia->get_dictionary_status();
  114.  
  115. if ($status["status"] == 1 || $status["status"] == 2) {
  116.  
  117.     $web-redirect("admin.php");
  118.  
  119.     exit;
  120. }
  121.  
  122. ?>
  123. <html>
  124. <head>
  125. <title>Bahasa Indonesia Dictionary: Parts of Speech</title>
  126.  
  127. <link href="bahasa.css" rel="stylesheet" type="text/css">
  128.  
  129. <script type="text/javascript" src="bahasa.js"></script>
  130.  
  131. <script language="Javascript" type="text/javascript">
  132. <!--
  133. //////////////////////////////////////////////////////////////////////////////
  134. function verify() {
  135.  
  136.     part_of_speech = document.parts_of_speech.part_of_speech.value;
  137.  
  138.     part_of_speech = trim(part_of_speech);
  139.  
  140.     if (is_white_space(part_of_speech)) {
  141.  
  142.         alert(
  143.         "You must enter a part of speech value.");
  144.  
  145.         document.parts_of_speech.part_of_speech.focus();
  146.  
  147.         return(false);
  148.     }
  149.  
  150.     if (part_of_speech.length > 255) {
  151.  
  152.         alert(
  153.         "The part of speech value must be 255 characters or less!");
  154.  
  155.         document.parts_of_speech.part_of_speech.focus();
  156.  
  157.         return(false);
  158.     }
  159.  
  160.     description = document.parts_of_speech.description.value;
  161.  
  162.     description= trim(description);
  163.  
  164.     if (is_white_space(description)) {
  165.  
  166.         alert(
  167.         "You must enter a description value.");
  168.  
  169.         document.parts_of_speech.description.focus();
  170.  
  171.         return(false);
  172.     }
  173.  
  174.     password = document.parts_of_speech.password.value;
  175.  
  176.     if (is_white_space(password)) {
  177.  
  178.         alert(
  179.         "You must enter a password value.");
  180.  
  181.         document.parts_of_speech.password.focus();
  182.  
  183.         return(false);
  184.     }
  185.  
  186.     return(true);
  187. }
  188. //////////////////////////////////////////////////////////////////////////////
  189. // -->
  190. </script>
  191.  
  192. </head>
  193. <body>
  194. <?
  195. $web->show_logo("Parts of Speech");
  196. ?>
  197. <a href="admin.php">Administration</a>
  198. <?
  199.  
  200. if (
  201. ($_SESSION['NODUP_POS']) &&
  202. (isset($_POST['id'])) &&
  203. ($_SESSION['NODUP_POS'] == $_POST['id'])) {
  204.  
  205.     show_pos_form($web, $indonesia);
  206.  
  207. } else if (
  208. (isset($_POST['action'])) &&
  209. (isset($_POST['part_of_speech'])) &&
  210. (isset($_POST['description'])) &&
  211. (isset($_POST['id'])) &&
  212. (isset($_POST['password']))) {
  213.  
  214.     if ($_SESSION['NODUP_POS']) {
  215.  
  216.         unset($_SESSION['NODUP_POS']);
  217.     }
  218.  
  219.     $errstr = $indonesia->login($_SESSION['ADMIN'], $_POST['password']);
  220.  
  221.     if ($errstr != "") {
  222.  
  223.         print "<hr><b>Permission denied!</b><hr><br>\n";
  224.  
  225.     } else {
  226.  
  227.  
  228.         if ($_POST['action'] == "insert") {
  229.  
  230.             $errstr = 
  231.             $indonesia->insert_parts_of_speech(
  232.             $_POST['part_of_speech'], $_POST['description']);
  233.  
  234.             if ($errstr != "") {
  235.  
  236.                 print 
  237.                 "<hr><b>${errstr}</b><hr>\n";
  238.  
  239.             } else {
  240.  
  241.                 print 
  242.                 "<hr><b>Insert successful!</b><hr>\n";
  243.  
  244.                 $_SESSION['NODUP_POS'] = $_POST['id'];
  245.  
  246.                 show_pos_form($web, $indonesia);
  247.             }
  248.  
  249.         } else if ($_POST['action'] == "update") {
  250.  
  251.             $errstr = 
  252.             $indonesia->update_parts_of_speech($_POST['pkey'], 
  253.             $_POST['part_of_speech'], $_POST['description']);
  254.  
  255.             if ($errstr != "") {
  256.  
  257.                 print 
  258.                 "<hr><b>${errstr}</b><hr><br>\n";
  259.  
  260.             } else {
  261.  
  262.                 print 
  263.                 "<hr><b>Update successful!</b><hr>\n";
  264.  
  265.                 $_SESSION['NODUP_POS'] = $_POST['id'];
  266.  
  267.                 show_pos_form($web, $indonesia);
  268.             }
  269.  
  270.         } else {
  271.  
  272.             show_pos_form($web, $indonesia);
  273.         }
  274.     }
  275.  
  276. } else if (isset($_POST['pos_pkey'])) {
  277.  
  278.     if ($_POST['pos_pkey'] == 0) {
  279.  
  280.         show_insert_new_pos_form($web, $indonesia);
  281.  
  282.     } else {
  283.  
  284.         show_update_pos_form($web, $indonesia, $_POST['pos_pkey']);
  285.     }
  286.  
  287. } else {
  288.  
  289.     show_pos_form($web, $indonesia);
  290. }
  291. ?>
  292. </body>
  293. </html>
  294.  
  295. <?
  296. //////////////////////////////////////////////////////////////////////////////
  297. function show_insert_new_pos_form($web, $indonesia) {
  298.  
  299.     $id = uniqid(rand(), true);
  300.  
  301.     print <<<EOFINPF
  302. <form name="parts_of_speech" method="post" onsubmit='return verify()'>
  303. <table cellpadding="3" cellspacing="3" border="0">
  304. <tr>
  305. <td>Part of Speech<br>(1 to 255 characters):</td>
  306. <td> 
  307. <input type="text" name="part_of_speech" size="50" maxlength="255">
  308. </td>
  309. </tr><tr>
  310. <td>Description:</td>
  311. <td>
  312. <textarea name="description" rows="7" 
  313. cols="55" wrap="soft"></textarea> 
  314. </td>
  315. </tr><tr>
  316. <td>Password:</td>
  317. <td>
  318. <input type="password" name="password" size="50">
  319. </td>
  320. </tr><tr>
  321. <td colspan="2" align="right">
  322. <input type="reset" value="Reset">
  323.    
  324. <input type="submit" value="Insert Part of Speech!">
  325. </td>
  326. </tr>
  327. </table>
  328. <input type="hidden" name="action" value="insert">
  329. <input type="hidden" name="id" value="${id}">
  330. </form>
  331. <script language="Javascript" type="text/javascript">
  332. document.parts_of_speech.part_of_speech.focus();
  333. </script>
  334. EOFINPF;
  335.  
  336.     return;
  337. }
  338. //////////////////////////////////////////////////////////////////////////////
  339. function show_pos_form($web, $indonesia) {
  340.  
  341.     $pos = array();
  342.  
  343.     $errstr = $indonesia->get_parts_of_speech($pos);
  344.  
  345.     if ($errstr != "") {
  346.  
  347.         print "<hr><b>${errstr}</b><hr><br>\n";
  348.  
  349.         return;
  350.     }
  351.  
  352.     print 
  353.     "<br><br>\n" .
  354.     "Insert a new parts of speech category or " .
  355.     "update an existing one below:" .
  356.     "<form method=\"post\"><input type=\"submit\" " .
  357.     "value=\"Insert a New Parts of Speech Category!\">\n" .
  358.     "<input type=\"hidden\" name=\"pos_pkey\" value=\"0\"> " .
  359.     "</form>\n";
  360.  
  361.     $pos_table = 
  362.     "<br>\n" .
  363.     "<table cellpadding=\"3\" \n" . 
  364.     "cellspacing=\"3\" border=\"1\">\n" .
  365.     "<tr>\n" .
  366.     "<th>PKEY</th>\n" .
  367.     "<th>Part of Speech</th>\n" .
  368.     "<th>Description</th>\n" .
  369.     "<th>Created</th>\n" .
  370.     "<th>Modified</th>\n" .
  371.     "<th>Action</th></tr>\n";
  372.  
  373.     $total_pos = count($pos);
  374.  
  375.     for($i = 0; $i < $total_pos; $i++) {
  376.  
  377.         $pkey = $web->tohtml($pos[$i]["pkey"]);
  378.         $part_of_speech = $web->tohtml($pos[$i]["part_of_speech"]);
  379.         $description = $web->tohtml($pos[$i]["description"]);
  380.         $created = $web->tohtml($pos[$i]["created"]);
  381.         $modified = $web->tohtml($pos[$i]["modified"]);
  382.  
  383.         $pos_table .=
  384.         "<tr>\n" .
  385.         "<td>${pkey}</td>\n" .
  386.         "<td>${part_of_speech}</td>\n" .
  387.         "<td>${description}</td>\n" .
  388.         "<td>${created}</td>\n" .
  389.         "<td>${modified}</td>\n" .
  390.         "<td>\n" .
  391.         "<form name=${pkey} method=\"post\">\n" .
  392.         "<input type=\"submit\" value=\"Update!\">\n" .
  393.         "<input type=\"hidden\" name=\"pos_pkey\" " .
  394.         "value=\"${pkey}\"></form>\n" .
  395.         "</td></tr>\n";
  396.     }
  397.  
  398.     $pos_table .= "</table>\n";
  399.  
  400.     print "$pos_table";
  401.  
  402.     return;
  403. }
  404. //////////////////////////////////////////////////////////////////////////////
  405. function show_update_pos_form($web, $indonesia, $pkey) {
  406.  
  407.     $pos = array();
  408.  
  409.     $id = uniqid(rand(), true);
  410.  
  411.     $errstr = $indonesia->get_part_of_speech($pos, $pkey);
  412.  
  413.     if ($errstr != "") {
  414.  
  415.         print "<hr><b>${errstr}</b><hr>\n";
  416.  
  417.         return;
  418.     }
  419.  
  420.     $pkey = $web->tohtml($pos->pkey);
  421.  
  422.     $part_of_speech = $web->tohtml($pos->part_of_speech);
  423.  
  424.     $description = $web->tohtml($pos->description);
  425.  
  426.     print <<<EOFUPF
  427. <form name="parts_of_speech" method="post" onsubmit='return verify()'>
  428. <table cellpadding="3" cellspacing="3" border="0">
  429. <tr>
  430. <td>Part of Speech<br>(255 characters maximum):</td>
  431. <td> 
  432. <input type="text" name="part_of_speech" 
  433. value="${part_of_speech}" maxlength="255">
  434. </td>
  435. </tr><tr>
  436. <td>Description:</td>
  437. <td>
  438. <textarea name="description" rows="7" 
  439. cols="55" wrap="soft">${description}</textarea> 
  440. </td>
  441. </tr><tr>
  442. <td>Password:</td>
  443. <td>
  444. <input type="password" name="password">
  445. </td>
  446. </tr><tr>
  447. <td colspan="2" align="right">
  448. <input type="reset" value="Reset">
  449.    
  450. <input type="submit" value="Update Part of Speech!">
  451. </td>
  452. </tr>
  453. </table>
  454. <input type="hidden" name="action" value="update">
  455. <input type="hidden" name="pkey" value="${pkey}">
  456. <input type="hidden" name="id" value="${id}">
  457. </form>
  458. <script language="Javascript" type="text/javascript">
  459. document.parts_of_speech.part_of_speech.focus();
  460. </script>
  461. EOFUPF;
  462.  
  463.     return;
  464. }
  465. //////////////////////////////////////////////////////////////////////////////
  466. //////////////////////////////////////////////////////////////////////////////
  467. ?>
  468. @
  469.  
  470.  
  471. 1.7
  472. log
  473. @*** empty log message ***
  474. @
  475. text
  476. @d12 1
  477. a12 1
  478. // Modified:     October 17, 2003
  479. d62 2
  480. @
  481.  
  482.  
  483. 1.6
  484. log
  485. @*** empty log message ***
  486. @
  487. text
  488. @d12 1
  489. a12 1
  490. // Modified:     October 05, 2003
  491. d61 3
  492. a63 2
  493. <title>Bahasa Indonesia Dictionary: Parts of Speech 
  494. </title>
  495. d66 1
  496. a66 25
  497. //////////////////////////////////////////////////////////////////////////////
  498. function is_white_space(stoken) {
  499.  
  500.     if (stoken == null) return(true);
  501.  
  502.     if (stoken == '') return(true);
  503.  
  504.     if (stoken == "") return(true);
  505.  
  506.     return(false);
  507. }
  508. //////////////////////////////////////////////////////////////////////////////
  509. function trim(stoken) {
  510.  
  511.     if (is_white_space(stoken)) {
  512.  
  513.         return(stoken);
  514.     }
  515.  
  516.     stoken = stoken.replace(/^\s*/, "");
  517.  
  518.     stoken = stoken.replace(/\s*$/, "");
  519.  
  520.     return(stoken);
  521. }
  522. d122 2
  523. @
  524.  
  525.  
  526. 1.5
  527. log
  528. @*** empty log message ***
  529. @
  530. text
  531. @d12 1
  532. a12 1
  533. // Modified:     September 30, 2003
  534. d149 3
  535. a151 1
  536. <h2>Bahasa Indonesia Dictionary: Parts of Speech</h2>
  537. @
  538.  
  539.  
  540. 1.4
  541. log
  542. @*** empty log message ***
  543. @
  544. text
  545. @d12 1
  546. a12 1
  547. // Modified:     September 04, 2003
  548. d40 1
  549. a40 1
  550. if (!session_is_registered("ADMIN")) {
  551. d154 1
  552. a154 1
  553. (session_is_registered("NODUP_POS")) &&
  554. d167 1
  555. a167 1
  556.     if (session_is_registered("NODUP_POS")) {
  557. d169 1
  558. a169 1
  559.         session_unregister("NODUP_POS");
  560. d197 1
  561. a197 3
  562.                 $NODUP_POS = $_POST['id']; 
  563.  
  564.                 session_register("NODUP_POS");
  565. a201 1
  566.  
  567. d218 1
  568. a218 3
  569.                 $NODUP_POS = $_POST['id']; 
  570.  
  571.                 session_register("NODUP_POS");
  572. @
  573.  
  574.  
  575. 1.3
  576. log
  577. @*** empty log message ***
  578. @
  579. text
  580. @d12 1
  581. a12 1
  582. // Modified:     September 03, 2003
  583. d263 1
  584. a263 1
  585. <td>Part of Speech<br>(255 characters maximum):</td>
  586. d265 1
  587. a265 1
  588. <input type="text" name="part_of_speech" maxlength="255">
  589. d276 1
  590. a276 1
  591. <input type="password" name="password">
  592. d313 1
  593. a313 1
  594.     "update one of the existing ones below:" .
  595. @
  596.  
  597.  
  598. 1.2
  599. log
  600. @*** empty log message ***
  601. @
  602. text
  603. @d9 1
  604. a9 1
  605. // File Name:    .php
  606. d12 1
  607. a12 1
  608. // Modified:     August 19, 2003
  609. d14 2
  610. a15 2
  611. //               client page is to allow the administrator edit 
  612. //               and add parts of speech entries. 
  613. a57 8
  614. if (session_is_registered("NODUP_POS_ENTRY")) {
  615.  
  616.     session_unregister("NODUP_POS_ENTRY");
  617.  
  618.     $web->redirect("admin.php");
  619.  
  620.     exit;
  621. }
  622. d154 7
  623. d164 1
  624. d167 5
  625. d176 1
  626. a176 2
  627.  
  628.         print "<br><hr><b>Permission denied!</b><hr><br>\n";
  629. d190 1
  630. a190 1
  631.                 "<br><hr><b>${errstr}</b><hr><br>\n";
  632. d195 3
  633. a197 1
  634.                 "<br><hr><b>Insert successful!</b><hr><br>\n";
  635. d199 1
  636. a199 1
  637.                 $NODUP_POS_ENTRY = 1; 
  638. d201 1
  639. a201 1
  640.                 session_register("NODUP_POS_ENTRY");
  641. d214 1
  642. a214 1
  643.                 "<br><hr><b>${errstr}</b><hr><br>\n";
  644. d219 1
  645. a219 1
  646.                 "<br><hr><b>Update successful!</b><hr><br>\n";
  647. d221 1
  648. a221 1
  649.                 $NODUP_POS_ENTRY = 1; 
  650. d223 3
  651. a225 1
  652.                 session_register("NODUP_POS_ENTRY");
  653. d257 2
  654. d287 1
  655. d305 1
  656. a305 1
  657.         print "<br><hr><b>${errstr}</b><hr><br>\n";
  658. d331 1
  659. a331 1
  660.     foreach($pos as $p) {
  661. d333 7
  662. a339 5
  663.         $pkey = $web->tohtml($p->pkey);
  664.         $part_of_speech = $web->tohtml($p->part_of_speech);
  665.         $description = $web->tohtml($p->description);
  666.         $created = $web->tohtml($p->created);
  667.         $modified = $web->tohtml($p->modified);
  668. d352 1
  669. a352 1
  670.         "value=\"$p->pkey\"></form>\n" .
  671. d367 2
  672. d373 1
  673. a373 1
  674.         print "<br><hr><b>${errstr}</b><hr><br>\n";
  675. d414 1
  676. @
  677.  
  678.  
  679. 1.1
  680. log
  681. @Initial revision
  682. @
  683. text
  684. @d5 33
  685. a37 1
  686.  
  687. a409 1
  688.  
  689. @
  690.  
  691.  
  692. 1.1.1.1
  693. log
  694. @Bahasa Indonesia Dictionary
  695. @
  696. text
  697. @@
  698.