Example #1
0
 /**
  * getShopDomain returns domain name according to configuration and ignoring ssl
  *
  * @param boolean $http if true, return domain name with protocol
  * @param boolean $entities if true,
  *
  * @return string domain
  */
 public static function getShopDomain($http = false, $entities = false)
 {
     if (!($domain = ShopUrl::getMainShopDomain())) {
         $domain = Tools::getHttpHost();
     }
     if ($entities) {
         $domain = htmlspecialchars($domain, ENT_COMPAT, 'UTF-8');
     }
     if ($http) {
         $domain = 'http://' . $domain;
     }
     return $domain;
 }
 public function getPreviewUrl(SmartBlogPost $smart_blog_post)
 {
     $id_lang = Configuration::get('PS_LANG_DEFAULT', null, null, Context::getContext()->shop->id);
     if (!ShopUrl::getMainShopDomain()) {
         return false;
     }
     $is_rewrite_active = (bool) Configuration::get('PS_REWRITING_SETTINGS');
     $blog_url = $preview_url = smartblog::GetSmartBlogLink('smartblog_post', array('id_post' => $smart_blog_post->id, 'slug' => $smart_blog_post->link_rewrite[$id_lang]));
     if (!$smart_blog_post->active) {
         $admin_dir = dirname($_SERVER['PHP_SELF']);
         $admin_dir = substr($admin_dir, strrpos($admin_dir, '/') + 1);
         $preview_url .= (strpos($preview_url, '?') === false ? '?' : '&') . 'adtoken=' . $this->token . '&ad=' . $admin_dir . '&id_employee=' . (int) $this->context->employee->id;
     }
     return $preview_url;
 }
Example #3
0
 public function getPreviewUrl(Product $product)
 {
     $id_lang = Configuration::get('PS_LANG_DEFAULT', null, null, Context::getContext()->shop->id);
     if (!ShopUrl::getMainShopDomain()) {
         return false;
     }
     $is_rewrite_active = (bool) Configuration::get('PS_REWRITING_SETTINGS');
     $preview_url = $this->context->link->getProductLink($product, $this->getFieldValue($product, 'link_rewrite', $this->context->language->id), Category::getLinkRewrite($this->getFieldValue($product, 'id_category_default'), $this->context->language->id), null, $id_lang, (int) Context::getContext()->shop->id, 0, $is_rewrite_active);
     if (!$product->active) {
         $admin_dir = dirname($_SERVER['PHP_SELF']);
         $admin_dir = substr($admin_dir, strrpos($admin_dir, '/') + 1);
         $preview_url .= (strpos($preview_url, '?') === false ? '?' : '&') . 'adtoken=' . $this->token . '&ad=' . $admin_dir . '&id_employee=' . (int) $this->context->employee->id;
     }
     return $preview_url;
 }
 public function ajaxProcessCronjobLiveExchangeRate()
 {
     $moduleManagerBuilder = ModuleManagerBuilder::getInstance();
     $moduleManager = $moduleManagerBuilder->build();
     if (!$moduleManager->isInstalled('cronjobs')) {
         die(json_encode(array()));
     }
     $enable = (int) Tools::getValue('enable');
     $config = Configuration::get('PS_ACTIVE_CRONJOB_EXCHANGE_RATE', null, null, $this->context->shop->id);
     $cronJobUrl = 'http://' . ShopUrl::getMainShopDomain($this->context->shop->id) . __PS_BASE_URI__ . basename(_PS_ADMIN_DIR_) . '/cron_currency_rates.php?secure_key=' . md5(_COOKIE_KEY_ . Configuration::get('PS_SHOP_NAME'));
     if ($config && $enable == 0) {
         Configuration::updateValue('PS_ACTIVE_CRONJOB_EXCHANGE_RATE', 0, false, null, $this->context->shop->id);
         Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'cronjobs WHERE `id_cronjob` = \'' . (int) $config . '\'');
     }
     //The cronjob is not defined, create it
     if ($enable == 1 && (!$config || $config == 0)) {
         $cronJobs = new CronJobs();
         $cronJobs->addOneShotTask($cronJobUrl, sprintf($this->l('Live exchange Rate for %s'), Configuration::get('PS_SHOP_NAME')));
         Configuration::updateValue('PS_ACTIVE_CRONJOB_EXCHANGE_RATE', Db::getInstance()->Insert_ID(), false, null, $this->context->shop->id);
     } else {
         $cronJob = Db::getInstance()->executeS('SELECT * FROM ' . _DB_PREFIX_ . 'cronjobs WHERE `id_cronjob` = \'' . (int) $config . '\'');
         //if cronjob do not exsit anymore OR cronjob dis disabled => disable conf
         if (!$cronJob || $cronJob[0]['active'] == 0) {
             Configuration::updateValue('PS_ACTIVE_CRONJOB_EXCHANGE_RATE', 0, false, null, $this->context->shop->id);
         }
     }
     die(json_encode(array()));
 }