public function postProcess()
 {
     //Incomplete. Payment will be validated and order will be created.
     echo '<pre>';
     var_dump(Tools::getAllValues());
     echo '</pre>';
     die;
 }
 /**
  * Assign template vars related to page content.
  *
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     if (Configuration::isCatalogMode()) {
         Tools::redirect('index.php');
     }
     parent::initContent();
     $order = new Order(Order::getOrderByCartId((int) $this->id_cart));
     $presentedOrder = $this->order_presenter->present($order);
     $register_form = $this->makeCustomerForm()->setGuestAllowed(false)->fillWith(Tools::getAllValues());
     $this->context->smarty->assign(array('HOOK_ORDER_CONFIRMATION' => $this->displayOrderConfirmation($order), 'HOOK_PAYMENT_RETURN' => $this->displayPaymentReturn($order), 'order' => $presentedOrder, 'register_form' => $register_form));
     if ($this->context->customer->is_guest) {
         /* If guest we clear the cookie for security reason */
         $this->context->customer->mylogout();
     }
     $this->setTemplate('checkout/order-confirmation');
 }
Example #3
0
 public function initContent()
 {
     parent::initContent();
     $should_redirect = false;
     if (Tools::isSubmit('submitCreate') || Tools::isSubmit('create_account')) {
         $register_form = $this->makeCustomerForm()->setGuestAllowed(false)->fillWith(Tools::getAllValues());
         if (Tools::isSubmit('submitCreate')) {
             if ($register_form->submit()) {
                 $should_redirect = true;
             }
         }
         $this->context->smarty->assign(['register_form' => $register_form->getProxy(), 'hook_create_account_top' => Hook::exec('displayCustomerAccountFormTop')]);
         $this->setTemplate('customer/registration');
     } else {
         $login_form = $this->makeLoginForm()->fillWith(Tools::getAllValues());
         if (Tools::isSubmit('submitLogin')) {
             if ($login_form->submit()) {
                 $should_redirect = true;
             }
         }
         $this->context->smarty->assign(['login_form' => $login_form->getProxy()]);
         $this->setTemplate('customer/authentication');
     }
     if ($should_redirect && !$this->ajax) {
         $back = urldecode(Tools::getValue('back'));
         if (Tools::secureReferrer($back)) {
             // Checks to see if "back" is a fully qualified
             // URL that is on OUR domain, with the right protocol
             $this->redirectWithNotifications($back);
         } else {
             // Well we're not redirecting to a URL,
             // so...
             if ($this->authRedirection) {
                 // We may need to go there if defined
                 $back = $this->authRedirection;
             } elseif (!preg_match('/^[\\w\\-]+$/', $back)) {
                 // Otherwise, check that "back" matches a controller name
                 // and set a default if not.
                 $back = 'my-account';
             }
             $this->redirectWithNotifications('index.php?controller=' . urlencode($back));
         }
     }
 }
Example #4
0
 public function copyFromPost()
 {
     /* Classical fields */
     $posts = Tools::getAllValues();
     foreach ($posts as $key => $value) {
         if (key_exists($key, $this) && $key != 'id_' . $this->table) {
             $this->{$key} = $value;
         }
     }
     /* Multilingual fields */
     if (count($this->fieldsValidateLang) > 0) {
         $languages = Language::getLanguages(false);
         foreach ($languages as $language) {
             foreach ($this->fieldsValidateLang as $field => $validation) {
                 if (Tools::getIsset($field . '_' . (int) $language['id_lang'])) {
                     $this->{$field}[(int) $language['id_lang']] = Tools::getValue($field . '_' . (int) $language['id_lang']);
                 }
             }
         }
     }
 }
