OSDN Git Service

BugTrack2/140: check_non_list() handles
[pukiwiki/pukiwiki.git] / lib / func.php
index 61432a1..4d89ad7 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // PukiWiki - Yet another WikiWikiWeb clone.
-// $Id: func.php,v 1.48 2005/11/23 07:41:06 henoheno Exp $
+// $Id: func.php,v 1.52 2005/12/18 15:11:08 henoheno Exp $
 // Copyright (C)
 //   2002-2005 PukiWiki Developers Team
 //   2001-2002 Originally written by yu-ji
@@ -92,6 +92,18 @@ function is_freeze($page, $clearcache = FALSE)
        }
 }
 
+// Handling $non_list
+// $non_list will be preg_quote($str, '/') later.
+function check_non_list($page = '')
+{
+       global $non_list;
+       static $regex;
+
+       if (! isset($regex)) $regex = '/' . $non_list . '/';
+
+       return preg_match($regex, $page);
+}
+
 // Auto template
 function auto_template($page)
 {
@@ -131,8 +143,6 @@ function get_search_words($words = array(), $do_escape = FALSE)
 {
        static $init, $mb_convert_kana, $pre, $post, $quote = '/';
 
-       if (! is_array($words)) $words = array($words);
-
        if (! isset($init)) {
                // function: mb_convert_kana() is for Japanese code only
                if (LANG == 'ja' && function_exists('mb_convert_kana')) {
@@ -154,6 +164,8 @@ function get_search_words($words = array(), $do_escape = FALSE)
                $init = TRUE;
        }
 
+       if (! is_array($words)) $words = array($words);
+
        // Generate regex for the words
        $regex = array();
        foreach ($words as $word) {
@@ -180,7 +192,7 @@ function get_search_words($words = array(), $do_escape = FALSE)
                                        $or[] = preg_quote($mb_convert_kana($_char, 'A'), $quote); // As Zenkaku?
                                }
                        } else {
-                               // NEVER COME HERE except with mb_substr(string, 'EUC-JP') etc
+                               // NEVER COME HERE with mb_substr(string, start, length, 'ASCII')
                                // A multi-byte character
                                $or[] = preg_quote($mb_convert_kana($char, 'c'), $quote); // As Hiragana?
                                $or[] = preg_quote($mb_convert_kana($char, 'k'), $quote); // As Hankaku-Katakana?
@@ -195,7 +207,7 @@ function get_search_words($words = array(), $do_escape = FALSE)
 }
 
 // 'Search' main function
-function do_search($word, $type = 'AND', $non_format = FALSE)
+function do_search($word, $type = 'AND', $non_format = FALSE, $base = '')
 {
        global $script, $whatsnew, $non_list, $search_non_list;
        global $_msg_andresult, $_msg_orresult, $_msg_notfoundresult;
@@ -207,6 +219,9 @@ function do_search($word, $type = 'AND', $non_format = FALSE)
        $keys = get_search_words(preg_split('/\s+/', $word, -1, PREG_SPLIT_NO_EMPTY));
 
        $_pages = get_existpages();
+       if ($base != '') {
+               $_pages = preg_grep('/^' . $base . '/', $_pages);
+       }
        $pages = array();
 
        $non_list_pattern = '/' . $non_list . '/';