[*] BO : now you can't activate friendly URL when mod_rewrite is not active

This commit is contained in:
vAugagneur
2012-02-29 08:13:09 +00:00
parent e462d968f0
commit 320e44d464
6 changed files with 66 additions and 7 deletions
@@ -27,10 +27,10 @@
{block name="defaultOptions"}
<form action="{$current}&amp;token={$token}" method="post" enctype="multipart/form-data">
<fieldset><legend><img src="../img/admin/htaccess.gif" alt="" />{l s='Htaccess file generation'}</legend>
<p>
<div class="warn">
<b>{l s='Warning:'}</b>
{l s='this tool can ONLY be used if you are hosted by an Apache web server. Please ask your webhost.'}
</p>
</div>
<p>
{l s='This tool will automatically generate a ".htaccess" file that will give you the ability to do URL rewriting and to catch 404 errors.'}
</p>
@@ -44,8 +44,16 @@
<div class="clear">&nbsp;</div>
<label for="imageCacheControl">{l s='Friendly URL'}</label>
<div class="margin-form">
<input type="checkbox" name="PS_REWRITING_SETTINGS" id="PS_REWRITING_SETTINGS" value="1" {if $ps_rewriting_settings}checked="checked"{/if} />
<p>{l s='Enable only if your server allows URL rewriting.'}</p>
{if $mod_rewrite}
<input type="checkbox" name="PS_REWRITING_SETTINGS" id="PS_REWRITING_SETTINGS" value="1" {if $ps_rewriting_settings}checked="checked"{/if} />
<p>{l s='Enable only if your server allows URL rewriting.'}</p>
{else}
<span class="warning_mod_rewrite" style="display:block;height:15px">
{l s='URL rewriting (mod_rewrite) is not active on your server. If you want to use Friendly URL you have to active this mod.'}
</span>
<div class="clear"></div>
{/if}
</div>
<div class="clear">&nbsp;</div>
<label for="imageCacheControl">{l s='Disable apache multiviews'}</label>
@@ -0,0 +1,43 @@
{*
* 2007-2012 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @version Release: $Revision: 13686 $
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
{extends file="helpers/options/options.tpl"}
{block name="start_field_block"}
<div class="margin-form">
{if $field['type'] == 'rewriting_settings'}
{if $field['mod_rewrite']}
<label class="t" for="{$key}_on"><img src="../img/admin/enabled.gif" alt="{l s='Yes'}" title="{l s='Yes'}" /></label>
<input type="radio" name="{$key}" id="{$key}_on" value="1" {if $field['value']} checked="checked"{/if}{if isset($field['js']['on'])} {$field['js']['on']}{/if}/>
<label class="t" for="{$key}_on"> {l s='Yes'}</label>
<label class="t" for="{$key}_off"><img src="../img/admin/disabled.gif" alt="{l s='No'}" title="{l s='No'}" style="margin-left: 10px;" /></label>
<input type="radio" name="{$key}" id="{$key}_off" value="0" {if !$field['value']} checked="checked"{/if}{if isset($field['js']['off'])} {$field['js']['off']}{/if}/>
<label class="t" for="{$key}_off"> {l s='No'}</label>
{else}
<span class="warning_mod_rewrite" style="display:block;height:15px">{l s='URL rewriting (mod_rewrite) is not active on your server. If you want to use Friendly URL you have to active this mod.'}</span>
<div class="clear"></div>
{/if}
{/if}
{/block}
+5
View File
@@ -2221,6 +2221,11 @@ FileETag INode MTime Size
for ($len; $len > 0; $len--)
$str .= '.0';
}
public static function modRewriteActive()
{
return (in_array('mod_rewrite', apache_get_modules()) ? true : false);
}
}
/**
@@ -45,6 +45,7 @@ class AdminGeneratorControllerCore extends AdminController
$this->tpl_option_vars['checkConfiguration_rb'] = $this->checkConfiguration($this->rb_file);
$this->tpl_option_vars['ps_htaccess_cache_control'] = Configuration::get('PS_HTACCESS_CACHE_CONTROL');
$this->tpl_option_vars['ps_rewriting_settings'] = Configuration::get('PS_REWRITING_SETTINGS');
$this->tpl_option_vars['mod_rewrite'] = Tools::modRewriteActive();
$this->tpl_option_vars['ps_htaccess_disable_multiviews'] = Configuration::get('PS_HTACCESS_DISABLE_MULTIVIEWS');
parent::initContent();
+4 -2
View File
@@ -48,16 +48,18 @@ class AdminMetaControllerCore extends AdminController
);
$this->_group = 'GROUP BY a.id_meta';
$mod_rewrite = Tools::modRewriteActive();
$this->options = array(
'general' => array(
'title' => $this->l('URLs Setup'),
'fields' => array(
'PS_REWRITING_SETTINGS' => array(
'title' => $this->l('Friendly URL'),
'desc' => $this->l('Enable only if your server allows URL rewriting (recommended)'),
'desc' => ($mod_rewrite ? $this->l('Enable only if your server allows URL rewriting (recommended)') : ''),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool'
'type' => 'rewriting_settings',
'mod_rewrite' => $mod_rewrite
),
'PS_CANONICAL_REDIRECT' => array(
'title' => $this->l('Automatically redirect to Canonical url'),
+1 -1
View File
@@ -1822,7 +1822,7 @@ p.preference_description .light-warning {
font-style: italic;
}
.multishop_warning{
.multishop_warning, .warning_mod_rewrite{
background-image: url("../img/admin/warning.gif");
background-repeat: no-repeat;
color: #FE2744;