Exemplo n.º 1
0
 private function makeStaticLinks($staticIds)
 {
     $staticLinks = array();
     foreach ($staticIds as $staticId) {
         if (false !== $staticId) {
             $meta = Meta::getMetaByPage($staticId, (int) $this->language->id);
             $staticLinks[] = array('id' => 'link-static-page-' . $staticId, 'class' => 'cms-page-link', 'title' => $meta['title'], 'description' => $meta['description'], 'url' => $this->link->getPageLink($staticId, true));
         }
     }
     return $staticLinks;
 }
 /**
  * Registers rewrite urls for frontend controller
  * @return bool
  */
 public function registerUrls()
 {
     try {
         foreach (Language::getLanguages() as $language) {
             $data = Meta::getMetaByPage('module-newsletter2go-Export', $language['id_lang']);
             $meta = new Meta($data['id_meta']);
             if ($meta && $meta->id) {
                 $meta->url_rewrite = 'n2go-export';
                 $meta->save();
             }
         }
     } catch (Exception $e) {
         return false;
     }
     return true;
 }
Exemplo n.º 3
0
 public static function getHomeMetas($id_lang, $page_name)
 {
     if (!Module::isInstalled('agilemultipleshop') || !Module::isInstalled('agilemultipleseller')) {
         return parent::getHomeMetas($id_lang, $page_name);
     }
     if (Shop::$id_shop_owner <= 1) {
         return parent::getHomeMetas($id_lang, $page_name);
     }
     include_once _PS_ROOT_DIR_ . "/modules/agilemultipleseller/SellerInfo.php";
     $id_sellerinfo = SellerInfo::getIdBSellerId(Shop::$id_shop_owner);
     $sellerinfo = new SellerInfo($id_sellerinfo, $id_lang);
     $metas = Meta::getMetaByPage($page_name, $id_lang);
     $ret['meta_title'] = !empty($sellerinfo->meta_title) ? $sellerinfo->meta_title : $sellerinfo->company;
     $ret['meta_description'] = !empty($sellerinfo->meta_description) ? $sellerinfo->meta_description : '';
     $ret['meta_keywords'] = !empty($sellerinfo->meta_keywords) ? $sellerinfo->meta_description : '';
     return $ret;
 }
Exemplo n.º 4
0
 /**
  * Get meta tags for a given page
  *
  * @since 1.5.0
  * @param int $id_lang
  * @param string $page_name
  * @return array Meta tags
  */
 public static function getHomeMetas($id_lang, $page_name)
 {
     $metas = Meta::getMetaByPage($page_name, $id_lang);
     $ret['meta_title'] = isset($metas['title']) && $metas['title'] ? $metas['title'] . ' - ' . Configuration::get('PS_SHOP_NAME') . ' %city_name' : Configuration::get('PS_SHOP_NAME') . ' %city_name';
     $ret['meta_description'] = isset($metas['description']) && $metas['description'] ? $metas['description'] : '';
     $ret['meta_keywords'] = isset($metas['keywords']) && $metas['keywords'] ? $metas['keywords'] : '';
     if ($page_name == 'index') {
         Meta::getEgCeoWords('HOME', null, $ret);
     }
     return Meta::replaceCity($ret);
 }
Exemplo n.º 5
0
 protected function generateUrl($value, $default = "#", $prefix = '')
 {
     $response = $default;
     if ($prefix) {
         $value .= $prefix;
     }
     if ($value) {
         $langId = $this->context->language->id;
         $shopId = $this->context->shop->id;
         $arr = explode('|', $value);
         switch ($arr[0]) {
             case 'PRD':
                 $product = new Product((int) $arr[1], true, (int) $langId);
                 $response = Tools::HtmlEntitiesUTF8($product->getLink());
                 break;
             case 'CAT':
                 $response = Tools::HtmlEntitiesUTF8($this->context->link->getCategoryLink((int) $arr[1], null, $langId));
                 break;
             case 'CMS_CAT':
                 $response = Tools::HtmlEntitiesUTF8($this->context->link->getCMSCategoryLink((int) $arr[1], null, $langId));
                 break;
             case 'CMS':
                 $response = Tools::HtmlEntitiesUTF8($this->context->link->getCMSLink((int) $arr[1], null, $langId));
                 break;
             case 'ALLMAN':
                 $response = Tools::HtmlEntitiesUTF8($this->context->link->getPageLink('manufacturer'), true, $langId);
                 break;
             case 'MAN':
                 $man = new Manufacturer((int) $arr[1], $langId);
                 $response = Tools::HtmlEntitiesUTF8($this->context->link->getManufacturerLink($man->id, $man->link_rewrite, $langId));
                 break;
             case 'ALLSUP':
                 $response = Tools::HtmlEntitiesUTF8($this->context->link->getPageLink('supplier'), true, $langId);
                 break;
             case 'SUP':
                 $sup = new Supplier((int) $arr[1], $langId);
                 $response = Tools::HtmlEntitiesUTF8($this->context->link->getSupplierLink($sup->id, $sup->link_rewrite, $langId));
                 break;
             case 'SHO':
                 $shop = new Shop((int) $key);
                 $response = $shop->getBaseURL();
                 break;
             case 'PAG':
                 $pag = Meta::getMetaByPage($arr[1], $langId);
                 if (strpos($pag['page'], 'module-') === false) {
                     $response = Tools::HtmlEntitiesUTF8($this->context->link->getPageLink($pag['page'], true, $langId));
                 } else {
                     $page = explode('-', $pag['page']);
                     Context::getContext()->link->getModuleLink($page[1], $page[2]);
                     $response = Tools::HtmlEntitiesUTF8($this->context->link->getModuleLink($page[1], $page[2]));
                 }
                 break;
             default:
                 break;
         }
     }
     return $response;
 }
