/** * Formate les valeurs principales d'un élément suivant la ligne passées en paramètre * @param $row * @param $current * @return array|null */ public function setItemData($row, $current) { $ModelImagepath = new magixglobal_model_imagepath(); $ModelDateformat = new magixglobal_model_dateformat(); $ModelTemplate = new frontend_model_template(); $ModelRewrite = new magixglobal_model_rewrite(); $data = null; if (isset($row['idnews'])) { $data['tag'] = null; $tag['data'] = parent::s_tagByNews($row['idnews']); if (is_array($tag['data'])) { foreach ($tag['data'] as $t) { $t['uri'] = $ModelRewrite->filter_news_tag_url($row['iso'], $t['name_tag'], true); $data['tag'] .= '<a href="' . $t['uri'] . '" title="' . $t['name_tag'] . '">'; $data['tag'] .= $t['name_tag']; $data['tag'] .= '</a> '; } } if (isset($row['n_image'])) { $data['imgSrc'] = array('small' => $ModelImagepath->filterPathImg(array('filtermod' => 'news', 'img' => 's_' . $row['n_image'])), 'medium' => $ModelImagepath->filterPathImg(array('filtermod' => 'news', 'img' => $row['n_image']))); } $data['imgSrc']['default'] = $ModelImagepath->filterPathImg(array('img' => 'skin/' . $ModelTemplate->frontendTheme()->themeSelected() . '/img/news/news-default.png')); $data['id'] = $row['idnews']; $data['name'] = $row['n_title']; $data['uri'] = $ModelRewrite->filter_news_url($row['iso'], $ModelDateformat->date_europeen_format($row['date_register']), $row['n_uri'], $row['keynews'], true); $data['current'] = false; if (isset($current['record']['id'])) { $data['active'] = $row['keynews'] == $current['record']['id'] ? true : false; } $data['date']['register'] = $ModelDateformat->SQLDate($row['date_register']); $data['date']['publish'] = $ModelDateformat->SQLDate($row['date_publish']); $data['content'] = $row['n_content']; } return $data; }
/** * 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; } }
/** * @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; }