Example #1
0
 /**
  * Return the friendly url from the provided string.
  *
  * @param string $str
  * @param bool   $utf8_decode (deprecated)
  *
  * @return string
  */
 public function link_rewrite($str, $utf8_decode = null)
 {
     if ($utf8_decode !== null) {
         \ToolsCore::displayParameterAsDeprecated('utf8_decode');
     }
     return \ToolsCore::str2url($str);
 }
 /**
  * Delete a product attribute
  *
  * @param int $idAttribute The attribute ID
  * @param int $idProduct The product ID
  *
  * @return array
  */
 public function ajaxProcessDeleteProductAttribute($idAttribute, $idProduct)
 {
     if (!\CombinationCore::isFeatureActive()) {
         return false;
     }
     if ($idProduct && \ValidateCore::isUnsignedId($idProduct) && \ValidateCore::isLoadedObject($product = new \ProductCore($idProduct))) {
         if (($depends_on_stock = \StockAvailableCore::dependsOnStock($idProduct)) && \StockAvailableCore::getQuantityAvailableByProduct($idProduct, $idAttribute)) {
             return array('status' => 'error', 'message' => 'It is not possible to delete a combination while it still has some quantities in the Advanced Stock Management. You must delete its stock first.');
         } else {
             $product->deleteAttributeCombination((int) $idAttribute);
             $product->checkDefaultAttributes();
             \ToolsCore::clearColorListCache((int) $product->id);
             if (!$product->hasAttributes()) {
                 $product->cache_default_attribute = 0;
                 $product->update();
             } else {
                 \ProductCore::updateDefaultAttribute($idProduct);
             }
             if ($depends_on_stock && !\StockCore::deleteStockByIds($idProduct, $idAttribute)) {
                 return array('status' => 'error', 'message' => 'Error while deleting the stock');
             } else {
                 return array('status' => 'ok', 'message' => 'Successful deletion');
             }
         }
     } else {
         return array('status' => 'error', 'message' => 'You cannot delete this attribute.');
     }
 }
 public static function getPath($id_category, $path = '', $link_on_the_item = false, $category_type = 'products', Context $context = null)
 {
     if (ConfigurationCore::get('PST_DISPLAY_LAST_BREADCRUMB') == false) {
         $path = '';
     }
     return parent::getPath($id_category, $path, $link_on_the_item, $category_type, $context);
 }
Example #4
0
 public static function generateHtaccess($path = null, $rewrite_settings = null, $cache_control = null, $specific = '', $disable_multiviews = null, $medias = false, $disable_modsec = null)
 {
     if (Module::isInstalled('agilemultipleseller')) {
         AgileSellerManager::ensure_configuration_record_for_all_shops();
         Configuration::loadConfiguration();
         return self::generateHtaccess_override($path, $rewrite_settings, $cache_control, $specific, $disable_multiviews, $medias, $disable_modsec, $disable_modsec);
     }
     return parent::generateHtaccess($path, $rewrite_settings, $cache_control, $specific, $disable_multiviews, $medias, $disable_modsec);
 }
function getPreinstallXmlLang($object, $field)
{
    if (ToolsCore::property_exists($object, $field . '_' . ((int) $_GET['language'] + 1))) {
        return str_replace(array('!|', '|!'), array('<', '>'), trim($object->{$field . '_' . ((int) $_GET['language'] + 1)}));
    }
    if (ToolsCore::property_exists($object, $field . '_1')) {
        return str_replace(array('!|', '|!'), array('<', '>'), trim($object->{$field . '_1'}));
    }
    return '';
}
Example #6
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);
 }
