Module | Cms::Behaviors::Connecting::InstanceMethods |
In: |
lib/cms/behaviors/connecting.rb
|
# File lib/cms/behaviors/connecting.rb, line 61 61: def connect_to_page 62: unless connect_to_page_id.blank? || connect_to_container.blank? 63: #Note that we are setting connected_page so that page can look at that 64: #to determine if the page should be published 65: self.connected_page = Page.find(connect_to_page_id) 66: connected_page.create_connector(self, connect_to_container) 67: end 68: true 69: end
# File lib/cms/behaviors/connecting.rb, line 45 45: def connected_page_count 46: Page.connected_to(self).count 47: end
# File lib/cms/behaviors/connecting.rb, line 41 41: def connected_pages 42: Page.connected_to(self) 43: end
# File lib/cms/behaviors/connecting.rb, line 49 49: def content_block_type 50: self.class.content_block_type 51: end
# File lib/cms/behaviors/connecting.rb, line 53 53: def display_name 54: self.class.display_name 55: end
# File lib/cms/behaviors/connecting.rb, line 57 57: def display_name_plural 58: self.class.display_name_plural 59: end
# File lib/cms/behaviors/connecting.rb, line 71 71: def update_connected_pages 72: # If this is versioned, then we need make new versions of all the pages this is connected to 73: if self.class.versioned? 74: #logger.info "..... Updating connected pages for #{self.class} #{id} v#{version}" 75: 76: #Get all the pages the previous version of this connectable was connected to 77: draft_version = draft.version 78: Page.connected_to(:connectable => self, :version => (draft_version - 1)).all.each do |p| 79: # This is needed in the case of updating page, 80: # which updates this object, so as not to create a loop 81: if p != updated_by_page 82: #This just creates a new version of the page 83: action = deleted? ? "Deleted" : "Edited" 84: p.update_attributes(:version_comment => "#{self.class.name} ##{id} was #{action}") 85: 86: #The previous step will copy over a connector pointing to the previous version of this connectable 87: #We need to change that to point at the new version of this connectable 88: p.connectors.for_page_version(p.draft.version).for_connectable(self).each do |con| 89: con.update_attribute(:connectable_version, draft_version) 90: end 91: end 92: end 93: end 94: true 95: end