From: Geoffrey T. D. <da...@us...> - 2001-11-21 19:48:20
|
Update of /cvsroot/phpwiki/phpwiki/lib In directory usw-pr-cvs1:/tmp/cvs-serv19610/lib Modified Files: TextSearchQuery.php Log Message: Change argument semantics for TextSearchQuery::makeSqlClause. Now takes a WikiCallback. Index: TextSearchQuery.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/TextSearchQuery.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** TextSearchQuery.php 2001/09/18 19:16:23 1.1 --- TextSearchQuery.php 2001/11/21 19:48:15 1.2 *************** *** 98,102 **** * Make an SQL clause which matches the query. * ! * @param $make_sql_clause_func string,function or array * A callback which takes a single word as an argument and * returns an SQL clause which will match exactly those records --- 98,102 ---- * Make an SQL clause which matches the query. * ! * @param $make_sql_clause_cb WikiCallback * A callback which takes a single word as an argument and * returns an SQL clause which will match exactly those records *************** *** 104,117 **** * be in all lower case. * - * If $make_sql_clause_func is an array, it is interpreted as a method - * callback. The first element of the array is the object, the second - * element (a string) is the name of the method. - * - * If $make_sql_clause_func is a string, it is taken to be the name - * of a global function to call. - * - * Otherwise, $make_sql_clause_func is assumed to be a function object - * (created by create_function()). - * * Example usage: * <pre> --- 104,107 ---- *************** *** 124,128 **** * * $query = new TextSearchQuery("wiki -page"); ! * $sql_clause = $query->makeSqlClause('sql_title_match'); * </pre> * This will result in $sql_clause containing something like --- 114,119 ---- * * $query = new TextSearchQuery("wiki -page"); ! * $cb = new WikiFunctionCb('sql_title_match'); ! * $sql_clause = $query->makeSqlClause($cb); * </pre> * This will result in $sql_clause containing something like *************** *** 131,136 **** * @return string The PCRE regexp. */ ! function makeSqlClause($make_sql_clause_func) { ! $this->_sql_clause_func = $make_sql_clause_func; return $this->_sql_clause($this->_tree); } --- 122,127 ---- * @return string The PCRE regexp. */ ! function makeSqlClause($make_sql_clause_cb) { ! $this->_sql_clause_cb = $make_sql_clause_cb; return $this->_sql_clause($this->_tree); } *************** *** 139,151 **** switch ($node->op) { case 'WORD': ! $callback = $this->_sql_clause_func; ! if (is_array($callback)) { ! list($object, $method) = $callback; ! return call_user_method($method, $object, $node->word); ! } ! elseif (is_string($callback)) ! return call_user_func($callback, $node->word); ! else ! return $callback($node->word); case 'NOT': return "NOT (" . $this->_sql_clause($node->leaves[0]) . ")"; --- 130,134 ---- switch ($node->op) { case 'WORD': ! return $this->_sql_clause_cb->call($node->word); case 'NOT': return "NOT (" . $this->_sql_clause($node->leaves[0]) . ")"; |