// Remove old code and calls to AdminCatalog

This commit is contained in:
tDidierjean
2012-01-10 17:16:54 +00:00
parent 9d4dac5363
commit 2560f50da8
9 changed files with 14 additions and 406 deletions
-108
View File
@@ -71,122 +71,14 @@ function displayJavascriptAlert($s)
echo '<script type="text/javascript">alert(\''.addslashes($s).'\');</script>';
}
if (Tools::isSubmit('ajaxProductManufacturers'))
{
AdminTab::$currentIndex = 'index.php?tab=AdminCatalog';
$manufacturers = Manufacturer::getManufacturers();
$jsonArray = array();
if ($manufacturers)
foreach ($manufacturers AS $manufacturer)
$jsonArray[] = '{"optionValue": "'.$manufacturer['id_manufacturer'].'", "optionDisplay": "'.htmlspecialchars(trim($manufacturer['name'])).'"}';
die('['.implode(',', $jsonArray).']');
}
if (Tools::isSubmit('ajaxReferrers'))
{
require(_PS_CONTROLLER_DIR_.'admin/AdminReferrersController.php');
}
if (Tools::isSubmit('ajaxProductSuppliers'))
{
AdminTab::$currentIndex = 'index.php?tab=AdminCatalog';
$suppliers = Supplier::getSuppliers();
if ($suppliers)
{
$jsonArray = array();
foreach ($suppliers AS $supplier)
$jsonArray[] = '{"optionValue": "'.$supplier['id_supplier'].'", "optionDisplay": "'.htmlspecialchars(trim($supplier['name'])).'"}';
die('['.implode(',', $jsonArray).']');
}
}
if (Tools::isSubmit('ajaxProductAccessories'))
{
AdminTab::$currentIndex = 'index.php?tab=AdminCatalog';
$jsonArray = array();
$products = Db::getInstance()->executeS('
SELECT p.`id_product`, pl.`name`
FROM `'._DB_PREFIX_.'product` p
NATURAL LEFT JOIN `'._DB_PREFIX_.'product_lang` pl
WHERE pl.`id_lang` = '.(int)(Tools::getValue('id_lang')).'
'.Context::getContext()->shop->addSqlRestrictionOnLang('pl').'
AND p.`id_product` != '.(int)(Tools::getValue('id_product')).'
AND p.`id_product` NOT IN (
SELECT a.`id_product_2`
FROM `'._DB_PREFIX_.'accessory` a
WHERE a.`id_product_1` = '.(int)(Tools::getValue('id_product')).')
ORDER BY pl.`name`');
foreach ($products AS $accessory)
$jsonArray[] = '{"value: "'.(int)($accessory['id_product']).'-'.addslashes($accessory['name']).'", "text":"'.(int)($accessory['id_product']).' - '.addslashes($accessory['name']).'"}';
die('['.implode(',', $jsonArray).']');
}
if (Tools::isSubmit('ajaxDiscountCustomers'))
{
AdminTab::$currentIndex = 'index.php?tab=AdminDiscounts';
$jsonArray = array();
$filter = Tools::getValue('filter');
if (Validate::isBool_Id($filter))
$filterArray = explode('_', $filter);
$customers = Db::getInstance()->executeS('
SELECT `id_customer`, `email`, CONCAT(`lastname`, \' \', `firstname`) as name
FROM `'._DB_PREFIX_.'customer`
WHERE `deleted` = 0 AND is_guest = 0
AND '.(Validate::isUnsignedInt($filter) ? '`id_customer` = '.(int)($filter) : '(`email` LIKE "%'.pSQL($filter).'%"
'.((Validate::isBool_Id($filter) AND $filterArray[0] == 0) ? 'OR `id_customer` = '.(int)($filterArray[1]) : '').'
'.(Validate::isUnsignedInt($filter) ? '`id_customer` = '.(int)($filter) : '').'
OR CONCAT(`firstname`, \' \', `lastname`) LIKE "%'.pSQL($filter).'%"
OR CONCAT(`lastname`, \' \', `firstname`) LIKE "%'.pSQL($filter).'%")').'
ORDER BY CONCAT(`lastname`, \' \', `firstname`) ASC
LIMIT 50');
$groups = Db::getInstance()->executeS('
SELECT g.`id_group`, gl.`name`
FROM `'._DB_PREFIX_.'group` g
LEFT JOIN `'._DB_PREFIX_.'group_lang` AS gl ON (g.`id_group` = gl.`id_group` AND gl.`id_lang` = '.(int)($context->language->id).')
WHERE '.(Validate::isUnsignedInt($filter) ? 'g.`id_group` = '.(int)($filter) : 'gl.`name` LIKE "%'.pSQL($filter).'%"
'.((Validate::isBool_Id($filter) AND $filterArray[0] == 1) ? 'OR g.`id_group` = '.(int)($filterArray[1]) : '')).'
ORDER BY gl.`name` ASC
LIMIT 50');
$json = '{"customers" : ';
foreach ($customers AS $customer)
$jsonArray[] = '{"value":"0_'.(int)($customer['id_customer']).'", "text":"'.addslashes($customer['name']).' ('.addslashes($customer['email']).')"}';
$json .= '['.implode(',', $jsonArray).'],
"groups" : ';
$jsonArray = array();
foreach ($groups AS $group)
$jsonArray[] = '{"value":"1_'.(int)($group['id_group']).'", "text":"'.addslashes($group['name']).'"}';
$json .= '['.implode(',', $jsonArray).']}';
die($json);
}
if (Tools::getValue('page') == 'prestastore' AND @fsockopen('addons.prestashop.com', 80, $errno, $errst, 3))
readfile('http://addons.prestashop.com/adminmodules.php?lang='.$context->language->iso_code);
if ($step = (int)(Tools::getValue('ajaxProductTab')))
{
require_once(dirname(__FILE__).'/tabs/AdminCatalog.php');
$catalog = new AdminCatalog();
$admin = new AdminProducts();
$languages = Language::getLanguages(false);
$defaultLanguage = (int)(Configuration::get('PS_LANG_DEFAULT'));
$product = new Product((int)(Tools::getValue('id_product')));
if (!Validate::isLoadedObject($product))
die (Tools::displayError('Product cannot be loaded'));
$switchArray = array(3 => 'displayFormPrices', 4 => 'displayFormAttributes', 5 => 'displayFormFeatures', 6 => 'displayFormCustomization', 7 => 'displayFormAttachments');
AdminTab::$currentIndex = 'index.php?tab=AdminCatalog';
if (key_exists($step, $switchArray))
$admin->{$switchArray[$step]}($product, $languages, $defaultLanguage);
}
if (Tools::isSubmit('getAvailableFields') AND Tools::isSubmit('entity'))
{
$jsonArray = array();
-83
View File
@@ -1,83 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 6844 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
define('_PS_ADMIN_DIR_', getcwd());
include_once('../config/config.inc.php');
include_once('tabs/AdminCatalog.php');
include_once('tabs/AdminProducts.php');
include_once('init.php');
if (Tools::getValue('token') != Tools::getAdminTokenLite('AdminCatalog'))
die(1);
$catalog = new AdminCatalog();
$adminProducts = new AdminProducts();
echo ' <tr>
<td class="col-left"><label for="id_category_default" class="t">'.$adminProducts->getL('Default category:').'</label></td>
<td>
<select id="id_category_default" name="id_category_default" onchange="checkDefaultCategory(this.value);">';
$categories = Category::getCategories(Context::getContext()->language->id, false);
Category::recurseCategory($categories, $categories[0][1], 1, (int)(Tools::getValue('id_category_default')));
echo ' </select>
</td>
</tr>
<tr>
<td class="col-left">'.$adminProducts->getL('Catalog:').'</td>
<td>
<div style="overflow: auto; min-height: 300px; padding-top: 0.6em;" id="categoryList">
<script type="text/javascript">
$(document).ready(function() {
$(\'div#categoryList input.categoryBox\').click(function (){
if ($(this).is(\':not(:checked)\') && $(\'div#categoryList input.id_category_default\').val() == $(this).val())
jAlert(\''.utf8_encode(html_entity_decode($adminProducts->getL('Consider changing the default category.'))).'\');
});
});
</script>
<table cellspacing="0" cellpadding="0" class="table">
<tr>
<th><input type="checkbox" name="checkme" class="noborder" onclick="checkDelBoxes(this.form, \'categoryBox[]\', this.checked)" /></th>
<th>'.$adminProducts->getL('ID').'</th>
<th style="width: 600px">'.$adminProducts->getL('Name').'</th>
</tr>';
$done = array();
$index = array();
$categoryBox = Tools::getValue('categoryBox');
if ($categoryBox != '')
{
$categoryBox = @unserialize($categoryBox);
foreach ($categoryBox AS $k => $row)
$index[] = $row;
}
elseif ((int)Tools::getValue('id_product'))
$index = Product::getProductCategories((int)Tools::getValue('id_product'));
$adminProducts->recurseCategoryForInclude((int)(Tools::getValue('id_product')), $index, $categories, $categories[0][1], 1, (int)(Tools::getValue('id_category_default')));
echo ' </table>
<p style="padding:0px; margin:0px 0px 10px 0px;">'.$adminProducts->getL('Mark all checkbox(es) of categories in which product is to appear').'<sup> *</sup></p>
</div>
</tr>';
@@ -1,156 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 7499 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class AdminCatalogControllerCore extends AdminController
{
/** @var object AdminCategories() instance */
//private $adminCategories;
/** @var object AdminProducts() instance */
// private $adminProducts;
/** @var object AttributeGenerator() instance */
private $attributeGenerator;
/** @var object imageResize() instance */
private $imageResize;
/** @var object Category() instance for navigation*/
private static $_category = NULL;
public function __construct()
{
/* Get current category */
$id_category = abs(Tools::getValue('id_category'));
$shop = Context::getContext()->shop;
if (!$id_category)
$id_category = $shop->getCategory();
else if ($id_category != $shop->getCategory())
{
// Check if current category is "inside" shop default category
$sql = 'SELECT nleft, nright FROM '._DB_PREFIX_.'category
WHERE id_category = '.$shop->getCategory();
if ($interval = Category::getInterval($shop->getCategory()))
{
$sql = 'SELECT id_category FROM '._DB_PREFIX_.'category
WHERE id_category = '.(int)$id_category.'
AND nleft >= '.$interval['nleft'].'
AND nright <= '.$interval['nright'];
if (!Db::getInstance()->getValue($sql))
$id_category = $shop->getCategory();
}
}
self::$_category = new Category($id_category);
if (!Validate::isLoadedObject(self::$_category))
throw new PrestaShopException('Category cannot be loaded');
$this->table = array('category', 'product');
// $this->adminCategories = new AdminCategories();
// $this->adminProducts = new AdminProducts();
parent::__construct();
}
/**
* Return current category
*
* @return object
*/
public static function getCurrentCategory()
{
return self::$_category;
}
public function viewAccess($disable = false)
{
$result = parent::viewAccess($disable);
$this->adminCategories->tabAccess = $this->tabAccess;
$this->adminProducts->tabAccess = $this->tabAccess;
return $result;
}
public function postProcess()
{
if (isset($_GET['attributegenerator']))
{
if (!isset($this->attributeGenerator))
{
include_once(_PS_ADMIN_DIR_.'/tabs/AdminAttributeGenerator.php');
$this->attributeGenerator = new AdminAttributeGenerator();
}
$this->attributeGenerator->postProcess();
}
// $this->adminProducts->postProcess($this->token);
}
public function ajaxProcess()
{
if (Tools::getValue('addImage') !== false)
$this->adminProducts->ajaxProcess();
if (Tools::getValue('updateProductImageShopAsso'))
$this->adminProducts->ajaxProcess();
if (Tools::getValue('deleteImage'))
$this->adminProducts->ajaxProcess();
}
public function initContent()
{
// @todo : this has to be dealt in AdminAttributeGenerator !!
if (isset($_GET['attributegenerator']))
{
if (!isset($this->attributeGenerator))
{
include_once(_PS_ADMIN_DIR_.'/tabs/AdminAttributeGenerator.php');
$this->attributeGenerator = new AdminAttributeGenerator();
}
$this->attributeGenerator->displayForm();
}
elseif (!isset($_GET['editImage']))
{
$home = false;
$id_category = (int)(Tools::getValue('id_category'));
if (!$id_category)
{
$home = true;
$id_category = Context::getContext()->shop->getCategory();
}
$catalog_tabs = array('category', 'product');
// Cleaning links
$catBarIndex = self::$currentIndex;
foreach ($catalog_tabs AS $tab)
if (Tools::getValue($tab.'Orderby') && Tools::getValue($tab.'Orderway'))
$catBarIndex = preg_replace('/&'.$tab.'Orderby=([a-z _]*)&'.$tab.'Orderway=([a-z]*)/i', '', self::$currentIndex);
$this->context->smarty->assign('cat_bar',getPath($catBarIndex, $id_category, '', '', 'catalog', $home));
}
$this->content = '';
parent::initContent();
}
}
+10 -10
View File
@@ -273,36 +273,36 @@ class AdminGroupsControllerCore extends AdminController
protected function formatCategoryDiscountList($id)
{
$categorie = GroupReduction::getGroupReductions((int)$id, $this->context->language->id);
$categorie_reductions = array();
$category = GroupReduction::getGroupReductions((int)$id, $this->context->language->id);
$category_reductions = array();
$category_reduction = Tools::getValue('category_reduction');
foreach ($categorie as $category)
foreach ($category as $category)
{
if (is_array($category_reduction) && array_key_exists($category['id_category'], $category_reduction))
$category['reduction'] = $category_reduction[$category['id_category']];
$tmp = array();
$tmp['path'] = getPath(self::$currentIndex.'?tab=AdminCatalog', (int)$category['id_category']);
$tmp['path'] = getPath(self::$currentIndex.'?tab=AdminCategories', (int)$category['id_category']);
$tmp['reduction'] = (float)$category['reduction'] * 100;
$tmp['id_category'] = (int)$category['id_category'];
$categorie_reductions[(int)$category['id_category']] = $tmp;
$category_reductions[(int)$category['id_category']] = $tmp;
}
if (is_array($category_reduction))
foreach ($category_reduction as $key => $val)
{
if (!array_key_exists($key, $categorie_reductions))
if (!array_key_exists($key, $category_reductions))
{
$tmp = array();
$tmp['path'] = getPath(self::$currentIndex.'?tab=AdminCatalog', (int)$key);
$tmp['path'] = getPath(self::$currentIndex.'?tab=AdminCategories', $key);
$tmp['reduction'] = (float)$val * 100;
$tmp['id_category'] = (int)$key;
$categorie_reductions[(int)$category['id_category']] = $tmp;
$category_reductions[(int)$category['id_category']] = $tmp;
}
}
return $categorie_reductions;
return $category_reductions;
}
public function formatModuleListAuth($id_group)
@@ -388,7 +388,7 @@ class AdminGroupsControllerCore extends AdminController
else
{
$result['id_category'] = (int)$id_category;
$result['catPath'] = getPath(self::$currentIndex.'?tab=AdminCatalog', (int)$id_category);
$result['catPath'] = getPath(self::$currentIndex.'?tab=AdminCategories', (int)$id_category);
$result['discount'] = $category_reduction;
$result['hasError'] = false;
}
@@ -1,31 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 6844 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class AdminToolsControllerCore extends AdminController
{
}
+2 -2
View File
@@ -136,7 +136,7 @@ class StatsCatalog extends Module
public function hookAdminStatsModules($params)
{
$categories = Category::getCategories($this->context->language->id, true, false);
$productToken = Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)$this->context->employee->id);
$productToken = Tools::getAdminToken('AdminProducts'.(int)(Tab::getIdFromClassName('AdminProducts')).(int)$this->context->employee->id);
$irow = 0;
if ($id_category = (int)(Tools::getValue('id_category')))
@@ -216,7 +216,7 @@ class StatsCatalog extends Module
<td>'.$product['id_product'].'</td>
<td style="width: 400px;">'.$product['name'].'</td>
<td style="text-align: right">
<a href="index.php?tab=AdminCatalog&id_product='.$product['id_product'].'&addproduct&token='.$productToken.'" target="_blank"><img src="../modules/'.$this->name.'/page_edit.png" /></a>
<a href="index.php?tab=AdminProducts&id_product='.$product['id_product'].'&addproduct&token='.$productToken.'" target="_blank"><img src="../modules/'.$this->name.'/page_edit.png" /></a>
<a href="'.$this->context->link->getProductLink($product['id_product'], $product['link_rewrite']).'" target="_blank"><img src="../modules/'.$this->name.'/application_home.png" /></a>
</td>
</tr>';
+2 -2
View File
@@ -224,11 +224,11 @@ class StatsProduct extends ModuleGraph
<th>'.$this->l('Average price').'</th>
</tr>
</thead><tbody>';
$tokenProducts = Tools::getAdminToken('AdminCatalog'.(int)Tab::getIdFromClassName('AdminCatalog').(int)$this->context->employee->id);
$tokenProducts = Tools::getAdminToken('AdminProducts'.(int)Tab::getIdFromClassName('AdminProducts').(int)$this->context->employee->id);
foreach ($crossSelling as $selling)
$this->html .= '
<tr>
<td ><a href="?tab=AdminCatalog&id_product='.(int)$selling['id_product'].'&addproduct&token='.$tokenProducts.'">'.$selling['pname'].'</a></td>
<td ><a href="?tab=AdminProducts&id_product='.(int)$selling['id_product'].'&addproduct&token='.$tokenProducts.'">'.$selling['pname'].'</a></td>
<td align="center">'.(int)$selling['pqty'].'</td>
<td align="right">'.Tools::displayprice($selling['pprice'], $currency).'</td>
</tr>';
@@ -1,7 +0,0 @@
<?php
class AdminCatalogController extends AdminCatalogControllerCore
{
}
@@ -1,7 +0,0 @@
<?php
class AdminToolsController extends AdminToolsControllerCore
{
}