Example #1
0
function page_list($pages, $cmd = 'read', $withfilename = FALSE)
{
    global $script, $list_index;
    global $_msg_symbol, $_msg_other;
    global $pagereading_enable;
    // ソートキーを決定する。 ' ' < '[a-zA-Z]' < 'zz'という前提。
    $symbol = ' ';
    $other = 'zz';
    $retval = '';
    if ($pagereading_enable) {
        mb_regex_encoding(SOURCE_ENCODING);
        $readings = get_readings($pages);
    }
    $list = $matches = array();
    // Shrink URI for read
    if ($cmd == 'read') {
        $href = $script . '?';
    } else {
        $href = $script . '?cmd=' . $cmd . '&amp;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="' . $href . $r_page . '">' . $s_page . '</a>' . $passage;
        if ($withfilename) {
            $s_file = htmlspecialchars($file);
            $str .= "\n" . '    <ul><li>' . $s_file . '</li></ul>' . "\n" . '   ';
        }
        $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 (isset($readings[$page]) && mb_ereg('^([ァ-ヶ])', $readings[$page], $matches)) {
                // here
                $head = $matches[1];
            } elseif (mb_ereg('^[ -~]|[^ぁ-ん亜-熙]', $page)) {
                // and here
                $head = $symbol;
            } else {
                $head = $other;
            }
        } else {
            $head = preg_match('/^([A-Za-z])/', $page, $matches) ? $matches[1] : (preg_match('/^([ -~])/', $page, $matches) ? $symbol : $other);
        }
        $list[$head][$page] = $str;
    }
    ksort($list);
    $cnt = 0;
    $arr_index = array();
    $retval .= '<ul>' . "\n";
    foreach ($list as $head => $pages) {
        if ($head === $symbol) {
            $head = $_msg_symbol;
        } else {
            if ($head === $other) {
                $head = $_msg_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";
        }
        ksort($pages);
        $retval .= join("\n", $pages);
        if ($list_index) {
            $retval .= "\n  </ul>\n </li>\n";
        }
    }
    $retval .= '</ul>' . "\n";
    if ($list_index && $cnt > 0) {
        $top = array();
        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;
}
Example #2
0
 function get_readings()
 {
     return get_readings();
 }
Example #3
0
function plugin_ajaxtree_get_readings($pages)
{
    static $all_readings;
    if (empty($all_readings)) {
        $all_readings = get_readings();
    }
    $readings = array();
    foreach ($pages as $page) {
        $readings[$page] = $all_readings[$page];
    }
    return $readings;
}
Example #4
0
function page_list($pages, $cmd = 'read', $withfilename=FALSE)
{
	global $script,$list_index,$top;
	global $_msg_symbol,$_msg_other;
	global $pagereading_enable;
	
	// ソートキーを決定する。 ' ' < '[a-zA-Z]' < 'zz'という前提。
	$symbol = ' ';
	$other = 'zz';
	
	$retval = '';
	
	if($pagereading_enable) {
		mb_regex_encoding(SOURCE_ENCODING);
		$readings = get_readings($pages);
	}
	
	$list = array();
	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&amp;page=$r_page\">$s_page</a>$passage";
		
		if ($withfilename)
		{
			$s_file = htmlspecialchars($file);
			$str .= "\n    <ul><li>$s_file</li></ul>\n   ";
		}
		$str .= "</li>";
		
		if($pagereading_enable) {
			if(mb_ereg('^([A-Za-zァ-ヶ])',$readings[$page],$matches)) {
				$head = $matches[1];
			}
			elseif (mb_ereg('^[ -~]|[^ぁ-ん亜-熙]',$page)) {
				$head = $symbol;
			}
			else {
				$head = $other;
			}
		}
		else {
			$head = (preg_match('/^([A-Za-z])/',$page,$matches)) ? $matches[1] :
				(preg_match('/^([ -~])/',$page,$matches) ? $symbol : $other);
		}
		
		$list[$head][$page] = $str;
	}
	ksort($list);
	
	$cnt = 0;
	$arr_index = array();
	$retval .= "<ul>\n";
	foreach ($list as $head=>$pages)
	{
		if ($head === $symbol)
		{
			$head = $_msg_symbol;
		}
		else if ($head === $other)
		{
			$head = $_msg_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";
		}
		ksort($pages);
		$retval .= join("\n",$pages);
		if ($list_index)
		{
			$retval .= "\n  </ul>\n </li>\n";
		}
	}
	$retval .= "</ul>\n";
	if ($list_index and $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;
	}
	return $retval;
}