/////////////////////////////////////////////////
// PukiWiki - Yet another WikiWikiWeb clone.
//
-// $Id: func.php,v 1.16 2004/12/08 13:18:41 henoheno Exp $
+// $Id: func.php,v 1.17 2004/12/08 13:31:15 henoheno Exp $
//
// ʸ»úÎó¤¬InterWikiName¤«¤É¤¦¤«
// #freeze¤òºï½ü
$body = preg_replace('/^#freeze\s*$/m', '', $body);
- for ($i = 0; $i < count($matches); $i++) {
+ $count = count($matches);
+ for ($i = 0; $i < $count; $i++)
$body = str_replace("\$$i", $matches[$i], $body);
- }
+
break;
}
return $body;
// Perl¥á¥â - Àµ¤·¤¯¥Ñ¥¿¡¼¥ó¥Þ¥Ã¥Á¤µ¤»¤ë
// http://www.din.or.jp/~ohzaki/perl.htm#JP_Match
$eucpre = $eucpost = '';
- if (SOURCE_ENCODING == 'EUC-JP')
- {
+ if (SOURCE_ENCODING == 'EUC-JP') {
$eucpre = '(?<!\x8F)';
// # JIS X 0208 ¤¬ 0ʸ»ú°Ê¾å³¤¤¤Æ # ASCII, SS2, SS3 ¤Þ¤¿¤Ï½ªÃ¼
$eucpost = '(?=(?:[\xA1-\xFE][\xA1-\xFE])*(?:[\x00-\x7F\x8E\x8F]|\z))';
'return mb_convert_kana($str, $option);' : 'return $str;'
);
- foreach ($words as $word)
- {
+ foreach ($words as $word) {
// ±Ñ¿ô»ú¤ÏȾ³Ñ,¥«¥¿¥«¥Ê¤ÏÁ´³Ñ,¤Ò¤é¤¬¤Ê¤Ï¥«¥¿¥«¥Ê¤Ë
$word_zk = $convert_kana($word, 'aKCV');
$chars = array();
- for ($pos = 0; $pos < mb_strlen($word_zk); $pos++)
- {
- $char = mb_substr($word_zk, $pos,1);
+ for ($pos = 0; $pos < mb_strlen($word_zk); $pos++) {
+ $char = mb_substr($word_zk, $pos, 1);
// $special : htmlspecialchars()¤òÄ̤¹¤«
$arr = array($quote_func($special ? htmlspecialchars($char) : $char));
- if (strlen($char) == 1) // ±Ñ¿ô»ú
- {
- foreach (array(strtoupper($char), strtolower($char)) as $_char)
- {
- if ($char != '&') {
+ if (strlen($char) == 1) {
+ // ±Ñ¿ô»ú
+ foreach (array(strtoupper($char), strtolower($char)) as $_char) {
+ if ($char != '&')
$arr[] = $quote_func($_char);
- }
$ord = ord($_char);
$arr[] = sprintf('&#(?:%d|x%x);', $ord, $ord); // ¼ÂÂλ²¾È
$arr[] = $quote_func($convert_kana($_char, 'A')); // Á´³Ñ
}
- }
- else // ¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»ú
- {
+ } else {
+ // ¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»ú
$arr[] = $quote_func($convert_kana($char, 'c')); // ¤Ò¤é¤¬¤Ê
$arr[] = $quote_func($convert_kana($char, 'k')); // Ⱦ³Ñ¥«¥¿¥«¥Ê
}
$_pages = get_existpages();
$pages = array();
- foreach ($_pages as $page)
- {
+ foreach ($_pages as $page) {
if ($page == $whatsnew || (! $search_non_list && preg_match("/$non_list/", $page)))
continue;
$b_match = FALSE;
foreach ($keys as $key) {
$tmp = preg_grep("/$key/", $source);
- $b_match = (count($tmp) > 0);
- if ($b_match xor $b_type)
- break;
+ $b_match = (! empty($tmp));
+ if ($b_match xor $b_type) break;
}
- if ($b_match)
- $pages[$page] = get_filetime($page);
+ if ($b_match) $pages[$page] = get_filetime($page);
}
- if ($non_format)
- return array_keys($pages);
+ if ($non_format) return array_keys($pages);
$r_word = rawurlencode($word);
$s_word = htmlspecialchars($word);
$r_page = rawurlencode($page);
$s_page = htmlspecialchars($page);
$passage = get_passage($time);
- $retval .= " <li><a href=\"$script?cmd=read&page=$r_page&word=$r_word\">$s_page</a>$passage</li>\n";
+ $retval .= ' <li><a href="' . $script . '?cmd=read&page=' .
+ $r_page . '&word=' . $r_word . '">' . $s_page .
+ '</a>' . $passage . '</li>' . "\n";
}
- $retval .= "</ul>\n";
+ $retval .= '</ul>' . "\n";
$retval .= str_replace('$1', $s_word, str_replace('$2', count($pages),
str_replace('$3', count($_pages), $b_type ? $_msg_andresult : $_msg_orresult)));
function arg_check($str)
{
global $vars;
-
return isset($vars['cmd']) && (strpos($vars['cmd'], $str) === 0);
}
}
$list = $matches = array();
- foreach($pages as $file=>$page)
- {
+ foreach($pages as $file=>$page) {
$r_page = rawurlencode($page);
$s_page = htmlspecialchars($page, ENT_QUOTES);
$passage = get_pg_passage($page);
- $str = " <li><a href=\"$script?cmd=$cmd&page=$r_page\">$s_page</a>$passage";
+ $str = ' <li><a href="' .
+ $script . '?cmd=' . $cmd . '&page=' . $r_page .
+ '">' . $s_page . '</a>' . $passage;
if ($withfilename) {
$s_file = htmlspecialchars($file);
- $str .= "\n <ul><li>$s_file</li></ul>\n ";
+ $str .= "\n" . ' <ul><li>' . $s_file . '</li></ul>' .
+ "\n" . ' ';
}
- $str .= "</li>";
+ $str .= '</li>';
+ // WARNING: Japanese code hard-wired
if($pagereading_enable) {
if(mb_ereg('^([A-Za-z])', mb_convert_kana($page, 'a'), $matches)) {
$head = $matches[1];
- }
- elseif(mb_ereg('^([¥¡-¥ö])', $readings[$page], $matches)) {
+ } elseif(mb_ereg('^([¥¡-¥ö])', $readings[$page], $matches)) { // here
$head = $matches[1];
- }
- elseif (mb_ereg('^[ -~]|[^¤¡-¤ó°¡-ô¦]', $page)) {
+ } elseif (mb_ereg('^[ -~]|[^¤¡-¤ó°¡-ô¦]', $page)) { // and here
$head = $symbol;
- }
- else {
+ } else {
$head = $other;
}
- }
- else {
+ } else {
$head = (preg_match('/^([A-Za-z])/', $page, $matches)) ? $matches[1] :
(preg_match('/^([ -~])/', $page, $matches) ? $symbol : $other);
}
$cnt = 0;
$arr_index = array();
- $retval .= "<ul>\n";
- foreach ($list as $head=>$pages)
- {
+ $retval .= '<ul>' . "\n";
+ foreach ($list as $head=>$pages) {
if ($head === $symbol) {
$head = $_msg_symbol;
} else if ($head === $other) {
if ($list_index) {
++$cnt;
- $arr_index[] = "<a id=\"top_$cnt\" href=\"#head_$cnt\"><strong>$head</strong></a>";
- $retval .= " <li><a id=\"head_$cnt\" href=\"#top_$cnt\"><strong>$head</strong></a>\n <ul>\n";
+ $arr_index[] = '<a id="top_' . $cnt .
+ '" href="#head_' . $cnt . '"><strong>' .
+ $head . '</strong></a>';
+ $retval .= ' <li><a id="head_' . $cnt . '" href="#top_' . $cnt .
+ '"><strong>' . $head . '</strong></a>' . "\n" .
+ ' <ul>' . "\n";
}
ksort($pages);
$retval .= join("\n", $pages);
if ($list_index)
$retval .= "\n </ul>\n </li>\n";
}
- $retval .= "</ul>\n";
+ $retval .= '</ul>' . "\n";
if ($list_index && $cnt > 0) {
$top = array();
- while (count($arr_index) > 0) {
- $top[] = join(" | \n", array_splice($arr_index, 0, 16)) . "\n";
- }
- $retval = "<div id=\"top\" style=\"text-align:center\">\n" .
- join('<br />', $top) . "</div>\n" . $retval;
+ while (! empty($arr_index))
+ $top[] = join(' | ' . "\n", array_splice($arr_index, 0, 16)) . "\n";
+
+ $retval = '<div id="top" style="text-align:center">' . "\n" .
+ join('<br />', $top) . '</div>' . "\n" . $retval;
}
return $retval;
}