Exemple #1
0
 /**
  * Adapter to get Admin HTTP link.
  *
  * @param string $controller the controller name
  * @param bool $withToken
  * @param array[string] $extraParams
  * @return string
  */
 public function getAdminLink($controller, $withToken = true, $extraParams = array())
 {
     $id_lang = OldContext::getContext()->language->id;
     $params = $extraParams;
     if ($withToken) {
         $params['token'] = \ToolsCore::getAdminTokenLite($controller);
     }
     $link = new \LinkCore();
     return $link->getBaseLink() . basename(_PS_ADMIN_DIR_) . '/' . \DispatcherCore::getInstance()->createUrl($controller, $id_lang, $params, false);
 }
Exemple #2
0
 /**
  * Override method getPageLink for redirect "attachment" link to method : getAttachmentLink
  *
  * @module now_seo_links
  *
  * @param string $controller
  * @param null $ssl
  * @param null $id_lang
  * @param null $request
  * @param bool $request_url_encode
  * @param null $id_shop
  * @return string
  * @see LinkCore::getPageLink()
  */
 public function getPageLink($controller, $ssl = null, $id_lang = null, $request = null, $request_url_encode = false, $id_shop = null)
 {
     if ($controller == 'attachment') {
         return $this->getAttachmentLink($id_lang, $request, $id_shop);
     } else {
         return parent::getPageLink($controller, $ssl, $id_lang, $request, $request_url_encode, $id_shop);
     }
 }
Exemple #3
0
 public function getCMSLink($cms, $alias = null, $ssl = null, $id_lang = null, $id_shop = null, $relative_protocol = false)
 {
     if (!Module::isInstalled('agilemultipleshop')) {
         return parent::getCMSLink($cms, $alias = null, $ssl = null, $id_lang = null, $id_shop, $relative_protocol);
     }
     $url_choice_cms = (int) Configuration::get('ASP_URL_CHOICE_CMS');
     if (!$id_lang) {
         $id_lang = Context::getContext()->language->id;
     }
     $id_seller = AgileSellerManager::getObjectOwnerID('cms', is_object($cms) ? $cms->id : (int) $cms);
     $url = $this->getAgileBaseUrl($url_choice_cms == 2, $id_seller, $ssl, $relative_protocol) . $this->getLangLink($id_lang, null, $id_shop);
     $dispatcher = Dispatcher::getInstance();
     if (!is_object($cms)) {
         if ($alias !== null && !$dispatcher->hasKeyword('cms_rule', $id_lang, 'meta_keywords', $id_shop) && !$dispatcher->hasKeyword('cms_rule', $id_lang, 'meta_title', $id_shop)) {
             return $url . $dispatcher->createUrl('cms_rule', $id_lang, array('id' => (int) $cms, 'rewrite' => (string) $alias), $this->allow, '', $id_shop);
         }
         $cms = new CMS($cms, $id_lang);
     }
     $params = array();
     $params['id'] = $cms->id;
     $params['rewrite'] = !$alias ? is_array($cms->link_rewrite) ? $cms->link_rewrite[(int) $id_lang] : $cms->link_rewrite : $alias;
     $params['meta_keywords'] = '';
     if (isset($cms->meta_keywords) && !empty($cms->meta_keywords)) {
         $params['meta_keywords'] = is_array($cms->meta_keywords) ? Tools::str2url($cms->meta_keywords[(int) $id_lang]) : Tools::str2url($cms->meta_keywords);
     }
     $params['meta_title'] = '';
     if (isset($cms->meta_title) && !empty($cms->meta_title)) {
         $params['meta_title'] = is_array($cms->meta_title) ? Tools::str2url($cms->meta_title[(int) $id_lang]) : Tools::str2url($cms->meta_title);
     }
     return $url . $dispatcher->createUrl('cms_rule', $id_lang, $params, $this->allow, '', $id_shop);
 }
 /**
  * Return the rich snippet code to the hook footer in front office if configurated
  *
  * Case 1: Return rich snippet code if configurated
  * Case 2: Return '' if not configurated or if the product are no reviews
  *
  * @return tpl string in hook footer
  */
 public function hookFooter()
 {
     global $smarty, $cookie;
     if (Configuration::get('AV_MULTILINGUE') == 'checked') {
         $this->id_lang = $this->context->language->id;
         $this->iso_lang = pSQL(Language::getIsoById($this->id_lang));
         $this->group_name = $this->getIdConfigurationGroup($this->iso_lang);
     }
     $id_product = (int) Tools::getValue('id_product');
     if (empty($id_product)) {
         return '';
     }
     $o_av = new NetReviewsModel();
     $stats_product = !isset($this->stats_product) || empty($this->stats_product) ? $o_av->getStatsProduct($id_product, $this->group_name, $this->context->shop->getContextShopID()) : $this->stats_product;
     if ($stats_product['nb_reviews'] == 0) {
         return '';
     }
     $lang_id = (int) $this->context->language->id;
     if (empty($lang_id)) {
         $lang_id = 1;
     }
     $product = new Product((int) $id_product);
     $link = new LinkCore();
     $a_image = Image::getCover($id_product);
     $smarty->assign(array('count_reviews' => $stats_product['nb_reviews'], 'average_rate' => round($stats_product['rate'], 1), 'average_rate_percent' => $stats_product['rate'] * 20, 'product_name' => $this->getProductName($id_product, $lang_id), 'product_description' => $product->description_short[$lang_id], 'product_price' => $product->getPrice(true, null, 2), 'product_quantity' => $product->quantity, 'url_image' => !empty($a_image) ? $link->getImageLink($product->link_rewrite[(int) Configuration::get('PS_LANG_DEFAULT')], $id_product . '-' . $a_image['id_image']) : ''));
     if (version_compare(_PS_VERSION_, '1.5', '>') && ($return = $this->display(__FILE__, '/views/templates/hook/footer_av.tpl')) || version_compare(_PS_VERSION_, '1.5', '<') && ($return = $this->display(__FILE__, 'footer_av.tpl'))) {
         return $return;
     } else {
         return '';
     }
 }