public function initContent()
 {
     parent::initContent();
     $params = KwixoURLCallFrontController::ManageUrlCall();
     $payment_ok = $params['payment_status'];
     $errors = $params['errors'];
     $id_order = $params['id_order'];
     if ($id_order != false) {
         $order = new Order($id_order);
         $cart = new Cart($order->id_cart);
         $products = $cart->getProducts();
         $amount = $order->total_paid_tax_incl;
         $total_shipping = $order->total_shipping;
     } else {
         $products = false;
         $amount = false;
         $total_shipping = false;
     }
     $link = new Link();
     $this->context->smarty->assign('payment_ok', $payment_ok);
     $this->context->smarty->assign('errors', $errors);
     $this->context->smarty->assign('amount', $amount);
     $this->context->smarty->assign('total_shipping', $total_shipping);
     $this->context->smarty->assign('products', $products);
     $this->context->smarty->assign('path_order', $link->getPageLink('order', true));
     $this->context->smarty->assign('path_history', $link->getPageLink('history', true));
     $this->context->smarty->assign('path_contact', $link->getPageLink('contact', true));
     $this->setTemplate('urlcall.tpl');
 }
Ejemplo n.º 2
0
 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     /* id_carrier is not defined in database before choosing a carrier, set it to a default one to match a potential cart _rule */
     if (empty($this->context->cart->id_carrier)) {
         $checked = $this->context->cart->simulateCarrierSelectedOutput();
         $checked = (int) Cart::desintifier($checked);
         $this->context->cart->id_carrier = $checked;
         $this->context->cart->update();
         CartRule::autoRemoveFromCart($this->context);
         CartRule::autoAddToCart($this->context);
     }
     // SHOPPING CART
     $this->_assignSummaryInformations();
     // WRAPPING AND TOS
     $this->_assignWrappingAndTOS();
     if (Configuration::get('PS_RESTRICT_DELIVERED_COUNTRIES')) {
         $countries = Carrier::getDeliveredCountries($this->context->language->id, true, true);
     } else {
         $countries = Country::getCountries($this->context->language->id, true);
     }
     // If a rule offer free-shipping, force hidding shipping prices
     $free_shipping = false;
     foreach ($this->context->cart->getCartRules() as $rule) {
         if ($rule['free_shipping'] && !$rule['carrier_restriction']) {
             $free_shipping = true;
             break;
         }
     }
     $this->context->smarty->assign(array('free_shipping' => $free_shipping, 'isGuest' => isset($this->context->cookie->is_guest) ? $this->context->cookie->is_guest : 0, 'countries' => $countries, 'sl_country' => (int) Tools::getCountry(), 'PS_GUEST_CHECKOUT_ENABLED' => Configuration::get('PS_GUEST_CHECKOUT_ENABLED'), 'errorCarrier' => Tools::displayError('You must choose a carrier.', false), 'errorTOS' => Tools::displayError('You must accept the Terms of Service.', false), 'isPaymentStep' => isset($_GET['isPaymentStep']) && $_GET['isPaymentStep'], 'genders' => Gender::getGenders(), 'one_phone_at_least' => (int) Configuration::get('PS_ONE_PHONE_AT_LEAST'), 'HOOK_CREATE_ACCOUNT_FORM' => Hook::exec('displayCustomerAccountForm'), 'HOOK_CREATE_ACCOUNT_TOP' => Hook::exec('displayCustomerAccountFormTop')));
     $years = Tools::dateYears();
     $months = Tools::dateMonths();
     $days = Tools::dateDays();
     $this->context->smarty->assign(array('years' => $years, 'months' => $months, 'days' => $days));
     /* Load guest informations */
     if ($this->isLogged && $this->context->cookie->is_guest) {
         $this->context->smarty->assign('guestInformations', $this->_getGuestInformations());
     }
     // ADDRESS
     if ($this->isLogged) {
         $this->_assignAddress();
     }
     // CARRIER
     $this->_assignCarrier();
     // PAYMENT
     $this->_assignPayment();
     Tools::safePostVars();
     $newsletter = Configuration::get('PS_CUSTOMER_NWSL') || Module::isInstalled('blocknewsletter') && Module::getInstanceByName('blocknewsletter')->active;
     $this->context->smarty->assign('newsletter', $newsletter);
     $this->context->smarty->assign('optin', (bool) Configuration::get('PS_CUSTOMER_OPTIN'));
     $this->context->smarty->assign('field_required', $this->context->customer->validateFieldsRequiredDatabase());
     $this->_processAddressFormat();
     $link = new Link();
     if (Tools::getValue('deleteFromOrderLine')) {
         $id_product = Tools::getValue('id_product');
         $date_from = Tools::getValue('date_from');
         $date_to = Tools::getValue('date_to');
         $obj_cart_bk_data = new HotelCartBookingData();
         $cart_data_dlt = $obj_cart_bk_data->deleteRoomDataFromOrderLine($this->context->cart->id, $this->context->cart->id_guest, $id_product, $date_from, $date_to);
         if ($cart_data_dlt) {
             Tools::redirect($link->getPageLink('order', null, $this->context->language->id));
         }
     }
     if ((bool) Configuration::get('PS_ADVANCED_PAYMENT_API')) {
         $this->addJS(_THEME_JS_DIR_ . 'advanced-payment-api.js');
         $this->setTemplate(_PS_THEME_DIR_ . 'order-opc-advanced.tpl');
     } else {
         if (Module::isInstalled('hotelreservationsystem')) {
             require_once _PS_MODULE_DIR_ . 'hotelreservationsystem/define.php';
             $obj_cart_bk_data = new HotelCartBookingData();
             $obj_htl_bk_dtl = new HotelBookingDetail();
             $obj_rm_type = new HotelRoomType();
             $htl_rm_types = $this->context->cart->getProducts();
             if (!empty($htl_rm_types)) {
                 foreach ($htl_rm_types as $type_key => $type_value) {
                     $product = new Product($type_value['id_product'], false, $this->context->language->id);
                     $cover_image_arr = $product->getCover($type_value['id_product']);
                     if (!empty($cover_image_arr)) {
                         $cover_img = $this->context->link->getImageLink($product->link_rewrite, $product->id . '-' . $cover_image_arr['id_image'], 'small_default');
                     } else {
                         $cover_img = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code . "-default", 'small_default');
                     }
                     $unit_price = Product::getPriceStatic($type_value['id_product'], true, null, 6, null, false, true, 1);
                     if (isset($this->context->customer->id)) {
                         $cart_bk_data = $obj_cart_bk_data->getOnlyCartBookingData($this->context->cart->id, $this->context->cart->id_guest, $type_value['id_product']);
                     } else {
                         $cart_bk_data = $obj_cart_bk_data->getOnlyCartBookingData($this->context->cart->id, $this->context->cart->id_guest, $type_value['id_product']);
                     }
                     $rm_dtl = $obj_rm_type->getRoomTypeInfoByIdProduct($type_value['id_product']);
                     $cart_htl_data[$type_key]['id_product'] = $type_value['id_product'];
                     $cart_htl_data[$type_key]['cover_img'] = $cover_img;
                     $cart_htl_data[$type_key]['name'] = $product->name;
                     $cart_htl_data[$type_key]['unit_price'] = $unit_price;
                     $cart_htl_data[$type_key]['adult'] = $rm_dtl['adult'];
                     $cart_htl_data[$type_key]['children'] = $rm_dtl['children'];
                     foreach ($cart_bk_data as $data_k => $data_v) {
                         $date_join = strtotime($data_v['date_from']) . strtotime($data_v['date_to']);
                         if (isset($cart_htl_data[$type_key]['date_diff'][$date_join])) {
                             $cart_htl_data[$type_key]['date_diff'][$date_join]['num_rm'] += 1;
                             $num_days = $cart_htl_data[$type_key]['date_diff'][$date_join]['num_days'];
                             $vart_quant = (int) $cart_htl_data[$type_key]['date_diff'][$date_join]['num_rm'] * $num_days;
                             $amount = Product::getPriceStatic($type_value['id_product'], true, null, 6, null, false, true, 1);
                             $amount *= $vart_quant;
                             $cart_htl_data[$type_key]['date_diff'][$date_join]['amount'] = $amount;
                         } else {
                             $num_days = $obj_htl_bk_dtl->getNumberOfDays($data_v['date_from'], $data_v['date_to']);
                             $cart_htl_data[$type_key]['date_diff'][$date_join]['num_rm'] = 1;
                             $cart_htl_data[$type_key]['date_diff'][$date_join]['data_form'] = $data_v['date_from'];
                             $cart_htl_data[$type_key]['date_diff'][$date_join]['data_to'] = $data_v['date_to'];
                             $cart_htl_data[$type_key]['date_diff'][$date_join]['num_days'] = $num_days;
                             $amount = Product::getPriceStatic($type_value['id_product'], true, null, 6, null, false, true, 1);
                             $amount *= $num_days;
                             $cart_htl_data[$type_key]['date_diff'][$date_join]['amount'] = $amount;
                             $cart_htl_data[$type_key]['date_diff'][$date_join]['link'] = $link->getPageLink('order', null, $this->context->language->id, "id_product=" . $type_value['id_product'] . "&deleteFromOrderLine=1&date_from=" . $data_v['date_from'] . "&date_to=" . $data_v['date_to']);
                         }
                     }
                 }
                 $this->context->smarty->assign('cart_htl_data', $cart_htl_data);
             }
         }
         $this->setTemplate(_PS_THEME_DIR_ . 'order-opc.tpl');
     }
 }
    public function displayList()
    {
        global $currentIndex;
        $link = new Link();
        $admin_dir = dirname($_SERVER['PHP_SELF']);
        $admin_dir = substr($admin_dir, strrpos($admin_dir, '/') + 1);
        echo '
		<script type="text/javascript" src="../js/jquery/jquery.tablednd_0_5.js"></script>
		<script type="text/javascript">
			var token = \'' . $this->token . '\';
			var come_from = \'AdminModulesPositions\';
		</script>
		<script type="text/javascript" src="../js/admin-dnd.js"></script>
		';
        echo '<a href="' . $currentIndex . '&addToHook' . ($this->displayKey ? '&show_modules=' . $this->displayKey : '') . '&token=' . $this->token . '"><img src="../img/admin/add.gif" border="0" /> <b>' . $this->l('Transplant a module') . '</b></a><br /><br />';
        // Print select list
        echo '
		<form>
			' . $this->l('Show') . ' :
			<select id="show_modules" onChange="autoUrl(\'show_modules\', \'' . $currentIndex . '&token=' . $this->token . '&show_modules=\')">
				<option value="all">' . $this->l('All modules') . '&nbsp;</option>
				<option>---------------</option>';
        $modules = Module::getModulesInstalled();
        $moduleIdList = array();
        foreach ($modules as $module) {
            $moduleIdList[] = (int) $module['id_module'];
        }
        Module::preloadModuleNameFromId($moduleIdList);
        foreach ($modules as $module) {
            Module::getInstanceById((int) $module['id_module']);
            if ($tmpInstance = Module::getInstanceById((int) $module['id_module'])) {
                $cm[$tmpInstance->displayName] = $tmpInstance;
            }
        }
        ksort($cm);
        foreach ($cm as $module) {
            echo '
					<option value="' . (int) $module->id . '" ' . ($this->displayKey == $module->id ? 'selected="selected" ' : '') . '>' . $module->displayName . '</option>';
        }
        echo '
			</select><br /><br />
			<input type="checkbox" id="hook_position" onclick="autoUrlNoList(\'hook_position\', \'' . $currentIndex . '&token=' . $this->token . '&show_modules=' . (int) Tools::getValue('show_modules') . '&hook_position=\')" ' . (Tools::getValue('hook_position') ? 'checked="checked" ' : '') . ' />&nbsp;<label class="t" for="hook_position">' . $this->l('Display non-positionable hook') . '</label>
		</form>
		
		<fieldset style="width:250px;float:right"><legend>' . $this->l('Live edit') . '</legend>
				<p>' . $this->l('By clicking here you will be redirected to the front office of your shop to move and delete modules directly.') . '</p>
				<br>
				<a href="' . $link->getPageLink('index.php') . '?live_edit&ad=' . $admin_dir . '&liveToken=' . sha1($admin_dir . _COOKIE_KEY_) . '" target="_blank" class="button">' . $this->l('Run LiveEdit') . '</a>
		</fieldset>
		';
        // Print hook list
        echo '<form method="post" action="' . $currentIndex . '&token=' . $this->token . '">';
        $irow = 0;
        $hooks = Hook::getHooks(!(int) Tools::getValue('hook_position'));
        echo '<div id="unhook_button_position_top"><input class="button floatr" type="submit" name="unhookform" value="' . $this->l('Unhook the selection') . '"/></div>';
        Hook::preloadModulesFromHooks();
        foreach ($hooks as $hook) {
            $modules = array();
            if (!$this->displayKey) {
                $modules = Hook::getModulesFromHook($hook['id_hook']);
            } elseif ($res = Hook::getModuleFromHook($hook['id_hook'], $this->displayKey)) {
                $modules[0] = $res;
            }
            $nbModules = sizeof($modules);
            echo '
			<a name="' . $hook['name'] . '"/>
			<table cellpadding="0" cellspacing="0" class="table width3 space' . ($nbModules >= 2 ? ' tableDnD' : '') . '" id="' . $hook['id_hook'] . '">
			<tr class="nodrag nodrop"><th colspan="4">' . $hook['title'] . ' - <span style="color: red">' . $nbModules . '</span> ' . ($nbModules > 1 ? $this->l('modules') : $this->l('module'));
            if ($nbModules) {
                echo '<input type="checkbox" id="Ghook' . $hook['id_hook'] . '" class="floatr" style="margin-right: 2px;" onclick="hookCheckboxes(' . $hook['id_hook'] . ', 0, this)"/>';
            }
            if (!empty($hook['description'])) {
                echo '&nbsp;<span style="font-size:0.8em; font-weight: normal">[' . $hook['description'] . ']</span>';
            }
            echo ' <sub style="color:grey;"><i>(' . $this->l('Technical name: ') . $hook['name'] . ')</i></sub></th></tr>';
            // Print modules list
            if ($nbModules) {
                $instances = array();
                foreach ($modules as $module) {
                    $moduleIdList[] = (int) $module['id_module'];
                }
                Module::preloadModuleNameFromId($moduleIdList);
                foreach ($modules as $module) {
                    if ($tmpInstance = Module::getInstanceById((int) $module['id_module'])) {
                        $instances[$tmpInstance->getPosition($hook['id_hook'])] = $tmpInstance;
                    }
                }
                ksort($instances);
                foreach ($instances as $position => $instance) {
                    echo '
					<tr id="' . $hook['id_hook'] . '_' . $instance->id . '"' . ($irow++ % 2 ? ' class="alt_row"' : '') . ' style="height: 42px;">';
                    if (!$this->displayKey) {
                        echo '
						<td class="positions" width="40">' . (int) $position . '</td>
						<td' . ($nbModules >= 2 ? ' class="dragHandle"' : '') . ' id="td_' . $hook['id_hook'] . '_' . $instance->id . '" width="40">
						<a' . ($position == 1 ? ' style="display: none;"' : '') . ' href="' . $currentIndex . '&id_module=' . $instance->id . '&id_hook=' . $hook['id_hook'] . '&direction=0&token=' . $this->token . '&changePosition=' . rand() . '#' . $hook['name'] . '"><img src="../img/admin/up.gif" alt="' . $this->l('Up') . '" title="' . $this->l('Up') . '" /></a><br />
							<a ' . ($position == sizeof($instances) ? ' style="display: none;"' : '') . 'href="' . $currentIndex . '&id_module=' . $instance->id . '&id_hook=' . $hook['id_hook'] . '&direction=1&token=' . $this->token . '&changePosition=' . rand() . '#' . $hook['name'] . '"><img src="../img/admin/down.gif" alt="' . $this->l('Down') . '" title="' . $this->l('Down') . '" /></a>
						</td>
						<td style="padding-left: 10px;"><label class="lab_modules_positions" for="mod' . $hook['id_hook'] . '_' . $instance->id . '">
						';
                    } else {
                        echo '<td style="padding-left: 10px;" colspan="3"><label class="lab_modules_positions" for="' . $hook['id_hook'] . '_' . $instance->id . '">';
                    }
                    echo '
					<img src="../modules/' . $instance->name . '/logo.gif" alt="' . stripslashes($instance->name) . '" /> <strong>' . stripslashes($instance->displayName) . '</strong>
						' . ($instance->version ? ' v' . ((int) $instance->version == $instance->version ? sprintf('%.1f', $instance->version) : (double) $instance->version) : '') . '<br />' . $instance->description . '
					</label></td>
						<td width="60">
							<a href="' . $currentIndex . '&id_module=' . $instance->id . '&id_hook=' . $hook['id_hook'] . '&editGraft' . ($this->displayKey ? '&show_modules=' . $this->displayKey : '') . '&token=' . $this->token . '"><img src="../img/admin/edit.gif" border="0" alt="' . $this->l('Edit') . '" title="' . $this->l('Edit') . '" /></a>
							<a href="' . $currentIndex . '&id_module=' . $instance->id . '&id_hook=' . $hook['id_hook'] . '&deleteGraft' . ($this->displayKey ? '&show_modules=' . $this->displayKey : '') . '&token=' . $this->token . '"><img src="../img/admin/delete.gif" border="0" alt="' . $this->l('Delete') . '" title="' . $this->l('Delete') . '" /></a>
							<input type="checkbox" id="mod' . $hook['id_hook'] . '_' . $instance->id . '" class="hook' . $hook['id_hook'] . '" onclick="hookCheckboxes(' . $hook['id_hook'] . ', 1, this)" name="unhooks[]" value="' . $hook['id_hook'] . '_' . $instance->id . '"/>
						</td>
					</tr>';
                }
            } else {
                echo '<tr><td colspan="4">' . $this->l('No module for this hook') . '</td></tr>';
            }
            echo '</table>';
        }
        echo '<div id="unhook_button_position_bottom"><input class="button floatr" type="submit" name="unhookform" value="' . $this->l('Unhook the selection') . '"/></div></form>';
    }
