Skip to content

Commit 39ea656

Browse files
committed
Merge pull request #442 from hongoctrien/develop
Update custom field
2 parents 08a9f5c + 5a38383 commit 39ea656

File tree

9 files changed

+39
-43
lines changed

9 files changed

+39
-43
lines changed

modules/shops/admin.functions.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,10 +1191,8 @@ function nv_show_custom_form( $is_edit, $form, $array_custom )
11911191
* @param mixed $idshop
11921192
* @return
11931193
*/
1194-
11951194
function Insertabl_catfields( $table, $array, $idshop )
11961195
{
1197-
11981196
global $db, $module_name, $module_file, $db, $link, $module_info, $global_array_shops_cat, $global_config;
11991197

12001198
$result = $db->query( "SHOW COLUMNS FROM " . $table );

modules/shops/admin/content.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,6 @@
574574
$idtemplate = $db->query( 'SELECT id FROM ' . $db_config['prefix'] . '_' . $module_data . '_template where alias = "' . preg_replace( "/[\_]/", "-", $global_array_shops_cat[$rowcontent['listcatid']]['form'] ) . '"' )->fetchColumn( );
575575

576576
$table_insert = $db_config['prefix'] . "_" . $module_data . "_info_" . $idtemplate;
577-
578577
Insertabl_catfields( $table_insert, $array_custom, $rowcontent['id'] );
579578
}
580579
if( !empty( $rowcontent['group_id'] ) )

modules/shops/admin/field_tab.php

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
$table_name = $db_config['prefix'] . '_' . $module_data . '_tabs';
1414

1515
$arr_tab = array( );
16-
$arr_tab['introduce'] = $lang_module['status_1'];
16+
$arr_tab['introduce'] = 'introduce';
1717
$sql = 'SELECT * FROM ' . $table_name . ' where content = ' . $db->quote( 'content_customdata' ) . ' ORDER BY weight ASC';
1818
$result = $db->query( $sql );
1919
$field_lang = nv_file_table( $table_name );
@@ -87,11 +87,15 @@
8787

8888
if( $show_view )
8989
{
90-
foreach( $arr_tab as $key => $value )
90+
$arr_tab_tmp = $arr_tab;
91+
$arr_tab_tmp['introduce'] = $lang_module['field_info_list'];
92+
foreach( $arr_tab_tmp as $key => $value )
9193
{
9294
$xtpl->assign( 'title_tab', $value );
9395
$xtpl->parse( 'main.view.title_tab' );
9496
}
97+
unset( $arr_tab_tmp );
98+
9599
while( $view = $sth->fetch( ) )
96100
{
97101
$arr_display_tab = unserialize( $view['tab'] );
@@ -180,35 +184,41 @@
180184
}
181185
}
182186
}
187+
183188
foreach( $arr as $key => $value )// loai bo phan tu trung nhau
184189
{
185190
$arr_tab_tpl[$key] = array_unique( $value );
186191
}
187-
file_put_contents( NV_ROOTDIR . '/themes/default/modules/' . $module_file . '/tab_introduce.tpl', '', LOCK_EX );
192+
193+
if( !file_exists( NV_ROOTDIR . '/' . NV_ASSETS_DIR . '/' . $module_name . '/files_tpl' ) )
194+
{
195+
nv_mkdir( NV_ROOTDIR . '/' . NV_ASSETS_DIR . '/' . $module_name, 'files_tpl' );
196+
}
197+
188198
foreach( $arr_tab_tpl as $key => $value )
189199
{
190-
$name_file = 'tab_' . str_replace( '-', '_', strtolower( change_alias( $arr_tab[$key] ) ) ) . '.tpl';
200+
$name_file = 'tab-' . strtolower( change_alias( $arr_tab[$key] ) ) . '-' . NV_LANG_DATA . '.tpl';
191201
$html_tpl = "<!-- BEGIN: main -->\n";
192-
$html_tpl .= "\t<ul>\n\n";
202+
$html_tpl .= "\t<ul>\n";
193203

194204
foreach( $value as $key => $val )
195205
{
196206
$html_tpl .= "\t\t<!-- BEGIN: " . $val . " -->\n";
197207
$html_tpl .= "\t\t\t<li>\n";
198208
$html_tpl .= "\t\t\t\t<p> <strong>{CUSTOM_LANG." . $val . "}:</strong> {CUSTOM_DATA." . $val . "}</p>\n";
199209
$html_tpl .= "\t\t\t</li>\n";
200-
$html_tpl .= "\t\t<!-- END: " . $val . " -->\n\n";
210+
$html_tpl .= "\t\t<!-- END: " . $val . " -->\n";
201211
}
202212

203-
$html_tpl .= "\t<ul>\n";
213+
$html_tpl .= "\t</ul>\n";
204214
$html_tpl .= "<!-- END: main -->";
205215

206-
file_put_contents( NV_ROOTDIR . '/themes/default/modules/' . $module_file . '/' . $name_file, $html_tpl, LOCK_EX );
216+
file_put_contents( NV_ROOTDIR . '/' . NV_ASSETS_DIR . '/' . $module_name . '/files_tpl/' . $name_file, $html_tpl, LOCK_EX );
207217
}
208218
Header( 'Location:' . NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=template' );
209219
exit ;
210220
}
211221

