private function _getDefaultShopUrl() { if (version_compare(_PS_VERSION_, '1.5', '>')) { $shop = new Shop(Configuration::get('PS_SHOP_DEFAULT')); return $shop->getBaseURL(); } else { return __PS_BASE_URI__; } }
public function renderChoicesSelect() { $spacer = str_repeat(' ', $this->spacer_size); $items = $this->getMenuItems(); $html = '<select multiple="multiple" id="availableItems" style="width: 300px; height: 160px;">'; $html .= '<optgroup label="' . $this->l('CMS') . '">'; $html .= $this->getCMSOptions(0, 1, $this->context->language->id, $items); $html .= '</optgroup>'; // BEGIN SUPPLIER $html .= '<optgroup label="' . $this->l('Supplier') . '">'; // Option to show all Suppliers $html .= '<option value="ALLSUP0">' . $this->l('All suppliers') . '</option>'; $suppliers = Supplier::getSuppliers(false, $this->context->language->id); foreach ($suppliers as $supplier) { if (!in_array('SUP' . $supplier['id_supplier'], $items)) { $html .= '<option value="SUP' . $supplier['id_supplier'] . '">' . $spacer . $supplier['name'] . '</option>'; } } $html .= '</optgroup>'; // BEGIN Manufacturer $html .= '<optgroup label="' . $this->l('Manufacturer') . '">'; // Option to show all Manufacturers $html .= '<option value="ALLMAN0">' . $this->l('All manufacturers') . '</option>'; $manufacturers = Manufacturer::getManufacturers(false, $this->context->language->id); foreach ($manufacturers as $manufacturer) { if (!in_array('MAN' . $manufacturer['id_manufacturer'], $items)) { $html .= '<option value="MAN' . $manufacturer['id_manufacturer'] . '">' . $spacer . $manufacturer['name'] . '</option>'; } } $html .= '</optgroup>'; // BEGIN Categories $shop = new Shop((int) Shop::getContextShopID()); $html .= '<optgroup label="' . $this->l('Categories') . '">'; $shops_to_get = Shop::getContextListShopID(); foreach ($shops_to_get as $shop_id) { $html .= $this->generateCategoriesOption($this->customGetNestedCategories($shop_id, null, (int) $this->context->language->id, false), $items); } $html .= '</optgroup>'; // BEGIN Shops if (Shop::isFeatureActive()) { $html .= '<optgroup label="' . $this->l('Shops') . '">'; $shops = Shop::getShopsCollection(); foreach ($shops as $shop) { if (!$shop->setUrl() && !$shop->getBaseURL()) { continue; } if (!in_array('SHOP' . (int) $shop->id, $items)) { $html .= '<option value="SHOP' . (int) $shop->id . '">' . $spacer . $shop->name . '</option>'; } } $html .= '</optgroup>'; } // BEGIN Products $html .= '<optgroup label="' . $this->l('Products') . '">'; $html .= '<option value="PRODUCT" style="font-style:italic">' . $spacer . $this->l('Choose product ID') . '</option>'; $html .= '</optgroup>'; // BEGIN Menu Top Links $html .= '<optgroup label="' . $this->l('Menu Top Links') . '">'; $links = MenuTopLinks::gets($this->context->language->id, null, (int) Shop::getContextShopID()); foreach ($links as $link) { if ($link['label'] == '') { $default_language = Configuration::get('PS_LANG_DEFAULT'); $link = MenuTopLinks::get($link['id_linksmenutop'], $default_language, (int) Shop::getContextShopID()); if (!in_array('LNK' . (int) $link[0]['id_linksmenutop'], $items)) { $html .= '<option value="LNK' . (int) $link[0]['id_linksmenutop'] . '">' . $spacer . Tools::safeOutput($link[0]['label']) . '</option>'; } } elseif (!in_array('LNK' . (int) $link['id_linksmenutop'], $items)) { $html .= '<option value="LNK' . (int) $link['id_linksmenutop'] . '">' . $spacer . Tools::safeOutput($link['label']) . '</option>'; } } $html .= '</optgroup>'; $html .= '</select>'; return $html; }
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)); }
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); }
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; }
public function api_3_0_refreshtoken() { $params = array('client_id' => Configuration::get('PS_GAPI30_CLIENT_ID'), 'client_secret' => Configuration::get('PS_GAPI30_CLIENT_SECRET')); // https://developers.google.com/accounts/docs/OAuth2WebServer#offline if (Configuration::get('PS_GAPI30_REFRESH_TOKEN')) { $params['grant_type'] = 'refresh_token'; $params['refresh_token'] = Configuration::get('PS_GAPI30_REFRESH_TOKEN'); } else { $shop = new Shop(Shop::getContextShopID(true)); $params['grant_type'] = 'authorization_code'; $params['code'] = Configuration::get('PS_GAPI30_AUTHORIZATION_CODE'); $params['redirect_uri'] = $shop->getBaseURL(true) . 'modules/' . $this->name . '/oauth2callback.php'; } $content = http_build_query($params); $stream_context = stream_context_create(array('http' => array('method' => 'POST', 'content' => $content, 'header' => "Content-type: application/x-www-form-urlencoded\r\nContent-length: " . strlen($content) . "\r\n", 'timeout' => 5))); if (!($response_json = Tools::file_get_contents('https://accounts.google.com/o/oauth2/token', false, $stream_context))) { return false; } $response = Tools::jsonDecode($response_json, true); if (isset($response['error'])) { return false; } Configuration::updateValue('PS_GAPI30_ACCESS_TOKEN', $response['access_token']); Configuration::updateValue('PS_GAPI30_TOKEN_EXPIRATION', time() + (int) $response['expires_in']); if (isset($response['refresh_token'])) { Configuration::updateValue('PS_GAPI30_REFRESH_TOKEN', $response['refresh_token']); } return true; }
'; break; case 'state': /*$sql = 'SELECT distinct s.id_state AS id, s.name AS name FROM `'._DB_PREFIX_.'state` s INNER JOIN `'._DB_PREFIX_.'sellerinfo` si ON s.id_state = si.id_state
private function getDataToQr() { $this->setContext(); $array = array(); $shop_info = new Shop((int) Configuration::get('PS_SHOP_DEFAULT')); $shop_url = $shop_info->getBaseURL(); $store_url = str_replace('http://', '', $shop_url); $store_url = str_replace('https://', '', $store_url); preg_replace('/\\/*$/i', '', $store_url); $array['url'] = $store_url; $data = unserialize(Configuration::get('MOBASSISTANTCONNECTOR')); $array['login'] = $data['login']; $array['password'] = $data['password']; return $array; }
protected function displaySeoUrlList() { $id_search = Tools::getValue('id_search'); $this->_startForm(array('id' => 'SEOURLListForm')); $this->_displayTitle($this->l('SEO URL list')); $this->_showInfo($this->l('You will find here the list of all the SEO URLs pages you have created for this search engine. You have to add them in your menu, slideshow, footer, blocks, or anywhere you want in your website for Google crawling')); $seoSearchs = AdvancedSearchSeoClass::getSeoSearchs($this->_cookie->id_lang, false, $id_search); if ($seoSearchs && self::_isFilledArray($seoSearchs)) { $new_SeoSearch = array(); foreach ($seoSearchs as $row) { $resultTotalProducts = $this->countProductFromSeoCriteria($id_search, unserialize($row['criteria']), $row['id_currency']); $ObjAdvancedSearchSeoClass = new AdvancedSearchSeoClass($row['id_seo'], null); if (version_compare(_PS_VERSION_, '1.5.0.0', '>=') && Shop::isFeatureActive()) { $shopUrl = new Shop($this->_context->shop->id); $base_url = $shopUrl->getBaseURL(); } else { $base_url = Tools::getShopDomain(true) . __PS_BASE_URI__; } if (version_compare(_PS_VERSION_, '1.5.0.0', '>=') && Configuration::get('PS_SSL_ENABLED') && Configuration::get('PS_SSL_ENABLED_EVERYWHERE')) { $base_url = 'https://' . ltrim($base_url, 'http://'); } foreach ($this->_languages as $language) { $url = $base_url . (Language::countActiveLanguages() > 1 ? $language['iso_code'] . '/' : '') . 's/' . (int) $ObjAdvancedSearchSeoClass->id . '/' . $ObjAdvancedSearchSeoClass->seo_url[$language['id_lang']]; $title = htmlentities($ObjAdvancedSearchSeoClass->title[$language['id_lang']], ENT_COMPAT, 'UTF-8'); $new_SeoSearch[$language['id_lang']][$ObjAdvancedSearchSeoClass->id]['url'] = $url; $new_SeoSearch[$language['id_lang']][$ObjAdvancedSearchSeoClass->id]['title'] = $title; } } $seoSearchs = $new_SeoSearch; unset($new_SeoSearch); if ($seoSearchs && self::_isFilledArray($seoSearchs)) { $this->_html .= '<p>' . $this->l('Please select the language :') . '<p>'; $this->displayPMFlags(); $this->_html .= '<div class="clear"></div>'; foreach ($seoSearchs as $id_lang => $seo_urls) { $this->_html .= '<div id="langseo_url_' . $id_lang . '" class="pmFlag pmFlagLang_' . $id_lang . '" style="display: ' . ($id_lang == $this->_default_language ? 'block' : 'none') . '; float: left;">'; $this->_html .= '<h3>' . $this->l('HTML version:') . '</h3>'; $this->_html .= '<textarea cols="110" rows="10">'; $this->_html .= htmlentities('<ul>', ENT_COMPAT, 'UTF-8') . "\n"; foreach ($seo_urls as $seo_url) { $this->_html .= htmlentities('<li><a href="' . $seo_url['url'] . '" title="' . $seo_url['title'] . '">' . $seo_url['title'] . '</a></li>', ENT_COMPAT, 'UTF-8') . "\n"; } $this->_html .= htmlentities('</ul>', ENT_COMPAT, 'UTF-8') . "\n"; $this->_html .= '</textarea>'; $this->_html .= '<h3>' . $this->l('CSV version:') . '</h3>'; $this->_html .= '<textarea cols="110" rows="10">'; foreach ($seo_urls as $seo_url) { $this->_html .= '"' . $seo_url['title'] . '";"' . $seo_url['url'] . '"' . "\n"; } $this->_html .= '</textarea>'; $this->_html .= '</div>'; } } } else { $this->_showInfo($this->l('No seo page at this time please add one')); } $this->_endForm(array('id' => 'SEOURLListForm')); }