[+] Add the TinyMCE editor on categories description
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@8024 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
+42
-4
@@ -87,7 +87,7 @@ class CategoryCore extends ObjectModel
|
|||||||
protected $fieldsValidate = array('nleft' => 'isUnsignedInt', 'nright' => 'isUnsignedInt', 'level_depth' => 'isUnsignedInt', 'active' => 'isBool', 'id_parent' => 'isUnsignedInt', 'groupBox' => 'isArrayWithIds');
|
protected $fieldsValidate = array('nleft' => 'isUnsignedInt', 'nright' => 'isUnsignedInt', 'level_depth' => 'isUnsignedInt', 'active' => 'isBool', 'id_parent' => 'isUnsignedInt', 'groupBox' => 'isArrayWithIds');
|
||||||
protected $fieldsRequiredLang = array('name', 'link_rewrite');
|
protected $fieldsRequiredLang = array('name', 'link_rewrite');
|
||||||
protected $fieldsSizeLang = array('name' => 64, 'link_rewrite' => 64, 'meta_title' => 128, 'meta_description' => 255, 'meta_keywords' => 255);
|
protected $fieldsSizeLang = array('name' => 64, 'link_rewrite' => 64, 'meta_title' => 128, 'meta_description' => 255, 'meta_keywords' => 255);
|
||||||
protected $fieldsValidateLang = array('name' => 'isCatalogName', 'link_rewrite' => 'isLinkRewrite', 'description' => 'isCleanHtml',
|
protected $fieldsValidateLang = array('name' => 'isCatalogName', 'link_rewrite' => 'isLinkRewrite', 'description' => 'isString',
|
||||||
'meta_title' => 'isGenericName', 'meta_description' => 'isGenericName', 'meta_keywords' => 'isGenericName');
|
'meta_title' => 'isGenericName', 'meta_description' => 'isGenericName', 'meta_keywords' => 'isGenericName');
|
||||||
|
|
||||||
protected $table = 'category';
|
protected $table = 'category';
|
||||||
@@ -132,6 +132,16 @@ class CategoryCore extends ObjectModel
|
|||||||
$fields['date_upd'] = pSQL($this->date_upd);
|
$fields['date_upd'] = pSQL($this->date_upd);
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows to display the category description without HTML tags and slashes
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function getDescriptionClean($description)
|
||||||
|
{
|
||||||
|
return strip_tags(stripslashes($description));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check then return multilingual fields for database interaction
|
* Check then return multilingual fields for database interaction
|
||||||
@@ -140,8 +150,36 @@ class CategoryCore extends ObjectModel
|
|||||||
*/
|
*/
|
||||||
public function getTranslationsFieldsChild()
|
public function getTranslationsFieldsChild()
|
||||||
{
|
{
|
||||||
parent::validateFieldsLang();
|
self::validateFieldsLang();
|
||||||
return parent::getTranslationsFields(array('name', 'description', 'link_rewrite', 'meta_title', 'meta_keywords', 'meta_description'));
|
|
||||||
|
$fieldsArray = array('name', 'link_rewrite', 'meta_title', 'meta_keywords', 'meta_description');
|
||||||
|
$fields = array();
|
||||||
|
$languages = Language::getLanguages(false);
|
||||||
|
$defaultLanguage = Configuration::get('PS_LANG_DEFAULT');
|
||||||
|
foreach ($languages as $language)
|
||||||
|
{
|
||||||
|
$fields[$language['id_lang']]['id_lang'] = $language['id_lang'];
|
||||||
|
$fields[$language['id_lang']][$this->identifier] = (int)($this->id);
|
||||||
|
$fields[$language['id_lang']]['id_shop'] = (int)$this->id_shop; // @todo ID shop in product ???
|
||||||
|
$fields[$language['id_lang']]['description'] = (isset($this->description[$language['id_lang']])) ? addslashes($this->description[$language['id_lang']]) : '';
|
||||||
|
foreach ($fieldsArray as $field)
|
||||||
|
{
|
||||||
|
if (!Validate::isTableOrIdentifier($field))
|
||||||
|
die(Tools::displayError());
|
||||||
|
|
||||||
|
/* Check fields validity */
|
||||||
|
if (isset($this->{$field}[$language['id_lang']]) AND !empty($this->{$field}[$language['id_lang']]))
|
||||||
|
$fields[$language['id_lang']][$field] = pSQL($this->{$field}[$language['id_lang']]);
|
||||||
|
elseif (in_array($field, $this->fieldsRequiredLang))
|
||||||
|
{
|
||||||
|
if ($this->{$field} != '')
|
||||||
|
$fields[$language['id_lang']][$field] = pSQL($this->{$field}[$defaultLanguage]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$fields[$language['id_lang']][$field] = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function add($autodate = true, $nullValues = false)
|
public function add($autodate = true, $nullValues = false)
|
||||||
@@ -223,7 +261,7 @@ class CategoryCore extends ObjectModel
|
|||||||
'id' => (int)$this->id_category,
|
'id' => (int)$this->id_category,
|
||||||
'link' => Context::getContext()->link->getCategoryLink($this->id, $this->link_rewrite),
|
'link' => Context::getContext()->link->getCategoryLink($this->id, $this->link_rewrite),
|
||||||
'name' => $this->name,
|
'name' => $this->name,
|
||||||
'desc'=> $this->description,
|
'desc'=> Category::getDescriptionClean($this->description),
|
||||||
'children' => $children
|
'children' => $children
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user