212222
include NV_ROOTDIR . '/includes/header.php';
213223
echo nv_admin_theme( $contents );
214-
include NV_ROOTDIR . '/includes/footer.php';
224+
include NV_ROOTDIR . '/includes/footer.php';

modules/shops/admin/template.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,19 @@
5959

6060
$data['title'] = nv_substr( $nv_Request->get_title( 'title', 'post', '' ), 0, 50 );
6161
$data['alias'] = strtolower( change_alias( $data['title'] ) );
62-
$stmt = $db->query( 'SELECT * FROM ' . $db_config['prefix'] . '_' . $module_data . '_template where alias=' . $db->quote( $data['alias'] ) )->fetchColumn( );
6362

64-
if( empty( $data['title'] ) )
63+
$count = $db->query( 'SELECT * FROM ' . $db_config['prefix'] . '_' . $module_data . '_template where alias=' . $db->quote( $data['alias'] ) . ' AND id!=' . $data['id'] )->fetchColumn();
64+
if( $count > 0 )
6565
{
66-
$error = $lang_module['template_error_name'];
66+
$_tem_id = $db->query( 'SELECT MAX(id) FROM ' . $db_config['prefix'] . '_' . $module_data . '_template WHERE alias=' . $db->quote( $data['alias'] ) )->fetchColumn();
67+
$data['alias'] = $data['alias'] . '-' . $_tem_id;
6768
}
68-
elseif( !empty( $stmt ) )
69+
70+
if( empty( $data['title'] ) )
6971
{
70-
$error = $lang_module['block_error_alias'];
72+
$error = $lang_module['template_error_name'];
7173
}
74+
7275
else
7376
{
7477
if( $data['id'] == 0 )

modules/shops/functions.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ function SetSessionProView( $id, $title, $alias, $addtime, $link, $homeimgthumb
335335
*/
336336
function nv_custom_tpl( $name_file, $array_custom, $array_custom_lang, $idtemplate )
337337
{
338-
global $module_data, $module_info, $module_file, $lang_module, $db_config, $db, $global_config;
338+
global $module_data, $module_info, $module_name, $module_file, $lang_module, $db_config, $db, $global_config;
339339

340340
$sql = 'SELECT * FROM ' . $db_config['prefix'] . '_' . $module_data . '_field';
341341
$result = $db->query( $sql );
@@ -353,18 +353,9 @@ function nv_custom_tpl( $name_file, $array_custom, $array_custom_lang, $idtempla
353353
}
354354
}
355355
}
356-
$html ='';
357-
358-
if( file_exists( NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $module_file . '/' . $name_file ) )
359-
{
360-
$theme_tpl = $global_config['module_theme'];
361-
}
362-
else
363-
{
364-
$theme_tpl = 'default';
365-
}
366356

367-
$xtpl = new XTemplate( $name_file, NV_ROOTDIR . '/themes/' . $theme_tpl . '/modules/' . $module_file );
357+
$html ='';
358+
$xtpl = new XTemplate( $name_file, NV_ROOTDIR . '/' . NV_ASSETS_DIR . '/' . $module_name . '/files_tpl' );
368359
$xtpl->assign( 'CUSTOM_LANG', $array_custom_lang );
369360
$xtpl->assign( 'CUSTOM_DATA', $array_custom );
370361
$count = 0;

modules/shops/language/admin_vi.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@
131131
$lang_module['setting_facebookAppID'] = 'Facebook App ID';
132132
$lang_module['setting_facebookAppIDNote'] = ' (Có dạng 1419186468293063, <a href="http://wiki.nukeviet.vn/nukeviet:admin:news:facebookapi" target="_blank">xem chi tiết</a>)';
133133
$lang_module['setting_socialbutton'] = 'Hiển thị các công cụ Like facebook, G+, Twitter khi xem bài viết';
134+
$lang_module['template_setting_active'] = 'Sử dụng chức Tùy biến dữ liệu';
134135
$lang_module['setup_payment'] = 'Tích hợp cổng thanh toán';
135136
$lang_module['setup_payment_guide'] = 'Xem hướng dẫn Tích hợp cổng thanh toán';
136137
$lang_module['setting_stt'] = 'STT';
@@ -566,6 +567,7 @@
566567

567568
//field
568569
$lang_module['fields'] = 'Tùy biến dữ liệu';
570+
$lang_module['field_tab_page'] = 'Cấu hình hiển thị dữ liệu tùy biến';
569571
$lang_module['captionform_add'] = 'Thêm trường dữ liệu';
570572
$lang_module['captionform_edit'] = 'Sửa trường dữ liệu';
571573
$lang_module['field_edit'] = 'Sửa';
@@ -617,6 +619,8 @@
617619
$lang_module['field_number'] = 'STT';
618620
$lang_module['field_value'] = 'Giá trị';
619621
$lang_module['field_text'] = 'Miêu tả';
622+
$lang_module['field_info_list'] = 'Thông tin sản phẩm';
623+
$lang_module['field_info_list_note'] = 'Hiển thị trong phần thông tin sản phẩm';
620624
$lang_module['field_add_choice'] = 'Thêm lựa chọn';
621625
$lang_module['field_date_error'] = 'Giá trị của Min Date cần nhỏ hơn Max Date';
622626
$lang_module['field_number_error'] = 'Giá trị của Min Value cần nhỏ hơn Max Value';
@@ -679,8 +683,6 @@
679683
$lang_module['download_setting_groups'] = 'Ai được phép tải tập tin';
680684
$lang_module['download_setting_groups_module'] = 'Theo cấu hình module';
681685

682-
$lang_module['template_setting_active'] = 'Sử dụng chức Tùy biến dữ liệu';
683-
684686
//Lang for function tabs
685687
$lang_module['tabs'] = 'Quản lý tab';
686688
$lang_module['tabs_icon'] = 'Biểu tượng';
@@ -693,10 +695,6 @@
693695
$lang_module['tabs_content_customdata'] = 'Dữ liệu tùy biến';
694696
$lang_module['error_required_content'] = 'Lỗi: bạn cần nhập dữ liệu cho Nội dung';
695697

696-
//Lang for function field
697-
$lang_module['field_tab_page'] = 'Hiển thị dữ liệu cho tab';
698-
$lang_module['introduce'] = 'Giới thiệu';
699-
700-
$lang_module['updateprice']='Cập nhật giá theo loại';
698+
$lang_module['updateprice'] = 'Cập nhật giá theo loại';
701699
$lang_module['cateid'] = 'Loại sản phẩm';
702-
$lang_module['newprice'] = 'Giá mới';
700+
$lang_module['newprice'] = 'Giá mới';

modules/shops/theme.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,7 +1340,7 @@ function detail_product( $data_content, $data_unit, $data_others, $array_other_v
13401340
// Hien thi du lieu tuy bien o phan gioi thieu
13411341
if( !empty( $data_content['array_custom'] ) and !empty( $data_content['array_custom_lang'] ) )
13421342
{
1343-
$custom_data = nv_custom_tpl( 'tab_introduce.tpl', $data_content['array_custom'], $data_content['array_custom_lang'], $idtemplate );
1343+
$custom_data = nv_custom_tpl( 'tab-introduce-' . NV_LANG_DATA . '.tpl', $data_content['array_custom'], $data_content['array_custom_lang'], $idtemplate );
13441344
$xtpl->assign( 'CUSTOM_DATA', $custom_data );
13451345
$xtpl->parse( 'main.custom_data' );
13461346

@@ -1409,7 +1409,7 @@ function detail_product( $data_content, $data_unit, $data_others, $array_other_v
14091409
{
14101410
if( !empty( $data_content['array_custom'] ) and !empty( $data_content['array_custom_lang'] ) )
14111411
{
1412-
$tabs_content = nv_custom_tpl( 'tab_' . str_replace( '-', '_', strtolower( change_alias( $data_content['tabs'][$tabs_id][NV_LANG_DATA.'_title'] ) ) ) . '.tpl', $data_content['array_custom'], $data_content['array_custom_lang'], $idtemplate );
1412+
$tabs_content = nv_custom_tpl( 'tab-' . strtolower( change_alias( $data_content['tabs'][$tabs_id][NV_LANG_DATA.'_title'] ) ) . '-' . NV_LANG_DATA . '.tpl', $data_content['array_custom'], $data_content['array_custom_lang'], $idtemplate );
14131413
}
14141414
}
14151415

themes/admin_default/modules/shops/field_tab.tpl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
<colgroup>
88
<col class="w100" />
99
<col />
10-
<col class="w100" />
1110
</colgroup>
1211
<thead>
1312
<tr>
@@ -29,7 +28,7 @@
2928
</select></td>
3029
<td> {VIEW.field} </td>
3130
<!-- BEGIN: tab -->
32-
<td class="text-center"><input type="checkbox" name="check[{VIEW.fid}][{tab}]" value="{tab}" {CHECK} /></td>
31+
<td class="text-center w200"><input type="checkbox" name="check[{VIEW.fid}][{tab}]" value="{tab}" {CHECK} /></td>
3332
<!-- END: tab -->
3433
</tr>
3534
<!-- END: loop -->

themes/default/modules/shops/tab_introduce.tpl

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)