Beispiel #1
0
    /**
     * confirm_page
     * 確認ページでのフォーム項目を返す
     * @return string HTML
     */
    protected function confirm_page()
    {
        $value = $this->Data->get_raw($this->atts['name']);
        if ($value) {
            $filepath = MWF_Functions::fileurl_to_path($value);
            if (file_exists($filepath)) {
                return sprintf('<div class="%s_image">
						<img src="%s" alt="" />
						%s
					</div>', esc_attr(MWF_Config::NAME), esc_attr($value), $this->Form->hidden($this->atts['name'], $value));
            }
        }
    }
 /**
  * confirmPage
  * 確認ページでのフォーム項目を返す
  * @return string HTML
  */
 protected function confirmPage()
 {
     $value = $this->Form->getValue($this->atts['name']);
     if ($value) {
         $filepath = MWF_Functions::fileurl_to_path($value);
         if (file_exists($filepath)) {
             $_ret = '<div class="' . MWF_Config::NAME . '_image">';
             $_ret .= '<img src="' . esc_attr($value) . '" alt="" />';
             $_ret .= $this->Form->hidden($this->atts['name'], $value);
             $_ret .= '</div>';
             return $_ret;
         }
     }
 }
 /**
  * confirmPage
  * 確認ページでのフォーム項目を返す
  * @return string HTML
  */
 protected function confirmPage()
 {
     $value = $this->Form->getValue($this->atts['name']);
     if ($value) {
         $filepath = MWF_Functions::fileurl_to_path($value);
         if (file_exists($filepath)) {
             $_ret = '<div class="' . MWF_Config::NAME . '_file">';
             $_ret .= '<a href="' . esc_attr($value) . '" target="_blank">' . __('Uploaded.', MWF_Config::DOMAIN) . '</a>';
             $_ret .= '</div>';
             $_ret .= $this->Form->hidden($this->atts['name'], $value);
             return $_ret;
         }
     }
 }
Beispiel #4
0
 /**
  * アップロードに失敗、もしくはファイルが削除されている key を UPLOAD_FILE_KEYS から削除
  */
 public function set_upload_file_keys()
 {
     $upload_file_keys = $this->get_post_value_by_key(MWF_Config::UPLOAD_FILE_KEYS);
     if (!$upload_file_keys) {
         $upload_file_keys = array();
     }
     $wp_upload_dir = wp_upload_dir();
     foreach ($upload_file_keys as $key => $upload_file_key) {
         $upload_file_url = $this->get_post_value_by_key($upload_file_key);
         if ($upload_file_url) {
             $filepath = MWF_Functions::fileurl_to_path($upload_file_url);
             if (!file_exists($filepath)) {
                 unset($upload_file_keys[$key]);
             }
         }
     }
     $this->set(MWF_Config::UPLOAD_FILE_KEYS, $upload_file_keys);
 }
Beispiel #5
0
 /**
  * 送信されたデータをもとに添付ファイル用の配列を生成して返す
  *
  * @return array $attachments pathの配列
  */
 protected function get_attachments()
 {
     $attachments = array();
     $upload_file_keys = $this->Data->get_post_value_by_key(MWF_Config::UPLOAD_FILE_KEYS);
     if ($upload_file_keys !== null && is_array($upload_file_keys)) {
         $wp_upload_dir = wp_upload_dir();
         foreach ($upload_file_keys as $key) {
             $upload_file_url = $this->Data->get_post_value_by_key($key);
             if (!$upload_file_url) {
                 continue;
             }
             $filepath = MWF_Functions::fileurl_to_path($upload_file_url);
             if (file_exists($filepath)) {
                 $filepath = MWF_Functions::move_temp_file_to_upload_dir($filepath);
                 $new_upload_file_url = MWF_Functions::filepath_to_url($filepath);
                 $this->Data->set($key, $new_upload_file_url);
                 $attachments[$key] = $filepath;
             }
         }
     }
     return $attachments;
 }
Beispiel #6
0
 /**
  * fileupload
  * ファイルアップロード処理。実際のアップロード状況に合わせてフォームデータも再生成する。
  */
 protected function fileupload()
 {
     $uploadedFiles = array();
     $files = $this->Data->getValue(MWF_Config::UPLOAD_FILES);
     if (!is_array($files)) {
         $files = array();
     }
     foreach ($files as $key => $file) {
         if ($this->Validation->singleCheck($key)) {
             $uploadedFile = $this->File->singleFileupload($key);
             if ($uploadedFile) {
                 $uploadedFiles[$key] = $uploadedFile;
             }
         }
     }
     // 時間切れなどで削除されたファイルのキーを削除
     $upload_file_keys = $this->Data->getValue(MWF_Config::UPLOAD_FILE_KEYS);
     if (!$upload_file_keys) {
         $upload_file_keys = array();
     }
     $wp_upload_dir = wp_upload_dir();
     foreach ($upload_file_keys as $upload_file_key) {
         $upload_file_url = $this->Data->getValue($upload_file_key);
         if ($upload_file_url) {
             $filepath = MWF_Functions::fileurl_to_path($upload_file_url);
             if (!file_exists($filepath)) {
                 unset($upload_file_keys[$upload_file_key]);
             }
         }
     }
     $this->Data->setValue(MWF_Config::UPLOAD_FILE_KEYS, $upload_file_keys);
     // アップロードに成功したファイルをフォームデータに格納
     foreach ($uploadedFiles as $key => $uploadfile) {
         $this->Data->setValue($key, $uploadfile);
         if (!in_array($key, $upload_file_keys)) {
             $this->Data->pushValue(MWF_Config::UPLOAD_FILE_KEYS, $key);
         }
     }
 }