ref: master
app/helpers/forum_helper.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
module ForumHelper include ActionView::Helpers::DateHelper def cms_label_for_new_children _('New discussion topic') end def cms_label_for_edit _('Configure forum') end def list_forum_posts(articles) pagination = pagination_links(articles, { :param_name => 'npage' }) content = [content_tag('tr',_('Answers'))] content = [content_tag('tr', content_tag('th', _('Discussion topic')) + content_tag('th', _('Answers')) + content_tag('th', _('Last answer')) ) ] artic_len = articles.length articles.each_with_index{ |art,i| css_add = [ 'position-'+(i+1).to_s() ] position = (i%2 == 0) ? 'odd-post' : 'even-post' css_add << 'first' if i == 0 css_add << 'last' if i == (artic_len-1) css_add << 'not-published' if !art.published? css_add << position content << content_tag('tr', content_tag('td', topic_title(art), :class => 'forum-post-title') + content_tag('td', link_to(art.comments.count, art.url.merge(:anchor => 'comments_list')), :class => "forum-post-answers") + content_tag('td', last_topic_update(art).html_safe, :class => "forum-post-last-answer"), :class => 'forum-post ' + css_add.join(' '), :id => "post-#{art.id}" ) } content_tag('table', safe_join(content, "")) + (pagination or '').html_safe end def topic_title(article) topic_link = link_to(article.title, article.url) if article.published? topic_link else content_tag(:span, '', :class => 'ui-icon ui-icon-locked', :title => ('This is a private content')) + topic_link end end def last_topic_update(article) info = article.info_from_last_update if info[:author_url] (time_ago_in_words(info[:date]) + ' ' + _('by') + ' ' + link_to(info[:author_name], info[:author_url])).html_safe else time_ago_in_words(info[:date]) + ' ' + _('by') + ' ' + info[:author_name] end end end |