Example #5
0
 /**
  * Start forms process
  * @see FrontController::postProcess()
  */
 public function postProcess()
 {
     $this->context->smarty->assign('editing', false);
     $this->address_form->fillWith(Tools::getAllValues());
     if (Tools::isSubmit('submitAddress')) {
         if (!$this->address_form->submit()) {
             $this->errors[] = $this->trans('Please fix the error below.', array(), 'Shop.Notifications.Error');
         } else {
             if (Tools::getValue('id_address')) {
                 $this->success[] = $this->trans('Address successfully updated!', array(), 'Shop.Notifications.Success');
             } else {
                 $this->success[] = $this->trans('Address successfully added!', array(), 'Shop.Notifications.Success');
             }
             $this->should_redirect = true;
         }
     } elseif ($id_address = (int) Tools::getValue('id_address')) {
         $addressForm = $this->address_form->loadAddressById($id_address);
         if ($addressForm->getAddress()->id === null) {
             return Tools::redirect('index.php?controller=404');
         }
         if (!$this->context->customer->isLogged()) {
             return $this->redirectWithNotifications('/index.php?controller=authentication');
         }
         if ($addressForm->getAddress()->id_customer != $this->context->customer->id) {
             return Tools::redirect('index.php?controller=404');
         }
         if (Tools::getValue('delete')) {
             $ok = $this->makeAddressPersister()->delete(new Address($id_address, $this->context->language->id), Tools::getValue('token'));
             if ($ok) {
                 $this->success[] = $this->trans('Address successfully deleted!', array(), 'Shop.Notifications.Success');
                 $this->should_redirect = true;
             } else {
                 $this->errors[] = $this->trans('Could not delete address.', array(), 'Shop.Notifications.Error');
             }
         } else {
             $this->context->smarty->assign('editing', true);
         }
     }
 }
Example #6
0
 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     $should_redirect = false;
     parent::initContent();
     $customer_form = $this->makeCustomerForm();
     $customer_form->getFormatter()->setAskForNewPassword(true)->setPasswordRequired(true);
     if (Tools::isSubmit('submitCreate')) {
         $customer_form->fillWith(Tools::getAllValues());
         if ($customer_form->submit()) {
             $this->success[] = $this->trans('Information successfully updated.', array(), 'Shop.Notifications.Success');
             $should_redirect = true;
         } else {
             $this->errors[] = $this->trans('Could not update your information, please check your data.', array(), 'Shop.Notifications.Error');
         }
     } else {
         $customer_form->fillFromCustomer($this->context->customer);
     }
     $this->context->smarty->assign(['customer_form' => $customer_form->getProxy()]);
     if ($should_redirect) {
         $this->redirectWithNotifications($this->getCurrentURL());
     }
     $this->setTemplate('customer/identity');
 }
 protected function processAeucLegalContentManager()
 {
     $posted_values = Tools::getAllValues();
     $cms_role_repository = $this->entity_manager->getRepository('CMSRole');
     foreach ($posted_values as $key_name => $assoc_cms_id) {
         if (strpos($key_name, 'CMSROLE_') !== false) {
             $exploded_key_name = explode('_', $key_name);
             $cms_role = $cms_role_repository->findOne((int) $exploded_key_name[1]);
             $cms_role->id_cms = (int) $assoc_cms_id;
             $cms_role->update();
         }
     }
     unset($cms_role);
 }
