本文整理汇总了PHP中Tools::unSerialize方法的典型用法代码示例。如果您正苦于以下问题:PHP Tools::unSerialize方法的具体用法?PHP Tools::unSerialize怎么用?PHP Tools::unSerialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tools
的用法示例。
在下文中一共展示了Tools::unSerialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: downloadAddonsThemes
public function downloadAddonsThemes()
{
if (!$this->logged_on_addons) {
return false;
}
if (!$this->isFresh(self::CACHE_FILE_CUSTOMER_THEMES_LIST, 86400)) {
file_put_contents(_PS_ROOT_DIR_ . self::CACHE_FILE_CUSTOMER_THEMES_LIST, Tools::addonsRequest('customer_themes'));
}
$customer_themes_list = file_get_contents(_PS_ROOT_DIR_ . self::CACHE_FILE_CUSTOMER_THEMES_LIST);
if (!empty($customer_themes_list) && ($customer_themes_list_xml = @simplexml_load_string($customer_themes_list))) {
foreach ($customer_themes_list_xml->theme as $addons_theme) {
//get addons theme if folder does not exist
$ids_themes = Tools::unSerialize(Configuration::get('PS_ADDONS_THEMES_IDS'));
if (!is_array($ids_themes) || is_array($ids_themes) && !in_array((string) $addons_theme->id, $ids_themes)) {
$zip_content = Tools::addonsRequest('module', array('id_module' => pSQL($addons_theme->id), 'username_addons' => pSQL(trim($this->context->cookie->username_addons)), 'password_addons' => pSQL(trim($this->context->cookie->password_addons))));
$uniqid = uniqid();
$sandbox = _PS_CACHE_DIR_ . 'sandbox' . DIRECTORY_SEPARATOR . $uniqid . DIRECTORY_SEPARATOR;
mkdir($sandbox);
file_put_contents($sandbox . (string) $addons_theme->getName() . '.zip', $zip_content);
if ($this->extractTheme($sandbox . (string) $addons_theme->getName() . '.zip', $sandbox)) {
if ($theme_directory = $this->installTheme(self::UPLOADED_THEME_DIR_NAME, $sandbox, false)) {
$ids_themes[$theme_directory] = (string) $addons_theme->id;
}
}
Tools::deleteDirectory($sandbox);
}
Configuration::updateValue('PS_ADDONS_THEMES_IDS', serialize($ids_themes));
}
}
}
示例2: getDeliveryOption
public function getDeliveryOption($default_country = null, $dontAutoSelectOptions = false, $use_cache = true)
{
@session_start();
if (Module::isInstalled('agilepaypal') && isset($_SESSION['agile_paypal_validating_order']) && $_SESSION['agile_paypal_validating_order'] == 1 && isset($this->delivery_option) && $this->delivery_option != '') {
$_SESSION['agile_paypal_validating_order'] = 0;
return Tools::unSerialize($this->delivery_option);
}
return parent::getDeliveryOption($default_country, $dontAutoSelectOptions, $use_cache);
}
示例3: printManifest
public static function printManifest($module_instance)
{
$cookie = Context::getContext()->cookie;
if (isset($cookie->dpdpoland_packages_ids)) {
if (version_compare(_PS_VERSION_, '1.5', '<')) {
$package_ids = unserialize(Context::getContext()->cookie->dpdpoland_packages_ids);
} else {
$package_ids = Tools::unSerialize(Context::getContext()->cookie->dpdpoland_packages_ids);
}
unset($cookie->dpdpoland_packages_ids);
$cookie->write();
$separated_packages = DpdPolandPackage::separatePackagesBySession($package_ids);
$international_packages = $separated_packages['INTERNATIONAL'];
$domestic_packages = $separated_packages['DOMESTIC'];
$manifest_ids = array();
if ($international_packages) {
$manifest_ids[] = DpdPolandManifest::getManifestIdWsByPackageIdWs($international_packages[0]);
}
if ($domestic_packages) {
$manifest_ids[] = DpdPolandManifest::getManifestIdWsByPackageIdWs($domestic_packages[0]);
}
require_once _DPDPOLAND_CONTROLLERS_DIR_ . 'manifestList.controller.php';
$manifest_controller = new DpdPolandManifestListController();
return $manifest_controller->printManifest($manifest_ids);
}
if ($package_ids = Tools::getValue('PackagesBox')) {
if (!DpdPolandManifest::validateSenderAddresses($package_ids)) {
$error_message = $module_instance->l('Manifests can not have different sender addresses', self::FILENAME);
$error = $module_instance->displayError($error_message);
return $module_instance->outputHTML($error);
}
$separated_packages = DpdPolandPackage::separatePackagesBySession($package_ids);
$international_packages = $separated_packages['INTERNATIONAL'];
$domestic_packages = $separated_packages['DOMESTIC'];
if ($international_packages) {
$manifest = new DpdPolandManifest();
if (!$manifest->generateMultiple($international_packages)) {
$error = $module_instance->displayError(reset(DpdPolandManifestWS::$errors));
return $module_instance->outputHTML($error);
}
}
if ($domestic_packages) {
$manifest = new DpdPolandManifest();
if (!$manifest->generateMultiple($domestic_packages)) {
$error = $module_instance->displayError(reset(DpdPolandManifestWS::$errors));
return $module_instance->outputHTML($error);
}
}
$cookie->dpdpoland_packages_ids = serialize($package_ids);
$redirect_uri = $module_instance->module_url . '&menu=packages_list';
die(Tools::redirectAdmin($redirect_uri));
}
}
示例4: getErrorMessage
public function getErrorMessage()
{
$message = $this->cookie->{self::DPD_POLAND_ERROR_MESSAGE};
if (Validate::isSerializedArray($message)) {
if (version_compare(_PS_VERSION_, '1.5', '<')) {
$message = unserialize($message);
} else {
$message = Tools::unSerialize($message);
}
}
$this->cookie->__unset(self::DPD_POLAND_ERROR_MESSAGE);
if (is_array($message)) {
return array_unique($message);
}
return $message ? array($message) : '';
}
示例5: initList
public function initList()
{
//$helper = new HelperList();
//$helper->title = array($this->module_instance->displayName, $this->module_instance->l('Translation projects', 'translation_projects.view'));
//return parent::initList($helper);
$projects = $this->getData();
$list_total = count($this->getData(false));
$pagination = array(20, 50, 100, 300);
$page = (int) Tools::getValue('submitFilterproject');
if (!$page) {
$page = 1;
}
$total_pages = ceil($list_total / Tools::getValue('pagination', 50));
if (!$total_pages) {
$total_pages = 1;
}
$selected_pagination = Tools::getValue('pagination', isset($this->context->cookie->{'project_pagination'}) ? $this->context->cookie->{'project_pagination'} : null);
$this->context->smarty->assign(array('projects' => $projects, 'list_total' => $list_total, 'page' => $page, 'full_url' => TextMaster::CURRENT_INDEX . Tools::getValue('token') . '&configure=' . $this->module_instance->name . '&menu=' . Tools::getValue('menu') . '&token=' . Tools::getAdminTokenLite('AdminModules'), 'menu' => 'translation', 'selected_pagination' => $selected_pagination, 'pagination' => $pagination, 'total_pages' => $total_pages));
$fields = array('id_project', 'name', 'language_from', 'language_to', 'status');
foreach ($fields as $key => $values) {
if ($this->context->cookie->__isset('projectFilter_' . $values)) {
$this->context->smarty->assign('cookie_projectFilter_' . $values, $this->context->cookie->{'projectFilter_' . $values});
}
}
$fields = array('date_add', 'date_upd');
foreach ($fields as $key => $values) {
if ($this->context->cookie->__isset('projectFilter_' . $values)) {
if (version_compare(_PS_VERSION_, '1.5', '<')) {
$date = unserialize($this->context->cookie->{'projectFilter_' . $values});
} else {
$date = Tools::unSerialize($this->context->cookie->{'projectFilter_' . $values});
}
if (!empty($date[0])) {
$this->context->smarty->assign('cookie_projectFilter_' . $values . '_0', pSQL($date[0]));
}
if (!empty($date[1])) {
$this->context->smarty->assign('cookie_projectFilter_' . $values . '_1', pSQL($date[1]));
}
}
}
if (version_compare(_PS_VERSION_, '1.5', '<')) {
includeDatepicker(array('projectFilter_date_add_0', 'projectFilter_date_add_1', 'projectFilter_date_upd_0', 'projectFilter_date_upd_1'));
} else {
$this->context->controller->addJqueryUI('ui.datepicker');
}
return $this->context->smarty->fetch(_PS_MODULE_DIR_ . 'textmaster/views/templates/admin/main_list.tpl');
}
示例6: isOrderSelected
public function isOrderSelected($id_order)
{
/*
* true = chechekd
* false = unchechekd
*/
$poutput = '<input type="checkbox" name="selected_orders[]" class="selected_orders" checked="checked" value="' . (int) $id_order . '">';
if (!empty($this->context->cookie->unselected_orders)) {
$unselected_orders_array = Tools::unSerialize($this->context->cookie->unselected_orders);
if (is_array($unselected_orders_array) && !empty($unselected_orders_array)) {
if (in_array($id_order, $unselected_orders_array)) {
$poutput = '<input type="checkbox" name="selected_orders[]" class="selected_orders" value="' . (int) $id_order . '">';
}
}
}
return $poutput;
}
示例7: ps1700_stores
function ps1700_stores()
{
$stores = Db::getInstance()->executeS('
SELECT `id_store`, `hours`
FROM `' . _DB_PREFIX_ . 'store`
');
$result = false;
foreach ($stores as $store) {
$hours = Tools::unSerialize($store['hours']);
if (is_array($hours)) {
foreach ($hours as $key => $h) {
$hours[$key] = [$h];
}
} else {
$hours = array();
}
$hours = json_encode($hours);
$result &= Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'store`
SET `hours` = ' . $hours . '
WHERE `id_store` = ' . $store['id_store']);
}
return $result;
}
示例8: collectFilterRules
private function collectFilterRules()
{
$rules = array();
$fields = array('id_project', 'name', 'language_from', 'language_to', 'status');
foreach ($fields as $key => $values) {
if ($this->context->cookie->__isset($this->table . 'Filter_' . $values)) {
$value = $this->context->cookie->{$this->table . 'Filter_' . $values};
if (!empty($value) || $value == '0') {
$rule = array('key' => $values, 'value' => pSQL($value));
$rules['find'][] = $rule;
}
}
}
$fields = array('date_add', 'date_upd');
foreach ($fields as $key => $values) {
if ($this->context->cookie->__isset($this->table . 'Filter_' . $values)) {
if (version_compare(_PS_VERSION_, '1.5', '<')) {
$date = unserialize($this->context->cookie->{$this->table . 'Filter_' . $values});
} else {
$date = Tools::unSerialize($this->context->cookie->{$this->table . 'Filter_' . $values});
}
if (!empty($date[0])) {
$rules['compare'][] = array('key' => $values, 'value' => pSQL($date[0]), 'operator' => '>');
}
if (!empty($date[1])) {
$rules['compare'][] = array('key' => $values, 'value' => pSQL($date[1]), 'operator' => '<');
}
}
}
return $rules;
$rules = array();
foreach ($this->module_instance->fields_list as $key => $value) {
$rule = '';
if ($this->context->cookie->__isset($this->table . 'Filter_' . $key)) {
$value = $this->context->cookie->{$this->table . 'Filter_' . $key};
if (Validate::isSerializedArray($value)) {
if (version_compare(_PS_VERSION_, '1.5', '<')) {
$date = unserialize($value);
} else {
$date = Tools::unSerialize($value);
}
if (!empty($date[0])) {
$rules['compare'][] = array('key' => $key, 'value' => pSQL($date[0]), 'operator' => '>');
}
if (!empty($date[1])) {
$rules['compare'][] = array('key' => $key, 'value' => pSQL($date[1]), 'operator' => '<');
}
} elseif (!empty($value) || $value == '0') {
$rule = array('key' => $key, 'value' => pSQL($value));
$rules['find'][] = $rule;
}
}
}
return $rules;
}
示例9: displayListHeader
//.........这里部分代码省略.........
<tr class="nodrag nodrop">
<th>';
if ($this->delete) {
echo ' <input type="checkbox" name="checkme" class="noborder" onclick="checkDelBoxes(this.form, \'' . $this->table . 'Box[]\', this.checked)" />';
}
echo ' </th>';
foreach ($this->fieldsDisplay as $key => $params) {
echo ' <th ' . (isset($params['widthColumn']) ? 'style="width: ' . $params['widthColumn'] . 'px"' : '') . '>' . $params['title'];
if (!isset($params['orderby']) || $params['orderby']) {
// Cleaning links
if (Tools::getValue($this->table . 'Orderby') && Tools::getValue($this->table . 'Orderway')) {
self::$currentIndex = preg_replace('/&' . $this->table . 'Orderby=([a-z _]*)&' . $this->table . 'Orderway=([a-z]*)/i', '', self::$currentIndex);
}
echo ' <br />
<a href="' . self::$currentIndex . '&' . $this->identifier . '=' . $id_cat . '&' . $this->table . 'Orderby=' . urlencode($key) . '&' . $this->table . 'Orderway=desc&token=' . $token . '"><img border="0" src="../img/admin/down' . (isset($this->_orderBy) && $key == $this->_orderBy && $this->_orderWay == 'DESC' ? '_d' : '') . '.gif" /></a>
<a href="' . self::$currentIndex . '&' . $this->identifier . '=' . $id_cat . '&' . $this->table . 'Orderby=' . urlencode($key) . '&' . $this->table . 'Orderway=asc&token=' . $token . '"><img border="0" src="../img/admin/up' . (isset($this->_orderBy) && $key == $this->_orderBy && $this->_orderWay == 'ASC' ? '_d' : '') . '.gif" /></a>';
}
echo ' </th>';
}
if ($this->shopLinkType) {
echo '<th style="width: 80px">' . $this->l($this->shopLinkType == 'shop' ? 'Shop' : 'Shop group') . '</th>';
}
/* Check if object can be modified, deleted or detailed */
if ($this->edit || $this->delete || $this->view && $this->view !== 'noActionColumn') {
echo ' <th style="width: 52px">' . $this->l('Actions') . '</th>';
}
echo ' </tr>
<tr class="nodrag nodrop" style="height: 35px;">
<td class="center">';
if ($this->delete) {
echo ' --';
}
echo ' </td>';
/* Javascript hack in order to catch ENTER keypress event */
$keyPress = 'onkeypress="formSubmit(event, \'submitFilterButton_' . $this->table . '\');"';
/* Filters (input, select, date or bool) */
foreach ($this->fieldsDisplay as $key => $params) {
$width = isset($params['width']) ? ' style="width: ' . (int) $params['width'] . 'px;"' : '';
echo '<td' . (isset($params['align']) ? ' class="' . $params['align'] . '"' : '') . '>';
if (!isset($params['type'])) {
$params['type'] = 'text';
}
$value = Tools::getValue($this->table . 'Filter_' . (array_key_exists('filter_key', $params) ? $params['filter_key'] : $key));
if (isset($params['search']) && !$params['search']) {
echo '--</td>';
continue;
}
switch ($params['type']) {
case 'bool':
echo '
<select name="' . $this->table . 'Filter_' . $key . '">
<option value="">-</option>
<option value="1"' . ($value == 1 ? ' selected="selected"' : '') . '>' . $this->l('Yes') . '</option>
<option value="0"' . ($value == 0 && $value != '' ? ' selected="selected"' : '') . '>' . $this->l('No') . '</option>
</select>';
break;
case 'date':
case 'datetime':
if (is_string($value)) {
$value = Tools::unSerialize($value);
}
if (!Validate::isCleanHtml($value[0]) || !Validate::isCleanHtml($value[1])) {
$value = '';
}
$name = $this->table . 'Filter_' . (isset($params['filter_key']) ? $params['filter_key'] : $key);
$nameId = str_replace('!', '__', $name);
includeDatepicker(array($nameId . '_0', $nameId . '_1'));
echo $this->l('From') . ' <input type="text" id="' . $nameId . '_0" name="' . $name . '[0]" value="' . (isset($value[0]) ? $value[0] : '') . '"' . $width . ' ' . $keyPress . ' /><br />
' . $this->l('To') . ' <input type="text" id="' . $nameId . '_1" name="' . $name . '[1]" value="' . (isset($value[1]) ? $value[1] : '') . '"' . $width . ' ' . $keyPress . ' />';
break;
case 'select':
if (isset($params['filter_key'])) {
echo '<select onchange="$(\'#submitFilter' . $this->table . '\').focus();$(\'#submitFilter' . $this->table . '\').click();" name="' . $this->table . 'Filter_' . $params['filter_key'] . '" ' . (isset($params['width']) ? 'style="width: ' . $params['width'] . 'px"' : '') . '>
<option value=""' . ($value == 0 && $value != '' ? ' selected="selected"' : '') . '>-</option>';
if (isset($params['select']) && is_array($params['select'])) {
foreach ($params['select'] as $optionValue => $optionDisplay) {
echo '<option value="' . $optionValue . '"' . (isset($_POST[$this->table . 'Filter_' . $params['filter_key']]) && Tools::getValue($this->table . 'Filter_' . $params['filter_key']) == $optionValue && Tools::getValue($this->table . 'Filter_' . $params['filter_key']) != '' ? ' selected="selected"' : '') . '>' . $optionDisplay . '</option>';
}
}
echo '</select>';
break;
}
case 'text':
default:
if (!Validate::isCleanHtml($value)) {
$value = '';
}
echo '<input type="text" name="' . $this->table . 'Filter_' . (isset($params['filter_key']) ? $params['filter_key'] : $key) . '" value="' . htmlentities($value, ENT_COMPAT, 'UTF-8') . '"' . $width . ' ' . $keyPress . ' />';
}
echo '</td>';
}
if ($this->shopLinkType) {
echo '<td>--</td>';
}
if ($this->edit || $this->delete || $this->view && $this->view !== 'noActionColumn') {
echo '<td class="center">--</td>';
}
echo '</tr>
</thead>';
}
示例10: setOrderStatusCapturedSuccesfully
public static function setOrderStatusCapturedSuccesfully($order_ref)
{
$oid = self::getOrdersIdFromOrderRef($order_ref);
if ($oid) {
$amz_payments = new AmzPayments();
$new_status = $amz_payments->capture_success_status_id;
self::setOrderStatus($oid, $new_status);
} else {
if (!isset(Context::getContext()->cookie->amzSetStatusCaptured)) {
Context::getContext()->cookie->amzSetStatusCaptured = serialize(array());
}
$tmpData = Tools::unSerialize(Context::getContext()->cookie->amzSetStatusCaptured);
$tmpData[] = $order_ref;
Context::getContext()->cookie->amzSetStatusCaptured = serialize($tmpData);
}
}
示例11: loadFromConfig
/**
* load the last version informations stocked in base
*
* @return $this
*/
public function loadFromConfig()
{
$last_version_check = Tools::unSerialize(Configuration::get('PS_LAST_VERSION'));
if ($last_version_check) {
if (isset($last_version_check['name'])) {
$this->version_name = $last_version_check['name'];
}
if (isset($last_version_check['num'])) {
$this->version_num = $last_version_check['num'];
}
if (isset($last_version_check['link'])) {
$this->link = $last_version_check['link'];
}
if (isset($last_version_check['autoupgrade'])) {
$this->autoupgrade = $last_version_check['autoupgrade'];
}
if (isset($last_version_check['autoupgrade_module'])) {
$this->autoupgrade_module = $last_version_check['autoupgrade_module'];
}
if (isset($last_version_check['autoupgrade_last_version'])) {
$this->autoupgrade_last_version = $last_version_check['autoupgrade_last_version'];
}
if (isset($last_version_check['autoupgrade_module_link'])) {
$this->autoupgrade_module_link = $last_version_check['autoupgrade_module_link'];
}
if (isset($last_version_check['md5'])) {
$this->md5 = $last_version_check['md5'];
}
if (isset($last_version_check['desc'])) {
$this->desc = $last_version_check['desc'];
}
if (isset($last_version_check['changelog'])) {
$this->changelog = $last_version_check['changelog'];
}
}
return $this;
}
示例12: sizeofvar
private function sizeofvar($var)
{
$start_memory = memory_get_usage();
$tmp = Tools::unSerialize(serialize($var));
$size = memory_get_usage() - $start_memory;
return $size;
}
示例13: init
//.........这里部分代码省略.........
$new_order_status_id = Configuration::get('AMZ_ORDER_STATUS_ID');
}
$this->module->validateOrder((int) $this->context->cart->id, $new_order_status_id, $total, $this->module->displayName, null, array(), null, false, $customer->secure_key);
if (self::$amz_payments->authorization_mode == 'after_checkout') {
$authorization_reference_id = Tools::getValue('amazonOrderReferenceId');
$authorization_response_wrapper = AmazonTransactions::authorize(self::$amz_payments, $this->service, $authorization_reference_id, $total, $currency_code);
$amazon_authorization_id = @$authorization_response_wrapper->getAuthorizeResult()->getAuthorizationDetails()->getAmazonAuthorizationId();
/*
if (self::$amz_payments->capture_mode == 'after_auth' && isset($amazon_authorization_id) && $amazon_authorization_id !== false && $amazon_authorization_id != null) {
$amazon_capture_response = AmazonTransactions::capture(self::$amz_payments, $this->service, $amazon_authorization_id, $total, $currency_code);
if (is_object($amazon_capture_response)) {
$amazon_capture_id = $amazon_capture_response->getCaptureResult()
->getCaptureDetails()
->getAmazonCaptureId();
$amazon_capture_reference_id = $amazon_capture_response->getCaptureResult()
->getCaptureDetails()
->getCaptureReferenceId();
}
}
*/
}
self::$amz_payments->setAmazonReferenceIdForOrderId(Tools::getValue('amazonOrderReferenceId'), $this->module->currentOrder);
self::$amz_payments->setAmazonReferenceIdForOrderTransactionId(Tools::getValue('amazonOrderReferenceId'), $this->module->currentOrder);
if (isset($authorization_reference_id)) {
self::$amz_payments->setAmazonAuthorizationReferenceIdForOrderId($authorization_reference_id, $this->module->currentOrder);
}
if (isset($amazon_authorization_id)) {
self::$amz_payments->setAmazonAuthorizationIdForOrderId($amazon_authorization_id, $this->module->currentOrder);
}
/*
if (isset($amazon_capture_reference_id)) {
self::$amz_payments->setAmazonCaptureReferenceIdForOrderId($amazon_capture_reference_id, $this->module->currentOrder);
}
if (isset($amazon_capture_id)) {
self::$amz_payments->setAmazonCaptureIdForOrderId($amazon_capture_id, $this->module->currentOrder);
}
*/
if (isset($this->context->cookie->amzSetStatusAuthorized)) {
$tmpOrderRefs = Tools::unSerialize($this->context->cookie->amzSetStatusAuthorized);
if (is_array($tmpOrderRefs)) {
foreach ($tmpOrderRefs as $order_ref) {
AmazonTransactions::setOrderStatusAuthorized($order_ref);
}
}
unset($this->context->cookie->amzSetStatusAuthorized);
}
if (isset($this->context->cookie->amzSetStatusCaptured)) {
$tmpOrderRefs = Tools::unSerialize($this->context->cookie->amzSetStatusCaptured);
if (is_array($tmpOrderRefs)) {
foreach ($tmpOrderRefs as $order_ref) {
AmazonTransactions::setOrderStatusCaptured($order_ref);
}
}
unset($this->context->cookie->amzSetStatusCaptured);
}
if (Tools::getValue('connect_amz_account') == '1') {
$this->context->cookie->amz_connect_order = $this->module->currentOrder;
$this->context->cookie->amz_payments_address_id = $address_delivery->id;
$this->context->cookie->amz_payments_invoice_address_id = $address_invoice->id;
$login_redirect = $this->context->link->getModuleLink('amzpayments', 'process_login');
$login_redirect = str_replace('http://', 'https://', $login_redirect);
$login_redirect .= '?fromCheckout=1&access_token=' . $this->context->cookie->amz_access_token;
die(Tools::jsonEncode(array('orderSucceed' => true, 'redirection' => $login_redirect)));
}
if (!$customer->is_guest) {
if (!AmzPayments::addressAlreadyExists($address_delivery, $customer)) {
$address_delivery->id_customer = $customer->id;
$address_delivery->save();
}
if (!AmzPayments::addressAlreadyExists($address_invoice, $customer)) {
$address_invoice->id_customer = $customer->id;
$address_invoice->save();
}
} else {
if ($registered_customer = AmazonPaymentsCustomerHelper::findByEmailAddress($customer->email)) {
if (!AmzPayments::addressAlreadyExists($address_delivery, $registered_customer)) {
$address_delivery->id_customer = $registered_customer->id;
$address_delivery->save();
}
if (!AmzPayments::addressAlreadyExists($address_invoice, $registered_customer)) {
$address_invoice->id_customer = $registered_customer->id;
$address_invoice->save();
}
}
$this->context->cookie->show_success_amz_message = true;
}
die(Tools::jsonEncode(array('orderSucceed' => true, 'redirection' => __PS_BASE_URI__ . 'index.php?controller=order-confirmation&id_cart=' . (int) $this->context->cart->id . '&id_module=' . $this->module->id . '&id_order=' . $this->module->currentOrder . '&key=' . $customer->secure_key)));
}
die;
default:
throw new PrestaShopException('Unknown method "' . Tools::getValue('method') . '"');
}
} else {
throw new PrestaShopException('Method is not defined');
}
}
} elseif (Tools::isSubmit('ajax')) {
throw new PrestaShopException('Method is not defined');
}
}
示例14: displayListHeader
/**
* Display list header (filtering, pagination and column names)
*/
public function displayListHeader()
{
if (!isset($this->list_id)) {
$this->list_id = $this->table;
}
$id_cat = (int) Tools::getValue('id_' . ($this->is_cms ? 'cms_' : '') . 'category');
if (!isset($token) || empty($token)) {
$token = $this->token;
}
/* Determine total page number */
$pagination = $this->_default_pagination;
if (in_array((int) Tools::getValue($this->list_id . '_pagination'), $this->_pagination)) {
$pagination = (int) Tools::getValue($this->list_id . '_pagination');
} elseif (isset($this->context->cookie->{$this->list_id . '_pagination'}) && $this->context->cookie->{$this->list_id . '_pagination'}) {
$pagination = $this->context->cookie->{$this->list_id . '_pagination'};
}
$total_pages = max(1, ceil($this->listTotal / $pagination));
$identifier = Tools::getIsset($this->identifier) ? '&' . $this->identifier . '=' . (int) Tools::getValue($this->identifier) : '';
$order = '';
if (Tools::getIsset($this->table . 'Orderby')) {
$order = '&' . $this->table . 'Orderby=' . urlencode($this->orderBy) . '&' . $this->table . 'Orderway=' . urlencode(strtolower($this->orderWay));
}
$action = $this->currentIndex . $identifier . '&token=' . $token . '#' . $this->list_id;
/* Determine current page number */
$page = (int) Tools::getValue('submitFilter' . $this->list_id);
if (!$page) {
$page = 1;
}
if ($page > $total_pages) {
$page = $total_pages;
}
$this->page = (int) $page;
/* Choose number of results per page */
$selected_pagination = Tools::getValue($this->list_id . '_pagination', isset($this->context->cookie->{$this->list_id . '_pagination'}) ? $this->context->cookie->{$this->list_id . '_pagination'} : $this->_default_pagination);
if (!isset($this->table_id) && $this->position_identifier && (int) Tools::getValue($this->position_identifier, 1)) {
$this->table_id = substr($this->identifier, 3, strlen($this->identifier));
}
if ($this->position_identifier && ($this->orderBy == 'position' && $this->orderWay != 'DESC')) {
$table_dnd = true;
}
$prefix = isset($this->controller_name) ? str_replace(array('admin', 'controller'), '', Tools::strtolower($this->controller_name)) : '';
$ajax = false;
foreach ($this->fields_list as $key => $params) {
if (!isset($params['type'])) {
$params['type'] = 'text';
}
$value_key = $prefix . $this->list_id . 'Filter_' . (array_key_exists('filter_key', $params) && $key != 'active' ? $params['filter_key'] : $key);
$value = Context::getContext()->cookie->{$value_key};
if (!$value && Tools::getIsset($value_key)) {
$value = Tools::getValue($value_key);
}
switch ($params['type']) {
case 'bool':
if (isset($params['ajax']) && $params['ajax']) {
$ajax = true;
}
break;
case 'date':
case 'datetime':
if (is_string($value)) {
$value = Tools::unSerialize($value);
}
if (!Validate::isCleanHtml($value[0]) || !Validate::isCleanHtml($value[1])) {
$value = '';
}
$name = $this->list_id . 'Filter_' . (isset($params['filter_key']) ? $params['filter_key'] : $key);
$name_id = str_replace('!', '__', $name);
$params['id_date'] = $name_id;
$params['name_date'] = $name;
$this->context->controller->addJqueryUI('ui.datepicker');
break;
case 'select':
foreach ($params['list'] as $option_value => $option_display) {
if (isset(Context::getContext()->cookie->{$prefix . $this->list_id . 'Filter_' . $params['filter_key']}) && Context::getContext()->cookie->{$prefix . $this->list_id . 'Filter_' . $params['filter_key']} == $option_value && Context::getContext()->cookie->{$prefix . $this->list_id . 'Filter_' . $params['filter_key']} != '') {
$this->fields_list[$key]['select'][$option_value]['selected'] = 'selected';
}
}
break;
case 'text':
if (!Validate::isCleanHtml($value)) {
$value = '';
}
}
$params['value'] = $value;
$this->fields_list[$key] = $params;
}
$has_value = false;
$has_search_field = false;
foreach ($this->fields_list as $key => $field) {
if (isset($field['value']) && $field['value'] !== false && $field['value'] !== '') {
if (is_array($field['value']) && trim(implode('', $field['value'])) == '') {
continue;
}
$has_value = true;
break;
}
if (!(isset($field['search']) && $field['search'] === false)) {
//.........这里部分代码省略.........
示例15: renderForm
public function renderForm()
{
if (!($obj = $this->loadObject(true))) {
return;
}
$image = _PS_STORE_IMG_DIR_ . $obj->id . '.jpg';
$image_url = ImageManager::thumbnail($image, $this->table . '_' . (int) $obj->id . '.' . $this->imageType, 350, $this->imageType, true, true);
$image_size = file_exists($image) ? filesize($image) / 1000 : false;
$tmp_addr = new Address();
$res = $tmp_addr->getFieldsRequiredDatabase();
$required_fields = array();
foreach ($res as $row) {
$required_fields[(int) $row['id_required_field']] = $row['field_name'];
}
$this->fields_form = array('legend' => array('title' => $this->l('Stores'), 'icon' => 'icon-home'), 'input' => array(array('type' => 'text', 'label' => $this->l('Name'), 'name' => 'name', 'required' => false, 'hint' => array($this->l('Store name (e.g. City Center Mall Store).'), $this->l('Allowed characters: letters, spaces and %s'))), array('type' => 'text', 'label' => $this->l('Address'), 'name' => 'address1', 'required' => true), array('type' => 'text', 'label' => $this->l('Address (2)'), 'name' => 'address2'), array('type' => 'text', 'label' => $this->l('Zip/postal Code'), 'name' => 'postcode', 'required' => in_array('postcode', $required_fields)), array('type' => 'text', 'label' => $this->l('City'), 'name' => 'city', 'required' => true), array('type' => 'select', 'label' => $this->l('Country'), 'name' => 'id_country', 'required' => true, 'default_value' => (int) $this->context->country->id, 'options' => array('query' => Country::getCountries($this->context->language->id), 'id' => 'id_country', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('State'), 'name' => 'id_state', 'required' => true, 'options' => array('id' => 'id_state', 'name' => 'name', 'query' => null)), array('type' => 'latitude', 'label' => $this->l('Latitude / Longitude'), 'name' => 'latitude', 'required' => true, 'maxlength' => 12, 'hint' => $this->l('Store coordinates (e.g. 45.265469/-47.226478).')), array('type' => 'text', 'label' => $this->l('Phone'), 'name' => 'phone'), array('type' => 'text', 'label' => $this->l('Fax'), 'name' => 'fax'), array('type' => 'text', 'label' => $this->l('Email address'), 'name' => 'email'), array('type' => 'textarea', 'label' => $this->l('Note'), 'name' => 'note', 'cols' => 42, 'rows' => 4), array('type' => 'switch', 'label' => $this->l('Status'), 'name' => 'active', 'required' => false, 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'hint' => $this->l('Whether or not to display this store.')), array('type' => 'file', 'label' => $this->l('Picture'), 'name' => 'image', 'display_image' => true, 'image' => $image_url ? $image_url : false, 'size' => $image_size, 'hint' => $this->l('Storefront picture.'))), 'hours' => array(), 'submit' => array('title' => $this->l('Save')));
if (Shop::isFeatureActive()) {
$this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association'), 'name' => 'checkBoxShopAsso');
}
$days = array();
$days[1] = $this->l('Monday');
$days[2] = $this->l('Tuesday');
$days[3] = $this->l('Wednesday');
$days[4] = $this->l('Thursday');
$days[5] = $this->l('Friday');
$days[6] = $this->l('Saturday');
$days[7] = $this->l('Sunday');
$hours = $this->getFieldValue($obj, 'hours');
if (!empty($hours)) {
$hours_unserialized = Tools::unSerialize($hours);
}
$this->fields_value = array('latitude' => $this->getFieldValue($obj, 'latitude') ? $this->getFieldValue($obj, 'latitude') : Configuration::get('PS_STORES_CENTER_LAT'), 'longitude' => $this->getFieldValue($obj, 'longitude') ? $this->getFieldValue($obj, 'longitude') : Configuration::get('PS_STORES_CENTER_LONG'), 'days' => $days, 'hours' => isset($hours_unserialized) ? $hours_unserialized : false);
return parent::renderForm();
}