Exemplo n.º 6
0
*  International Registered Trademark & Property of PrestaShop SA
*/
include dirname(__FILE__) . '/../../config/config.inc.php';
require_once dirname(__FILE__) . '/../../init.php';
if (!Module::getInstanceByName('feeder')->active) {
    exit;
}
// Get data
$number = (int) Tools::getValue('n') ? (int) Tools::getValue('n') : 10;
$orderBy = Tools::getProductsOrder('by', Tools::getValue('orderby'));
$orderWay = Tools::getProductsOrder('way', Tools::getValue('orderway'));
$id_category = (int) Tools::getValue('id_category') ? (int) Tools::getValue('id_category') : Configuration::get('PS_HOME_CATEGORY');
$products = Product::getProducts((int) $context->language->id, 0, $number > 10 ? 10 : $number, $orderBy, $orderWay, $id_category, true);
$currency = new Currency((int) $context->currency->id);
$affiliate = Tools::getValue('ac') ? '?ac=' . (int) Tools::getValue('ac') : '';
$metas = Meta::getMetaByPage('index', (int) $context->language->id);
$shop_uri = Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__;
// Send feed
header("Content-Type:text/xml; charset=utf-8");
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
?>
<rss version="2.0">
	<channel>
		<title><![CDATA[<?php 
echo Configuration::get('PS_SHOP_NAME');
?>
]]></title>
		<description><![CDATA[<?php 
echo $metas['description'];
?>
]]></description>
Exemplo n.º 7
0
 /**
  * Delete module from datable
  *
  * @return boolean result
  */
 public function uninstall()
 {
     // Check module installation id validation
     if (!Validate::isUnsignedId($this->id)) {
         $this->_errors[] = $this->l('The module is not installed.');
         return false;
     }
     // Uninstall overrides
     if (!$this->uninstallOverrides()) {
         return false;
     }
     // Retrieve hooks used by the module
     $sql = 'SELECT `id_hook` FROM `' . _DB_PREFIX_ . 'hook_module` WHERE `id_module` = ' . (int) $this->id;
     $result = Db::getInstance()->executeS($sql);
     foreach ($result as $row) {
         $this->unregisterHook((int) $row['id_hook']);
         $this->unregisterExceptions((int) $row['id_hook']);
     }
     foreach ($this->controllers as $controller) {
         $meta = Meta::getMetaByPage('module-' . $this->name . '-' . $controller, $this->context->language->id);
         if ((int) $meta['id_meta'] > 0) {
             Db::getInstance()->execute('DELETE FROM `' . _DB_PREFIX_ . 'theme_meta` WHERE id_meta=' . (int) $meta['id_meta']);
             Db::getInstance()->execute('DELETE FROM `' . _DB_PREFIX_ . 'meta` WHERE id_meta=' . (int) $meta['id_meta']);
         }
     }
     // Disable the module for all shops
     $this->disable(true);
     // Delete permissions module access
     Db::getInstance()->execute('DELETE FROM `' . _DB_PREFIX_ . 'module_access` WHERE `id_module` = ' . (int) $this->id);
     // Remove restrictions for client groups
     Group::truncateRestrictionsByModule($this->id);
     // Uninstall the module
     if (Db::getInstance()->execute('DELETE FROM `' . _DB_PREFIX_ . 'module` WHERE `id_module` = ' . (int) $this->id)) {
         Cache::clean('Module::isInstalled' . $this->name);
         return true;
     }
     return false;
 }
