<?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      H.Watanabe <hiroshi.watanabe@netnee.jp>
 * @access      public
 */
class Admin_Itemmanage_Import_Cast_Execute
{
    /**
     * [[機能説明]]
     *
     * @access  public
     */
    
    var $title;
    var $pagename;
    var $div;

    var $importfile;
    var $actionChain;

    var $import;
    var $importfilename;
    var $release;
    var $images;
    
    function execute()
    {
        $errorList =& $this->actionChain->getCurErrorList();

        $log =& LogFactory::getLog();
        $log->debug("Admin_Itemmanage_Import_Cast_Executeが実行されました", "Admin_Itemmanage_Import_Cast_Execute#execute");

        $originalName = $this->importfile->getOriginalName();
        $mimeType     = $this->importfile->getMimeType();
        $filesize     = $this->importfile->getFilesize();
        $tmpname     = $this->importfile->getTmpName();

        $this->import = array();
        if ($filesize[0] <= 0) {
            $errorList -> add("SIZE_ERROR", "処理できるデータがありません");
            return 'upload';
        }

        $this->importfilename = date("Ymd-his") .".csv";
        $dist = IMPORTDIR_TEMP ."/temp_". $this->importfilename;
        if (!$this->importfile->move(0, $dist)) {
            $errorList -> add("正しくアップロードされませんでした。もう一度やり直すか、管理者へ報告してください。");
            return 'upload';
        }

        if (!isset($this->release)) $this->release = 0;
        if (empty($this->images)) $this->images = "none";

        return 'success';
    }
}
?>
