コード例 #1
0
ファイル: _object_base.php プロジェクト: klan1/k1.lib
 public function apply_file_uploads_filter()
 {
     if ($this->get_state()) {
         if (empty($this->db_table_data) || !is_array($this->db_table_data)) {
             trigger_error(__METHOD__ . " " . object_base_strings::$error_no_table_data, E_USER_WARNING);
             return FALSE;
         } else {
             $table_config_array = $this->db_table->get_db_table_config();
             $file_upload_fields = [];
             foreach ($table_config_array as $field => $options) {
                 if ($options['validation'] == 'file-upload') {
                     $file_upload_fields[$field] = $options['file-type'];
                 }
             }
             if (!empty($file_upload_fields)) {
                 foreach ($file_upload_fields as $field => $file_type) {
                     switch ($file_type) {
                         case "image":
                             //                                $div_container = new \k1lib\html\div();
                             $img_tag = new \k1lib\html\img(file_uploads::get_uploads_url() . "--fieldvalue--");
                             $img_tag->set_attrib("class", "k1lib-data-img", TRUE);
                             //                                $delete_file_link = new \k1lib\html\a("./unlink-uploaded-file/", "remove this file");
                             //                                $div_container->append_child($img_tag);
                             //                                $div_container->append_child($delete_file_link);
                             return $this->apply_html_tag_on_field_filter($img_tag, array_keys($file_upload_fields));
                         default:
                             $link_tag = new \k1lib\html\a(url::do_url(file_uploads::get_uploads_url() . "--fieldvalue--"), "--fieldvalue--", "_blank");
                             $link_tag->set_attrib("class", "k1lib-data-link", TRUE);
                             return $this->apply_html_tag_on_field_filter($link_tag, array_keys($file_upload_fields));
                     }
                 }
             }
         }
     } else {
         return FALSE;
     }
 }