Exemplo n.º 8
0
 public function hookHeader($params)
 {
     // Better way to check which file / controller name is loaded
     if (!($file = basename(Tools::getValue('controller')))) {
         $file = str_replace(array('.php', '-'), '', basename($_SERVER['SCRIPT_NAME']));
     }
     // Otherwise, create Google Analytics stats
     $ganalytics_id = Configuration::get('GANALYTICS_ID');
     $multilang = method_exists('Language', 'isMultiLanguageActivated') ? Language::isMultiLanguageActivated() : Language::countActiveLanguages() > 1;
     $defaultMetaOrder = Meta::getMetaByPage('order', $this->context->language->id);
     $order = ($multilang ? (string) Tools::getValue('isolang') . '/' : '') . $defaultMetaOrder['url_rewrite'];
     $pageTrack = preg_match('#(^' . __PS_BASE_URI__ . 'order.php)|(^' . __PS_BASE_URI__ . ($multilang ? (string) Tools::getValue('isolang') . '/' : '') . $defaultMetaOrder['url_rewrite'] . '[^-])#', $_SERVER['REQUEST_URI']) ? '/order/step' . (int) Tools::getValue('step') . '.html' : $file;
     $this->context->smarty->assign('ganalytics_id', $ganalytics_id);
     $this->context->smarty->assign('pageTrack', $pageTrack);
     $this->context->smarty->assign('isOrder', false);
     return $this->display(__FILE__, 'header.tpl');
 }
 public function getStaticPages($id_lang = null)
 {
     $statics = array();
     $staticPages = array('contact', 'sitemap', 'stores', 'authentication', 'my-account');
     foreach ($staticPages as $staticPage) {
         $meta = Meta::getMetaByPage($staticPage, $id_lang ? (int) $id_lang : (int) Context::getContext()->language->id);
         $statics[] = ['id_cms' => $staticPage, 'title' => $meta['title']];
     }
     $pages[]['pages'] = $statics;
     return $pages;
 }
Exemplo n.º 10
0
 /**
  * Get meta tags for a given page
  *
  * @param integer $id_lang Language id
  * @return array Meta tags
  */
 public static function getHomeMetaTags($id_lang, $page_name)
 {
     /* Metas-tags */
     $metas = Meta::getMetaByPage($page_name, $id_lang);
     $ret['meta_title'] = (isset($metas['title']) and $metas['title']) ? $metas['title'] . ' - ' . Configuration::get('PS_SHOP_NAME') : Configuration::get('PS_SHOP_NAME');
     $ret['meta_description'] = (isset($metas['description']) and $metas['description']) ? $metas['description'] : '';
     $ret['meta_keywords'] = (isset($metas['keywords']) and $metas['keywords']) ? $metas['keywords'] : '';
     return $ret;
 }
Exemplo n.º 11
0
 function hookHeader($params)
 {
     if (method_exists('Language', 'isMultiLanguageActivated') && Language::isMultiLanguageActivated() || Language::countActiveLanguages() > 1) {
         $multilang = (string) Tools::getValue('isolang') . '/';
     } else {
         $multilang = '';
     }
     $defaultMetaOrder = Meta::getMetaByPage('order', $this->context->language->id);
     if (strpos($_SERVER['REQUEST_URI'], __PS_BASE_URI__ . 'order.php') === 0 || strpos($_SERVER['REQUEST_URI'], __PS_BASE_URI__ . $multilang . $defaultMetaOrder['url_rewrite']) === 0) {
         $this->context->smarty->assign('pageTrack', '/order/step' . (int) Tools::getValue('step') . '.html');
     }
     $this->context->smarty->assign('ganalytics_id', Configuration::get('GANALYTICS_ID'));
     $this->context->smarty->assign('isOrder', false);
     return $this->display(__FILE__, 'header.tpl');
 }
Exemplo n.º 12
0
 /**
  * Get meta tags for a given page
  *
  * @param int    $idLang   Language ID
  * @param string $pageName Page name
  *
  * @return array Meta tags
  *
  * @since 1.5.0
  */
 public static function getHomeMetas($idLang, $pageName)
 {
     $metas = Meta::getMetaByPage($pageName, $idLang);
     $ret['meta_title'] = isset($metas['title']) && $metas['title'] ? $metas['title'] : Configuration::get('PS_SHOP_NAME');
     $ret['meta_description'] = isset($metas['description']) && $metas['description'] ? $metas['description'] : '';
     $ret['meta_keywords'] = isset($metas['keywords']) && $metas['keywords'] ? $metas['keywords'] : '';
     return $ret;
 }