Ejemplo n.º 4
0
    /**
     * This method is called by PayPal when an order has been placed by a customer using PayPal Payments Advanced (from the <iframe>)
     *
     * We will first double-check the PayPal tokens and then create the order in the database
     */
    private function _paymentAdvanced()
    {
        /* Step 1 - The tokens sent by PayPal must match the ones stores in the customer cookie while displaying the <iframe> (see hookPayment() method in paypalmx.php)  */
        if (isset($this->context->cookie->paypal_advanced_token) && Tools::getValue('SECURETOKEN') != '' && Tools::getValue('SECURETOKEN') == $this->context->cookie->paypal_advanced_token) {
            /* Step 2 - Determine the order status in accordance with the response from PayPal */
            /* Approved */
            if (Tools::getValue('RESULT') == 0) {
                $order_status = (int) Configuration::get('PS_OS_PAYMENT');
            } elseif (Tools::getValue('RESULT') == 126) {
                $order_status = (int) Configuration::get('PS_OS_PAYPAL');
            } else {
                $order_status = (int) Configuration::get('PS_OS_ERROR');
            }
            $credit_card_types = array('Visa', 'MasterCard', 'Discover', 'American Express', 'Diners Club', 'JCB');
            $currency = new Currency((int) $this->context->cart->id_currency);
            $message = '
			Status: ' . Tools::getValue('Review') . '
			Comment: ' . Tools::getValue('RESPMSG') . '
			Comment 2: ' . Tools::getValue('PREFPSMSG') . '
			Credit card type: ' . $credit_card_types[Tools::getValue('CARDTYPE')] . '
			Credit card last 4 digits: ' . Tools::getValue('ACCT') . '
			Amount charged: ' . Tools::getValue('AMT') . '
			Currency: ' . $currency->iso_code . '
			Time: ' . Tools::getValue('TRANSTIME') . '
			Method: ' . Tools::getValue('METHOD') . '
			PayPal result code: ' . (int) Tools::getValue('RESULT') . '
			Transaction ID: ' . Tools::getValue('PNREF');
            /* Step 3 - Create the order in the database */
            $customer = new Customer((int) $this->context->cart->id_customer);
            if ($this->paypal_mx->validateOrder((int) $this->context->cart->id, (int) $order_status, (double) Tools::getValue('AMT'), $this->paypal_mx->displayName, $message, array(), null, false, false)) {
                /* Store the transaction ID and details */
                $this->paypal_mx->addTransactionId((int) $this->paypal_mx->currentOrder, Tools::getValue('PNREF'));
                $this->paypal_mx->addTransaction('payment', array('source' => 'advanced', 'id_shop' => (int) $this->context->cart->id_shop, 'id_customer' => (int) $this->context->cart->id_customer, 'id_cart' => (int) $this->context->cart->id, 'id_order' => (int) $this->paypal_mx->currentOrder, 'id_transaction' => Tools::getValue('PNREF'), 'amount' => (double) Tools::getValue('AMT'), 'currency' => $currency->iso_code, 'cc_type' => $credit_card_types[Tools::getValue('CARDTYPE')], 'cc_exp' => Tools::getValue('EXPDATE'), 'cc_last_digits' => Tools::getValue('ACCT'), 'cvc_check' => 0, 'fee' => 0));
            }
            /* Reset the PayPal's token so the customer will be able to place a new order in the future */
            unset($this->context->cookie->paypal_advanced_token);
            $redirect = '';
            /* Step 4 - Redirect the user to the order confirmation page */
            if (version_compare(_PS_VERSION_, '1.5', '<')) {
                //$redirect = _PS_BASE_URL_.'/order-confirmation.php?id_cart='.(int)$this->context->cart->id.'&id_module='.(int)$this->paypal_mx->id.'&id_order='.(int)$this->paypal_mx->currentOrder.'&key='.$customer->secure_key;
                $redirect = Link::getPageLink('order-confirmation.php', array('id_cart' => (int) $this->context->cart->id, 'id_module' => (int) $this->paypal_mx->id, 'id_order' => (int) $this->paypal_mx->currentOrder, 'key' => $customer->secure_key));
            } else {
                $redirect = _PS_BASE_URL_ . '/index.php?controller=order-confirmation&id_cart=' . (int) $this->context->cart->id . '&id_module=' . (int) $this->paypal_mx->id . '&id_order=' . (int) $this->paypal_mx->currentOrder . '&key=' . $customer->secure_key;
            }
            die('
			<script type="text/javascript">
			<!--
			window.top.location.href = "' . $redirect . '";
			//-->
			</script>');
        } else {
            $this->context->smarty->assign('paypal_mx_error_messages', array($this->paypal_mx->l('Invalid PayPal token')));
            $this->setTemplate('errors-messages.tpl');
        }
    }
Ejemplo n.º 5
0
*
*  @author PaymentSense <*****@*****.**>
*  @copyright  2013 PaymentSense
*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*
This file is part of the Prestashop PaymentSense Re-Directed Payment Module
See paymentsense.php for Licensing and support info.
File Last Modified: 12/03/2013 - By Shaun Ponting - Opal Creations
*/
include dirname(__FILE__) . '/../../config/config.inc.php';
include dirname(__FILE__) . '/../../init.php';
include dirname(__FILE__) . '/paymentsense.php';
$paymentsense = new PaymentSense();
if ($paymentsense->active) {
    if ((int) Configuration::get('PS_REWRITING_SETTINGS') === 1) {
        $rewrited_url = __PS_BASE_URI__;
    }
    /*include(dirname(__FILE__).'/../../header.php');*/
    $controller = new FrontController();
    $controller->init();
    $controller->initContent();
    $controller->setMedia();
    $controller->displayHeader();
    if (!isset($link)) {
        $link = new Link();
    }
    $smarty->assign('contactURL', $link->getPageLink('contact-form.php'));
    $smarty->assign('advice', '<a href="javascript: history.go(-1);">' . $paymentsense->l('click here') . '</a>');
    $smarty->display(dirname(__FILE__) . '/views/templates/front/failure.tpl');
    $controller->displayFooter();
}
Ejemplo n.º 6
0
*
*  @author PaymentSense <*****@*****.**>
*  @copyright  2013 PaymentSense
*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*
This file is part of the Prestashop PaymentSense Re-Directed Payment Module
See paymentsense.php for Licensing and support info.
File Last Modified: 12/03/2013 - By Shaun Ponting - Opal Creations
*/
include dirname(__FILE__) . '/../../config/config.inc.php';
include dirname(__FILE__) . '/../../init.php';
include dirname(__FILE__) . '/paymentsense.php';
$paymentsense = new PaymentSense();
if ($paymentsense->active) {
    if ((int) Configuration::get('PS_REWRITING_SETTINGS') === 1) {
        $rewrited_url = __PS_BASE_URI__;
    }
    /*include(dirname(__FILE__).'/../../header.php');*/
    $controller = new FrontController();
    $controller->init();
    $controller->initContent();
    $controller->setMedia();
    $controller->displayHeader();
    if (!isset($link)) {
        $link = new Link();
    }
    $smarty->assign('cartURL', $link->getPageLink('order.php?step=1'));
    $smarty->assign('contactURL', $link->getPageLink('contact-form.php'));
    $smarty->display(dirname(__FILE__) . '/views/templates/front/return.tpl');
    $controller->displayFooter();
}
Ejemplo n.º 7
0
 /**
  * Display Bootstrap MegaMenu
  */
 public function hookDisplayTop()
 {
     $this->context->controller->addCSS($this->_path . 'megamenu.css', 'all');
     $tpl = 'views/templates/hook/megamenu.tpl';
     if (!$this->isCached($tpl, $this->getCacheId())) {
         $link = new Link();
         $params = array();
         $params['params'] = Configuration::get('LEO_MEGAMENU_PARAMS');
         $show_cavas = Configuration::get('LEO_MEGAMENU_CAVAS');
         $current_link = $link->getPageLink('', false, $this->context->language->id);
         if (isset($params['params']) && !empty($params['params'])) {
             # validate module
             $params['params'] = Tools::jsonDecode($params['params']);
         }
         $obj = new Btmegamenu();
         $obj->setModule($this);
         $boostrapmenu = $obj->getFrontTree(1, false, $params['params']);
         $this->smarty->assign('boostrapmenu', $boostrapmenu);
         $this->smarty->assign('current_link', $current_link);
         $this->smarty->assign('show_cavas', $show_cavas);
         return $this->display(__FILE__, $tpl, $this->getCacheId());
     }
     return $this->display(__FILE__, $tpl, $this->getCacheId());
 }
Ejemplo n.º 8
0
 private function _displayLogo()
 {
     global $smarty;
     $blockPositionList = array(self::DISABLE => $this->l('Disable'), self::LEFT_COLUMN => $this->l('Left Column'), self::RIGHT_COLUMN => $this->l('Right Column'));
     $currentLogoBlockPosition = $this->isRegisteredInHook('leftColumn') ? self::LEFT_COLUMN : ($this->isRegisteredInHook('rightColumn') ? self::RIGHT_COLUMN : -1);
     $option = '';
     foreach ($blockPositionList as $position => $translation) {
         $selected = $currentLogoBlockPosition == $position ? 'selected="selected"' : '';
         $option .= '<option value="' . $position . '" ' . $selected . '>' . $translation . '</option>';
     }
     $link = new Link();
     $admin_dir = substr(_PS_ADMIN_DIR_, strrpos(_PS_ADMIN_DIR_, '/') + 1);
     $smarty->assign('option', $option);
     $smarty->assign('link', $link->getPageLink('index.php') . '?live_edit&ad=' . $admin_dir . '&liveToken=' . sha1($admin_dir . _COOKIE_KEY_));
     return $this->display(__FILE__, 'tpl/logo.tpl');
 }
Ejemplo n.º 9
0
 public function hookActionObjectDeleteBefore($params)
 {
     if ((bool) Configuration::get('MGRT_DELPARENTREDIR') === true) {
         if (isset($params['object']) && !empty($params['object'])) {
             $object = $params['object'];
             $type = get_class($object);
             if (!in_array($type, array('Product', 'Manufacturer', 'Supplier', 'Category', 'CMS', 'CMSCategory'))) {
                 // Ok not our job
                 return;
             }
             $shops = $this->getShopsIds();
             $link = new Link();
             $redirect_list = array();
             // Incremental way, it's a bugfix, for supplier for example
             $shop_urls = array();
             $shop_urls[] = 'https:';
             $shop_urls[] = 'http:';
             foreach ($shops as $id_shop) {
                 $shop = new ShopUrl($id_shop);
                 $shop_urls[] = str_replace(array('http://', 'https://'), '', $shop->getURL(true));
                 $shop_urls[] = str_replace(array('http://', 'https://'), '', $shop->getURL(false));
             }
             $shop_urls = array_unique($shop_urls);
             foreach ($shops as $id_shop) {
                 // foreach langs, foreach shops ...
                 $langs = Language::getLanguages(false, $id_shop, true);
                 foreach ($langs as $id_lang) {
                     switch ($type) {
                         case 'Manufacturer':
                             $manufacturer = new Manufacturer($object->id, $id_lang);
                             if (Validate::isLoadedObject($manufacturer)) {
                                 $old_link = $link->getManufacturerLink($manufacturer, null, null, null, $id_lang, $id_shop);
                                 // Redirect to manufacturers page
                                 $new_link = $link->getPageLink(Tools::strtolower($type), null, $id_lang, null, false, $id_shop);
                             }
                             break;
                         case 'Supplier':
                             $supplier = new Supplier($object->id, $id_lang);
                             if (Validate::isLoadedObject($supplier)) {
                                 $old_link = $link->getSupplierLink($supplier, null, $id_lang, $id_shop);
                                 // Redirect to suppliers page
                                 $new_link = $link->getPageLink(Tools::strtolower($type), null, $id_lang, null, false, $id_shop);
                             }
                             break;
                         case 'CMS':
                             $cms = new CMS($object->id, $id_lang, $id_shop);
                             if (Validate::isLoadedObject($cms)) {
                                 $old_link = $link->getCMSLink($cms, null, null, $id_lang, $id_shop);
                                 $new_link = $link->getCMSCategoryLink($cms->id_parent, null, $id_lang, $id_shop);
                             }
                             break;
                         case 'Product':
                             $product = new Product($object->id, null, $id_lang, $id_shop);
                             if (Validate::isLoadedObject($product)) {
                                 $old_link = $link->getProductLink($product, null, null, null, $id_lang, $id_shop);
                                 $new_link = $link->getCategoryLink($product->id_category_default, null, $id_lang, null, $id_shop);
                             }
                             break;
                         case 'Category':
                             $category = new Category($object->id, $id_lang, $id_shop);
                             if (Validate::isLoadedObject($category)) {
                                 $old_link = $link->getCategoryLink($category, null, $id_lang, null, $id_shop);
                                 $new_link = $link->getCategoryLink($category->id_parent, null, $id_lang, null, $id_shop);
                             }
                             break;
                         case 'CMSCategory':
                             $cmscategory = new CMSCategory($object->id, $id_lang, $id_shop);
                             if (Validate::isLoadedObject($product)) {
                                 $old_link = $link->getCMSCategoryLink($cmscategory, null, $id_lang, $id_shop);
                                 $new_link = $link->getCMSCategoryLink($cmscategory->id_parent, null, $id_lang, $id_shop);
                             }
                             break;
                         default:
                             // UFO
                             break;
                     }
                     // Escape shops urls, it's a multishop relative approach
                     $old = str_replace('//', '/', $old_link);
                     $old = str_replace($shop_urls, '', $old_link);
                     $old = '/' . ltrim($old, '/');
                     $new = str_replace('//', '/', $new_link);
                     $new = str_replace($shop_urls, '', $new_link);
                     $new = '/' . ltrim($new, '/');
                     // Avoid duplicates, simplify complex mapings
                     $md5 = md5($old . $new);
                     if (!isset($redirect_list[$md5])) {
                         $redirect_list[$md5]['old'] = $old;
                         $redirect_list[$md5]['new'] = $new;
                         $redirect_list[$md5]['shops'][] = $id_shop;
                     } elseif (!in_array($id_shop, $redirect_list[$md5]['shops'])) {
                         $redirect_list[$md5]['shops'][] = $id_shop;
                     }
                 }
             }
             if (!empty($redirect_list)) {
                 // Force new redirect
                 $this->insertRedirects($redirect_list, true);
             }
         }
     }
 }
Ejemplo n.º 10
0
 /**
  * _getCurrentUrl() method returns current URL
  *
  * @return array
  */
 private function _getCurrentUrl()
 {
     $sLink = '';
     // PS 1.5
     if (version_compare(_PS_VERSION_, '1.5', '>')) {
         // check if OPC deactivated and get redirect on authentication page
         if (Tools::getValue('controller') == 'authentication' && Tools::getIsset('back')) {
             $sLink = urldecode(Tools::getValue('back'));
             if ($sLink == 'my-account') {
                 $sLink = BT_FPCModuleTools::getAccountPageLink();
             }
         } elseif (Tools::getValue('controller') == 'orderopc' || Tools::getValue('controller') == 'order') {
             $sLink = $_SERVER['REQUEST_URI'];
         } else {
             $sLink = BT_FPCModuleTools::getAccountPageLink();
         }
     } elseif (version_compare(_PS_VERSION_, '1.4', '>')) {
         // check if OPC deactivated and get redirect on authentication page
         if (strstr($_SERVER['SCRIPT_NAME'], 'authentication') && Tools::getIsset('back')) {
             if ($sLink == 'my-account.php') {
                 $sLink = BT_FPCModuleTools::getAccountPageLink();
             } else {
                 $oLink = new Link();
                 $sLink = $oLink->getPageLink('order.php');
                 unset($oLink);
             }
         } elseif (strstr($_SERVER['SCRIPT_NAME'], 'order-opc') || strstr($_SERVER['SCRIPT_NAME'], 'order')) {
             $sLink = $_SERVER['REQUEST_URI'];
         } else {
             $sLink = BT_FPCModuleTools::getAccountPageLink();
         }
     } else {
         // check if get redirect on authentication page
         if (strstr($_SERVER['SCRIPT_NAME'], 'authentication') || Tools::getIsset('back')) {
             $sLink = Tools::getValue('back');
             // get PS_BASE_URI
             $sLink = Configuration::get('PS_BASE_URI') . $sLink;
         } elseif (strstr($_SERVER['SCRIPT_NAME'], 'order')) {
             $sLink = $_SERVER['REQUEST_URI'];
         } else {
             global $smarty;
             $sLink = $smarty->_tpl_vars['base_dir_ssl'] . 'my-account.php';
         }
     }
     return $sLink;
 }
Ejemplo n.º 11
0
 public function getMenuCustomerLink($lang_id = NULL)
 {
     $menu_items = $this->getMenuItems();
     $id_lang = (int) $this->context->language->id;
     $id_shop = (int) Shop::getContextShopID();
     foreach ($menu_items as $item) {
         if (!$item) {
             continue;
         }
         preg_match($this->pattern, $item, $value);
         $id = (int) substr($item, strlen($value[1]), strlen($item));
         switch (substr($item, 0, strlen($value[1]))) {
             case 'CAT':
                 $this->_menuLink .= $this->drawCustomMenuItem($id, 0, false, 0, $lang_id);
                 break;
             case 'PRD':
                 $selected = $this->page_name == 'product' && Tools::getValue('id_product') == $id ? ' class="sfHover"' : '';
                 $product = new Product((int) $id, true, (int) $id_lang);
                 if (!is_null($product->id)) {
                     $this->_menuLink .= '<div id ="pt_menu_product" class ="pt_menu"><div class="parentMenu" ><a href="' . Tools::HtmlEntitiesUTF8($product->getLink()) . '"><span>' . $product->name . '</span></a></div></div>' . PHP_EOL;
                 }
                 break;
             case 'CMS':
                 $selected = $this->page_name == 'cms' && Tools::getValue('id_cms') == $id ? ' class="sfHover"' : '';
                 $cms = CMS::getLinks((int) $id_lang, array($id));
                 if (count($cms)) {
                     $this->_menuLink .= '<div id ="pt_menu_cms" class ="pt_menu"><div class="parentMenu" ><a href="' . Tools::HtmlEntitiesUTF8($cms[0]['link']) . '"><span>' . $cms[0]['meta_title'] . '</span></a></div></div>' . PHP_EOL;
                 }
                 break;
             case 'CMS_CAT':
                 $category = new CMSCategory((int) $id, (int) $id_lang);
                 if (Validate::isLoadedObject($category)) {
                     $this->_menuLink .= '<div id ="pt_menu_cms" class ="pt_menu"><div class="parentMenu" ><a href="' . Tools::HtmlEntitiesUTF8($category->getLink()) . '"><span>' . $category->name . '</span></a>';
                 }
                 $this->_menuLink .= '</div>' . PHP_EOL;
                 $this->_menuLink .= $this->getCMSMenuItems($category->id);
                 // Case to handle the option to show all Manufacturers
             // Case to handle the option to show all Manufacturers
             case 'ALLMAN':
                 $link = new Link();
                 $this->_menuLink .= '<div id ="pt_menu_allsub" class ="pt_menu"><div class="parentMenu" ><a href="' . $link->getPageLink('manufacturer') . '" ><span>' . $this->l('All manufacturers') . '</span></a></div>' . PHP_EOL;
                 $manufacturers = Manufacturer::getManufacturers();
                 $this->_menuLink .= '<div class ="popup" style ="display:none">';
                 foreach ($manufacturers as $key => $manufacturer) {
                     $this->_menuLink .= '<div class ="block1"><div class="column col1"><div class="itemSubMenu level3"><a href="' . $link->getManufacturerLink((int) $manufacturer['id_manufacturer'], $manufacturer['link_rewrite']) . '">' . $manufacturer['name'] . '</a></div></div></div>' . PHP_EOL;
                 }
                 $this->_menuLink .= '</div></div>';
                 break;
             case 'MAN':
                 $selected = $this->page_name == 'manufacturer' && Tools::getValue('id_manufacturer') == $id ? ' class="sfHover"' : '';
                 $manufacturer = new Manufacturer((int) $id, (int) $id_lang);
                 if (!is_null($manufacturer->id)) {
                     if (intval(Configuration::get('PS_REWRITING_SETTINGS'))) {
                         $manufacturer->link_rewrite = Tools::link_rewrite($manufacturer->name);
                     } else {
                         $manufacturer->link_rewrite = 0;
                     }
                     $link = new Link();
                     $this->_menuLink .= '<div id ="pt_menu_man" class ="pt_menu"><div class="parentMenu" ><a href="' . Tools::HtmlEntitiesUTF8($link->getManufacturerLink((int) $id, $manufacturer->link_rewrite)) . '"><span>' . $manufacturer->name . '</span></a></div></div>' . PHP_EOL;
                 }
                 break;
                 // Case to handle the option to show all Suppliers
             // Case to handle the option to show all Suppliers
             case 'ALLSUP':
                 $link = new Link();
                 $this->_menuLink .= '<div id ="pt_menu_allsub" class ="pt_menu"><div class="parentMenu" ><a href="' . $link->getPageLink('supplier') . '" ><span>' . $this->l('All suppliers') . '</span></a></div>' . PHP_EOL;
                 $suppliers = Supplier::getSuppliers();
                 $this->_menuLink .= '<div class ="popup" style ="display:none">';
                 foreach ($suppliers as $key => $supplier) {
                     $this->_menuLink .= '<div class ="block1"><div class="column col1"><div class="itemSubMenu level3"><a href="' . $link->getSupplierLink((int) $supplier['id_supplier'], $supplier['link_rewrite']) . '">' . $supplier['name'] . '</a></div></div></div>' . PHP_EOL;
                 }
                 $this->_menuLink .= '</div></div>';
                 break;
             case 'SUP':
                 $selected = $this->page_name == 'supplier' && Tools::getValue('id_supplier') == $id ? ' class="sfHover"' : '';
                 $supplier = new Supplier((int) $id, (int) $id_lang);
                 if (!is_null($supplier->id)) {
                     $link = new Link();
                     $this->_menuLink .= '<div id ="pt_menu_sub" class ="pt_menu"><div class="parentMenu" ><a href="' . Tools::HtmlEntitiesUTF8($link->getSupplierLink((int) $id, $supplier->link_rewrite)) . '"><span>' . $supplier->name . '</span></a></div></div>' . PHP_EOL;
                 }
                 break;
             case 'SHOP':
                 $selected = $this->page_name == 'index' && $this->context->shop->id == $id ? ' class="sfHover"' : '';
                 $shop = new Shop((int) $id);
                 if (Validate::isLoadedObject($shop)) {
                     $link = new Link();
                     $this->_menuLink .= '<div id ="pt_menu_sub" class ="pt_menu"><div class="parentMenu" ><a href="' . Tools::HtmlEntitiesUTF8($shop->getBaseURL()) . '"><span>' . $supplier->name . '</span></a></div></div>' . PHP_EOL;
                 }
                 break;
             case 'LNK':
                 $link = VegaTopLinks::get((int) $id, (int) $id_lang, (int) $id_shop);
                 if (count($link)) {
                     if (!isset($link[0]['label']) || $link[0]['label'] == '') {
                         $default_language = Configuration::get('PS_LANG_DEFAULT');
                         $link = VegaTopLinks::get($link[0]['id_linksvegatop'], $default_language, (int) Shop::getContextShopID());
                     }
                     $this->_menuLink .= '<div id ="pt_ver_menu_link" class ="pt_menu"><div class="parentMenu" ><a href="' . Tools::HtmlEntitiesUTF8($link[0]['link']) . '"' . ($link[0]['new_window'] ? ' target="_blank"' : '') . '><span>' . $link[0]['label'] . '</a></span></div></div>' . PHP_EOL;
                 }
                 break;
         }
     }
 }
Ejemplo n.º 12
0
 public function hookPaymentTop($param)
 {
     if (!$this->_activeVerification()) {
         return false;
     }
     $smarty = Context::getContext()->smarty;
     $customer = new Customer($param['cart']->id_customer);
     $addresses = $customer->getAddresses(Context::getContext()->language->id);
     $address = new Address($addresses[0]['id_address']);
     $cart = new Cart($param['cart']->id);
     $link = new Link();
     $fidbag_user = new FidbagUser($param['cart']->id_customer);
     $fidbag_user->getFidBagUser();
     $var = array('path' => $this->_path, 'img' => _PS_IMG_, 'id_customer' => $param['cart']->id_customer, 'id_cart' => $param['cart']->id, 'fidbag_token' => Configuration::get('FIDBAG_TOKEN'), 'module' => _PS_MODULE_DIR_ . $this->_moduleName . '/');
     $smarty->assign('glob', $var);
     $smarty->assign('main_url', $this->getMainUrl());
     $smarty->assign('fidbag_token', Tools::encrypt((int) $param['cart']->id_customer));
     $smarty->assign('price', $cart->getOrderTotal(true, Cart::ONLY_PRODUCTS_WITHOUT_SHIPPING));
     $smarty->assign('shipment', $cart->getOrderTotal(true, Cart::ONLY_SHIPPING));
     $smarty->assign('total_cart', $cart->getOrderTotal());
     $smarty->assign('shipping', $cart->getOrderTotal(true, Cart::ONLY_SHIPPING));
     $smarty->assign('discount', $cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS));
     $smarty->assign('fidbag_login', $fidbag_user->getLogin());
     $smarty->assign('fidbag_password', $fidbag_user->getPassword());
     if (_PS_VERSION_ < '1.5') {
         $smarty->assign('base_dir', Tools::getProtocol() . Tools::getHttpHost() . __PS_BASE_URI__);
     }
     if ((int) Configuration::get('PS_ORDER_PROCESS_TYPE') == 1) {
         $smarty->assign('redirect', $link->getPageLink('order-opc.php'));
     } else {
         if (_PS_VERSION_ >= '1.5') {
             $smarty->assign('redirect', $link->getPageLink('order.php', false, null, array('step' => '3')));
         } else {
             $smarty->assign('redirect', $link->getPageLink('order.php?step=3'));
         }
     }
     if (isset($customer->id_gender)) {
         $smarty->assign('sub_gender', $customer->id_gender);
     }
     $smarty->assign('sub_lastname', $customer->lastname);
     $smarty->assign('sub_firstname', $customer->firstname);
     $smarty->assign('sub_email', $customer->email);
     $smarty->assign('sub_address', $address->address1 . ' ' . $address->address2);
     $smarty->assign('sub_zipcode', $address->postcode);
     $smarty->assign('sub_city', $address->city);
     if (_PS_VERSION_ < '1.5') {
         return $this->display(__FILE__, 'views/templates/hook/payment_top_14x.tpl');
     }
     return $this->display(__FILE__, 'views/templates/hook/payment_top.tpl');
 }
