';
return $html;
}
/**
* Create a select input field
*
* @param array $values
* @param array $html_options any key => value options
* @param array $select_options
* - key: the array value that will be used as a key in my select (optional)
* - value: the array value that will be used as a label in my select (optional)
* - empty: the label displayed as an empty value (optional)
* - selected: the key corresponding to the selected value (optional)
*
* @return string html content
*/
public static function selectInput(array $values, array $html_options = array(), array $select_options = array())
{
// options management
$options = self::buildHtmlOptions($html_options);
$select_html = '';
return $select_html;
}
/**
* Create html a string containing html options
* eg: buildHtmlOptions(array('name' => 'myInputName', 'id' => 'myInputId'));
* return => 'name="myInputName" id="myInputId"'
*
* @param array $html_options
*
* @return string
*/
protected static function buildHtmlOptions(array $html_options)
{
$html = '';
foreach ($html_options as $html_option => $value)
$html .= Tools::htmlentitiesUTF8($html_option).'="'.Tools::htmlentitiesUTF8($value).'" ';
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)));
}
protected function displayAssoShop($type = 'shop')
{
if (!Shop::isFeatureActive() || (!$this->id && $this->context->shop->getContextType() != Shop::CONTEXT_ALL))
return;
if ($type != 'shop' && $type != 'group_shop')
$type = 'shop';
$assos = array();
$sql = 'SELECT id_'.$type.', `'.pSQL($this->identifier).'`
FROM `'._DB_PREFIX_.pSQL($this->table).'_'.$type.'`';
foreach (Db::getInstance()->executeS($sql) as $row)
$assos[$row['id_'.$type]][] = $row[$this->identifier];
$html = <<
$().ready(function()
{
// Click on "all shop"
$('.input_all_shop').click(function()
{
var checked = $(this).attr('checked');
$('.input_group_shop').attr('checked', checked);
$('.input_shop').attr('checked', checked);
});
// Click on a group shop
$('.input_group_shop').click(function()
{
$('.input_shop[value='+$(this).val()+']').attr('checked', $(this).attr('checked'));
check_all_shop();
});
// Click on a shop
$('.input_shop').click(function()
{
check_group_shop_status($(this).val());
check_all_shop();
});
// Initialize checkbox
$('.input_shop').each(function(k, v)
{
check_group_shop_status($(v).val());
check_all_shop();
});
});
function check_group_shop_status(id_group)
{
var groupChecked = true;
$('.input_shop[value='+id_group+']').each(function(k, v)
{
if (!$(v).attr('checked'))
groupChecked = false;
});
$('.input_group_shop[value='+id_group+']').attr('checked', groupChecked);
}
function check_all_shop()
{
var allChecked = true;
$('.input_group_shop').each(function(k, v)
{
if (!$(v).attr('checked'))
allChecked = false;
});
$('.input_all_shop').attr('checked', allChecked);
}
EOF;
$html .= '