Exemplo n.º 13
0
 function hookHeader($params)
 {
     // Better way to check which file / controller name is loaded
     if (!($file = basename(Tools::getValue('controller')))) {
         $file = str_replace(array('.php', '-'), '', basename($_SERVER['SCRIPT_NAME']));
     }
     #PNM-30 - Order confirmation wasn't tracked
     // If other controller / file name need to be done, add it to the array
     // if (in_array(v, array('orderconfirmation')))
     // return '';
     // Otherwise, create Google Analytics stats
     $ganalytics_id = Configuration::get('GANALYTICS_ID');
     $multilang = method_exists('Language', 'isMultiLanguageActivated') ? Language::isMultiLanguageActivated() : Language::countActiveLanguages() > 1;
     $defaultMetaOrder = Meta::getMetaByPage('order', $this->context->language->id);
     $order = ($multilang ? (string) Tools::getValue('isolang') . '/' : '') . $defaultMetaOrder['url_rewrite'];
     $pageTrack = strpos($_SERVER['REQUEST_URI'], __PS_BASE_URI__ . 'order.php') === 0 || strpos($_SERVER['REQUEST_URI'], __PS_BASE_URI__ . ($multilang ? (string) Tools::getValue('isolang') . '/' : '') . $defaultMetaOrder['url_rewrite']) === 0 ? '/order/step' . (int) Tools::getValue('step') . '.html' : $file;
     $this->context->smarty->assign('ganalytics_id', $ganalytics_id);
     $this->context->smarty->assign('pageTrack', $pageTrack);
     $this->context->smarty->assign('isOrder', false);
     return $this->display(__FILE__, 'header.tpl');
 }
Exemplo n.º 14
0
 /**
  * Get meta tags for a given page
  *
  * @since 1.5.0
  * @param int $id_lang
  * @param string $page_name
  * @return array Meta tags
  */
 public static function getHomeMetas($id_lang, $page_name)
 {
     $metas = Meta::getMetaByPage($page_name, $id_lang);
     //   var_dump($metas);exit();
     $ret['meta_title'] = isset($metas['title']) && $metas['title'] ? $metas['title'] : Configuration::get('PS_SHOP_NAME');
     $ret['meta_description'] = isset($metas['description']) && $metas['description'] ? $metas['description'] : '';
     $ret['meta_keywords'] = isset($metas['keywords']) && $metas['keywords'] ? $metas['keywords'] : '';
     $ret['meta_content'] = isset($metas['content']) && $metas['content'] ? $metas['content'] : '';
     $ret['meta_urlrewrite'] = isset($metas['url_rewrite']) && $metas['url_rewrite'] ? $metas['url_rewrite'] : '';
     return $ret;
 }
Exemplo n.º 15
0
 function hookHeader($params)
 {
     global $smarty, $cookie;
     // hookOrderConfirmation() already send the sats bypass this step
     if (strpos($_SERVER['REQUEST_URI'], __PS_BASE_URI__ . 'order-confirmation.php') === 0) {
         return '';
     }
     // Otherwise, create Google Analytics stats
     $ganalytics_id = Configuration::get('GANALYTICS_ID');
     $multilang = Language::countActiveLanguages() > 1;
     $defaultMetaOrder = Meta::getMetaByPage('order', (int) $cookie->id_lang);
     $order = ($multilang ? (string) Tools::getValue('isolang') . '/' : '') . $defaultMetaOrder['url_rewrite'];
     $pageTrack = strpos($_SERVER['REQUEST_URI'], __PS_BASE_URI__ . 'order.php') === 0 || strpos($_SERVER['REQUEST_URI'], __PS_BASE_URI__ . ($multilang ? (string) Tools::getValue('isolang') . '/' : '') . $defaultMetaOrder['url_rewrite']) === 0 ? '/order/step' . (int) Tools::getValue('step') . '.html' : '';
     $smarty->assign('ganalytics_id', $ganalytics_id);
     $smarty->assign('pageTrack', $pageTrack);
     $smarty->assign('isOrder', false);
     return $this->display(__FILE__, 'header.tpl');
 }
