<?php
/**
 * パンくずリスト
 */
class Platy_Breadcrumb {
    
    public $list;
    
    /**
     * リストに追加
     */
    public function add($name, $url = '') {
        $this->list[] = array('name'=> $name, 'url' => $url);
    }
    
    /**
     * 表示
     */
    public function display() {
        global $kbl_config;
        if (count($this->list) <= 0) { return; }
        //echo '<div id="breadcrumb">' . "\n";
        echo '現在の位置:&nbsp;';
        for ($i = 0; $i < count($this->list); $i++) {
            if ($this->list[$i]['url'] != '') {
                echo '<a href="' . $this->list[$i]['url'] . '">' . $this->list[$i]['name'] . '</a>' . "\n";
            }
            else {
                echo $this->list[$i]['name'] . "\n";
            }
            if ($i < count($this->list) - 1) {
                echo '&nbsp;&gt;&nbsp;';
                //echo '<img src="' . $kbl_config['base_url'] . 'media/system/resultset_next.gif' . '">';
            }
        }
        //echo '</div>' . "\n";
    }
    
    /**
     * 文字列を返す
     */
    public function getContents()
    {
        ob_start();
        if (count($this->list) <= 0) { return; }
        //echo '<div id="breadcrumb">' . "\n";
        //echo '現在の位置:&nbsp;';
        for ($i = 0; $i < count($this->list); $i++) {
            if ($this->list[$i]['url'] != '') {
                echo '<a href="' . $this->list[$i]['url'] . '">' . $this->list[$i]['name'] . '</a>' . "\n";
            }
            else {
                echo $this->list[$i]['name'] . "\n";
            }
            if ($i < count($this->list) - 1) {
                echo '&nbsp;&gt;&nbsp;';
                //echo '<img src="' . $kbl_config['base_url'] . 'media/system/resultset_next.gif' . '">';
            }
        }
        //echo '</div>' . "\n";
        $contents = ob_get_contents();
        ob_end_clean();
        return $contents;
    }
}
?>