From ce469b6edec0ab2fa1cff93ff546f482ad3645c9 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Thu, 31 Jan 2013 15:33:24 +0100 Subject: [PATCH] Updated CMS code. Separated code to have a lib and an example. Improved design, fixed a few issues related to folder location. This is still experimental and require more work to be really friendly to use. --- draft/application/cms/cms-safe.ecf | 2 +- draft/application/cms/cms.ecf | 30 ++ draft/application/cms/cms.ini | 3 - draft/application/cms/example/cms.ini | 8 + .../application/cms/example/cms_demo-safe.ecf | 22 + draft/application/cms/{ => example}/ewf.ini | 0 .../src/module/demo/demo_module.e | 0 .../module/shutdown/shutdown_cms_execution.e | 0 .../src/module/shutdown/shutdown_module.e | 0 .../cms/{ => example}/src/web_cms.e | 15 +- .../cms/src/{core => }/cms_configuration.e | 93 ++++- .../cms/src/{core => }/cms_execution.e | 75 +++- .../src/{core => }/cms_html_page_response.e | 0 .../cms/src/{core => }/cms_service.e | 103 ++++- .../cms/src/{core => }/cms_session.e | 0 .../core/default_theme/default_cms_theme.e | 134 ------ .../kernel/form/cms_form_checkbox_input.e | 46 -- .../default_theme/default_cms_html_template.e | 0 .../default_theme/default_cms_page_template.e | 0 .../cms/src/default_theme/default_cms_theme.e | 131 ++++++ .../{core => }/handler/any_cms_execution.e | 12 +- .../handler/cms_file_system_handler.e | 0 .../cms/src/{core => }/handler/cms_handler.e | 0 .../{core => }/handler/home_cms_execution.e | 0 .../handler/not_found_cms_execution.e | 0 .../{core => }/handler/theme_cms_execution.e | 0 .../cms/src/{core => }/hooks/cms_hook.e | 0 .../cms/src/hooks/cms_hook_auto_register.e | 29 ++ .../cms/src/{core => }/hooks/cms_hook_block.e | 0 .../{core => }/hooks/cms_hook_form_alter.e | 0 .../{core => }/hooks/cms_hook_menu_alter.e | 0 .../{core => }/kernel/api/cms_api_options.e | 0 .../{core => }/kernel/api/cms_common_api.e | 39 +- .../kernel/api/cms_url_api_options.e | 0 .../{core => }/kernel/auth/cms_auth_engine.e | 0 .../kernel/auth/cms_storage_auth_engine.e | 4 +- draft/application/cms/src/kernel/cms_css.e | 65 +++ .../cms/src/kernel/cms_css_selector.e | 24 ++ .../cms/src/kernel/cms_css_style.e | 393 ++++++++++++++++++ .../cms/src/{core => }/kernel/cms_html_page.e | 0 .../{core => }/kernel/cms_session_controler.e | 0 .../cms/src/{core => }/kernel/cms_user.e | 18 +- .../src/{core => }/kernel/cms_user_profile.e | 0 .../src/{core => }/kernel/content/cms_block.e | 0 .../kernel/content/cms_content_block.e | 0 .../kernel/content/cms_content_type.e | 0 .../kernel/content/cms_menu_block.e | 0 .../src/{core => }/kernel/content/cms_node.e | 0 .../content/format/cms_filtered_html_format.e | 0 .../kernel/content/format/cms_format.e | 0 .../kernel/content/format/cms_formats.e | 0 .../content/format/cms_full_html_format.e | 0 .../content/format/cms_plain_text_format.e | 0 .../content/format/filters/cms_filter.e | 0 .../content/format/filters/cms_html_filter.e | 0 .../format/filters/cms_html_to_text_filter.e | 0 .../filters/cms_line_break_converter_filter.e | 0 .../format/filters/cms_no_html_filter.e | 0 .../content/format/filters/cms_url_filter.e | 0 .../cms/src/{core => }/kernel/form/cms_form.e | 17 +- .../kernel/form/cms_form_button_input.e | 0 .../src/kernel/form/cms_form_checkbox_input.e | 81 ++++ .../{core => }/kernel/form/cms_form_data.e | 0 .../cms/src/kernel/form/cms_form_div.e | 65 +++ .../{core => }/kernel/form/cms_form_field.e | 39 +- .../kernel/form/cms_form_field_set.e | 9 +- .../kernel/form/cms_form_file_input.e | 0 .../kernel/form/cms_form_hidden_input.e | 3 +- .../kernel/form/cms_form_image_input.e | 0 .../{core => }/kernel/form/cms_form_input.e | 24 +- .../{core => }/kernel/form/cms_form_item.e | 5 + .../kernel/form/cms_form_password_input.e | 3 +- .../kernel/form/cms_form_radio_input.e | 15 + .../kernel/form/cms_form_raw_text.e | 0 .../kernel/form/cms_form_reset_input.e | 0 .../{core => }/kernel/form/cms_form_select.e | 23 +- .../kernel/form/cms_form_select_option.e | 12 +- .../kernel/form/cms_form_selectable_item.e | 25 ++ .../kernel/form/cms_form_submit_input.e | 3 +- .../kernel/form/cms_form_text_input.e | 3 +- .../kernel/form/cms_form_textarea.e | 5 + .../cms/src/kernel/form/cms_form_utility.e | 22 + .../cms/src/kernel/form/with_css_class.e | 83 ++++ .../cms/src/kernel/form/with_css_id.e | 41 ++ .../cms/src/kernel/form/with_css_style.e | 31 ++ .../kernel/link/cms_external_link.e | 0 .../cms/src/{core => }/kernel/link/cms_link.e | 0 .../{core => }/kernel/link/cms_local_link.e | 0 .../cms/src/{core => }/kernel/link/cms_menu.e | 0 .../{core => }/kernel/link/cms_menu_system.e | 0 .../cms/src/kernel/link/cms_pager.e | 144 +++++++ .../cms/src/{core => }/kernel/log/cms_log.e | 0 .../admin/admin_blocks_cms_execution.e | 0 .../modules/admin/admin_cms_execution.e | 0 .../modules/admin/admin_logs_cms_execution.e | 0 .../{core => }/modules/admin/admin_module.e | 0 .../admin/admin_modules_cms_execution.e | 0 .../modules/admin/admin_users_cms_execution.e | 0 .../modules/admin/log_view_cms_execution.e | 0 .../cms/src/{core => }/modules/cms_module.e | 0 .../src/{core => }/modules/cms_module_link.e | 0 .../src/{core => }/modules/node/cms_page.e | 0 .../modules/node/cms_page_content_type.e | 2 +- .../modules/node/node_add_cms_execution.e | 0 .../modules/node/node_edit_cms_execution.e | 0 .../src/{core => }/modules/node/node_module.e | 0 .../modules/node/node_view_cms_execution.e | 0 .../modules/user/user_account_cms_execution.e | 0 .../modules/user/user_cms_execution.e | 2 +- .../modules/user/user_edit_cms_execution.e | 0 .../modules/user/user_login_cms_execution.e | 0 .../modules/user/user_logout_cms_execution.e | 0 .../src/{core => }/modules/user/user_module.e | 0 .../{core => }/modules/user/user_module_lib.e | 0 .../user/user_new_password_cms_execution.e | 0 .../user/user_register_cms_execution.e | 0 .../user/user_reset_password_cms_execution.e | 0 .../notification/cms_chain_mailer.e | 0 .../src/{core => }/notification/cms_email.e | 0 .../notification/cms_external_mailer.e | 33 +- .../src/{core => }/notification/cms_mailer.e | 0 .../notification/cms_sendmail_mailer.e | 0 .../notification/cms_storage_mailer.e | 0 .../src/{core => }/storage/cms_sed_storage.e | 13 + .../cms/src/{core => }/storage/cms_storage.e | 7 +- .../src/{core => }/theme/cms_html_template.e | 0 .../src/{core => }/theme/cms_page_template.e | 0 .../cms/src/{core => }/theme/cms_template.e | 0 .../cms/src/{core => }/theme/cms_theme.e | 2 +- .../cms/themes/default/res/favicon.ico | Bin 786 -> 0 bytes .../{ => www/themes/default/res}/favicon.ico | Bin .../cms/{ => www}/themes/default/res/logo.png | Bin .../{ => www}/themes/default/res/style.css | 0 .../themes/test/res}/favicon.ico | Bin .../cms/www/themes/test/res/logo.png | Bin 0 -> 3193 bytes .../cms/www/themes/test/res/style.css | 182 ++++++++ 136 files changed, 1841 insertions(+), 299 deletions(-) create mode 100644 draft/application/cms/cms.ecf delete mode 100644 draft/application/cms/cms.ini create mode 100644 draft/application/cms/example/cms.ini create mode 100644 draft/application/cms/example/cms_demo-safe.ecf rename draft/application/cms/{ => example}/ewf.ini (100%) rename draft/application/cms/{ => example}/src/module/demo/demo_module.e (100%) rename draft/application/cms/{ => example}/src/module/shutdown/shutdown_cms_execution.e (100%) rename draft/application/cms/{ => example}/src/module/shutdown/shutdown_module.e (100%) rename draft/application/cms/{ => example}/src/web_cms.e (89%) rename draft/application/cms/src/{core => }/cms_configuration.e (61%) rename draft/application/cms/src/{core => }/cms_execution.e (88%) rename draft/application/cms/src/{core => }/cms_html_page_response.e (100%) rename draft/application/cms/src/{core => }/cms_service.e (75%) rename draft/application/cms/src/{core => }/cms_session.e (100%) delete mode 100644 draft/application/cms/src/core/default_theme/default_cms_theme.e delete mode 100644 draft/application/cms/src/core/kernel/form/cms_form_checkbox_input.e rename draft/application/cms/src/{core => }/default_theme/default_cms_html_template.e (100%) rename draft/application/cms/src/{core => }/default_theme/default_cms_page_template.e (100%) create mode 100644 draft/application/cms/src/default_theme/default_cms_theme.e rename draft/application/cms/src/{core => }/handler/any_cms_execution.e (74%) rename draft/application/cms/src/{core => }/handler/cms_file_system_handler.e (100%) rename draft/application/cms/src/{core => }/handler/cms_handler.e (100%) rename draft/application/cms/src/{core => }/handler/home_cms_execution.e (100%) rename draft/application/cms/src/{core => }/handler/not_found_cms_execution.e (100%) rename draft/application/cms/src/{core => }/handler/theme_cms_execution.e (100%) rename draft/application/cms/src/{core => }/hooks/cms_hook.e (100%) create mode 100644 draft/application/cms/src/hooks/cms_hook_auto_register.e rename draft/application/cms/src/{core => }/hooks/cms_hook_block.e (100%) rename draft/application/cms/src/{core => }/hooks/cms_hook_form_alter.e (100%) rename draft/application/cms/src/{core => }/hooks/cms_hook_menu_alter.e (100%) rename draft/application/cms/src/{core => }/kernel/api/cms_api_options.e (100%) rename draft/application/cms/src/{core => }/kernel/api/cms_common_api.e (83%) rename draft/application/cms/src/{core => }/kernel/api/cms_url_api_options.e (100%) rename draft/application/cms/src/{core => }/kernel/auth/cms_auth_engine.e (100%) rename draft/application/cms/src/{core => }/kernel/auth/cms_storage_auth_engine.e (69%) create mode 100644 draft/application/cms/src/kernel/cms_css.e create mode 100644 draft/application/cms/src/kernel/cms_css_selector.e create mode 100644 draft/application/cms/src/kernel/cms_css_style.e rename draft/application/cms/src/{core => }/kernel/cms_html_page.e (100%) rename draft/application/cms/src/{core => }/kernel/cms_session_controler.e (100%) rename draft/application/cms/src/{core => }/kernel/cms_user.e (97%) rename draft/application/cms/src/{core => }/kernel/cms_user_profile.e (100%) rename draft/application/cms/src/{core => }/kernel/content/cms_block.e (100%) rename draft/application/cms/src/{core => }/kernel/content/cms_content_block.e (100%) rename draft/application/cms/src/{core => }/kernel/content/cms_content_type.e (100%) rename draft/application/cms/src/{core => }/kernel/content/cms_menu_block.e (100%) rename draft/application/cms/src/{core => }/kernel/content/cms_node.e (100%) rename draft/application/cms/src/{core => }/kernel/content/format/cms_filtered_html_format.e (100%) rename draft/application/cms/src/{core => }/kernel/content/format/cms_format.e (100%) rename draft/application/cms/src/{core => }/kernel/content/format/cms_formats.e (100%) rename draft/application/cms/src/{core => }/kernel/content/format/cms_full_html_format.e (100%) rename draft/application/cms/src/{core => }/kernel/content/format/cms_plain_text_format.e (100%) rename draft/application/cms/src/{core => }/kernel/content/format/filters/cms_filter.e (100%) rename draft/application/cms/src/{core => }/kernel/content/format/filters/cms_html_filter.e (100%) rename draft/application/cms/src/{core => }/kernel/content/format/filters/cms_html_to_text_filter.e (100%) rename draft/application/cms/src/{core => }/kernel/content/format/filters/cms_line_break_converter_filter.e (100%) rename draft/application/cms/src/{core => }/kernel/content/format/filters/cms_no_html_filter.e (100%) rename draft/application/cms/src/{core => }/kernel/content/format/filters/cms_url_filter.e (100%) rename draft/application/cms/src/{core => }/kernel/form/cms_form.e (94%) rename draft/application/cms/src/{core => }/kernel/form/cms_form_button_input.e (100%) create mode 100644 draft/application/cms/src/kernel/form/cms_form_checkbox_input.e rename draft/application/cms/src/{core => }/kernel/form/cms_form_data.e (100%) create mode 100644 draft/application/cms/src/kernel/form/cms_form_div.e rename draft/application/cms/src/{core => }/kernel/form/cms_form_field.e (68%) rename draft/application/cms/src/{core => }/kernel/form/cms_form_field_set.e (86%) rename draft/application/cms/src/{core => }/kernel/form/cms_form_file_input.e (100%) rename draft/application/cms/src/{core => }/kernel/form/cms_form_hidden_input.e (95%) rename draft/application/cms/src/{core => }/kernel/form/cms_form_image_input.e (100%) rename draft/application/cms/src/{core => }/kernel/form/cms_form_input.e (78%) rename draft/application/cms/src/{core => }/kernel/form/cms_form_item.e (84%) rename draft/application/cms/src/{core => }/kernel/form/cms_form_password_input.e (92%) rename draft/application/cms/src/{core => }/kernel/form/cms_form_radio_input.e (70%) rename draft/application/cms/src/{core => }/kernel/form/cms_form_raw_text.e (100%) rename draft/application/cms/src/{core => }/kernel/form/cms_form_reset_input.e (100%) rename draft/application/cms/src/{core => }/kernel/form/cms_form_select.e (80%) rename draft/application/cms/src/{core => }/kernel/form/cms_form_select_option.e (81%) create mode 100644 draft/application/cms/src/kernel/form/cms_form_selectable_item.e rename draft/application/cms/src/{core => }/kernel/form/cms_form_submit_input.e (91%) rename draft/application/cms/src/{core => }/kernel/form/cms_form_text_input.e (91%) rename draft/application/cms/src/{core => }/kernel/form/cms_form_textarea.e (92%) create mode 100644 draft/application/cms/src/kernel/form/cms_form_utility.e create mode 100644 draft/application/cms/src/kernel/form/with_css_class.e create mode 100644 draft/application/cms/src/kernel/form/with_css_id.e create mode 100644 draft/application/cms/src/kernel/form/with_css_style.e rename draft/application/cms/src/{core => }/kernel/link/cms_external_link.e (100%) rename draft/application/cms/src/{core => }/kernel/link/cms_link.e (100%) rename draft/application/cms/src/{core => }/kernel/link/cms_local_link.e (100%) rename draft/application/cms/src/{core => }/kernel/link/cms_menu.e (100%) rename draft/application/cms/src/{core => }/kernel/link/cms_menu_system.e (100%) create mode 100644 draft/application/cms/src/kernel/link/cms_pager.e rename draft/application/cms/src/{core => }/kernel/log/cms_log.e (100%) rename draft/application/cms/src/{core => }/modules/admin/admin_blocks_cms_execution.e (100%) rename draft/application/cms/src/{core => }/modules/admin/admin_cms_execution.e (100%) rename draft/application/cms/src/{core => }/modules/admin/admin_logs_cms_execution.e (100%) rename draft/application/cms/src/{core => }/modules/admin/admin_module.e (100%) rename draft/application/cms/src/{core => }/modules/admin/admin_modules_cms_execution.e (100%) rename draft/application/cms/src/{core => }/modules/admin/admin_users_cms_execution.e (100%) rename draft/application/cms/src/{core => }/modules/admin/log_view_cms_execution.e (100%) rename draft/application/cms/src/{core => }/modules/cms_module.e (100%) rename draft/application/cms/src/{core => }/modules/cms_module_link.e (100%) rename draft/application/cms/src/{core => }/modules/node/cms_page.e (100%) rename draft/application/cms/src/{core => }/modules/node/cms_page_content_type.e (98%) rename draft/application/cms/src/{core => }/modules/node/node_add_cms_execution.e (100%) rename draft/application/cms/src/{core => }/modules/node/node_edit_cms_execution.e (100%) rename draft/application/cms/src/{core => }/modules/node/node_module.e (100%) rename draft/application/cms/src/{core => }/modules/node/node_view_cms_execution.e (100%) rename draft/application/cms/src/{core => }/modules/user/user_account_cms_execution.e (100%) rename draft/application/cms/src/{core => }/modules/user/user_cms_execution.e (99%) rename draft/application/cms/src/{core => }/modules/user/user_edit_cms_execution.e (100%) rename draft/application/cms/src/{core => }/modules/user/user_login_cms_execution.e (100%) rename draft/application/cms/src/{core => }/modules/user/user_logout_cms_execution.e (100%) rename draft/application/cms/src/{core => }/modules/user/user_module.e (100%) rename draft/application/cms/src/{core => }/modules/user/user_module_lib.e (100%) rename draft/application/cms/src/{core => }/modules/user/user_new_password_cms_execution.e (100%) rename draft/application/cms/src/{core => }/modules/user/user_register_cms_execution.e (100%) rename draft/application/cms/src/{core => }/modules/user/user_reset_password_cms_execution.e (100%) rename draft/application/cms/src/{core => }/notification/cms_chain_mailer.e (100%) rename draft/application/cms/src/{core => }/notification/cms_email.e (100%) rename draft/application/cms/src/{core => }/notification/cms_external_mailer.e (88%) rename draft/application/cms/src/{core => }/notification/cms_mailer.e (100%) rename draft/application/cms/src/{core => }/notification/cms_sendmail_mailer.e (100%) rename draft/application/cms/src/{core => }/notification/cms_storage_mailer.e (100%) rename draft/application/cms/src/{core => }/storage/cms_sed_storage.e (97%) rename draft/application/cms/src/{core => }/storage/cms_storage.e (88%) rename draft/application/cms/src/{core => }/theme/cms_html_template.e (100%) rename draft/application/cms/src/{core => }/theme/cms_page_template.e (100%) rename draft/application/cms/src/{core => }/theme/cms_template.e (100%) rename draft/application/cms/src/{core => }/theme/cms_theme.e (97%) delete mode 100644 draft/application/cms/themes/default/res/favicon.ico rename draft/application/cms/{ => www/themes/default/res}/favicon.ico (100%) rename draft/application/cms/{ => www}/themes/default/res/logo.png (100%) rename draft/application/cms/{ => www}/themes/default/res/style.css (100%) rename draft/application/cms/{files => www/themes/test/res}/favicon.ico (100%) create mode 100644 draft/application/cms/www/themes/test/res/logo.png create mode 100644 draft/application/cms/www/themes/test/res/style.css diff --git a/draft/application/cms/cms-safe.ecf b/draft/application/cms/cms-safe.ecf index 596289b0..ae3fa3e0 100644 --- a/draft/application/cms/cms-safe.ecf +++ b/draft/application/cms/cms-safe.ecf @@ -1,5 +1,5 @@ - + diff --git a/draft/application/cms/cms.ecf b/draft/application/cms/cms.ecf new file mode 100644 index 00000000..c8139825 --- /dev/null +++ b/draft/application/cms/cms.ecf @@ -0,0 +1,30 @@ + + + + + + /EIFGENs$ + /CVS$ + /.svn$ + + + + + + + + + + + + + + + + + + + + diff --git a/draft/application/cms/cms.ini b/draft/application/cms/cms.ini deleted file mode 100644 index f1803e45..00000000 --- a/draft/application/cms/cms.ini +++ /dev/null @@ -1,3 +0,0 @@ -site.name=EWF Web CMS -#site.base_url=/demo -site.email=your@email.com diff --git a/draft/application/cms/example/cms.ini b/draft/application/cms/example/cms.ini new file mode 100644 index 00000000..41e81088 --- /dev/null +++ b/draft/application/cms/example/cms.ini @@ -0,0 +1,8 @@ +site.name=EWF Web CMS +#site.base_url=/demo +site.email=your@email.com +root-dir=../www +var-dir=var +files-dir=../www/files +themes-dir=../www/themes +theme=test diff --git a/draft/application/cms/example/cms_demo-safe.ecf b/draft/application/cms/example/cms_demo-safe.ecf new file mode 100644 index 00000000..cac6d8f4 --- /dev/null +++ b/draft/application/cms/example/cms_demo-safe.ecf @@ -0,0 +1,22 @@ + + + + + + /.git$ + /EIFGENs$ + /.svn$ + + + + + + + + + + + + + diff --git a/draft/application/cms/ewf.ini b/draft/application/cms/example/ewf.ini similarity index 100% rename from draft/application/cms/ewf.ini rename to draft/application/cms/example/ewf.ini diff --git a/draft/application/cms/src/module/demo/demo_module.e b/draft/application/cms/example/src/module/demo/demo_module.e similarity index 100% rename from draft/application/cms/src/module/demo/demo_module.e rename to draft/application/cms/example/src/module/demo/demo_module.e diff --git a/draft/application/cms/src/module/shutdown/shutdown_cms_execution.e b/draft/application/cms/example/src/module/shutdown/shutdown_cms_execution.e similarity index 100% rename from draft/application/cms/src/module/shutdown/shutdown_cms_execution.e rename to draft/application/cms/example/src/module/shutdown/shutdown_cms_execution.e diff --git a/draft/application/cms/src/module/shutdown/shutdown_module.e b/draft/application/cms/example/src/module/shutdown/shutdown_module.e similarity index 100% rename from draft/application/cms/src/module/shutdown/shutdown_module.e rename to draft/application/cms/example/src/module/shutdown/shutdown_module.e diff --git a/draft/application/cms/src/web_cms.e b/draft/application/cms/example/src/web_cms.e similarity index 89% rename from draft/application/cms/src/web_cms.e rename to draft/application/cms/example/src/web_cms.e index 35452815..d86e4b4a 100644 --- a/draft/application/cms/src/web_cms.e +++ b/draft/application/cms/example/src/web_cms.e @@ -25,6 +25,13 @@ feature -- Initialization base_url: detachable READABLE_STRING_8 + server_base_url: detachable READABLE_STRING_8 + -- Base url (related to absolute path). + --| Mainly pertinent when run from a standalone server. + do + Result := base_url + end + modules: ARRAYED_LIST [CMS_MODULE] local m: CMS_MODULE @@ -83,14 +90,14 @@ feature {NONE} -- Initialization create cms_config.make end - --| The following line is to be able to load options from the file ewf.ini + --| EWF settings create opts.make_from_file ("ewf.ini") service_options := opts - - --| If you don't need any custom options, you are not obliged to redefine `initialize' Precursor + + --| CMS settings base_url := cms_config.site_base_url (base_url) - initialize_cms + initialize_cms (cms_config) site_email := cms_config.site_email (site_email) site_name := cms_config.site_name (site_name) diff --git a/draft/application/cms/src/core/cms_configuration.e b/draft/application/cms/src/cms_configuration.e similarity index 61% rename from draft/application/cms/src/core/cms_configuration.e rename to draft/application/cms/src/cms_configuration.e index e0f56325..2ce1e69f 100644 --- a/draft/application/cms/src/core/cms_configuration.e +++ b/draft/application/cms/src/cms_configuration.e @@ -7,6 +7,9 @@ note class CMS_CONFIGURATION +--inherit +-- SHARED_EXECUTION_ENVIRONMENT + create make, make_from_file @@ -16,6 +19,7 @@ feature {NONE} -- Initialization make do create options.make (10) + analyze end make_from_file (a_filename: READABLE_STRING_32) @@ -23,6 +27,15 @@ feature {NONE} -- Initialization do make import (a_filename) + analyze + end + + analyze + do + get_root_location + get_var_location + get_themes_location + get_files_location end feature -- Access @@ -43,24 +56,74 @@ feature -- Element change feature -- Access - root_location: STRING + var_location: READABLE_STRING_8 + + get_var_location + local + res: STRING_32 do - if attached options.item ("root.location") as s then - Result := s + if attached options.item ("var-dir") as s then + res := s else - Result := execution_environment.current_working_directory + res := execution_environment.current_working_directory end - if not Result.ends_with ("/") then - Result.append_character ('/') + if res.ends_with ("/") then + res.remove_tail (1) + end + var_location := res + end + + root_location: READABLE_STRING_8 + + get_root_location + local + res: STRING_32 + do + if attached options.item ("root-dir") as s then + res := s + else + res := execution_environment.current_working_directory + end + if res.ends_with ("/") then + res.remove_tail (1) + end + root_location := res + end + + files_location: STRING + + get_files_location + do + if attached options.item ("files-dir") as s then + files_location := s + else + files_location := "files" end end themes_location: STRING + + get_themes_location + local + dn: DIRECTORY_NAME do - if attached options.item ("themes.location") as s then - Result := s + if attached options.item ("themes-dir") as s then + themes_location := s else - Result := root_location + "theme/default/" + create dn.make_from_string (root_location) + dn.extend ("theme") + themes_location := dn.string + end + end + + theme_name (dft: detachable like theme_name): READABLE_STRING_8 + do + if attached options.item ("theme") as s then + Result := s + elseif dft /= Void then + Result := dft + else + Result := "default" end end @@ -103,11 +166,6 @@ feature -- Access feature {NONE} -- Implementation - execution_environment: EXECUTION_ENVIRONMENT - once - create Result - end - import (a_filename: READABLE_STRING_32) -- Import ini file content local @@ -143,4 +201,11 @@ feature {NONE} -- Implementation end end +feature {NONE} -- Environment + + Execution_environment: EXECUTION_ENVIRONMENT + once + create Result + end + end diff --git a/draft/application/cms/src/core/cms_execution.e b/draft/application/cms/src/cms_execution.e similarity index 88% rename from draft/application/cms/src/core/cms_execution.e rename to draft/application/cms/src/cms_execution.e index 94d420d5..6e6b64dc 100644 --- a/draft/application/cms/src/core/cms_execution.e +++ b/draft/application/cms/src/cms_execution.e @@ -24,7 +24,7 @@ feature {NONE} -- Initialization initialize do - is_front := request.path_info.same_string (service.front_path) + is_front := service.is_front_page (request) has_js := True -- by default it is true, check cookie to see if this is not supported. if attached request.cookie ("has_js") as c_has_js then has_js := c_has_js.same_string ("0") @@ -53,7 +53,7 @@ feature {CMS_SESSION_CONTROLER} -- Access: restricted base_url: detachable READABLE_STRING_8 do - Result := service.base_url + Result := service.server_base_url end pending_messages_session_item_name: STRING = "cms.pending_messages" @@ -349,10 +349,10 @@ feature -- Blocks add_block (create {CMS_MENU_BLOCK}.make (m), Void) end - create s.make_empty - s.append ("This site demonstrates a first implementation of CMS using EWF.%N") - create b.make ("about", "About", s, formats.plain_text) - add_block (b, "second_sidebar") +-- create s.make_empty +-- s.append ("This site demonstrates a first implementation of CMS using EWF.%N") +-- create b.make ("about", "About", s, formats.plain_text) +-- add_block (b, "second_sidebar") create s.make_empty s.append ("Made with EWF") @@ -374,6 +374,9 @@ feature -- Access page_title: detachable READABLE_STRING_32 -- Page title + additional_page_head_lines: detachable LIST [READABLE_STRING_8] + -- HTML>head>...extra lines + main_content: detachable STRING_8 redirection: detachable READABLE_STRING_8 @@ -416,6 +419,14 @@ feature -- Generation local s: STRING_8 do + if attached additional_page_head_lines as l_head_lines then + across + l_head_lines as hl + loop + page.head_lines.force (hl.item) + end + end + add_to_main_menu (create {CMS_LOCAL_LINK}.make ("Home", "/")) service.call_menu_alter_hooks (menu_system, Current) @@ -491,7 +502,51 @@ feature -- Generation end end -feature -- Element change +feature -- Head customization + + add_additional_head_line (s: READABLE_STRING_8; a_allow_duplication: BOOLEAN) + local + lst: like additional_page_head_lines + do + lst := additional_page_head_lines + if lst = Void then + create {ARRAYED_LIST [like additional_page_head_lines.item]} lst.make (1) + additional_page_head_lines := lst + end + if a_allow_duplication or else across lst as c all not c.item.same_string (s) end then + lst.extend (s) + end + end + + add_style (a_href: STRING; a_media: detachable STRING) + local + s: STRING_8 + do + s := "") + add_additional_head_line (s, False) + end + + add_javascript_url (a_src: STRING) + local + s: STRING_8 + do + s := "" + add_additional_head_line (s, False) + end + + add_javascript_content (a_script: STRING) + local + s: STRING_8 + do + s := "" + add_additional_head_line (s, True) + end + +feature -- Element change set_title (t: like title) do @@ -558,6 +613,12 @@ feature {NONE} -- Execution controller.session_commit (page, Current) response.send (page) + on_terminated + end + + on_terminated + do + end feature {NONE} -- Implementation diff --git a/draft/application/cms/src/core/cms_html_page_response.e b/draft/application/cms/src/cms_html_page_response.e similarity index 100% rename from draft/application/cms/src/core/cms_html_page_response.e rename to draft/application/cms/src/cms_html_page_response.e diff --git a/draft/application/cms/src/core/cms_service.e b/draft/application/cms/src/cms_service.e similarity index 75% rename from draft/application/cms/src/core/cms_service.e rename to draft/application/cms/src/cms_service.e index aebb13d4..027c2de2 100644 --- a/draft/application/cms/src/core/cms_service.e +++ b/draft/application/cms/src/cms_service.e @@ -11,11 +11,27 @@ deferred class feature -- Initialization - initialize_cms + initialize_cms (a_cfg: detachable CMS_CONFIGURATION) + local + cfg: detachable CMS_CONFIGURATION do - site_name := "EWF::CMS" - site_email := "webmaster" - site_url := "" -- FIXME + cfg := a_cfg + if cfg = Void then + create cfg.make + end + + site_url := "" -- Fixme + site_name := cfg.site_name ("EWF::CMS") + site_email := cfg.site_email ("webmaster") + site_dir := cfg.root_location + site_var_dir := cfg.var_location + files_location := cfg.files_location + themes_location := cfg.themes_location + theme_name := cfg.theme_name ("default") + + compute_theme_resource_location + + create content_types.make (3) initialize_storage initialize_auth_engine @@ -29,7 +45,7 @@ feature -- Initialization local dn: DIRECTORY_NAME do - create dn.make_from_string ((create {EXECUTION_ENVIRONMENT}).current_working_directory) + create dn.make_from_string (site_var_dir) dn.extend ("_storage_") dn.extend ("_sessions_") create {WSF_FS_SESSION_MANAGER} session_manager.make_with_folder (dn.string) @@ -37,26 +53,25 @@ feature -- Initialization initialize_storage local - e: EXECUTION_ENVIRONMENT dn: DIRECTORY_NAME +-- u: CMS_USER do - create e - create dn.make_from_string (e.current_working_directory) + create dn.make_from_string (site_var_dir) dn.extend ("_storage_") create {CMS_SED_STORAGE} storage.make (dn.string) - if storage.users_count = 0 then + if not storage.has_user then initialize_users end end initialize_users require - has_no_user: storage.users_count = 0 + has_no_user: not storage.has_user local u: CMS_USER do create u.make_new ("admin") - u.set_encoded_password (storage.encoded_password ("istrator")) + u.set_password ("istrator") storage.save_user (u) end @@ -75,6 +90,7 @@ feature -- Initialization local -- h: CMS_HANDLER file_hdl: CMS_FILE_SYSTEM_HANDLER + dn: DIRECTORY_NAME do create router.make (10) router.set_base_url (base_url) @@ -82,12 +98,13 @@ feature -- Initialization router.map (create {WSF_URI_MAPPING}.make ("/", create {CMS_HANDLER}.make (agent handle_home))) router.map (create {WSF_URI_MAPPING}.make ("/favicon.ico", create {CMS_HANDLER}.make (agent handle_favicon))) - create file_hdl.make ("files") + create file_hdl.make (files_location) file_hdl.disable_index file_hdl.set_max_age (8*60*60) router.map (create {WSF_STARTS_WITH_MAPPING}.make ("/files/", file_hdl)) - create file_hdl.make ("themes/default/res") + create dn.make_from_string (theme_resource_location) + create file_hdl.make (theme_resource_location) file_hdl.set_max_age (8*60*60) router.map (create {WSF_STARTS_WITH_MAPPING}.make ("/theme/", file_hdl)) end @@ -99,6 +116,9 @@ feature -- Initialization loop if m.item.is_enabled then m.item.register (Current) + if attached {CMS_HOOK_AUTO_REGISTER} m.item as h_auto then + h_auto.hook_auto_register (Current) + end end end end @@ -218,17 +238,54 @@ feature -- Hook: block feature -- Router - site_name: STRING_32 + site_name: READABLE_STRING_32 - site_email: STRING + site_email: READABLE_STRING_8 - site_url: STRING + site_url: READABLE_STRING_8 - front_path: STRING = "/" + site_dir: READABLE_STRING_8 + + site_var_dir: READABLE_STRING_8 + + files_location: READABLE_STRING_8 + + themes_location: READABLE_STRING_8 + + compute_theme_resource_location + local + dn: DIRECTORY_NAME + do + create dn.make_from_string (themes_location) + dn.extend (theme_name) + dn.extend ("res") + theme_resource_location := dn.string + end + + theme_resource_location: READABLE_STRING_8 + + theme_name: READABLE_STRING_32 + + front_path: STRING + do + if attached base_url as l_base_url then + Result := l_base_url + "/" + else + Result := "/" + end + end router: WSF_ROUTER base_url: detachable READABLE_STRING_8 + -- Base url (related to the script path). + deferred + ensure + valid_base_url: (Result /= Void and then Result.is_empty) implies (Result.starts_with ("/") and not Result.ends_with ("/")) + end + + server_base_url: detachable READABLE_STRING_8 + -- Base url (related to absolute path). deferred ensure valid_base_url: (Result /= Void and then Result.is_empty) implies (Result.starts_with ("/") and not Result.ends_with ("/")) @@ -244,6 +301,13 @@ feature -- Router router.map (create {WSF_URI_MAPPING}.make (a_uri, create {CMS_HANDLER}.make (proc))) end +feature -- Report + + is_front_page (req: WSF_REQUEST): BOOLEAN + do + Result := req.path_info.same_string (front_path) + end + feature -- Storage session_controller (req: WSF_REQUEST): CMS_SESSION_CONTROLER @@ -302,8 +366,11 @@ feature -- Core Execution handle_favicon (req: WSF_REQUEST; res: WSF_RESPONSE) local fres: WSF_FILE_RESPONSE + fn: FILE_NAME do - create fres.make ("files/favicon.ico") + create fn.make_from_string (theme_resource_location) + fn.set_file_name ("favicon.ico") + create fres.make (fn.string) fres.set_expires_in_seconds (7 * 24 * 60 * 60) -- 7 jours res.send (fres) end diff --git a/draft/application/cms/src/core/cms_session.e b/draft/application/cms/src/cms_session.e similarity index 100% rename from draft/application/cms/src/core/cms_session.e rename to draft/application/cms/src/cms_session.e diff --git a/draft/application/cms/src/core/default_theme/default_cms_theme.e b/draft/application/cms/src/core/default_theme/default_cms_theme.e deleted file mode 100644 index 07826965..00000000 --- a/draft/application/cms/src/core/default_theme/default_cms_theme.e +++ /dev/null @@ -1,134 +0,0 @@ -note - description: "Summary description for {CMS_THEME}." - author: "" - date: "$Date$" - revision: "$Revision$" - -class - DEFAULT_CMS_THEME - -inherit - CMS_THEME - -create - make - -feature {NONE} -- Initialization - - make (a_service: like service) - do - service := a_service - end - - service: CMS_SERVICE - -feature -- Access - - name: STRING = "CMS" - - regions: ARRAY [STRING] - once - Result := <<"header", "content", "footer", "first_sidebar", "second_sidebar">> - end - - html_template: DEFAULT_CMS_HTML_TEMPLATE - local - tpl: like internal_html_template - do - tpl := internal_html_template - if tpl = Void then - create tpl.make (Current) - internal_html_template := tpl - end - Result := tpl - end - - page_template: DEFAULT_CMS_PAGE_TEMPLATE - local - tpl: like internal_page_template - do - tpl := internal_page_template - if tpl = Void then - create tpl.make (Current) - internal_page_template := tpl - end - Result := tpl - end - - css: STRING - do - Result := "[ - body { margin: 0; } - div#header { background-color: #00a; color: #fff; border: solid 1px #00a; padding: 10px;} - div#header img#logo { float: left; margin: 3px; } - div#header div#title {font-size: 180%; font-weight: bold; } - ul.horizontal { - list-style-type: none; - } - ul.horizontal li { - display: inline; - padding: 5px; - } - div#first-menu { padding: 5px; color: #ccf; background-color: #006; } - div#first-menu a { color: #ccf; } - div#second-menu { color: #99f; background-color: #333; } - div#second-menu a { color: #99f; } - - div#left_sidebar { - width: 150px; - border: solid 1px #009; - margin: 5px; - padding: 5px; - width: 150px; - display: inline; - float: left; - position: relative; - } - div#main-wrapper { - clear: both; - display: block; - height: 0; - } - div#main { margin: 0; padding: 10px; clear: both; height:0; display: block; } - div#content { padding: 10px; border: solid 1px #00f; - width: 700px; - display: inline; - float: left; - position: relative; - } - div#footer { margin: 10px 0 10px 0; clear: both; display: block; text-align: center; padding: 10px; border-top: solid 1px #00f; color: #fff; background-color: #333;} - div#footer a { color: #ff0; } - ]" - end - -feature -- Conversion - - prepare (page: CMS_HTML_PAGE) - do - if attached css as t_css then --- page.head_lines.extend ("") - page.add_style (url ("/theme/style.css", Void), Void) - end - end - - page_html (page: CMS_HTML_PAGE): STRING_8 - local - l_content: STRING_8 - do - prepare (page) - page_template.prepare (page) - l_content := page_template.to_html (page) - html_template.prepare (page) - html_template.register (l_content, "page") - Result := html_template.to_html (page) - end - -feature {NONE} -- Internal - - internal_page_template: detachable like page_template - - internal_html_template: detachable like html_template - -invariant - attached internal_page_template as inv_p implies inv_p.theme = Current -end diff --git a/draft/application/cms/src/core/kernel/form/cms_form_checkbox_input.e b/draft/application/cms/src/core/kernel/form/cms_form_checkbox_input.e deleted file mode 100644 index 42b35165..00000000 --- a/draft/application/cms/src/core/kernel/form/cms_form_checkbox_input.e +++ /dev/null @@ -1,46 +0,0 @@ -note - description: "Summary description for {CMS_FORM_CHECKBOX_INPUT}." - author: "" - date: "$Date$" - revision: "$Revision$" - -class - CMS_FORM_CHECKBOX_INPUT - -inherit - CMS_FORM_INPUT - redefine - specific_input_attributes_string - end - -create - make - -feature -- Access - - checked: BOOLEAN - -- Current element should be preselected when the page loads - - input_type: STRING = "checkbox" - -feature -- Change - - set_checked (b: like checked) - do - checked := b - end - -feature {NONE} -- Implementation - - specific_input_attributes_string: detachable STRING_8 - -- Specific input attributes if any. - -- To redefine if needed - do - if checked then - Result := "checked=%"checked%"" - end - end - -invariant - -end diff --git a/draft/application/cms/src/core/default_theme/default_cms_html_template.e b/draft/application/cms/src/default_theme/default_cms_html_template.e similarity index 100% rename from draft/application/cms/src/core/default_theme/default_cms_html_template.e rename to draft/application/cms/src/default_theme/default_cms_html_template.e diff --git a/draft/application/cms/src/core/default_theme/default_cms_page_template.e b/draft/application/cms/src/default_theme/default_cms_page_template.e similarity index 100% rename from draft/application/cms/src/core/default_theme/default_cms_page_template.e rename to draft/application/cms/src/default_theme/default_cms_page_template.e diff --git a/draft/application/cms/src/default_theme/default_cms_theme.e b/draft/application/cms/src/default_theme/default_cms_theme.e new file mode 100644 index 00000000..78ae04ae --- /dev/null +++ b/draft/application/cms/src/default_theme/default_cms_theme.e @@ -0,0 +1,131 @@ +note + description: "Summary description for {CMS_THEME}." + author: "" + date: "$Date$" + revision: "$Revision$" + +class + DEFAULT_CMS_THEME + +inherit + CMS_THEME + +create + make + +feature {NONE} -- Initialization + + make (a_service: like service) + do + service := a_service + end + + service: CMS_SERVICE + +feature -- Access + + name: STRING = "CMS" + + regions: ARRAY [STRING] + once + Result := <<"header", "content", "footer", "first_sidebar", "second_sidebar">> + end + + html_template: DEFAULT_CMS_HTML_TEMPLATE + local + tpl: like internal_html_template + do + tpl := internal_html_template + if tpl = Void then + create tpl.make (Current) + internal_html_template := tpl + end + Result := tpl + end + + page_template: DEFAULT_CMS_PAGE_TEMPLATE + local + tpl: like internal_page_template + do + tpl := internal_page_template + if tpl = Void then + create tpl.make (Current) + internal_page_template := tpl + end + Result := tpl + end + +-- css: STRING +-- do +-- Result := "[ +-- body { margin: 0; } +-- div#header { background-color: #00a; color: #fff; border: solid 1px #00a; padding: 10px;} +-- div#header img#logo { float: left; margin: 3px; } +-- div#header div#title {font-size: 180%; font-weight: bold; } +-- ul.horizontal { +-- list-style-type: none; +-- } +-- ul.horizontal li { +-- display: inline; +-- padding: 5px; +-- } +-- div#first-menu { padding: 5px; color: #ccf; background-color: #006; } +-- div#first-menu a { color: #ccf; } +-- div#second-menu { color: #99f; background-color: #333; } +-- div#second-menu a { color: #99f; } +-- +-- div#left_sidebar { +-- width: 150px; +-- border: solid 1px #009; +-- margin: 5px; +-- padding: 5px; +-- width: 150px; +-- display: inline; +-- float: left; +-- position: relative; +-- } +-- div#main-wrapper { +-- clear: both; +-- display: block; +-- height: 0; +-- } +-- div#main { margin: 0; padding: 10px; clear: both; height:0; display: block; } +-- div#content { padding: 10px; border: solid 1px #00f; +-- width: 700px; +-- display: inline; +-- float: left; +-- position: relative; +-- } +-- div#footer { margin: 10px 0 10px 0; clear: both; display: block; text-align: center; padding: 10px; border-top: solid 1px #00f; color: #fff; background-color: #333;} +-- div#footer a { color: #ff0; } +-- ]" +-- end + +feature -- Conversion + + prepare (page: CMS_HTML_PAGE) + do + page.add_style (url ("/theme/style.css", Void), Void) + end + + page_html (page: CMS_HTML_PAGE): STRING_8 + local + l_content: STRING_8 + do + prepare (page) + page_template.prepare (page) + l_content := page_template.to_html (page) + html_template.prepare (page) + html_template.register (l_content, "page") + Result := html_template.to_html (page) + end + +feature {NONE} -- Internal + + internal_page_template: detachable like page_template + + internal_html_template: detachable like html_template + +invariant + attached internal_page_template as inv_p implies inv_p.theme = Current +end diff --git a/draft/application/cms/src/core/handler/any_cms_execution.e b/draft/application/cms/src/handler/any_cms_execution.e similarity index 74% rename from draft/application/cms/src/core/handler/any_cms_execution.e rename to draft/application/cms/src/handler/any_cms_execution.e index 86312476..18be1303 100644 --- a/draft/application/cms/src/core/handler/any_cms_execution.e +++ b/draft/application/cms/src/handler/any_cms_execution.e @@ -34,10 +34,20 @@ feature -- Execution -- Computed response message. local b: STRING_8 + s: STRING do create b.make_empty if attached text as t then - set_title (request.path_info) + s := request.path_info + if attached service.base_url as l_base_url then + if s.starts_with (l_base_url) then + s.remove_head (l_base_url.count) + if s.starts_with ("/") then + s.remove_head (1) + end + end + end + set_title (s) b.append (t) else set_title ("Page Not Found") diff --git a/draft/application/cms/src/core/handler/cms_file_system_handler.e b/draft/application/cms/src/handler/cms_file_system_handler.e similarity index 100% rename from draft/application/cms/src/core/handler/cms_file_system_handler.e rename to draft/application/cms/src/handler/cms_file_system_handler.e diff --git a/draft/application/cms/src/core/handler/cms_handler.e b/draft/application/cms/src/handler/cms_handler.e similarity index 100% rename from draft/application/cms/src/core/handler/cms_handler.e rename to draft/application/cms/src/handler/cms_handler.e diff --git a/draft/application/cms/src/core/handler/home_cms_execution.e b/draft/application/cms/src/handler/home_cms_execution.e similarity index 100% rename from draft/application/cms/src/core/handler/home_cms_execution.e rename to draft/application/cms/src/handler/home_cms_execution.e diff --git a/draft/application/cms/src/core/handler/not_found_cms_execution.e b/draft/application/cms/src/handler/not_found_cms_execution.e similarity index 100% rename from draft/application/cms/src/core/handler/not_found_cms_execution.e rename to draft/application/cms/src/handler/not_found_cms_execution.e diff --git a/draft/application/cms/src/core/handler/theme_cms_execution.e b/draft/application/cms/src/handler/theme_cms_execution.e similarity index 100% rename from draft/application/cms/src/core/handler/theme_cms_execution.e rename to draft/application/cms/src/handler/theme_cms_execution.e diff --git a/draft/application/cms/src/core/hooks/cms_hook.e b/draft/application/cms/src/hooks/cms_hook.e similarity index 100% rename from draft/application/cms/src/core/hooks/cms_hook.e rename to draft/application/cms/src/hooks/cms_hook.e diff --git a/draft/application/cms/src/hooks/cms_hook_auto_register.e b/draft/application/cms/src/hooks/cms_hook_auto_register.e new file mode 100644 index 00000000..0bb95c75 --- /dev/null +++ b/draft/application/cms/src/hooks/cms_hook_auto_register.e @@ -0,0 +1,29 @@ +note + description: "[ + Summary description for {CMS_HOOK_AUTO_REGISTER}. + When inheriting from this class, the declared hooks are automatically + registered, otherwise, each descendant has to add it to the cms service + itself. + ]" + date: "$Date$" + revision: "$Revision$" + +deferred class + CMS_HOOK_AUTO_REGISTER + +inherit + CMS_HOOK + +feature -- Hook + + hook_auto_register (a_service: CMS_SERVICE) + do + if attached {CMS_HOOK_MENU_ALTER} Current as h_menu_alter then + a_service.add_menu_alter_hook (h_menu_alter) + end + if attached {CMS_HOOK_BLOCK} Current as h_block then + a_service.add_block_hook (h_block) + end + end + +end diff --git a/draft/application/cms/src/core/hooks/cms_hook_block.e b/draft/application/cms/src/hooks/cms_hook_block.e similarity index 100% rename from draft/application/cms/src/core/hooks/cms_hook_block.e rename to draft/application/cms/src/hooks/cms_hook_block.e diff --git a/draft/application/cms/src/core/hooks/cms_hook_form_alter.e b/draft/application/cms/src/hooks/cms_hook_form_alter.e similarity index 100% rename from draft/application/cms/src/core/hooks/cms_hook_form_alter.e rename to draft/application/cms/src/hooks/cms_hook_form_alter.e diff --git a/draft/application/cms/src/core/hooks/cms_hook_menu_alter.e b/draft/application/cms/src/hooks/cms_hook_menu_alter.e similarity index 100% rename from draft/application/cms/src/core/hooks/cms_hook_menu_alter.e rename to draft/application/cms/src/hooks/cms_hook_menu_alter.e diff --git a/draft/application/cms/src/core/kernel/api/cms_api_options.e b/draft/application/cms/src/kernel/api/cms_api_options.e similarity index 100% rename from draft/application/cms/src/core/kernel/api/cms_api_options.e rename to draft/application/cms/src/kernel/api/cms_api_options.e diff --git a/draft/application/cms/src/core/kernel/api/cms_common_api.e b/draft/application/cms/src/kernel/api/cms_common_api.e similarity index 83% rename from draft/application/cms/src/core/kernel/api/cms_common_api.e rename to draft/application/cms/src/kernel/api/cms_common_api.e index 03855975..cb374fb2 100644 --- a/draft/application/cms/src/core/kernel/api/cms_common_api.e +++ b/draft/application/cms/src/kernel/api/cms_common_api.e @@ -55,24 +55,45 @@ feature -- Access end end - link (a_text: READABLE_STRING_GENERAL; a_path: STRING; opts: detachable CMS_API_OPTIONS): STRING + link (a_text: detachable READABLE_STRING_GENERAL; a_path: STRING; opts: detachable CMS_API_OPTIONS): STRING local l_html: BOOLEAN + t: READABLE_STRING_GENERAL do l_html := True if opts /= Void then l_html := opts.boolean_item ("html", l_html) end Result := "" - if l_html then - if attached {READABLE_STRING_8} a_text as t then - Result.append (t) - else - Result.append (a_text.to_string_8) - end + if a_text = Void then + t := a_path else - Result.append (checked_plain (a_text)) + t := a_text end + if l_html then + Result.append (html_encoded (t)) + else + Result.append (checked_plain (t)) + end + Result.append ("") + end + + link_with_raw_text (a_text: detachable READABLE_STRING_8; a_path: STRING; opts: detachable CMS_API_OPTIONS): STRING + local + l_html: BOOLEAN + t: READABLE_STRING_8 + do + l_html := True + if opts /= Void then + l_html := opts.boolean_item ("html", l_html) + end + Result := "" + if a_text = Void then + t := a_path + else + t := a_text + end + Result.append (t) Result.append ("") end @@ -83,7 +104,7 @@ feature -- Access node_link (n: CMS_NODE): like link do - Result := link (html_encoded (n.title), "/node/" + n.id.out, Void) + Result := link (n.title, "/node/" + n.id.out, Void) end user_url (u: CMS_USER): like url diff --git a/draft/application/cms/src/core/kernel/api/cms_url_api_options.e b/draft/application/cms/src/kernel/api/cms_url_api_options.e similarity index 100% rename from draft/application/cms/src/core/kernel/api/cms_url_api_options.e rename to draft/application/cms/src/kernel/api/cms_url_api_options.e diff --git a/draft/application/cms/src/core/kernel/auth/cms_auth_engine.e b/draft/application/cms/src/kernel/auth/cms_auth_engine.e similarity index 100% rename from draft/application/cms/src/core/kernel/auth/cms_auth_engine.e rename to draft/application/cms/src/kernel/auth/cms_auth_engine.e diff --git a/draft/application/cms/src/core/kernel/auth/cms_storage_auth_engine.e b/draft/application/cms/src/kernel/auth/cms_storage_auth_engine.e similarity index 69% rename from draft/application/cms/src/core/kernel/auth/cms_storage_auth_engine.e rename to draft/application/cms/src/kernel/auth/cms_storage_auth_engine.e index 1dc7b0ba..f213f56a 100644 --- a/draft/application/cms/src/core/kernel/auth/cms_storage_auth_engine.e +++ b/draft/application/cms/src/kernel/auth/cms_storage_auth_engine.e @@ -26,9 +26,7 @@ feature -- Status valid_credential (u,p: READABLE_STRING_32): BOOLEAN do - if attached storage.user_by_name (u) as l_user then - Result := attached l_user.encoded_password as l_pass and then l_pass.same_string (storage.encoded_password (p)) - end + Result := storage.is_valid_credential (u, p) end end diff --git a/draft/application/cms/src/kernel/cms_css.e b/draft/application/cms/src/kernel/cms_css.e new file mode 100644 index 00000000..f6f89777 --- /dev/null +++ b/draft/application/cms/src/kernel/cms_css.e @@ -0,0 +1,65 @@ +note + description: "Summary description for {CMS_CSS}." + author: "" + date: "$Date$" + revision: "$Revision$" + +class + CMS_CSS + +create + make + +feature {NONE} -- Initialization + + make + do + create items.make (3) + end + +feature -- Access + + items: ARRAYED_LIST [TUPLE [selectors: ITERABLE [CMS_CSS_SELECTOR]; style: CMS_CSS_STYLE]] + +feature -- Conversion + + string: READABLE_STRING_8 + local + s: STRING_8 + do + create s.make (64) + append_to (s) + Result := s + end + + append_to (a_target: STRING_8) + local + s: STRING_8 + s_selectors: STRING_8 + do + create s.make (64) + create s_selectors.make (10) + across + items as c + loop + s_selectors.wipe_out + across + c.item.selectors as cs + loop + if not s_selectors.is_empty then + s_selectors.append_character (',') + end + s_selectors.append (cs.item) + end + if not s_selectors.is_empty then + a_target.append (s_selectors) + a_target.append_character (' ') + a_target.append_character ('{') + a_target.append (c.item.style) + a_target.append_character ('}') + a_target.append_character ('%N') + end + end + end + +end diff --git a/draft/application/cms/src/kernel/cms_css_selector.e b/draft/application/cms/src/kernel/cms_css_selector.e new file mode 100644 index 00000000..14bc1dcf --- /dev/null +++ b/draft/application/cms/src/kernel/cms_css_selector.e @@ -0,0 +1,24 @@ +note + description: "Summary description for {CMS_CSS_SELECTOR}." + author: "" + date: "$Date$" + revision: "$Revision$" + +class + CMS_CSS_SELECTOR + +create + make_from_string + +feature {NONE} -- Initialization + + make_from_string (s: READABLE_STRING_8) + do + string := s + end + +feature -- Conversion + + string: READABLE_STRING_8 + +end diff --git a/draft/application/cms/src/kernel/cms_css_style.e b/draft/application/cms/src/kernel/cms_css_style.e new file mode 100644 index 00000000..40c0548f --- /dev/null +++ b/draft/application/cms/src/kernel/cms_css_style.e @@ -0,0 +1,393 @@ +note + description: "Summary description for {CMS_CSS_STYLE}." + date: "$Date$" + revision: "$Revision$" + EIS: "name=CSS reference", "protocol=URI", "src=http://www.w3schools.com/cssref/" + +class + CMS_CSS_STYLE + +create + make, + make_from_string + +feature {NONE} -- Initialization + + make + do + create {ARRAYED_LIST [READABLE_STRING_8]} items.make (3) + end + + make_from_string (s: READABLE_STRING_8) + do + items := s.split (';') + end + + items: LIST [READABLE_STRING_8] + +feature -- Change + + put_key_value (k,v: READABLE_STRING_8) + do + items.force (k + ": " + v) + end + +feature -- Property: colors + + put_color (v: READABLE_STRING_8) + do + put_key_value ("color", v) + end + + put_background (v: READABLE_STRING_8) + --| ex: #00ff00 url('smiley.gif') no-repeat fixed center; + do + put_key_value ("background", v) + end + + put_background_color (v: READABLE_STRING_8) + do + put_key_value ("background-color", v) + end + +feature -- Property: fonts + + put_font (v: READABLE_STRING_8) + do + put_key_value ("font", v) + end + + put_font_family (v: READABLE_STRING_8) + do + put_key_value ("font-family", v) + end + + put_font_size (v: READABLE_STRING_8) + do + put_key_value ("font-size", v) + end + + put_font_style (v: READABLE_STRING_8) + do + put_key_value ("font-style", v) + end + + put_font_weight (v: READABLE_STRING_8) + do + put_key_value ("font-weight", v) + end + + put_font_bold + do + put_font_weight ("bold") + end + + put_font_italic + do + put_font_style ("italic") + end + + put_text_decoration (v: READABLE_STRING_8) + do + put_key_value ("text-decoration", v) + end + + put_text_decoration_none + do + put_text_decoration ("none") + end + + put_text_decoration_underline + do + put_text_decoration ("underline") + end + + put_text_decoration_strike + do + put_text_decoration ("strike") + end + + put_text_align (v: READABLE_STRING_8) + do + put_key_value ("text-align", v) + end + + put_white_space (v: READABLE_STRING_8) + --| normal Sequences of whitespace will collapse into a single whitespace. Text will wrap when necessary. This is default + --| nowrap Sequences of whitespace will collapse into a single whitespace. Text will never wrap to the next line. The text continues on the same line until a
tag is encountered + --| pre Whitespace is preserved by the browser. Text will only wrap on line breaks Acts like the
 tag in HTML