Exemplo n.º 16
0
 private function fomartLink($item = null, $id_lang = null)
 {
     if (is_null($item)) {
         return;
     }
     if (!empty($this->context->controller->php_self)) {
         $page_name = $this->context->controller->php_self;
     } else {
         $page_name = Dispatcher::getInstance()->getController();
         $page_name = preg_match('/^[0-9]/', $page_name) ? 'page_' . $page_name : $page_name;
     }
     $html = '';
     $selected_item = false;
     if (is_null($id_lang)) {
         $id_lang = (int) $this->context->language->id;
     }
     $type = substr($item['link'], 0, 3);
     $key = substr($item['link'], 3, strlen($item['link']) - 3);
     switch ($type) {
         case 'CAT':
             if ($page_name == 'category' && (int) Tools::getValue('id_category') == (int) $key) {
                 $selected_item = true;
             }
             $html = $this->context->link->getCategoryLink((int) $key, null, $id_lang);
             break;
         case 'CMS':
             if ($page_name == 'cms' && (int) Tools::getValue('id_cms') == (int) $key) {
                 $selected_item = true;
             }
             $html = $this->context->link->getCMSLink((int) $key, null, $id_lang);
             break;
         case 'MAN':
             if ($page_name == 'manufacturer' && (int) Tools::getValue('id_manufacturer') == (int) $key) {
                 $selected_item = true;
             }
             $man = new Manufacturer((int) $key, $id_lang);
             $html = $this->context->link->getManufacturerLink($man->id, $man->link_rewrite, $id_lang);
             break;
         case 'SUP':
             if ($page_name == 'supplier' && (int) Tools::getValue('id_supplier') == (int) $key) {
                 $selected_item = true;
             }
             $sup = new Supplier((int) $key, $id_lang);
             $html = $this->context->link->getSupplierLink($sup->id, $sup->link_rewrite, $id_lang);
             break;
         case 'PAG':
             $pag = Meta::getMetaByPage($key, $id_lang);
             $html = $this->context->link->getPageLink($pag['page'], true, $id_lang);
             if ($page_name == $pag['page']) {
                 $selected_item = true;
             }
             break;
         case 'SHO':
             $shop = new Shop((int) $key);
             $html = $shop->getBaseURL();
             break;
         default:
             $html = $item['link'];
             break;
     }
     return array('link' => $html, 'selected_item' => $selected_item);
 }
