Class | SectionNode |
In: |
app/models/section_node.rb
|
Parent: | ActiveRecord::Base |
# File app/models/section_node.rb, line 81 81: def ancestors() 82: ancestors = [] 83: fn = lambda do |sn| 84: ancestors << sn.section 85: if sn.section && !sn.section.root? 86: fn.call(sn.section.node) 87: end 88: end 89: fn.call(self) 90: ancestors.reverse 91: end
# File app/models/section_node.rb, line 63 63: def move_after(section_node) 64: if section == section_node.section && position < section_node.position 65: pos = section_node.position 66: else 67: pos = section_node.position + 1 68: end 69: move_to(section_node.section, pos) 70: end
# File app/models/section_node.rb, line 54 54: def move_before(section_node) 55: if section == section_node.section && position < section_node.position 56: pos = section_node.position - 1 57: else 58: pos = section_node.position 59: end 60: move_to(section_node.section, pos) 61: end
# File app/models/section_node.rb, line 31 31: def move_to(sec, pos) 32: #logger.info "Moving Section Node ##{id} to Section ##{sec.id} Position #{pos}" 33: transaction do 34: if section != sec 35: remove_from_list 36: self.section = sec 37: save 38: end 39: 40: if pos < 0 41: pos = 0 42: else 43: #This helps prevent the position from getting out of whack 44: #If you pass in a really high number for position, 45: #this just corrects it to the right number 46: node_count = SectionNode.count(:conditions => {:section_id => section_id}) 47: pos = node_count if pos > node_count 48: end 49: 50: insert_at_position(pos) 51: end 52: end
# File app/models/section_node.rb, line 72 72: def move_to_beginning(sec) 73: move_to(sec, 0) 74: end
# File app/models/section_node.rb, line 76 76: def move_to_end(sec) 77: #1.0/0 == Infinity 78: move_to(sec, 1.0/0) 79: end
# File app/models/section_node.rb, line 17 17: def orphaned? 18: !node || (node.class.uses_soft_delete? && node.deleted?) 19: end
Is this node a page
# File app/models/section_node.rb, line 27 27: def page? 28: node_type == 'Page' 29: end
Is this node a section
# File app/models/section_node.rb, line 22 22: def section? 23: node_type == 'Section' 24: end
# File app/models/section_node.rb, line 9 9: def visible? 10: return false unless node 11: return false if(node.respond_to?(:hidden?) && node.hidden?) 12: return false if(node.respond_to?(:archived?) && node.archived?) 13: return false if(node.respond_to?(:published?) && !node.published?) 14: true 15: end