<?php
/**
 * @copyright ONE/DEPO Project
 * @license   PHP License 3.01 <http://www.php.net/license/3_01.txt>
 */


/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */

/**
 * [[機能説明]]
 *
 * @package     [[package名]]
 * @author      Your Name <mail@example.com>
 * @access      public
 */
class Util_Dropmaker_Item
{
    var $maker;
    
    var $capital;  //頭文字
    var $dropid;   //メーカ名ドロップのID
    var $selid;   //メーカ名選択済みのID
    var $div;

    var $initial = array (
                          "a"  => array ("あ","い","う","え","お"), 
                          "ka" => array ("か","き","く","け","こ","が","ぎ","ぐ","げ","ご"), 
                          "sa" => array ("さ","し","す","せ","そ","ざ","じ","ず","ぜ","ぞ"), 
                          "ta" => array ("た","ち","つ","て","と","だ","ぢ","づ","で","ど"), 
                          "na" => array ("な","に","ぬ","ね","の"), 
                          "ha" => array ("は","ひ","ふ","へ","ほ","ば","び","ぶ","べ","ぼ","ぱ","ぴ","ぷ","ぺ","ぽ"), 
                          "ma" => array ("ま","み","む","め","も"), 
                          "ya" => array ("や","ゆ","よ"), 
                          "ra" => array ("ら","り","る","れ","ろ"), 
                          "wa" => array ("わ","を","ん")
                         );
    
    /**
     * [[機能説明]]
     *
     * @access  public
     */
    function execute()
    {
        $log =& LogFactory::getLog();
        $log->debug("Util_Dropmakerが実行されました", "Util_Dropmaker#execute");

        return "success";
    }
    
    //文字出力
    function getOutput()
    {
        $div = (empty($this->div)) ? 2 : 1;
        $maker_results = array();
        switch ($this->capital)
        {
            case 'a':
                $maker_results = $this->maker->selectKanaOfItem($this->initial['a'], $div);
            break;

            case 'ka':
                $maker_results = $this->maker->selectKanaOfItem($this->initial['ka'], $div);
            break;

            case 'sa':
                $maker_results = $this->maker->selectKanaOfItem($this->initial['sa'], $div);
            break;

            case 'ta':
                $maker_results = $this->maker->selectKanaOfItem($this->initial['ta'], $div);
            break;

            case 'na':
                $maker_results = $this->maker->selectKanaOfItem($this->initial['na'], $div);
            break;

            case 'ha':
                $maker_results = $this->maker->selectKanaOfItem($this->initial['ha'], $div);
            break;

            case 'ma':
                $maker_results = $this->maker->selectKanaOfItem($this->initial['ma'], $div);
            break;

            case 'ya':
                $maker_results = $this->maker->selectKanaOfItem($this->initial['ya'], $div);
            break;

            case 'ra':
                $maker_results = $this->maker->selectKanaOfItem($this->initial['ra'], $div);
            break;

            case 'wa':
                $maker_results = $this->maker->selectKanaOfItem($this->initial['wa'], $div);
            break;

            case '': 
                if (!empty($this->selid)) {
                    $maker_results = $this->maker->selectKeyToKana($this->selid, $this->initial, $div);
                }
            break;
        }

        /**************************
         * 出力フォーマットは以下の通り
         * 
         * ドロップのID
         * optionのname,optionのvalue,option.selected
         * optionのname,optionのvalue,option.selected
         * ...
         * 
         */

        $out = $this->dropid ."\n0,メーカー名,false";
        foreach ($maker_results as $key => $val) {
            $out .= "\n". $val["makercd"] .",". $val["makernm"];
            if ($this->selid == $val["makercd"]) {
                $out .= ",true";
            } else {
                $out .= ",false";
            }
        }
        return $out;
    }
}
?>