Exemplo n.º 17
0
*  International Registered Trademark & Property of PrestaShop SA
*/
include dirname(__FILE__) . '/../../config/config.inc.php';
require_once dirname(__FILE__) . '/../../init.php';
if (!Module::getInstanceByName('feeder')->active) {
    exit;
}
// Get data
$number = (int) Tools::getValue('n') ? (int) Tools::getValue('n') : 10;
$orderBy = Tools::getProductsOrder('by', Tools::getValue('orderby'));
$orderWay = Tools::getProductsOrder('way', Tools::getValue('orderway'));
$id_category = (int) Tools::getValue('id_category') ? (int) Tools::getValue('id_category') : Configuration::get('PS_HOME_CATEGORY');
$products = Product::getProducts((int) Context::getContext()->language->id, 0, $number > 10 ? 10 : $number, $orderBy, $orderWay, $id_category, true);
$currency = new Currency((int) Context::getContext()->currency->id);
$affiliate = Tools::getValue('ac') ? '?ac=' . (int) Tools::getValue('ac') : '';
$metas = Meta::getMetaByPage('index', (int) Context::getContext()->language->id);
// Send feed
header("Content-Type:text/xml; charset=utf-8");
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
?>
<rss version="2.0">
	<channel>
		<title><![CDATA[<?php 
echo Configuration::get('PS_SHOP_NAME');
?>
]]></title>
		<description><![CDATA[<?php 
echo $metas['description'];
?>
]]></description>
		<link><?php 
 public function renderList()
 {
     $view = Tools::getValue('view', 'default');
     $id_lang = $this->context->language->id;
     $id_shop = $this->context->shop->id;
     if ($view == 'default') {
         $languages = Language::getLanguages(false);
         $id_lang_default = (int) Configuration::get('PS_LANG_DEFAULT');
         $tpl = $this->createTemplate('oviclayout.tpl');
         $id_tab = (int) Tools::getValue('id_tab', 0);
         $current_id_option = Configuration::get('OVIC_CURRENT_OPTION', null, null, $id_shop);
         $check_option = new Options($current_id_option);
         $current_theme = Theme::getThemeInfo($this->context->shop->id_theme);
         if (strtolower($check_option->theme) != strtolower($current_theme['theme_name'])) {
             Configuration::deleteByName('OVIC_CURRENT_OPTION');
             Configuration::deleteByName('OVIC_LAYOUT_COLUMN');
             Configuration::deleteByName('OVIC_CURRENT_DIR');
             $current_id_option = null;
         }
         $emptyOption = false;
         $sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'ovic_options` o
             WHERE LCASE(o.`theme`) =\'' . strtolower($current_theme['theme_name']) . '\'';
         $options = Db::getInstance()->executeS($sql);
         if ($options && is_array($options) && sizeof($options) > 0) {
             if (!$current_id_option || !Validate::isUnsignedId($current_id_option) || !OvicLayoutControl::isAvailablebyId($current_id_option)) {
                 foreach ($options as $option) {
                     $current_option = new Options($option['id_option']);
                     Configuration::updateValue('OVIC_CURRENT_OPTION', $option['id_option'], false, null, $id_shop);
                     Configuration::updateValue('OVIC_CURRENT_DIR', str_replace(' ', '_', $current_option->alias), false, null, $id_shop);
                     $current_id_option = $option['id_option'];
                     break;
                 }
             }
         } else {
             $emptyOption = true;
         }
         if ($options && is_array($options) && sizeof($options) > 0) {
             $current_option = new Options($current_id_option);
         }
         if (!$emptyOption) {
             $selected_layout = Configuration::get('OVIC_LAYOUT_COLUMN', null, null, $id_shop);
             if (!$selected_layout || substr_count($current_option->column, $selected_layout) < 1) {
                 if (strlen($current_option->column) > 0) {
                     $selected_layout = (int) substr($current_option->column, 0, 1);
                     Configuration::updateValue('OVIC_LAYOUT_COLUMN', $selected_layout, false, null, $id_shop);
                     $this->ProcessLayoutColumn();
                 }
             }
         } else {
             $tpl->assign(array('emptyOption' => Tools::displayError('There is no Option, please add new Option from Layout Builder menu.')));
         }
         //get sidebar infomation
         $pagelist = Meta::getMetas();
         $sidebarPages = array();
         if ($pagelist && is_array($pagelist) && sizeof($pagelist) > 0) {
             $theme = new Theme((int) $this->context->shop->id_theme);
             foreach ($pagelist as $page) {
                 $sidebarPage = array();
                 $meta_object = new Meta($page['id_meta']);
                 $title = $page['page'];
                 if (isset($meta_object->title[(int) $id_lang]) && $meta_object->title[(int) $id_lang] != '') {
                     $title = $meta_object->title[(int) $id_lang];
                 }
                 $sidebarPage['id_meta'] = $page['id_meta'];
                 $sidebarPage['title'] = $title;
                 $sidebarPage['page_name'] = $page['page'];
                 $sidebarPage['displayLeft'] = $theme->hasLeftColumn($page['page']) ? 1 : 0;
                 $sidebarPage['displayRight'] = $theme->hasRightColumn($page['page']) ? 1 : 0;
                 $sidebarPages[] = $sidebarPage;
             }
         }
         $tpl->assign(array('postUrl' => self::$currentIndex . '&token=' . Tools::getAdminTokenLite('AdminLayoutSetting'), 'absoluteUrl' => __PS_BASE_URI__ . 'modules/' . $this->module->name, 'id_tab' => $id_tab, 'options' => $options, 'current_option' => isset($current_option) ? $current_option : null, 'selected_layout' => isset($selected_layout) ? $selected_layout : null, 'sidebarPages' => $sidebarPages));
     } elseif ($view == 'detail') {
         $tpl = $this->createTemplate('sidebarmodule.tpl');
         $pagemeta = Tools::getValue('pagemeta');
         $meta = Meta::getMetaByPage($pagemeta, $id_lang);
         $theme = new Theme((int) $this->context->shop->id_theme);
         $LeftModules = array();
         $RightModules = array();
         if ($theme->hasLeftColumn($pagemeta)) {
             $LeftModules = OvicLayoutControl::getSideBarModulesByPage($pagemeta, 'left');
         }
         if ($theme->hasRightColumn($pagemeta)) {
             $RightModules = OvicLayoutControl::getSideBarModulesByPage($pagemeta, 'right');
         }
         $tpl->assign(array('postUrl' => self::$currentIndex . '&token=' . Tools::getAdminTokenLite('AdminLayoutSetting'), 'leftModule' => $LeftModules, 'rightModule' => $RightModules, 'pagemeta' => $pagemeta, 'pagename' => $meta['title'], 'displayLeft' => $theme->hasLeftColumn($pagemeta), 'displayRight' => $theme->hasRightColumn($pagemeta), 'templatePath' => $this->getTemplatePath(), 'moduleDir' => _MODULE_DIR_));
     }
     return $tpl->fetch();
 }
