Documentation is available at Kopie van menu.inc.php
- <?php
- /*
- Program E related AIML knowledgebase tools
- Copyright 2004, Anne Kootstra [anne@aiml.info]
- http://www.AIML.info
- Program E is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
- Program E is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with Program E; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
- $engine['no_resultpages'] = 10;
- $engine['no_searchresults'] = 15;
- function findAllwords($botid, $pat_id, $pid) {
- global $engine;
- if($pid) {
- $limit = (trim($pid) * $engine['no_searchresults'])-$engine['no_searchresults'];
- $SQL_limit = $limit.",".$engine['no_searchresults'];
- }
- $query = "select id, ifnull(word,if(ordera='1','_','*')) as word from patterns where parent = ".$pat_id." and bot = '".$botid."' order by word";
- if($pid) {
- $query .= ' LIMIT '. $SQL_limit;
- }
- //debugger($query,2);
- $selectcode = mysql_query($query);
- if ($selectcode){
- if(!mysql_numrows($selectcode)){
- return "";
- }else{
- while($q = mysql_fetch_array($selectcode)){
- $words[$q[0]] = $q[1];
- }
- }return $words;
- }
- return "";
- }
- function getPatternWord($id) {
- $query = "select word from patterns where id=".$id."";
- debugger($query,2);
- $selectcode = mysql_query($query);
- if ($selectcode){
- if(!mysql_numrows($selectcode)){
- return "";
- }
- else{
- while ($q = mysql_fetch_array($selectcode)){
- return $q[0];
- }
- }
- }
- return "";
- }
- function processWordPath($botid, $pat_id) {
- // retrieve the pattern ID of the main node
- $mainNode= findmainnode($botid);
- $final_pattern = array();
- $final_word_index = 0;
- while($mainNode <= $pat_id) {
- // save current word into a seperate array element
- $final_pattern[$final_word_index] = findPatternPart($pat_id);
- // set up for processing next word.
- $pat_id = $final_pattern[$final_word_index]['parent'];
- $final_word_index++;}
- $final_pattern_reverse = array_reverse($final_pattern);
- return $final_pattern_reverse;
- }
- function PrintNavigation($pat_id, $pid, $botid) {
- // these are the main settings of the search and spider engine.
- global $engine;
- // check to see if $pid is set
- if (!$pid) {
- $pid = 1;
- }
- // connection to database
- $query = "select id, ifnull(word,if(ordera='1','_','*')) as word from patterns where parent = ".$pat_id." and bot = '".$botid."' order by word";
- //debugger($query,2);
- $selectcode = mysql_query($query);
- if ($selectcode){
- if(!mysql_numrows($selectcode)){
- return "NO results";
- }
- }
- $NO_results = mysql_num_rows($selectcode);
- // floor'ing the results of the outcome of pagenumber / 10
- // means that the page numbering startpoint.
- // Example 1, pid = 6 -> 0.6 -> 0 --> 0
- // Example 2, pid = 56 -> 5.6 -> 5 --> 50
- $startpagenumber = floor($pid/$engine['no_resultpages'])*$engine['no_resultpages'];
- // determining the end page number.
- // If the startpagenumber + number of pageresults (10)
- // is lower than the number of pages needed results
- // proceed with that otherwise take the needed number
- // of pages.
- if(($startpagenumber + $engine['no_searchresults']) < (ceil($NO_results/$engine['no_searchresults']))) {
- $endpagenumber = $startpagenumber + $engine['no_resultpages'];
- } else {
- $endpagenumber = (ceil($NO_results/$engine['no_searchresults']));
- }
- $nav_HTML = "<table>
- <tr>
- <td class=\"resultnumber\"> </td>
- <td>";
- // unless it's the first page, add the "previous" link.
- if($pid > 1) {
- $nav_HTML .= "<a href=\"#\" onClick=\"alterPid(".($pid -1).");\">Previous</a> ";
- }
- // reminence of old code. for compatibility reasons.
- $pagenumber = $startpagenumber;
- // the 1,2,3 pagenumbers.
- for($pagenumber; $pagenumber <= $endpagenumber; $pagenumber++) {
- // but leave out page number 0, which doesn't exist.
- if($pagenumber != '0') {
- // don't create a hyperlink to the present result page (and show where we are)
- if($pagenumber == $pid) {
- $nav_HTML .= "<b>".$pagenumber."</b> ";
- } else {
- $nav_HTML .= "<a href=\"#\" onClick=\"alterPid(".($pagenumber).");\">".$pagenumber."</a> ";
- }
- }
- }
- // add the 'next' link.
- if (($NO_results > $engine['no_searchresults']) && ((($pid * $engine['no_searchresults'])) < $NO_results)) {
- $nav_HTML .= "  <a href=\"#\" onClick=\"alterPid(".($pid + 1).");\">Next</a>";
- }
- $nav_HTML .= "</td>
- </tr>
- </table>";
- return $nav_HTML;
- }
- ?>
Documentation generated on Tue, 11 Jan 2005 18:41:07 +0100 by phpDocumentor 1.3.0RC3