// Merge -> revision 8059

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@8062 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
rMalie
2011-08-16 09:10:40 +00:00
parent bbb8acc0de
commit 21ca4d15d7
31 changed files with 188 additions and 84 deletions
+1 -1
View File
@@ -199,7 +199,7 @@ class GroupReductionCore extends ObjectModel
WHERE pgr.`id_product` = '.(int)$id_product_old
);
if (!$row)
return false;
return true;
$query = 'INSERT INTO `'._DB_PREFIX_.'product_group_reduction_cache` (`id_product`, `id_group`, `reduction`) VALUES ';
$query .= '('.(int)($id_product).', '.(int)($row['id_group']).', '.(float)($row['reduction']).')';
+19 -7
View File
@@ -59,8 +59,11 @@ class HelperCore
* @param type $input_name name of input
* @return string
*/
public static function renderAdminCategorieTree($trads, $selected_cat = array(), $input_name = 'categoryBox')
public static function renderAdminCategorieTree($trads, $selected_cat = array(), $input_name = 'categoryBox', $use_radio = false)
{
if (!$use_radio)
$input_name = $input_name.'[]';
$html = '
<script src="../js/jquery/treeview/jquery.treeview.js" type="text/javascript"></script>
<script src="../js/jquery/treeview/jquery.treeview.async.js" type="text/javascript"></script>
@@ -68,11 +71,18 @@ class HelperCore
<script src="../js/admin-categories-tree.js" type="text/javascript"></script>
<script type="text/javascript">
var inputName = "'.$input_name.'";
var selectedCat = "'.implode(',', array_keys($selected_cat)).'";
</script>
<script type="text/javascript">
';
if (sizeof($selected_cat) > 0)
{
if (isset($selected_cat[0]))
$html .= 'var selectedCat = "'.implode(',', $selected_cat).'"';
else
$html .= 'var selectedCat = "'.implode(',', array_keys($selected_cat)).'"';
}
$html .= '
var selectedLabel = \''.$trads['selected'].'\';
var home = \''.$trads['Home'].'\';
var use_radio = '.(int)$use_radio.';
</script>
<link type="text/css" rel="stylesheet" href="../css/jquery.treeview.css" />
';
@@ -81,8 +91,10 @@ class HelperCore
<div style="background-color:#F4E6C9; width:99%;padding:5px 0 5px 5px;">
<a href="#" id="collapse_all" >'.$trads['Collapse All'].'</a>
- <a href="#" id="expand_all" >'.$trads['Expand All'].'</a>
'.(!$use_radio ? '
- <a href="#" id="check_all" >'.$trads['Check All'].'</a>
- <a href="#" id="uncheck_all" >'.$trads['Uncheck All'].'</a>
' : '').'
</div>
';
@@ -92,14 +104,14 @@ class HelperCore
if (is_array($cat))
{
if ($cat['id_category'] != 1)
$html .= '<input type="hidden" name="'.$input_name.'[]" value="'.$cat['id_category'].'" >';
$html .= '<input type="hidden" name="'.$input_name.'" value="'.$cat['id_category'].'" >';
else
$home_is_selected = true;
}
else
{
if ($cat != 1)
$html .= '<input type="hidden" name="'.$input_name.'[]" value="'.$cat.'" >';
$html .= '<input type="hidden" name="'.$input_name.'" value="'.$cat.'" >';
else
$home_is_selected = true;
}
@@ -107,7 +119,7 @@ class HelperCore
$html .= '
<ul id="categories-treeview" class="filetree">
<li id="1" class="hasChildren">
<span class="folder"> <input type="checkbox" name="'.$input_name.'[]" value="1" '.($home_is_selected ? 'checked' : '').' onclick="clickOnCategoryBox($(this));" /> '.$trads['Home'].'</span>
<span class="folder"> <input type="'.(!$use_radio ? 'checkbox' : 'radio').'" name="'.$input_name.'" value="1" '.($home_is_selected ? 'checked' : '').' onclick="clickOnCategoryBox($(this));" /> '.$trads['Home'].'</span>
<ul>
<li><span class="placeholder">&nbsp;</span></li>
</ul>
+31 -1
View File
@@ -117,13 +117,43 @@ class LanguageCore extends ObjectModel
if (file_exists(_PS_MAIL_DIR_.$this->iso_code))
rename(_PS_MAIL_DIR_.$this->iso_code, _PS_MAIL_DIR_.$newIso);
foreach (Module::getModulesDirOnDisk() as $moduleDir) {
$modulesList = Module::getModulesDirOnDisk();
foreach ($modulesList as $moduleDir)
{
if (file_exists(_PS_MODULE_DIR_.$moduleDir.'/mails/'.$this->iso_code))
rename(_PS_MODULE_DIR_.$moduleDir.'/mails/'.$this->iso_code, _PS_MODULE_DIR_.$moduleDir.'/mails/'.$newIso);
if (file_exists(_PS_MODULE_DIR_.$moduleDir.'/'.$this->iso_code.'.php'))
rename(_PS_MODULE_DIR_.$moduleDir.'/'.$this->iso_code.'.php', _PS_MODULE_DIR_.$moduleDir.'/'.$newIso.'.php');
}
foreach ($this->_getThemesList() as $theme => $data)
{
if (file_exists(_PS_ALL_THEMES_DIR_.$theme.'/lang/'.$this->iso_code.'.php'))
rename(_PS_ALL_THEMES_DIR_.$theme.'/lang/'.$this->iso_code.'.php', _PS_ALL_THEMES_DIR_.$theme.'/lang/'.$newIso.'.php');
if (file_exists(_PS_ALL_THEMES_DIR_.$theme.'/mails/'.$this->iso_code))
rename(_PS_ALL_THEMES_DIR_.$theme.'/mails/'.$this->iso_code, _PS_ALL_THEMES_DIR_.$theme.'/mails/'.$newIso);
foreach ($modulesList as $module)
if (file_exists(_PS_ALL_THEMES_DIR_.$theme.'/modules/'.$module.'/'.$this->iso_code.'.php'))
rename(_PS_ALL_THEMES_DIR_.$theme.'/modules/'.$module.'/'.$this->iso_code.'.php', _PS_ALL_THEMES_DIR_.$theme.'/modules/'.$module.'/'.$newIso.'.php');
}
}
/**
* Return an array with themes and thumbnails
*
* @return array
*/
private function _getThemesList()
{
$dir = opendir(_PS_ALL_THEMES_DIR_);
while ($folder = readdir($dir))
if ($folder != '.' AND $folder != '..' AND file_exists(_PS_ALL_THEMES_DIR_.'/'.$folder.'/preview.jpg'))
$themes[$folder]['name'] = $folder;
closedir($dir);
return isset($themes) ? $themes : array();
}
public function add($autodate = true, $nullValues = false)
+14 -15
View File
@@ -549,7 +549,7 @@ class ProductCore extends ObjectModel
if ($die) die (Tools::displayError().' ('.get_class($this).'->description: length > '.$limit.' for language '.$k.')');
return $errorReturn ? get_class($this).'->'.Tools::displayError('description: length >').' '.$limit.' '.Tools::displayError('for language').' '.$k : false;
}
return $this->validateFieldsLang($die, $errorReturn);
return parent::validateFieldsLang($die, $errorReturn);
}
public function delete()
@@ -880,13 +880,14 @@ class ProductCore extends ObjectModel
$price = str_replace(',', '.', $price);
$weight = str_replace(',', '.', $weight);
Db::getInstance()->AutoExecute(_DB_PREFIX_.'product_attribute', array(
'id_product' => $this->id,
'id_product' => (int)$this->id,
'price' => (float)$price,
'ecotax' => (float)$ecotax,
'quantity' => (int)$quantity,
'weight' => $weight ? (float)$weight : 0,
'unit_price_impact' => $unit_impact ? (float)$unit_impact : 0,
'quantity' => 0,
'weight' => ($weight ? (float)$weight : 0),
'unit_price_impact' => ($unit_impact ? (float)$unit_impact : 0),
'reference' => pSQL($reference),
'supplier_reference' => pSQL($supplier_reference),
'location' => pSQL($location),
@@ -894,12 +895,16 @@ class ProductCore extends ObjectModel
'upc' => pSQL($upc),
'default_on' => (int)$default
), 'INSERT');
$id_product_attribute = Db::getInstance()->Insert_ID();
$this->setStock($quantity, $id_product_attribute);
Product::updateDefaultAttribute($this->id);
if (!$id_product_attribute)
return false;
$this->addStockMvt((int)$quantity, 1, $id_product_attribute);
if (empty($id_images))
return (int)($id_product_attribute);
$query = 'INSERT INTO `'._DB_PREFIX_.'product_attribute_image` (`id_product_attribute`, `id_image`) VALUES ';
@@ -2432,23 +2437,18 @@ class ProductCore extends ObjectModel
if (!$context)
$context = Context::getContext();
$sql = 'SELECT p.`id_product`, pl.`name`, pl.`link_rewrite`, p.`weight`, p.`active`, p.`ecotax`, i.`id_image`, p.`reference`, p.`cache_is_pack`,
il.`legend`, m.`name` AS manufacturer_name, tl.`name` AS tax_name
$sql = 'SELECT p.`id_product`, pl.`name`, p.`active`, p.`reference`, m.`name` AS manufacturer_name, stock.quantity
FROM `'._DB_PREFIX_.'category_product` cp
LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = cp.`id_product`
'.$context->shop->sqlAsso('product', 'p').'
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$id_lang.$context->shop->sqlLang('pl').')
LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group`
AND tr.`id_country` = '.(int)Context::getContext()->country->id.'
AND tr.`id_state` = 0)
LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = tr.`id_tax`)
LEFT JOIN `'._DB_PREFIX_.'tax_lang` tl ON (t.`id_tax` = tl.`id_tax` AND tl.`id_lang` = '.(int)$id_lang.')
LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON m.`id_manufacturer` = p.`id_manufacturer`
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product`) AND i.`cover` = 1
LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang.')
LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON pa.`id_product` = p.`id_product`
'.Product::sqlStock('p', 'pa', false, $context->shop).'
WHERE pl.`name` LIKE \'%'.pSQL($query).'%\'
OR p.`reference` LIKE \'%'.pSQL($query).'%\'
OR p.`supplier_reference` LIKE \'%'.pSQL($query).'%\'
OR pa.`reference` LIKE \'%'.pSQL($query).'%\'
GROUP BY `id_product`
ORDER BY pl.`name` ASC';
$result = Db::getInstance()->ExecuteS($sql);
@@ -2460,7 +2460,6 @@ class ProductCore extends ObjectModel
foreach ($result AS $row)
{
$row['price'] = Product::getPriceStatic($row['id_product'], true, NULL, 2);
$row['quantity'] = Product::getQuantity($row['id_product'], NULL, $row['cache_is_pack']);
$resultsArray[] = $row;
}
return $resultsArray;
+8 -4
View File
@@ -646,6 +646,7 @@ class ToolsCore
/* Categories specifics meta tags */
elseif ($id_category = self::getValue('id_category'))
{
$page_number = self::getValue('p');
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
SELECT `name`, `meta_title`, `meta_description`, `meta_keywords`, `description`
FROM `'._DB_PREFIX_.'category_lang`
@@ -654,13 +655,16 @@ class ToolsCore
{
if (empty($row['meta_description']))
$row['meta_description'] = strip_tags($row['description']);
return self::completeMetaTags($row, $row['name']);
$row['meta_title'] .= $row['name'] . (!empty($page_number) ? ' ('.$page_number.')' : '');
$row['meta_title'] .= ' - '.Configuration::get('PS_SHOP_NAME');
return self::completeMetaTags($row, $row['meta_title']);
}
}
/* Manufacturers specifics meta tags */
elseif ($id_manufacturer = self::getValue('id_manufacturer'))
{
$page_number = self::getValue('p');
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
SELECT `name`, `meta_title`, `meta_description`, `meta_keywords`
FROM `'._DB_PREFIX_.'manufacturer_lang` ml
@@ -670,9 +674,9 @@ class ToolsCore
{
if (empty($row['meta_description']))
$row['meta_description'] = strip_tags($row['meta_description']);
if (!empty($row['meta_title']))
$row['meta_title'] = $row['meta_title'].' - '.Configuration::get('PS_SHOP_NAME');
return self::completeMetaTags($row, $row['name']);
$row['meta_title'] .= $row['name'] . (!empty($page_number) ? ' ('.$page_number.')' : '');
$row['meta_title'] .= ' - '.Configuration::get('PS_SHOP_NAME');
return self::completeMetaTags($row, $row['meta_title']);
}
}