/** * Formate les valeurs principales d'un élément suivant la ligne passées en paramètre * @param $row * @param $current * @return array|null * @todo revoir le nommage de 'current', lui préférant 'active' */ public function setItemData($row, $current) { $ModelImagepath = new magixglobal_model_imagepath(); $ModelTemplate = new frontend_model_template(); $ModelRewrite = new magixglobal_model_rewrite(); $data = null; if ($row != null) { // *** Product if (isset($row['titlecatalog'])) { $subcat['id'] = isset($row['idcls']) ? $row['idcls'] : null; $subcat['name'] = isset($row['pathslibelle']) ? $row['pathslibelle'] : null; if (isset($row['imgcatalog'])) { $data['imgSrc'] = array('small' => $ModelImagepath->filterPathImg(array('filtermod' => 'catalog', 'img' => 'mini/' . $row['imgcatalog'], 'levelmod' => '')), 'medium' => $ModelImagepath->filterPathImg(array('filtermod' => 'catalog', 'img' => 'medium/' . $row['imgcatalog'], 'levelmod' => '')), 'large' => $ModelImagepath->filterPathImg(array('filtermod' => 'catalog', 'img' => 'product/' . $row['imgcatalog'], 'levelmod' => ''))); } $data['imgSrc']['default'] = $ModelImagepath->filterPathImg(array('img' => 'skin/' . $ModelTemplate->frontendTheme()->themeSelected() . '/img/catalog/product-default.png')); $data['url'] = $ModelRewrite->filter_catalog_product_url($row['iso'], $row['pathclibelle'], $row['idclc'], $subcat['name'], $subcat['id'], $row['urlcatalog'], $row['idproduct'], true); $data['active'] = false; if (is_array($current)) { $data['active'] = (isset($current['product']['id']) and $current['product']['id'] == $row['idproduct']) ? true : false; } elseif ($current === true) { $data['active'] = true; } $data['id'] = $row['idproduct']; $data['name'] = $row['titlecatalog']; $data['price'] = $row['price']; $data['content'] = $row['desccatalog']; // *** Subcategory } elseif (isset($row['slibelle'])) { $data['active'] = false; if (is_array($current) and isset($current['subcategory']['id'])) { $data['active'] = $current['subcategory']['id'] == $row['idcls'] ? true : false; } if (isset($row['img_s'])) { $data['imgSrc'] = array(); $data['imgSrc']['small'] = $ModelImagepath->filterPathImg(array('filtermod' => 'catalog', 'img' => $row['img_s'], 'levelmod' => 'subcategory')); $data['imgSrc']['medium'] = $data['imgSrc']['small']; $data['imgSrc']['large'] = $data['imgSrc']['small']; } $data['imgSrc']['default'] = $ModelImagepath->filterPathImg(array('img' => 'skin/' . $ModelTemplate->frontendTheme()->themeSelected() . '/img/catalog/subcategory-default.png')); $data['url'] = $ModelRewrite->filter_catalog_subcategory_url($row['iso'], $row['pathclibelle'], $row['idclc'], $row['pathslibelle'], $row['idcls'], true); $data['id'] = $row['idcls']; $data['name'] = $row['slibelle']; $data['content'] = $row['s_content'] != '' ? $row['s_content'] : null; // *** Category } elseif (isset($row['clibelle'])) { $data['active'] = false; if (is_array($current) and isset($current['category']['id'])) { $data['active'] = $current['category']['id'] == $row['idclc'] ? true : false; } if (isset($row['img_c'])) { $data['imgSrc'] = array(); $data['imgSrc']['small'] = $ModelImagepath->filterPathImg(array('filtermod' => 'catalog', 'img' => $row['img_c'], 'levelmod' => 'category')); // I know it's like cheat $data['imgSrc']['medium'] = $data['imgSrc']['small']; $data['imgSrc']['large'] = $data['imgSrc']['small']; } $data['imgSrc']['default'] = $ModelImagepath->filterPathImg(array('img' => 'skin/' . $ModelTemplate->frontendTheme()->themeSelected() . '/img/catalog/category-default.png')); $data['url'] = $ModelRewrite->filter_catalog_category_url($row['iso'], $row['pathclibelle'], $row['idclc'], true); $data['id'] = $row['idclc']; $data['name'] = $row['clibelle']; $data['content'] = $row['c_content'] != '' ? $row['c_content'] : null; // *** Micro-gallery (product page) } elseif (isset($row['idmicro'])) { $data['id'] = $row['idmicro']; $data['img_src']['small'] = $ModelImagepath->filterPathImg(array('filtermod' => 'catalog', 'img' => 'mini/' . $row['imgcatalog'], 'levelmod' => 'galery')); $data['img_src']['medium'] = $ModelImagepath->filterPathImg(array('filtermod' => 'catalog', 'img' => 'maxi/' . $row['imgcatalog'], 'levelmod' => 'galery')); } return $data; } }
/** * Retourne les produits du catalogue dans l'éditeur * @access private * */ private function json_url_product() { if ($this->product_search != '') { if (parent::s_product_url($this->product_search) != null) { foreach (parent::s_product_url($this->product_search) as $key) { $url_product = magixglobal_model_rewrite::filter_catalog_product_url($key['iso'], $key['pathclibelle'], $key['idclc'], $key['pathslibelle'], $key['idcls'], $key['urlcatalog'], $key['idproduct'], true); $json[] = '{"idproduct":' . json_encode($key['idproduct']) . ',"titlecatalog":' . json_encode($key['titlecatalog']) . ',"category":' . json_encode($key['clibelle']) . ',"subcategory":' . json_encode($key['slibelle']) . ',"uriproduct":' . json_encode($url_product) . ',"iso":' . json_encode($key['iso']) . '}'; } print '[' . implode(',', $json) . ']'; } } else { print '{}'; } }
/** * @access private * Ecrit les urls des images du catalogue (Google Image sitemap) */ private function writeImagesCatalog($idlang) { // instance la classe $sitemap = new magixcjquery_xml_sitemap(); // Les images des catégories du catalogue sur la racine de celui-ci foreach (parent::c_catalog_category($idlang) as $data) { if ($data['catimg'] != 0) { $sitemap->writeMakeNodeImage(magixcjquery_html_helpersHtml::getUrl() . magixglobal_model_rewrite::filter_catalog_root_url($data['iso'], true), 'img_c', magixcjquery_html_helpersHtml::getUrl() . '/upload/catalogimg/category/', parent::s_catalog_category($data['idlang'])); } } //Les images des sous catégories du catalogue de chaque catégorie foreach (parent::s_catalog_category($idlang) as $data) { $count = parent::c_catalog_subcategory($data['idclc']); if ($count['subcatimg'] != 0) { $uri_cat = magixglobal_model_rewrite::filter_catalog_category_url($data['iso'], $data['pathclibelle'], $data['idclc'], true); $sitemap->writeMakeNodeImage(magixcjquery_html_helpersHtml::getUrl() . $uri_cat, 'img_s', magixcjquery_html_helpersHtml::getUrl() . '/upload/catalogimg/subcategory/', parent::s_catalog_subcategory_images_by_lang($data['idclc'])); } } // Les images des produits du catalogue foreach (parent::s_catalog_sitemap($idlang) as $data) { $uri = magixglobal_model_rewrite::filter_catalog_product_url($data['iso'], $data['pathclibelle'], $data['idclc'], $data['pathslibelle'], $data['idcls'], $data['urlcatalog'], $data['idproduct'], true); if ($data['imgcatalog'] != null) { $sitemap->writeMakeNodeImage(magixcjquery_html_helpersHtml::getUrl() . $uri, $data['imgcatalog'], magixcjquery_html_helpersHtml::getUrl() . '/upload/catalogimg/product/'); } } }
/** * @param $row * @return array */ private function setItemCartData($row) { $data = null; $newData = array(); $ModelImagepath = new magixglobal_model_imagepath(); $ModelTemplate = new frontend_model_template(); foreach ($row as $key => $value) { $urlProduct = magixglobal_model_rewrite::filter_catalog_product_url($value['iso'], $value['pathclibelle'], $value['idclc'], $value['pathslibelle'], $value['idcls'], $value['urlcatalog'], $value['idproduct'], true); $newData[$key]['id_item'] = $value['id_item']; $newData[$key]['idcatalog'] = $value['idcatalog']; $newData[$key]['titlecatalog'] = $value['titlecatalog']; if ($value['imgcatalog']) { $newData[$key]['imgSrc'] = array('small' => $ModelImagepath->filterPathImg(array('filtermod' => 'catalog', 'img' => 'mini/' . $value['imgcatalog'], 'levelmod' => '')), 'medium' => $ModelImagepath->filterPathImg(array('filtermod' => 'catalog', 'img' => 'medium/' . $value['imgcatalog'], 'levelmod' => '')), 'large' => $ModelImagepath->filterPathImg(array('filtermod' => 'catalog', 'img' => 'product/' . $value['imgcatalog'], 'levelmod' => ''))); } $newData[$key]['imgSrc']['default'] = $ModelImagepath->filterPathImg(array('img' => 'skin/' . $ModelTemplate->frontendTheme()->themeSelected() . '/img/catalog/product-default.png')); $newData[$key]['imgcatalog'] = $value['imgcatalog']; $newData[$key]['urlproduct'] = $urlProduct; $newData[$key]['quantity'] = $value['quantity_items']; $newData[$key]['price'] = $value['price_items']; $newData[$key]['idattr'] = $value['idattr']; if (isset($value['idattr'])) { $newData[$key]['idattr'] = $value['idattr']; if ($value['idattr'] && $value['idattr'] != null) { $newData[$key]['title_attr'] = $value['title_attribute']; $newData[$key]['idgroup'] = $value['idgroup']; } } //$newData[$key]['fixed_costs'] = $value['fixed_costs']; //$newData[$key]['weight'] = !is_null($value['weight']) ? ($value['weight']*$value['quantity_items']) : null; //$newData[$key]['marking_costs'] = !is_null($value['marking_costs']) ? $value['marking_costs']/*($value['quantity_items']*$value['marking_costs'])*/ : null; $newData[$key]['price_products'] = $value['price_items']; $newData[$key]['sub_amount'] = number_format($value['quantity_items'] * $value['price_items'], 2, '.', ''); } return $newData; }