A_NextGen_Basic_Gallery_Urls

Class A_NextGen_Basic_Gallery_Urls.

Defined (1)

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

/products/photocrati_nextgen/modules/nextgen_basic_gallery/package.module.nextgen_basic_gallery.php  
  1. class A_NextGen_Basic_Gallery_Urls extends Mixin 
  2. public function create_parameter_segment($key, $value, $id = NULL, $use_prefix = FALSE) 
  3. if ($key == 'show') { 
  4. if ($value == NGG_BASIC_SLIDESHOW) { 
  5. $value = 'slideshow'; 
  6. } elseif ($value == NGG_BASIC_THUMBNAILS) { 
  7. $value = 'thumbnails'; 
  8. } elseif ($value == NGG_BASIC_IMAGEBROWSER) { 
  9. $value = 'imagebrowser'; 
  10. return $value; 
  11. } elseif ($key == 'nggpage') { 
  12. return 'page/' . $value; 
  13. } else { 
  14. return $this->call_parent('create_parameter_segment', $key, $value, $id, $use_prefix); 
  15. public function set_parameter_value($key, $value, $id = NULL, $use_prefix = FALSE, $url = FALSE) 
  16. $retval = $this->call_parent('set_parameter_value', $key, $value, $id, $use_prefix, $url); 
  17. return $this->_set_ngglegacy_page_parameter($retval, $key, $value, $id, $use_prefix); 
  18. public function remove_parameter($key, $id = NULL, $url = FALSE) 
  19. $retval = $this->call_parent('remove_parameter', $key, $id, $url); 
  20. $retval = $this->_set_ngglegacy_page_parameter($retval, $key); 
  21. // For some reason, we're not removing our parameters the way we should. Our routing system seems to be 
  22. // a bit broken and so I'm adding an exception here. 
  23. // TODO: Our parameter manipulations need to be flawless. Look into route cause 
  24. if ($key == 'show') { 
  25. $uri = explode('?', $retval); 
  26. $uri = $uri[0]; 
  27. $settings = C_NextGen_Settings::get_instance(); 
  28. $regex = '#/' . $settings->router_param_slug . '.*(/?(slideshow|thumbnails|imagebrowser)/?)#'; 
  29. if (preg_match($regex, $retval, $matches)) { 
  30. $retval = str_replace($matches[1], '', $retval); 
  31. return $retval; 
  32. public function _set_ngglegacy_page_parameter($retval, $key, $value = NULL, $id = NULL, $use_prefix = NULL) 
  33. // Get the settings manager 
  34. $settings = C_NextGen_Settings::get_instance(); 
  35. // Create regex pattern 
  36. $param_slug = preg_quote($settings->router_param_slug, '#'); 
  37. if ($key == 'nggpage') { 
  38. $regex = "#(/{$param_slug}/.*)(/?page/\\d+/?)(.*)#"; 
  39. if (preg_match($regex, $retval, $matches)) { 
  40. $new_segment = $value ? "/page/{$value}" : ''; 
  41. $retval = rtrim(str_replace($matches[0], rtrim($matches[1], '/') . $new_segment . ltrim($matches[3], '/'), $retval), '/'); 
  42. # Convert the nggpage parameter to a slug 
  43. if (preg_match("#(/{$param_slug}/.*)nggpage--(.*)#", $retval, $matches)) { 
  44. $retval = rtrim(str_replace($matches[0], rtrim($matches[1], '/') . '/page/' . ltrim($matches[2], '/'), $retval), '/'); 
  45. # Convert the show parameter to a slug 
  46. if (preg_match("#(/{$param_slug}/.*)show--(.*)#", $retval, $matches)) { 
  47. $retval = rtrim(str_replace($matches[0], rtrim($matches[1], '/') . '/' . $matches[2], $retval), '/'); 
  48. $retval = str_replace(NGG_BASIC_SLIDESHOW, 'slideshow', $retval); 
  49. $retval = str_replace(NGG_BASIC_THUMBNAILS, 'thumbnails', $retval); 
  50. $retval = str_replace(NGG_BASIC_IMAGEBROWSER, 'imagebrowser', $retval); 
  51. return $retval;