Source for file Kopie van menu.inc.php

Documentation is available at Kopie van menu.inc.php

  1. <?php
  2.  
  3. /*
  4. Program E related AIML knowledgebase tools
  5. Copyright 2004, Anne Kootstra [anne@aiml.info]
  6. http://www.AIML.info
  7. Program E is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or
  10. (at your option) any later version.
  11.  
  12. Program E is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with Program E; if not, write to the Free Software
  19. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. */
  21.  
  22. $engine['no_resultpages'] = 10;
  23. $engine['no_searchresults'] = 15;
  24.  
  25.  
  26. function findAllwords($botid, $pat_id, $pid) {
  27.  
  28. global $engine;
  29.  
  30. if($pid) {
  31. $limit = (trim($pid) * $engine['no_searchresults'])-$engine['no_searchresults'];
  32. $SQL_limit = $limit.",".$engine['no_searchresults'];
  33. }
  34. $query = "select id, ifnull(word,if(ordera='1','_','*')) as word from patterns where parent = ".$pat_id." and bot = '".$botid."' order by word";
  35.  
  36. if($pid) {
  37. $query .= ' LIMIT '. $SQL_limit;
  38. }
  39.  
  40. //debugger($query,2);
  41. $selectcode = mysql_query($query);
  42. if ($selectcode){
  43. if(!mysql_numrows($selectcode)){
  44. return "";
  45. }else{
  46. while($q = mysql_fetch_array($selectcode)){
  47. $words[$q[0]] = $q[1];
  48. }
  49. }return $words;
  50. }
  51.  
  52. return "";
  53. }
  54.  
  55.  
  56.  
  57.  
  58. function getPatternWord($id) {
  59.  
  60. $query = "select word from patterns where id=".$id."";
  61. debugger($query,2);
  62. $selectcode = mysql_query($query);
  63. if ($selectcode){
  64. if(!mysql_numrows($selectcode)){
  65. return "";
  66. }
  67. else{
  68. while ($q = mysql_fetch_array($selectcode)){
  69. return $q[0];
  70. }
  71. }
  72. }
  73.  
  74. return "";
  75. }
  76.  
  77.  
  78.  
  79.  
  80.  
  81. function processWordPath($botid, $pat_id) {
  82.  
  83. // retrieve the pattern ID of the main node
  84. $mainNode= findmainnode($botid);
  85. $final_pattern = array();
  86. $final_word_index = 0;
  87. while($mainNode <= $pat_id) {
  88.  
  89. // save current word into a seperate array element
  90. $final_pattern[$final_word_index] = findPatternPart($pat_id);
  91.  
  92. // set up for processing next word.
  93. $pat_id = $final_pattern[$final_word_index]['parent'];
  94. $final_word_index++;}
  95. $final_pattern_reverse = array_reverse($final_pattern);
  96. return $final_pattern_reverse;
  97.  
  98. }
  99.  
  100. function PrintNavigation($pat_id, $pid, $botid) {
  101.  
  102. // these are the main settings of the search and spider engine.
  103. global $engine;
  104.  
  105. // check to see if $pid is set
  106. if (!$pid) {
  107. $pid = 1;
  108. }
  109. // connection to database
  110. $query = "select id, ifnull(word,if(ordera='1','_','*')) as word from patterns where parent = ".$pat_id." and bot = '".$botid."' order by word";
  111. //debugger($query,2);
  112. $selectcode = mysql_query($query);
  113. if ($selectcode){
  114. if(!mysql_numrows($selectcode)){
  115. return "NO results";
  116. }
  117. }
  118. $NO_results = mysql_num_rows($selectcode);
  119.  
  120. // floor'ing the results of the outcome of pagenumber / 10
  121. // means that the page numbering startpoint.
  122. // Example 1, pid = 6 -> 0.6 -> 0 --> 0
  123. // Example 2, pid = 56 -> 5.6 -> 5 --> 50
  124. $startpagenumber = floor($pid/$engine['no_resultpages'])*$engine['no_resultpages'];
  125. // determining the end page number.
  126. // If the startpagenumber + number of pageresults (10)
  127. // is lower than the number of pages needed results
  128. // proceed with that otherwise take the needed number
  129. // of pages.
  130. if(($startpagenumber + $engine['no_searchresults']) < (ceil($NO_results/$engine['no_searchresults']))) {
  131. $endpagenumber = $startpagenumber + $engine['no_resultpages'];
  132. } else {
  133. $endpagenumber = (ceil($NO_results/$engine['no_searchresults']));
  134. }
  135.  
  136. $nav_HTML = "<table>
  137. <tr>
  138. <td class=\"resultnumber\">&nbsp;</td>
  139. <td>";
  140. // unless it's the first page, add the "previous" link.
  141. if($pid > 1) {
  142. $nav_HTML .= "<a href=\"#\" onClick=\"alterPid(".($pid -1).");\">Previous</a>&nbsp;&nbsp;";
  143. }
  144. // reminence of old code. for compatibility reasons.
  145. $pagenumber = $startpagenumber;
  146. // the 1,2,3 pagenumbers.
  147. for($pagenumber; $pagenumber <= $endpagenumber; $pagenumber++) {
  148.  
  149. // but leave out page number 0, which doesn't exist.
  150. if($pagenumber != '0') {
  151.  
  152. // don't create a hyperlink to the present result page (and show where we are)
  153. if($pagenumber == $pid) {
  154. $nav_HTML .= "<b>".$pagenumber."</b> ";
  155. } else {
  156. $nav_HTML .= "<a href=\"#\" onClick=\"alterPid(".($pagenumber).");\">".$pagenumber."</a> ";
  157. }
  158. }
  159. }
  160. // add the 'next' link.
  161. if (($NO_results > $engine['no_searchresults']) && ((($pid * $engine['no_searchresults'])) < $NO_results)) {
  162. $nav_HTML .= "&nbsp;&nbsp<a href=\"#\" onClick=\"alterPid(".($pid + 1).");\">Next</a>";
  163. }
  164. $nav_HTML .= "</td>
  165. </tr>
  166. </table>";
  167.  
  168. return $nav_HTML;
  169. }
  170.  
  171.  
  172. ?>

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