<?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     Admin.Imguploader.Confirm
 * @author      netnee <mail@example.com>
 * @access      public
 */
class Admin_Imguploader_Confirm
{
    var $fileUpload;
    var $actionChain;
    
    var $imgtypedivlist;
    var $nmtypedivlist;
    var $title;
    var $pagename;
    var $div;
    
    var $imgtypediv;
    var $generalcd;
    var $generalsub;
    var $imgintotitle;
    var $fromaction;
    
    var $filelist;
    
    var $mode_s;
    var $mode_m;
    var $mode_l;
    var $mode_logo;
    var $mode_main;
    var $mode_mov;
    
    var $dest_s;
    var $dest_m;
    var $dest_l;
    var $dest_logo;
    var $dest_main;
    var $dest_mov;
    
    // マスタメンテ部関連
    var $srcword;
    var $srcrecommenddiv;
    var $srcdispnum;
    var $srccastdiv;
    var $from;
    
    
    function execute()
    {
        $log =& LogFactory::getLog();
        $log->debug("Admin_Imguploader_Confirmが実行されました", "Admin_Imguploader_Confirm#execute");

        // タイトル設定
        if (!empty($this->imgtypediv)){
            $this->pagename = $this->nmtypedivlist[$this->imgtypediv - 1];
        }

        $tmpcd  = $this->generalcd;
        $tmpcd .= (!empty($this->generalsub)) ? "-".$this->generalsub : "";

        $this->filelist = array();
        $i = 0;

        // L
        $this->fileUpload->setName("image_l");
        $count        = $this->fileUpload->count();
        $originalName = $this->fileUpload->getOriginalName();
        $mimeType     = $this->fileUpload->getMimeType();
        $filesize     = $this->fileUpload->getFilesize();

        if (isset($originalName[0]) && $originalName[0]) {
            $pathinfo = pathInfo($originalName[0]);
            $extension = $pathinfo['extension'];

            $imgnm = $tmpcd ."L.jpg";
            $dest = IMAGE_WORKDIR ."/". $imgnm;
            $this->fileUpload->move(0, $dest);

            $this->dest_l = $imgnm;
            $this->filelist[$i] = array(
                'id'           => 'L',
                'originalName' => $originalName[0],
                'mimeType'     => $mimeType[0],
                'filesize'     => $filesize[0],
            );
            
            $log->debug(print_r($this->filelist[$i], true), "Admin_Imguploader_Confirm#execute");
            
            $i++;
        } else {
            $this->mode_l = "";
        }

        // M
        $this->fileUpload->setName("image_m");
        $count        = $this->fileUpload->count();
        $originalName = $this->fileUpload->getOriginalName();
        $mimeType     = $this->fileUpload->getMimeType();
        $filesize     = $this->fileUpload->getFilesize();

        if (isset($originalName[0]) && $originalName[0]) {
            $pathinfo = pathInfo($originalName[0]);
            $extension = $pathinfo['extension'];

            $imgnm = $tmpcd ."M.jpg";
            $dest = IMAGE_WORKDIR ."/". $imgnm;
            $this->fileUpload->move(0, $dest);

            $this->dest_m = $imgnm;
            $this->filelist[$i] = array(
                'id'           => 'M',
                'originalName' => $originalName[0],
                'mimeType'     => $mimeType[0],
                'filesize'     => $filesize[0],
            );
            
            $log->debug(print_r($this->filelist[$i], true), "Admin_Imguploader_Confirm#execute");
            
            $i++;
        } else {
            $this->mode_m = "";
        }

        // S
        $this->fileUpload->setName("image_s");
        $count        = $this->fileUpload->count();
        $originalName = $this->fileUpload->getOriginalName();
        $mimeType     = $this->fileUpload->getMimeType();
        $filesize     = $this->fileUpload->getFilesize();

        if (isset($originalName[0]) && $originalName[0]) {

            $pathinfo = pathInfo($originalName[0]);
            $extension = $pathinfo['extension'];

            $imgnm = $tmpcd ."S.jpg";
            $dest = IMAGE_WORKDIR ."/". $imgnm;
            $this->fileUpload->move(0, $dest);

            $this->dest_s = $imgnm;
            $this->filelist[$i] = array(
                'id'           => 'S',
                'originalName' => $originalName[0],
                'mimeType'     => $mimeType[0],
                'filesize'     => $filesize[0],
            );
            
            $log->debug(print_r($this->filelist[$i], true), "Admin_Imguploader_Confirm#execute");
            
            $i++;
        } else {
            $this->mode_s = "";
        }

        // shop-logo
        $this->fileUpload->setName("image_logo");
        $count        = $this->fileUpload->count();
        $originalName = $this->fileUpload->getOriginalName();
        $mimeType     = $this->fileUpload->getMimeType();
        $filesize     = $this->fileUpload->getFilesize();

        if (isset($originalName[0]) && $originalName[0]) {

            $pathinfo = pathInfo($originalName[0]);
            $extension = $pathinfo['extension'];

            $imgnm = $tmpcd ."logo.jpg";
            $dest = IMAGE_WORKDIR ."/". $imgnm;
            $this->fileUpload->move(0, $dest);

            $this->dest_logo = $imgnm;
            $this->filelist[$i] = array(
                'id'           => 'logo',
                'originalName' => $originalName[0],
                'mimeType'     => $mimeType[0],
                'filesize'     => $filesize[0],
            );
            
            $log->debug(print_r($this->filelist[$i], true), "Admin_Imguploader_Confirm#execute");
            $log->debug($this->mode_logo, "Admin_Imguploader_Confirm#execute");
            
            $i++;
        } else {
            $this->mode_logo = "";
        }

        // shop-main
        $this->fileUpload->setName("image_main");
        $count        = $this->fileUpload->count();
        $originalName = $this->fileUpload->getOriginalName();
        $mimeType     = $this->fileUpload->getMimeType();
        $filesize     = $this->fileUpload->getFilesize();

        if (isset($originalName[0]) && $originalName[0]) {

            $pathinfo = pathInfo($originalName[0]);
            $extension = $pathinfo['extension'];

            $imgnm = $tmpcd ."main.jpg";
            $dest = IMAGE_WORKDIR ."/". $imgnm;
            $this->fileUpload->move(0, $dest);

            $this->dest_main = $imgnm;
            $this->filelist[$i] = array(
                'id'           => 'main',
                'originalName' => $originalName[0],
                'mimeType'     => $mimeType[0],
                'filesize'     => $filesize[0],
            );
            
            $log->debug(print_r($this->filelist[$i], true), "Admin_Imguploader_Confirm#execute");
            $log->debug($this->mode_main, "Admin_Imguploader_Confirm#execute");
            
            $i++;
        } else {
            $this->mode_main = "";
        }

        // item-mov
        $this->fileUpload->setName("item_movie");
        $count        = $this->fileUpload->count();
        $originalName = $this->fileUpload->getOriginalName();
        $mimeType     = $this->fileUpload->getMimeType();
        $filesize     = $this->fileUpload->getFilesize();

        if (isset($originalName[0]) && $originalName[0]) {

            $pathinfo = pathInfo($originalName[0]);
            $extension = $pathinfo['extension'];

            $imgnm = $this->generalcd ."_". $this->generalsub .".". $extension;
            $dest = IMAGE_WORKDIR ."/". $imgnm;
            $this->fileUpload->move(0, $dest);

            $this->dest_mov = $imgnm;
            $this->filelist[$i] = array(
                'id'           => 'mov',
                'originalName' => $originalName[0],
                'mimeType'     => $mimeType[0],
                'filesize'     => $filesize[0],
            );
            
            $log->debug(print_r($this->filelist[$i], true), "Admin_Imguploader_Confirm#execute");
            $log->debug($this->mode_mov, "Admin_Imguploader_Confirm#execute");
            
            $i++;
        } else {
            $this->mode_mov = "";
        }

        return "success";
    }

    function getImageUrl($params)
    {
        return ;
    }
}
?>
