diff --git a/examples/demo/demo-safe.ecf b/examples/demo/demo-safe.ecf index 482e63e..306db91 100644 --- a/examples/demo/demo-safe.ecf +++ b/examples/demo/demo-safe.ecf @@ -26,6 +26,7 @@ + @@ -54,7 +55,6 @@ - diff --git a/examples/demo/site/files/uploaded_files/demo-safe.ecf b/examples/demo/site/files/uploaded_files/demo-safe.ecf deleted file mode 100644 index 482e63e..0000000 --- a/examples/demo/site/files/uploaded_files/demo-safe.ecf +++ /dev/null @@ -1,82 +0,0 @@ - - - Example/demo for Eiffel ROC CMS library - - - - /.svn$ - /CVS$ - /EIFGENs$ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/demo/site/files/uploaded_files/demo.ini b/examples/demo/site/files/uploaded_files/demo.ini deleted file mode 100644 index 2498319..0000000 --- a/examples/demo/site/files/uploaded_files/demo.ini +++ /dev/null @@ -1,3 +0,0 @@ -port=9090 -#port=12345 -#verbose=true diff --git a/examples/demo/site/files/uploaded_files/install_modules.bat b/examples/demo/site/files/uploaded_files/install_modules.bat deleted file mode 100644 index 98de61d..0000000 --- a/examples/demo/site/files/uploaded_files/install_modules.bat +++ /dev/null @@ -1,15 +0,0 @@ -setlocal -set ROC_CMD=call %~dp0..\..\tools\roc.bat -set ROC_CMS_DIR=%~dp0 - -%ROC_CMD% install --module ..\..\modules\admin --dir %ROC_CMS_DIR% -%ROC_CMD% install --module ..\..\modules\auth --dir %ROC_CMS_DIR% -%ROC_CMD% install --module ..\..\modules\basic_auth --dir %ROC_CMS_DIR% -%ROC_CMD% install --module ..\..\modules\blog --dir %ROC_CMS_DIR% -%ROC_CMD% install --module ..\..\modules\node --dir %ROC_CMS_DIR% -%ROC_CMD% install --module ..\..\modules\oauth20 --dir %ROC_CMS_DIR% -%ROC_CMD% install --module ..\..\modules\openid --dir %ROC_CMS_DIR% -%ROC_CMD% install --module ..\..\modules\recent_changes --dir %ROC_CMS_DIR% -%ROC_CMD% install --module ..\..\modules\feed_aggregator --dir %ROC_CMS_DIR% -%ROC_CMD% install --module ..\..\modules\google_search --dir %ROC_CMS_DIR% -%ROC_CMD% install --module ..\..\modules\taxonomy --dir %ROC_CMS_DIR% diff --git a/examples/demo/src/demo_cms_execution.e b/examples/demo/src/demo_cms_execution.e index 8a1490e..b4c5b3f 100644 --- a/examples/demo/src/demo_cms_execution.e +++ b/examples/demo/src/demo_cms_execution.e @@ -94,7 +94,7 @@ feature -- CMS modules a_setup.register_module (m) -- uploader - create {CMS_FILE_UPLOAD} m.make + create {CMS_FILE_UPLOADER_MODULE} m.make a_setup.register_module (m) end diff --git a/modules/file_upload/cms_file.e b/modules/file_upload/cms_file.e new file mode 100644 index 0000000..fc2a023 --- /dev/null +++ b/modules/file_upload/cms_file.e @@ -0,0 +1,69 @@ +note + description: "Interface representing any files under `{CMS_API}.files_location' ." + date: "$Date$" + revision: "$Revision$" + +class + CMS_FILE + +create + make + +feature {NONE} -- Initializaion + + make (a_relative_path: PATH; a_api: CMS_API) + do + cms_api := a_api + location := a_relative_path + end + + cms_api: CMS_API + +feature -- Access + + filename: STRING_32 + -- File name of Current file. + local + p: PATH + do + p := location + if attached p.entry as e then + Result := e.name + else + Result := p.name + end + end + + location: PATH + -- Path relative the `CMS_API.files_location'. + + owner: detachable CMS_USER + -- Optional owner. + +feature -- Status report + + is_directory: BOOLEAN + local + d: DIRECTORY + do + create d.make_with_path (cms_api.files_location.extended_path (location)) + Result := d.exists + end + + is_file: BOOLEAN + local + f: RAW_FILE + do + create f.make_with_path (cms_api.files_location.extended_path (location)) + Result := f.exists + end + +feature -- Element change + + set_owner (u: detachable CMS_USER) + -- Set `owner' to `u'. + do + owner := u + end + +end diff --git a/modules/file_upload/cms_file_upload.e b/modules/file_upload/cms_file_upload.e deleted file mode 100644 index 2975dd1..0000000 --- a/modules/file_upload/cms_file_upload.e +++ /dev/null @@ -1,248 +0,0 @@ -note - description: "file_upload application root class" - date: "$Date$" - revision: "$Revision$" - -class - CMS_FILE_UPLOAD - -inherit - CMS_MODULE - redefine - install, - initialize, - setup_hooks, - permissions - end - - CMS_HOOK_BLOCK - - CMS_HOOK_MENU_SYSTEM_ALTER - - SHARED_EXECUTION_ENVIRONMENT - -create - make - -feature {NONE} -- Initialization - - make - do - name := "file_uploader" - version := "1.0" - description := "Service to upload some files" - package := "file upload" - end - -feature -- Access - - name: STRING - - permissions: LIST [READABLE_STRING_8] - -- List of permission ids, used by this module, and declared. - do - Result := Precursor - Result.force ("manage admin") - Result.force ("admin users") - Result.force ("admin roles") - Result.force ("admin modules") - Result.force ("install modules") - Result.force ("admin core caches") - Result.force ("clear blocks cache") - Result.force ("admin export") - Result.force ("export core") - - Result.force ("upload files") - end - -feature {CMS_API} -- Module Initialization - - initialize (api: CMS_API) - -- - do - Precursor (api) - end - -feature {CMS_API}-- Module management - - install (api: CMS_API) - -- install the module - local - sql: STRING - do - -- create a database table - if attached {CMS_STORAGE_SQL_I} api.storage as l_sql_storage then - if not l_sql_storage.sql_table_exists ("file_upload_table") then - sql := "[ -CREATE TABLE file_upload_table( - `id` INTEGER PRIMARY KEY AUTO_INCREMENT NOT NULL CHECK("id">=0), - `name` VARCHAR(100) NOT NULL, - `uploaded_date` DATE, - `size` INTEGER -); - ]" - l_sql_storage.sql_execute_script (sql, Void) - if l_sql_storage.has_error then - api.logger.put_error ("Could not initialize database for file uploader module", generating_type) - end - end - Precursor {CMS_MODULE}(api) - end - end - -feature -- Access: router - - - setup_router (a_router: WSF_ROUTER; a_api: CMS_API) - -- - local - www: WSF_FILE_SYSTEM_HANDLER - do - - map_uri_template_agent (a_router, "/upload/", agent execute_upload, void) - - create www.make_with_path (document_root) - www.set_directory_index (<<"index.html">>) - www.set_not_found_handler (agent execute_not_found_handler) - a_router.handle("", www, a_router.methods_get) - end - -feature -- Hooks - - setup_hooks (a_hooks: CMS_HOOK_CORE_MANAGER) - do - a_hooks.subscribe_to_menu_system_alter_hook (Current) - a_hooks.subscribe_to_block_hook (Current) - end - - block_list: ITERABLE [like {CMS_BLOCK}.name] - do - Result := <<"?uploader">> - end - - get_block_view (a_block_id: READABLE_STRING_8; a_response: CMS_RESPONSE) - local - menu: CMS_MENU - menu_block: CMS_MENU_BLOCK - menu_entries_count: INTEGER - do - if a_block_id.same_string ("uploader") then - -- create menu_block.make ({CMS_MENU_SYSTEM}.primary_menu) - -- a_response.add_block (menu_block, "page_top") - end - end - - menu_system_alter (a_menu_system: CMS_MENU_SYSTEM; a_response: CMS_RESPONSE) - local - link: CMS_LOCAL_LINK - second_link: CMS_LOCAL_LINK - do - -- login in demo did somehow not work - -- if a_response.has_permission ("upload files") then - create link.make ("Upload", "upload/") - a_menu_system.primary_menu.extend (link) - -- end - end - -feature -- Configuration - - document_root: PATH - -- Document root to look for files or directories - once - Result := execution_environment.current_working_path.extended ("site") - end - - files_root: PATH - -- Uploaded files will be stored in `files_root' folder - local - tmp: PATH - once - tmp := document_root.extended ("files") - Result := tmp.extended ("uploaded_files") - end - -feature -- Handler - - execute_not_found_handler (uri: READABLE_STRING_8; req: WSF_REQUEST; res: WSF_RESPONSE) - -- `uri' is not found, redirect to default page - do - res.redirect_now_with_content (req.script_url ("/"), uri + ": not found. %N Redirectioin to" + req.script_url ("/"), "text/html") - end - - execute_upload (req: WSF_REQUEST; res: WSF_RESPONSE) - local - body: STRING_8 - do - -- create body - create body.make_empty - body.append ("

