Ngg_Serializable

The NextGEN Gallery Ngg Serializable class.

Defined (1)

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

/products/photocrati_nextgen/modules/ngglegacy/lib/class.ngg_serializable.php  
  1. class Ngg_Serializable 
  2. /** 
  3. * Serializes the data 
  4. * @param mixed $value 
  5. * @return string 
  6. */ 
  7. function serialize($value) 
  8. //Using json_encode here because PHP's serialize is not Unicode safe 
  9. return base64_encode(json_encode($value)); 
  10.  
  11.  
  12. /** 
  13. * Unserializes data using our proprietary format 
  14. * @param string $value 
  15. * @return mixed 
  16. */ 
  17. function unserialize($value) 
  18. $retval = NULL; 
  19. if (is_string($value)) 
  20. $retval = stripcslashes($value); 
  21.  
  22. if (strlen($value) > 1) 
  23. // We can't always rely on base64_decode() or json_decode() to return FALSE as their documentation 
  24. // claims so check if $retval begins with a: as that indicates we have a serialized PHP object. 
  25. if (strpos($retval, 'a:') === 0) 
  26. $er = error_reporting(0); 
  27. $retval = unserialize($value); 
  28. error_reporting($er); 
  29. else { 
  30. // We use json_decode() here because PHP's unserialize() is not Unicode safe. 
  31. $retval = json_decode(base64_decode($retval), TRUE); 
  32.  
  33. return $retval;