Skip to content

Latest commit

 

History

History
2080 lines (1049 loc) · 46 KB

class.LanguageCore.md

File metadata and controls

2080 lines (1049 loc) · 46 KB

Class LanguageCore

Contents

Properties

Methods

Properties

$_LANGUAGES

protected mixed $_LANGUAGES

$_cache_language_installation

protected mixed $_cache_language_installation = null

$_checkedLangs

protected array $_checkedLangs

$active

public boolean $active = true

$countActiveLanguages

protected mixed $countActiveLanguages = array()

$date_format_full

public string $date_format_full = 'Y-m-d H:i:s'

$date_format_lite

public string $date_format_lite = 'Y-m-d'

$definition

public mixed $definition = array('table' => 'lang', 'primary' => 'id_lang', 'fields' => array('name' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true, 'size' => 32), 'iso_code' => array('type' => self::TYPE_STRING, 'validate' => 'isLanguageIsoCode', 'required' => true, 'size' => 2), 'language_code' => array('type' => self::TYPE_STRING, 'validate' => 'isLanguageCode', 'size' => 5), 'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'is_rtl' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'date_format_lite' => array('type' => self::TYPE_STRING, 'validate' => 'isPhpDateFormat', 'required' => true, 'size' => 32), 'date_format_full' => array('type' => self::TYPE_STRING, 'validate' => 'isPhpDateFormat', 'required' => true, 'size' => 32)))

$id

public mixed $id

$is_rtl

public boolean $is_rtl = false

$iso_code

public string $iso_code

$language_code

public string $language_code

$name

public string $name

$translationsFilesAndVars

protected mixed $translationsFilesAndVars = array('fields' => '_FIELDS', 'errors' => '_ERRORS', 'admin' => '_LANGADM', 'pdf' => '_LANGPDF', 'tabs' => 'tabs')

$webserviceParameters

protected mixed $webserviceParameters = array('objectNodeName' => 'language', 'objectsNodeName' => 'languages')

$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()

$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

$image_format

protected string $image_format = 'jpg'

$table

protected mixed $table

$tables

protected mixed $tables = array()

$update_fields

protected array $update_fields = null

Methods

__construct

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

Arguments

  • $id mixed
  • $id_lang mixed

_copyNoneFlag

mixed LanguageCore::_copyNoneFlag($id)

Arguments

  • $id mixed

_generateFiles

mixed LanguageCore::_generateFiles($newIso)

Generate translations files

Arguments

  • $newIso mixed

_getThemesList

\array([theme LanguageCore::_getThemesList()

Return an array of theme

add

mixed LanguageCore::add($autodate, $nullValues, $only_add)

Arguments

  • $autodate mixed
  • $nullValues mixed
  • $only_add 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()

checkAndAddLanguage

mixed LanguageCore::checkAndAddLanguage($iso_code, $lang_pack, $only_add, $params_lang)

Arguments

  • $iso_code mixed
  • $lang_pack mixed
  • $only_add mixed
  • $params_lang mixed

checkFiles

mixed LanguageCore::checkFiles()

checkFilesWithIsoCode

mixed LanguageCore::checkFilesWithIsoCode(mixed $iso_code)

This functions checks if every files exists for the language $iso_code.

Concerned files are those located in translations/$iso_code/ and translations/mails/$iso_code .

Arguments

  • $iso_code mixed

clearCache

mixed ObjectModelCore::clearCache($all)

Arguments

  • $all mixed

copyLanguageData

mixed LanguageCore::copyLanguageData($from, $to)

Arguments

  • $from mixed
  • $to mixed

countActiveLanguages

mixed LanguageCore::countActiveLanguages($id_shop)

Arguments

  • $id_shop mixed

delete

mixed LanguageCore::delete()

deleteImage

boolean ObjectModelCore::deleteImage($force_delete)

Delete images associated with the object

Arguments

  • $force_delete mixed

deleteSelection

mixed LanguageCore::deleteSelection($selection)

Arguments

  • $selection mixed

displayFieldName

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

Arguments

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

downloadAndInstallLanguagePack

mixed LanguageCore::downloadAndInstallLanguagePack($iso, $version, $params, $install)

Arguments

  • $iso mixed
  • $version mixed
  • $params mixed
  • $install mixed

duplicateObject

\new ObjectModelCore::duplicateObject()

Duplicate current object to database

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

getAssociatedShops

array ObjectModelCore::getAssociatedShops()

Get the list of associated id_shop

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

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 LanguageCore::getFields()

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.

getFilesList

mixed LanguageCore::getFilesList($iso_from, $theme_from, $iso_to, $theme_to, $select, $check, $modules)

Arguments

  • $iso_from mixed
  • $theme_from mixed
  • $iso_to mixed
  • $theme_to mixed
  • $select mixed
  • $check mixed
  • $modules mixed

getIdByIso

integer LanguageCore::getIdByIso(string $iso_code)

Return id from iso code

Arguments

  • $iso_code string - Iso code

getIsoById

string LanguageCore::getIsoById(integer $id_lang)

Return iso code from id

Arguments

  • $id_lang integer - Language ID

getIsoIds

array LanguageCore::getIsoIds($active)

Return array (id_lang, iso_code)

Arguments

  • $active mixed

getLanguage

mixed LanguageCore::getLanguage($id_lang)

Arguments

  • $id_lang mixed

getLanguageByIETFCode

mixed LanguageCore::getLanguageByIETFCode($code)

Arguments

  • $code mixed

getLanguageCodeByIso

mixed LanguageCore::getLanguageCodeByIso($iso_code)

Arguments

  • $iso_code mixed

getLanguagePackListContent

mixed LanguageCore::getLanguagePackListContent($iso, $tar)

Arguments

  • $iso mixed
  • $tar mixed

getLanguages

array LanguageCore::getLanguages(boolean $active, $id_shop)

Return available languages

Arguments

  • $active boolean - Select only active languages
  • $id_shop 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

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

isInstalled

mixed LanguageCore::isInstalled($iso_code)

Arguments

  • $iso_code mixed

isLangMultishop

mixed ObjectModelCore::isLangMultishop()

isMultiLanguageActivated

boolean LanguageCore::isMultiLanguageActivated($id_shop)

Check if more on than one language is activated

Arguments

  • $id_shop mixed

isMultiShopField

mixed ObjectModelCore::isMultiShopField($field)

Arguments

  • $field mixed

isMultishop

mixed ObjectModelCore::isMultishop()

loadLanguages

mixed LanguageCore::loadLanguages()

Load all languages in memory for caching

loadUpdateSQL

boolean LanguageCore::loadUpdateSQL()

loadUpdateSQL will create default lang values when you create a new lang, based on default id lang

makeTranslationFields

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

Arguments

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

moveToIso

mixed LanguageCore::moveToIso($newIso)

Move translations files after editing language iso code

Arguments

  • $newIso mixed

recurseDeleteDir

mixed LanguageCore::recurseDeleteDir($dir)

Arguments

  • $dir 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

toggleStatus

mixed LanguageCore::toggleStatus()

update

mixed LanguageCore::update($nullValues)

Arguments

  • $nullValues mixed

updateModulesTranslations

mixed LanguageCore::updateModulesTranslations(array $modules_list)

Arguments

  • $modules_list array

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

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