EWF: Upload files

%N") - body.append ("

Please choose some file(s) to upload.

") - - -- create form to choose files and upload them - body.append ("
%N") - body.append (" %N") - body.append ("%N") - body.append ("
%N") - - -- put the body to the response - res.put_string (body) - - show_and_store_files (req, res) - - end - - show_and_store_files (req: WSF_REQUEST; res: WSF_RESPONSE) - -- show all uploaded files - local - file_path: PATH - file_name: STRING_8 - stored: BOOLEAN - file_system_handler: WSF_FILE_SYSTEM_HANDLER - file_system_upload_handler: CMS_FILE_UPLOAD_FILE_SYSTEM_HANDLER - uploaded_file: CMS_FILE_UPLOAD_FILE - do - -- if has uploaded files, then store them - if req.has_uploaded_file then - across - req.uploaded_files as uf - loop - file_name := uf.item.safe_filename - - -- check if file is already in folder - if not files_root.has_extension (file_name) then - file_path := files_root.extended (file_name) - - -- move file to path - stored := uf.item.move_to(file_path.name) - end - end - end - - -- create file_system_handler and show the uploaded files - create file_system_handler.make_with_path (document_root) - file_system_handler.enable_index - file_system_handler.process_index ("/uploaded_files", files_root, req, res) - - end - - -feature -- Mapping helper: uri template agent (analogue to the demo-module) - - map_uri_template (a_router: WSF_ROUTER; a_tpl: STRING; h: WSF_URI_TEMPLATE_HANDLER; rqst_methods: detachable WSF_REQUEST_METHODS) - -- Map `h' as handler for `a_tpl', according to `rqst_methods'. - require - a_tpl_attached: a_tpl /= Void - h_attached: h /= Void - do - a_router.map (create {WSF_URI_TEMPLATE_MAPPING}.make (a_tpl, h), rqst_methods) - end - - map_uri_template_agent (a_router: WSF_ROUTER; a_tpl: READABLE_STRING_8; proc: PROCEDURE [TUPLE [req: WSF_REQUEST; res: WSF_RESPONSE]]; rqst_methods: detachable WSF_REQUEST_METHODS) - -- Map `proc' as handler for `a_tpl', according to `rqst_methods'. - require - a_tpl_attached: a_tpl /= Void - proc_attached: proc /= Void - do - map_uri_template (a_router, a_tpl, create {WSF_URI_TEMPLATE_AGENT_HANDLER}.make (proc), rqst_methods) - end -end diff --git a/modules/file_upload/cms_file_upload_file.e b/modules/file_upload/cms_file_upload_file.e index c94ae8a..8ab4288 100644 --- a/modules/file_upload/cms_file_upload_file.e +++ b/modules/file_upload/cms_file_upload_file.e @@ -9,26 +9,35 @@ class inherit WSF_UPLOADED_FILE - redefine - name + rename + make as make_uploaded_file, + name as uploaded_file_name, + change_name as change_uploaded_file_name, + is_empty as is_empty_uploaded_file, + exists as uploaded_file_exists end RAW_FILE - undefine - make, change_name, is_empty, exists + rename + make as make_file end +-- undefine +-- make, change_name, is_empty, exists +-- end create - make_new, - make_with_path + make feature -- Initialization - make_new (a_name: READABLE_STRING_GENERAL; a_filename: READABLE_STRING_GENERAL; a_content_type: like content_type; a_size: like size; a_user: CMS_USER) + make (a_name: READABLE_STRING_GENERAL; a_filename: READABLE_STRING_GENERAL; a_content_type: like content_type; a_size: like size; a_user: CMS_USER) local time: DATE_TIME do - new_name := a_name.as_string_32 + make_uploaded_file (a_name, a_filename, a_content_type, a_size) + make_with_name (a_filename) + + uploaded_file_name := a_name.as_string_32 url_encoded_name := url_encoded_string (a_name) filename := a_filename.as_string_32 content_type := a_content_type diff --git a/modules/file_upload/cms_file_uploader_api.e b/modules/file_upload/cms_file_uploader_api.e new file mode 100644 index 0000000..22c4311 --- /dev/null +++ b/modules/file_upload/cms_file_uploader_api.e @@ -0,0 +1,78 @@ +note + description: "API to manage files." + date: "$Date$" + revision: "$Revision$" + +class + CMS_FILE_UPLOADER_API + +inherit + CMS_MODULE_API + + REFACTORING_HELPER + +create + make + +feature -- Access + + uploads_directory_name: STRING = "uploaded_files" + + uploads_location: PATH + do + Result := cms_api.files_location.extended (uploads_directory_name) + end + + file_link (f: CMS_FILE): CMS_LOCAL_LINK + local + s: STRING + do + s := "files" + across + f.location.components as ic + loop + s.append_character ('/') + s.append (percent_encoded (ic.item.name)) + end + create Result.make (f.filename, s) + end + +feature -- Factory + + new_file (p: PATH): CMS_FILE + do + create Result.make (p, cms_api) + end + + new_uploads_file (p: PATH): CMS_FILE + -- New uploaded path from `p' related to `uploads_location'. + do + create Result.make ((create {PATH}.make_from_string (uploads_directory_name)).extended_path (p), cms_api) + end + +feature -- Storage + + save_uploaded_file (f: CMS_UPLOADED_FILE) + local + p: PATH + ut: FILE_UTILITIES + stored: BOOLEAN + do + p := f.location + if p.is_absolute then + else + p := uploads_location.extended_path (p) + end + if ut.file_path_exists (p) then + -- FIXME: find an alternative name for it, by appending "-" + i.out , with i: INTEGER; + error_handler.add_custom_error (-1, "uploaded file storage failed", "A file with same name already exists!") + else + -- move file to path + stored := f.move_to (p) + if not stored then + error_handler.add_custom_error (-1, "uploaded file storage failed", "Issue occurred when saving uploaded file!") + end + end + end + +end diff --git a/modules/file_upload/cms_file_uploader_module.e b/modules/file_upload/cms_file_uploader_module.e new file mode 100644 index 0000000..23c75fe --- /dev/null +++ b/modules/file_upload/cms_file_uploader_module.e @@ -0,0 +1,332 @@ +note + description: "file_upload application root class" + date: "$Date$" + revision: "$Revision$" + +class + CMS_FILE_UPLOADER_MODULE + +inherit + CMS_MODULE + rename + module_api as file_upload_api + redefine + install, + initialize, + setup_hooks, + permissions, + file_upload_api + end + + CMS_HOOK_MENU_SYSTEM_ALTER + + SHARED_EXECUTION_ENVIRONMENT + +create + make + +feature {NONE} -- Initialization + + make + do + name := "file_uploader" + version := "1.0" + description := "Service to upload files, and manage them." + package := "file" + end + +feature -- Access + + name: STRING + + permissions: LIST [READABLE_STRING_8] + -- List of permission ids, used by this module, and declared. + do + Result := Precursor + Result.force ("admin uploaded files") + Result.force ("upload files") + end + +feature {CMS_API} -- Module Initialization + + initialize (api: CMS_API) + -- + do + Precursor (api) + if file_upload_api = Void then + create file_upload_api.make (api) + end + end + +feature {CMS_API}-- Module management + + install (api: CMS_API) + -- install the module + local + sql: STRING + l_file_upload_api: like file_upload_api + d: DIRECTORY + do + -- create a database table + if attached {CMS_STORAGE_SQL_I} api.storage as l_sql_storage then + + -- FIXME: This is not used, is it planned in the future? + + if not l_sql_storage.sql_table_exists ("file_upload_table") then + sql := "[ +CREATE TABLE file_upload_table( + `id` INTEGER PRIMARY KEY AUTO_INCREMENT NOT NULL CHECK("id">=0), + `name` VARCHAR(100) NOT NULL, + `uploaded_date` DATE, + `size` INTEGER +); + ]" + l_sql_storage.sql_execute_script (sql, Void) + if l_sql_storage.has_error then + api.logger.put_error ("Could not initialize database for file uploader module", generating_type) + end + end + end + + create l_file_upload_api.make (api) + create d.make_with_path (l_file_upload_api.uploads_location) + if not d.exists then + d.recursive_create_dir + end + file_upload_api := l_file_upload_api + Precursor (api) + end + +feature {CMS_API} -- Access: API + + file_upload_api: detachable CMS_FILE_UPLOADER_API + -- + +feature -- Access: router + + setup_router (a_router: WSF_ROUTER; a_api: CMS_API) + -- + local +-- www: WSF_FILE_SYSTEM_HANDLER + do + map_uri_template_agent (a_router, "/upload/", agent execute_upload (?, ?, a_api), Void) -- Accepts any method GET, HEAD, POST, PUT, DELETE, ... + map_uri_template_agent (a_router, "/upload/{filename}", agent display_uploaded_file_info (?, ?, a_api), a_router.methods_get) + +-- create www.make_with_path (document_root) +-- www.set_directory_index (<<"index.html">>) +-- www.set_not_found_handler (agent execute_not_found_handler) +-- a_router.handle("", www, a_router.methods_get) + end + +feature -- Hooks + + setup_hooks (a_hooks: CMS_HOOK_CORE_MANAGER) + do + a_hooks.subscribe_to_menu_system_alter_hook (Current) + end + + menu_system_alter (a_menu_system: CMS_MENU_SYSTEM; a_response: CMS_RESPONSE) + local + link: CMS_LOCAL_LINK + do + -- login in demo did somehow not work + -- if a_response.has_permission ("upload files") then + create link.make ("Upload", "upload/") + a_menu_system.primary_menu.extend (link) + -- end + end + +--feature -- Configuration + +-- document_root: PATH +-- -- Document root to look for files or directories +-- once +-- Result := execution_environment.current_working_path.extended ("site") +-- end + +-- files_root: PATH +-- -- Uploaded files will be stored in `files_root' folder +-- local +-- tmp: PATH +-- once +-- tmp := document_root.extended ("files") +-- Result := tmp.extended ("uploaded_files") +-- end + +feature -- Handler + + execute_not_found_handler (uri: READABLE_STRING_8; req: WSF_REQUEST; res: WSF_RESPONSE) + -- `uri' is not found, redirect to default page + do + res.redirect_now_with_content (req.script_url ("/"), uri + ": not found. %N Redirectioin to" + req.script_url ("/"), "text/html") + end + + display_uploaded_file_info (req: WSF_REQUEST; res: WSF_RESPONSE; api: CMS_API) + local + body: STRING_8 + r: CMS_RESPONSE + f: CMS_FILE + fn: READABLE_STRING_32 + do + check req.is_get_request_method end + create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api) + + create body.make_empty + if attached {WSF_STRING} req.path_parameter ("filename") as p_filename then + fn := p_filename.value + body.append ("

