From af137629e051109b65c615d9af357284314bfd21 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Thu, 18 Feb 2016 16:26:00 +0100 Subject: [PATCH] Restored previous template_block* function signatures and made them obsolete. Added smarty_template_block* functions as new recommended functions. --- modules/auth/cms_authentication_module.e | 26 +++++++++---------- modules/basic_auth/cms_basic_auth_module.e | 4 +-- modules/contact/src/cms_contact_module.e | 10 +++---- .../src/google_custom_search_module.e | 2 +- modules/oauth20/cms_oauth_20_module.e | 4 +-- modules/openid/cms_openid_module.e | 2 +- .../session_auth/cms_session_auth_module.e | 8 +++--- src/hooks/cms_hook_block_helper.e | 25 +++++++++++++++--- 8 files changed, 50 insertions(+), 31 deletions(-) diff --git a/modules/auth/cms_authentication_module.e b/modules/auth/cms_authentication_module.e index 654b9f1..da6af53 100644 --- a/modules/auth/cms_authentication_module.e +++ b/modules/auth/cms_authentication_module.e @@ -210,7 +210,7 @@ feature -- Handler create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api) create b.make_empty l_user := r.user - if attached template_block (Current, "account_info", api) as l_tpl_block then + if attached smarty_template_block (Current, "account_info", api) as l_tpl_block then l_tpl_block.set_weight (-10) r.add_block (l_tpl_block, "content") else @@ -248,7 +248,7 @@ feature -- Handler create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api) create b.make_empty l_user := r.user - if attached template_block (Current, "account_edit", api) as l_tpl_block then + if attached smarty_template_block (Current, "account_edit", api) as l_tpl_block then l_tpl_block.set_weight (-10) r.add_block (l_tpl_block, "content") else @@ -935,7 +935,7 @@ feature {NONE} -- Block views or else a_response.values.has ("error_email") ) then - if attached template_block (Current, a_block_id, a_response.api) as l_tpl_block then + if attached smarty_template_block (Current, a_block_id, a_response.api) as l_tpl_block then -- l_tpl_block.set_value (a_response.values.item ("error_name"), "error_name") -- l_tpl_block.set_value (a_response.values.item ("error_email"), "error_email") -- l_tpl_block.set_value (a_response.values.item ("email"), "email") @@ -951,7 +951,7 @@ feature {NONE} -- Block views end end elseif a_response.request.is_post_request_method then - if attached template_block (Current, "post_register", a_response.api) as l_tpl_block then + if attached smarty_template_block (Current, "post_register", a_response.api) as l_tpl_block then a_response.add_block (l_tpl_block, "content") else debug ("cms") @@ -965,7 +965,7 @@ feature {NONE} -- Block views get_block_view_reactivate (a_block_id: READABLE_STRING_8; a_response: CMS_RESPONSE) do if a_response.request.is_get_request_method then - if attached template_block (Current, a_block_id, a_response.api) as l_tpl_block then + if attached smarty_template_block (Current, a_block_id, a_response.api) as l_tpl_block then a_response.add_block (l_tpl_block, "content") else debug ("cms") @@ -974,7 +974,7 @@ feature {NONE} -- Block views end elseif a_response.request.is_post_request_method then if a_response.values.has ("error_email") or else a_response.values.has ("is_active") then - if attached template_block (Current, a_block_id, a_response.api) as l_tpl_block then + if attached smarty_template_block (Current, a_block_id, a_response.api) as l_tpl_block then -- l_tpl_block.set_value (a_response.values.item ("error_email"), "error_email") -- l_tpl_block.set_value (a_response.values.item ("email"), "email") -- l_tpl_block.set_value (a_response.values.item ("is_active"), "is_active") @@ -985,7 +985,7 @@ feature {NONE} -- Block views end end else - if attached template_block (Current, "post_reactivate", a_response.api) as l_tpl_block then + if attached smarty_template_block (Current, "post_reactivate", a_response.api) as l_tpl_block then a_response.add_block (l_tpl_block, "content") else debug ("cms") @@ -999,7 +999,7 @@ feature {NONE} -- Block views get_block_view_new_password (a_block_id: READABLE_STRING_8; a_response: CMS_RESPONSE) do if a_response.request.is_get_request_method then - if attached template_block (Current, a_block_id, a_response.api) as l_tpl_block then + if attached smarty_template_block (Current, a_block_id, a_response.api) as l_tpl_block then a_response.add_block (l_tpl_block, "content") else debug ("cms") @@ -1008,7 +1008,7 @@ feature {NONE} -- Block views end elseif a_response.request.is_post_request_method then if a_response.values.has ("error_email") or else a_response.values.has ("error_username") then - if attached template_block (Current, a_block_id, a_response.api) as l_tpl_block then + if attached smarty_template_block (Current, a_block_id, a_response.api) as l_tpl_block then -- l_tpl_block.set_value (a_response.values.item ("error_email"), "error_email") -- l_tpl_block.set_value (a_response.values.item ("email"), "email") -- l_tpl_block.set_value (a_response.values.item ("error_username"), "error_username") @@ -1020,7 +1020,7 @@ feature {NONE} -- Block views end end else - if attached template_block (Current, "post_password", a_response.api) as l_tpl_block then + if attached smarty_template_block (Current, "post_password", a_response.api) as l_tpl_block then a_response.add_block (l_tpl_block, "content") else debug ("cms") @@ -1034,7 +1034,7 @@ feature {NONE} -- Block views get_block_view_reset_password (a_block_id: READABLE_STRING_8; a_response: CMS_RESPONSE) do if a_response.request.is_get_request_method then - if attached template_block (Current, a_block_id, a_response.api) as l_tpl_block then + if attached smarty_template_block (Current, a_block_id, a_response.api) as l_tpl_block then -- l_tpl_block.set_value (a_response.values.item ("token"), "token") -- l_tpl_block.set_value (a_response.values.item ("error_token"), "error_token") a_response.add_block (l_tpl_block, "content") @@ -1045,7 +1045,7 @@ feature {NONE} -- Block views end elseif a_response.request.is_post_request_method then if a_response.values.has ("error_token") or else a_response.values.has ("error_password") then - if attached template_block (Current, a_block_id, a_response.api) as l_tpl_block then + if attached smarty_template_block (Current, a_block_id, a_response.api) as l_tpl_block then -- l_tpl_block.set_value (a_response.values.item ("error_token"), "error_token") -- l_tpl_block.set_value (a_response.values.item ("error_password"), "error_password") -- l_tpl_block.set_value (a_response.values.item ("token"), "token") @@ -1056,7 +1056,7 @@ feature {NONE} -- Block views end end else - if attached template_block (Current, "post_reset", a_response.api) as l_tpl_block then + if attached smarty_template_block (Current, "post_reset", a_response.api) as l_tpl_block then a_response.add_block (l_tpl_block, "content") else debug ("cms") diff --git a/modules/basic_auth/cms_basic_auth_module.e b/modules/basic_auth/cms_basic_auth_module.e index b96aa3b..6430e44 100644 --- a/modules/basic_auth/cms_basic_auth_module.e +++ b/modules/basic_auth/cms_basic_auth_module.e @@ -118,7 +118,7 @@ feature {NONE} -- Implementation: routes r.add_error_message ("You are already signed in!") r.set_main_content (r.link ("Logout", "account/roc-logout", Void)) else - if attached template_block (Current, "login", api) as l_tpl_block then + if attached smarty_template_block (Current, "login", api) as l_tpl_block then r.add_javascript_url (r.url ("module/" + name + "/files/js/roc_basic_auth.js", Void)) create vals.make (1) @@ -170,7 +170,7 @@ feature {NONE} -- Block views local vals: CMS_VALUE_TABLE do - if attached template_block (Current, a_block_id, a_response.api) as l_tpl_block then + if attached smarty_template_block (Current, a_block_id, a_response.api) as l_tpl_block then create vals.make (1) -- add the variable to the block a_response.api.hooks.invoke_value_table_alter (vals, a_response) diff --git a/modules/contact/src/cms_contact_module.e b/modules/contact/src/cms_contact_module.e index e85820b..92baa12 100644 --- a/modules/contact/src/cms_contact_module.e +++ b/modules/contact/src/cms_contact_module.e @@ -181,7 +181,7 @@ feature -- Hooks if a_block_id.is_case_insensitive_equal_general ("contact") then -- "contact", "post_contact" if a_response.request.is_get_request_method then - if attached template_block (Current, a_block_id, a_response.api) as l_tpl_block then + if attached smarty_template_block (Current, a_block_id, a_response.api) as l_tpl_block then if attached recaptcha_site_key (a_response.api) as l_recaptcha_site_key then l_tpl_block.set_value (l_recaptcha_site_key, "recaptcha_site_key") end @@ -201,7 +201,7 @@ feature -- Hooks f: CMS_FORM do a_response.add_style (a_response.url ("/module/" + name + "/files/css/contact.css", Void), Void) - if attached template_block (Current, "contact", api) as l_tpl_block then + if attached smarty_template_block (Current, "contact", api) as l_tpl_block then if attached recaptcha_site_key (api) as l_recaptcha_site_key then l_tpl_block.set_value (l_recaptcha_site_key, "recaptcha_site_key") end @@ -339,7 +339,7 @@ feature -- Hooks r.values.force (True, "has_error") vars.put ("True", "has_error") end - if attached template_block_with_values (Current, "post_contact", api, vars) as l_tpl_block then + if attached smarty_template_block_with_values (Current, "post_contact", api, vars) as l_tpl_block then across r.values as tb loop @@ -354,7 +354,7 @@ feature -- Hooks -- send a bad request status code and redisplay the form with the previous data loaded. r.set_value (False, "error") r.set_status_code ({HTTP_STATUS_CODE}.bad_request) - if attached template_block_with_values (Current, "contact", api, vars) as l_tpl_block then + if attached smarty_template_block_with_values (Current, "contact", api, vars) as l_tpl_block then across r.values as tb loop @@ -377,7 +377,7 @@ feature -- Hooks write_error_log (generator + ".handle_post_contact: Internal Server error") r.values.force (True, "has_error") r.set_status_code ({HTTP_CONSTANTS}.internal_server_error) - if attached template_block_with_values (Current, "post_contact", api, vars) as l_tpl_block then + if attached smarty_template_block_with_values (Current, "post_contact", api, vars) as l_tpl_block then across r.values as tb loop diff --git a/modules/google_search/src/google_custom_search_module.e b/modules/google_search/src/google_custom_search_module.e index c9e1a4f..6e2344a 100644 --- a/modules/google_search/src/google_custom_search_module.e +++ b/modules/google_search/src/google_custom_search_module.e @@ -114,7 +114,7 @@ feature -- Handler attached l_search.last_result as l_result and then l_result.status = 200 then - if attached template_block (Current, "search", api) as l_tpl_block then + if attached smarty_template_block (Current, "search", api) as l_tpl_block then l_tpl_block.set_value (l_result, "result") r.add_block (l_tpl_block, "content") end diff --git a/modules/oauth20/cms_oauth_20_module.e b/modules/oauth20/cms_oauth_20_module.e index c33ede2..58fdd80 100644 --- a/modules/oauth20/cms_oauth_20_module.e +++ b/modules/oauth20/cms_oauth_20_module.e @@ -243,7 +243,7 @@ feature -- Hooks a_response.location.same_string ("account") then if - attached template_block (Current, "account_info", a_response.api) as l_tpl_block and then + attached smarty_template_block (Current, "account_info", a_response.api) as l_tpl_block and then attached a_response.user as l_user then associate_account (l_user, a_response.values) @@ -323,7 +323,7 @@ feature {NONE} -- Block views local vals: CMS_VALUE_TABLE do - if attached template_block (Current, a_block_id, a_response.api) as l_tpl_block then + if attached smarty_template_block (Current, a_block_id, a_response.api) as l_tpl_block then create vals.make (1) -- add the variable to the block a_response.api.hooks.invoke_value_table_alter (vals, a_response) diff --git a/modules/openid/cms_openid_module.e b/modules/openid/cms_openid_module.e index 56928fe..259599b 100644 --- a/modules/openid/cms_openid_module.e +++ b/modules/openid/cms_openid_module.e @@ -270,7 +270,7 @@ feature {NONE} -- Block views local vals: CMS_VALUE_TABLE do - if attached template_block (Current, a_block_id, a_response.api) as l_tpl_block then + if attached smarty_template_block (Current, a_block_id, a_response.api) as l_tpl_block then create vals.make (1) -- add the variable to the block a_response.api.hooks.invoke_value_table_alter (vals, a_response) diff --git a/modules/session_auth/cms_session_auth_module.e b/modules/session_auth/cms_session_auth_module.e index 271e274..602270e 100644 --- a/modules/session_auth/cms_session_auth_module.e +++ b/modules/session_auth/cms_session_auth_module.e @@ -141,7 +141,7 @@ feature {NONE} -- Implementation: routes if api.user_is_authenticated then r.add_error_message ("You are already signed in!") else - if attached template_block (Current, "login", api) as l_tpl_block then + if attached smarty_template_block (Current, "login", api) as l_tpl_block then create vals.make (1) -- add the variable to the block l_tpl_block.set_value (api.user, "user") @@ -223,7 +223,7 @@ feature {NONE} -- Implementation: routes end else create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api) - if attached template_block (Current, "login", api) as l_tpl_block then + if attached smarty_template_block (Current, "login", api) as l_tpl_block then l_tpl_block.set_value (l_username.value, "username") l_tpl_block.set_value ("Wrong: Username or password ", "error") r.add_block (l_tpl_block, "content") @@ -232,7 +232,7 @@ feature {NONE} -- Implementation: routes r.execute else create {BAD_REQUEST_ERROR_CMS_RESPONSE} r.make (req, res, api) - if attached template_block (Current, "login", api) as l_tpl_block then + if attached smarty_template_block (Current, "login", api) as l_tpl_block then if attached {WSF_STRING} req.form_parameter ("username") as l_username then l_tpl_block.set_value (l_username.value, "username") end @@ -272,7 +272,7 @@ feature {NONE} -- Block views local vals: CMS_VALUE_TABLE do - if attached template_block (Current, a_block_id, a_response.api) as l_tpl_block then + if attached smarty_template_block (Current, a_block_id, a_response.api) as l_tpl_block then create vals.make (1) -- add the variable to the block a_response.api.hooks.invoke_value_table_alter (vals, a_response) diff --git a/src/hooks/cms_hook_block_helper.e b/src/hooks/cms_hook_block_helper.e index 8393bd5..633a41a 100644 --- a/src/hooks/cms_hook_block_helper.e +++ b/src/hooks/cms_hook_block_helper.e @@ -8,7 +8,7 @@ deferred class feature {NONE} -- Factory - template_block (a_module: CMS_MODULE; a_block_id: READABLE_STRING_8; a_cms_api: CMS_API): detachable CMS_SMARTY_TEMPLATE_BLOCK + smarty_template_block (a_module: CMS_MODULE; a_block_id: READABLE_STRING_8; a_cms_api: CMS_API): detachable CMS_SMARTY_TEMPLATE_BLOCK -- Smarty content block for `a_block_id' in the context of `a_module' and `a_cms_api'. local res: PATH @@ -26,11 +26,11 @@ feature {NONE} -- Factory end end - template_block_with_values (a_module: CMS_MODULE; a_block_id: READABLE_STRING_8; a_cms_api: CMS_API; a_values: STRING_TABLE [ANY]): like template_block + smarty_template_block_with_values (a_module: CMS_MODULE; a_block_id: READABLE_STRING_8; a_cms_api: CMS_API; a_values: STRING_TABLE [ANY]): like smarty_template_block -- Smarty content block for `a_block_id' in the context of `a_module' and `a_cms_api', -- With additional `a_values'. do - Result := template_block (a_module, a_block_id, a_cms_api) + Result := smarty_template_block (a_module, a_block_id, a_cms_api) if Result /= Void then across a_values as ic @@ -40,6 +40,25 @@ feature {NONE} -- Factory end end +feature {NONE} -- Factory: obsolete + + template_block (a_module: CMS_MODULE; a_block_id: READABLE_STRING_8; a_response: CMS_RESPONSE): detachable CMS_SMARTY_TEMPLATE_BLOCK + -- Smarty content block for `a_block_id' in the context of `a_module' and `a_response'. + obsolete + "Use smarty_template_block [Feb/2016]" + do + Result := smarty_template_block (a_module, a_block_id, a_response.api) + end + + template_block_with_values (a_module: CMS_MODULE; a_block_id: READABLE_STRING_8; a_response: CMS_RESPONSE; a_values: STRING_TABLE [ANY]): like smarty_template_block + -- Smarty content block for `a_block_id' in the context of `a_module' and `a_response', + -- With additional `a_values'. + obsolete + "Use smarty_template_block_with_values [Feb/2016]" + do + Result := smarty_template_block_with_values (a_module, a_block_id, a_response.api, a_values) + end + note copyright: "2011-2016, Jocelyn Fiat, Javier Velilla, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"