Ejemplo n.º 13
0
 private function sendShopParamsToApp($token)
 {
     // Get default language
     $default_lang = (int) Configuration::get('PS_LANG_DEFAULT');
     // Get order states
     $oss = OrderState::getOrderStates($default_lang);
     $states = array();
     foreach ($oss as $os) {
         $states[$os['id_order_state']] = $os['name'];
     }
     // Get payment modules
     $token = Configuration::get('checkyourdata_token');
     $modules = array();
     $pms = PaymentModule::getInstalledPaymentModules();
     foreach ($pms as $pm) {
         $p = Module::getInstanceByName($pm['name']);
         if (is_object($p)) {
             $modules[$pm['id_module']] = $p->displayName;
         }
     }
     // get confirmation page url
     $l = new Link();
     $shopUrl = $this->context->shop->getBaseURL();
     $confirmUrl = str_replace($shopUrl, '', $l->getPageLink('order-confirmation'));
     // get confirmation page title
     $meta = MetaCore::getMetaByPage('order-confirmation', $default_lang);
     $confirmTitle = $meta['title'];
     $data = array('token' => $token, 'action' => 'setShopParams', 'data' => array('modules' => $modules, 'states' => $states, 'trackers' => Configuration::get('checkyourdata_trackers'), 'confirm_url' => $confirmUrl, 'confirm_title' => $confirmTitle));
     return CheckYourDataWSHelper::send(self::$dcUrl, $data);
 }
