本文整理汇总了PHP中ShopUrl类的典型用法代码示例。如果您正苦于以下问题:PHP ShopUrl类的具体用法?PHP ShopUrl怎么用?PHP ShopUrl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ShopUrl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderForm
public function renderForm()
{
$update_htaccess = Tools::modRewriteActive() && (file_exists('.htaccess') && is_writable('.htaccess') || is_writable(dirname('.htaccess')));
$this->multiple_fieldsets = true;
if (!$update_htaccess) {
$desc_virtual_uri = array('<span class="warning_mod_rewrite">' . $this->l('You need to activate URL Rewriting if you want to add a virtual URL.') . '</span>');
} else {
$desc_virtual_uri = array($this->l('You can use this option if you want to create a store with a URL that doesn\'t exist on your server (e.g. if you want your store to be available with the URL www.my-prestashop.com/my-store/shoes/, you have to set shoes/ in this field, assuming that my-store/ is your Physical URL).'), '<strong>' . $this->l('URL rewriting must be activated on your server to use this feature.') . '</strong>');
}
$this->fields_form = array(array('form' => array('legend' => array('title' => $this->l('URL options'), 'icon' => 'icon-cogs'), 'input' => array(array('type' => 'select', 'label' => $this->l('Shop'), 'name' => 'id_shop', 'onchange' => 'checkMainUrlInfo(this.value);', 'options' => array('optiongroup' => array('query' => Shop::getTree(), 'label' => 'name'), 'options' => array('query' => 'shops', 'id' => 'id_shop', 'name' => 'name'))), array('type' => 'switch', 'label' => $this->l('Main URL'), 'name' => 'main', 'class' => 't', 'values' => array(array('id' => 'main_on', 'value' => 1), array('id' => 'main_off', 'value' => 0)), 'desc' => array($this->l('If you set this URL as the Main URL for the selected shop, all URLs set to this shop will be redirected to this URL (you can only have one Main URL per shop).'), array('text' => $this->l('Since the selected shop has no main URL, you have to set this URL as the Main URL.'), 'id' => 'mainUrlInfo'), array('text' => $this->l('The selected shop already has a Main URL. Therefore, if you set this one as the Main URL, the older of the two will be set as the normal URL.'), 'id' => 'mainUrlInfoExplain'))), array('type' => 'switch', 'label' => $this->l('Enabled'), 'name' => 'active', 'required' => false, 'class' => 't', 'values' => array(array('id' => 'active_on', 'value' => 1), array('id' => 'active_off', 'value' => 0)))), 'submit' => array('title' => $this->l('Save')))), array('form' => array('legend' => array('title' => $this->l('Shop URL'), 'icon' => 'icon-shopping-cart'), 'input' => array(array('type' => 'text', 'label' => $this->l('Domain'), 'name' => 'domain', 'size' => 50), array('type' => 'text', 'label' => $this->l('Domain SSL'), 'name' => 'domain_ssl', 'size' => 50)), 'submit' => array('title' => $this->l('Save')))));
if (!defined('_PS_HOST_MODE_')) {
$this->fields_form[1]['form']['input'] = array_merge($this->fields_form[1]['form']['input'], array(array('type' => 'text', 'label' => $this->l('Physical URL'), 'name' => 'physical_uri', 'desc' => $this->l('This is the physical folder for your store on the server. Leave this field empty if your store is installed on the root path (e.g. if your store is available at www.my-prestashop.com/my-store/, you input my-store/ in this field).'), 'size' => 50)));
}
$this->fields_form[1]['form']['input'] = array_merge($this->fields_form[1]['form']['input'], array(array('type' => 'text', 'label' => $this->l('Virtual URL'), 'name' => 'virtual_uri', 'desc' => $desc_virtual_uri, 'size' => 50, 'hint' => !$update_htaccess ? $this->l('Warning: URL rewriting (e.g. mod_rewrite for Apache) seems to be disabled. If your URL doesn\'t work, please check with your host provider on how to activate URL rewriting.') : null), array('type' => 'text', 'label' => $this->l('Your final URL will be'), 'name' => 'final_url', 'size' => 76, 'readonly' => true)));
if (!($obj = $this->loadObject(true))) {
return;
}
self::$currentIndex = self::$currentIndex . '&id_shop=' . $obj->id;
$current_shop = Shop::initialize();
$list_shop_with_url = array();
foreach (Shop::getShops(false, null, true) as $id) {
$list_shop_with_url[$id] = (bool) count(ShopUrl::getShopUrls($id));
}
$this->tpl_form_vars = array('js_shop_url' => Tools::jsonEncode($list_shop_with_url));
$this->fields_value = array('domain' => Validate::isLoadedObject($obj) ? $this->getFieldValue($obj, 'domain') : $current_shop->domain, 'domain_ssl' => Validate::isLoadedObject($obj) ? $this->getFieldValue($obj, 'domain_ssl') : $current_shop->domain_ssl, 'physical_uri' => Validate::isLoadedObject($obj) ? $this->getFieldValue($obj, 'physical_uri') : $current_shop->physical_uri, 'active' => true);
return parent::renderForm();
}
示例2: generateRewriteRules
private function generateRewriteRules()
{
if (Configuration::get('PS_REWRITING_SETTINGS')) {
$rules = "#start_prestanews - not remove this comment \n";
$physical_uri = array();
foreach (ShopUrl::getShopUrls() as $shop_url) {
if (in_array($shop_url->physical_uri, $physical_uri)) {
continue;
}
$rules .= "RewriteRule ^(.*)news\$ " . $shop_url->physical_uri . "index.php?fc=module&module=psnews&controller=news [QSA,L] \n";
$rules .= "RewriteRule ^(.*)news/([0-9]+)\\-([a-zA-Z0-9-]*) " . $shop_url->physical_uri . "index.php?fc=module&module=psnews&controller=news&news=\$2 [QSA,L] \n";
$physical_uri[] = $shop_url->physical_uri;
}
$rules .= "#end_prestanews \n\n";
$path = _PS_ROOT_DIR_ . '/.htaccess';
if (is_writable($path)) {
$existingRules = file_get_contents($path);
if (!strpos($existingRules, "start_prestanews")) {
$handle = fopen($path, 'w');
fwrite($handle, $rules . $existingRules);
fclose($handle);
}
}
}
}
示例3: __construct
public function __construct()
{
parent::__construct();
$this->ht_file = _PS_ROOT_DIR_ . '/.htaccess';
$this->rb_file = _PS_ROOT_DIR_ . '/robots.txt';
$this->sm_file = _PS_ROOT_DIR_ . '/sitemap.xml';
$this->rb_data = $this->getRobotsContent();
$this->explicitSelect = true;
$this->addRowAction('edit');
$this->addRowAction('delete');
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
$this->fields_list = array('id_meta' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'page' => array('title' => $this->l('Page'), 'width' => 120), 'title' => array('title' => $this->l('Title'), 'width' => 120), 'url_rewrite' => array('title' => $this->l('Friendly URL'), 'width' => 120));
$this->_group = 'GROUP BY a.id_meta';
// Options to generate friendly urls
$mod_rewrite = Tools::modRewriteActive();
$general_fields = array('PS_REWRITING_SETTINGS' => array('title' => $this->l('Friendly URL'), 'desc' => $mod_rewrite ? $this->l('Enable only if your server allows URL rewriting (recommended).') : '', 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'rewriting_settings', 'mod_rewrite' => $mod_rewrite), 'PS_ALLOW_ACCENTED_CHARS_URL' => array('title' => $this->l('Accented URL'), 'desc' => $this->l('Enable if you want to allow accented characters in your friendly URLs.') . ' ' . $this->l('You should only activate this option if you are using non-latin characters ; for all the latin charsets, your SEO will be better without this option.'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'PS_CANONICAL_REDIRECT' => array('title' => $this->l('Automatically redirect to the canonical URL'), 'desc' => $this->l('Recommended, but your theme must be compliant.'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'));
$url_description = '';
if ($this->checkConfiguration($this->ht_file)) {
$general_fields['PS_HTACCESS_DISABLE_MULTIVIEWS'] = array('title' => $this->l('Disable apache multiviews'), 'desc' => $this->l('Enable this option only if you have problems with URL rewriting.'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool');
$general_fields['PS_HTACCESS_DISABLE_MODSEC'] = array('title' => $this->l('Disable apache mod security'), 'desc' => $this->l('Some features could not work correctly with a specific configuration of apache mod security. We recommend to turn it off.'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool');
} else {
$url_description = $this->l('Before being able to use this tool, you need to:');
$url_description .= '<br />- ' . $this->l('Create a blank .htaccess in your root directory.');
$url_description .= '<br />- ' . $this->l('Give it write permissions (CHMOD 666 on Unix system)');
}
// Options to generate robot.txt
$robots_description = $this->l('Your robots.txt file MUST be in your website\'s root directory and nowhere else (e.g. http://www.yoursite.com/robots.txt).');
if ($this->checkConfiguration($this->rb_file)) {
$robots_description .= '<br />' . $this->l('Generate your "robots.txt" file by clicking on the following button (this will erase the old robots.txt file)');
$robots_submit = array('name' => 'submitRobots', 'title' => $this->l('Generate robots.txt file'));
} else {
$robots_description .= '<br />' . $this->l('Before being able to use this tool, you need to:');
$robots_description .= '<br />- ' . $this->l('Create a blank robots.txt file in your root directory.');
$robots_description .= '<br />- ' . $this->l('Give it write permissions (CHMOD 666 on Unix system)');
}
$robots_options = array('title' => $this->l('Robots file generation'), 'description' => $robots_description);
if (isset($robots_submit)) {
$robots_options['submit'] = $robots_submit;
}
// Options for shop URL if multishop is disabled
$shop_url_options = array('title' => $this->l('Set shop URL'), 'fields' => array());
if (!Shop::isFeatureActive()) {
$this->url = ShopUrl::getShopUrls($this->context->shop->id)->where('main', '=', 1)->getFirst();
if ($this->url) {
$shop_url_options['description'] = $this->l('Here you can set the URL for your shop. If you migrate your shop to a new URL, remember to change the values below.');
$shop_url_options['fields'] = array('domain' => array('title' => $this->l('Shop domain'), 'validation' => 'isString', 'type' => 'text', 'size' => 70, 'defaultValue' => $this->url->domain), 'domain_ssl' => array('title' => $this->l('SSL domain'), 'validation' => 'isString', 'type' => 'text', 'size' => 70, 'defaultValue' => $this->url->domain_ssl), 'uri' => array('title' => $this->l('Base URI'), 'validation' => 'isString', 'type' => 'text', 'size' => 70, 'defaultValue' => $this->url->physical_uri));
}
} else {
$shop_url_options['description'] = $this->l('The multistore option is enabled. If you want to change the URL of your shop, you must go to the "Multistore" page under the "Advanced Parameters" menu.');
}
// List of options
$this->fields_options = array('general' => array('title' => $this->l('Set up URLs'), 'description' => $url_description, 'fields' => $general_fields, 'submit' => array()), 'shop_url' => $shop_url_options);
// Add display route options to options form
if (Configuration::get('PS_REWRITING_SETTINGS')) {
$this->fields_options['routes'] = array('title' => $this->l('Schema of URLs'), 'description' => $this->l('Change the pattern of your links. There are some available keywords for each route listed below, keywords with * are required. To add a keyword in your URL use {keyword} syntax. You can add text before or after the keyword if the keyword is not empty with syntax {prepend:keyword:append}. For example {-hey-:meta_title} will add "-hey-my-title" in the URL if the meta title is set. Friendly URL and rewriting Apache option must be activated on your web server to use this functionality.'), 'fields' => array());
$this->addAllRouteFields();
}
$this->fields_options['robots'] = $robots_options;
}
示例4: ajaxProcessInfoQuery
public function ajaxProcessInfoQuery()
{
$this->content_only = true;
$result = array('status' => false);
if (time() > (int) Configuration::get('PP_INFO_CHECK_TIME')) {
$protocol = Tools::getCurrentUrlProtocolPrefix();
$iso_lang = Context::getContext()->language->iso_code;
$iso_country = Context::getContext()->country->iso_code;
$stream_context = @stream_context_create(array('http' => array('method' => 'GET', 'timeout' => 3)));
$old_content = $this->getInfo();
$msg = $old_content === false ? 0 : $old_content[0];
$shop_url = ShopUrl::getShopUrls($this->context->shop->id)->where('main', '=', 1)->getFirst();
$shop = $shop_url ? $shop_url->getURL() : Tools::getShopDomain();
$date = Db::getInstance()->getValue('SELECT `date_add` FROM `' . _DB_PREFIX_ . 'configuration` WHERE `name` = \'PSM_ID_' . Tools::strtoupper($this->module->name) . '\'');
$psm_date = $date ? urlencode(date('Y-m-d H:i:s', strtotime($date))) : '';
$plugins_string = '';
$plugins = $this->module->plugins();
foreach ($plugins as $name => $api_version) {
if (Module::isInstalled($name)) {
$plugins_string .= '&' . $name . '=' . $this->moduleVersion($name);
}
}
$url = $protocol . 'store.psandmore.com/query/?key=' . $this->module->name . '&ver=' . $this->module->version . '&psm=' . PSM::getPSMId($this->module) . '&psm_date=' . $psm_date . $plugins_string . '&msg=' . $msg . '&iso_country=' . $iso_country . '&iso_lang=' . $iso_lang . '&shop=' . urlencode($shop);
$contents = Tools::file_get_contents($url, false, $stream_context);
$check_info_offset = 3600;
if ($contents !== false) {
$content = explode('|', $contents);
if (is_numeric($content[0])) {
if (!$this->infoIgnore(false, $content[0])) {
if (Validate::isCleanHtml($content[1])) {
$this->putInfo($contents);
$check_info_offset = 86400;
}
}
} else {
if ($content[0] == 'hide') {
Configuration::deleteByName('PP_INFO_CONTENT');
}
}
}
Configuration::updateValue('PP_INFO_CHECK_TIME', time() + $check_info_offset);
}
$content = $this->getInfo();
if ($content !== false) {
if (!$this->infoIgnore($content)) {
if (Validate::isCleanHtml($content[1])) {
$result['status'] = 'success';
$result['content'] = $content[1];
}
}
}
$this->content = Tools::jsonEncode($result);
}
示例5: processInstallDefaultData
/**
* PROCESS : installDefaultData
* Create default shop and languages
*/
public function processInstallDefaultData()
{
$this->initializeContext();
if (!($res = $this->model_install->installDefaultData($this->datas->shop_name, $this->datas->shop_country, (int) $this->datas->all_languages, true))) {
return false;
}
if ($this->datas->base_uri != '/') {
$shop_url = new ShopUrl(1);
$shop_url->physical_uri = $this->datas->base_uri;
$shop_url->save();
}
return $res;
}
示例6: validateOrder
public function validateOrder($id_cart, $id_order_state, $amount_paid, $payment_method = 'Unknown', $message = null, $extra_vars = array(), $currency_special = null, $dont_touch_amount = false, $secure_key = false, Shop $shop = null)
{
if (self::DEBUG_MODE) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Function called', 1, null, 'Cart', (int) $id_cart, true);
}
if (!isset($this->context)) {
$this->context = Context::getContext();
}
$this->context->cart = new Cart($id_cart);
$this->context->customer = new Customer($this->context->cart->id_customer);
// The tax cart is loaded before the customer so re-cache the tax calculation method
$this->context->cart->setTaxCalculationMethod();
$this->context->language = new Language($this->context->cart->id_lang);
$this->context->shop = $shop ? $shop : new Shop($this->context->cart->id_shop);
ShopUrl::resetMainDomainCache();
$id_currency = $currency_special ? (int) $currency_special : (int) $this->context->cart->id_currency;
$this->context->currency = new Currency($id_currency, null, $this->context->shop->id);
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
$context_country = $this->context->country;
}
$order_status = new OrderState((int) $id_order_state, (int) $this->context->language->id);
if (!Validate::isLoadedObject($order_status)) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status cannot be loaded', 3, null, 'Cart', (int) $id_cart, true);
throw new PrestaShopException('Can\'t load Order status');
}
if (!$this->active) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Module is not active', 3, null, 'Cart', (int) $id_cart, true);
die(Tools::displayError());
}
// Does order already exists ?
if (Validate::isLoadedObject($this->context->cart) && $this->context->cart->OrderExists() == false) {
if ($secure_key !== false && $secure_key != $this->context->cart->secure_key) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Secure key does not match', 3, null, 'Cart', (int) $id_cart, true);
die(Tools::displayError());
}
// For each package, generate an order
$delivery_option_list = $this->context->cart->getDeliveryOptionList();
$package_list = $this->context->cart->getPackageList();
$cart_delivery_option = $this->context->cart->getDeliveryOption();
// If some delivery options are not defined, or not valid, use the first valid option
foreach ($delivery_option_list as $id_address => $package) {
if (!isset($cart_delivery_option[$id_address]) || !array_key_exists($cart_delivery_option[$id_address], $package)) {
foreach ($package as $key => $val) {
$cart_delivery_option[$id_address] = $key;
break;
}
}
}
$order_list = array();
$order_detail_list = array();
do {
$reference = Order::generateReference();
} while (Order::getByReference($reference)->count());
$this->currentOrderReference = $reference;
$order_creation_failed = false;
$cart_total_paid = (double) Tools::ps_round((double) $this->context->cart->getOrderTotal(true, Cart::BOTH), 2);
foreach ($cart_delivery_option as $id_address => $key_carriers) {
foreach ($delivery_option_list[$id_address][$key_carriers]['carrier_list'] as $id_carrier => $data) {
foreach ($data['package_list'] as $id_package) {
// Rewrite the id_warehouse
$package_list[$id_address][$id_package]['id_warehouse'] = (int) $this->context->cart->getPackageIdWarehouse($package_list[$id_address][$id_package], (int) $id_carrier);
$package_list[$id_address][$id_package]['id_carrier'] = $id_carrier;
}
}
}
// Make sure CartRule caches are empty
CartRule::cleanCache();
$cart_rules = $this->context->cart->getCartRules();
foreach ($cart_rules as $cart_rule) {
if (($rule = new CartRule((int) $cart_rule['obj']->id)) && Validate::isLoadedObject($rule)) {
if ($error = $rule->checkValidity($this->context, true, true)) {
$this->context->cart->removeCartRule((int) $rule->id);
if (isset($this->context->cookie) && isset($this->context->cookie->id_customer) && $this->context->cookie->id_customer && !empty($rule->code)) {
if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1) {
Tools::redirect('index.php?controller=order-opc&submitAddDiscount=1&discount_name=' . urlencode($rule->code));
}
Tools::redirect('index.php?controller=order&submitAddDiscount=1&discount_name=' . urlencode($rule->code));
} else {
$rule_name = isset($rule->name[(int) $this->context->cart->id_lang]) ? $rule->name[(int) $this->context->cart->id_lang] : $rule->code;
$error = Tools::displayError(sprintf('CartRule ID %1s (%2s) used in this cart is not valid and has been withdrawn from cart', (int) $rule->id, $rule_name));
PrestaShopLogger::addLog($error, 3, '0000002', 'Cart', (int) $this->context->cart->id);
}
}
}
}
foreach ($package_list as $id_address => $packageByAddress) {
foreach ($packageByAddress as $id_package => $package) {
$order = new Order();
$order->product_list = $package['product_list'];
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
$address = new Address($id_address);
$this->context->country = new Country($address->id_country, $this->context->cart->id_lang);
if (!$this->context->country->active) {
throw new PrestaShopException('The delivery address country is not active.');
}
}
$carrier = null;
if (!$this->context->cart->isVirtualCart() && isset($package['id_carrier'])) {
$carrier = new Carrier($package['id_carrier'], $this->context->cart->id_lang);
$order->id_carrier = (int) $carrier->id;
//.........这里部分代码省略.........
示例7: _displayForm
//.........这里部分代码省略.........
$this->_html .= '</fieldset><div class="clear"></div><br />';
$this->_html .= '<fieldset>
<legend>' . $this->l('Comments settings') . '</legend>
<label>' . $this->l('All comments must be validated by an employee') . '</label>
<div class="margin-form">
<input type="checkbox" name="pref[comment_moderate]" value="1" ' . (isset($values['comment_moderate']) && $values['comment_moderate'] == '1' ? 'checked' : '') . '/>
</div>
<div class="clear"></div><br />
<label>' . $this->l('Allow guest comments') . '</label>
<div class="margin-form">
<input type="checkbox" name="pref[comment_guest]" value="1" ' . (isset($values['comment_guest']) && $values['comment_guest'] == '1' ? 'checked' : '') . '/>
</div>
<div class="clear"></div><br />
<label>' . $this->l('Minimum time between 2 comments from the same user') . '</label>
<div class="margin-form">
<input name="pref[comment_min_time]" type="text" class="text" value="' . $values['comment_min_time'] . '" style="width: 40px; text-align: right;" /> ' . $this->l('seconds') . '
</div>
<div class="clear"></div><br />
<label>' . $this->l('Minimum length of user name') . '</label>
<div class="margin-form">
<input name="pref[comment_name_min_length]" type="text" class="text" value="' . $values['comment_name_min_length'] . '" style="width: 40px; text-align: right;" /> ' . $this->l('characters') . '
</div>';
$this->_html .= '</fieldset>';
$this->_html .= '<div class="clear"></div><br />';
$this->_html .= '<fieldset>
<legend>' . $this->l('RSS settings') . '</legend>
<label>' . $this->l('Enable RSS feed') . '</label>
<div class="margin-form">
<input type="checkbox" name="pref[rss_active]" value="1" ' . (isset($values['rss_active']) && $values['rss_active'] == '1' ? 'checked' : '') . '/>
</div>
<div class="clear"></div><br />
<label>' . $this->l('Post field used for content') . '</label>
<div class="margin-form">
<select name="pref[rss_display]">
<option value="excerpt" ' . ($values['rss_display'] == "excerpt" ? "selected" : "") . '>' . $this->l('Excerpt') . ' </option>
<option value="content" ' . ($values['rss_display'] == "content" ? "selected" : "") . '>' . $this->l('Content') . ' </option>
</select>
</div>';
$this->_html .= '</fieldset><div class="clear"></div><br />';
$this->_html .= '<div class="clear"></div>
<input class="button" name="submitPsblog" value="' . $this->l('Update settings') . '" type="submit" />';
$this->_html .= '<div class="clear"></div><br /><br />';
$this->_html .= '<fieldset>
<legend>' . $this->l('Tools') . '</legend>
<p>
<input class="button" name="submitGenerateImg" value="' . $this->l('Regenerate all blog images') . '" type="submit" />
' . $this->l('Useful if you change the images sizes') . '
</p>';
if (self::isInstalled('gsitemap')) {
$this->_html .= '<p>
<input class="button" name="submitGenerateSitemap" value="' . $this->l('Regenerate Google sitemap') . '" type="submit" />
<a href="' . _PS_BASE_URL_ . __PS_BASE_URI__ . 'modules/psblog/sitemap-blog.xml" target="_blank">' . _PS_BASE_URL_ . __PS_BASE_URI__ . 'modules/psblog/sitemap-blog.xml</a> ' . '
</p>';
}
$this->_html .= '<div class="multishop_info">
<p>
' . $this->l('If url rewriting doesn\'t works, check that this above lines exist in your current .htaccess file, if no, add it manually on top of your .htaccess file') . ': <br /><br />
<strong>';
$physical_uri = array();
foreach (ShopUrl::getShopUrls() as $shop_url) {
if (in_array($shop_url->physical_uri, $physical_uri)) {
continue;
}
$this->_html .= "RewriteRule ^(.*)blog\$ " . $shop_url->physical_uri . "index.php?fc=module&module=psblog&controller=posts [QSA,L] <br />";
$this->_html .= "RewriteRule ^(.*)blog/([0-9]+)\\-([a-zA-Z0-9-]*) " . $shop_url->physical_uri . "index.php?fc=module&module=psblog&controller=posts&post=\$2 [QSA,L] <br />";
$this->_html .= "RewriteRule ^(.*)blog/category/([0-9]+)\\-([a-zA-Z0-9-]*) " . $shop_url->physical_uri . "index.php?fc=module&module=psblog&controller=posts&category=\$2 [QSA,L] <br />";
$physical_uri[] = $shop_url->physical_uri;
}
$this->_html .= '</strong>
</p>
</div>';
$this->_html .= '<div class="multishop_info">
<p>
' . $this->l('To declare blog sitemap xml, add this line at the end of your robots.txt file') . ': <br /><br />
<strong>
Sitemap ' . _PS_BASE_URL_ . __PS_BASE_URI__ . 'modules/psblog/sitemap-blog.xml
</strong>
</p>
</div>';
$this->_html .= '</fieldset>
</form>';
}
示例8:
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2015 PrestaShop SA
* @version Release: $Revision: 14390 $
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
// Workaround for redirection on init
$_POST['id_shop'] = 1;
require_once 'config/config.inc.php';
if (!defined('_PS_VERSION_')) {
exit;
}
// First, we get the URL used to reach this page.
$domain = Tools::getHttpHost();
$old_domain = Configuration::get('PS_SHOP_DOMAIN');
if (version_compare(_PS_VERSION_, '1.5', '>=') && $domain != $old_domain && !Shop::isFeatureActive()) {
$url = ShopUrl::getShopUrls(Configuration::get('PS_SHOP_DEFAULT'))->where('main', '=', 1)->getFirst();
if ($url) {
$url->domain = $domain;
$url->domain_ssl = $domain;
$url->save();
// Then, we update the configuration table
Configuration::updateValue('PS_SHOP_DOMAIN', $domain);
Configuration::updateValue('PS_SHOP_DOMAIN_SSL', $domain);
}
}
unlink(__FILE__);
Tools::redirect("index.php");
die;
示例9: getAgileSellerLink
public function getAgileSellerLink($id_seller, $alias = NULL, $id_lang = NULL)
{
if (!$id_seller) {
return '';
}
include_once _PS_ROOT_DIR_ . "/modules/agilemultipleseller/SellerInfo.php";
$sellerinfo = new SellerInfo(SellerInfo::getIdBSellerId($id_seller));
$id_shopurl = Shop::get_main_url_id($sellerinfo->id_shop);
$shopurl = new ShopUrl($id_shopurl);
$url = $shopurl->getURL() . $this->getLangLink();
if (Module::IsInstalled('agilemultipleshop')) {
include_once _PS_ROOT_DIR_ . "/modules/agilemultipleshop/agilemultipleshop.php";
if ((int) Configuration::get('ASP_SHOP_URL_MODE') == AgileMultipleShop::SHOP_URL_MODE_DOMAIN) {
return $url;
}
}
if ($this->allow) {
return $url;
} else {
return _PS_BASE_URL_SSL_ . __PS_BASE_URI__ . 'index.php?controller=agileseller&id_seller=' . (int) $id_seller;
}
}
示例10: Send
//.........这里部分代码省略.........
if ($override_mail && file_exists($template_path . $iso . '/lang.php')) {
include_once $template_path . $iso . '/lang.php';
} elseif ($module_name && file_exists($theme_path . 'mails/' . $iso . '/lang.php')) {
include_once $theme_path . 'mails/' . $iso . '/lang.php';
} elseif (file_exists(_PS_MAIL_DIR_ . $iso . '/lang.php')) {
include_once _PS_MAIL_DIR_ . $iso . '/lang.php';
} else {
Tools::dieOrLog(Tools::displayError('Error - The language file is missing for:') . ' ' . $iso, $die);
return false;
}
/* Create mail and attach differents parts */
$subject = '[' . Configuration::get('PS_SHOP_NAME', null, null, $id_shop) . '] ' . $subject;
$message->setSubject($subject);
$message->setCharset('utf-8');
/* Set Message-ID - getmypid() is blocked on some hosting */
$message->setId(Mail::generateId());
if (!($reply_to && Validate::isEmail($reply_to))) {
$reply_to = $from;
}
if (isset($reply_to) && $reply_to) {
$message->setReplyTo($reply_to);
}
$template_vars = array_map(array('Tools', 'htmlentitiesDecodeUTF8'), $template_vars);
$template_vars = array_map(array('Tools', 'stripslashes'), $template_vars);
if (Configuration::get('PS_LOGO_MAIL') !== false && file_exists(_PS_IMG_DIR_ . Configuration::get('PS_LOGO_MAIL', null, null, $id_shop))) {
$logo = _PS_IMG_DIR_ . Configuration::get('PS_LOGO_MAIL', null, null, $id_shop);
} else {
if (file_exists(_PS_IMG_DIR_ . Configuration::get('PS_LOGO', null, null, $id_shop))) {
$logo = _PS_IMG_DIR_ . Configuration::get('PS_LOGO', null, null, $id_shop);
} else {
$template_vars['{shop_logo}'] = '';
}
}
ShopUrl::cacheMainDomainForShop((int) $id_shop);
/* don't attach the logo as */
if (isset($logo)) {
$template_vars['{shop_logo}'] = $message->embed(Swift_Image::fromPath($logo));
}
if (Context::getContext()->link instanceof Link === false) {
Context::getContext()->link = new Link();
}
$template_vars['{shop_name}'] = Tools::safeOutput(Configuration::get('PS_SHOP_NAME', null, null, $id_shop));
$template_vars['{shop_url}'] = Context::getContext()->link->getPageLink('index', true, Context::getContext()->language->id, null, false, $id_shop);
$template_vars['{my_account_url}'] = Context::getContext()->link->getPageLink('my-account', true, Context::getContext()->language->id, null, false, $id_shop);
$template_vars['{guest_tracking_url}'] = Context::getContext()->link->getPageLink('guest-tracking', true, Context::getContext()->language->id, null, false, $id_shop);
$template_vars['{history_url}'] = Context::getContext()->link->getPageLink('history', true, Context::getContext()->language->id, null, false, $id_shop);
$template_vars['{color}'] = Tools::safeOutput(Configuration::get('PS_MAIL_COLOR', null, null, $id_shop));
// Get extra template_vars
$extra_template_vars = array();
Hook::exec('actionGetExtraMailTemplateVars', array('template' => $template, 'template_vars' => $template_vars, 'extra_template_vars' => &$extra_template_vars, 'id_lang' => (int) $id_lang), null, true);
$template_vars = array_merge($template_vars, $extra_template_vars);
$swift->registerPlugin(new Swift_Plugins_DecoratorPlugin(array($to_plugin => $template_vars)));
if ($configuration['PS_MAIL_TYPE'] == Mail::TYPE_BOTH || $configuration['PS_MAIL_TYPE'] == Mail::TYPE_TEXT) {
$message->addPart($template_txt, 'text/plain', 'utf-8');
}
if ($configuration['PS_MAIL_TYPE'] == Mail::TYPE_BOTH || $configuration['PS_MAIL_TYPE'] == Mail::TYPE_HTML) {
$message->addPart($template_html, 'text/html', 'utf-8');
}
if ($file_attachment && !empty($file_attachment)) {
// Multiple attachments?
if (!is_array(current($file_attachment))) {
$file_attachment = array($file_attachment);
}
foreach ($file_attachment as $attachment) {
if (isset($attachment['content']) && isset($attachment['name']) && isset($attachment['mime'])) {
$message->attach(Swift_Attachment::newInstance()->setFilename($attachment['name'])->setContentType($attachment['mime'])->setBody($attachment['content']));
示例11: execCapture
public function execCapture()
{
$context = Context::getContext();
$hipay = new HiPay_Tpp();
$hipay_redirect_status = 'ok';
// If id_order is sent, we instanciate a new Order object
if (Tools::isSubmit('id_order') && Tools::getValue('id_order') > 0) {
$order = new Order(Tools::getValue('id_order'));
if (!Validate::isLoadedObject($order)) {
throw new PrestaShopException('Can\'t load Order object');
}
if (version_compare(_PS_VERSION_, '1.5.6', '>')) {
ShopUrl::cacheMainDomainForShop((int) $order->id_shop);
}
if (Tools::isSubmit('id_emp') && Tools::getValue('id_emp') > 0) {
$id_employee = Tools::getValue('id_emp');
} else {
$id_employee = '1';
}
}
if (Tools::isSubmit('hipay_capture_type')) {
$refund_type = Tools::getValue('hipay_capture_type');
$refund_amount = Tools::getValue('hipay_capture_amount');
$refund_amount = str_replace(' ', '', $refund_amount);
$refund_amount = floatval(str_replace(',', '.', $refund_amount));
}
// First check
if (Tools::isSubmit('hipay_capture_submit') && $refund_type == 'partial') {
$hipay_redirect_status = false;
$hipay = new HiPay_Tpp();
$orderLoaded = new OrderCore(Tools::getValue('id_order'));
// v1.5 // $orderTotal = $orderLoaded->total_products_wt + $orderLoaded->total_shipping_tax_incl + $orderLoaded->total_wrapping_tax_incl;
$orderTotal = $orderLoaded->total_products_wt + $orderLoaded->total_shipping + $orderLoaded->total_wrapping;
$totalEncaissement = $hipay->getOrderTotalAmountCaptured($orderLoaded->id);
$stillToCapture = floatval($orderTotal - $totalEncaissement);
if (!$refund_amount) {
$hipay_redirect_status = $hipay->l('Please enter an amount', 'capture');
Tools::redirectAdmin('../../' . Tools::getValue('adminDir') . '/index.php?tab=AdminOrders' . '&id_order=' . (int) $order->id . '&vieworder&token=' . Tools::getValue('token') . '&hipay_err=' . $hipay_redirect_status . '#hipay');
die('');
}
if ($refund_amount < 0) {
$hipay_redirect_status = $hipay->l('Please enter an amount greater than zero', 'capture');
Tools::redirectAdmin('../../' . Tools::getValue('adminDir') . '/index.php?tab=AdminOrders' . '&id_order=' . (int) $order->id . '&vieworder&token=' . Tools::getValue('token') . '&hipay_err=' . $hipay_redirect_status . '#hipay');
die('');
}
if ($refund_amount > $stillToCapture) {
$hipay_redirect_status = $hipay->l('Amount exceeding authorized amount', 'capture');
Tools::redirectAdmin('../../' . Tools::getValue('adminDir') . '/index.php?tab=AdminOrders' . '&id_order=' . (int) $order->id . '&vieworder&token=' . Tools::getValue('token') . '&hipay_err=' . $hipay_redirect_status . '#hipay');
die('');
}
}
if (Tools::isSubmit('hipay_capture_submit') && isset($order)) {
$sql = "SELECT * FROM `" . _DB_PREFIX_ . "hipay_transactions` WHERE `cart_id`='" . (int) $order->id_cart . "'";
$result = Db::getInstance()->getRow($sql);
$reference = $result['transaction_reference'];
if ($refund_type == 'complete') {
// Appel HiPay
$data = HipayMaintenance::getMaintenanceData('capture', '0');
$response = HipayMaintenance::restMaintenanceApi($reference, $data);
// Ajout commentaire
$msg = new Message();
$message = 'HIPAY_CAPTURE_REQUESTED ' . $orderTotal;
$message = strip_tags($message, '<br>');
if (Validate::isCleanHtml($message)) {
$msg->message = $message;
$msg->id_order = intval($order->id);
$msg->private = 1;
$msg->add();
}
} else {
// 'partial';
// Appel HiPay
/**
* VERIFICATION
*/
// v1.5 // $orderTotal = $order->total_products_wt + $order->total_shipping_tax_incl + $order->total_wrapping_tax_incl;
$orderTotal = $order->total_products_wt + $order->total_shipping + $order->total_wrapping;
$totalEncaissement = $this->getOrderTotalAmountCaptured($order->id);
$stillToCapture = $orderTotal - $totalEncaissement;
$orderLoaded = new OrderCore(Tools::getValue('id_order'));
$currentState = $orderLoaded->getCurrentState();
$stateLoaded = new OrderState($currentState);
if (round($stillToCapture, 2) < round($refund_amount, 2)) {
$hipay_redirect_status = $hipay->l('Error, you are trying to capture more than the amount remaining', 'capture');
} else {
$data = HipayMaintenance::getMaintenanceData('capture', $refund_amount);
$response = HipayMaintenance::restMaintenanceApi($reference, $data);
// Ajout commentaire
$msg = new Message();
$message = 'HIPAY_CAPTURE_REQUESTED ' . $refund_amount;
$message = strip_tags($message, '<br>');
if (Validate::isCleanHtml($message)) {
$msg->message = $message;
$msg->id_order = intval($order->id);
$msg->private = 1;
$msg->add();
}
$hipay_redirect_status = 'ok';
}
}
//.........这里部分代码省略.........
示例12: postProcess
public function postProcess()
{
if (isset($_GET['dobirkaorder']) && Tools::getValue('id_order') > 0) {
return $this->processDobirka();
}
if (isset($_GET['exportedorder']) && Tools::getValue('id_order') > 0) {
return $this->processExported();
}
if (Tools::isSubmit('updateorder') && Tools::getValue('id_order')) {
$link = Context::getContext()->link->getAdminLink('AdminOrders');
$link .= '&id_order=' . Tools::getValue('id_order') . '&vieworder';
Tools::redirectAdmin($link);
}
// If id_order is sent, we instanciate a new Order object
if (Tools::isSubmit('id_order') && Tools::getValue('id_order') > 0) {
$order = new Order(Tools::getValue('id_order'));
if (!Validate::isLoadedObject($order)) {
throw new PrestaShopException('Can\'t load Order object');
}
ShopUrl::cacheMainDomainForShop((int) $order->id_shop);
}
parent::postProcess();
}
示例13: createShop
public function createShop($shop_name)
{
// Create default group shop
$shop_group = new ShopGroup();
$shop_group->name = 'Default';
$shop_group->active = true;
if (!$shop_group->add()) {
$this->setError($this->language->l('Cannot create group shop') . ' / ' . Db::getInstance()->getMsgError());
return false;
}
// Create default shop
$shop = new Shop();
$shop->active = true;
$shop->id_shop_group = $shop_group->id;
$shop->id_category = 2;
$shop->id_theme = 1;
$shop->name = $shop_name;
if (!$shop->add()) {
$this->setError($this->language->l('Cannot create shop') . ' / ' . Db::getInstance()->getMsgError());
return false;
}
Context::getContext()->shop = $shop;
// Create default shop URL
$shop_url = new ShopUrl();
$shop_url->domain = Tools::getHttpHost();
$shop_url->domain_ssl = Tools::getHttpHost();
$shop_url->physical_uri = __PS_BASE_URI__;
$shop_url->id_shop = $shop->id;
$shop_url->main = true;
$shop_url->active = true;
if (!$shop_url->add()) {
$this->setError($this->language->l('Cannot create shop URL') . ' / ' . Db::getInstance()->getMsgError());
return false;
}
return true;
}
示例14: Send
//.........这里部分代码省略.........
/* Get templates content */
$iso = Language::getIsoById((int) $id_lang);
if (!$iso) {
Tools::dieOrLog(Tools::displayError('Error - No ISO code for email'), $die);
return false;
}
$template = $iso . '/' . $template;
$module_name = false;
$override_mail = false;
// get templatePath
if (preg_match('#' . __PS_BASE_URI__ . 'modules/#', str_replace(DIRECTORY_SEPARATOR, '/', $template_path)) && preg_match('#modules/([a-z0-9_-]+)/#ui', str_replace(DIRECTORY_SEPARATOR, '/', $template_path), $res)) {
$module_name = $res[1];
}
if ($module_name !== false && (file_exists($theme_path . 'modules/' . $module_name . '/mails/' . $template . '.txt') || file_exists($theme_path . 'modules/' . $module_name . '/mails/' . $template . '.html'))) {
$template_path = $theme_path . 'modules/' . $module_name . '/mails/';
} elseif (file_exists($theme_path . 'mails/' . $template . '.txt') || file_exists($theme_path . 'mails/' . $template . '.html')) {
$template_path = $theme_path . 'mails/';
$override_mail = true;
}
if (!file_exists($template_path . $template . '.txt') && ($configuration['PS_MAIL_TYPE'] == Mail::TYPE_BOTH || $configuration['PS_MAIL_TYPE'] == Mail::TYPE_TEXT)) {
Tools::dieOrLog(Tools::displayError('Error - The following e-mail template is missing:') . ' ' . $template_path . $template . '.txt', $die);
return false;
} else {
if (!file_exists($template_path . $template . '.html') && ($configuration['PS_MAIL_TYPE'] == Mail::TYPE_BOTH || $configuration['PS_MAIL_TYPE'] == Mail::TYPE_HTML)) {
Tools::dieOrLog(Tools::displayError('Error - The following e-mail template is missing:') . ' ' . $template_path . $template . '.html', $die);
return false;
}
}
$template_html = file_get_contents($template_path . $template . '.html');
$template_txt = strip_tags(html_entity_decode(file_get_contents($template_path . $template . '.txt'), null, 'utf-8'));
if ($override_mail && file_exists($template_path . $iso . '/lang.php')) {
include_once $template_path . $iso . '/lang.php';
} else {
if ($module_name && file_exists($theme_path . 'mails/' . $iso . '/lang.php')) {
include_once $theme_path . 'mails/' . $iso . '/lang.php';
} else {
if (file_exists(_PS_MAIL_DIR_ . $iso . '/lang.php')) {
include_once _PS_MAIL_DIR_ . $iso . '/lang.php';
} else {
Tools::dieOrLog(Tools::displayError('Error - The lang file is missing for :') . ' ' . $iso, $die);
return false;
}
}
}
/* Create mail and attach differents parts */
$message = new Swift_Message('[' . Configuration::get('PS_SHOP_NAME', null, null, $id_shop) . '] ' . $subject);
$message->setCharset('utf-8');
/* Set Message-ID - getmypid() is blocked on some hosting */
$message->setId(Mail::generateId());
$message->headers->setEncoding('Q');
if (Configuration::get('PS_LOGO_MAIL') !== false && file_exists(_PS_IMG_DIR_ . Configuration::get('PS_LOGO_MAIL', null, null, $id_shop))) {
$logo = _PS_IMG_DIR_ . Configuration::get('PS_LOGO_MAIL', null, null, $id_shop);
} else {
if (file_exists(_PS_IMG_DIR_ . Configuration::get('PS_LOGO', null, null, $id_shop))) {
$logo = _PS_IMG_DIR_ . Configuration::get('PS_LOGO', null, null, $id_shop);
} else {
$template_vars['{shop_logo}'] = '';
}
}
ShopUrl::cacheMainDomainForShop((int) $id_shop);
/* don't attach the logo as */
if (isset($logo)) {
$template_vars['{shop_logo}'] = $message->attach(new Swift_Message_EmbeddedFile(new Swift_File($logo), null, ImageManager::getMimeTypeByExtension($logo)));
}
if (Context::getContext()->link instanceof Link === false) {
Context::getContext()->link = new Link();
}
$template_vars['{shop_name}'] = Tools::safeOutput(Configuration::get('PS_SHOP_NAME', null, null, $id_shop));
$template_vars['{shop_url}'] = Context::getContext()->link->getPageLink('index', true, Context::getContext()->language->id);
$template_vars['{my_account_url}'] = Context::getContext()->link->getPageLink('my-account', true, Context::getContext()->language->id);
$template_vars['{guest_tracking_url}'] = Context::getContext()->link->getPageLink('guest-tracking', true, Context::getContext()->language->id);
$template_vars['{history_url}'] = Context::getContext()->link->getPageLink('history', true, Context::getContext()->language->id);
$template_vars['{color}'] = Tools::safeOutput(Configuration::get('PS_MAIL_COLOR', null, null, $id_shop));
$swift->attachPlugin(new Swift_Plugin_Decorator(array($to_plugin => $template_vars)), 'decorator');
if ($configuration['PS_MAIL_TYPE'] == Mail::TYPE_BOTH || $configuration['PS_MAIL_TYPE'] == Mail::TYPE_TEXT) {
$message->attach(new Swift_Message_Part($template_txt, 'text/plain', '8bit', 'utf-8'));
}
if ($configuration['PS_MAIL_TYPE'] == Mail::TYPE_BOTH || $configuration['PS_MAIL_TYPE'] == Mail::TYPE_HTML) {
$message->attach(new Swift_Message_Part($template_html, 'text/html', '8bit', 'utf-8'));
}
if ($file_attachment && !empty($file_attachment)) {
// Multiple attachments?
if (!is_array(current($file_attachment))) {
$file_attachment = array($file_attachment);
}
foreach ($file_attachment as $attachment) {
if (isset($attachment['content']) && isset($attachment['name']) && isset($attachment['mime'])) {
$message->attach(new Swift_Message_Attachment($attachment['content'], $attachment['name'], $attachment['mime']));
}
}
}
/* Send mail */
$send = $swift->send($message, $to, new Swift_Address($from, $from_name));
$swift->disconnect();
ShopUrl::resetMainDomainCache();
return $send;
} catch (Swift_Exception $e) {
return false;
}
}
示例15: getPreviewUrl
public function getPreviewUrl(SmartBlogPost $smart_blog_post)
{
$id_lang = Configuration::get('PS_LANG_DEFAULT', null, null, Context::getContext()->shop->id);
if (!ShopUrl::getMainShopDomain()) {
return false;
}
$is_rewrite_active = (bool) Configuration::get('PS_REWRITING_SETTINGS');
$blog_url = $preview_url = smartblog::GetSmartBlogLink('smartblog_post', array('id_post' => $smart_blog_post->id, 'slug' => $smart_blog_post->link_rewrite[$id_lang]));
if (!$smart_blog_post->active) {
$admin_dir = dirname($_SERVER['PHP_SELF']);
$admin_dir = substr($admin_dir, strrpos($admin_dir, '/') + 1);
$preview_url .= (strpos($preview_url, '?') === false ? '?' : '&') . 'adtoken=' . $this->token . '&ad=' . $admin_dir . '&id_employee=' . (int) $this->context->employee->id;
}
return $preview_url;
}