Example #7
0
 /**
  * Registered as kernel.request event listener.
  *
  * If the condition needs a redirection to HTTPS, then the current process is interrupted, the headers are sent directly.
  *
  * @param GetResponseEvent $event
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     // already SSL, do nothing more
     if (\ToolsCore::usingSecureMode()) {
         return;
     }
     $enabled = 1 == \Configuration::get('PS_SSL_ENABLED');
     $forced = 1 == \Configuration::get('PS_SSL_ENABLED_EVERYWHERE');
     $serverParams = $event->getRequest()->server;
     $refererSsl = $serverParams->has('HTTP_REFERER') && strpos($serverParams->get('HTTP_REFERER'), 'https') === 0;
     if ($enabled && ($forced || $refererSsl)) {
         $this->redirectToSsl($event);
     }
 }
 function __construct()
 {
     $this->name = 'googleshopping';
     $this->tab = 'export';
     $this->version = '1.3';
     $this->author = 'https://github.com/jmartin82/ps_googleshopping';
     parent::__construct();
     $this->page = basename(__FILE__, '.php');
     $this->displayName = $this->l('Google Shopping');
     $this->description = $this->l('Export Google Shoping products');
     $this->need_instance = 0;
     $this->ps_versions_compliancy = array('min' => '1.5', 'max' => '1.7');
     $this->uri = ToolsCore::getCurrentUrlProtocolPrefix() . $this->context->shop->domain_ssl . $this->context->shop->physical_uri;
 }
 function __construct()
 {
     $this->name = 'gshoppingflux';
     $this->tab = 'smart_shopping';
     $this->version = '1.5.6';
     $this->author = 'Dim00z';
     $this->bootstrap = true;
     parent::__construct();
     $this->page = basename(__FILE__, '.php');
     $this->displayName = $this->l('Google Shopping Flux');
     $this->description = $this->l('Export your products to Google Merchant Center, easily.');
     $this->need_instance = 0;
     $this->ps_versions_compliancy = array('min' => '1.5', 'max' => '1.7');
     $this->uri = ToolsCore::getCurrentUrlProtocolPrefix() . $this->context->shop->domain_ssl . $this->context->shop->physical_uri;
     $this->categories_values = array();
 }
    /**
     * Return current category products
     *
     * @param integer $id_lang Language ID
     * @param integer $p Page number
     * @param integer $n Number of products per page
     * @param boolean $get_total return the number of results instead of the results themself
     * @param boolean $active return only active products
     * @param boolean $random active a random filter for returned products
     * @param int $random_number_products number of products to return if random is activated
     * @param boolean $check_access set to false to return all products (even if customer hasn't access)
     * @return mixed Products or number of products
     *	This edit function for right sorting by price
     */
    public function getProducts($id_lang, $p, $n, $order_by = null, $order_way = null, $get_total = false, $active = true, $random = false, $random_number_products = 1, $check_access = true, Context $context = null)
    {
        $manufacturer = ToolsCore::getValue('manufacturer', 0);
        if (!$context) {
            $context = Context::getContext();
        }
        if ($check_access && !$this->checkAccess($context->customer->id)) {
            return false;
        }
        $front = true;
        if (!in_array($context->controller->controller_type, array('front', 'modulefront'))) {
            $front = false;
        }
        if ($p < 1) {
            $p = 1;
        }
        if (empty($order_by)) {
            $order_by = 'position';
        } else {
            /* Fix for all modules which are now using lowercase values for 'orderBy' parameter */
            $order_by = strtolower($order_by);
        }
        if (empty($order_way)) {
            $order_way = 'ASC';
        }
        if ($order_by == 'id_product' || $order_by == 'date_add' || $order_by == 'date_upd') {
            $order_by_prefix = 'p';
        } elseif ($order_by == 'name') {
            $order_by_prefix = 'pl';
        } elseif ($order_by == 'manufacturer') {
            $order_by_prefix = 'm';
            $order_by = 'name';
        } elseif ($order_by == 'position') {
            $order_by_prefix = 'cp';
        }
        if ($order_by == 'price') {
            $order_by = 'orderprice';
        }
        if (!Validate::isBool($active) || !Validate::isOrderBy($order_by) || !Validate::isOrderWay($order_way)) {
            die(Tools::displayError());
        }
        $id_supplier = (int) Tools::getValue('id_supplier');
        /* Return only the number of products */
        if ($get_total) {
            $sql = 'SELECT COUNT(cp.`id_product`) AS total
					FROM `' . _DB_PREFIX_ . 'product` p
					' . Shop::addSqlAssociation('product', 'p') . '
					LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON p.`id_product` = cp.`id_product`
					WHERE cp.`id_category` = ' . (int) $this->id . ($front ? ' AND product_shop.`visibility` IN ("both", "catalog")' : '') . ($active ? ' AND product_shop.`active` = 1' : '') . ($id_supplier ? 'AND p.id_supplier = ' . (int) $id_supplier : '');
            return (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
        }
        $sql = 'SELECT p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, MAX(product_attribute_shop.id_product_attribute) id_product_attribute, product_attribute_shop.minimal_quantity AS product_attribute_minimal_quantity, pl.`description`, pl.`description_short`, pl.`available_now`,
					pl.`available_later`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, MAX(image_shop.`id_image`) id_image,
					il.`legend`, m.`name` AS manufacturer_name, cl.`name` AS category_default,
					DATEDIFF(product_shop.`date_add`, DATE_SUB(NOW(),
					INTERVAL ' . (Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20) . '
						DAY)) > 0 AS new, product_shop.price AS orderprice
				FROM `' . _DB_PREFIX_ . 'category_product` cp
				LEFT JOIN `' . _DB_PREFIX_ . 'product` p
					ON p.`id_product` = cp.`id_product`
				' . Shop::addSqlAssociation('product', 'p') . '
				LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute` pa
				ON (p.`id_product` = pa.`id_product`)
				' . Shop::addSqlAssociation('product_attribute', 'pa', false, 'product_attribute_shop.`default_on` = 1') . '
				' . Product::sqlStock('p', 'product_attribute_shop', false, $context->shop) . '
				LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl
					ON (product_shop.`id_category_default` = cl.`id_category`
					AND cl.`id_lang` = ' . (int) $id_lang . Shop::addSqlRestrictionOnLang('cl') . ')
				LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl
					ON (p.`id_product` = pl.`id_product`
					AND pl.`id_lang` = ' . (int) $id_lang . Shop::addSqlRestrictionOnLang('pl') . ')
				LEFT JOIN `' . _DB_PREFIX_ . 'image` i
					ON (i.`id_product` = p.`id_product`)' . Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1') . '
				LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il
					ON (image_shop.`id_image` = il.`id_image`
					AND il.`id_lang` = ' . (int) $id_lang . ')
				LEFT JOIN `' . _DB_PREFIX_ . 'manufacturer` m
					ON m.`id_manufacturer` = p.`id_manufacturer`
				WHERE product_shop.`id_shop` = ' . (int) $context->shop->id . '
					AND cp.`id_category` = ' . (int) $this->id . ($active ? ' AND product_shop.`active` = 1' : '') . ($front ? ' AND product_shop.`visibility` IN ("both", "catalog")' : '') . ($id_supplier ? ' AND p.id_supplier = ' . (int) $id_supplier : '') . ($manufacturer ? ' AND p.id_manufacturer = ' . (int) $manufacturer : '') . ' GROUP BY product_shop.id_product';
        if ($random === true) {
            $sql .= ' ORDER BY RAND()';
            $sql .= ' LIMIT 0, ' . (int) $random_number_products;
        } else {
            $sql .= ' ORDER BY ' . (isset($order_by_prefix) ? $order_by_prefix . '.' : '') . '`' . pSQL($order_by) . '` ' . pSQL($order_way);
            //custom for right sort by price//
            //LIMIT '.(((int)$p - 1) * (int)$n).','.(int)$n;
            //-------------------------------//
        }
        $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
        if ($order_by == 'orderprice') {
            Tools::orderbyPrice($result, $order_way);
        }
        //-------- custom for right sort by price -----------------//
        $result = array_slice($result, ((int) $p - 1) * (int) $n, (int) $n);
        //--------------------------------------------------------//
        if (!$result) {
            return array();
        }
        /* Modify SQL result */
        return Product::getProductsProperties($id_lang, $result);
    }
Example #11
0
 /**
  * ALIAS OF dieObject() - Display an error with detailed object but don't stop the execution
  * (display in firefox console if Firephp is enabled)
  *
  * @param object $object Object to display
  */
 public static function p($object)
 {
     if (PS_USE_FIREPHP) {
         FB::info($object);
     } else {
         return parent::p($object);
     }
     return $object;
 }
 /**
  * Check and add a Trusted Shops certificate in shop.
  *
  * @uses TSBuyerProtection::_getProtectionItems()
  * 		 to get all buyer protection products from Trusted Shops
  * @uses TSBuyerProtection::_saveProtectionItems()
  * 		 to save buyer protection products in shop
  * @return boolean true if certificate is added successfully, false otherwise
  */
 private function _submitAddCertificate()
 {
     $checked_certificate = false;
     try {
         $checked_certificate = $this->_checkCertificate(ToolsCore::getValue('new_certificate'));
     } catch (TSBPException $e) {
         $this->errors[] = $e->getMessage();
     }
     if ($checked_certificate) {
         TSBuyerProtection::$CERTIFICATE[strtoupper($checked_certificate->certificationLanguage)] = array('stateEnum' => $checked_certificate->stateEnum, 'typeEnum' => $checked_certificate->typeEnum, 'url' => $checked_certificate->url, 'tsID' => $checked_certificate->tsID, 'user' => '', 'password' => '');
         // update the configuration var
         Configuration::updateValue(TSBuyerProtection::PREFIX_TABLE . 'CERTIFICATE_' . strtoupper($checked_certificate->certificationLanguage), Tools::htmlentitiesUTF8(Tools::jsonEncode(TSBuyerProtection::$CERTIFICATE[strtoupper($checked_certificate->certificationLanguage)])));
         $this->confirmations[] = $this->l('Certificate has been added successfully.');
         if ($checked_certificate->typeEnum === 'EXCELLENCE') {
             try {
                 $protection_items = $this->_getProtectionItems($checked_certificate->tsID);
                 if ($protection_items) {
                     $this->_saveProtectionItems($protection_items, $checked_certificate->tsID);
                 }
             } catch (TSBPException $e) {
                 $this->errors[] = $e->getMessage();
             }
         }
         return true;
     }
     return false;
 }
Example #13
0
 /**
  * Check, confirm and add a Trusted Shops certificate in shop.
  *
  * @uses TSCommon::getProtectionItems()
  *         to get all buyer protection products from Trusted Shops
  * @uses TSCommon::saveProtectionItems()
  *         to save buyer protection products in shop
  * @return boolean true if certificate is added successfully, false otherwise
  */
 private function submitConfirmCertificate()
 {
     $checked_certificate = false;
     try {
         $checked_certificate = $this->checkCertificate(ToolsCore::getValue('new_certificate'), Tools::getValue('lang'));
     } catch (TSBPException $e) {
         $this->errors[] = $e->getMessage();
     }
     if ($checked_certificate) {
         TSCommon::$certificates[Tools::strtoupper($checked_certificate->certificationLanguage)] = array('stateEnum' => $checked_certificate->stateEnum, 'typeEnum' => $checked_certificate->typeEnum, 'tsID' => $checked_certificate->tsID, 'url' => $checked_certificate->url, 'user' => '', 'password' => '', 'variant' => 'default', 'yoffset' => '0', 'jscode' => '', 'display_rating_front_end' => '1', 'display_rating_oc' => '0', 'send_separate_mail' => '0', 'send_seperate_mail_delay' => '0', 'send_seperate_mail_order_state' => Configuration::get('PS_OS_SHIPPING'));
         // update the configuration var
         Configuration::updateValue(TSCommon::PREFIX_TABLE . 'CERTIFICATE_' . Tools::strtoupper($checked_certificate->certificationLanguage), Tools::htmlentitiesUTF8(Tools::jsonEncode(TSCommon::$certificates[Tools::strtoupper($checked_certificate->certificationLanguage)])));
         unset(self::$available_languages_for_adding[Tools::strtoupper($checked_certificate->certificationLanguage)]);
         $this->confirmations[] = $this->l('Your Trusted Shops membership is valid.');
         if ($checked_certificate->typeEnum !== 'UNKNOWN') {
             self::registerCertificate($checked_certificate->tsID);
         }
         if ($checked_certificate->typeEnum === 'EXCELLENCE') {
             try {
                 $protection_items = $this->getProtectionItems($checked_certificate->tsID);
                 if ($protection_items) {
                     $this->saveProtectionItems($protection_items, $checked_certificate->tsID);
                 }
             } catch (TSBPException $e) {
                 $this->errors[] = $e->getMessage();
             }
         }
     }
     return (bool) $checked_certificate;
 }
 /**
  * {@inheritdoc}
  */
 public function getPaginationLimitChoices()
 {
     $paginationLimitChoices = [20, 50, 100];
     $memory = \ToolsCore::getMemoryLimit();
     if ($memory >= 512 * 1024 * 1024) {
         $paginationLimitChoices[] = 300;
     }
     if ($memory >= 1536 * 1024 * 1024) {
         $paginationLimitChoices[] = 1000;
     }
     return $paginationLimitChoices;
 }
Example #15
0
 /**
  * Generate preview URL deactivate
  *
  * @param string $preview_url
  *
  * @return string preview url deactivate
  */
 public function getPreviewUrlDeactivate($preview_url)
 {
     $context = \ContextCore::getContext();
     $token = \ToolsCore::getAdminTokenLite('AdminProducts');
     $admin_dir = dirname($_SERVER['PHP_SELF']);
     $admin_dir = substr($admin_dir, strrpos($admin_dir, '/') + 1);
     $preview_url_deactivate = $preview_url . (strpos($preview_url, '?') === false ? '?' : '&') . 'adtoken=' . $token . '&ad=' . $admin_dir . '&id_employee=' . (int) $context->employee->id;
     return $preview_url_deactivate;
 }
Example #16
0
 public function hookHeader()
 {
     $this->context->controller->addCSS($this->_path . 'css/payu.css', 'all');
     if (Tools::getValue('payu_order_error')) {
         return sprintf('<script>alert(%s);</script>', ToolsCore::jsonEncode($this->l('An error occurred when processing the order')));
     }
 }
Example #17
0
 public static function enableCache($level = 1)
 {
     global $smarty;
     if (!Configuration::get('PS_SMARTY_CACHE')) {
         return;
     }
     if ($smarty->force_compile == 0 and $smarty->caching == $level) {
         return;
     }
     self::$_forceCompile = (int) $smarty->force_compile;
     self::$_caching = (int) $smarty->caching;
     $smarty->force_compile = 0;
     $smarty->caching = (int) $level;
 }
Example #18
0
 /**
  * @brief Retrieve the media server to use
  *
  * @param filename Name of the file to serve (acually, part of the path)
  *
  * @todo Check performences
  *
  * @return URL of the server to use.
  */
 public static function getMediaServer($filename, &$protocol = NULL)
 {
     if (!self::_isActive()) {
         return parent::getMediaServer($filename);
     }
     // Init the server list if needed
     if (!self::$_servers) {
         self::_initServers();
     }
     if (!self::$_activatedModule) {
         return parent::getMediaServer($filename);
     }
     // If there is a least one ALL server, then use one of them
     if (self::$_serversCount[CLOUDCACHE_FILE_TYPE_ALL]) {
         $server = self::$_servers[CLOUDCACHE_FILE_TYPE_ALL][abs(crc32($filename)) % self::$_serversCount[CLOUDCACHE_FILE_TYPE_ALL]];
         if ($protocol) {
             $protocol = $server['protocol'];
         }
         return $server['url'];
     }
     // If there is servers, then use them
     if (self::$_totalServerCount) {
         // Loop on the file types to find the current one
         foreach (self::$_fileTypes as $type) {
             // If we find the type in the filename, then it is our
             if (strstr($filename, $type) && self::$_serversCount[$type]) {
                 // Return one of those server
                 $server = self::$_servers[$type][abs(crc32($filename)) % self::$_serversCount[$type]];
                 if ($protocol) {
                     $protocol = $server['protocol'];
                 }
                 return $server['url'];
             }
         }
         // If no file type found, then it is 'other'
         // If there is server setted for the 'other' type, use it
         if (self::$_serversCount[CLOUDCACHE_FILE_TYPE_OTHER]) {
             // Return one of the server setted up
             $server = self::$_servers[$type][abs(crc32($filename)) % self::$_serversCount[$type]];
             if ($protocol) {
                 $protocol = $server['protocol'];
             }
             return $server['url'];
         }
     }
     // If there is no server setted up, then use the parent method
     return parent::getMediaServer($filename);
 }
Example #19
0
 public static function enableCache($level = 1, Context $context = null)
 {
     if (!$context) {
         $context = Context::getContext();
     }
     $smarty = $context->smarty;
     if (!Configuration::get('PS_SMARTY_CACHE')) {
         return;
     }
     if ($smarty->force_compile == 0 && $smarty->caching == $level) {
         return;
     }
     self::$_forceCompile = (int) $smarty->force_compile;
     self::$_caching = (int) $smarty->caching;
     $smarty->force_compile = 0;
     $smarty->caching = (int) $level;
 }
Example #20
0
 public static function addonsRequest($request, $params = array())
 {
     if (!self::$is_addons_up) {
         return false;
     }
     $postData = http_build_query(array('version' => isset($params['version']) ? $params['version'] : _PS_VERSION_, 'iso_lang' => Tools::strtolower(isset($params['iso_lang']) ? $params['iso_lang'] : Context::getContext()->language->iso_code), 'iso_code' => Tools::strtolower(isset($params['iso_country']) ? $params['iso_country'] : Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'))), 'shop_url' => isset($params['shop_url']) ? $params['shop_url'] : Tools::getShopDomain(), 'mail' => isset($params['email']) ? $params['email'] : Configuration::get('email')));
     $protocols = array('https');
     switch ($request) {
         case 'native':
             $protocols[] = 'http';
             $postData .= '&method=listing&action=native';
             break;
         case 'must-have':
             $protocols[] = 'http';
             $postData .= '&method=listing&action=must-have';
             break;
         case 'customer':
             $postData .= '&method=listing&action=customer&username='******'&password='******'check_customer':
             $postData .= '&method=check_customer&username='******'username_addons']) . '&password='******'password_addons']);
             break;
         case 'module':
             $postData .= '&method=module&id_module=' . urlencode($params['id_module']);
             if (isset($params['username_addons']) && isset($params['password_addons'])) {
                 $postData .= '&username='******'username_addons']) . '&password='******'password_addons']);
             } else {
                 $protocols[] = 'http';
             }
             break;
         case 'install-modules':
             $protocols[] = 'http';
             $postData .= '&method=listing&action=install-modules';
             break;
         default:
             return false;
     }
     $context = stream_context_create(array('http' => array('method' => 'POST', 'content' => $postData, 'header' => 'Content-type: application/x-www-form-urlencoded', 'timeout' => 5)));
     foreach ($protocols as $protocol) {
         if ($content = Tools::file_get_contents($protocol . '://api.addons.prestashop.com', false, $context)) {
             return $content;
         }
     }
     self::$is_addons_up = false;
     return false;
 }
Example #21
0
 public static function getUserBrowser()
 {
     if (isset(self::$_user_browser)) {
         return self::$_user_browser;
     }
     $user_agent = $_SERVER['HTTP_USER_AGENT'];
     self::$_user_browser = 'unknown';
     if (preg_match('/MSIE/i', $user_agent) && !preg_match('/Opera/i', $user_agent)) {
         self::$_user_browser = 'Internet Explorer';
     } elseif (preg_match('/Firefox/i', $user_agent)) {
         self::$_user_browser = 'Mozilla Firefox';
     } elseif (preg_match('/Chrome/i', $user_agent)) {
         self::$_user_browser = 'Google Chrome';
     } elseif (preg_match('/Safari/i', $user_agent)) {
         self::$_user_browser = 'Apple Safari';
     } elseif (preg_match('/Opera/i', $user_agent)) {
         self::$_user_browser = 'Opera';
     } elseif (preg_match('/Netscape/i', $user_agent)) {
         self::$_user_browser = 'Netscape';
     }
     return self::$_user_browser;
 }
Example #22
0
 public static function enableCache($level = 1)
 {
     global $smarty;
     if (!Configuration::get('PS_SMARTY_CACHE') || $smarty->force_compile == 0 && $smarty->caching == $level) {
         return;
     }
     /* Backup current values */
     self::$_forceCompile = (int) $smarty->force_compile;
     self::$_caching = (int) $smarty->caching;
     /* Forcing Smarty to use the cache */
     $smarty->force_compile = 0;
     $smarty->caching = (int) $level;
 }