Ejemplo n.º 14
0
 /**
  * @return array
  */
 private function getLinks()
 {
     if (version_compare(_PS_VERSION_, '1.5', 'gt')) {
         $order_complete_link = $this->context->link->getModuleLink('payu', 'success');
         $order_notify_link = $this->context->link->getModuleLink('payu', 'notification');
         $order_cancel_link = $this->context->link->getPageLink('order.php', true);
         return array($order_complete_link, $order_notify_link, $order_cancel_link);
     } else {
         $link = new Link();
         $order_complete_link = $this->getModuleAddress() . 'backward_compatibility/success.php';
         $order_notify_link = $this->getModuleAddress() . 'backward_compatibility/notification.php';
         $order_cancel_link = $link->getPageLink(__PS_BASE_URI__ . 'order.php');
         return array($order_complete_link, $order_notify_link, $order_cancel_link);
     }
 }
Ejemplo n.º 15
0
 /**
  * _updateEmail() method update customer email
  *
  * @param array $aParams
  * @return bool
  */
 private function _updateEmail(array $aParams)
 {
     $aAssign = array();
     if (version_compare(_PS_VERSION_, '1.4', '>')) {
         $oLink = new Link();
         $sLink = $oLink->getPageLink('my-account.php');
         unset($oLink);
     } else {
         global $smarty;
         $sLink = $smarty->_tpl_vars['base_dir_ssl'] . 'my-account.php';
     }
     $aAssign['sLink'] = $sLink;
     // get serialized connector data
     BT_FPCModuleTools::getConnectorData();
     // check if customer is the same customer connected and if the e-mail is valid
     if (!empty($aParams['connector']) && !empty($GLOBALS[_FPC_MODULE_NAME . '_CONNECTORS'][$aParams['connector']]['data']['activeConnector']) && !empty($aParams['customerId']) && $aParams['customerId'] === md5(_FPC_MODULE_NAME . $aParams['connector'] . FacebookPsConnect::$oCookie->id_customer) && !empty($aParams['customerId']) && filter_var($aParams['socialEmail'], FILTER_VALIDATE_EMAIL) !== false) {
         // include
         require_once _FPC_PATH_LIB . 'module-dao_class.php';
         require_once _FPC_PATH_LIB . 'mail-send_class.php';
         // check if exists and return id customer if exists
         $iCustomerId = BT_FPCModuleDao::existCustomerEmail($aParams['socialEmail']);
         // if customer not exists
         if (empty($iCustomerId)) {
             if (BT_FPCModuleDao::updateCustomerEmail(FacebookPsConnect::$oCookie->id_customer, $aParams['socialEmail'])) {
                 $aAssign['sMsg'] = FacebookPsConnect::$oModule->l('Your information has been updated', 'hook-action_class');
                 // set the new e-mail in cookie
                 if (version_compare(_PS_VERSION_, '1.5', '>')) {
                     Context::getContext()->cookie->email = $aParams['socialEmail'];
                 } else {
                     global $cookie;
                     $cookie->email = $aParams['socialEmail'];
                 }
             } else {
                 $aAssign['aErrors'][] = array('msg' => FacebookPsConnect::$oModule->l('Internal server error. The customer e-mail has not been updated. Please try again by clicking on reload button below', 'hook-action_class') . '.', 'code' => 590);
             }
             // manage the update firstname and name for twitter connexion
             BT_FPCModuleDao::updateCustomerFirstName(FacebookPsConnect::$oCookie->id_customer, $aParams['socialFirstName']);
             BT_FPCModuleDao::updateCustomerName(FacebookPsConnect::$oCookie->id_customer, $aParams['socialName']);
             BT_FPCModuleDao::updateCustomerPassword(FacebookPsConnect::$oCookie->id_customer, $aParams['socialPassword']);
             BT_FpcMailSend::_updateEmailTwitter($aParams['socialFirstName'], $aParams['socialName'], $aParams['socialEmail'], $aParams['socialPassword'], FacebookPsConnect::$iCurrentLang, FacebookPsConnect::$iShopId);
         } else {
             $aAssign['aErrors'][] = array('msg' => FacebookPsConnect::$oModule->l('This e-mail address is already taken by a customer account or you already have linked this e-mail address with another network. Please try again by clicking on reload button below', 'hook-action_class') . '.', 'code' => 591);
         }
     } else {
         $aAssign['aErrors'][] = array('msg' => FacebookPsConnect::$oModule->l('Internal server error. The customer could not be identified. You may be a victim of cross-site request forgery', 'hook-action_class') . '.', 'code' => 592);
     }
     if (empty($aAssign['aErrors'])) {
         $sTpl = _FPC_TPL_CONFIRM;
     } else {
         $sTpl = _FPC_TPL_ERROR;
     }
     return array('tpl' => $sTpl, 'assign' => $aAssign);
 }
