knowledge_base_icon_helper.rb 885 B

123456789101112131415161718192021222324252627282930
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. module KnowledgeBaseIconHelper
  3. def icon_for_object(object, iconset)
  4. case object
  5. when KnowledgeBase::Category
  6. icon object.category_icon, iconset
  7. when KnowledgeBase::Answer
  8. icon 'knowledge-base-answer'
  9. when KnowledgeBase
  10. icon 'knowledge-base'
  11. when Array
  12. icon 'hashtag' # object[0] override while tag icon is available
  13. end
  14. end
  15. def icon(icon_identifier, iconset = nil)
  16. return icon_native(icon_identifier) if iconset.nil?
  17. icon_from_set(icon_identifier, iconset)
  18. end
  19. def icon_native(icon_identifier)
  20. render 'knowledge_base/public/icon_native', icon_identifier: icon_identifier
  21. end
  22. def icon_from_set(icon_identifier, iconset)
  23. render 'knowledge_base/public/icon_from_set', iconset: iconset, icon_identifier: icon_identifier
  24. end
  25. end