Mixin_NextGen_Gallery_Validation

The NextGEN Gallery Mixin NextGen Gallery Validation class.

Defined (1)

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

/products/photocrati_nextgen/modules/nextgen_data/package.module.nextgen_data.php  
  1. class Mixin_NextGen_Gallery_Validation 
  2. /** 
  3. * Validates whether the gallery can be saved 
  4. */ 
  5. function validation() 
  6. // If a title is present, we can auto-populate some other properties 
  7. if ($this->object->title) { 
  8. // Strip html 
  9. $this->object->title = M_NextGen_Data::strip_html($this->object->title, TRUE); 
  10. $sanitized_title = str_replace(' ', '-', $this->object->title); 
  11. if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { 
  12. $sanitized_title = remove_accents($sanitized_title); 
  13. // If no name is present, use the title to generate one 
  14. if (!$this->object->name) { 
  15. $this->object->name = apply_filters('ngg_gallery_name', sanitize_file_name($sanitized_title)); 
  16. // If no slug is set, use the title to generate one 
  17. if (!$this->object->slug) { 
  18. $this->object->slug = preg_replace('|[^a-z0-9 \\-~+_.#=!&;, /:%@$\\|*\'()\\x80-\\xff]|i', '', $sanitized_title); 
  19. $this->object->slug = nggdb::get_unique_slug($this->object->slug, 'gallery'); 
  20. // Set what will be the path to the gallery 
  21. if (!$this->object->path) { 
  22. $storage = C_Gallery_Storage::get_instance(); 
  23. $this->object->path = $storage->get_upload_relpath($this->object); 
  24. unset($storage); 
  25. } else { 
  26. $this->object->path = M_NextGen_Data::strip_html($this->object->path); 
  27. $this->object->path = str_replace(array('"', "''", ">", "<"), array('', '', '', ''), $this->object->path); 
  28. $this->object->validates_presence_of('title'); 
  29. $this->object->validates_presence_of('name'); 
  30. $this->object->validates_uniqueness_of('slug'); 
  31. $this->object->validates_numericality_of('author'); 
  32. return $this->object->is_valid();