PageRenderTime 38ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 0ms

/joomla/templates/gantry/html/base_override.php

https://gitlab.com/ricardosanchez/prueba
PHP | 126 lines | 100 code | 11 blank | 15 comment | 12 complexity | fce6c911c812c5901566634092815731 MD5 | raw file
  1. <?php
  2. /**
  3. * @version $Id: base_override.php 9830 2013-04-29 23:56:49Z btowles $
  4. * @author RocketTheme http://www.rockettheme.com
  5. * @copyright Copyright (C) 2007 - 2013 RocketTheme, LLC
  6. * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
  7. */
  8. defined('_JEXEC') or die;
  9. if (!function_exists('base_override_getAvailablePlatformVersions')) {
  10. /**
  11. * Get the list of available platform versions
  12. * @return array the list of available Platform Versions
  13. */
  14. function base_override_getAvailablePlatformVersions($dir)
  15. {
  16. $family = substr(JVERSION, 0, strpos(JVERSION, '.'));
  17. $dir = rtrim($dir, '/\\');
  18. // find all entries in the dir
  19. $entries = array();
  20. if ($handle = opendir($dir)) {
  21. while (false !== ($entry = readdir($handle))) {
  22. if ($entry != "." && $entry != ".." && preg_match(sprintf('/^%s\./', $family), $entry) && is_dir($dir . '/' . $entry)) {
  23. $key = (preg_match('/^\d+\.\d+$/', $entry)) ? $entry . '.0' : $entry;
  24. $entries[$entry] = $key;
  25. }
  26. }
  27. closedir($handle);
  28. }
  29. $entries = array_filter($entries, 'base_override_versionfilter');
  30. uksort($entries, 'version_compare');
  31. return array_reverse(array_keys($entries));
  32. }
  33. function base_override_versionfilter($version)
  34. {
  35. $jversion = new JVersion();
  36. return version_compare($version, $jversion->getShortVersion(), '<=');
  37. }
  38. }
  39. $go_app = JFactory::getApplication();
  40. $go_current_template = $go_app->getTemplate(true);
  41. $go_search_paths = array();
  42. $go_jversion = new JVersion();
  43. $go_backtrace = debug_backtrace();
  44. $go_called_path = preg_replace('#[/\\\\]+#', '/', $go_backtrace[0]['file']);
  45. $go_called_array = explode('/', $go_called_path);
  46. $go_template = array_pop($go_called_array);
  47. $go_view = array_pop($go_called_array);
  48. $go_extension = array_pop($go_called_array);
  49. $go_relative_template_override_path = $go_view . '/' . $go_template;
  50. if ($go_extension != 'html') {
  51. $go_relative_template_override_path = $go_extension . '/' . $go_relative_template_override_path;
  52. }
  53. JLog::add(JText::sprintf('PLG_SYSTEM_GANTRY_LOG_USING_OVERRRIDE', $go_backtrace[0]['file']), JLog::DEBUG, 'gantry');
  54. $go_template_platform_versions = base_override_getAvailablePlatformVersions(implode('/', array(
  55. dirname(__FILE__),
  56. 'joomla'
  57. )));
  58. foreach ($go_template_platform_versions as $go_template_version) {
  59. $go_search_paths[] = implode('/', array(
  60. dirname(__FILE__),
  61. 'joomla',
  62. $go_template_version,
  63. $go_relative_template_override_path
  64. ));
  65. }
  66. if (defined('GANTRY_OVERRIDES_PATH')) {
  67. $go_output = '';
  68. // add fallback rokoverride paths
  69. $go_platform_versions = gantry_getAvailablePlatformVersions(GANTRY_OVERRIDES_PATH);
  70. foreach ($go_platform_versions as $go_platform_version) {
  71. $go_search_paths[] = implode('/', array(
  72. GANTRY_OVERRIDES_PATH,
  73. $go_platform_version,
  74. $go_current_template->params->get('override_set', '2.5'),
  75. $go_relative_template_override_path
  76. ));
  77. }
  78. }
  79. JLog::add(JText::sprintf('PLG_SYSTEM_GANTRY_LOG_OVERRIDE_SEARCH_PATH', implode(',', $go_search_paths)), JLog::DEBUG, 'gantry');
  80. // cycle through the search path and use the first thats there
  81. foreach ($go_search_paths as $go_search_path) {
  82. if (is_file($go_search_path)) {
  83. JLog::add(JText::sprintf('PLG_SYSTEM_GANTRY_LOG_FOUND_OVERRIDE_FILE', $go_search_path), JLog::DEBUG, 'gantry');
  84. ob_start();
  85. include $go_search_path;
  86. $go_output = ob_get_clean();
  87. echo $go_output;
  88. return;
  89. }
  90. }
  91. // fallback case to route back to default overrides
  92. if (isset($this) && isset($filetofind)) {
  93. // Fallback for components
  94. array_shift($this->_path['template']);
  95. $go_current_layout = $this->getLayout();
  96. $go_current_tpl = preg_replace('/^' . $go_current_layout . '_/', '', pathinfo($filetofind, PATHINFO_FILENAME));
  97. if ($go_current_tpl == pathinfo($filetofind, PATHINFO_FILENAME)) $go_current_tpl = null;
  98. echo $this->loadTemplate($go_current_tpl);
  99. return;
  100. } elseif (isset($module) && isset($path) && isset($attribs)) {
  101. // Build the base path for the layout
  102. $go_bPath = JPATH_BASE . '/modules/' . $module->module . '/tmpl/' . basename($go_backtrace[0]['file']);
  103. $go_dPath = JPATH_BASE . '/modules/' . $module->module . '/tmpl/default.php';
  104. if (file_exists($go_bPath)) {
  105. require $go_bPath;
  106. return;
  107. } elseif (file_exists($go_dPath)) {
  108. require $go_dPath;
  109. return;
  110. }
  111. }
  112. JLog::add(JText::sprintf('PLG_SYSTEM_GANTRY_LOG_UNABLE_TO_FIND_FALLBACK', $go_backtrace[0]['file']), JLog::ERROR, 'gantry');
  113. throw new Exception(JText::sprintf('PLG_SYSTEM_GANTRY_ERROR_UNABLE_TO_FIND_FALLBACK_OVERRIDE', $go_backtrace[0]['file']));