Example #8
0
 /**
  *
  */
 public function showWidgetsSetting()
 {
     $this->context->controller->addCss(__PS_BASE_URI__ . 'modules/psmegamenu/views/css/admin/widget.css');
     if (Tools::isSubmit('deletepsmegamenu') && Tools::getValue('id_widget')) {
         $model = new PsMegamenuWidget(Tools::getValue('id_widget'));
         $model->deleteItem(Tools::getValue('id_widget'));
         $this->clearCache();
         Tools::redirectAdmin($this->base_config_url);
     }
     $form = '';
     $widget_selected = '';
     $id = (int) Tools::getValue('id_widget');
     $key = (int) Tools::getValue('key');
     $fb_widget_action = $this->base_config_url . '&widgets=1&wtype=' . Tools::getValue('wtype');
     Media::addJsDef(array('fb_widget_action' => $fb_widget_action));
     if (Tools::getValue('key_widget')) {
         $key = Tools::getValue('key_widget');
     }
     if (Tools::getValue('id_widget')) {
         $model = new PsMegamenuWidget($id);
     } else {
         $model = $this->widget;
     }
     $model->loadEngines();
     $model->id_shop = Context::getContext()->shop->id;
     $types = $model->getTypes();
     $resul_html = array('error' => '', 'confirm' => '');
     if (Tools::isSubmit('widgets') && Tools::isSubmit('savepsmegamenu') && Tools::isSubmit('widget_name') && Tools::isSubmit('widget_type') && Tools::getValue('widget_type') && Tools::getValue('widget_name')) {
         $posts = Tools::getAllValues();
         foreach ($posts as $key => $value) {
             $posts[$key] = str_replace('"', '\'', str_replace('\\n\\r', ' ', trim($value)));
         }
         $data = array('id' => $id, 'params' => $this->mscript->encode(serialize($posts)), 'type' => Tools::getValue('widget_type'), 'name' => Tools::getValue('widget_name'));
         foreach ($data as $k => $v) {
             $model->{$k} = $v;
         }
         if ($model->id) {
             if ($model->update()) {
                 $url = $this->base_config_url . '&widgets=1&id_widget=' . Tools::getValue('id_widget') . '&updatepsmegamenu';
                 Tools::redirectAdmin($url);
                 $resul_html['confirm'] = $this->l('Save Widget Setting, Done');
             } else {
                 $resul_html['error'] = $this->l('Can not update widget');
             }
         } else {
             $model->key_widget = time();
             if ($model->add()) {
                 $url = $this->base_config_url . '&widgets=1&id_widget=' . Tools::getValue('id_widget') . '&updatepsmegamenu';
                 Tools::redirectAdmin($url);
                 $resul_html['confirm'] = $this->l('Add New Widget, Done');
             } else {
                 $resul_html['error'] = $this->l('Can not add new widget');
             }
         }
         $id = $model->id;
         $this->clearCache();
     }
     if ($key) {
         $widget_data = $model->getWidetByKey($key);
     } else {
         $widget_data = $model->getWidetById($id);
     }
     $id = (int) $widget_data['id'];
     $widget_selected = array();
     $widget_selected = trim(Tools::strtolower(Tools::getValue('wtype')));
     if ($widget_data['type']) {
         $widget_selected = $widget_data['type'];
     }
     $form = $model->getForm($widget_selected, $widget_data);
     $this->context->smarty->assign('resulHtml', $resul_html);
     $this->context->smarty->assign('form', $form);
     $this->context->smarty->assign('types', $types);
     $this->context->smarty->assign('widget_selected', $widget_selected);
     $this->context->smarty->assign('fb_widget_action', $fb_widget_action);
     $this->context->smarty->assign('backtolist_action', $this->base_config_url . '&widgets=1');
     return $this->display(__FILE__, 'views/templates/admin/widget.tpl');
 }
 public function ajaxDoSavewidget()
 {
     $wpost = Tools::getIsset('wkey') ? Tools::getAllValues() : null;
     if (Tools::getValue('controller') && $wpost) {
         $exls = array('action', 'ajax', 'controller', 'id_tab');
         foreach ($exls as $e) {
             if (isset($wpost[$e])) {
                 unset($wpost[$e]);
             }
         }
         $post = array();
         $post['widget'] = $wpost;
         $post['wkey'] = Tools::getValue('wkey');
         foreach ($post['widget'] as $key => $value) {
             if (is_array($value)) {
                 if ($key != 'categorytab' && $key != 'promotions' && $key != 'products_slideshow') {
                     foreach ($value as &$val) {
                         $val = html_entity_decode($val, ENT_QUOTES, 'UTF-8');
                     }
                     $post['widget'][$key] = $this->mcrypt->encode(implode(',', $value));
                 }
             } else {
                 $value = html_entity_decode($value, ENT_QUOTES, 'UTF-8');
                 $post['widget'][$key] = preg_replace('#\\n|\\r|\\t#', '', $this->mcrypt->encode($value));
             }
         }
         if (Tools::getIsset('categorytab') && Tools::getValue('categorytab')) {
             $post['widget']['categorytab'] = $this->mcrypt->encode(Tools::jsonEncode(Tools::getValue('categorytab')));
         }
         if (Tools::getIsset('promotions') && Tools::getValue('promotions')) {
             $post['widget']['promotions'] = $this->mcrypt->encode(Tools::jsonEncode(Tools::getValue('promotions')));
         }
         if (Tools::getIsset('products_slideshow') && Tools::getValue('products_slideshow')) {
             $post['widget']['products_slideshow'] = $this->mcrypt->encode(Tools::jsonEncode(Tools::getValue('products_slideshow')));
         }
         $content = trim(serialize($post));
         $output = new stdClass();
         $output->wkey = $post['wkey'];
         $output->config = $content;
         $output->name = isset($wpost['widget_name']) ? $wpost['widget_name'] : '';
         echo Tools::jsonEncode($output);
         exit;
     }
 }