Ejemplo n.º 16
0
 /**
  * Builds a page url for the language and shop.
  *
  * We created our own method due to the existing one in `LinkCore` behaving differently across PS versions.
  *
  * @param string $controller the controller name.
  * @param int|null $id_lang the language ID (falls back on current context if not set).
  * @param int|null $id_shop the shop ID (falls back on current context if not set).
  * @param array $params additional params to add to the url.
  * @return string the page url.
  */
 public function getPageUrl($controller, $id_lang = null, $id_shop = null, array $params = array())
 {
     if (is_null($id_lang)) {
         $id_lang = (int) Context::getContext()->language->id;
     }
     if (is_null($id_shop)) {
         $id_shop = (int) Context::getContext()->shop->id;
     }
     if (version_compare(_PS_VERSION_, '1.5.0.0') === -1 || version_compare(_PS_VERSION_, '1.5.5.0') >= 0) {
         /** @var LinkCore $link */
         $link = new Link();
         $url = $link->getPageLink($controller, true, $id_lang, null, false, $id_shop);
     } else {
         // For PS versions 1.5.0.0 - 1.5.4.1 we always hard-code the urls to be in non-friendly format and fetch
         // the shops base url ourselves. This is a workaround to all the bugs related to url building in these
         // PS versions.
         $query_params = array('controller' => Tools::strReplaceFirst('.php', '', $controller), 'id_lang' => $id_lang);
         $url = $this->getBaseUrl($id_shop) . 'index.php?' . http_build_query($query_params);
     }
     if ((int) Configuration::get('PS_REWRITING_SETTINGS') === 0) {
         $params['id_lang'] = $id_lang;
     }
     return NostoHttpRequest::replaceQueryParamsInUrl($params, $url);
 }
Ejemplo n.º 17
0
 public function getLink($menu)
 {
     if ($this->edit_string) {
         return '#';
     }
     $link = new Link();
     $id_lang = Context::getContext()->language->id;
     $value = (int) $menu['item'];
     $result = '';
     switch ($menu['type']) {
         case 'product':
             if (Validate::isLoadedObject($obj_pro = new Product($value, true, $id_lang))) {
                 $result = $link->getProductLink((int) $obj_pro->id, $obj_pro->link_rewrite, null, null, $id_lang);
             }
             break;
         case 'category':
             if (Validate::isLoadedObject($obj_cate = new Category($value, $id_lang))) {
                 $result = $link->getCategoryLink((int) $obj_cate->id, $obj_cate->link_rewrite, $id_lang);
             }
             break;
         case 'cms':
             if (Validate::isLoadedObject($obj_cms = new CMS($value, $id_lang))) {
                 $result = $link->getCMSLink((int) $obj_cms->id, $obj_cms->link_rewrite, $id_lang);
             }
             break;
         case 'url':
             $value = $menu['url'];
             if ($value == 'index' || $value == 'index.php') {
                 $result = $link->getPageLink('index.php', false, $id_lang);
                 break;
             }
             $regex = '((https?|ftp)\\:\\/\\/)?';
             // SCHEME
             $regex .= '([a-z0-9+!*(),;?&=\\$_.-]+(\\:[a-z0-9+!*(),;?&=\\$_.-]+)?@)?';
             // User and Pass
             $regex .= '([a-z0-9-.]*)\\.([a-z]{2,3})';
             // Host or IP
             $regex .= '(\\:[0-9]{2,5})?';
             // Port
             $regex .= '(\\/([a-z0-9+\\$_-]\\.?)+)*\\/?';
             // Path
             $regex .= '(\\?[a-z+&\\$_.-][a-z0-9;:@&%=+\\/\\$_.-]*)?';
             // GET Query
             $regex .= '(#[a-z_.-][a-z0-9+\\$_.-]*)?';
             // Anchor
             if ($value == '#' || preg_match("/^{$regex}\$/", $value)) {
                 $result = $value;
                 break;
             }
             $result = $link->getPageLink($value, false, $id_lang);
             break;
         case 'manufacture':
             if (Validate::isLoadedObject($obj_manu = new Manufacturer($value, $id_lang))) {
                 $result = $link->getManufacturerLink((int) $obj_manu->id, $obj_manu->link_rewrite, $id_lang);
             }
             break;
         case 'supplier':
             if (Validate::isLoadedObject($obj_supp = new Supplier($value, $id_lang))) {
                 $result = $link->getSupplierLink((int) $obj_supp->id, $obj_supp->link_rewrite, $id_lang);
             }
             break;
         default:
             $result = '#';
             break;
     }
     return $result;
 }
Ejemplo n.º 18
0
 /**
  * getAccountPageLink() method returns account page link
  *
  * @return string link
  */
 public static function getAccountPageLink()
 {
     $oLink = new Link();
     $sLink = $oLink->getPageLink('my-account.php');
     unset($oLink);
     return $sLink;
 }
Ejemplo n.º 19
0
 /**
  * Hydrate $link_sitemap with meta link
  *
  * @param array  $link_sitemap contain all the links for the Google Sitemap file to be generated
  * @param string $lang         language of link to add
  * @param int    $index        index of the current Google Sitemap file
  * @param int    $i            count of elements added to sitemap main array
  * @param int    $id_meta      meta object identifier
  *
  * @return bool
  */
 private function _getMetaLink(&$link_sitemap, $lang, &$index, &$i, $id_meta = 0)
 {
     if (method_exists('ShopUrl', 'resetMainDomainCache')) {
         ShopUrl::resetMainDomainCache();
     }
     $link = new Link();
     $metas = Db::getInstance()->ExecuteS('SELECT * FROM `' . _DB_PREFIX_ . 'meta` WHERE `id_meta` > ' . (int) $id_meta . ' ORDER BY `id_meta` ASC');
     foreach ($metas as $meta) {
         $url = '';
         if (!in_array($meta['id_meta'], explode(',', Configuration::get('GSITEMAP_DISABLE_LINKS')))) {
             if (_PS_VERSION_ >= 1.5) {
                 $url_rewrite = Db::getInstance()->getValue('SELECT url_rewrite, id_shop FROM `' . _DB_PREFIX_ . 'meta_lang` WHERE `id_meta` = ' . (int) $meta['id_meta'] . ' AND `id_shop` =' . (int) $this->context->shop->id . ' AND `id_lang` = ' . (int) $lang['id_lang']);
                 Dispatcher::getInstance()->addRoute($meta['page'], isset($url_rewrite) ? $url_rewrite : $meta['page'], $meta['page'], $lang['id_lang']);
                 $uri_path = Dispatcher::getInstance()->createUrl($meta['page'], $lang['id_lang'], array(), (bool) Configuration::get('PS_REWRITING_SETTINGS'));
                 $url .= Tools::getShopDomain(true) . ($this->context->shop->virtual_uri ? __PS_BASE_URI__ . $this->context->shop->virtual_uri : __PS_BASE_URI__) . (Language::isMultiLanguageActivated() ? $lang['iso_code'] . '/' : '') . ltrim($uri_path, '/');
             } else {
                 $url = $link->getPageLink($meta['page'] . '.php', true, $lang['id_lang']);
             }
             if (!$this->_addLinkToSitemap($link_sitemap, array('type' => 'meta', 'page' => $meta['page'], 'link' => $url, 'image' => false), $lang['iso_code'], $index, $i, $meta['id_meta'])) {
                 return false;
             }
         }
     }
     return true;
 }
Ejemplo n.º 20
0
 public function hookextraCarrier($params)
 {
     if (!$this->active) {
         return;
     }
     if (!Configuration::get('TNT_CARRIER_LOGIN') || !Configuration::get('TNT_CARRIER_PASSWORD') || !Configuration::get('TNT_CARRIER_NUMBER_ACCOUNT')) {
         return;
     }
     global $smarty;
     $id_cart = $params['cart']->id;
     $city = $this->putCityInNormeTnt($params['address']->city);
     $postal_code = $params['address']->postcode;
     if (serviceCache::getError($id_cart)) {
         $smarty->assign('error', $this->l('The postal Code entered does not correspond to the city.') . '<br/>' . $this->l('Please confirm the city below :'));
         $smarty->assign('postalCode', $postal_code);
         $postal = $postal_code;
         $cities = array();
         if ($postal == '75000') {
             for ($i = 1; $i <= 20; $i++) {
                 if ($i < 10) {
                     $nb = '0' . $i;
                 } else {
                     $nb = $i;
                 }
                 $cities[] = "PARIS " . $nb;
             }
         } else {
             if ($postal == '69000') {
                 for ($i = 1; $i < 10; $i++) {
                     $cities[] = "LYON " . $i;
                 }
             } else {
                 if ($postal == '13000') {
                     for ($i = 1; $i <= 16; $i++) {
                         if ($i < 10) {
                             $nb = '0' . $i;
                         } else {
                             $nb = $i;
                         }
                         $cities[] = "MARSEILLE " . $nb;
                     }
                 } else {
                     try {
                         $tntWebService = new TntWebService();
                         $city = $tntWebService->getCity($postal);
                     } catch (SoapFault $e) {
                         $erreur = $e->faultstring;
                     } catch (Exception $e) {
                         $erreur = "Problem : follow failed";
                     }
                     if (!isset($erreur) && isset($city->City)) {
                         if (is_array($city->City)) {
                             foreach ($city->City as $v) {
                                 $cities[] = $v->name;
                             }
                         } else {
                             $cities[] = $city->City->name;
                         }
                     }
                 }
             }
         }
         $link = new Link();
         $redirect = $link->getPageLink('order.php?step=2');
         $smarty->assign('redirect', $redirect);
         if (!sizeof($cities)) {
             $smarty->assign('cityError', $this->l('your shipping address zipcode is not correct.'));
         }
         $smarty->assign('cities', $cities);
     }
     $services = Db::getInstance()->ExecuteS('SELECT `id_carrier`, `option` FROM `' . _DB_PREFIX_ . 'tnt_carrier_option`');
     $dueDate = serviceCache::getDueDate($id_cart, $services);
     $smarty->assign('id_cart', $id_cart);
     $smarty->assign('tnt_token', Configuration::get('TNT_CARRIER_TOKEN'));
     $smarty->assign('version', _PS_VERSION_);
     $smarty->assign('services', $services);
     $smarty->assign('dueDate', $dueDate);
     if (_PS_VERSION_ >= 1.5) {
         $this->context->controller->addJS('http://maps.google.com/maps/api/js?sensor=true');
         $this->context->controller->addJS($this->_path . 'js/relais.js');
         $this->context->controller->addJS($this->_path . 'js/jquery-ui-1.8.10.custom.min.js');
     }
     return $this->display(__FILE__, 'tpl/relaisColis.tpl');
 }
