Skip to content

Latest commit

 

History

History
2046 lines (1044 loc) · 45.8 KB

class.ImageCore.md

File metadata and controls

2046 lines (1044 loc) · 45.8 KB

Class ImageCore

Contents

Properties

Methods

Properties

$_cacheGetSize

protected mixed $_cacheGetSize = array()

$access_rights

protected integer $access_rights = 509

$cover

public boolean $cover

$definition

public mixed $definition = array('table' => 'image', 'primary' => 'id_image', 'multilang' => true, 'fields' => array('id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), 'position' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), 'cover' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'shop' => true), 'legend' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 128)))

$existing_path

protected string $existing_path

$folder

protected string $folder

$id

public mixed $id

$id_image

public integer $id_image

$id_product

public integer $id_product

$image_format

public string $image_format = 'jpg'

$legend

public string $legend

$position

public integer $position

$source_index

public string $source_index

$db

protected \Db $db = false

$def

protected array $def

$fieldsRequired

protected mixed $fieldsRequired = array()

$fieldsRequiredDatabase

protected mixed $fieldsRequiredDatabase = null

$fieldsRequiredLang

protected mixed $fieldsRequiredLang = array()

$fieldsSize

protected mixed $fieldsSize = array()

$fieldsSizeLang

protected mixed $fieldsSizeLang = array()

$fieldsValidate

protected mixed $fieldsValidate = array()

$fieldsValidateLang

protected mixed $fieldsValidateLang = array()

$force_id

public \boolean, $force_id = false

$get_shop_from_context

protected mixed $get_shop_from_context = true

$id_lang

protected integer $id_lang = null

$id_shop

protected mixed $id_shop = null

$id_shop_list

public mixed $id_shop_list = null

$identifier

protected mixed $identifier

$image_dir

protected string $image_dir = null

$table

protected mixed $table

$tables

protected mixed $tables = array()

$update_fields

protected array $update_fields = null

$webserviceParameters

protected array $webserviceParameters = array()

Methods

__construct

mixed ImageCore::__construct($id, $id_lang)

Arguments

  • $id mixed
  • $id_lang mixed

add

mixed ImageCore::add($autodate, $null_values)

Arguments

  • $autodate mixed
  • $null_values mixed

addFieldsRequiredDatabase

mixed ObjectModelCore::addFieldsRequiredDatabase($fields)

Arguments

  • $fields mixed

associateTo

boolean ObjectModelCore::associateTo(integer|array $id_shops)

This function associate an item to its context

Arguments

  • $id_shops integer|array

cacheFieldsRequiredDatabase

mixed ObjectModelCore::cacheFieldsRequiredDatabase()

clearCache

mixed ObjectModelCore::clearCache($all)

Arguments

  • $all mixed

clearTmpDir

mixed ImageCore::clearTmpDir()

Clear all images in tmp dir

createImgFolder

boolean ImageCore::createImgFolder()

Create parent folders for the image in the new filesystem

delete

mixed ImageCore::delete()

deleteAllImages

boolean ImageCore::deleteAllImages(string $path, string $format)

Recursively deletes all product images in the given folder tree and removes empty folders.

Arguments

  • $path string - folder containing the product images to delete
  • $format string - image format

deleteCover

boolean ImageCore::deleteCover(integer $id_product)

Delete product cover

Arguments

  • $id_product integer - Product ID

deleteImage

mixed ImageCore::deleteImage($force_delete)

Delete the product image from disk and remove the containing folder if empty Handles both legacy and new image filesystems

Arguments

  • $force_delete mixed

deleteProductAttributeImage

mixed ImageCore::deleteProductAttributeImage()

Delete Image - Product attribute associations for this image

deleteSelection

boolean ObjectModelCore::deleteSelection(array $selection)

Delete several objects from database

Arguments

  • $selection array

displayFieldName

mixed ObjectModelCore::displayFieldName($field, $class, $htmlentities, \Context $context)

Arguments

  • $field mixed
  • $class mixed
  • $htmlentities mixed
  • $context Context

duplicateAttributeImageAssociations

boolean ImageCore::duplicateAttributeImageAssociations($combination_images)

Duplicate product attribute image associations

Arguments

  • $combination_images mixed

duplicateObject

\new ObjectModelCore::duplicateObject()

Duplicate current object to database

duplicateProductImages

mixed ImageCore::duplicateProductImages(integer $id_product_old, boolean $id_product_new, $combination_images)

Copy images from a product to another

Arguments

  • $id_product_old integer - Source product ID
  • $id_product_new boolean - Destination product ID
  • $combination_images mixed

duplicateShops

mixed ObjectModelCore::duplicateShops($id)

Arguments

  • $id mixed

existsInDatabase

boolean ObjectModelCore::existsInDatabase(integer $id_entity, string $table)

Specify if an ObjectModel is already in database

Arguments

  • $id_entity integer
  • $table string

formatFields

array ObjectModelCore::formatFields(integer $type, integer $id_lang)

Arguments

  • $type integer - FORMAT_COMMON or FORMAT_LANG or FORMAT_SHOP
  • $id_lang integer - If this parameter is given, only take lang fields

formatValue

mixed ObjectModelCore::formatValue(mixed $value, integer $type, $with_quotes, $purify)

Format a data

Arguments

  • $value mixed
  • $type integer
  • $with_quotes mixed
  • $purify mixed

getAllImages

array ImageCore::getAllImages()

Return Images

getAssociatedShops

array ObjectModelCore::getAssociatedShops()

Get the list of associated id_shop

getCover

boolean ImageCore::getCover(integer $id_product)

Get product cover

Arguments

  • $id_product integer - Product ID

getDefinition

array ObjectModelCore::getDefinition(string $class, string $field)

Get object definition

Arguments

  • $class string - Name of object
  • $field string - Name of field if we want the definition of one field only

getExistingImgPath

mixed ImageCore::getExistingImgPath()

Returns image path in the old or in the new filesystem

@ returns string image path

getFieldByLang

mixed ObjectModelCore::getFieldByLang($field_name, null $id_lang)

Return the field value for the specified language if the field is multilang, else the field value.

Arguments

  • $field_name mixed
  • $id_lang null

getFields

array ObjectModelCore::getFields()

Prepare fields for ObjectModel class (add, update) All fields are verified (pSQL, intval.

..)

getFieldsLang

array ObjectModelCore::getFieldsLang()

Prepare multilang fields

getFieldsRequiredDatabase

mixed ObjectModelCore::getFieldsRequiredDatabase($all)

Arguments

  • $all mixed

getFieldsShop

array ObjectModelCore::getFieldsShop()

Prepare fields for multishop Fields are not validated here, we considere they are already validated in getFields() method, this not the best solution but this is the only one possible for retro compatibility.

getHeight

mixed ImageCore::getHeight($params, $smarty)

Arguments

  • $params mixed
  • $smarty mixed

getHighestPosition

integer ImageCore::getHighestPosition(integer $id_product)

Return highest position of images for a product

Arguments

  • $id_product integer - Product ID

getImages

array ImageCore::getImages(integer $id_lang, integer $id_product, integer $id_product_attribute)

Return available images for a product

Arguments

  • $id_lang integer - Language ID
  • $id_product integer - Product ID
  • $id_product_attribute integer - Product Attribute ID

getImagesTotal

integer ImageCore::getImagesTotal(integer $id_product)

Return number of images for a product

Arguments

  • $id_product integer - Product ID

getImgFolder

string ImageCore::getImgFolder()

Returns the path to the folder containing the image in the new filesystem

getImgFolderStatic

string ImageCore::getImgFolderStatic(mixed $id_image)

Returns the path to the folder containing the image in the new filesystem

Arguments

  • $id_image mixed

getImgPath

string ImageCore::getImgPath()

Returns the path to the image without file extension

getPathForCreation

string ImageCore::getPathForCreation()

Returns the path where a product image should be created (without file format)

getSize

mixed ImageCore::getSize($type)

Arguments

  • $type mixed

getTranslationsFields

mixed ObjectModelCore::getTranslationsFields($fields_array)

Arguments

  • $fields_array mixed

getValidationRules

array ObjectModelCore::getValidationRules(string $class)

Returns object validation rules (fields validity)

Arguments

  • $class string - Child class name for static use (optional)

getWebserviceObjectList

mixed ObjectModelCore::getWebserviceObjectList($sql_join, $sql_filter, $sql_sort, $sql_limit)

Arguments

  • $sql_join mixed
  • $sql_filter mixed
  • $sql_sort mixed
  • $sql_limit mixed

getWebserviceParameters

mixed ObjectModelCore::getWebserviceParameters($ws_params_attribute_name)

Arguments

  • $ws_params_attribute_name mixed

getWidth

mixed ImageCore::getWidth($params, $smarty)

Arguments

  • $params mixed
  • $smarty mixed

hasMultishopEntries

boolean ObjectModelCore::hasMultishopEntries()

Check if there is more than one entries in associated shop table for current entity

hydrate

mixed ObjectModelCore::hydrate(array $data, integer $id_lang)

Fill an object with given data. Data must be an array with this syntax: array(objProperty => value, objProperty2 => value, etc.)

Arguments

  • $data array
  • $id_lang integer

hydrateCollection

array ObjectModelCore::hydrateCollection(string $class, array $datas, integer $id_lang)

Fill (hydrate) a list of objects in order to get a collection of these objects

Arguments

  • $class string - Class of objects to hydrate
  • $datas array - List of data (multi-dimensional array)
  • $id_lang integer

isAssociatedToShop

boolean ObjectModelCore::isAssociatedToShop(integer $id_shop)

Check if current object is associated to a shop

Arguments

  • $id_shop integer

isCurrentlyUsed

boolean ObjectModelCore::isCurrentlyUsed(string $table, boolean $has_active_column)

This method is allow to know if a entity is currently used

Arguments

  • $table string - name of table linked to entity
  • $has_active_column boolean - true if the table has an active column

isLangMultishop

mixed ObjectModelCore::isLangMultishop()

isMultiShopField

mixed ObjectModelCore::isMultiShopField($field)

Arguments

  • $field mixed

isMultishop

mixed ObjectModelCore::isMultishop()

makeTranslationFields

mixed ObjectModelCore::makeTranslationFields($fields, $fields_array, $id_language)

Arguments

  • $fields mixed
  • $fields_array mixed
  • $id_language mixed

moveToNewFileSystem

mixed ImageCore::moveToNewFileSystem($max_execution_time)

Move all legacy product image files from the image folder root to their subfolder in the new filesystem.

If max_execution_time is provided, stops before timeout and returns string "timeout". If any image cannot be moved, stops and returns "false"

Arguments

  • $max_execution_time mixed

positionImage

mixed ImageCore::positionImage(integer $position, boolean $direction)

Reposition image

Arguments

  • $position integer - Position
  • $direction boolean - Direction

replaceAttributeImageAssociationId

mixed ImageCore::replaceAttributeImageAssociationId($combination_images, $saved_id, $id_image)

Arguments

  • $combination_images mixed
  • $saved_id mixed
  • $id_image mixed

save

boolean ObjectModelCore::save(boolean $null_values, boolean $autodate)

Save current object to database (add or update)

Arguments

  • $null_values boolean
  • $autodate boolean

setDefinitionRetrocompatibility

mixed ObjectModelCore::setDefinitionRetrocompatibility()

Retrocompatibility for classes without $definition static Remove this in 1.6 !

setFieldsToUpdate

mixed ObjectModelCore::setFieldsToUpdate(array $fields)

Set a list of specific fields to update array(field1 => true, field2 => false, langfield1 => array(1 => true, 2 => false))

Arguments

  • $fields array

testFileSystem

boolean ImageCore::testFileSystem()

Try to create and delete some folders to check if moving images to new file system will be possible

toggleStatus

boolean ObjectModelCore::toggleStatus()

Toggle object status in database

update

boolean ObjectModelCore::update(boolean $null_values)

Update current object to database

Arguments

  • $null_values boolean

updateMultishopTable

boolean ObjectModelCore::updateMultishopTable(string $classname, array $data, string $where, string $specific_where)

Update a table and splits the common datas and the shop datas

Arguments

  • $classname string
  • $data array
  • $where string
  • $specific_where string - Only executed for common table

updatePosition

integer ImageCore::updatePosition(integer $way, integer $position)

Change an image position and update relative positions

Arguments

  • $way integer - position is moved up if 0, moved down if 1
  • $position integer - new position of the moved image

validateControler

mixed ObjectModelCore::validateControler($htmlentities)

TODO: refactor rename all calls to this to validateController

Arguments

  • $htmlentities mixed

validateController

mixed ObjectModelCore::validateController($htmlentities)

Arguments

  • $htmlentities mixed

validateField

boolean|string ObjectModelCore::validateField(string $field, mixed $value, integer $id_lang, $skip, $human_errors)

Validate a single field

Arguments

  • $field string - Field name
  • $value mixed - Field value
  • $id_lang integer
  • $skip mixed
  • $human_errors mixed

validateFields

boolean|string ObjectModelCore::validateFields(boolean $die, boolean $error_return)

Check for fields validity before database interaction

Arguments

  • $die boolean
  • $error_return boolean

validateFieldsLang

boolean|string ObjectModelCore::validateFieldsLang(boolean $die, boolean $error_return)

Check for multilingual fields validity before database interaction

Arguments

  • $die boolean
  • $error_return boolean

validateFieldsRequiredDatabase

mixed ObjectModelCore::validateFieldsRequiredDatabase($htmlentities)

Arguments

  • $htmlentities mixed