// Use protected instead of private for classes we can override #PSCFV-1976
This commit is contained in:
@@ -36,7 +36,7 @@ class AddressFormatCore extends ObjectModel
|
||||
/** @var string */
|
||||
public $format;
|
||||
|
||||
private $_errorFormatList = array();
|
||||
protected $_errorFormatList = array();
|
||||
|
||||
/**
|
||||
* @see ObjectModel::$definition
|
||||
|
||||
+2
-2
@@ -49,8 +49,8 @@ class CountyCore extends ObjectModel
|
||||
),
|
||||
);
|
||||
|
||||
private static $_cache_get_counties = array();
|
||||
private static $_cache_county_zipcode = array();
|
||||
protected static $_cache_get_counties = array();
|
||||
protected static $_cache_county_zipcode = array();
|
||||
|
||||
const USE_BOTH_TAX = 0;
|
||||
const USE_COUNTY_TAX = 1;
|
||||
|
||||
@@ -27,10 +27,9 @@
|
||||
|
||||
class FileUploaderCore
|
||||
{
|
||||
|
||||
private $allowedExtensions = array();
|
||||
private $file;
|
||||
private $sizeLimit;
|
||||
protected $allowedExtensions = array();
|
||||
protected $file;
|
||||
protected $sizeLimit;
|
||||
|
||||
public function __construct(array $allowedExtensions = array(), $sizeLimit = 10485760)
|
||||
{
|
||||
|
||||
@@ -698,7 +698,7 @@ class LanguageCore extends ObjectModel
|
||||
return copy(dirname(__FILE__).'/../img/l/none.jpg', dirname(__FILE__).'/../img/l/'.$id.'.jpg');
|
||||
}
|
||||
|
||||
private static $_cache_language_installation = null;
|
||||
protected static $_cache_language_installation = null;
|
||||
public static function isInstalled($iso_code)
|
||||
{
|
||||
if (self::$_cache_language_installation === null)
|
||||
|
||||
@@ -59,7 +59,7 @@ abstract class ObjectModelCore
|
||||
|
||||
protected $id_shop = null;
|
||||
|
||||
private $get_shop_from_context = true;
|
||||
protected $get_shop_from_context = true;
|
||||
|
||||
protected static $fieldsRequiredDatabase = null;
|
||||
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ class ProfileCore extends ObjectModel
|
||||
),
|
||||
);
|
||||
|
||||
private static $_cache_accesses = array();
|
||||
protected static $_cache_accesses = array();
|
||||
|
||||
/**
|
||||
* Get all available profiles
|
||||
|
||||
+1
-1
@@ -1534,7 +1534,7 @@ class ToolsCore
|
||||
return Media::cccJS($js_files);
|
||||
}
|
||||
|
||||
private static $_cache_nb_media_servers = null;
|
||||
protected static $_cache_nb_media_servers = null;
|
||||
|
||||
public static function getMediaServer($filename)
|
||||
{
|
||||
|
||||
@@ -33,9 +33,9 @@ class UpgraderCore
|
||||
/**
|
||||
* @var boolean contains true if last version is not installed
|
||||
*/
|
||||
private $need_upgrade = false;
|
||||
private $changed_files = array();
|
||||
private $missing_files = array();
|
||||
protected $need_upgrade = false;
|
||||
protected $changed_files = array();
|
||||
protected $missing_files = array();
|
||||
|
||||
public $version_name;
|
||||
public $version_num;
|
||||
|
||||
@@ -35,8 +35,8 @@ class ShopUrlCore extends ObjectModel
|
||||
public $main;
|
||||
public $active;
|
||||
|
||||
private static $main_domain = null;
|
||||
private static $main_domain_ssl = null;
|
||||
protected static $main_domain = null;
|
||||
protected static $main_domain_ssl = null;
|
||||
|
||||
/**
|
||||
* @see ObjectModel::$definition
|
||||
|
||||
@@ -35,7 +35,7 @@ class TaxRulesTaxManagerCore implements TaxManagerInterface
|
||||
public $type;
|
||||
public $tax_calculator;
|
||||
|
||||
private static $cache_tax_calculator;
|
||||
protected static $cache_tax_calculator;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -420,7 +420,7 @@ class WebserviceOutputBuilderCore
|
||||
* @param $ws_params webserviceParams from the entity
|
||||
* @return string
|
||||
*/
|
||||
private function renderSchema($object, $ws_params)
|
||||
protected function renderSchema($object, $ws_params)
|
||||
{
|
||||
$output = $this->objectRender->renderNodeHeader($ws_params['objectNodeName'], $ws_params);
|
||||
foreach ($ws_params['fields'] as $field_name => $field)
|
||||
@@ -499,7 +499,7 @@ class WebserviceOutputBuilderCore
|
||||
* @param int $depth
|
||||
* @return string
|
||||
*/
|
||||
private function renderField($object, $ws_params, $field_name, $field, $depth)
|
||||
protected function renderField($object, $ws_params, $field_name, $field, $depth)
|
||||
{
|
||||
$output = '';
|
||||
$show_field = true;
|
||||
@@ -560,7 +560,7 @@ class WebserviceOutputBuilderCore
|
||||
* @param $ws_params
|
||||
* @return string
|
||||
*/
|
||||
private function renderAssociations($object, $depth, $associations, $ws_params)
|
||||
protected function renderAssociations($object, $depth, $associations, $ws_params)
|
||||
{
|
||||
$output = $this->objectRender->renderAssociationWrapperHeader();
|
||||
foreach ($associations as $assoc_name => $association)
|
||||
@@ -643,7 +643,7 @@ class WebserviceOutputBuilderCore
|
||||
return $output;
|
||||
}
|
||||
|
||||
private function renderFlatAssociation($object, $depth, $assoc_name, $resource_name, $fields_assoc, $object_assoc, $parent_details)
|
||||
protected function renderFlatAssociation($object, $depth, $assoc_name, $resource_name, $fields_assoc, $object_assoc, $parent_details)
|
||||
{
|
||||
$output = '';
|
||||
$more_attr = array();
|
||||
@@ -721,7 +721,7 @@ class WebserviceOutputBuilderCore
|
||||
$this->specificFields[$field_name] = array('entity'=>$entity_name, 'object' => $object, 'method' => $method, 'type' => gettype($object));
|
||||
return $this;
|
||||
}
|
||||
private function validateObjectAndMethod($object, $method)
|
||||
protected function validateObjectAndMethod($object, $method)
|
||||
{
|
||||
if (is_string($object) && !class_exists($object))
|
||||
throw new WebserviceException ('The object you want to set in '.__METHOD__.' is not allowed.', array(98, 500));
|
||||
@@ -732,7 +732,7 @@ class WebserviceOutputBuilderCore
|
||||
{
|
||||
return $this->specificFields;
|
||||
}
|
||||
private function overrideSpecificField($entity_name, $field_name, $field, $entity_object, $ws_params)
|
||||
protected function overrideSpecificField($entity_name, $field_name, $field, $entity_object, $ws_params)
|
||||
{
|
||||
if (array_key_exists($field_name, $this->specificFields) && $this->specificFields[$field_name]['entity'] == $entity_name)
|
||||
{
|
||||
|
||||
@@ -39,7 +39,7 @@ class WebserviceSpecificManagementImagesCore implements WebserviceSpecificManage
|
||||
/**
|
||||
* @var array The type of images (general, categories, manufacturers, suppliers, stores...)
|
||||
*/
|
||||
private $imageTypes = array(
|
||||
protected $imageTypes = array(
|
||||
'general' => array(
|
||||
'header' => array(),
|
||||
'mail' => array(),
|
||||
@@ -56,12 +56,12 @@ class WebserviceSpecificManagementImagesCore implements WebserviceSpecificManage
|
||||
/**
|
||||
* @var string The image type (product, category, general,...)
|
||||
*/
|
||||
private $imageType = NULL;
|
||||
protected $imageType = null;
|
||||
|
||||
/**
|
||||
* @var int The maximum size supported when uploading images, in bytes
|
||||
*/
|
||||
private $imgMaxUploadSize = 3000000;
|
||||
protected $imgMaxUploadSize = 3000000;
|
||||
|
||||
/**
|
||||
* @var array The list of supported mime types
|
||||
@@ -71,7 +71,7 @@ class WebserviceSpecificManagementImagesCore implements WebserviceSpecificManage
|
||||
/**
|
||||
* @var string The product image declination id
|
||||
*/
|
||||
protected $productImageDeclinationId = NULL;
|
||||
protected $productImageDeclinationId = null;
|
||||
|
||||
/**
|
||||
* @var boolean If the current image management has to manage a "default" image (i.e. "No product available")
|
||||
@@ -150,7 +150,7 @@ class WebserviceSpecificManagementImagesCore implements WebserviceSpecificManage
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
private function manageImages()
|
||||
protected function manageImages()
|
||||
{
|
||||
/*
|
||||
* available cases api/... :
|
||||
@@ -315,7 +315,7 @@ class WebserviceSpecificManagementImagesCore implements WebserviceSpecificManage
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
private function manageGeneralImages()
|
||||
protected function manageGeneralImages()
|
||||
{
|
||||
$path = '';
|
||||
$alternative_path = '';
|
||||
@@ -393,7 +393,7 @@ class WebserviceSpecificManagementImagesCore implements WebserviceSpecificManage
|
||||
break;
|
||||
case 'PUT':
|
||||
|
||||
if ($this->writePostedImageOnDisk($path, NULL, NULL))
|
||||
if ($this->writePostedImageOnDisk($path, null, null))
|
||||
{
|
||||
if ($this->wsObject->urlSegment[2] == 'header')
|
||||
{
|
||||
@@ -410,7 +410,7 @@ class WebserviceSpecificManagementImagesCore implements WebserviceSpecificManage
|
||||
}
|
||||
}
|
||||
|
||||
private function manageDefaultDeclinatedImages($directory, $normal_image_sizes)
|
||||
protected function manageDefaultDeclinatedImages($directory, $normal_image_sizes)
|
||||
{
|
||||
$this->defaultImage = true;
|
||||
// Get the language iso code list
|
||||
@@ -455,7 +455,7 @@ class WebserviceSpecificManagementImagesCore implements WebserviceSpecificManage
|
||||
}
|
||||
}
|
||||
|
||||
private function manageListDeclinatedImages($directory, $normal_image_sizes)
|
||||
protected function manageListDeclinatedImages($directory, $normal_image_sizes)
|
||||
{
|
||||
// Check if method is allowed
|
||||
if ($this->wsObject->method != 'GET')
|
||||
@@ -502,7 +502,7 @@ class WebserviceSpecificManagementImagesCore implements WebserviceSpecificManage
|
||||
return true;
|
||||
}
|
||||
|
||||
private function manageEntityDeclinatedImages($directory, $normal_image_sizes)
|
||||
protected function manageEntityDeclinatedImages($directory, $normal_image_sizes)
|
||||
{
|
||||
$normal_image_size_names = array();
|
||||
foreach ($normal_image_sizes as $normal_image_size)
|
||||
@@ -634,7 +634,7 @@ class WebserviceSpecificManagementImagesCore implements WebserviceSpecificManage
|
||||
* @param string $directory the file path of the root of the images folder type
|
||||
* @return boolean
|
||||
*/
|
||||
private function manageDeclinatedImages($directory)
|
||||
protected function manageDeclinatedImages($directory)
|
||||
{
|
||||
// Get available image sizes for the current image type
|
||||
$normal_image_sizes = ImageType::getImagesTypes($this->imageType);
|
||||
@@ -655,7 +655,7 @@ class WebserviceSpecificManagementImagesCore implements WebserviceSpecificManage
|
||||
|
||||
}
|
||||
|
||||
private function manageProductImages()
|
||||
protected function manageProductImages()
|
||||
{
|
||||
$this->manageDeclinatedImages(_PS_PROD_IMG_DIR_);
|
||||
}
|
||||
@@ -669,7 +669,7 @@ class WebserviceSpecificManagementImagesCore implements WebserviceSpecificManage
|
||||
* @param string $directory
|
||||
* @return boolean
|
||||
*/
|
||||
private function manageDeclinatedImagesCRUD($filename_exists, $filename, $imageSizes, $directory)
|
||||
protected function manageDeclinatedImagesCRUD($filename_exists, $filename, $imageSizes, $directory)
|
||||
{
|
||||
switch ($this->wsObject->method)
|
||||
{
|
||||
@@ -684,7 +684,7 @@ class WebserviceSpecificManagementImagesCore implements WebserviceSpecificManage
|
||||
// Modify the image
|
||||
case 'PUT':
|
||||
if ($filename_exists)
|
||||
if ($this->writePostedImageOnDisk($filename, NULL, NULL, $imageSizes, $directory))
|
||||
if ($this->writePostedImageOnDisk($filename, null, null, $imageSizes, $directory))
|
||||
{
|
||||
$this->imgToDisplay = $filename;
|
||||
return true;
|
||||
@@ -716,7 +716,7 @@ class WebserviceSpecificManagementImagesCore implements WebserviceSpecificManage
|
||||
throw new WebserviceException('This image already exists. To modify it, please use the PUT method', array(65, 400));
|
||||
else
|
||||
{
|
||||
if ($this->writePostedImageOnDisk($filename, NULL, NULL, $imageSizes, $directory))
|
||||
if ($this->writePostedImageOnDisk($filename, null, null, $imageSizes, $directory))
|
||||
return true;
|
||||
else
|
||||
throw new WebserviceException('Unable to save this image', array(66, 500));
|
||||
@@ -735,7 +735,7 @@ class WebserviceSpecificManagementImagesCore implements WebserviceSpecificManage
|
||||
* @param string $parentPath The parent path
|
||||
* @return boolean
|
||||
*/
|
||||
private function deleteImageOnDisk($filePath, $imageTypes = NULL, $parentPath = NULL)
|
||||
protected function deleteImageOnDisk($filePath, $imageTypes = null, $parentPath = null)
|
||||
{
|
||||
$this->wsObject->setOutputEnabled(false);
|
||||
if (file_exists($filePath))
|
||||
@@ -778,13 +778,13 @@ class WebserviceSpecificManagementImagesCore implements WebserviceSpecificManage
|
||||
* @param string $parentPath
|
||||
* @return string
|
||||
*/
|
||||
private function writeImageOnDisk($basePath, $newPath, $destWidth = NULL, $destHeight = NULL, $imageTypes = NULL, $parentPath = NULL)
|
||||
protected function writeImageOnDisk($basePath, $newPath, $destWidth = null, $destHeight = null, $imageTypes = null, $parentPath = null)
|
||||
{
|
||||
list($sourceWidth, $sourceHeight, $type, $attr) = getimagesize($basePath);
|
||||
if (!$sourceWidth)
|
||||
throw new WebserviceException('Image width was null', array(68, 400));
|
||||
if ($destWidth == NULL) $destWidth = $sourceWidth;
|
||||
if ($destHeight == NULL) $destHeight = $sourceHeight;
|
||||
if ($destWidth == null) $destWidth = $sourceWidth;
|
||||
if ($destHeight == null) $destHeight = $sourceHeight;
|
||||
switch ($type)
|
||||
{
|
||||
case 1:
|
||||
@@ -802,14 +802,14 @@ class WebserviceSpecificManagementImagesCore implements WebserviceSpecificManage
|
||||
$widthDiff = $destWidth / $sourceWidth;
|
||||
$heightDiff = $destHeight / $sourceHeight;
|
||||
|
||||
if ($widthDiff > 1 AND $heightDiff > 1)
|
||||
if ($widthDiff > 1 && $heightDiff > 1)
|
||||
{
|
||||
$nextWidth = $sourceWidth;
|
||||
$nextHeight = $sourceHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((int)(Configuration::get('PS_IMAGE_GENERATION_METHOD')) == 2 OR ((int)(Configuration::get('PS_IMAGE_GENERATION_METHOD')) == 0 AND $widthDiff > $heightDiff))
|
||||
if ((int)(Configuration::get('PS_IMAGE_GENERATION_METHOD')) == 2 || ((int)(Configuration::get('PS_IMAGE_GENERATION_METHOD')) == 0 && $widthDiff > $heightDiff))
|
||||
{
|
||||
$nextHeight = $destHeight;
|
||||
$nextWidth = (int)(($sourceWidth * $nextHeight) / $sourceHeight);
|
||||
@@ -888,11 +888,11 @@ class WebserviceSpecificManagementImagesCore implements WebserviceSpecificManage
|
||||
* @param string $parentPath
|
||||
* @return boolean
|
||||
*/
|
||||
private function writePostedImageOnDisk($receptionPath, $destWidth = NULL, $destHeight = NULL, $imageTypes = NULL, $parentPath = NULL)
|
||||
protected function writePostedImageOnDisk($receptionPath, $destWidth = null, $destHeight = null, $imageTypes = null, $parentPath = null)
|
||||
{
|
||||
if ($this->wsObject->method == 'PUT')
|
||||
{
|
||||
if (isset($_FILES['image']['tmp_name']) AND $_FILES['image']['tmp_name'])
|
||||
if (isset($_FILES['image']['tmp_name']) && $_FILES['image']['tmp_name'])
|
||||
{
|
||||
$file = $_FILES['image'];
|
||||
if ($file['size'] > $this->imgMaxUploadSize)
|
||||
@@ -923,7 +923,7 @@ class WebserviceSpecificManagementImagesCore implements WebserviceSpecificManage
|
||||
throw new WebserviceException('Error while uploading image. Please change your server\'s settings', array(74, 400));
|
||||
|
||||
// Try to copy image file to a temporary file
|
||||
if (!$tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS') OR !move_uploaded_file($_FILES['image']['tmp_name'], $tmpName))
|
||||
if (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS')) || !move_uploaded_file($_FILES['image']['tmp_name'], $tmpName))
|
||||
throw new WebserviceException('Error while copying image to the temporary directory', array(75, 400));
|
||||
// Try to copy image file to the image directory
|
||||
else
|
||||
@@ -938,15 +938,15 @@ class WebserviceSpecificManagementImagesCore implements WebserviceSpecificManage
|
||||
}
|
||||
elseif ($this->wsObject->method == 'POST')
|
||||
{
|
||||
if (isset($_FILES['image']['tmp_name']) AND $_FILES['image']['tmp_name'])
|
||||
if (isset($_FILES['image']['tmp_name']) && $_FILES['image']['tmp_name'])
|
||||
{
|
||||
$file = $_FILES['image'];
|
||||
if ($file['size'] > $this->imgMaxUploadSize)
|
||||
throw new WebserviceException(sprintf('The image size is too large (maximum allowed is %d KB)', ($this->imgMaxUploadSize/1000)), array(72, 400));
|
||||
require_once(_PS_ROOT_DIR_.'/images.inc.php');
|
||||
if (ImageManager::validateUpload($file))
|
||||
if ($error = ImageManager::validateUpload($file))
|
||||
throw new WebserviceException('Image upload error : '.$error, array(76, 400));
|
||||
if (isset($file['tmp_name']) AND $file['tmp_name'] != NULL)
|
||||
if (isset($file['tmp_name']) && $file['tmp_name'] != null)
|
||||
{
|
||||
if ($this->imageType == 'products')
|
||||
{
|
||||
@@ -974,7 +974,7 @@ class WebserviceSpecificManagementImagesCore implements WebserviceSpecificManage
|
||||
if (!(Configuration::get('PS_OLD_FILESYSTEM') && file_exists(_PS_PROD_IMG_DIR_.$product->id.'-'.$image->id.'.jpg')))
|
||||
$image->createImgFolder();
|
||||
|
||||
if (!$tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS') OR !move_uploaded_file($file['tmp_name'], $tmpName))
|
||||
if (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS')) || !move_uploaded_file($file['tmp_name'], $tmpName))
|
||||
throw new WebserviceException('An error occurred during the image upload', array(76, 400));
|
||||
elseif (!ImageManager::resize($tmpName, _PS_PROD_IMG_DIR_.$image->getExistingImgPath().'.'.$image->image_format))
|
||||
throw new WebserviceException('An error occurred while copying image', array(76, 400));
|
||||
@@ -990,7 +990,7 @@ class WebserviceSpecificManagementImagesCore implements WebserviceSpecificManage
|
||||
}
|
||||
elseif ($this->imageType == 'categories')
|
||||
{
|
||||
if (!$tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS') OR !move_uploaded_file($file['tmp_name'], $tmpName))
|
||||
if (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS')) || !move_uploaded_file($file['tmp_name'], $tmpName))
|
||||
throw new WebserviceException('An error occurred during the image upload', array(76, 400));
|
||||
elseif (!ImageManager::resize($tmpName, $receptionPath))
|
||||
throw new WebserviceException('An error occurred while copying image', array(76, 400));
|
||||
|
||||
Reference in New Issue
Block a user