Ejemplo n.º 21
0
    private function _postProcess()
    {
        Configuration::updateValue('GSITEMAP_ALL_CMS', (int) Tools::getValue('GSITEMAP_ALL_CMS'));
        Configuration::updateValue('GSITEMAP_ALL_PRODUCTS', (int) Tools::getValue('GSITEMAP_ALL_PRODUCTS'));
        $link = new Link();
        $langs = Language::getLanguages();
        $xmlString = <<<XML
<?xml version="1.0" encoding="UTF-8" ?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
</urlset>
XML;
        $xml = new SimpleXMLElement($xmlString);
        if (Configuration::get('PS_REWRITING_SETTINGS') and sizeof($langs) > 1) {
            foreach ($langs as $lang) {
                $this->_addSitemapNode($xml, Tools::getShopDomain(true, true) . __PS_BASE_URI__ . $lang['iso_code'] . '/', '1.00', 'daily', date('Y-m-d'));
            }
        } else {
            $this->_addSitemapNode($xml, Tools::getShopDomain(true, true) . __PS_BASE_URI__, '1.00', 'daily', date('Y-m-d'));
        }
        /* CMS Generator */
        if (Configuration::get('GSITEMAP_ALL_CMS') or !Module::isInstalled('blockcms')) {
            $sql_cms = '
			SELECT DISTINCT ' . (Configuration::get('PS_REWRITING_SETTINGS') ? 'cl.id_cms, cl.link_rewrite, cl.id_lang' : 'cl.id_cms') . ' FROM ' . _DB_PREFIX_ . 'cms_lang cl
			LEFT JOIN ' . _DB_PREFIX_ . 'lang l ON (cl.id_lang = l.id_lang)
			WHERE l.`active` = 1
			ORDER BY cl.id_cms, cl.id_lang ASC';
        } elseif (Module::isInstalled('blockcms')) {
            $sql_cms = '
			SELECT DISTINCT ' . (Configuration::get('PS_REWRITING_SETTINGS') ? 'cl.id_cms, cl.link_rewrite, cl.id_lang' : 'cl.id_cms') . ' FROM ' . _DB_PREFIX_ . 'cms_block_page b
			LEFT JOIN ' . _DB_PREFIX_ . 'cms_lang cl ON (b.id_cms = cl.id_cms)
			LEFT JOIN ' . _DB_PREFIX_ . 'lang l ON (cl.id_lang = l.id_lang)
			WHERE l.`active` = 1
			ORDER BY cl.id_cms, cl.id_lang ASC';
        }
        $cmss = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql_cms);
        foreach ($cmss as $cms) {
            $tmpLink = Configuration::get('PS_REWRITING_SETTINGS') ? $link->getCMSLink((int) $cms['id_cms'], $cms['link_rewrite'], false, (int) $cms['id_lang']) : $link->getCMSLink((int) $cms['id_cms']);
            $this->_addSitemapNode($xml, $tmpLink, '0.8', 'daily');
        }
        /* Categories Generator */
        if (Configuration::get('PS_REWRITING_SETTINGS')) {
            $categories = Db::getInstance()->ExecuteS('
			SELECT c.id_category, c.level_depth, link_rewrite, DATE_FORMAT(IF(date_upd,date_upd,date_add), \'%Y-%m-%d\') AS date_upd, cl.id_lang
			FROM ' . _DB_PREFIX_ . 'category c
			LEFT JOIN ' . _DB_PREFIX_ . 'category_lang cl ON c.id_category = cl.id_category
			LEFT JOIN ' . _DB_PREFIX_ . 'lang l ON cl.id_lang = l.id_lang
			WHERE l.`active` = 1 AND c.`active` = 1 AND c.id_category != 1
			ORDER BY cl.id_category, cl.id_lang ASC');
        } else {
            $categories = Db::getInstance()->ExecuteS('SELECT c.id_category, c.level_depth, DATE_FORMAT(IF(date_upd,date_upd,date_add), \'%Y-%m-%d\') AS date_upd
			FROM ' . _DB_PREFIX_ . 'category c 
			ORDER BY c.id_category ASC');
        }
        foreach ($categories as $category) {
            if (($priority = 0.9 - $category['level_depth'] / 10) < 0.1) {
                $priority = 0.1;
            }
            $tmpLink = Configuration::get('PS_REWRITING_SETTINGS') ? $link->getCategoryLink((int) $category['id_category'], $category['link_rewrite'], (int) $category['id_lang']) : $link->getCategoryLink((int) $category['id_category']);
            $this->_addSitemapNode($xml, htmlspecialchars($tmpLink), $priority, 'weekly', substr($category['date_upd'], 0, 10));
        }
        $products = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
		SELECT p.id_product, pl.link_rewrite, DATE_FORMAT(IF(date_upd,date_upd,date_add), \'%Y-%m-%d\') date_upd, pl.id_lang, cl.`link_rewrite` category, ean13, i.id_image, il.legend legend_image, (
			SELECT MIN(level_depth)
			FROM ' . _DB_PREFIX_ . 'product p2
			LEFT JOIN ' . _DB_PREFIX_ . 'category_product cp2 ON p2.id_product = cp2.id_product
			LEFT JOIN ' . _DB_PREFIX_ . 'category c2 ON cp2.id_category = c2.id_category
			WHERE p2.id_product = p.id_product AND p2.`active` = 1 AND c2.`active` = 1) AS level_depth
		FROM ' . _DB_PREFIX_ . 'product p
		LEFT JOIN ' . _DB_PREFIX_ . 'product_lang pl ON (p.id_product = pl.id_product)
		LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl ON (p.`id_category_default` = cl.`id_category` AND pl.`id_lang` = cl.`id_lang`)
		LEFT JOIN ' . _DB_PREFIX_ . 'image i ON p.id_product = i.id_product
		LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (i.`id_image` = il.`id_image` AND pl.`id_lang` = il.`id_lang`)
		LEFT JOIN ' . _DB_PREFIX_ . 'lang l ON (pl.id_lang = l.id_lang)
		WHERE l.`active` = 1 AND p.`active` = 1
		' . (Configuration::get('GSITEMAP_ALL_PRODUCTS') ? '' : 'HAVING level_depth IS NOT NULL') . '
		ORDER BY pl.id_product, pl.id_lang ASC');
        $tmp = null;
        $res = null;
        foreach ($products as $product) {
            if ($tmp == $product['id_product']) {
                $res[$tmp]['images'][] = array('id_image' => $product['id_image'], 'legend_image' => $product['legend_image']);
            } else {
                $tmp = $product['id_product'];
                $res[$tmp] = $product;
                unset($res[$tmp]['id_image'], $res[$tmp]['legend_image']);
                $res[$tmp]['images'][] = array('id_image' => $product['id_image'], 'legend_image' => $product['legend_image']);
            }
        }
        foreach ($res as $product) {
            if (($priority = 0.7 - $product['level_depth'] / 10) < 0.1) {
                $priority = 0.1;
            }
            $tmpLink = $link->getProductLink((int) $product['id_product'], $product['link_rewrite'], $product['category'], $product['ean13'], (int) $product['id_lang']);
            $sitemap = $this->_addSitemapNode($xml, htmlspecialchars($tmpLink), $priority, 'weekly', substr($product['date_upd'], 0, 10));
            $sitemap = $this->_addSitemapNodeImage($sitemap, $product);
        }
        /* Add classic pages (contact, best sales, new products...) */
        $pages = array('authentication' => true, 'best-sales' => false, 'contact-form' => true, 'discount' => false, 'index' => false, 'manufacturer' => false, 'new-products' => false, 'prices-drop' => false, 'supplier' => false, 'store' => false);
        // Don't show suppliers and manufacturers if they are disallowed
        if (!Module::getInstanceByName('blockmanufacturer')->id && !Configuration::get('PS_DISPLAY_SUPPLIERS')) {
            unset($pages['manufacturer']);
        }
        if (!Module::getInstanceByName('blocksupplier')->id && !Configuration::get('PS_DISPLAY_SUPPLIERS')) {
            unset($pages['supplier']);
        }
        // Generate nodes for pages
        if (Configuration::get('PS_REWRITING_SETTINGS')) {
            foreach ($pages as $page => $ssl) {
                foreach ($langs as $lang) {
                    $this->_addSitemapNode($xml, $link->getPageLink($page . '.php', $ssl, $lang['id_lang']), '0.5', 'monthly');
                }
            }
        } else {
            foreach ($pages as $page => $ssl) {
                $this->_addSitemapNode($xml, $link->getPageLink($page . '.php', $ssl), '0.5', 'monthly');
            }
        }
        $xmlString = $xml->asXML();
        $fp = fopen(GSITEMAP_FILE, 'w');
        fwrite($fp, $xmlString);
        fclose($fp);
        $res = file_exists(GSITEMAP_FILE);
        $this->_html .= '<h3 class="' . ($res ? 'conf confirm' : 'alert error') . '" style="margin-bottom: 20px">';
        $this->_html .= $res ? $this->l('Sitemap file generated') : $this->l('Error while creating sitemap file');
        $this->_html .= '</h3>';
    }
Ejemplo n.º 22
0
    public function getContent()
    {
        global $cookie;
        $errors = array();
        $output = '
			<p><img src="' . __PS_BASE_URI__ . 'modules/moneybookers/logo-mb.gif" alt="Moneybookers" /></p><br />';
        /* Validate account */
        if (isset($_POST['SubmitValidation'])) {
            if (isset($_POST['mb_email_to_validate']) && !empty($_POST['mb_email_to_validate'])) {
                try {
                    $url = 'http://moneybookers.prestashop.com/email_check.php?email=' . $_POST['mb_email_to_validate'] . '&url=http://' . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__;
                    $content = $this->_fetchWebContent($url);
                    $response = trim(strtolower($content));
                    if (!strstr('ok', $response)) {
                        $errors[] = $this->l('Account validation failed, please check your e-mail.');
                    } else {
                        Configuration::updateValue('MB_PAY_TO_EMAIL', $_POST['mb_email_to_validate']);
                        Configuration::updateValue('MB_PARAMETERS', 1);
                        $output .= '
							<ul style="color: green; font-weight: bold; margin-bottom: 30px; width: 506px; background: #E1FFE9; border: 1px dashed #BBB; padding: 10px;">
								<li>' . $this->l('E-mail activation successful, you can now validate your secret word.') . '<img src="http://api.prestashop.com/modules/moneybookers.png?email=' . urlencode($_POST['mb_email_to_validate']) . '" style="float:right" /></li>
							</ul>';
                    }
                } catch (Exception $e) {
                    $errors[] = $this->l('Unable to contact activation server, please try again later.');
                }
            } else {
                $errors[] = $this->l('E-mail field is required');
            }
        }
        /* Validate secret word */
        if (isset($_POST['SubmitSecret'])) {
            if (isset($_POST['mb_sw_to_validate']) and !empty($_POST['mb_sw_to_validate'])) {
                try {
                    $url = 'http://moneybookers.prestashop.com/email_check.php?email=' . Configuration::get('MB_PAY_TO_EMAIL') . '&url=http://' . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__ . '&sw=1&secret_word=' . md5($_POST['mb_sw_to_validate']);
                    $content = $this->_fetchWebContent($url);
                    $response = trim(strtolower($content));
                    if (strstr('velocity_check_exceeded', $response)) {
                        $errors[] = $this->l('Secret word validation failed, exceeded max attempts (3 per hour)');
                    } elseif (!strstr('ok', $response)) {
                        $errors[] = $this->l('Secret word validation failed, please check your secret word.');
                    } else {
                        Configuration::updateValue('MB_SECRET_WORD', $_POST['mb_sw_to_validate']);
                        Configuration::updateValue('MB_PARAMETERS_2', 1);
                        $output .= '
						<ul style="color: green; font-weight: bold; margin-bottom: 30px; width: 506px; background: #E1FFE9; border: 1px dashed #BBB; padding: 10px;">
							<li>' . $this->l('Account activation successful, secret word OK') . '</li>
						</ul>';
                    }
                } catch (Exception $e) {
                    $errors[] = $this->l('Unable to contact activation server, please try again later.');
                }
            } else {
                $errors[] = $this->l('Secret word field is required');
            }
        }
        /* Update configuration variables */
        if (isset($_POST['submitMoneyBookers'])) {
            if (!isset($_POST['mb_hide_login'])) {
                $_POST['mb_hide_login'] = 0;
            }
            Configuration::updateValue('MB_CANCEL_URL', $_POST['mb_cancel_url']);
            Configuration::updateValue('MB_HIDE_LOGIN', (int) $_POST['mb_hide_login']);
            $local = '';
            $inter = '';
            foreach ($_POST as $key => $value) {
                if (strstr($key, 'mb_local_')) {
                    preg_match('/mb_local_([0-9]+)/', $key, $matches);
                    if (isset($matches[1])) {
                        $local .= $matches[1] . '|';
                    }
                } elseif (strstr($key, 'mb_inter_')) {
                    preg_match('/mb_inter_([0-9]+)/', $key, $matches);
                    if (isset($matches[1])) {
                        $inter .= $matches[1] . '|';
                    }
                }
            }
            $local = rtrim($local, '|');
            $inter = rtrim($inter, '|');
            Configuration::updateValue('MB_LOCAL_METHODS', $local);
            Configuration::updateValue('MB_INTER_METHODS', $inter);
            Configuration::updateValue('MB_DISPLAY_MODE', (int) $_POST['mb_display_mode']);
        }
        if (Tools::getValue('submitSettings')) {
            foreach (array('leftColumn', 'rightColumn') as $hookName) {
                if ($this->isRegisteredInHook($hookName)) {
                    $this->unregisterHook(Hook::get($hookName));
                }
            }
            if (Tools::getValue('logo_position') == self::LEFT_COLUMN) {
                $this->registerHook('leftColumn');
            } else {
                if (Tools::getValue('logo_position') == self::RIGHT_COLUMN) {
                    $this->registerHook('rightColumn');
                }
            }
        }
        /* Display errors */
        if (sizeof($errors)) {
            $output .= '<ul style="color: red; font-weight: bold; margin-bottom: 30px; width: 506px; background: #FFDFDF; border: 1px dashed #BBB; padding: 10px;">';
            foreach ($errors as $error) {
                $output .= '<li>' . $error . '</li>';
            }
            $output .= '</ul>';
        }
        $lang = new Language((int) $cookie->id_lang);
        $iso_img = $lang->iso_code;
        if ($lang->iso_code != 'fr' and $lang->iso_code != 'en') {
            $iso_img = 'en';
        }
        $manual_links = array('en' => 'http://moneybookers.com/creatives/integrationmanual/MB-Prestashop-Integration_en.pdf', 'es' => 'http://www.moneybookers.com/creatives/integrationmanual/MB-Prestashop-Integration_es.pdf', 'fr' => 'http://www.moneybookers.com/creatives/integrationmanual/MB-Prestashop-Integration_fr.pdf');
        $iso_manual = $lang->iso_code;
        if (!array_key_exists($lang->iso_code, $manual_links)) {
            $iso_manual = 'en';
        }
        $blockPositionList = array(self::DISABLE => $this->l('Disable'), self::LEFT_COLUMN => $this->l('Left Column'), self::RIGHT_COLUMN => $this->l('Right Column'));
        $currentLogoBlockPosition = $this->isRegisteredInHook('leftColumn') ? self::LEFT_COLUMN : ($this->isRegisteredInHook('rightColumn') ? self::RIGHT_COLUMN : -1);
        /* Display settings form */
        $output .= '
		<b>' . $this->l('About Moneybookers') . '</b><br /><br /><p style="font-size: 11px;">' . $this->l('Take advantage of the special fees offered by Moneybookers to PrestaShop merchants !') . '<br /><br />' . $this->l('Moneybookers, controlled by Skrill Holdings, is one of the largest online payment systems in Europe, and proposes more than 100 payment options, 41 currencies in more than 200 countries and territories. More than 80,000 merchants already use this solution among which eBay.com, Skype and Thomas Cook.') . '<br /><br />' . $this->l('With more than 17 million users and more than 15,000 new accounts created per day, Moneybookers also offers one of the biggest electronic wallets in the world. Your customers can also pay by using their email and password thanks to the e-Wallet solution.') . '<br /><br />' . $this->l('Moneybookers changes its name and becomes Skrill!') . '<br /><br />
                <div style="clear: both;"></div>

		<form method="post" action="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '" id="form-settings">
			<fieldset class="width2" style="margin: 20px 0; width: 800px;">
				<legend><img src="' . __PS_BASE_URI__ . 'modules/moneybookers/logo.gif" alt="" />' . $this->l('Settings') . '</legend>
				<div class="margin-form" style="margin:0; padding:0 0 1em 20px">' . $this->l('You can display the Skrill/Moneybookers logo on your shop, this may reassure your customers about the fact that you are a serious merchant.') . '</div>
				<div class="margin-form" style="margin:0; padding:0 0 1em 20px">
					<b>' . $this->l('Select the logo position') . '</b> :
					<select name="logo_position">';
        foreach ($blockPositionList as $position => $translation) {
            $selected = $currentLogoBlockPosition == $position ? 'selected="selected"' : '';
            $output .= '<option value="' . $position . '" ' . $selected . '>' . $translation . '</option>';
        }
        $link = new Link();
        $admin_dir = substr(_PS_ADMIN_DIR_, strrpos(_PS_ADMIN_DIR_, '/') + 1);
        $iso_code = strtolower(Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT')));
        $landingPage = $iso_code == 'en' || $iso_code == 'us' ? 'http://www.moneybookers.com/ads/partners/index.html?p=Prestashop' : 'http://www.moneybookers.com/ads/partners/' . $iso_code . '/index.html?p=Prestashop';
        $output .= '
					</select>
					<p>' . $this->l('Change your logo position in the Front Office. Works with') . '
						<a href="' . $link->getPageLink('index.php') . '?live_edit&ad=' . $admin_dir . '&liveToken=' . sha1($admin_dir . _COOKIE_KEY_) . '">' . $this->l(' Live edit.') . '</a></p>
				</div>
				<div style="text-align:center;">
					<input type="submit" name="submitSettings" value="' . $this->l('Submit settings') . '" />
				</div>
			</fieldset>
		</form>

		<form method="post" action="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '" id="form-activation"' . ((!Configuration::get('MB_PARAMETERS') and !isset($_POST['SubmitValidation'])) ? ' style="display: none;"' : '') . '>
			<fieldset class="width2" style="margin: 20px 0; width: 800px;">
				<legend><img src="' . __PS_BASE_URI__ . 'modules/moneybookers/logo.gif" alt="" />' . $this->l('Account validation') . '</legend>
				' . (Configuration::get('MB_PARAMETERS') == 1 ? '<p style="font-weight: bold; color: green;"><img src="../img/admin/ok.gif" alt="" /> ' . $this->l('Your account has been activated') . '</p>' : '') . '
				<p style="line-height: 20px;">' . $this->l('You need to') . ' <b>' . $this->l('validate your account') . '</b>.<br /><br />
				<input type="text" name="mb_email_to_validate" value="' . Configuration::get('MB_PAY_TO_EMAIL') . '" style="width: 250px;" />
				<input type="submit" name="SubmitValidation" class="button" value="' . $this->l('Validate my account') . '" /></p>
				<p style="font-size: 14px;"><a href="' . $manual_links[$iso_manual] . '" target="_blank"><img src="../img/admin/pdf.gif" alt="" /></a><a href="' . $manual_links[$iso_manual] . '" target="_blank"><b>' . $this->l('For help, refer to the activation manual.') . '</b></a></p>
				<p style="font-size: 12px;">
' . $this->l('You can test Moneybookers payment with the test account testaccount2@moneybookers.com and the secret word mbtest.') . '<br />
' . $this->l('Beware, this is only a test account: you will not receive money if you use this test account on your shop. To receive money, you have to use the login and password of your personal Moneybookers account !') . '
				</p>
			</fieldset>
		</form>
		
		<form method="post" action="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '" id="form-opening">
			<fieldset class="width2" style="margin: 20px 0; width: 800px;">
				<legend><img src="' . __PS_BASE_URI__ . 'modules/moneybookers/logo.gif" alt="" />' . $this->l('Open Account') . '</legend>
				' . $this->l('Start by opening a') . ' <b>' . $this->l('free account') . '</b> ' . $this->l('with Moneybookers:') . '
				<p><a href="http://www.moneybookers.com/partners/prestashop/' . ($lang->iso_code == 'fr' ? '' : strtolower($lang->iso_code) . '/') . '"><img src="../modules/moneybookers/prestashop_mb_' . $iso_img . '.gif" alt="PrestaShop & Moneybookers" /></a><br /><br />
				<p style="margin: 0;">
					' . $this->l('Then click here:') . ' <input type="button" class="button" value="' . $this->l('I already have a Moneybookers account') . '" style="margin: 0 auto;" onclick="$(\'#form-activation\').show(1500);" />
					<hr size="1" style="margin: 0 0 15px 0;" noshade />
				</p>
				<span style="color: #CC0000; font-weight: bold; line-height: 20px;"><img src="../img/admin/gold.gif" alt="" /> ' . $this->l('Thanks to the PrestaShop/Moneybookers partnership,') . ' ' . $this->l('you will get a preferential commission rate!') . '</span></p>

<br /><br />
<style>
.tdMBL { border-left: 1px solid black; border-top: 1px solid black; }
.tdMBR { border-left: 1px solid black; border-top: 1px solid black; border-right: 1px solid black; }
.tdMBLast { border-top: 1px solid black; border-right: 1px solid black; }
</style>

<p>' . $this->l('Fees available since March 21st 2011') . '</p>


<table cellpadding="2" cellspacing="0" style="width: 750px;">
 <tr><td class="tdMBL" style="background-color: grey;"><b>PrestaShop</b></td><td colspan="2" class="tdMBR" style="background-color: grey;"><b>' . $this->l('Online payment solution by Moneybookers') . '</b></td></tr>
 <tr><td class="tdMBL">' . $this->l('Monthly volume for payments made via Moneybookers') . '</td><td class="tdMBL">Quick Checkout Moneybookers ***</td><td class="tdMBR">Moneybookers eWallet **</td></tr>
 <tr><td class="tdMBL">€ 0 - € 1,000</td><td class="tdMBR">2.9% + 0.19€</td><td rowspan="5" class="tdMBLast">0.9% + 0.19€</td></tr>
 <tr><td class="tdMBL">€ 1,000.01 - € 10,000</td><td class="tdMBR">1.8% + 0.19€</td></tr>
 <tr><td class="tdMBL">€ 10,000.01 - € 50,000</td><td class="tdMBR">1.6% + 0.19€</td></tr>
 <tr><td class="tdMBL">€ 50,000.01 - € 100,000</td><td class="tdMBR">1.4% + 0.19€</td></tr>
 <tr><td class="tdMBL">€ 100,000</td><td class="tdMBR">1.2% + 0.19€</td></tr>
 <tr><td colspan="3" style="border-top: 1px solid black;"><small>' . $this->l('For merchants over €100,000 fees can be negotiated.') . ' Contact: ecommerce@moneybookers.com</small></td></tr>
</table>
<br />
' . $this->l('To view the last update of the detailed fees') . '<a href="' . $landingPage . '"> <b>' . $this->l('Click here') . '</b></a>

<p align="left">
** ' . $this->l('Moneybookers eWallet') . '<br />
*** ' . $this->l('Quick Checkout Moneybookers') . '
</p>

			</fieldset>
		</form>

		<form method="post" action="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '" id="form-secret"' . ((!Configuration::get('MB_PARAMETERS') and !isset($_POST['SubmitSecret'])) ? ' style="display: none;"' : '') . '>
			<fieldset class="width2" style="margin: 20px 0; width: 800px;">
				<legend><img src="' . __PS_BASE_URI__ . 'modules/moneybookers/logo.gif" alt="" />' . $this->l('Secret word validation') . '</legend>
				' . (Configuration::get('MB_PARAMETERS_2') == 1 ? '<p style="font-weight: bold; color: green;"><img src="../img/admin/ok.gif" alt="" /> ' . $this->l('Your secret word has been activated') . '</p>' : '') . '
				<p style="line-height: 20px;">' . $this->l('You need to ') . ' <b>' . $this->l('validate your secret word') . '</b>, ' . $this->l('Please enter the secret word entered on your Moneybookers account:') . '<br /><br />
				<input type="password" name="mb_sw_to_validate" value="' . Configuration::get('MB_SECRET_WORD') . '" style="width: 250px;" />
				<input type="submit" name="SubmitSecret" class="button" value="' . $this->l('Validate my secret word') . '" /></p>

				<br />
				<p><b>' . $this->l('What is the secret word ?') . '</b></p>
				<p>' . $this->l('The secret word is different from the password. It is used by Moneybookers to securely encrypt the transmission from your server.') . '</p>
				<p><b>' . $this->l('Why do you need a secret word as well as the  password?') . '</b></p>
				<p>' . $this->l('The secret word is used to reinforce the payment security.') . '</p>
				<p>' . $this->l('The password is only used to securely connect to your Moneybookers account. If the password changes, it won\'t affect your secret word. So it is recommended to have a different password from your secret word.') . '</p>
				<p><b>' . $this->l('Where can I find my secret word ?') . '</b></p>
				<p>' . $this->l('Once your account has been validated, go to your account in the "Merchant Tools" section. There, you will be able to define your secret word.') . '</p>


			</fieldset>
		</form>

		<form method="post" action="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '" id="form-settings"' . (!Configuration::get('MB_PARAMETERS') ? ' style="display: none;"' : '') . '>
			<style type="text/css">
				label {
					width: 300px;
					margin-right: 10px;
					font-size: 12px;
				}
			</style>
			<fieldset style="width: 800px;">';
        $interActivated = Configuration::get('MB_INTER_METHODS') != '' ? explode('|', Configuration::get('MB_INTER_METHODS')) : array();
        $localActivated = Configuration::get('MB_LOCAL_METHODS') != '' ? explode('|', Configuration::get('MB_LOCAL_METHODS')) : array();
        $output .= '
				<p>' . $this->l('Click the') . ' <b>' . $this->l('international payment methods') . '</b> ' . $this->l('that you would like to enable:') . '</p>
				<div style="width: 200px; float: left; margin-right: 25px; line-height: 75px;">';
        for ($i = 0; $i != 3; $i++) {
            $output .= '<input type="checkbox" name="mb_inter_' . (int) $i . '" value="1"' . (in_array($i, $interActivated) ? ' checked="checked"' : '') . ' /> <img src="' . __PS_BASE_URI__ . 'modules/moneybookers/logos/international/' . $this->_internationalPaymentMethods[$i]['file'] . '.gif" alt="" style="vertical-align: middle;" /><br />';
        }
        $output .= '
				</div>
				<div style="width: 250px; float: left; margin-right: 25px; line-height: 75px;">';
        for ($i = 3; $i != 6; $i++) {
            $output .= '<input type="checkbox" name="mb_inter_' . (int) $i . '" value="1"' . (in_array($i, $interActivated) ? ' checked="checked"' : '') . ' /> <img src="' . __PS_BASE_URI__ . 'modules/moneybookers/logos/international/' . $this->_internationalPaymentMethods[$i]['file'] . '.gif" alt="" style="vertical-align: middle;" /><br />';
        }
        $output .= '
				</div>
				<div style="width: 200px; float: left; line-height: 75px;">';
        for ($i = 6; $i != sizeof($this->_internationalPaymentMethods); $i++) {
            $output .= '<input type="checkbox" name="mb_inter_' . (int) $i . '" value="1"' . (in_array($i, $interActivated) ? ' checked="checked"' : '') . ' /> <img src="' . __PS_BASE_URI__ . 'modules/moneybookers/logos/international/' . $this->_internationalPaymentMethods[$i]['file'] . '.gif" alt="" style="vertical-align: middle;" /><br />';
        }
        $output .= '
				</div>
				<div style="clear: both;"></div>
				<hr size="1" noshade />
				<p>' . $this->l('Click the') . ' <b>' . $this->l('local payment methods') . '</b> ' . $this->l('that you would like to enable:') . '</p>
				<div style="width: 200px; float: left; margin-right: 25px; line-height: 75px;">';
        for ($i = 0; $i != 7; $i++) {
            $output .= '<input type="checkbox" name="mb_local_' . (int) $i . '" value="1"' . (in_array($i, $localActivated) ? ' checked="checked"' : '') . ' /> <img src="' . __PS_BASE_URI__ . 'modules/moneybookers/logos/local/' . $this->_localPaymentMethods[$i]['file'] . '.gif" alt="" style="vertical-align: middle;" /><br />';
        }
        $output .= '
				</div>
				<div style="width: 250px; float: left; margin-right: 25px; line-height: 75px;">';
        for ($i = 8; $i != 15; $i++) {
            $output .= '<input type="checkbox" name="mb_local_' . (int) $i . '" value="1"' . (in_array($i, $localActivated) ? ' checked="checked"' : '') . ' /> <img src="' . __PS_BASE_URI__ . 'modules/moneybookers/logos/local/' . $this->_localPaymentMethods[$i]['file'] . '.gif" alt="" style="vertical-align: middle;" /><br />';
        }
        $output .= '
				</div>
				<div style="width: 200px; float: left; line-height: 75px;">';
        for ($i = 16; $i != sizeof($this->_localPaymentMethods); $i++) {
            $output .= '<input type="checkbox" name="mb_local_' . (int) $i . '" value="1"' . (in_array($i, $localActivated) ? ' checked="checked"' : '') . ' /> <img src="' . __PS_BASE_URI__ . 'modules/moneybookers/logos/local/' . $this->_localPaymentMethods[$i]['file'] . '.gif" alt="" style="vertical-align: middle;" /><br />';
        }
        $output .= '
				</div>
				<div style="clear: both;"></div>

				<hr size="1" noshade />
				<legend><img src="' . __PS_BASE_URI__ . 'modules/moneybookers/logo.gif" alt="" />' . $this->l('Settings and payment methods') . '</legend>
				<label>' . $this->l('Page displayed if payment error:') . '</label>
				<div class="margin-form">
					<input type="text" name="mb_cancel_url" value="' . Configuration::get('MB_CANCEL_URL') . '" style="width: 300px;" />
				</div>
				<div style="clear: both;"></div>
				<label>' . $this->l('Hide the login form on Moneybookers page') . '</label>
				<div class="margin-form">
					<input type="checkbox" name="mb_hide_login" value="1" ' . (Configuration::get('MB_HIDE_LOGIN') ? 'checked="checked"' : '') . ' style="margin-top: 4px;" />
				</div>
				<div style="clear: both;"></div>
				<label>' . $this->l('Display mode:') . '</label>
				<div class="margin-form">
					<input type="radio" name="mb_display_mode" value="0" ' . (!Configuration::get('MB_DISPLAY_MODE') ? 'checked="checked"' : '') . ' style="vertical-align: text-bottom;" /> ' . $this->l('All logos in 1 block') . '
					<input type="radio" name="mb_display_mode" value="1" ' . (Configuration::get('MB_DISPLAY_MODE') ? 'checked="checked"' : '') . ' style="vertical-align: text-bottom; margin-left: 10px;" /> ' . $this->l('1 block for each logo') . '
				</div>
				<div style="clear: both;"></div>

				<center><input type="submit" class="button" name="submitMoneyBookers" value="' . $this->l('Save settings') . '" style="margin-top: 25px;" /></center>
			</fieldset>
		</form>';
        return $output;
    }
Ejemplo n.º 23
0
 protected function makeMenu()
 {
     $menu_items = $this->getMenuItems();
     $id_lang = (int) $this->context->language->id;
     $id_shop = (int) Shop::getContextShopID();
     foreach ($menu_items as $item) {
         if (!$item) {
             continue;
         }
         preg_match($this->pattern, $item, $value);
         $id = (int) substr($item, strlen($value[1]), strlen($item));
         switch (substr($item, 0, strlen($value[1]))) {
             case 'CAT':
                 $this->_menu .= $this->generateCategoriesMenu(Category::getNestedCategories($id, $id_lang, false, $this->user_groups));
                 break;
             case 'PRD':
                 $selected = $this->page_name == 'product' && Tools::getValue('id_product') == $id ? ' class="sfHover"' : '';
                 $product = new Product((int) $id, true, (int) $id_lang);
                 if (!is_null($product->id)) {
                     $this->_menu .= '<li' . $selected . '><a href="' . Tools::HtmlEntitiesUTF8($product->getLink()) . '" title="' . $product->name . '">' . $product->name . '</a></li>' . PHP_EOL;
                 }
                 break;
             case 'CMS':
                 $selected = $this->page_name == 'cms' && Tools::getValue('id_cms') == $id ? ' class="sfHover"' : '';
                 $cms = CMS::getLinks((int) $id_lang, array($id));
                 if (count($cms)) {
                     $this->_menu .= '<li' . $selected . '><a href="' . Tools::HtmlEntitiesUTF8($cms[0]['link']) . '" title="' . Tools::safeOutput($cms[0]['meta_title']) . '">' . Tools::safeOutput($cms[0]['meta_title']) . '</a></li>' . PHP_EOL;
                 }
                 break;
             case 'CMS_CAT':
                 $category = new CMSCategory((int) $id, (int) $id_lang);
                 if (count($category)) {
                     $this->_menu .= '<li><a href="' . Tools::HtmlEntitiesUTF8($category->getLink()) . '" title="' . $category->name . '">' . $category->name . '</a>';
                     $this->getCMSMenuItems($category->id);
                     $this->_menu .= '</li>' . PHP_EOL;
                 }
                 break;
                 // Case to handle the option to show all Manufacturers
             // Case to handle the option to show all Manufacturers
             case 'ALLMAN':
                 $link = new Link();
                 $this->_menu .= '<li><a href="' . $link->getPageLink('manufacturer') . '" title="' . $this->l('All manufacturers') . '">' . $this->l('All manufacturers') . '</a><ul>' . PHP_EOL;
                 $manufacturers = Manufacturer::getManufacturers();
                 foreach ($manufacturers as $key => $manufacturer) {
                     $this->_menu .= '<li><a href="' . $link->getManufacturerLink((int) $manufacturer['id_manufacturer'], $manufacturer['link_rewrite']) . '" title="' . Tools::safeOutput($manufacturer['name']) . '">' . Tools::safeOutput($manufacturer['name']) . '</a></li>' . PHP_EOL;
                 }
                 $this->_menu .= '</ul>';
                 break;
             case 'MAN':
                 $selected = $this->page_name == 'manufacturer' && Tools::getValue('id_manufacturer') == $id ? ' class="sfHover"' : '';
                 $manufacturer = new Manufacturer((int) $id, (int) $id_lang);
                 if (!is_null($manufacturer->id)) {
                     if (intval(Configuration::get('PS_REWRITING_SETTINGS'))) {
                         $manufacturer->link_rewrite = Tools::link_rewrite($manufacturer->name);
                     } else {
                         $manufacturer->link_rewrite = 0;
                     }
                     $link = new Link();
                     $this->_menu .= '<li' . $selected . '><a href="' . Tools::HtmlEntitiesUTF8($link->getManufacturerLink((int) $id, $manufacturer->link_rewrite)) . '" title="' . Tools::safeOutput($manufacturer->name) . '">' . Tools::safeOutput($manufacturer->name) . '</a></li>' . PHP_EOL;
                 }
                 break;
                 // Case to handle the option to show all Suppliers
             // Case to handle the option to show all Suppliers
             case 'ALLSUP':
                 $link = new Link();
                 $this->_menu .= '<li><a href="' . $link->getPageLink('supplier') . '" title="' . $this->l('All suppliers') . '">' . $this->l('All suppliers') . '</a><ul>' . PHP_EOL;
                 $suppliers = Supplier::getSuppliers();
                 foreach ($suppliers as $key => $supplier) {
                     $this->_menu .= '<li><a href="' . $link->getSupplierLink((int) $supplier['id_supplier'], $supplier['link_rewrite']) . '" title="' . Tools::safeOutput($supplier['name']) . '">' . Tools::safeOutput($supplier['name']) . '</a></li>' . PHP_EOL;
                 }
                 $this->_menu .= '</ul>';
                 break;
             case 'SUP':
                 $selected = $this->page_name == 'supplier' && Tools::getValue('id_supplier') == $id ? ' class="sfHover"' : '';
                 $supplier = new Supplier((int) $id, (int) $id_lang);
                 if (!is_null($supplier->id)) {
                     $link = new Link();
                     $this->_menu .= '<li' . $selected . '><a href="' . Tools::HtmlEntitiesUTF8($link->getSupplierLink((int) $id, $supplier->link_rewrite)) . '" title="' . $supplier->name . '">' . $supplier->name . '</a></li>' . PHP_EOL;
                 }
                 break;
             case 'SHOP':
                 $selected = $this->page_name == 'index' && $this->context->shop->id == $id ? ' class="sfHover"' : '';
                 $shop = new Shop((int) $id);
                 if (Validate::isLoadedObject($shop)) {
                     $link = new Link();
                     $this->_menu .= '<li' . $selected . '><a href="' . Tools::HtmlEntitiesUTF8($shop->getBaseURL()) . '" title="' . $shop->name . '">' . $shop->name . '</a></li>' . PHP_EOL;
                 }
                 break;
             case 'LNK':
                 $link = MenuTopLinks::get((int) $id, (int) $id_lang, (int) $id_shop);
                 if (count($link)) {
                     if (!isset($link[0]['label']) || $link[0]['label'] == '') {
                         $default_language = Configuration::get('PS_LANG_DEFAULT');
                         $link = MenuTopLinks::get($link[0]['id_linksmenutop'], $default_language, (int) Shop::getContextShopID());
                     }
                     $this->_menu .= '<li><a href="' . Tools::HtmlEntitiesUTF8($link[0]['link']) . '"' . ($link[0]['new_window'] ? ' onclick="return !window.open(this.href);"' : '') . ' title="' . Tools::safeOutput($link[0]['label']) . '">' . Tools::safeOutput($link[0]['label']) . '</a></li>' . PHP_EOL;
                 }
                 break;
         }
     }
 }
Ejemplo n.º 24
0
             $countdown_js = __PS_BASE_URI__ . 'modules/revsliderprestashop/js/countdown/jquery.countdown.js';
             $countdown_css = __PS_BASE_URI__ . 'modules/revsliderprestashop/css/countdown/countdown.css';
             Context::getcontext()->controller->addJs($countdown_js);
             Context::getcontext()->controller->addCSS($countdown_css);
             // end start countdown JS
         }
     }
     return $html;
 }
 private function setLayersByPostData($postData, $sliderID)
 {
     $priceDisplay = Product::getTaxCalculationMethod((int) Context::getcontext()->cookie->id_customer);
     if (!$priceDisplay) {
         $productprice = Tools::displayPrice($postData["price"], Context::getContext()->currency);
     } else {
         $productprice = Tools::displayPrice($postData["price_tax_exc"], Context::getContext()->currency);
     }
     $postID = $postData["id_product"];
     $countdown = $this->SetCountDown($postData);
     // $imgsrc = $this->SetImageSrc($postData);
     $title = UniteFunctionsRev::getVal($postData, "name");
     $excerpt_limit = $this->getSliderParam($sliderID, "excerpt_limit", 55, RevSlider::VALIDATE_NUMERIC);
     $excerpt_limit = (int) $excerpt_limit;
     $description = substr($postData["description"], $excerpt_limit);
     $description_short = $postData["description_short"];
     // $alias = UniteFunctionsRev::getVal($postData, "post_name");
     // $content = UniteFunctionsRev::getVal($postData, "post_content");
     //$link = get_permalink($postID);
     $link = $postData["link"];
     $date_add = $postData["date_add"];
     //$date_add = UniteFunctionsWPRev::convertPostDate($date_add);
     $date_upd = $postData["date_upd"];
     //$date_upd = UniteFunctionsWPRev::convertPostDate($date_upd);
     $category_default = $postData["category_default"];
     $linkobj = new Link();
     $addtocart = $linkobj->getPageLink('cart', false, NULL, "add=1&amp;id_product=" . $postID, false);
     foreach ($this->arrLayers as $key => $layer) {
         $text = UniteFunctionsRev::getVal($layer, "text");
         $text = str_replace("%title%", $title, $text);
         $text = str_replace("%description_short%", $description_short, $text);
         $text = str_replace("%description%", $description, $text);
         $text = str_replace("%link%", $link, $text);
         $text = str_replace("%addtocart%", $addtocart, $text);
         $text = str_replace("%countdown%", $countdown, $text);
         // $text = str_replace("%imgsrc%", $imgsrc, $text);
         $text = str_replace("%date%", $date_add, $text);
         $text = str_replace("%date_modified%", $date_upd, $text);
         $text = str_replace("%product_price%", $productprice, $text);
         $text = str_replace("%category_default%", $category_default, $text);
         $arrMatches = array();
         $text = str_replace('-', '_REVSLIDER_', $text);
         preg_match_all('/%product:\\w+%/', $text, $arrMatches);
         foreach ($arrMatches as $matched) {
             foreach ($matched as $match) {
                 $meta = str_replace("%product:", "", $match);
                 $meta = str_replace("%", "", $meta);
                 $meta = str_replace('_REVSLIDER_', '-', $meta);
                 if (isset($postData[$meta]) && !empty($postData[$meta])) {
                     $metaValue = $postData[$meta];
                     $text = str_replace($match, $metaValue, $text);
                 }
             }
         }
         $text = str_replace('_REVSLIDER_', '-', $text);
         // start hook exec
         $extra_hook_meta_exec = array();
         Hook::exec('actionsdsrevinsertmetaexec', array('extra_hook_meta_exec' => &$extra_hook_meta_exec, 'id_product' => &$postID));
         if (isset($extra_hook_meta_exec) && !empty($extra_hook_meta_exec)) {
             foreach ($extra_hook_meta_exec as $svalue) {
                 $hook_title = "%" . $svalue['title'] . "%";