File %"" + api.html_encoded (fn) + "%"

%N") + body.append ("
%N") -- To ease css customization. + if attached file_upload_api as l_file_upload_api then + f := l_file_upload_api.new_uploads_file (create {PATH}.make_from_string (fn)) + + -- FIXME: get CMS information related to this file ... + + body.append ("

Open the media ") + body.append (api.html_encoded (f.filename)) + body.append (".

%N") + + if attached f.location.extension as ext then + if + ext.is_case_insensitive_equal_general ("png") + or ext.is_case_insensitive_equal_general ("jpg") + then + body.append ("
") + end + end + end + body.append ("%N
%N") + end + r.add_to_primary_tabs (create {CMS_LOCAL_LINK}.make ("Uploaded files", "upload/")) + r.set_main_content (body) + r.execute + end + + execute_upload (req: WSF_REQUEST; res: WSF_RESPONSE; api: CMS_API) + local + body: STRING_8 + r: CMS_RESPONSE + do + if req.is_get_head_request_method or req.is_post_request_method then + -- create body + create body.make_empty + body.append ("

Upload files

%N") + body.append ("

Please choose some file(s) to upload.

") + + -- create form to choose files and upload them + body.append ("
%N") + body.append (" %N") + body.append ("%N") + body.append ("
%N") + + if req.is_post_request_method then + process_uploaded_files (req, api, body) + end + + -- Build the response. + create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api) + append_uploaded_file_album_to (req, api, body) + r.set_main_content (body) + else + create {BAD_REQUEST_ERROR_CMS_RESPONSE} r.make (req, res, api) + end + r.execute + end + + process_uploaded_files (req: WSF_REQUEST; api: CMS_API; a_output: STRING) + -- show all uploaded files + local +-- stored: BOOLEAN +-- file_system_handler: WSF_FILE_SYSTEM_HANDLER +-- file_system_upload_handler: CMS_FILE_UPLOAD_FILE_SYSTEM_HANDLER + l_uploaded_file: CMS_UPLOADED_FILE + uf: WSF_UPLOADED_FILE +-- ut: FILE_UTILITIES +-- files_root: PATH + do + if attached file_upload_api as l_file_upload_api then + -- if has uploaded files, then store them + if req.has_uploaded_file then + a_output.append ("
    Uploaded file(s):%N") + across + req.uploaded_files as ic + loop + uf := ic.item + create l_uploaded_file.make_with_uploaded_file (l_file_upload_api.uploads_location, uf) + a_output.append ("
  • ") + a_output.append (api.html_encoded (l_uploaded_file.filename)) + l_file_upload_api.save_uploaded_file (l_uploaded_file) + -- FIXME: display for information, about the new disk filename. + if l_file_upload_api.error_handler.has_error then + a_output.append (" failed!") + end + a_output.append ("
  • ") + end + a_output.append ("
