A_WordPress_Routing_App

Class A_WordPress_Routing_App.

Defined (1)

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

/products/photocrati_nextgen/modules/wordpress_routing/package.module.wordpress_routing.php  
  1. class A_WordPress_Routing_App extends Mixin 
  2. function remove_parameter($key, $id = NULL, $url = FALSE) 
  3. $generated_url = $this->call_parent('remove_parameter', $key, $id, $url); 
  4. $generated_url = $this->object->add_post_permalink_to_url($generated_url); 
  5. return $generated_url; 
  6. function parse_url($url) 
  7. $parts = parse_url($url); 
  8. if (!isset($parts['path'])) { 
  9. $parts['path'] = '/'; 
  10. if (!isset($parts['query'])) { 
  11. $parts['query'] = ''; 
  12. return $parts; 
  13. /** 
  14. * Adds the post permalink to the url, if it isn't already present. 
  15. * The generated_url could look like: 
  16. * http://localhost/dir/nggallery/show/slideshow 
  17. * @param $generated_url 
  18. * @return mixed 
  19. */ 
  20. function add_post_permalink_to_url($generated_url) 
  21. if (!apply_filters('ngg_wprouting_add_post_permalink', TRUE)) { 
  22. return $generated_url; 
  23. $base_url = $this->object->get_router()->get_base_url('home'); 
  24. $settings = C_NextGen_Settings::get_instance(); 
  25. if (strlen($generated_url) < 2) { 
  26. $generated_url = $base_url; 
  27. $original_url = $generated_url; 
  28. $generated_parts = explode($settings->router_param_slug, $generated_url); 
  29. $generated_url = $generated_parts[0]; 
  30. $ngg_parameters = '/'; 
  31. if (isset($generated_parts[1])) { 
  32. $parts = explode('?', $generated_parts[1]); 
  33. $ngg_parameters = array_shift($parts); 
  34. $post_permalink = get_permalink(isset($_REQUEST['p']) ? $_REQUEST['p'] : 0); 
  35. if ($post_permalink == '/') { 
  36. $post_permalink = $base_url; 
  37. // Trailing slash all of the urls 
  38. $original_url = trailingslashit($original_url); 
  39. $post_permalink = trailingslashit($post_permalink); 
  40. $generated_url = trailingslashit($generated_url); 
  41. // We need to determine if the generated url and the post permalink TRULY differ. If they 
  42. // differ, then we'll return post_permalink + nggallery parameters appended. Otherwise, we'll 
  43. // just return the generated url 
  44. $generated_url = str_replace($base_url, home_url(), $generated_url); 
  45. $generated_parts = $this->parse_url($generated_url); 
  46. $post_parts = $this->parse_url($post_permalink); 
  47. $generated_parts['path'] = trailingslashit($generated_parts['path']); 
  48. if (isset($generated_parts['query'])) { 
  49. $generated_parts['query'] = untrailingslashit($generated_parts['query']); 
  50. $post_parts['path'] = trailingslashit($post_parts['path']); 
  51. if (isset($post_parts['query'])) { 
  52. $post_parts['query'] = untrailingslashit($post_parts['query']); 
  53. $generated_url = $this->object->construct_url_from_parts($generated_parts); 
  54. $post_permalink = $this->object->construct_url_from_parts($post_parts); 
  55. // No change required... 
  56. if ($generated_url == $post_permalink) { 
  57. $generated_url = $original_url; 
  58. // Ensure that the generated url has the real base url for default permalinks 
  59. if (strpos($generated_url, home_url()) !== FALSE && strpos($generated_url, $base_url) === FALSE) { 
  60. $generated_url = str_replace(home_url(), $base_url, $generated_url); 
  61. } else { 
  62. // The post permalink differs from the generated url 
  63. $post_permalink = str_replace(home_url(), $base_url, $post_permalink); 
  64. $post_parts = $this->parse_url($post_permalink); 
  65. $post_parts['path'] = $this->object->join_paths($post_parts['path'], $settings->router_param_slug, $ngg_parameters); 
  66. $post_parts['path'] = str_replace('index.php/index.php', 'index.php', $post_parts['path']); 
  67. // incase permalink_structure contains index.php 
  68. if (!empty($generated_parts['query']) && empty($post_parts['query'])) { 
  69. $post_parts['query'] = $generated_parts['query']; 
  70. $generated_url = $this->object->construct_url_from_parts($post_parts); 
  71. return $generated_url; 
  72. function join_paths() 
  73. $args = func_get_args(); 
  74. return $this->get_router()->join_paths($args); 
  75. function passthru() 
  76. $router = C_Router::get_instance(); 
  77. $_SERVER['ORIG_REQUEST_URI'] = $_SERVER['REQUEST_URI']; 
  78. $base_parts = parse_url($router->get_base_url('root')); 
  79. $new_request_uri = $router->join_paths(!empty($base_parts['path']) ? $base_parts['path'] : '', $this->object->strip_param_segments($router->get_request_uri())); 
  80. $new_request_uri = str_replace('index.php/index.php', 'index.php', $new_request_uri); 
  81. $_SERVER['UNENCODED_URL'] = $_SERVER['HTTP_X_ORIGINAL_URL'] = $_SERVER['REQUEST_URI'] = '/' . trailingslashit($new_request_uri); 
  82. if (isset($_SERVER['PATH_INFO'])) { 
  83. $_SERVER['ORIG_PATH_INFO'] = $_SERVER['PATH_INFO']; 
  84. unset($_SERVER['PATH_INFO']);