A_MVC_Router

Class A_MVC_Router.

Defined (1)

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

/products/photocrati_nextgen/modules/mvc/package.module.mvc.php  
  1. class A_MVC_Router extends Mixin 
  2. static $_lookups = array(); 
  3. function initialize() 
  4. register_shutdown_function(array(&$this, 'cache_lookups')); 
  5. self::$_lookups = C_Photocrati_Transient_Manager::fetch($this->_get_cache_key(), array()); 
  6. function _get_cache_key() 
  7. return C_Photocrati_Transient_Manager::create_key('MVC', 'get_static_url'); 
  8. function cache_lookups() 
  9. C_Photocrati_Transient_Manager::update($this->_get_cache_key(), self::$_lookups); 
  10. function _get_static_url_key($path, $module = FALSE) 
  11. $parts = array($path, $module, $this->object->get_base_url('plugins'), $this->object->get_base_url('plugins_mu'), $this->object->get_base_url('templates'), $this->object->get_base_url('stylesheets')); 
  12. return implode('|', $parts); 
  13. /** 
  14. * First tries to find the static file in the 'static' folder 
  15. * @param string $path 
  16. * @param string $module 
  17. * @return string 
  18. */ 
  19. function get_static_url($path, $module = FALSE) 
  20. $retval = NULL; 
  21. $key = $this->object->_get_static_url_key($path, $module); 
  22. // Have we looked up this url before? 
  23. if (isset(self::$_lookups[$key])) { 
  24. $retval = self::$_lookups[$key]; 
  25. $fs = C_Fs::get_instance(); 
  26. // Check for a user-supplied override 
  27. if (NULL === $retval) { 
  28. $formatted_path = $fs->parse_formatted_path($path); 
  29. $abspath = $fs->join_paths($this->object->get_static_override_dir($formatted_path[1]), $formatted_path[0]); 
  30. if (@is_file($abspath)) { 
  31. $abspath = str_replace($fs->get_document_root('content'), '', $abspath); 
  32. $retval = self::$_lookups[$key] = $this->object->join_paths($this->object->get_base_url('content'), str_replace("\\", '/', $abspath)); 
  33. // We'll have to calculate the url from our own modules 
  34. if (NULL === $retval) { 
  35. $path = $fs->find_static_abspath($path, $module); 
  36. $original_length = strlen($path); 
  37. $roots = array('plugins', 'plugins_mu', 'templates', 'stylesheets'); 
  38. $found_root = FALSE; 
  39. foreach ($roots as $root) { 
  40. $path = str_replace($fs->get_document_root($root), '', $path); 
  41. if (strlen($path) != $original_length) { 
  42. $found_root = $root; 
  43. break; 
  44. // We found the root so we know what base url to prepend 
  45. if ($found_root) { 
  46. $retval = self::$_lookups[$key] = $this->object->join_paths($this->object->get_base_url($found_root), str_replace("\\", '/', $path)); 
  47. } else { 
  48. $retval = self::$_lookups[$key] = $this->object->join_paths($this->object->get_base_url('root'), str_replace("\\", '/', $path)); 
  49. // For the "Sage" theme and others using the "Soil" plugin "Roots" theme was re-branded to "Sage" theme 
  50. // 2015-02-25; see https://roots.io/new-website-sage-and-the-future/ 
  51. if ((current_theme_supports('soil-relative-urls') || current_theme_supports('root-relative-urls')) && strpos($retval, '/') !== 0) { 
  52. $retval = '/' . $retval; 
  53. return $retval; 
  54. /** 
  55. * @param string $module_id 
  56. * @return string $dir 
  57. */ 
  58. function get_static_override_dir($module_id = NULL) 
  59. $fs = C_Fs::get_instance(); 
  60. $dir = $fs->join_paths(WP_CONTENT_DIR, 'ngg'); 
  61. if (!@file_exists($dir)) { 
  62. wp_mkdir_p($dir); 
  63. $dir = $fs->join_paths($dir, 'modules'); 
  64. if (!@file_exists($dir)) { 
  65. wp_mkdir_p($dir); 
  66. if ($module_id) { 
  67. $dir = $fs->join_paths($dir, $module_id); 
  68. if (!@file_exists($dir)) { 
  69. wp_mkdir_p($dir); 
  70. $dir = $fs->join_paths($dir, 'static'); 
  71. if (!@file_exists($dir)) { 
  72. wp_mkdir_p($dir); 
  73. return $dir;