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