Allow hotel friendly url to be changed
This commit is contained in:
@@ -606,7 +606,7 @@ class HotelBranchInformation extends ObjectModel
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function addCategory($name, $parent_cat = false, $group_ids, $ishotel = false, $idHotel = false)
|
||||
public function addCategory($name, $parent_cat = false, $group_ids, $ishotel = false, $idHotel = false, $link_rewrite = false)
|
||||
{
|
||||
$context = Context::getContext();
|
||||
if (!$parent_cat) {
|
||||
@@ -622,6 +622,15 @@ class HotelBranchInformation extends ObjectModel
|
||||
$catName,
|
||||
$parent_cat
|
||||
)) {
|
||||
if (is_array($link_rewrite)) {
|
||||
$objCategory = new Category($categoryExists['id_category']);
|
||||
|
||||
foreach (Language::getLanguages() as $lang) {
|
||||
$objCategory->link_rewrite[$lang['id_lang']] = $link_rewrite[$lang['id_lang']];
|
||||
}
|
||||
|
||||
$objCategory->save();
|
||||
}
|
||||
return $categoryExists['id_category'];
|
||||
} else {
|
||||
$category = new Category();
|
||||
@@ -635,7 +644,12 @@ class HotelBranchInformation extends ObjectModel
|
||||
$category->description[$lang['id_lang']] = $this->moduleInstance->l(
|
||||
'Hotel Branch Category', 'HotelBranchInformation'
|
||||
);
|
||||
$category->link_rewrite[$lang['id_lang']] = Tools::link_rewrite($catName);
|
||||
|
||||
if (is_array($link_rewrite)) {
|
||||
$category->link_rewrite[$lang['id_lang']] = $link_rewrite[$lang['id_lang']];
|
||||
} else {
|
||||
$category->link_rewrite[$lang['id_lang']] = Tools::link_rewrite($catName);
|
||||
}
|
||||
}
|
||||
$category->id_parent = $parent_cat;
|
||||
$category->groupBox = $group_ids;
|
||||
|
||||
@@ -112,7 +112,7 @@ class AdminAddHotelController extends ModuleAdminController
|
||||
$smartyVars['lang'] = true;
|
||||
$smartyVars['iso'] = $this->context->language->iso_code;
|
||||
//lang vars
|
||||
$currentLangId = Configuration::get('PS_LANG_DEFAULT');
|
||||
$currentLangId = $this->default_form_language ? $this->default_form_language : Configuration::get('PS_LANG_DEFAULT');
|
||||
$smartyVars['languages'] = Language::getLanguages(false);
|
||||
$smartyVars['currentLang'] = Language::getLanguage((int) $currentLangId);
|
||||
|
||||
@@ -128,6 +128,7 @@ class AdminAddHotelController extends ModuleAdminController
|
||||
if ($this->display == 'edit') {
|
||||
$idHotel = Tools::getValue('id');
|
||||
$hotelBranchInfo = new HotelBranchInformation($idHotel);
|
||||
$objCategory = new Category($hotelBranchInfo->id_category);
|
||||
|
||||
$addressInfo = HotelBranchInformation::getAddress($idHotel);
|
||||
$idCountry = Tools::getValue('hotel_country', $addressInfo['id_country']);
|
||||
@@ -135,6 +136,7 @@ class AdminAddHotelController extends ModuleAdminController
|
||||
$smartyVars['edit'] = 1;
|
||||
$smartyVars['address_info'] = $addressInfo;
|
||||
$smartyVars['hotel_info'] = (array) $hotelBranchInfo;
|
||||
$smartyVars['link_rewrite_info'] = $objCategory->link_rewrite;
|
||||
//Hotel Images
|
||||
$objHotelImage = new HotelImage();
|
||||
if ($hotelAllImages = $objHotelImage->getImagesByHotelId($idHotel)) {
|
||||
@@ -187,6 +189,7 @@ class AdminAddHotelController extends ModuleAdminController
|
||||
Media::addJsDef(
|
||||
array(
|
||||
'img_dir_l' => _PS_IMG_.'l/',
|
||||
'PS_ALLOW_ACCENTED_CHARS_URL' => (int) Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL'),
|
||||
)
|
||||
);
|
||||
$this->fields_form = array(
|
||||
@@ -253,6 +256,21 @@ class AdminAddHotelController extends ModuleAdminController
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// validate Friendly URL values
|
||||
if (!trim(Tools::getValue('link_rewrite_'.$defaultLangId))) {
|
||||
$this->errors[] = $this->l('Friendly URL is required at least in ').
|
||||
$objDefaultLanguage['name'];
|
||||
} else {
|
||||
foreach ($languages as $lang) {
|
||||
if (trim(Tools::getValue('link_rewrite_'.$lang['id_lang']))) {
|
||||
if (!Validate::isLinkRewrite(Tools::getValue('link_rewrite_'.$lang['id_lang']))) {
|
||||
$this->errors[] = $this->l('Invalid Friendly URL in ').$lang['name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$phone) {
|
||||
$this->errors[] = $this->l('Phone number is required field.');
|
||||
} elseif (!Validate::isPhoneNumber($phone)) {
|
||||
@@ -357,6 +375,7 @@ class AdminAddHotelController extends ModuleAdminController
|
||||
|
||||
// lang fields
|
||||
$hotelCatName = array();
|
||||
$linkRewiteArray = array();
|
||||
foreach ($languages as $lang) {
|
||||
if (!trim(Tools::getValue('hotel_name_'.$lang['id_lang']))) {
|
||||
$objHotelBranch->hotel_name[$lang['id_lang']] = Tools::getValue(
|
||||
@@ -368,6 +387,16 @@ class AdminAddHotelController extends ModuleAdminController
|
||||
);
|
||||
}
|
||||
|
||||
if (!trim(Tools::getValue('link_rewrite_'.$lang['id_lang']))) {
|
||||
$linkRewiteArray[$lang['id_lang']] = Tools::getValue(
|
||||
'link_rewrite_'.$defaultLangId
|
||||
);
|
||||
} else {
|
||||
$linkRewiteArray[$lang['id_lang']] = Tools::getValue(
|
||||
'link_rewrite_'.$lang['id_lang']
|
||||
);
|
||||
}
|
||||
|
||||
$cleanShortDescription = Tools::getDescriptionClean(
|
||||
Tools::getValue('short_description_'.$lang['id_lang'])
|
||||
);
|
||||
@@ -502,7 +531,7 @@ class AdminAddHotelController extends ModuleAdminController
|
||||
if ($catCity = $objHotelBranch->addCategory($city, $catState, $groupIds)) {
|
||||
$hotelCatName = $objHotelBranch->hotel_name;
|
||||
if ($catHotel = $objHotelBranch->addCategory(
|
||||
$hotelCatName, $catCity, $groupIds, 1, $newIdHotel
|
||||
$hotelCatName, $catCity, $groupIds, 1, $newIdHotel, $linkRewiteArray
|
||||
)) {
|
||||
$objHotelBranch = new HotelBranchInformation($newIdHotel);
|
||||
$objHotelBranch->id_category = $catHotel;
|
||||
|
||||
@@ -767,6 +767,13 @@ function showLangField(select_lang_name, id_lang)
|
||||
|
||||
$('.all_lang_icon').attr('src', img_dir_l+id_lang+'.jpg');
|
||||
$('#choosedLangId').val(id_lang);
|
||||
|
||||
var id_old_language = id_language;
|
||||
id_language = id_lang;
|
||||
|
||||
if (id_old_language != id_lang) {
|
||||
changeEmployeeLanguage();
|
||||
}
|
||||
}
|
||||
|
||||
/* ---- HotelConfigurationSettingController Admin ---- */
|
||||
|
||||
@@ -112,9 +112,27 @@
|
||||
{foreach from=$languages item=language}
|
||||
{assign var="hotel_name" value="hotel_name_`$language.id_lang`"}
|
||||
<input type="text"
|
||||
id="hotel_name_{$language.id_lang}"
|
||||
id="name_{$language.id_lang}"
|
||||
name="hotel_name_{$language.id_lang}"
|
||||
value="{if isset($smarty.post.$hotel_name)}{$smarty.post.$hotel_name|escape:'htmlall':'UTF-8'}{elseif isset($edit)}{$hotel_info.hotel_name[{$language.id_lang}]|escape:'htmlall':'UTF-8'}{/if}"
|
||||
class="form-control wk_text_field_all wk_text_field_{$language.id_lang} copy2friendlyUrl"
|
||||
maxlength="128"
|
||||
{if $currentLang.id_lang != $language.id_lang}style="display:none;"{/if} />
|
||||
{/foreach}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label required" for="link_rewrite" >
|
||||
{l s='Friendly URL :' mod='hotelreservationsystem'}
|
||||
{include file="../../../_partials/htl-form-fields-flag.tpl"}
|
||||
</label>
|
||||
<div class="col-lg-6">
|
||||
{foreach from=$languages item=language}
|
||||
{assign var="link_rewrite" value="link_rewrite_`$language.id_lang`"}
|
||||
<input type="text"
|
||||
id="link_rewrite_{$language.id_lang}"
|
||||
name="link_rewrite_{$language.id_lang}"
|
||||
value="{if isset($smarty.post.$link_rewrite)}{$smarty.post.$link_rewrite|escape:'htmlall':'UTF-8'}{elseif isset($edit)}{$link_rewrite_info[{$language.id_lang}]|escape:'htmlall':'UTF-8'}{/if}"
|
||||
class="form-control wk_text_field_all wk_text_field_{$language.id_lang}"
|
||||
maxlength="128"
|
||||
{if $currentLang.id_lang != $language.id_lang}style="display:none;"{/if} />
|
||||
@@ -483,6 +501,10 @@
|
||||
|
||||
{block name=script}
|
||||
<script type="text/javascript">
|
||||
var id_language = {$defaultFormLanguage|intval};
|
||||
allowEmployeeFormLang = {$allowEmployeeFormLang|intval};
|
||||
var ps_force_friendly_product = false;
|
||||
|
||||
// for tiny mce setup
|
||||
var iso = "{$iso|escape:'htmlall':'UTF-8'}";
|
||||
var pathCSS = "{$smarty.const._THEME_CSS_DIR_|escape:'htmlall':'UTF-8'}";
|
||||
|
||||
Reference in New Issue
Block a user