Exemplo n.º 19
0
 public static function generationUrl()
 {
     $value = Tools::getValue('value');
     $response = '';
     if ($value) {
         $langId = Context::getContext()->language->id;
         $shopId = Context::getContext()->shop->id;
         $arr = explode('-', $value);
         switch ($arr[0]) {
             case 'PRD':
                 $product = new Product((int) $arr[1], true, (int) $langId);
                 $response = Tools::HtmlEntitiesUTF8($product->getLink());
                 break;
             case 'CAT':
                 $response = Tools::HtmlEntitiesUTF8(Context::getContext()->link->getCategoryLink((int) $arr[1], null, $langId));
                 break;
             case 'CMS_CAT':
                 $response = Tools::HtmlEntitiesUTF8(Context::getContext()->link->getCMSCategoryLink((int) $arr[1], null, $langId));
                 break;
             case 'CMS':
                 $response = Tools::HtmlEntitiesUTF8(Context::getContext()->link->getCMSLink((int) $arr[1], null, $langId));
                 break;
             case 'ALLMAN':
                 $response = Tools::HtmlEntitiesUTF8(Context::getContext()->link->getPageLink('manufacturer'), true, $langId);
                 break;
             case 'MAN':
                 $man = new Manufacturer((int) $arr[1], $langId);
                 $response = Tools::HtmlEntitiesUTF8(Context::getContext()->link->getManufacturerLink($man->id, $man->link_rewrite, $langId));
                 break;
             case 'ALLSUP':
                 $response = Tools::HtmlEntitiesUTF8(Context::getContext()->link->getPageLink('supplier'), true, $langId);
                 break;
             case 'SUP':
                 $sup = new Supplier((int) $arr[1], $langId);
                 $response = Tools::HtmlEntitiesUTF8(Context::getContext()->link->getSupplierLink($sup->id, $sup->link_rewrite, $langId));
                 break;
             case 'PAG':
                 $pag = Meta::getMetaByPage($arr[1], $langId);
                 $response = Tools::HtmlEntitiesUTF8(Context::getContext()->link->getPageLink($pag['page'], true, $langId));
                 break;
             case 'SHO':
                 $shop = new Shop((int) $key);
                 $response = $shop->getBaseURL();
                 break;
             default:
                 $response = '#';
                 break;
         }
     } else {
         $response = '#';
     }
     die(Tools::jsonEncode($response));
 }