Example #10
0
 /**
  *
  */
 public function hookdisplayHeader()
 {
     $this->context->controller->addJqueryPlugin('fancybox');
     $loadrlt = true;
     $cgtheme = _PS_MODE_DEMO_ ? $this->getCustomConfig('themeskin', Configuration::get('PTS_CP_THEME')) : Configuration::get('PTS_CP_THEME');
     if (_PS_MODE_DEMO_) {
         if (Tools::getValue('themeskin') && Tools::getValue('themeskinactived')) {
             $cgtheme = $this->saveCustomConfig('themeskin', Tools::getValue('themeskin'));
             if (Tools::getIsset('headers')) {
                 $header = Tools::getValue('headers', 'default');
                 $this->saveCustomConfig('header', $header);
             }
         }
         if (Tools::getValue('headers') && Tools::getValue('headerctived')) {
             $header = Tools::getValue('headers', 'default');
             $this->saveCustomConfig('header', $header);
         }
         if (Tools::getValue('productsstyle') && Tools::getValue('productsstyleactived')) {
             $productsstyle = Tools::getValue('productsstyle', 'style1');
             $this->saveCustomConfig('productsstyle', $productsstyle);
         }
         if (Tools::getValue('productdetail') && Tools::getValue('productdetailactived')) {
             $productdetail = Tools::getValue('productdetail', 'default');
             $this->saveCustomConfig('productdetail', $productdetail);
         }
         if (Tools::isSubmit('applyCustomSkinChanger')) {
             $cgtheme = $this->saveCustomConfig('themeskin', Tools::getValue('themeskin'));
             if (Tools::getIsset('headers')) {
                 $header = Tools::getValue('headers', 'default');
                 $this->saveCustomConfig('header', $header);
             }
             if (Tools::getIsset('productsstyle')) {
                 $productsstyle = Tools::getValue('productsstyle', 'style1');
                 $this->saveCustomConfig('productsstyle', $productsstyle);
             }
             if (Tools::getValue('productdetail') && Tools::getValue('productdetailactived')) {
                 $productdetail = Tools::getValue('productdetail', 'default');
                 $this->saveCustomConfig('productdetail', $productdetail);
             }
         }
         if (Tools::isSubmit('resetDemoTheme')) {
             $cgtheme = $this->saveCustomConfig('themeskin', Configuration::get('PTS_CP_THEME'));
             $this->saveCustomConfig('header', Configuration::get('PTS_CP_HEADER'));
         }
         $this->context->smarty->assign('header_cp', $this->getCustomConfig('header', Tools::getValue('headers', Configuration::get('PTS_CP_HEADER'))));
     }
     if (!isset($productdetail)) {
         $productdetail = _PS_MODE_DEMO_ ? $this->getCustomConfig('productdetail', Configuration::get('PTS_CP_PRODUCT_DETAIL')) : Configuration::get('PTS_CP_PRODUCT_DETAIL');
     }
     $this->context->smarty->assign('productdetail', $productdetail);
     if (!empty($cgtheme)) {
         $themeskinfile = _PS_ALL_THEMES_DIR_ . $this->theme_name . '/css/global-' . $cgtheme . '.css';
         $themeskinfilertl = _PS_ALL_THEMES_DIR_ . $this->theme_name . '/css/global-rtl-' . $cgtheme . '.css';
         if ($this->context->language->is_rtl && file_exists($themeskinfilertl)) {
             $this->reloadGlobalCssFile('global-rtl-' . $cgtheme . '.css');
             $loadrlt = false;
         } elseif (file_exists($themeskinfile)) {
             $this->reloadGlobalCssFile('global-' . $cgtheme . '.css');
         }
     }
     if ($this->context->language->is_rtl && $loadrlt) {
         $this->reloadGlobalCssFile('rtl-global.css');
     }
     if (!$this->is_showed) {
         return null;
     }
     if ($this->checkVisiable()) {
         $this->context->controller->addCSS($this->_path . 'views/css/panel.css');
         $this->context->controller->addJS($this->_path . 'views/js/live_configurator.js');
         $this->context->controller->addCSS($this->_path . 'views/css/colorpicker/colorpicker.css', 'all');
         $this->context->controller->addJS($this->_path . 'views/js/colorpicker/colorpicker.js');
         $this->theme_customize_path = _PS_ALL_THEMES_DIR_ . $this->theme_name . '/css/profiles/';
     }
     if ((int) Configuration::get('PTS_CP_ACTIVE') == 1 && Tools::getValue('live_configurator_token') && $this->checkValidToken()) {
         if (Tools::isSubmit('submitPtsLiveConfiguratorDelete') && Tools::getValue('saved_file')) {
             $file = Tools::getValue('saved_file');
             if (file_exists($this->theme_customize_path . $file . '.css')) {
                 unlink($this->theme_customize_path . $file . '.css');
             }
             if (file_exists($this->theme_customize_path . $file . '.json')) {
                 unlink($this->theme_customize_path . $file . '.json');
             }
         }
         if (Tools::isSubmit('submitLiveThemeChanger') && Tools::getValue('themeskin')) {
             $themeskin = Tools::getValue('themeskin');
             if (Tools::getValue($themeskin . '_rehook')) {
                 $sample = new PtsThemeSample($this->theme_name);
                 $sample->reHookBySkin($themeskin);
             }
             Configuration::updateValue('PTS_CP_THEME', Tools::getValue('themeskin'));
             if (Tools::getIsset('headers')) {
                 $header = Tools::getValue('headers', 'default');
                 Configuration::updateValue('PTS_CP_HEADER', $header);
             }
             $id_employee = is_object($this->context->employee) ? (int) $this->context->employee->id : Tools::getValue('id_employee');
             $url = $this->context->shop->getBaseURL() . (Configuration::get('PS_REWRITING_SETTINGS') && count(Language::getLanguages(true)) > 1 ? Language::getIsoById($this->context->language->id) . '/' : '') . (Configuration::get('PS_REWRITING_SETTINGS') ? '' : 'index.php') . '?live_configurator_token=' . $this->getLiveConfiguratorToken() . '&id_employee=' . (int) $id_employee . '&id_shop=' . (int) $this->context->shop->id;
             Tools::redirect($url);
         }
         if (Tools::isSubmit('submitPtsLiveConfiguratorActiveProfile') && Tools::getValue('saved_file')) {
             Configuration::updateValue('PTS_CP_PROFILE', Tools::getValue('saved_file'));
         }
         if (Tools::isSubmit('submitPtsLiveConfigurator')) {
             $data = Tools::getAllValues();
             $selectors = $data['customize'];
             $matches = $data['customize_match'];
             $output = '';
             $cache = array();
             $tmpss = array();
             foreach ($selectors as $match => $customizes) {
                 foreach ($customizes as $key => $customize) {
                     if (isset($matches[$match]) && isset($matches[$match][$key])) {
                         $tmp = explode('|', $matches[$match][$key]);
                         if (trim($customize)) {
                             if (Tools::strtolower(trim($tmp[1])) == 'background-image') {
                                 $tmpss[$tmp[0]][] = $tmp[1] . ':url(' . $customize . ')';
                             } else {
                                 $prefix = preg_match('#color#i', $tmp[1]) ? '#' : '';
                                 $suffix = preg_match('#size#i', $tmp[1]) ? 'px' : '';
                                 $tmpss[$tmp[0]][] = $tmp[1] . ':' . $prefix . $customize . $suffix;
                             }
                         }
                         $cache[$match][] = array('val' => $customize, 'selector' => $tmp[0], 'attr' => $tmp[1]);
                     }
                 }
             }
             $output = '';
             foreach ($tmpss as $key => $values) {
                 $output .= "\r\n/* customize for {$key} */ \r\n";
                 $output .= $key . " { \r\n" . implode(";\r\n", $values) . " \r\n} \r\n";
             }
             if (!empty($data['saved_file'])) {
                 if ($data['saved_file'] && file_exists($this->theme_customize_path . $data['saved_file'] . '.css')) {
                     unlink($this->theme_customize_path . $data['saved_file'] . '.css');
                 }
                 if ($data['saved_file'] && file_exists($this->theme_customize_path . $data['saved_file'] . '.json')) {
                     unlink($this->theme_customize_path . $data['saved_file'] . '.json');
                 }
             }
             if (empty($data['newfile'])) {
                 $name_file = $data['saved_file'] ? $data['saved_file'] : 'profile-' . time();
             } else {
                 $name_file = preg_replace('#\\s+#', '-', trim($data['newfile']));
             }
             if ($data['action-mode'] != 'save-delete') {
                 if (!empty($output)) {
                     PtsThemePanelHelper::writeToCache($this->theme_customize_path, $name_file, $output);
                 }
                 if (!empty($cache)) {
                     PtsThemePanelHelper::writeToCache($this->theme_customize_path, $name_file, Tools::jsonEncode($cache), 'json');
                 }
             }
         }
     }
     if ($cgtheme != '') {
         $this->context->controller->addCss(_PS_THEME_DIR_ . 'css/themes/' . $cgtheme . '.css', 'all');
     }
     if (Configuration::get('PTS_CP_PROFILE')) {
         $this->context->controller->addCss(_PS_THEME_DIR_ . 'css/profiles/' . Configuration::get('PTS_CP_PROFILE') . '.css', 'all');
     }
     $this->context->smarty->registerPlugin('function', 'plugin', array('PtsthemePanel', 'smartyplugin'));
     $this->context->smarty->assign('LANG_DIRECTION', $this->context->language->is_rtl ? 'rtl' : 'ltr');
     if (!isset($productsstyle)) {
         $productsstyle = _PS_MODE_DEMO_ ? $this->getCustomConfig('productsstyle', Configuration::get('PTS_CP_PRODUCT_STYLE')) : Configuration::get('PTS_CP_PRODUCT_STYLE');
     }
     $this->context->smarty->assign('product_style', $productsstyle);
     $this->context->smarty->assign(array('DEFAUTL_LAYOUT' => $this->getConfigValue('layout'), 'PRODUCTS_ITEMSROW' => $this->getConfigValue('products_itemrow'), 'DEFAUTL_LANGUAGEID' => $this->context->language->id, 'DEFAULT_THEMESKIN' => $cgtheme, 'CURRENT_THEMEDIR' => _PS_ALL_THEMES_DIR_ . $this->theme_name . '/', 'THEME_SKIN_DIR' => _PS_ALL_THEMES_DIR_ . $this->theme_name . '/sub/themes/' . $cgtheme . '/', 'THEME_HEADER_FILE' => _PS_ALL_THEMES_DIR_ . $this->theme_name . '/sub/themes/' . $cgtheme . '/header.tpl'));
     $output = '';
     if ($this->getConfigValue('product_layout') == 'gallery') {
         $this->context->controller->addJS($this->_path . 'views/js/gallery.js');
     }
     if ($customcss = $this->getConfigValue('customcss')) {
         $output .= '<style type="text/css">' . $customcss . '</style>';
     }
     if ($customjs = $this->getConfigValue('customjs')) {
         $output .= '\\r\\n<script type="text/javascript">' . $customjs . '</script>';
     }
     return $output;
 }
Example #11
0
 public function initContent()
 {
     if (Configuration::isCatalogMode()) {
         Tools::redirect('index.php');
     }
     parent::initContent();
     $this->restorePersistedData($this->checkoutProcess);
     $this->checkoutProcess->handleRequest(Tools::getAllValues());
     $presentedCart = $this->cart_presenter->present($this->context->cart);
     if (count($presentedCart['products']) <= 0 || $presentedCart['minimalPurchaseRequired']) {
         Tools::redirect('index.php?controller=cart');
     }
     $this->checkoutProcess->setNextStepReachable()->markCurrentStep()->invalidateAllStepsAfterCurrent();
     $this->saveDataToPersist($this->checkoutProcess);
     if (!$this->checkoutProcess->hasErrors()) {
         if ($_SERVER['REQUEST_METHOD'] !== 'GET' && !$this->ajax) {
             return $this->redirectWithNotifications($this->checkoutProcess->getCheckoutSession()->getCheckoutURL());
         }
     }
     $this->context->smarty->assign(['checkout_process' => new RenderableProxy($this->checkoutProcess), 'cart' => $presentedCart]);
     $this->setTemplate('checkout/checkout');
 }