/** * 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; }
/** * Test si le cache est valide * @param string|object $template * @param string $plugin * @param mixed $cache_id * @param mixed $compile_id * @param object $parent */ public function isCached($template = null, $plugin = '', $cache_id = null, $compile_id = null, $parent = null) { if (file_exists('skin/' . frontend_model_template::frontendTheme()->themeSelected() . '/' . self::controlGetPlugin($plugin))) { frontend_model_smarty::getInstance()->isCached('skin/' . frontend_model_template::frontendTheme()->themeSelected() . '/' . self::controlGetPlugin($plugin) . '/' . $template, $cache_id, $compile_id, $parent); } else { frontend_model_smarty::getInstance()->isCached($this->directory_plugins() . self::controlGetPlugin($plugin) . '/skin/public/' . $template, $cache_id, $compile_id, $parent); } }
/** * 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; } }
/** * Smarty {template} function plugin * * Type: function * Name: load template * Date: january 26 2010 * Purpose: * Examples: {template} * Output: * @link * @author Gerits Aurelien * @version 1.0 * @param array * @param Smarty * @return string */ function smarty_function_template($params, $template) { return frontend_model_template::frontendTheme()->themeSelected(); }
/** * Les paramètres pour la configuration de smarty 3 */ protected function setParams() { /** * Path -> configs */ $this->setConfigDir(array(self::setPath() . "locali18n/")); /** * Path -> templates */ $this->setTemplateDir(array(self::setPath() . "skin/" . frontend_model_template::frontendTheme()->themeSelected() . '/')); /** * path plugins * @var void */ $this->setPluginsDir(array(self::setPath() . 'lib/smarty3/plugins/', self::setPath() . 'app/wdcore/', self::setPath() . 'widget/')); /** * Ajout du dossier additionnels des plugins smarty dans le template courant */ frontend_model_template::frontendTheme()->addWidgetDir($this, self::setPath(), false); /** * Path -> compile */ $this->setCompileDir(self::setPath() . 'var/templates_c/'); /** * debugging (true/false) */ $this->debugging = false; /** * compile (true/false) */ $this->compile_check = true; /** * Force compile * @var void * (true/false) */ $this->force_compile = false; /** * caching (true/false) */ frontend_model_template::frontendTheme()->setCache($this); //$this->setCaching(false); //$this->setCachingType('apc'); /** * Use sub dirs (true/false) */ $this->use_sub_dirs = false; /** * cache_dir -> cache */ $this->setCacheDir(self::setPath() . 'var/tpl_caches/'); /** * load pre filter */ //$this->load_filter('pre','magixmin'); $this->autoload_filters = array('pre' => array('magixmin')); $this->loadPlugin('smarty_compiler_switch'); /** * * @var error_reporting */ $this->error_reporting = error_reporting() & ~E_NOTICE; /** * Security */ //$this->enableSecurity(); /** * security settings */ //$this->enableSecurity('Security_Policy'); }
/** * Smarty {widget_lang_display} function plugin * * Type: function * Name: widget_lang_display * Date: 03/01/2013 * Date Update : 12/01/2013 * Output: * @author Sire Sam (http://www.sire-sam.be) * @author Gerits Aurélien (http://www.magix-dev.be) * @link * @version 1.0 * @param $params * @param $template * @return string */ function smarty_function_widget_lang_display($params, $template) { $ModelConstructor = new magixglobal_model_constructor(); // *** Catch location var $iso_current = magixcjquery_filter_request::isGet('strLangue'); // *** Load SQL DATA $data = frontend_db_lang::s_fetch_lang(); $output = null; if ($data != null) { // *** set default html structure $strucHtml_default = array('container' => array('before' => '<ul class="nav">', 'after' => '</ul>'), 'item' => array('before' => '<li>', 'after' => '</li>'), 'icon' => array('before' => ' ', 'after' => ' '), 'name' => array('before' => ' ', 'after' => ' '), 'iso' => array('before' => '(', 'after' => ')'), 'current' => array('class' => ' current'), 'last' => array('class' => ' last', 'col' => 1)); // *** Set default elem to display $strucHtml_default['allow'] = array('', 'icon', 'name', 'iso'); $strucHtml_default['display'] = array(1 => array('', 'icon', 'name', 'iso')); // *** Update html struct & item setting with custom var (params['structureHTML']) @TODO vérifier si le paramaètre htmlDispaly tj opérationnel $structHtml_custom = $params['htmlStructure'] ? $params['htmlStructure'] : null; $strucHtml = $ModelConstructor->mergeHtmlPattern($strucHtml_default, $structHtml_custom); // *** Set translation var $t_go_to_version = frontend_model_template::getConfigVars('go_to_version'); // *** format items loop (foreach item) $items = null; $i = 0; foreach ($data as $row) { $i++; // *** set additional var in htmlStruct $strucHtml['is_current'] = $iso_current == $row['iso'] ? 1 : 0; $strucHtml['is_last'] = 0; if ($i == $strucHtml['last']['col']) { $strucHtml['is_last'] = 1; $i = 0; } // *** in case diplay is null, we take default value if ($strucHtml['display'][1] == null) { $strucHtml['display'][1] = $strucHtml_default['display'][1]; } // *** set link class $item_classLink = null; if ($strucHtml['is_last'] == 1 or $strucHtml['is_current'] == 1) { $item_class = ' class="'; $item_class .= $strucHtml['is_last'] == 1 ? $strucHtml['last']['class'] : ''; $item_class .= $strucHtml['is_current'] == 1 ? $strucHtml['current']['class'] : ''; $item_class .= '"'; } // *** format item loop (foreach element) $item = null; foreach ($strucHtml['display'][1] as $elem_type) { $strucHtml_elem = $strucHtml[$elem_type]; if (array_search($elem_type, $strucHtml['display'][1])) { switch ($elem_type) { case 'name': $elem = ucfirst($row['language']); break; case 'icon': $elem = '<img src="/skin/' . frontend_model_template::frontendTheme()->themeSelected() . '/img/lang/' . $row['iso'] . '.png" alt="' . $row['name'] . '"/>'; break; case 'iso': $elem = $row['iso']; break; default: $elem = null; } // *** elem construct if ($elem != null) { $item .= $strucHtml_elem['before']; $item .= $elem; $item .= $strucHtml_elem['after']; } } } // *** item construct $items .= $strucHtml['item']['before']; $items .= '<a href="/' . $row['iso'] . '/" hreflang="' . $row['iso'] . '" title="' . ucfirst($t_go_to_version) . ': ' . $row['language'] . '">'; $items .= $item; $items .= '</a>'; $items .= $strucHtml['item']['after']; } // *** container construct $output .= $strucHtml['container']['before']; $output .= isset($params['htmlPrepend']) ? $params['htmlPrepend'] : null; $output .= $items; $output .= isset($params['htmlAppend']) ? $params['htmlAppend'] : null; $output .= $strucHtml['container']['after']; } return $output; }
/** * Smarty {widget_share_display} function plugin * * Type: function * Name: widget_share_display * Date: 04/01/2012 * Update: 12/01/2013 * Output: * @author Sire Sam (http://www.sire-sam.be) * @author Gerits Aurélien (http://www.magix-dev.be) * @version 1.0 * @param array * @param Smarty * @return string * <ul id="share-box" class="nav navbar-nav navbar-right"> <li> <a href="#" class="dropdown-toggle" data-toggle="dropdown"> <span class="glyphicon glyphicon-share"> </span> <span class="dropdown-text"> {#share#|ucfirst} </span> </a> {widget_share_display htmlStructure=[ 'container' => [ 'before' => '<ul id="share-nav" class="dropdown-menu">', 'after' => '</ul>' ] ] } </li> </ul> */ function smarty_function_widget_share_display($params, $template) { // *** Load active script var // ** Catch Domain var $url['root'] = magixcjquery_html_helpersHtml::getUrl(); $url['relativ'] = $_SERVER["REQUEST_URI"]; //strrpos récupère la dernière occurence de / et de . $url['share'] = $url['root'] . $url['relativ']; // ** Catch module's page name $smarty = frontend_model_smarty::getInstance(); // ** find active module $script['fileName'] = substr($_SERVER['SCRIPT_NAME'], 1); $script['chartBeforeExt'] = strpos($script['fileName'], '.'); $active_mod = substr($script['fileName'], 0, $script['chartBeforeExt']); // ** set active module name $name = null; switch ($active_mod) { case 'index': $name = $smarty->getTemplateVars('title'); break; case 'catalog': if (isset($_GET['idproduct'])) { $productData = $smarty->getTemplateVars('product'); $name = $productData['name']; } elseif (isset($_GET['idcls'])) { $subcatData = $smarty->getTemplateVars('subcat'); $name = $subcatData['name']; } elseif (isset($_GET['idclc'])) { $catData = $smarty->getTemplateVars('cat'); $name = $catData['name']; } else { $name = $smarty->getConfigVars('catalog_root_h1'); } break; case 'cms': $name = $smarty->getTemplateVars('name_page'); break; case 'news': if (isset($_GET['getnews'])) { $name = $smarty->getTemplateVars('name_news'); } elseif (isset($_GET['tag'])) { $name = $smarty->getConfigVars('news_root_h1') . ': ' . $_GET['tag']; } else { $name = $smarty->getConfigVars('news_root_h1'); } break; case 'plugin': $active_plugin = $_GET['magixmod']; switch ($active_plugin) { case 'contact': $name = $smarty->getConfigVars('contact_root_h1'); break; default: if (isset($_GET['pstring3'])) { $name = ucfirst(str_replace('-', ' ', 'pstring3')); } elseif (isset($_GET['pstring2'])) { $name = ucfirst(str_replace('-', ' ', 'pstring2')); } elseif (isset($_GET['pstring1'])) { $name = ucfirst(str_replace('-', ' ', 'pstring1')); } else { $name = $smarty->getConfigVars($active_mod . '_root_h1'); } } } // *** Set share data $name = str_replace(' ', '%20', $name); // W3C validation require no ' ' in url $data_default = array('facebook' => array('name' => 'facebook', 'url' => 'http://www.facebook.com/share.php?u=' . $url['share'], 'img' => 'facebook.png'), 'twitter' => array('name' => 'twitter', 'url' => 'https://twitter.com/intent/tweet?text=' . $name . '&url=' . $url['share'], 'img' => 'twitter.png'), 'viadeo' => array('name' => 'viadeo', 'url' => 'http://www.viadeo.com/shareit/share/?url=' . $url['share'] . '&title=' . $name . '&overview=' . $name, 'img' => 'viadeo.png'), 'google' => array('name' => 'google', 'url' => 'https://plus.google.com/share?url=' . $url['share'], 'onclick' => 'javascript:window.open(this.href,\'\', \'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600\');return false;', 'img' => 'google.png')); // ** Select Data if (isset($params['dataSelect']['context'])) { $dataSelect = explode(',', $params['dataSelect']['context']); foreach ($dataSelect as $share) { if (array_key_exists($share, $data_default)) { $data[] = $data_default[$share]; } } } else { $data = $data_default; } // *** Set default html structure $strucHtml_default = array('container' => array('before' => '<ul>', 'after' => '</ul>'), 'item' => array('before' => '<li>', 'after' => '</li>'), 'img' => array('before' => ' ', 'after' => ' '), 'name' => array('before' => ' ', 'after' => ' '), 'current' => array('class' => ' current'), 'last' => array('class' => ' last', 'col' => 1)); // ** Set default elem to display $strucHtml_default['allow'] = array('', 'name', 'img'); $strucHtml_default['display'] = array(1 => array('', 'img', 'name')); // ** Update html struct & item setting with custom var (params['htmlStructure']) $custom = $params['htmlStructure'] ? $params['htmlStructure'] : null; $default = $strucHtml_default; if (is_array($custom)) { $default['display'] = array(); foreach ($custom as $k => $v) { foreach ($v as $sk => $sv) { if ($sv != null) { $default[$k][$sk] = $sv; } } if (array_search($k, $default['allow'])) { $default['display'][1][] = $k; } } } // ** Update html struct with display params (params['htmlDisplay']) if (isset($params['htmlDisplay'])) { $default['display'] = $params['htmlDisplay']; } // * push null value on case[0] (allow array search on format function) foreach ($default['display'] as $k => $v) { array_unshift($default['display'][$k], null); } $strucHtml = $default; // ** in cas diplay is null, we take default value if ($strucHtml['display'][1] == null) { $strucHtml['display'][1] = $strucHtml_default['display'][1]; } // *** Set translation var $t_share_on = frontend_model_template::getConfigVars('share_on'); // *** format items loop (foreach item) $items = null; foreach ($data as $row) { // ** format item loop (foreach element) $elem = null; foreach ($strucHtml['display'][1] as $elem_type) { if (array_search($elem_type, $strucHtml['display'][1])) { switch ($elem_type) { case 'name': $elem .= ucfirst($row['name']); break; case 'img': $elem .= '<img src="' . '/skin/' . frontend_model_template::frontendTheme()->themeSelected() . '/img/share/' . $row['img'] . '" alt="' . $row['name'] . '" />'; } } } // ** item construct $items .= $strucHtml['item']['before']; $items .= '<a id="share-' . $row['name'] . '" class="targetblank" href="' . $row['url'] . '" title="' . ucfirst($t_share_on) . ': ' . $row['name'] . '">'; $items .= $elem; $items .= '</a>'; $items .= $strucHtml['item']['after']; } // *** container construct $output = $strucHtml['container']['before']; $output .= isset($params['htmlPrepend']) ? $params['htmlPrepend'] : null; $output .= $items; $output .= isset($params['htmlAppend']) ? $params['htmlAppend'] : null; $output .= $strucHtml['container']['after']; return $output; }
/** * @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; }