A_MVC_Fs

Class A_MVC_Fs.

Defined (1)

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

/products/photocrati_nextgen/modules/mvc/package.module.mvc.php  
  1. class A_MVC_Fs extends Mixin 
  2. static $_lookups = array(); 
  3. static $_non_minified_modules = array(); 
  4. public function _get_cache_key() 
  5. return C_Photocrati_Transient_Manager::create_key('MVC', 'find_static_abspath'); 
  6. public function initialize() 
  7. register_shutdown_function(array(&$this, 'cache_lookups')); 
  8. //self::$_lookups = C_Photocrati_Transient_Manager::fetch($this->_get_cache_key(), array()); 
  9. self::$_non_minified_modules = apply_filters('ngg_non_minified_modules', array()); 
  10. public function cache_lookups() 
  11. C_Photocrati_Transient_Manager::update($this->_get_cache_key(), self::$_lookups); 
  12. /** 
  13. * Gets the absolute path to a static resource. If it doesn't exist, then NULL is returned 
  14. * @param string $path 
  15. * @param string $module 
  16. * @param string $relative 
  17. * @return string|NULL 
  18. */ 
  19. public function find_static_abspath($path, $module = FALSE, $relative = FALSE, &$found_root = FALSE) 
  20. $retval = NULL; 
  21. $key = $this->_get_static_abspath_key($path, $module, $relative); 
  22. // Have we looked up this resource before? 
  23. if (isset(self::$_lookups[$key])) { 
  24. $retval = self::$_lookups[$key]; 
  25. } else { 
  26. // Get the module if we haven't got one yet 
  27. if (!$module) { 
  28. list($path, $module) = $this->object->parse_formatted_path($path); 
  29. // Lookup the module directory 
  30. $mod_dir = $this->object->get_registry()->get_module_dir($module); 
  31. $filter = has_filter('ngg_non_minified_files') ? apply_filters('ngg_non_minified_files', $path, $module) : FALSE; 
  32. if (!defined('SCRIPT_DEBUG')) { 
  33. define('SCRIPT_DEBUG', FALSE); 
  34. if (!SCRIPT_DEBUG && !in_array($module, self::$_non_minified_modules) && strpos($path, 'min.') === FALSE && strpos($path, 'pack.') === FALSE && strpos($path, 'packed.') === FALSE && preg_match('/\\.(js|css)$/', $path) && !$filter) { 
  35. $path = preg_replace('#\\.[^\\.]+$#', '.min\\0', $path); 
  36. // In case NextGen is in a symlink we make $mod_dir relative to the NGG root and then rebuild it 
  37. // using WP_PLUGIN_DIR; without this NGG-in-symlink creates URL that reference the file abspath 
  38. if (is_link($this->object->join_paths(WP_PLUGIN_DIR, basename(NGG_PLUGIN_DIR)))) { 
  39. $mod_dir = str_replace(dirname(NGG_PLUGIN_DIR), '', $mod_dir); 
  40. $mod_dir = $this->object->join_paths(WP_PLUGIN_DIR, $mod_dir); 
  41. // Create the absolute path to the file 
  42. $path = $this->object->join_paths($mod_dir, C_NextGen_Settings::get_instance()->get('mvc_static_dirname'), $path); 
  43. if ($relative) { 
  44. $original_length = strlen($path); 
  45. $roots = array('plugins', 'plugins_mu', 'templates', 'stylesheets'); 
  46. $found_root = FALSE; 
  47. foreach ($roots as $root) { 
  48. $path = str_replace($this->object->get_document_root($root), '', $path); 
  49. if (strlen($path) != $original_length) { 
  50. $found_root = $root; 
  51. break; 
  52. // Cache result 
  53. $retval = self::$_lookups[$key] = $path; 
  54. return $retval; 
  55. public function _get_static_abspath_key($path, $module = FALSE, $relative = FALSE) 
  56. $key = $path; 
  57. if ($module) { 
  58. $key .= '|' . $module; 
  59. if ($relative) { 
  60. $key .= 'r'; 
  61. global $wpdb; 
  62. if ($wpdb) { 
  63. $key .= '|' . $wpdb->blogid; 
  64. return $key; 
  65. /** 
  66. * Gets the relative path to a static resource. If it doesn't exist, then NULL is returned 
  67. * @param string $path 
  68. * @param string $module 
  69. * @return string|NULL 
  70. */ 
  71. public function find_static_relpath($path, $module = FALSE) 
  72. return $this->object->find_static_abspath($path, $module, TRUE);