Source for file addition.php

Documentation is available at addition.php

  1. <?php
  2.  
  3.  
  4.  
  5.  
  6. /*
  7. Program E related AIML knowledgebase tools
  8. Copyright 2004, Anne Kootstra [anne@aiml.info]
  9. http://www.AIML.info
  10. Program E is free software; you can redistribute it and/or modify
  11. it under the terms of the GNU General Public License as published by
  12. the Free Software Foundation; either version 2 of the License, or
  13. (at your option) any later version.
  14.  
  15. Program E is distributed in the hope that it will be useful,
  16. but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. GNU General Public License for more details.
  19.  
  20. You should have received a copy of the GNU General Public License
  21. along with Program E; if not, write to the Free Software
  22. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  23. */
  24. /**
  25. * All files that take part in adding AIML to the database
  26. *
  27. * This is a collection of functions that deal with adding categories
  28. * to the Program E database system.
  29. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  30. * @package addition
  31. * @uses getRequest()
  32. * @uses getbotnames()
  33. * @uses useTemplate()
  34. *
  35. */
  36. /**
  37. * Variables that are needed to
  38. */
  39. require_once "../admin/botloaderfuncs.php";
  40. require_once "include/common.inc.php";
  41. require_once "include/target.inc.php";
  42. require_once "include/add.inc.php";
  43.  
  44.  
  45. // HTTP_POST or HTTP_GET variables
  46. // used in this page. They are now accessible, as normal variables.
  47. // escape routine to make global variables from POST/GET variables.
  48.  
  49.  
  50.  
  51. /**
  52. *
  53. * @name cat_input
  54. *
  55. */
  56. getRequest("cat_input", 0);
  57. getRequest("cat_that", 0);
  58. getRequest("cat_topic", 0);
  59. getRequest("cat_template", 0);
  60. getRequest("botid", 0);
  61.  
  62.  
  63.  
  64. /**
  65. * routine to create the bot selection list.
  66. *
  67. * @see getbotnames()
  68. *
  69. */
  70. $botnames = getbotnames();
  71.  
  72. while(list($key, $val) = each($botnames)) {
  73. if($botid == $key){
  74. $bots .= "<option value=\"$key\" selected>$val</option>";
  75. }else{
  76. $bots .= "<option value=\"$key\">$val</option>";
  77. }
  78. }
  79.  
  80.  
  81. // auto select a previously selected bot.
  82. if(!$botid) {
  83.  
  84. $page['{{bots}}'] = $bots;
  85. echo useTemplate('botselect',$page);
  86.  
  87. return;
  88.  
  89. }
  90.  
  91.  
  92. //insert the new AIML category
  93. if($cat_input != '') {
  94.  
  95.  
  96. // check to see if fields are empty, then put a * in them
  97. if($cat_that == '') {
  98.  
  99. $cat_that = "*";
  100. }
  101.  
  102. if($cat_topic == '') {
  103.  
  104. $cat_topic = "*";
  105. }
  106.  
  107. // Make a string out of the received category that can be processed
  108. // by native Program E functions
  109. $mybigsentence=strtoupper($cat_input)." <that> ".strtoupper($cat_that)." <topic> ".strtoupper($cat_topic);
  110.  
  111. // Last record of a category in the paterntable is used as an
  112. // ID-reference to the templates table
  113. $idused=insertAnnesentence($mybigsentence, $botid);
  114.  
  115. // is used by insertmytemplate() in the ../admin/botloaderfuncs.php
  116. $selectbot = $botid;
  117. insertmytemplate($idused,$cat_template);
  118.  
  119.  
  120. }
  121.  
  122.  
  123.  
  124. // match the placeholders in the template to
  125. // a specific PHP variable.
  126.  
  127. $page['{{bots}}'] = $bots;
  128. $page['{{bot_id}}'] = $botid;
  129.  
  130.  
  131. // load the template and return the page.
  132. echo useTemplate('add',$page);
  133.  
  134. ?>

Documentation generated on Tue, 11 Jan 2005 18:40:57 +0100 by phpDocumentor 1.3.0RC3