// Back office is now always accessible even with a wrong base uri

This commit is contained in:
dMetzger
2012-09-21 08:57:58 +00:00
parent cb83f43604
commit 0f12f57714
4 changed files with 24 additions and 9 deletions
@@ -121,7 +121,7 @@ $(document).ready(function() {
<div id="discover_prestashop"><p class="center"><img src="../img/loader.gif" alt="" />{l s='Loading...'}</p></div>
{hook h="displayAdminHomeInfos"}
{hook h="displayBackOfficeHome"} //old name of the hook
{hook h="displayBackOfficeHome"} {*old name of the hook*}
</div>
+5 -1
View File
@@ -75,7 +75,11 @@ class ImageManagerCore
ImageManager::resize($image, _PS_TMP_IMG_DIR_.$cache_image, $ratio_x, $size, $image_type);
}
}
return '<img src="'._PS_TMP_IMG_.$cache_image.(!$disable_cache ? '?time='.time() : '').'" alt="" class="imgm" />';
// Relative link will always work, whatever the base uri set in the admin
if (Context::getContext()->controller->controller_type == 'admin')
return '<img src="../img/tmp/'.$cache_image.(!$disable_cache ? '?time='.time() : '').'" alt="" class="imgm" />';
else
return '<img src="'._PS_TMP_IMG_.$cache_image.(!$disable_cache ? '?time='.time() : '').'" alt="" class="imgm" />';
}
/**
+13 -4
View File
@@ -221,7 +221,12 @@ class MediaCore
if (!preg_match('/^http(s?):\/\//i', $file_uri) && !@filemtime($file_uri))
return false;
// adding file to the big array...;
if (Context::getContext()->controller->controller_type == 'admin')
{
$js_uri = preg_replace('/^'.preg_quote(__PS_BASE_URI__, '/').'/', '/', $js_uri);
$js_uri = dirname($_SERVER['REQUEST_URI'].'a').'/..'.$js_uri;
}
return $js_uri;
}
@@ -243,9 +248,12 @@ class MediaCore
if (!@filemtime($file_uri))
return false;
// adding file to the big array...
if (is_array($css_uri))
return $css_uri;
if (Context::getContext()->controller->controller_type == 'admin')
{
$css_uri = preg_replace('/^'.preg_quote(__PS_BASE_URI__, '/').'/', '/', $css_uri);
$css_uri = dirname($_SERVER['REQUEST_URI'].'a').'/..'.$css_uri;
}
return array($css_uri => $css_media_type);
}
@@ -269,6 +277,7 @@ class MediaCore
$folder = _PS_JS_DIR_.'jquery/'; //set default folder
//check if file exist
$file = $folder.'jquery-'.$version.($minifier ? '.min.js' : '.js');
// remove PS_BASE_URI on _PS_ROOT_DIR_ for the following
$url_data = parse_url($file);
$file_uri = _PS_ROOT_DIR_.Tools::str_replace_once(__PS_BASE_URI__, DIRECTORY_SEPARATOR, $url_data['path']);
+5 -3
View File
@@ -1239,13 +1239,15 @@ class AdminControllerCore extends Controller
else
{
$path_img = _PS_IMG_DIR_.'t/'.$tab['class_name'].'.png';
$img = _PS_IMG_.'t/'.$tab['class_name'].'.png';
// Relative link will always work, whatever the base uri set in the admin
$img = '../img/t/'.$tab['class_name'].'.png';
}
if (trim($tab['module']) != '')
{
$path_img = _PS_MODULE_DIR_.$tab['module'].'/'.$tab['class_name'].'.png';
$img = _MODULE_DIR_.$tab['module'].'/'.$tab['class_name'].'.png';
// Relative link will always work, whatever the base uri set in the admin
$img = '../modules/'.$tab['module'].'/'.$tab['class_name'].'.png';
}
// retrocompatibility
@@ -1651,7 +1653,7 @@ class AdminControllerCore extends Controller
Tools::redirectAdmin($this->context->link->getAdminLink('AdminLogin').(!isset($_GET['logout']) ? '&redirect='.$this->controller_name : ''));
// Set current index
$current_index = __PS_BASE_URI__.basename(_PS_ADMIN_DIR_).'/index.php'.(($controller = Tools::getValue('controller')) ? '?controller='.$controller : '');
$current_index = 'index.php'.(($controller = Tools::getValue('controller')) ? '?controller='.$controller : '');
if ($back = Tools::getValue('back'))
$current_index .= '&back='.urlencode($back);
self::$currentIndex = $current_index;