-
Notifications
You must be signed in to change notification settings - Fork 45
/
category.php
85 lines (72 loc) · 3.22 KB
/
category.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
include(dirname(__FILE__).'/config/config.inc.php');
include(dirname(__FILE__).'/init.php');
//will be initialized bellow...
if(intval(Configuration::get('PS_REWRITING_SETTINGS')) === 1)
$rewrited_url = null;
/* CSS ans JS files calls */
$css_files = array(__PS_BASE_URI__.'css/jquery.cluetip.css' => 'all', _THEME_CSS_DIR_.'scenes.css' => 'all');
include(dirname(__FILE__).'/header.php');
include(dirname(__FILE__).'/product-sort.php');
$errors = array();
if (!isset($_GET['id_category']) OR !Validate::isUnsignedId($_GET['id_category']))
$errors[] = Tools::displayError('category ID is missing');
else
{
$category = new Category(intval(Tools::getValue('id_category')), intval($cookie->id_lang));
if (!Validate::isLoadedObject($category))
$errors[] = Tools::displayError('category does not exist');
elseif (!$category->checkAccess(intval($cookie->id_customer)))
$errors[] = Tools::displayError('you do not have access to this category');
else
{
/* rewrited url set */
$rewrited_url = $link->getCategoryLink($category->id, $category->link_rewrite);
/* Scenes (could be externalised to another controler if you need them */
$smarty->assign('scenes', Scene::getScenes(intval($category->id), intval($cookie->id_lang), true, false));
/* Scenes images formats */
if ($sceneImageTypes = ImageType::getImagesTypes('scenes'))
{
foreach ($sceneImageTypes AS $sceneImageType)
{
if ($sceneImageType['name'] == 'thumb_scene')
$thumbSceneImageType = $sceneImageType;
elseif ($sceneImageType['name'] == 'large_scene')
$largeSceneImageType = $sceneImageType;
}
$smarty->assign('thumbSceneImageType', isset($thumbSceneImageType) ? $thumbSceneImageType : NULL);
$smarty->assign('largeSceneImageType', isset($largeSceneImageType) ? $largeSceneImageType : NULL);
}
$category->name = Category::hideCategoryPosition($category->name);
$category->description = nl2br2($category->description);
$subCategories = $category->getSubCategories(intval($cookie->id_lang));
$smarty->assign('category', $category);
if (Db::getInstance()->numRows())
$smarty->assign('subcategories', $subCategories);
if ($category->id != 1)
{
$nbProducts = $category->getProducts(NULL, NULL, NULL, $orderBy, $orderWay, true);
include(dirname(__FILE__).'/pagination.php');
$smarty->assign('nb_products', $nbProducts);
$cat_products = $category->getProducts(intval($cookie->id_lang), intval($p), intval($n), $orderBy, $orderWay);
}
$smarty->assign(array(
'products' => (isset($cat_products) AND $cat_products) ? $cat_products : NULL,
'id_category' => intval($category->id),
'id_category_parent' => intval($category->id_parent),
'return_category_name' => Tools::safeOutput(Category::hideCategoryPosition($category->name)),
'path' => Tools::getPath(intval($category->id), $category->name)
));
}
}
$smarty->assign(array(
'allow_oosp' => intval(Configuration::get('PS_ORDER_OUT_OF_STOCK')),
'suppliers' => Supplier::getSuppliers(),
'errors' => $errors));
if (isset($subCategories))
$smarty->assign(array(
'subcategories_nb_total' => sizeof($subCategories),
'subcategories_nb_half' => ceil(sizeof($subCategories) / 2)));
$smarty->display(_PS_THEME_DIR_.'category.tpl');
include(dirname(__FILE__).'/footer.php');
?>