Mixin_Displayed_Gallery_Validation

Provides validation.

Defined (1)

The class is defined in the following location(s).

/products/photocrati_nextgen/modules/nextgen_gallery_display/package.module.nextgen_gallery_display.php  
  1. class Mixin_Displayed_Gallery_Validation extends Mixin 
  2. public function validation() 
  3. // Valid sources 
  4. $this->object->validates_presence_of('source'); 
  5. // Valid display type? 
  6. $this->object->validates_presence_of('display_type'); 
  7. if ($display_type = $this->object->get_display_type()) { 
  8. foreach ($this->object->display_settings as $key => $val) { 
  9. $display_type->settings[$key] = $val; 
  10. $this->object->display_settings = $display_type->settings; 
  11. if (!$display_type->validate()) { 
  12. foreach ($display_type->get_errors() as $property => $errors) { 
  13. foreach ($errors as $error) { 
  14. $this->object->add_error($error, $property); 
  15. // Is the display type compatible with the source? E.g., if we're 
  16. // using a display type that expects images, we can't be feeding it 
  17. // galleries and albums 
  18. if ($source = $this->object->get_source()) { 
  19. if (!$display_type->is_compatible_with_source($source)) { 
  20. $this->object->add_error(__('Source not compatible with selected display type', 'nggallery'), 'display_type'); 
  21. // Allow ONLY recent & random galleries to have their own maximum_entity_count 
  22. if (!empty($this->object->display_settings['maximum_entity_count']) && in_array($this->object->source, array('random_images', 'recent_images', 'random', 'recent'))) { 
  23. $this->object->maximum_entity_count = $this->object->display_settings['maximum_entity_count']; 
  24. // If no maximum_entity_count has been given, then set a maximum 
  25. if (!isset($this->object->maximum_entity_count)) { 
  26. $settings = C_NextGen_Settings::get_instance(); 
  27. $this->object->maximum_entity_count = $settings->get('maximum_entity_count', 500); 
  28. } else { 
  29. $this->object->add_error('Invalid display type', 'display_type'); 
  30. return $this->object->is_valid();