Skip to content

Latest commit

 

History

History
2065 lines (1053 loc) · 47.6 KB

class.CMSCategoryCore.md

File metadata and controls

2065 lines (1053 loc) · 47.6 KB

Class CMSCategoryCore

Contents

Properties

Methods

Properties

$_links

protected mixed $_links = array()

$active

public boolean $active = 1

$date_add

public string $date_add

$date_upd

public string $date_upd

$definition

public mixed $definition = array('table' => 'cms_category', 'primary' => 'id_cms_category', 'multilang' => true, 'fields' => array('active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'required' => true), 'id_parent' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true), 'position' => array('type' => self::TYPE_INT), 'level_depth' => array('type' => self::TYPE_INT), 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), 'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCatalogName', 'required' => true, 'size' => 64), 'link_rewrite' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isLinkRewrite', 'required' => true, 'size' => 64), 'description' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCleanHtml'), 'meta_title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 128), 'meta_description' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255), 'meta_keywords' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255)))

$description

public string $description

$id

public mixed $id

$id_cms_category

public integer $id_cms_category

$id_parent

public integer $id_parent

$level_depth

public integer $level_depth

$link_rewrite

public string $link_rewrite

$meta_description

public string $meta_description

$meta_keywords

public string $meta_keywords

$meta_title

public string $meta_title

$name

public string $name

$position

public integer $position

$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

$webserviceParameters

protected array $webserviceParameters = array()

Methods

__construct

mixed ObjectModelCore::__construct(integer $id, integer $id_lang, integer $id_shop)

Build object

Arguments

  • $id integer - Existing object id in order to load object (optional)
  • $id_lang integer - Required if object is multilingual (optional)
  • $id_shop integer - ID shop for objects with multishop on langs

add

mixed CMSCategoryCore::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()

calcLevelDepth

integer CMSCategoryCore::calcLevelDepth()

Get the number of parent categories

checkBeforeMove

boolean CMSCategoryCore::checkBeforeMove($id_cms_category, integer $id_parent)

Check if CMSCategory can be moved in another one

Arguments

  • $id_cms_category mixed
  • $id_parent integer - Parent candidate

cleanPositions

mixed CMSCategoryCore::cleanPositions($id_category_parent)

Arguments

  • $id_category_parent mixed

clearCache

mixed ObjectModelCore::clearCache($all)

Arguments

  • $all mixed

delete

mixed CMSCategoryCore::delete()

deleteImage

boolean ObjectModelCore::deleteImage($force_delete)

Delete images associated with the object

Arguments

  • $force_delete mixed

deleteSelection

mixed CMSCategoryCore::deleteSelection($categories)

Delete several categories from database

return boolean Deletion result

Arguments

  • $categories mixed

displayFieldName

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

Arguments

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

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

getCategories

array CMSCategoryCore::getCategories(integer $id_lang, boolean $active, $order)

Return available categories

Arguments

  • $id_lang integer - Language ID
  • $active boolean - return only active categories
  • $order mixed

getChildren

mixed CMSCategoryCore::getChildren($id_parent, $id_lang, $active)

Arguments

  • $id_parent mixed
  • $id_lang mixed
  • $active mixed

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 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.

getHomeCategories

array CMSCategoryCore::getHomeCategories(integer $id_lang, boolean $active)

Return main categories

Arguments

  • $id_lang integer - Language ID
  • $active boolean - return only active categories

getLastPosition

mixed CMSCategoryCore::getLastPosition($id_category_parent)

Arguments

  • $id_category_parent mixed

getLink

mixed CMSCategoryCore::getLink(\Link $link)

Arguments

getLinkRewrite

mixed CMSCategoryCore::getLinkRewrite($id_cms_category, $id_lang)

Arguments

  • $id_cms_category mixed
  • $id_lang mixed

getName

mixed CMSCategoryCore::getName($id_lang)

Arguments

  • $id_lang mixed

getParentsCategories

array CMSCategoryCore::getParentsCategories(integer $id_lang)

Get Each parent CMSCategory of this CMSCategory until the root CMSCategory

Arguments

  • $id_lang integer - Language ID

getRecurseCategory

mixed CMSCategoryCore::getRecurseCategory($id_lang, $current, $active, $links, \Link $link)

Arguments

  • $id_lang mixed
  • $current mixed
  • $active mixed
  • $links mixed
  • $link Link

getSimpleCategories

mixed CMSCategoryCore::getSimpleCategories($id_lang)

Arguments

  • $id_lang mixed

getSubCategories

array CMSCategoryCore::getSubCategories(integer $id_lang, boolean $active)

Return current CMSCategory childs

Arguments

  • $id_lang integer - Language ID
  • $active boolean - return only active categories

getTranslationsFields

mixed ObjectModelCore::getTranslationsFields($fields_array)

Arguments

  • $fields_array mixed

getUrlRewriteInformations

mixed CMSCategoryCore::getUrlRewriteInformations($id_category)

Arguments

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

hideCMSCategoryPosition

string CMSCategoryCore::hideCMSCategoryPosition(string $name)

Hide CMSCategory prefix used for position

Arguments

  • $name string - CMSCategory name

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

recurseCMSCategory

mixed CMSCategoryCore::recurseCMSCategory($categories, $current, $id_cms_category, $id_selected, $is_html)

Arguments

  • $categories mixed
  • $current mixed
  • $id_cms_category mixed
  • $id_selected mixed
  • $is_html mixed

recurseLiteCategTree

array CMSCategoryCore::recurseLiteCategTree(integer $max_depth, integer $currentDepth, $id_lang, array $excluded_ids_array, \Link $link)

Recursive scan of subcategories

Arguments

  • $max_depth integer - Maximum depth of the tree (i.e. 2 => 3 levels depth)
  • $currentDepth integer - specify the current depth in the tree (don't use it, only for rucursivity!)
  • $id_lang mixed
  • $excluded_ids_array array - specify a list of ids to exclude of results
  • $link Link

recursiveDelete

mixed CMSCategoryCore::recursiveDelete($to_delete, array|integer $id_cms_category)

Recursively add specified CMSCategory childs to $toDelete array

Arguments

  • $to_delete mixed
  • $id_cms_category array|integer - Parent CMSCategory ID

save

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

Save current object to database (add or update)

Arguments

  • $null_values boolean
  • $autodate boolean

searchByName

array CMSCategoryCore::searchByName(integer $id_lang, string $query, boolean $unrestricted)

Light back office search for categories

Arguments

  • $id_lang integer - Language ID
  • $query string - Searched string
  • $unrestricted boolean - allows search without lang and includes first CMSCategory and exact match

searchByNameAndParentCMSCategoryId

array CMSCategoryCore::searchByNameAndParentCMSCategoryId(integer $id_lang, string $CMSCategory_name, integer $id_parent_CMSCategory)

Retrieve CMSCategory by name and parent CMSCategory id

Arguments

  • $id_lang integer - Language ID
  • $CMSCategory_name string - Searched CMSCategory name
  • $id_parent_CMSCategory integer - parent CMSCategory ID

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

boolean ObjectModelCore::toggleStatus()

Toggle object status in database

update

mixed CMSCategoryCore::update($null_values)

Arguments

  • $null_values mixed

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

mixed CMSCategoryCore::updatePosition($way, $position)

Arguments

  • $way mixed
  • $position mixed

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