Exemplo n.º 20
0
 private function generateFile($lang, $id_shop)
 {
     $id_lang = (int) $lang['id_lang'];
     $this->shop = new Shop($id_shop);
     $root = Category::getRootCategory($id_lang, $this->shop);
     $this->id_root = $root->id_category;
     // Get module configuration for this shop
     $this->module_conf = $this->getConfigFieldsValues($id_shop);
     // Init categories special attributes :
     // Google's matching category, gender, age_group, color_group, material, pattern, size...
     $this->getGCategValues($id_lang, $id_shop);
     // Init file_path value
     if ($this->module_conf['gen_file_in_root']) {
         $generate_file_path = dirname(__FILE__) . '/../../' . $this->_getOutputFileName($lang['iso_code'], $id_shop);
     } else {
         $generate_file_path = dirname(__FILE__) . '/file_exports/' . $this->_getOutputFileName($lang['iso_code'], $id_shop);
     }
     $meta = Meta::getMetaByPage('index', $id_lang);
     // Google Shopping XML
     $xml = '<?xml version="1.0" encoding="' . self::CHARSET . '" ?>' . "\n";
     $xml .= '<rss version="2.0" xmlns:g="http://base.google.com/ns/1.0">' . "\n\n";
     $xml .= '<channel>' . "\n";
     // Shop name
     $xml .= '<title><![CDATA[' . $this->shop->name . ']]></title>' . "\n";
     // Shop description
     $xml .= '<description><![CDATA[' . $this->getShopDescription($id_lang, $id_shop) . ']]></description>' . "\n";
     $xml .= '<link href="' . htmlspecialchars($this->uri, self::REPLACE_FLAGS, self::CHARSET, false) . '" rel="alternate" type="text/html"/>' . "\n";
     $xml .= '<image>' . "\n";
     $xml .= '<title><![CDATA[' . Configuration::get('PS_SHOP_NAME') . ']]></title>' . "\n";
     $xml .= '<url>' . htmlspecialchars($this->context->link->getMediaLink(_PS_IMG_ . Configuration::get('PS_LOGO')), self::REPLACE_FLAGS, self::CHARSET, false) . '</url>' . "\n";
     $xml .= '<link>' . htmlspecialchars($this->uri, self::REPLACE_FLAGS, self::CHARSET, false) . '</link>' . "\n";
     $xml .= '</image>' . "\n";
     $xml .= '<modified>' . date('Y-m-d') . 'T01:01:01Z</modified>' . "\n";
     $xml .= '<author>' . "\n" . '<name>' . htmlspecialchars(Configuration::get('PS_SHOP_NAME'), self::REPLACE_FLAGS, self::CHARSET, false) . '</name>' . "\n" . '</author>' . "\n\n";
     $googleshoppingfile = fopen($generate_file_path, 'w');
     // Add UTF-8 byte order mark
     fwrite($googleshoppingfile, pack("CCC", 0xef, 0xbb, 0xbf));
     // File header
     fwrite($googleshoppingfile, $xml);
     $sql = 'SELECT p.*, pl.*, ps.id_category_default as category_default, gc.*, gl.* ' . 'FROM ' . _DB_PREFIX_ . 'product p ' . 'LEFT JOIN ' . _DB_PREFIX_ . 'product_lang pl ON pl.id_product = p.id_product ' . 'LEFT JOIN ' . _DB_PREFIX_ . 'product_shop ps ON ps.id_product = p.id_product ' . 'LEFT JOIN ' . _DB_PREFIX_ . 'category c ON c.id_category = ps.id_category_default ' . 'LEFT JOIN ' . _DB_PREFIX_ . 'gshoppingflux gc ON gc.id_gcategory = c.id_category ' . 'LEFT JOIN ' . _DB_PREFIX_ . 'gshoppingflux_lang gl ON gl.id_gcategory = gc.id_gcategory ' . 'WHERE p.active = 1 AND c.active = 1 AND gc.export = 1 ' . 'AND pl.id_lang=' . $id_lang . ' AND gl.id_lang=' . $id_lang;
     // Multishops filter
     if (Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') && count(Shop::getShops(true, null, true)) > 1) {
         $sql .= ' AND gc.id_shop = ' . $id_shop . ' AND pl.id_shop = ' . $id_shop . ' AND ps.id_shop = ' . $id_shop . ' AND gl.id_shop = ' . $id_shop;
     }
     // Check EAN13
     if ($this->module_conf['no_gtin'] != 1) {
         $sql .= ' AND p.ean13 != "" AND p.ean13 != 0';
     }
     // Check BRAND
     if ($this->module_conf['no_brand'] != 1) {
         $sql .= ' AND p.id_manufacturer != "" AND p.id_manufacturer != 0';
     }
     $products = Db::getInstance()->ExecuteS($sql);
     $this->nb_total_products = 0;
     $this->nb_not_exported_products = 0;
     $this->nb_combinations = 0;
     $this->nb_prd_w_attr = array();
     $context = Context::getContext();
     $context->language->id = $id_lang;
     $context->shop->id = $id_shop;
     foreach ($products as $product) {
         $p = new Product($product['id_product'], true, $id_lang, $id_shop, $context);
         $attributeCombinations = $p->getAttributeCombinations($id_lang);
         if ($this->module_conf['mpn_type'] == 'reference' && !empty($product['reference'])) {
             $product['pid'] = $product['reference'];
         } else {
             if ($this->module_conf['mpn_type'] == 'supplier_reference' && !empty($product['supplier_reference'])) {
                 $product['pid'] = $product['supplier_reference'];
             } else {
                 $product['pid'] = $product['id_product'];
             }
         }
         $product['gid'] = $product['pid'];
         if (count($attributeCombinations) > 0 && $this->module_conf['export_attributes'] == 1) {
             $attr = array();
             foreach ($attributeCombinations as $a => $attribute) {
                 $attr[$attribute['id_product_attribute']][$attribute['id_attribute_group']] = $attribute;
             }
             foreach ($attr as $id_attr => $v) {
                 foreach ($v as $k => $a) {
                     foreach ($this->categories_values[$product['id_gcategory']]['gcat_color[]'] as $c) {
                         if ($k == $c) {
                             $product['color'] = $a['attribute_name'];
                         }
                     }
                     foreach ($this->categories_values[$product['id_gcategory']]['gcat_material[]'] as $c) {
                         if ($k == $c) {
                             $product['material'] = $a['attribute_name'];
                         }
                     }
                     foreach ($this->categories_values[$product['id_gcategory']]['gcat_pattern[]'] as $c) {
                         if ($k == $c) {
                             $product['pattern'] = $a['attribute_name'];
                         }
                     }
                     foreach ($this->categories_values[$product['id_gcategory']]['gcat_size[]'] as $c) {
                         if ($k == $c) {
                             $product['size'] = $a['attribute_name'];
                         }
                     }
                     $product['quantity'] = $a['quantity'];
                     $product['weight'] = $a['weight'];
                 }
                 if (empty($product['color']) && empty($product['material']) && empty($product['pattern']) && empty($product['size'])) {
                     continue 2;
                 }
                 $product['item_group_id'] = $product['pid'];
                 $product['gid'] = $product['pid'] . '-' . $id_attr;
                 $xml_googleshopping = $this->getItemXML($product, $lang, $id_shop, $id_attr);
                 fwrite($googleshoppingfile, $xml_googleshopping);
                 $product['color'] = '';
                 $product['material'] = '';
                 $product['pattern'] = '';
                 $product['size'] = '';
             }
         } else {
             $xml_googleshopping = $this->getItemXML($product, $lang, $id_shop);
             fwrite($googleshoppingfile, $xml_googleshopping);
         }
     }
     $xml = '</channel>' . "\n" . '</rss>';
     fwrite($googleshoppingfile, $xml);
     fclose($googleshoppingfile);
     @chmod($generate_file_path, 0777);
     return array('nb_products' => $this->nb_total_products, 'nb_combinations' => $this->nb_combinations, 'nb_prod_w_attr' => count($this->nb_prd_w_attr), 'non_exported_products' => $this->nb_not_exported_products);
 }