+ validates :panel_id, :numericality => {:allow_blank => true}
+ validates :picture_id, :numericality => true, :existence => {:both => false}
+ validates :link, :length => {:maximum => 200}, :url => {:allow_blank => true, :message => I18n.t('errors.messages.url')}
+ validates :x, :presence => true, :numericality => true
+ validates :y, :presence => true, :numericality => true
+ validates :width, :presence => true, :numericality => true, :not_zero => true, :reverse => true, :resize => true, :sync_vh => true
+ validates :height, :presence => true, :numericality => true, :not_zero => true, :reverse => true, :resize => true, :sync_vh => true
+ validates :z, :presence => true, :numericality => {:greater_than => 0}
+ validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
+
+ before_validation :valid_encode
+
+ def valid_encode
+ ['link', 'caption'].each do |a|
+ next if attributes[a] == nil
+ raise Pettanr::BadRequest unless attributes[a].valid_encoding?
+ end
+ end
+
+ def visible? roles
+ if MagicNumber['run_mode'] == 0
+ return false unless guest_role_check(roles)
+ else
+ return false unless reader_role_check(roles)
+ end
+ return true if self.panel.own?(roles)
+ self.panel.visible? roles
+ end
+
+ def supply_default
+ self.x = 0
+ self.y = 0
+ if self.picture
+ self.width = self.picture.width
+ self.height = self.picture.height
+ end
+ if self.panel
+ self.t = self.panel.new_t
+ self.z = self.panel.new_z
+ end
+ end
+
+ def overwrite
+ end