<commit_before>module EtabliocmsCore
  module Admin
    module TableTreeHelper

      def render_table_tree(items = [])
        stack = []
        html = ""
        items.each do |node|
          if stack.empty?
            html << item_html(node, stack)
            stack.push(node)
            next
          end
          if stack.last.lft < node.lft && node.lft < stack.last.rgt
            if node.leaf?
              html << item_html(node, stack)
            else
              html << item_html(node, stack)
              stack.push(node)
            end
            if node.rgt + 1 == stack.last.rgt
              stack.pop
            end
          else
            stack.pop
            redo
          end
        end
        html.html_safe
      end

      def item_html(item, stack)
        html = [
            link_to(item.title, edit_path(item), :style => "padding-left:#{stack.size*10}px"),
            content_tag(:span, I18n.l(item.created_at, :format => :short), :class => "centered"),
            content_tag(:span, item.locale, :class => 'centered'),
            actions_links(item, stack.last)
        ].inject("") { |line, cell_content| line + content_tag(:td, cell_content) }
        content_tag(:tr, html.html_safe)
      end

      def actions_links(item, parent)
        links = [
            link_to(I18n.t('hierarchy.edit'), edit_path(item),
                    :class => "icon icon-edit",
                    :title => I18n.t('hierarchy.edit')),
            link_to(I18n.t('hierarchy.destroy'), destroy_path(item),
                    :method => :delete,
                    :confirm => t("#{item.class.to_s.demodulize.underscore}.destroy_confirmation"),
                    :class => 'icon icon-destroy', :title => I18n.t('hierarchy.destroy'))
        ]<commit_msg>Fixed wrong translation scope<commit_after>module EtabliocmsCore
  module Admin
    module TableTreeHelper

      def render_table_tree(items = [])
        stack = []
        html = ""
        items.each do |node|
          if stack.empty?
            html << item_html(node, stack)
            stack.push(node)
            next
          end
          if stack.last.lft < node.lft && node.lft < stack.last.rgt
            if node.leaf?
              html << item_html(node, stack)
            else
              html << item_html(node, stack)
              stack.push(node)
            end
            if node.rgt + 1 == stack.last.rgt
              stack.pop
            end
          else
            stack.pop
            redo
          end
        end
        html.html_safe
      end

      def item_html(item, stack)
        html = [
            link_to(item.title, edit_path(item), :style => "padding-left:#{stack.size*10}px"),
            content_tag(:span, I18n.l(item.created_at, :format => :short), :class => "centered"),
            content_tag(:span, item.locale, :class => 'centered'),
            actions_links(item, stack.last)
        ].inject("") { |line, cell_content| line + content_tag(:td, cell_content) }
        content_tag(:tr, html.html_safe)
      end

      def actions_links(item, parent)
        links = [
            link_to(I18n.t('admin.edit'), edit_path(item),
                    :class => "icon icon-edit",
                    :title => I18n.t('admin.edit')),
            link_to(I18n.t('admin.destroy'), destroy_path(item),
                    :method => :delete,
                    :confirm => t("#{item.class.to_s.demodulize.underscore}.destroy_confirmation"),
                    :class => 'icon icon-destroy', :title => I18n.t('admin.destroy'))
        ]
{'fraction_non_alphanumeric': 0.12632164718976072, 'fraction_numerical': 0.007234279354479688, 'mean_word_length': 1.597543352601156, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5446984', 'n_tokens_mistral': 1086, 'n_tokens_neox': 1048, 'n_words': 205}