+			--| pre-line 	Sequences of whitespace will collapse into a single whitespace. Text will wrap when necessary, and on line breaks
+			--| pre-wrap 	Whitespace is preserved by the browser. Text will wrap when necessary, and on line breaks
+			--| inherit 	Specifies that the value of the white-space property should be inherited from the parent element			
+		do
+			put_key_value ("white-space", v)
+		end
+
+	put_white_space_nowrap
+		do
+			put_white_space ("nowrap")
+		end
+
+	put_white_space_pre
+		do
+			put_white_space ("pre")
+		end
+
+
+feature -- Property: margin		
+
+	put_margin (a_top, a_right, a_bottom, a_left: detachable READABLE_STRING_8)
+		local
+			v: STRING
+		do
+			create v.make (10)
+			if a_left /= Void then
+				v.append (a_left)
+			end
+			if not v.is_empty then
+				v.prepend_character (' ')
+			end
+			if a_bottom /= Void then
+				v.prepend (a_bottom)
+			else
+				v.prepend_character ('0')
+			end
+			if not v.is_empty then
+				v.prepend_character (' ')
+			end
+			if a_right /= Void then
+				v.prepend (a_right)
+			else
+				v.prepend_character ('0')
+			end
+			if not v.is_empty then
+				v.prepend_character (' ')
+			end
+			if a_top /= Void then
+				v.prepend (a_top)
+			else
+				v.prepend_character ('0')
+			end
+			put_key_value ("margin", v)
+		end
+
+	put_margin_top (v: READABLE_STRING_8)
+		do
+			put_key_value ("margin-top", v)
+		end
+
+	put_margin_right (v: READABLE_STRING_8)
+		do
+			put_key_value ("margin-right", v)
+		end
+
+	put_margin_bottom (v: READABLE_STRING_8)
+		do
+			put_key_value ("margin-bottom", v)
+		end
+
+	put_margin_left (v: READABLE_STRING_8)
+		do
+			put_key_value ("margin-left", v)
+		end
+
+feature -- Property: padding		
+
+	put_padding (a_top, a_right, a_bottom, a_left: detachable READABLE_STRING_8)
+		local
+			v: STRING
+		do
+			create v.make (10)
+			if a_left /= Void then
+				v.append (a_left)
+			end
+			if not v.is_empty then
+				v.prepend_character (' ')
+			end
+			if a_bottom /= Void then
+				v.prepend (a_bottom)
+			else
+				v.prepend_character ('0')
+			end
+			if not v.is_empty then
+				v.prepend_character (' ')
+			end
+			if a_right /= Void then
+				v.prepend (a_right)
+			else
+				v.prepend_character ('0')
+			end
+			if not v.is_empty then
+				v.prepend_character (' ')
+			end
+			if a_top /= Void then
+				v.prepend (a_top)
+			else
+				v.prepend_character ('0')
+			end
+			put_key_value ("padding", v)
+		end
+
+	put_padding_top (v: READABLE_STRING_8)
+		do
+			put_key_value ("padding-top", v)
+		end
+
+	put_padding_right (v: READABLE_STRING_8)
+		do
+			put_key_value ("padding-right", v)
+		end
+
+	put_padding_bottom (v: READABLE_STRING_8)
+		do
+			put_key_value ("padding-bottom", v)
+		end
+
+	put_padding_left (v: READABLE_STRING_8)
+		do
+			put_key_value ("padding-left", v)
+		end
+
+feature -- Properties: layout		
+
+	put_width (v: READABLE_STRING_8)
+		do
+			put_key_value ("width", v)
+		end
+
+	put_height (v: READABLE_STRING_8)
+		do
+			put_key_value ("height", v)
+		end
+
+	put_z_index (v: READABLE_STRING_8)
+		do
+			put_key_value ("z-index", v)
+		end
+
+feature -- Property: border
+
+	put_border (a_border: detachable READABLE_STRING_8; a_style: READABLE_STRING_8; a_size: READABLE_STRING_8; a_color: READABLE_STRING_8)
+			-- "solid 1px color"
+		require
+			a_border /= Void implies (a_border.same_string ("top") or a_border.same_string ("right") or a_border.same_string ("bottom") or a_border.same_string ("left"))
+		local
+			k: STRING
+		do
+			k := "border"
+			if a_border /= Void then
+				k.append_character ('-')
+				k.append (a_border)
+			end
+			put_key_value (k, a_style + " " + a_size + " " + a_color)
+		end
+
+	put_border_style (a_style: READABLE_STRING_8)
+			-- "solid 1px color"
+		do
+			put_key_value ("border-style", a_style)
+		end
+
+	put_border_style_none (a_style: READABLE_STRING_8)
+			-- "solid 1px color"
+		do
+			put_border_style ("none")
+		end
+
+feature -- Property: display		
+
+	put_display (v: READABLE_STRING_8)
+		do
+			put_key_value ("display", v)
+		end
+
+	put_display_none
+		do
+			put_display ("none")
+		end
+
+	put_display_block
+		do
+			put_display ("block")
+		end
+
+	put_display_inline
+		do
+			put_display ("inline")
+		end
+
+	put_display_inline_block
+		do
+			put_display ("inline-block")
+		end
+
+	put_list_style (v: READABLE_STRING_8)
+			--| ex: list-style:square url("sqpurple.gif");
+		do
+			put_key_value ("list-style", v)
+		end
+
+	put_list_style_type (v: READABLE_STRING_8)
+			--circle 	The marker is a circle
+			--decimal 	The marker is a number. This is default for 
    + --decimal-leading-zero The marker is a number with leading zeros (01, 02, 03, etc.) + --disc The marker is a filled circle. This is default for
      + --lower-alpha The marker is lower-alpha (a, b, c, d, e, etc.) + --lower-greek The marker is lower-greek + --lower-latin The marker is lower-latin (a, b, c, d, e, etc.) + --lower-roman The marker is lower-roman (i, ii, iii, iv, v, etc.) + --none No marker is shown + --square The marker is a square + --upper-alpha The marker is upper-alpha (A, B, C, D, E, etc.) + --upper-latin The marker is upper-latin (A, B, C, D, E, etc.) + --upper-roman The marker is upper-roman (I, II, III, IV, V, etc.) + do + put_key_value ("list-style-type", v) + end + +feature -- Property: float ... + + put_float (v: READABLE_STRING_8) + do + put_key_value ("float", v) + end + + put_clear (v: READABLE_STRING_8) + do + put_key_value ("clear", v) + end + +feature -- Conversion + + append_inline_to (s: STRING_8) + do + append_to (s, False) + end + + append_text_to (s: STRING_8) + do + append_to (s, True) + end + + append_to (s: STRING_8; a_multiline: BOOLEAN) + local + n: INTEGER + do + n := 0 + across + items as c + loop + if n > 0 then + if a_multiline then + s.append_character ('%N') + else + s.append_character (' ') + end + end + s.append (c.item) + s.append_character (';') + n := n + 1 + end + end + +end diff --git a/draft/application/cms/src/core/kernel/cms_html_page.e b/draft/application/cms/src/kernel/cms_html_page.e similarity index 100% rename from draft/application/cms/src/core/kernel/cms_html_page.e rename to draft/application/cms/src/kernel/cms_html_page.e diff --git a/draft/application/cms/src/core/kernel/cms_session_controler.e b/draft/application/cms/src/kernel/cms_session_controler.e similarity index 100% rename from draft/application/cms/src/core/kernel/cms_session_controler.e rename to draft/application/cms/src/kernel/cms_session_controler.e diff --git a/draft/application/cms/src/core/kernel/cms_user.e b/draft/application/cms/src/kernel/cms_user.e similarity index 97% rename from draft/application/cms/src/core/kernel/cms_user.e rename to draft/application/cms/src/kernel/cms_user.e index 182447f8..135d3f04 100644 --- a/draft/application/cms/src/core/kernel/cms_user.e +++ b/draft/application/cms/src/kernel/cms_user.e @@ -24,7 +24,7 @@ feature {NONE} -- Initialization creation_date := dt name := n ensure - valid_password: password = Void and encoded_password /= Void + valid_password: password = Void end make_new (n: like name) @@ -46,8 +46,6 @@ feature -- Access password: detachable READABLE_STRING_32 - encoded_password: detachable READABLE_STRING_8 - email: detachable READABLE_STRING_8 profile: detachable CMS_USER_PROFILE @@ -99,11 +97,6 @@ feature -- Element change password := p end - set_encoded_password (p: like encoded_password) - do - encoded_password := p - end - set_email (m: like email) do email := m @@ -155,4 +148,13 @@ feature -- Element change set_last_login_date (create {DATE_TIME}.make_now_utc) end +feature {CMS_STORAGE} -- Security + + encoded_password: detachable READABLE_STRING_8 + + set_encoded_password (p: like encoded_password) + do + encoded_password := p + end + end diff --git a/draft/application/cms/src/core/kernel/cms_user_profile.e b/draft/application/cms/src/kernel/cms_user_profile.e similarity index 100% rename from draft/application/cms/src/core/kernel/cms_user_profile.e rename to draft/application/cms/src/kernel/cms_user_profile.e diff --git a/draft/application/cms/src/core/kernel/content/cms_block.e b/draft/application/cms/src/kernel/content/cms_block.e similarity index 100% rename from draft/application/cms/src/core/kernel/content/cms_block.e rename to draft/application/cms/src/kernel/content/cms_block.e diff --git a/draft/application/cms/src/core/kernel/content/cms_content_block.e b/draft/application/cms/src/kernel/content/cms_content_block.e similarity index 100% rename from draft/application/cms/src/core/kernel/content/cms_content_block.e rename to draft/application/cms/src/kernel/content/cms_content_block.e diff --git a/draft/application/cms/src/core/kernel/content/cms_content_type.e b/draft/application/cms/src/kernel/content/cms_content_type.e similarity index 100% rename from draft/application/cms/src/core/kernel/content/cms_content_type.e rename to draft/application/cms/src/kernel/content/cms_content_type.e diff --git a/draft/application/cms/src/core/kernel/content/cms_menu_block.e b/draft/application/cms/src/kernel/content/cms_menu_block.e similarity index 100% rename from draft/application/cms/src/core/kernel/content/cms_menu_block.e rename to draft/application/cms/src/kernel/content/cms_menu_block.e diff --git a/draft/application/cms/src/core/kernel/content/cms_node.e b/draft/application/cms/src/kernel/content/cms_node.e similarity index 100% rename from draft/application/cms/src/core/kernel/content/cms_node.e rename to draft/application/cms/src/kernel/content/cms_node.e diff --git a/draft/application/cms/src/core/kernel/content/format/cms_filtered_html_format.e b/draft/application/cms/src/kernel/content/format/cms_filtered_html_format.e similarity index 100% rename from draft/application/cms/src/core/kernel/content/format/cms_filtered_html_format.e rename to draft/application/cms/src/kernel/content/format/cms_filtered_html_format.e diff --git a/draft/application/cms/src/core/kernel/content/format/cms_format.e b/draft/application/cms/src/kernel/content/format/cms_format.e similarity index 100% rename from draft/application/cms/src/core/kernel/content/format/cms_format.e rename to draft/application/cms/src/kernel/content/format/cms_format.e diff --git a/draft/application/cms/src/core/kernel/content/format/cms_formats.e b/draft/application/cms/src/kernel/content/format/cms_formats.e similarity index 100% rename from draft/application/cms/src/core/kernel/content/format/cms_formats.e rename to draft/application/cms/src/kernel/content/format/cms_formats.e diff --git a/draft/application/cms/src/core/kernel/content/format/cms_full_html_format.e b/draft/application/cms/src/kernel/content/format/cms_full_html_format.e similarity index 100% rename from draft/application/cms/src/core/kernel/content/format/cms_full_html_format.e rename to draft/application/cms/src/kernel/content/format/cms_full_html_format.e diff --git a/draft/application/cms/src/core/kernel/content/format/cms_plain_text_format.e b/draft/application/cms/src/kernel/content/format/cms_plain_text_format.e similarity index 100% rename from draft/application/cms/src/core/kernel/content/format/cms_plain_text_format.e rename to draft/application/cms/src/kernel/content/format/cms_plain_text_format.e diff --git a/draft/application/cms/src/core/kernel/content/format/filters/cms_filter.e b/draft/application/cms/src/kernel/content/format/filters/cms_filter.e similarity index 100% rename from draft/application/cms/src/core/kernel/content/format/filters/cms_filter.e rename to draft/application/cms/src/kernel/content/format/filters/cms_filter.e diff --git a/draft/application/cms/src/core/kernel/content/format/filters/cms_html_filter.e b/draft/application/cms/src/kernel/content/format/filters/cms_html_filter.e similarity index 100% rename from draft/application/cms/src/core/kernel/content/format/filters/cms_html_filter.e rename to draft/application/cms/src/kernel/content/format/filters/cms_html_filter.e diff --git a/draft/application/cms/src/core/kernel/content/format/filters/cms_html_to_text_filter.e b/draft/application/cms/src/kernel/content/format/filters/cms_html_to_text_filter.e similarity index 100% rename from draft/application/cms/src/core/kernel/content/format/filters/cms_html_to_text_filter.e rename to draft/application/cms/src/kernel/content/format/filters/cms_html_to_text_filter.e diff --git a/draft/application/cms/src/core/kernel/content/format/filters/cms_line_break_converter_filter.e b/draft/application/cms/src/kernel/content/format/filters/cms_line_break_converter_filter.e similarity index 100% rename from draft/application/cms/src/core/kernel/content/format/filters/cms_line_break_converter_filter.e rename to draft/application/cms/src/kernel/content/format/filters/cms_line_break_converter_filter.e diff --git a/draft/application/cms/src/core/kernel/content/format/filters/cms_no_html_filter.e b/draft/application/cms/src/kernel/content/format/filters/cms_no_html_filter.e similarity index 100% rename from draft/application/cms/src/core/kernel/content/format/filters/cms_no_html_filter.e rename to draft/application/cms/src/kernel/content/format/filters/cms_no_html_filter.e diff --git a/draft/application/cms/src/core/kernel/content/format/filters/cms_url_filter.e b/draft/application/cms/src/kernel/content/format/filters/cms_url_filter.e similarity index 100% rename from draft/application/cms/src/core/kernel/content/format/filters/cms_url_filter.e rename to draft/application/cms/src/kernel/content/format/filters/cms_url_filter.e diff --git a/draft/application/cms/src/core/kernel/form/cms_form.e b/draft/application/cms/src/kernel/form/cms_form.e similarity index 94% rename from draft/application/cms/src/core/kernel/form/cms_form.e rename to draft/application/cms/src/kernel/form/cms_form.e index 4065d98e..a7870a72 100644 --- a/draft/application/cms/src/core/kernel/form/cms_form.e +++ b/draft/application/cms/src/kernel/form/cms_form.e @@ -22,6 +22,7 @@ feature {NONE} -- Initialization create html_classes.make (2) create items.make (10) + set_method_post end feature -- Access @@ -37,6 +38,10 @@ feature -- Access Result := items.count end + method: READABLE_STRING_8 + -- Form's method + --| GET or POST + feature -- Validation validation_action: detachable PROCEDURE [ANY, TUPLE [CMS_FORM_DATA]] @@ -48,6 +53,16 @@ feature -- Validation feature -- Element change + set_method_get + do + method := "GET" + end + + set_method_post + do + method := "POST" + end + set_validation_action (act: like validation_action) do validation_action := act @@ -134,7 +149,7 @@ feature -- Conversion local s: STRING do - Result := "
      element should be preselected when the page loads + + input_type: STRING = "checkbox" + + text: detachable READABLE_STRING_32 + +feature -- Status report + + is_same_value (v: READABLE_STRING_32): BOOLEAN + do + Result := attached value as l_value and then v.same_string (l_value) + end + +feature -- Change + + set_text (t: detachable READABLE_STRING_32) + do + text := t + end + + set_checked (b: like checked) + do + checked := b + end + +feature {NONE} -- Implementation + + child_to_html (a_theme: CMS_THEME): detachable READABLE_STRING_8 + -- Specific child element if any. + --| To redefine if needed + do + if attached text as t then + Result := a_theme.html_encoded (t) + elseif attached value as v then + Result := a_theme.html_encoded (v) + end + end + + specific_input_attributes_string: detachable STRING_8 + -- Specific input attributes if any. + -- To redefine if needed + do + if checked then + Result := "checked=%"checked%"" + end + end + +invariant + +end diff --git a/draft/application/cms/src/core/kernel/form/cms_form_data.e b/draft/application/cms/src/kernel/form/cms_form_data.e similarity index 100% rename from draft/application/cms/src/core/kernel/form/cms_form_data.e rename to draft/application/cms/src/kernel/form/cms_form_data.e diff --git a/draft/application/cms/src/kernel/form/cms_form_div.e b/draft/application/cms/src/kernel/form/cms_form_div.e new file mode 100644 index 00000000..fb71cde9 --- /dev/null +++ b/draft/application/cms/src/kernel/form/cms_form_div.e @@ -0,0 +1,65 @@ +note + description : "Objects that ..." + author : "$Author$" + date : "$Date$" + revision : "$Revision$" + +class + CMS_FORM_DIV + +inherit + CMS_FORM_ITEM + + ITERABLE [CMS_FORM_ITEM] + + WITH_CSS_ID + +create + make + +feature {NONE} -- Initialization + + make + -- Initialize `Current'. + do + create items.make (0) + end + +feature -- Access + + new_cursor: ITERATION_CURSOR [CMS_FORM_ITEM] + -- Fresh cursor associated with current structure + do + Result := items.new_cursor + end + +feature -- Change + + extend (i: CMS_FORM_ITEM) + do + items.force (i) + end + +feature -- Conversion + + to_html (a_theme: CMS_THEME): STRING_8 + do + Result := "%N") + across + items as c + loop + Result.append (c.item.to_html (a_theme)) + end + Result.append ("%N%N") + end + +feature {NONE} -- Implementation + + items: ARRAYED_LIST [CMS_FORM_ITEM] + +end diff --git a/draft/application/cms/src/core/kernel/form/cms_form_field.e b/draft/application/cms/src/kernel/form/cms_form_field.e similarity index 68% rename from draft/application/cms/src/core/kernel/form/cms_form_field.e rename to draft/application/cms/src/kernel/form/cms_form_field.e index 17ebf9da..d2b43d39 100644 --- a/draft/application/cms/src/core/kernel/form/cms_form_field.e +++ b/draft/application/cms/src/kernel/form/cms_form_field.e @@ -10,6 +10,8 @@ deferred class inherit CMS_FORM_ITEM + WITH_CSS_ID + DEBUG_OUTPUT feature -- Access @@ -26,6 +28,7 @@ feature -- Access is_readonly: BOOLEAN + is_description_collapsible: BOOLEAN feature -- Status report @@ -91,28 +94,34 @@ feature -- Element change deferred end + set_description_collapsible (b: BOOLEAN) + -- Set `is_description_collapsible' to `b' + do + is_description_collapsible := b + end + feature -- Conversion to_html (a_theme: CMS_THEME): STRING_8 local - cl: STRING + l_class_items: detachable ARRAYED_LIST [READABLE_STRING_8] do - create cl.make_empty + create l_class_items.make (2) if is_required then - if not cl.is_empty then - cl.append_character (' ') - end - cl.append ("required") + l_class_items.extend ("required") end if is_invalid then - if not cl.is_empty then - cl.append_character (' ') - end - cl.append ("error") + l_class_items.extend ("error") end - create Result.make_from_string ("
      ") + if l_class_items.is_empty then + l_class_items := Void + end + + create Result.make_from_string ("') if attached label as lab then - Result.append ("") + Result.append ("") if is_required then Result.append (" (required)") end @@ -120,7 +129,11 @@ feature -- Conversion end Result.append (item_to_html (a_theme)) if attached description as desc then - Result.append ("
      " + desc + "
      ") + if is_description_collapsible then + Result.append ("
      Description ...
      " + desc + "
      ") + else + Result.append ("
      " + desc + "
      ") + end end Result.append ("
      ") end diff --git a/draft/application/cms/src/core/kernel/form/cms_form_field_set.e b/draft/application/cms/src/kernel/form/cms_form_field_set.e similarity index 86% rename from draft/application/cms/src/core/kernel/form/cms_form_field_set.e rename to draft/application/cms/src/kernel/form/cms_form_field_set.e index 9b3588b7..353d996a 100644 --- a/draft/application/cms/src/core/kernel/form/cms_form_field_set.e +++ b/draft/application/cms/src/kernel/form/cms_form_field_set.e @@ -12,6 +12,8 @@ inherit ITERABLE [CMS_FORM_ITEM] + WITH_CSS_ID + create make @@ -51,7 +53,12 @@ feature -- Conversion to_html (a_theme: CMS_THEME): STRING_8 do - Result := "
      %N" + Result := "%N") if attached legend as leg then Result.append ("" + leg + "%N") end diff --git a/draft/application/cms/src/core/kernel/form/cms_form_file_input.e b/draft/application/cms/src/kernel/form/cms_form_file_input.e similarity index 100% rename from draft/application/cms/src/core/kernel/form/cms_form_file_input.e rename to draft/application/cms/src/kernel/form/cms_form_file_input.e diff --git a/draft/application/cms/src/core/kernel/form/cms_form_hidden_input.e b/draft/application/cms/src/kernel/form/cms_form_hidden_input.e similarity index 95% rename from draft/application/cms/src/core/kernel/form/cms_form_hidden_input.e rename to draft/application/cms/src/kernel/form/cms_form_hidden_input.e index 20272d4f..8422a9fe 100644 --- a/draft/application/cms/src/core/kernel/form/cms_form_hidden_input.e +++ b/draft/application/cms/src/kernel/form/cms_form_hidden_input.e @@ -15,7 +15,8 @@ inherit end create - make + make, + make_with_text feature -- Access diff --git a/draft/application/cms/src/core/kernel/form/cms_form_image_input.e b/draft/application/cms/src/kernel/form/cms_form_image_input.e similarity index 100% rename from draft/application/cms/src/core/kernel/form/cms_form_image_input.e rename to draft/application/cms/src/kernel/form/cms_form_image_input.e diff --git a/draft/application/cms/src/core/kernel/form/cms_form_input.e b/draft/application/cms/src/kernel/form/cms_form_input.e similarity index 78% rename from draft/application/cms/src/core/kernel/form/cms_form_input.e rename to draft/application/cms/src/kernel/form/cms_form_input.e index fae1353d..f1dfca1c 100644 --- a/draft/application/cms/src/core/kernel/form/cms_form_input.e +++ b/draft/application/cms/src/kernel/form/cms_form_input.e @@ -17,6 +17,12 @@ feature {NONE} -- Initialization name := a_name end + make_with_text (a_name: like name; a_text: READABLE_STRING_32) + do + make (a_name) + set_text_value (a_text) + end + feature -- Access default_value: detachable READABLE_STRING_32 @@ -75,6 +81,10 @@ feature -- Conversion item_to_html (a_theme: CMS_THEME): STRING_8 do Result := "") + if attached child_to_html (a_theme) as s then + Result.append (">") + Result.append (s) + Result.append ("") + else + Result.append ("/>") + end end feature {NONE} -- Implementation + child_to_html (a_theme: CMS_THEME): detachable READABLE_STRING_8 + -- Specific child element if any. + --| To redefine if needed + do + end + specific_input_attributes_string: detachable STRING_8 -- Specific input attributes if any. --| To redefine if needed diff --git a/draft/application/cms/src/core/kernel/form/cms_form_item.e b/draft/application/cms/src/kernel/form/cms_form_item.e similarity index 84% rename from draft/application/cms/src/core/kernel/form/cms_form_item.e rename to draft/application/cms/src/kernel/form/cms_form_item.e index 0dafeb60..2718568d 100644 --- a/draft/application/cms/src/core/kernel/form/cms_form_item.e +++ b/draft/application/cms/src/kernel/form/cms_form_item.e @@ -7,6 +7,11 @@ note deferred class CMS_FORM_ITEM +inherit + WITH_CSS_CLASS + + WITH_CSS_STYLE + feature -- Conversion to_html (a_theme: CMS_THEME): STRING_8 diff --git a/draft/application/cms/src/core/kernel/form/cms_form_password_input.e b/draft/application/cms/src/kernel/form/cms_form_password_input.e similarity index 92% rename from draft/application/cms/src/core/kernel/form/cms_form_password_input.e rename to draft/application/cms/src/kernel/form/cms_form_password_input.e index 2949ca44..118b4788 100644 --- a/draft/application/cms/src/core/kernel/form/cms_form_password_input.e +++ b/draft/application/cms/src/kernel/form/cms_form_password_input.e @@ -14,7 +14,8 @@ inherit end create - make + make, + make_with_text feature -- Access diff --git a/draft/application/cms/src/core/kernel/form/cms_form_radio_input.e b/draft/application/cms/src/kernel/form/cms_form_radio_input.e similarity index 70% rename from draft/application/cms/src/core/kernel/form/cms_form_radio_input.e rename to draft/application/cms/src/kernel/form/cms_form_radio_input.e index f5c10a52..3d928d82 100644 --- a/draft/application/cms/src/core/kernel/form/cms_form_radio_input.e +++ b/draft/application/cms/src/kernel/form/cms_form_radio_input.e @@ -9,10 +9,18 @@ class inherit CMS_FORM_INPUT + rename + default_value as value redefine specific_input_attributes_string end + CMS_FORM_SELECTABLE_ITEM + rename + is_selected as checked, + set_is_selected as set_checked + end + create make @@ -23,6 +31,13 @@ feature -- Access input_type: STRING = "radio" +feature -- Status report + + is_same_value (v: READABLE_STRING_32): BOOLEAN + do + Result := attached value as l_value and then v.same_string (l_value) + end + feature -- Change set_checked (b: like checked) diff --git a/draft/application/cms/src/core/kernel/form/cms_form_raw_text.e b/draft/application/cms/src/kernel/form/cms_form_raw_text.e similarity index 100% rename from draft/application/cms/src/core/kernel/form/cms_form_raw_text.e rename to draft/application/cms/src/kernel/form/cms_form_raw_text.e diff --git a/draft/application/cms/src/core/kernel/form/cms_form_reset_input.e b/draft/application/cms/src/kernel/form/cms_form_reset_input.e similarity index 100% rename from draft/application/cms/src/core/kernel/form/cms_form_reset_input.e rename to draft/application/cms/src/kernel/form/cms_form_reset_input.e diff --git a/draft/application/cms/src/core/kernel/form/cms_form_select.e b/draft/application/cms/src/kernel/form/cms_form_select.e similarity index 80% rename from draft/application/cms/src/core/kernel/form/cms_form_select.e rename to draft/application/cms/src/kernel/form/cms_form_select.e index e8b5375b..0e65d184 100644 --- a/draft/application/cms/src/core/kernel/form/cms_form_select.e +++ b/draft/application/cms/src/kernel/form/cms_form_select.e @@ -10,6 +10,8 @@ class inherit CMS_FORM_FIELD + CMS_FORM_UTILITY + create make @@ -27,17 +29,18 @@ feature -- Access feature -- Element change - set_text_value (v: detachable like {CMS_FORM_SELECT_OPTION}.value) + set_text_by_value (a_text: detachable READABLE_STRING_GENERAL) local opt: CMS_FORM_SELECT_OPTION l_found: BOOLEAN + v: READABLE_STRING_8 do - if v /= Void then + if a_text /= Void then + v := html_encoded_string (a_text.to_string_32) across options as o loop - -- FIXME: unicode ... - if o.item.value.same_string (v) then + if o.item.is_same_value (v) then l_found := True o.item.set_is_selected (True) else @@ -61,9 +64,9 @@ feature -- Element change set_value (v: detachable WSF_VALUE) do if attached {WSF_STRING} v as s then - set_text_value (s.value) + set_text_by_value (s.value) else - set_text_value (Void) + set_text_by_value (Void) end end @@ -79,7 +82,13 @@ feature -- Conversion l_is_already_selected: BOOLEAN h: detachable STRING_8 do - Result := "