2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2019-09-18 17:25:04 +00:00
|
|
|
module KnowledgeBasePublicPageTitleHelper
|
|
|
|
def kb_public_page_title(leading, trailing, exception)
|
|
|
|
[
|
|
|
|
leading&.translation&.title,
|
|
|
|
kb_public_page_title_suffix(trailing, exception)
|
|
|
|
].compact.join(' - ')
|
|
|
|
end
|
|
|
|
|
|
|
|
def kb_public_page_title_suffix(item, exception)
|
2021-08-16 08:20:07 +00:00
|
|
|
case item
|
|
|
|
when HasTranslations
|
|
|
|
return item&.translation&.title if exception.blank?
|
2019-09-18 17:25:04 +00:00
|
|
|
|
2021-08-16 08:20:07 +00:00
|
|
|
zt kb_public_page_title_suffix_exception(exception)
|
|
|
|
when String
|
|
|
|
item
|
|
|
|
end
|
|
|
|
end
|
2019-09-18 17:25:04 +00:00
|
|
|
|
2021-08-16 08:20:07 +00:00
|
|
|
def kb_public_page_title_suffix_exception(exception)
|
|
|
|
case exception
|
|
|
|
when :not_found
|
2021-11-15 15:58:19 +00:00
|
|
|
__('Not Found')
|
2021-08-16 08:20:07 +00:00
|
|
|
when :alternatives
|
2021-11-15 15:58:19 +00:00
|
|
|
__('Alternative Translations')
|
2021-08-16 08:20:07 +00:00
|
|
|
end
|
2019-09-18 17:25:04 +00:00
|
|
|
end
|
|
|
|
end
|