// Shop association area use tpl file

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@11082 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
mDeflotte
2011-12-09 15:40:02 +00:00
parent fa4a59884c
commit eb40bcf854
6 changed files with 189 additions and 165 deletions
+37 -8
View File
@@ -293,8 +293,8 @@ class HelperCore
}
global $_LANGADM;
if ($class == __CLASS__)
$class = 'AdminTab';
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);
@@ -302,7 +302,14 @@ class HelperCore
return str_replace('"', '"', ($addslashes ? addslashes($str) : stripslashes($str)));
}
protected function displayAssoShop($type = 'shop')
/**
* Render an area to determinate shop association
*
* @param string $type 'shop' or 'group_shop'
*
* @return string
*/
public function renderAssoShop($type = 'shop')
{
if (!Shop::isFeatureActive() || (!$this->id && $this->context->shop->getContextType() != Shop::CONTEXT_ALL))
return;
@@ -311,12 +318,33 @@ class HelperCore
$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];
if ((int)$this->id)
{
$sql = 'SELECT id_'.$type.', `'.pSQL($this->identifier).'`
FROM `'._DB_PREFIX_.pSQL($this->table).'_'.$type.'`
WHERE `'.pSQL($this->identifier).'` = '.(int)$this->id;
foreach (Db::getInstance()->executeS($sql) as $row)
$assos[$row['id_'.$type]] = $row['id_'.$type];
}
$tpl = $this->createTemplate('helper/assoshop.tpl');
$tpl->assign(array(
'input' => array(
'type' => $type,
'values' => Shop::getTree(),
),
'fields_value' => array(
'shop' => $assos
),
'form_id' => $this->id,
'table' => $this->table
));
return $tpl->fetch();
/*
//$page = $this->context->smarty->fetch($tpl);
$html = <<<EOF
<script type="text/javascript">
$().ready(function()
@@ -404,6 +432,7 @@ EOF;
}
$html .= '</table></div>';
return $html;
*/
}
}