本文整理汇总了PHP中ShopUrl::getShopUrls方法的典型用法代码示例。如果您正苦于以下问题:PHP ShopUrl::getShopUrls方法的具体用法?PHP ShopUrl::getShopUrls怎么用?PHP ShopUrl::getShopUrls使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShopUrl
的用法示例。
在下文中一共展示了ShopUrl::getShopUrls方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: generateHtaccess
public static function generateHtaccess($path = null, $rewrite_settings = null, $cache_control = null, $specific = '', $disable_multiviews = null, $medias = false, $disable_modsec = null)
{
if (defined('PS_INSTALLATION_IN_PROGRESS') && $rewrite_settings === null) {
return true;
}
// Default values for parameters
if (is_null($path)) {
$path = _PS_ROOT_DIR_ . '/.htaccess';
}
if (is_null($cache_control)) {
$cache_control = (int) Configuration::get('PS_HTACCESS_CACHE_CONTROL');
}
if (is_null($disable_multiviews)) {
$disable_multiviews = (int) Configuration::get('PS_HTACCESS_DISABLE_MULTIVIEWS');
}
if ($disable_modsec === null) {
$disable_modsec = (int) Configuration::get('PS_HTACCESS_DISABLE_MODSEC');
}
// Check current content of .htaccess and save all code outside of prestashop comments
$specific_before = $specific_after = '';
if (file_exists($path)) {
$content = file_get_contents($path);
if (preg_match('#^(.*)\\# ~~start~~.*\\# ~~end~~[^\\n]*(.*)$#s', $content, $m)) {
$specific_before = $m[1];
$specific_after = $m[2];
} else {
// For retrocompatibility
if (preg_match('#\\# http://www\\.prestashop\\.com - http://www\\.prestashop\\.com/forums\\s*(.*)<IfModule mod_rewrite\\.c>#si', $content, $m)) {
$specific_before = $m[1];
} else {
$specific_before = $content;
}
}
}
// Write .htaccess data
if (!($write_fd = fopen($path, 'w'))) {
return false;
}
if ($specific_before) {
fwrite($write_fd, trim($specific_before) . "\n\n");
}
$domains = array();
foreach (ShopUrl::getShopUrls() as $shop_url) {
if (!isset($domains[$shop_url->domain])) {
$domains[$shop_url->domain] = array();
}
$domains[$shop_url->domain][] = array('physical' => $shop_url->physical_uri, 'virtual' => $shop_url->virtual_uri, 'id_shop' => $shop_url->id_shop);
if ($shop_url->domain == $shop_url->domain_ssl) {
continue;
}
if (!isset($domains[$shop_url->domain_ssl])) {
$domains[$shop_url->domain_ssl] = array();
}
$domains[$shop_url->domain_ssl][] = array('physical' => $shop_url->physical_uri, 'virtual' => $shop_url->virtual_uri, 'id_shop' => $shop_url->id_shop);
}
// Write data in .htaccess file
fwrite($write_fd, "# ~~start~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again\n");
fwrite($write_fd, "# .htaccess automaticaly generated by PrestaShop e-commerce open-source solution\n");
fwrite($write_fd, "# http://www.prestashop.com - http://www.prestashop.com/forums\n\n");
if ($disable_modsec) {
fwrite($write_fd, "<IfModule mod_security.c>\nSecFilterEngine Off\nSecFilterScanPOST Off\n</IfModule>\n\n");
}
fwrite($write_fd, "<IfModule mod_headers.c>\n");
fwrite($write_fd, "Header set Access-Control-Allow-Origin: *\n");
fwrite($write_fd, 'Header set Access-Control-Allow-Headers: "cache-control"' . "\n");
fwrite($write_fd, "</IfModule>\n");
// RewriteEngine
fwrite($write_fd, "<IfModule mod_rewrite.c>\n");
// Ensure HTTP_MOD_REWRITE variable is set in environment
fwrite($write_fd, "<IfModule mod_env.c>\n");
fwrite($write_fd, "SetEnv HTTP_MOD_REWRITE On\n");
fwrite($write_fd, "</IfModule>\n\n");
// Disable multiviews ?
if ($disable_multiviews) {
fwrite($write_fd, "\n# Disable Multiviews\nOptions -Multiviews\n\n");
}
fwrite($write_fd, "RewriteEngine on\n\n");
fwrite($write_fd, "RewriteCond %{REQUEST_URI} ^/komplekty\$\n");
fwrite($write_fd, "RewriteRule ^.*\$ http://decor.etagerca.ru/complects/ [R=301,L]\n\n");
fwrite($write_fd, "RewriteRule ^klassicheskaja-mebel-provans\$ /style/klassicheskaja-mebel-provans [R=301,L]\n");
fwrite($write_fd, "RewriteRule ^dizajnerskaja-mebel/divany\$ /style/dizajnerskaja-mebel/divany [R=301,L]\n");
fwrite($write_fd, "RewriteRule ^dizajnerskaja-mebel/komody\$ /style/dizajnerskaja-mebel/komody [R=301,L]\n");
fwrite($write_fd, "RewriteRule ^dizajnerskaja-mebel/kresla\$ /style/dizajnerskaja-mebel/kresla [R=301,L]\n");
fwrite($write_fd, "RewriteRule ^dizajnerskaja-mebel/krovati\$ /style/dizajnerskaja-mebel/krovati [R=301,L]\n");
fwrite($write_fd, "RewriteRule ^dizajnerskaja-mebel/konsoli\$ /style/dizajnerskaja-mebel/konsoli [R=301,L]\n");
fwrite($write_fd, "RewriteRule ^dizajnerskaja-mebel/stoly\$ /style/dizajnerskaja-mebel/stoly [R=301,L]\n");
fwrite($write_fd, "RewriteRule ^dizajnerskaja-mebel/pufi\$ /style/dizajnerskaja-mebel/pufi [R=301,L]\n");
fwrite($write_fd, "RewriteRule ^dizajnerskaja-mebel/shkafy\$ /style/dizajnerskaja-mebel/shkafy [R=301,L]\n");
fwrite($write_fd, "RewriteRule ^dizajnerskaja-mebel/stulya\$ /style/dizajnerskaja-mebel/stulya [R=301,L]\n");
fwrite($write_fd, "RewriteRule ^klassicheskaja-mebel-provans/bufety\$ /style/klassicheskaja-mebel-provans/bufety [R=301,L]\n");
fwrite($write_fd, "RewriteRule ^klassicheskaja-mebel-provans/divany\$ /style/klassicheskaja-mebel-provans/divany [R=301,L]\n");
fwrite($write_fd, "RewriteRule ^klassicheskaja-mebel-provans/komody\$ /style/klassicheskaja-mebel-provans/komody [R=301,L]\n");
fwrite($write_fd, "RewriteRule ^klassicheskaja-mebel-provans/konsoli\$ /style/klassicheskaja-mebel-provans/konsoli [R=301,L]\n");
fwrite($write_fd, "RewriteRule ^klassicheskaja-mebel-provans/kresla\$ /style/klassicheskaja-mebel-provans/kresla [R=301,L]\n");
fwrite($write_fd, "RewriteRule ^klassicheskaja-mebel-provans/krovati\$ /style/klassicheskaja-mebel-provans/krovati [R=301,L]\n");
fwrite($write_fd, "RewriteRule ^klassicheskaja-mebel-provans/obedennye-stoly\$ /style/klassicheskaja-mebel-provans/obedennye-stoly [R=301,L]\n");
fwrite($write_fd, "RewriteRule ^klassicheskaja-mebel-provans/shkafy\$ /style/klassicheskaja-mebel-provans/shkafy [R=301,L]\n");
fwrite($write_fd, "RewriteRule ^klassicheskaja-mebel-provans/stoly\$ /style/klassicheskaja-mebel-provans/stoly [R=301,L]\n");
fwrite($write_fd, "RewriteRule ^klassicheskaja-mebel-provans/stulya\$ /style/klassicheskaja-mebel-provans/stulya [R=301,L]\n");
fwrite($write_fd, "RewriteRule ^klassicheskaja-mebel-provans/tumbochki\$ /style/klassicheskaja-mebel-provans/tumbochki [R=301,L]\n");
//.........这里部分代码省略.........
示例6: generateHtaccess
public static function generateHtaccess($path = null, $rewrite_settings = null, $cache_control = null, $specific = '', $disable_multiviews = null, $medias = false, $disable_modsec = null)
{
if (defined('PS_INSTALLATION_IN_PROGRESS') && $rewrite_settings === null) {
return true;
}
// Default values for parameters
if (is_null($path)) {
$path = _PS_ROOT_DIR_ . '/.htaccess';
}
if (is_null($cache_control)) {
$cache_control = (int) Configuration::get('PS_HTACCESS_CACHE_CONTROL');
}
if (is_null($disable_multiviews)) {
$disable_multiviews = (int) Configuration::get('PS_HTACCESS_DISABLE_MULTIVIEWS');
}
if ($disable_modsec === null) {
$disable_modsec = (int) Configuration::get('PS_HTACCESS_DISABLE_MODSEC');
}
// Check current content of .htaccess and save all code outside of prestashop comments
$specific_before = $specific_after = '';
if (file_exists($path)) {
$content = file_get_contents($path);
if (preg_match('#^(.*)\\# ~~start~~.*\\# ~~end~~[^\\n]*(.*)$#s', $content, $m)) {
$specific_before = $m[1];
$specific_after = $m[2];
} else {
// For retrocompatibility
if (preg_match('#\\# http://www\\.prestashop\\.com - http://www\\.prestashop\\.com/forums\\s*(.*)<IfModule mod_rewrite\\.c>#si', $content, $m)) {
$specific_before = $m[1];
} else {
$specific_before = $content;
}
}
}
// Write .htaccess data
if (!($write_fd = @fopen($path, 'w'))) {
return false;
}
if ($specific_before) {
fwrite($write_fd, trim($specific_before) . "\n\n");
}
$domains = array();
foreach (ShopUrl::getShopUrls() as $shop_url) {
if (!isset($domains[$shop_url->domain])) {
$domains[$shop_url->domain] = array();
}
$domains[$shop_url->domain][] = array('physical' => $shop_url->physical_uri, 'virtual' => $shop_url->virtual_uri, 'id_shop' => $shop_url->id_shop);
if ($shop_url->domain == $shop_url->domain_ssl) {
continue;
}
if (!isset($domains[$shop_url->domain_ssl])) {
$domains[$shop_url->domain_ssl] = array();
}
$domains[$shop_url->domain_ssl][] = array('physical' => $shop_url->physical_uri, 'virtual' => $shop_url->virtual_uri, 'id_shop' => $shop_url->id_shop);
}
// Write data in .htaccess file
fwrite($write_fd, "# ~~start~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again\n");
fwrite($write_fd, "# .htaccess automaticaly generated by PrestaShop e-commerce open-source solution\n");
fwrite($write_fd, "# http://www.prestashop.com - http://www.prestashop.com/forums\n\n");
if ($disable_modsec) {
fwrite($write_fd, "<IfModule mod_security.c>\nSecFilterEngine Off\nSecFilterScanPOST Off\n</IfModule>\n\n");
}
// RewriteEngine
fwrite($write_fd, "<IfModule mod_rewrite.c>\n");
// Ensure HTTP_MOD_REWRITE variable is set in environment
fwrite($write_fd, "<IfModule mod_env.c>\n");
fwrite($write_fd, "SetEnv HTTP_MOD_REWRITE On\n");
fwrite($write_fd, "</IfModule>\n\n");
// Disable multiviews ?
if ($disable_multiviews) {
fwrite($write_fd, "\n# Disable Multiviews\nOptions -Multiviews\n\n");
}
fwrite($write_fd, "RewriteEngine on\n");
if (!$medias && defined('_MEDIA_SERVER_1_') && defined('_MEDIA_SERVER_2_') && defined('_MEDIA_SERVER_3_')) {
$medias = array(_MEDIA_SERVER_1_, _MEDIA_SERVER_2_, _MEDIA_SERVER_3_);
}
$media_domains = '';
if ($medias[0] != '') {
$media_domains = 'RewriteCond %{HTTP_HOST} ^' . $medias[0] . '$ [OR]' . "\n";
}
if ($medias[1] != '') {
$media_domains .= 'RewriteCond %{HTTP_HOST} ^' . $medias[1] . '$ [OR]' . "\n";
}
if ($medias[2] != '') {
$media_domains .= 'RewriteCond %{HTTP_HOST} ^' . $medias[2] . '$ [OR]' . "\n";
}
if (Configuration::get('PS_WEBSERVICE_CGI_HOST')) {
fwrite($write_fd, "RewriteCond %{HTTP:Authorization} ^(.*)\nRewriteRule . - [E=HTTP_AUTHORIZATION:%1]\n\n");
}
foreach ($domains as $domain => $list_uri) {
$physicals = array();
foreach ($list_uri as $uri) {
fwrite($write_fd, PHP_EOL . PHP_EOL . '#Domain: ' . $domain . PHP_EOL);
if (Shop::isFeatureActive()) {
fwrite($write_fd, 'RewriteCond %{HTTP_HOST} ^' . $domain . '$' . "\n");
}
fwrite($write_fd, 'RewriteRule . - [E=REWRITEBASE:' . $uri['physical'] . ']' . "\n");
// Webservice
fwrite($write_fd, 'RewriteRule ^api$ api/ [L]' . "\n\n");
fwrite($write_fd, 'RewriteRule ^api/(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]' . "\n\n");
//.........这里部分代码省略.........
示例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: __construct
public function __construct()
{
$this->table = 'meta';
$this->className = 'Meta';
$this->bootstrap = true;
$this->identifier_name = 'page';
$this->ht_file = _PS_ROOT_DIR_ . '/.htaccess';
$this->rb_file = _PS_ROOT_DIR_ . '/robots.txt';
$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?'), 'icon' => 'icon-trash'));
$this->fields_list = array('id_meta' => array('title' => $this->l('ID'), 'align' => 'center', 'class' => 'fixed-width-xs'), 'page' => array('title' => $this->l('Page')), 'title' => array('title' => $this->l('Page title')), 'url_rewrite' => array('title' => $this->l('Friendly URL')));
$this->_where = ' AND a.configurable = 1';
$this->_group = 'GROUP BY a.id_meta';
parent::__construct();
$this->sm_file = _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . $this->context->shop->id . '_index_sitemap.xml';
// Options to generate friendly urls
$mod_rewrite = Tools::modRewriteActive();
$general_fields = array('PS_REWRITING_SETTINGS' => array('title' => $this->l('Friendly URL'), 'hint' => $mod_rewrite ? $this->l('Enable this option only if your server allows URL rewriting (recommended).') : '', 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'desc' => !$mod_rewrite ? $this->l('URL rewriting (mod_rewrite) is not active on your server, or it is not possible to check your server configuration. If you want to use Friendly URLs, you must activate this mod.') : ''), 'PS_ALLOW_ACCENTED_CHARS_URL' => array('title' => $this->l('Accented URL'), 'hint' => $this->l('Enable this option 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('Redirect to the canonical URL'), 'validation' => 'isUnsignedInt', 'cast' => 'intval', 'type' => 'select', 'list' => array(array('value' => 0, 'name' => $this->l('No redirection (you may have duplicate content issues)')), array('value' => 1, 'name' => $this->l('302 Moved Temporarily (recommended while setting up your store)')), array('value' => 2, 'name' => $this->l('301 Moved Permanently (recommended once you have gone live)'))), 'identifier' => 'value'));
$url_description = '';
if (!defined('_PS_HOST_MODE_')) {
if ($this->checkConfiguration($this->ht_file)) {
$general_fields['PS_HTACCESS_DISABLE_MULTIVIEWS'] = array('title' => $this->l('Disable Apache\'s MultiViews option'), 'hint' => $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\'s mod_security module'), 'hint' => $this->l('Some of PrestaShop\'s features might not work correctly with a specific configuration of Apache\'s mod_security module. We recommend to turn it off.'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool');
} else {
$url_description = $this->l('Before you can use this tool, you need to:');
$url_description .= $this->l('1) Create a blank .htaccess file in your root directory.');
$url_description .= $this->l('2) 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.example.com/robots.txt).');
if ($this->checkConfiguration($this->rb_file)) {
$robots_description .= $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 .= $this->l('Before you can use this tool, you need to:');
$robots_description .= $this->l('1) Create a blank robots.txt file in your root directory.');
$robots_description .= $this->l('2) 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;
}
if (!defined('_PS_HOST_MODE_')) {
// 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', 'defaultValue' => $this->url->domain), 'domain_ssl' => array('title' => $this->l('SSL domain'), 'validation' => 'isString', 'type' => 'text', 'defaultValue' => $this->url->domain_ssl), 'uri' => array('title' => $this->l('Base URI'), 'validation' => 'isString', 'type' => 'text', 'defaultValue' => $this->url->physical_uri));
$shop_url_options['submit'] = array('title' => $this->l('Save'));
}
} 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('title' => $this->l('Save'))));
if (!defined('_PS_HOST_MODE_')) {
$this->fields_options['shop_url'] = $shop_url_options;
} else {
$this->fields_options['manage_domain_name'] = array('title' => $this->l('Manage domain name'), 'description' => $this->l('You can search for a new domain name or add a domain name that you already own. You will be redirected to your PrestaShop account.'), 'buttons' => array(array('title' => $this->l('Add a domain name'), 'href' => 'https://www.prestashop.com/cloud/', 'class' => 'pull-right', 'icon' => 'process-icon-new', 'js' => 'return !window.open(this.href);')));
}
// Add display route options to options form
if (Configuration::get('PS_REWRITING_SETTINGS') || Tools::getValue('PS_REWRITING_SETTINGS')) {
if (Configuration::get('PS_REWRITING_SETTINGS')) {
$this->addAllRouteFields();
}
$this->fields_options['routes']['title'] = $this->l('Schema of URLs');
$this->fields_options['routes']['description'] = $this->l('This section enables you to change the default pattern of your links. In order to use this functionality, PrestaShop\'s "Friendly URL" option must be enabled, and Apache\'s URL rewriting module (mod_rewrite) must be activated on your web server.') . '<br />' . $this->l('There are several available keywords for each route listed below; note that keywords with * are required!') . '<br />' . $this->l('To add a keyword in your URL, use the {keyword} syntax. If the keyword is not empty, you can add text before or after the keyword with syntax {prepend:keyword:append}. For example {-hey-:meta_title} will add "-hey-my-title" in the URL if the meta title is set.');
$this->fields_options['routes']['submit'] = array('title' => $this->l('Save'));
}
$this->fields_options['robots'] = $robots_options;
}
示例9: generateHtaccess
public static function generateHtaccess($path = null, $rewrite_settings = null, $cache_control = null, $specific = '', $disable_multiviews = null, $medias = false)
{
if (defined('PS_INSTALLATION_IN_PROGRESS')) {
return true;
}
// Default values for parameters
if (is_null($path)) {
$path = _PS_ROOT_DIR_ . '/.htaccess';
}
if (is_null($cache_control)) {
$cache_control = (int) Configuration::get('PS_HTACCESS_CACHE_CONTROL');
}
if (is_null($disable_multiviews)) {
$disable_multiviews = (int) Configuration::get('PS_HTACCESS_DISABLE_MULTIVIEWS');
}
// Check current content of .htaccess and save all code outside of prestashop comments
$specific_before = $specific_after = '';
if (file_exists($path)) {
$content = file_get_contents($path);
if (preg_match('#^(.*)\\# ~~start~~.*\\# ~~end~~[^\\n]*(.*)$#s', $content, $m)) {
$specific_before = $m[1];
$specific_after = $m[2];
} else {
// For retrocompatibility
if (preg_match('#\\# http://www\\.prestashop\\.com - http://www\\.prestashop\\.com/forums\\s*(.*)<IfModule mod_rewrite\\.c>#si', $content, $m)) {
$specific_before = $m[1];
} else {
$specific_before = $content;
}
}
}
// Write .htaccess data
if (!($write_fd = @fopen($path, 'w'))) {
return false;
}
fwrite($write_fd, trim($specific_before) . "\n\n");
$domains = array();
foreach (ShopUrl::getShopUrls() as $shop_url) {
if (!isset($domains[$shop_url->domain])) {
$domains[$shop_url->domain] = array();
}
$domains[$shop_url->domain][] = array('physical' => $shop_url->physical_uri, 'virtual' => $shop_url->virtual_uri, 'id_shop' => $shop_url->id_shop);
}
// Write data in .htaccess file
fwrite($write_fd, "# ~~start~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again\n");
fwrite($write_fd, "# .htaccess automaticaly generated by PrestaShop e-commerce open-source solution\n");
fwrite($write_fd, "# http://www.prestashop.com - http://www.prestashop.com/forums\n\n");
// RewriteEngine
fwrite($write_fd, "<IfModule mod_rewrite.c>\n");
// Disable multiviews ?
if ($disable_multiviews) {
fwrite($write_fd, "\n# Disable Multiviews\nOptions -Multiviews\n\n");
}
fwrite($write_fd, "RewriteEngine on\n");
if (!$medias) {
$medias = array(_MEDIA_SERVER_1_, _MEDIA_SERVER_2_, _MEDIA_SERVER_3_);
}
$media_domains = '';
if ($medias[0] != '') {
$media_domains = 'RewriteCond %{HTTP_HOST} ^' . $medias[0] . '$ [OR]' . "\n";
}
if ($medias[1] != '') {
$media_domains .= 'RewriteCond %{HTTP_HOST} ^' . $medias[1] . '$ [OR]' . "\n";
}
if ($medias[2] != '') {
$media_domains .= 'RewriteCond %{HTTP_HOST} ^' . $medias[2] . '$ [OR]' . "\n";
}
if (Configuration::get('PS_WEBSERVICE_CGI_HOST')) {
fwrite($write_fd, "RewriteCond %{HTTP:Authorization} ^(.*)\nRewriteRule . - [E=HTTP_AUTHORIZATION:%1]\n\n");
}
foreach ($domains as $domain => $list_uri) {
$physicals = array();
foreach ($list_uri as $uri) {
fwrite($write_fd, 'RewriteCond %{HTTP_HOST} ^' . $domain . '$' . "\n");
fwrite($write_fd, 'RewriteRule . - [E=REWRITEBASE:' . $uri['physical'] . ']' . "\n");
// Webservice
fwrite($write_fd, 'RewriteRule ^api/?(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]' . "\n\n");
$rewrite_settings = (int) Configuration::get('PS_REWRITING_SETTINGS', null, null, (int) $uri['id_shop']);
$domain_rewrite_cond = 'RewriteCond %{HTTP_HOST} ^' . $domain . '$' . "\n";
// Rewrite virtual multishop uri
if ($uri['virtual']) {
if (!$rewrite_settings) {
fwrite($write_fd, $media_domains);
fwrite($write_fd, $domain_rewrite_cond);
fwrite($write_fd, 'RewriteRule ^' . trim($uri['virtual'], '/') . '/?$ ' . $uri['physical'] . $uri['virtual'] . "index.php [L,R]\n");
} else {
fwrite($write_fd, $media_domains);
fwrite($write_fd, $domain_rewrite_cond);
fwrite($write_fd, 'RewriteRule ^' . trim($uri['virtual'], '/') . '$ ' . $uri['physical'] . $uri['virtual'] . " [L,R]\n");
}
fwrite($write_fd, $media_domains);
fwrite($write_fd, $domain_rewrite_cond);
fwrite($write_fd, 'RewriteRule ^' . ltrim($uri['virtual'], '/') . '(.*) ' . $uri['physical'] . "\$1 [L]\n\n");
}
if ($rewrite_settings) {
// Compatibility with the old image filesystem
fwrite($write_fd, "# Images\n");
if (Configuration::get('PS_LEGACY_IMAGES')) {
fwrite($write_fd, $media_domains);
fwrite($write_fd, $domain_rewrite_cond);
//.........这里部分代码省略.........
示例10:
* 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;
示例11: update_base_uri
public static function update_base_uri($uri)
{
$context = Context::getContext();
$url = ShopUrl::getShopUrls($context->shop->id)->where('main', '=', 1)->getFirst();
if ($url->physical_uri == $uri) {
echo "Base uri is already {$uri}\n";
return true;
}
$url->physical_uri = $uri;
if ($url->update()) {
echo "Successfully updated base URI\n";
return true;
} else {
echo "Error, could not update base URI\n";
return false;
}
}