Merge branch 'bootstrap' of https://github.com/PrestaShop/PrestaShop into bootstrap

This commit is contained in:
Kevin Granger
2013-11-07 21:49:11 +01:00
22 changed files with 391 additions and 283 deletions
+7 -1
View File
@@ -205,7 +205,13 @@ class DispatcherCore
{
$this->front_controller = self::FC_ADMIN;
$this->controller_not_found = 'adminnotfound';
$this->default_controller = 'admindashboard';
if (isset(Context::getContext()->employee) && Validate::isLoadedObject(Context::getContext()->employee) && isset(Context::getContext()->employee->default_tab))
{
$tab = new Tab((int)Context::getContext()->employee->default_tab);
$this->default_controller = $tab->class_name;
}
else
$this->default_controller = 'admindashboard';
}
elseif (Tools::getValue('fc') == 'module')
{
+24 -21
View File
@@ -48,9 +48,6 @@ class UploaderCore
public function getAcceptTypes()
{
if (!isset($this->_accept_types))
$this->setAcceptTypes('/.+$/i');
return $this->_accept_types;
}
@@ -101,6 +98,21 @@ class UploaderCore
return $this;
}
public function getPostMaxSizeBytes() {
$post_max_size = ini_get('post_max_size');
$bytes = trim($post_max_size);
$last = strtolower($post_max_size[strlen($post_max_size) - 1]);
switch ($last)
{
case 'g': $bytes *= 1024;
case 'm': $bytes *= 1024;
case 'k': $bytes *= 1024;
}
return $bytes;
}
public function getSavePath()
{
if (!isset($this->_save_path))
@@ -134,8 +146,11 @@ class UploaderCore
$this->files[] = $this->upload($tmp[$index]);
}
}
else
elseif ($upload)
{
$this->files[] = $this->upload($upload);
}
return $this->files;
}
@@ -173,7 +188,7 @@ class UploaderCore
protected function validate($file)
{
$post_max_size = $this->_getPostMaxSizeBytes();
$post_max_size = $this->getPostMaxSizeBytes();
if ($post_max_size && ($this->_getServerVars('CONTENT_LENGTH') > $post_max_size))
{
@@ -181,7 +196,10 @@ class UploaderCore
return false;
}
if (!preg_match($this->getAcceptTypes(), $file['name']))
$types = $this->getAcceptTypes();
//TODO check mime type.
if (isset($types) && !in_array(pathinfo($file['name'], PATHINFO_EXTENSION), $types))
{
$file['error'] = Tools::displayError('Filetype not allowed');
return false;
@@ -203,21 +221,6 @@ class UploaderCore
return filesize($file_path);
}
protected function _getPostMaxSizeBytes() {
$post_max_size = ini_get('post_max_size');
$bytes = trim($post_max_size);
$last = strtolower($post_max_size[strlen($post_max_size) - 1]);
switch ($last)
{
case 'g': $bytes *= 1024;
case 'm': $bytes *= 1024;
case 'k': $bytes *= 1024;
}
return $bytes;
}
protected function _getServerVars($var)
{
return (isset($_SERVER[$var]) ? $_SERVER[$var] : '');
+6 -2
View File
@@ -1502,7 +1502,7 @@ class AdminControllerCore extends Controller
if (Validate::isLoadedObject($this->context->employee))
{
$accesses = Profile::getProfileAccesses($this->context->employee->id_profile, 'class_name');
$default_tab = new Tab((int)Context::getContext()->employee->default_tab);
/* Hooks are volontary out the initialize array (need those variables already assigned) */
$bo_color = empty($this->context->employee->bo_color) ? '#FFFFFF' : $this->context->employee->bo_color;
$this->context->smarty->assign(array(
@@ -1516,7 +1516,7 @@ class AdminControllerCore extends Controller
'show_new_customers' => Configuration::get('PS_SHOW_NEW_CUSTOMERS') && $accesses['AdminCustomers']['view'],
'show_new_messages' => Configuration::get('PS_SHOW_NEW_MESSAGES') && $accesses['AdminCustomerThreads']['view'],
'first_name' => Tools::substr($this->context->employee->firstname, 0, 1),
'last_name' => htmlentities($this->context->employee->lastname, ENT_COMPAT, 'UTF-8'),
'last_name' => Tools::safeOutput($this->context->employee->lastname),
'employee' => $this->context->employee,
'search_type' => Tools::getValue('bo_search_type'),
'bo_query' => Tools::safeOutput(Tools::stripslashes(Tools::getValue('bo_query'))),
@@ -1529,9 +1529,13 @@ class AdminControllerCore extends Controller
'tabs' => $tabs,
'is_multishop' => $is_multishop,
'multishop_context' => $this->multishop_context,
'default_tab_link' => $this->context->link->getAdminLink($default_tab->class_name),
'employee_avatar' => ImageManager::thumbnail($this->context->employee->getImage(), 'employee'.'_'.(int)$this->context->employee->id.'.'.$this->imageType, 150, $this->imageType, true, true)
));
}
else
$this->context->smarty->assign('default_tab_link', $this->context->link->getAdminLink('AdminDashboard'));
$this->context->smarty->assign(array(
'img_dir' => _PS_IMG_,
'iso' => $this->context->language->iso_code,
+1 -1
View File
@@ -118,6 +118,7 @@ class HelperFormCore extends Helper
$uploader->setUrl(isset($params['url'])?$params['url']:null);
$uploader->setMultiple(isset($params['multiple'])?$params['multiple']:false);
$uploader->setUseAjax(isset($params['ajax'])?$params['ajax']:false);
$uploader->setMaxFiles(isset($params['max_files'])?$params['max_files']:null);
if (isset($params['files']) && $params['files'])
$uploader->setFiles($params['files']);
@@ -139,7 +140,6 @@ class HelperFormCore extends Helper
'download_url' => isset($params['file'])?$params['file']:null
)));
$uploader->setThumb(isset($params['thumb'])?$params['thumb']:null);
$uploader->setTitle(isset($params['title'])?$params['title']:null);
+8 -15
View File
@@ -26,35 +26,25 @@
class HelperImageUploaderCore extends HelperUploader
{
private $_temporary_path;
public function getMaxSize()
{
return (int)Configuration::get('PS_PRODUCT_PICTURE_MAX_SIZE');
}
public function setTemporaryPath($value)
public function getSavePath()
{
$this->_temporary_path = $value;
}
public function getTemporaryPath()
{
if (!isset($this->_temporary_path))
$this->_temporary_path = _PS_TMP_IMG_DIR_;
return $this->_normalizeDirectory($this->_temporary_path);
return $this->_normalizeDirectory(_PS_TMP_IMG_DIR_);
}
public function getFilePath($file_name = null)
{
//Force file path
return tempnam($this->getTemporaryPath(), $this->getUniqueFileName());
return tempnam($this->getSavePath(), $this->getUniqueFileName());
}
protected function validate($file)
{
$post_max_size = $this->_getPostMaxSizeBytes();
$post_max_size = $this->getPostMaxSizeBytes();
if ($post_max_size && ($this->_getServerVars('CONTENT_LENGTH') > $post_max_size))
{
@@ -62,7 +52,10 @@ class HelperImageUploaderCore extends HelperUploader
return false;
}
if (!preg_match($this->getAcceptTypes(), $file['name']))
$types = $this->getAcceptTypes();
//TODO check mime type.
if (isset($types) && !in_array(pathinfo($file['name'], PATHINFO_EXTENSION), $types))
{
$file['error'] = Tools::displayError('Filetype not allowed');
return false;
+1
View File
@@ -104,6 +104,7 @@ class HelperOptionsCore extends Helper
$uploader->setUrl(isset($field['url'])?$field['url']:null);
$uploader->setMultiple(isset($field['multiple'])?$field['multiple']:false);
$uploader->setUseAjax(isset($field['ajax'])?$field['ajax']:false);
$uploader->setMaxFiles(isset($field['max_files'])?$field['max_files']:null);
if (isset($field['files']) && $field['files'])
$uploader->setFiles($field['files']);
+13 -8
View File
@@ -243,22 +243,28 @@ class HelperUploaderCore extends Uploader
.'/themes/'.$bo_theme.'/js/vendor/jquery.ui.widget.js"></script>';
$html .= '<script type="text/javascript" src="'.__PS_BASE_URI__.$admin_webpath
.'/themes/'.$bo_theme.'/js/jquery.iframe-transport.js"></script>';
$html .= '<script type="text/javascript" src="'.__PS_BASE_URI__.$admin_webpath
$html .= '<script type="text/javascript" src="'.__PS_BASE_URI__.$admin_webpath
.'/themes/'.$bo_theme.'/js/jquery.fileupload.js"></script>';
$html .= '<script type="text/javascript" src="'.__PS_BASE_URI__.$admin_webpath
.'/themes/'.$bo_theme.'/js/jquery.fileupload-process.js"></script>';
$html .= '<script type="text/javascript" src="'.__PS_BASE_URI__.$admin_webpath
.'/themes/'.$bo_theme.'/js/jquery.fileupload-validate.js"></script>';
$html .= '<script type="text/javascript" src="'.__PS_BASE_URI__.'/js/vendor/spin.js"></script>';
$html .= '<script type="text/javascript" src="'.__PS_BASE_URI__.'/js/vendor/ladda.js"></script>';
}
else
{
$html = '';
$this->getContext()->controller->addJs(__PS_BASE_URI__.$admin_webpath
.'/themes/'.$bo_theme.'/js/vendor/jquery.ui.widget.js');
//$context->controller->addJs('http://blueimp.github.io/JavaScript-Load-Image/js/load-image.min.js');
$this->getContext()->controller->addJs(__PS_BASE_URI__.$admin_webpath
.'/themes/'.$bo_theme.'/js/jquery.iframe-transport.js');
$this->getContext()->controller->addJs(__PS_BASE_URI__.$admin_webpath
.'/themes/'.$bo_theme.'/js/jquery.fileupload.js');
/*$context->controller->addJs(__PS_BASE_URI__.$admin_webpath
.'/themes/'.$bo_theme.'/js/jquery.fileupload-image.js');*/
$this->getContext()->controller->addJs(__PS_BASE_URI__.$admin_webpath
.'/themes/'.$bo_theme.'/js/jquery.fileupload-process.js');
$this->getContext()->controller->addJs(__PS_BASE_URI__.$admin_webpath
.'/themes/'.$bo_theme.'/js/jquery.fileupload-validate.js');
$this->getContext()->controller->addJs(__PS_BASE_URI__.'/js/vendor/spin.js');
$this->getContext()->controller->addJs(__PS_BASE_URI__.'/js/vendor/ladda.js');
}
@@ -270,8 +276,6 @@ class HelperUploaderCore extends Uploader
$this->getTemplateFile($this->getTemplate()), $this->getContext()->smarty
);
$max_files = $this->getMaxFiles();
$template->assign(array(
'id' => $this->getId(),
'name' => $this->getName(),
@@ -280,7 +284,8 @@ class HelperUploaderCore extends Uploader
'files' => $this->getFiles(),
'thumb' => $this->getThumb(),
'title' => $this->getTitle(),
'max_files' => (isset($max_files) && $max_files > 0) ? ($max_files-count($this->getFiles())) : $max_files
'max_files' => $this->getMaxFiles(),
'post_max_size' => $this->getPostMaxSizeBytes()
));
$html .= $template->fetch();