// Add HelperOptions to generate preferences forms

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@9369 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
tDidierjean
2011-10-14 14:30:07 +00:00
parent 5bd7821915
commit 92565efe43
11 changed files with 1120 additions and 70 deletions
+33
View File
@@ -32,6 +32,10 @@
class HelperCore
{
public $currentIndex;
public $table;
public $token;
public $context;
public function __construct()
{
@@ -202,5 +206,34 @@ class HelperCore
return rtrim($html, ' ');
}
/**
* use translations files to replace english expression.
*
* @param mixed $string term or expression in english
* @param string $class
* @param boolan $addslashes if set to true, the return value will pass through addslashes(). Otherwise, stripslashes().
* @param boolean $htmlentities if set to true(default), the return value will pass through htmlentities($string, ENT_QUOTES, 'utf-8')
* @return string the translation if available, or the english default text.
*/
protected function l($string, $class = 'AdminTab', $addslashes = FALSE, $htmlentities = TRUE)
{
// if the class is extended by a module, use modules/[module_name]/xx.php lang file
$currentClass = get_class($this);
if(Module::getModuleNameFromClass($currentClass))
{
$string = str_replace('\'', '\\\'', $string);
return Module::findTranslation(Module::$classInModule[$currentClass], $string, $currentClass);
}
global $_LANGADM;
if ($class == __CLASS__)
$class = 'AdminTab';
$key = md5(str_replace('\'', '\\\'', $string));
$str = (key_exists(get_class($this).$key, $_LANGADM)) ? $_LANGADM[get_class($this).$key] : ((key_exists($class.$key, $_LANGADM)) ? $_LANGADM[$class.$key] : $string);
$str = $htmlentities ? htmlentities($str, ENT_QUOTES, 'utf-8') : $str;
return str_replace('"', '"', ($addslashes ? addslashes($str) : stripslashes($str)));
}
}