%N") + end + end + end + + append_uploaded_file_album_to (req: WSF_REQUEST; api: CMS_API; a_output: STRING) + local + d: DIRECTORY + f: CMS_FILE + p: PATH + rel: PATH + do + if attached file_upload_api as l_file_upload_api then + create rel.make_from_string (l_file_upload_api.uploads_directory_name) + p := api.files_location.extended_path (rel) + + a_output.append ("
    Index of uploads:%N") + + create d.make_with_path (p) + if d.exists then + across + d.entries as ic + loop + if ic.item.is_current_symbol then + -- Ignore + elseif ic.item.is_parent_symbol then + -- Ignore for now. + else + f := l_file_upload_api.new_file (rel.extended_path (ic.item)) + + if f.is_directory then + a_output.append ("
  • ") + else + a_output.append ("
  • ") + end + a_output.append ("") + a_output.append (api.html_encoded (f.filename)) + a_output.append ("") + + a_output.append ("( ") + a_output.append ("media)") + a_output.append ("
  • %N") + end + end + end + a_output.append ("
%N") + end + end + +feature -- Mapping helper: uri template agent (analogue to the demo-module) + + map_uri_template (a_router: WSF_ROUTER; a_tpl: STRING; h: WSF_URI_TEMPLATE_HANDLER; rqst_methods: detachable WSF_REQUEST_METHODS) + -- Map `h' as handler for `a_tpl', according to `rqst_methods'. + require + a_tpl_attached: a_tpl /= Void + h_attached: h /= Void + do + a_router.map (create {WSF_URI_TEMPLATE_MAPPING}.make (a_tpl, h), rqst_methods) + end + + map_uri_template_agent (a_router: WSF_ROUTER; a_tpl: READABLE_STRING_8; proc: PROCEDURE [TUPLE [req: WSF_REQUEST; res: WSF_RESPONSE]]; rqst_methods: detachable WSF_REQUEST_METHODS) + -- Map `proc' as handler for `a_tpl', according to `rqst_methods'. + require + a_tpl_attached: a_tpl /= Void + proc_attached: proc /= Void + do + map_uri_template (a_router, a_tpl, create {WSF_URI_TEMPLATE_AGENT_HANDLER}.make (proc), rqst_methods) + end +end diff --git a/modules/file_upload/cms_uploaded_file.e b/modules/file_upload/cms_uploaded_file.e new file mode 100644 index 0000000..23ee805 --- /dev/null +++ b/modules/file_upload/cms_uploaded_file.e @@ -0,0 +1,62 @@ +note + description: "Summary description for {CMS_UPLOADED_FILE}." + date: "$Date$" + revision: "$Revision$" + +class + CMS_UPLOADED_FILE + +create + make_with_uploaded_file + +feature {NONE} -- Initializaion + + make_with_uploaded_file (a_uploads_location: PATH; uf: WSF_UPLOADED_FILE) + do + uploads_location := a_uploads_location + uploaded_file := uf + location := a_uploads_location.extended (uf.safe_filename) + end + +feature -- Access + + uploaded_file: WSF_UPLOADED_FILE + + uploads_location: PATH + + filename: STRING_32 + -- File name of Current file. + local + p: PATH + do + p := location + if attached p.entry as e then + Result := e.name + else + Result := p.name + end + end + + + location: PATH + -- Absolute path, or relative path to the `CMS_API.files_location'. + + owner: detachable CMS_USER + -- Optional owner. + +feature -- Element change + + set_owner (u: detachable CMS_USER) + -- Set `owner' to `u'. + do + owner := u + end + +feature -- Basic operation + + move_to (p: PATH): BOOLEAN + do + Result := uploaded_file.move_to (p.name) + end + +end diff --git a/modules/file_upload/file_uploader.ecf b/modules/file_upload/file_uploader.ecf index ff9add6..1c7ec99 100644 --- a/modules/file_upload/file_uploader.ecf +++ b/modules/file_upload/file_uploader.ecf @@ -1,29 +1,21 @@ - - - - - + + /.svn$ + /CVS$ + /EIFGENs$ + +