Skip to content

Commit

Permalink
Merge pull request #442 from hongoctrien/develop
Browse files Browse the repository at this point in the history
Update custom field
  • Loading branch information
vuthao committed Aug 25, 2015
2 parents 08a9f5c + 5a38383 commit 39ea656
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 43 deletions.
2 changes: 0 additions & 2 deletions modules/shops/admin.functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1191,10 +1191,8 @@ function nv_show_custom_form( $is_edit, $form, $array_custom )
* @param mixed $idshop
* @return
*/

function Insertabl_catfields( $table, $array, $idshop )
{

global $db, $module_name, $module_file, $db, $link, $module_info, $global_array_shops_cat, $global_config;

$result = $db->query( "SHOW COLUMNS FROM " . $table );
Expand Down
1 change: 0 additions & 1 deletion modules/shops/admin/content.php
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,6 @@
$idtemplate = $db->query( 'SELECT id FROM ' . $db_config['prefix'] . '_' . $module_data . '_template where alias = "' . preg_replace( "/[\_]/", "-", $global_array_shops_cat[$rowcontent['listcatid']]['form'] ) . '"' )->fetchColumn( );

$table_insert = $db_config['prefix'] . "_" . $module_data . "_info_" . $idtemplate;

Insertabl_catfields( $table_insert, $array_custom, $rowcontent['id'] );
}
if( !empty( $rowcontent['group_id'] ) )
Expand Down
28 changes: 19 additions & 9 deletions modules/shops/admin/field_tab.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
$table_name = $db_config['prefix'] . '_' . $module_data . '_tabs';

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

if( $show_view )
{
foreach( $arr_tab as $key => $value )
$arr_tab_tmp = $arr_tab;
$arr_tab_tmp['introduce'] = $lang_module['field_info_list'];
foreach( $arr_tab_tmp as $key => $value )
{
$xtpl->assign( 'title_tab', $value );
$xtpl->parse( 'main.view.title_tab' );
}
unset( $arr_tab_tmp );

while( $view = $sth->fetch( ) )
{
$arr_display_tab = unserialize( $view['tab'] );
Expand Down Expand Up @@ -180,35 +184,41 @@
}
}
}

foreach( $arr as $key => $value )// loai bo phan tu trung nhau
{
$arr_tab_tpl[$key] = array_unique( $value );
}
file_put_contents( NV_ROOTDIR . '/themes/default/modules/' . $module_file . '/tab_introduce.tpl', '', LOCK_EX );

if( !file_exists( NV_ROOTDIR . '/' . NV_ASSETS_DIR . '/' . $module_name . '/files_tpl' ) )
{
nv_mkdir( NV_ROOTDIR . '/' . NV_ASSETS_DIR . '/' . $module_name, 'files_tpl' );
}

foreach( $arr_tab_tpl as $key => $value )
{
$name_file = 'tab_' . str_replace( '-', '_', strtolower( change_alias( $arr_tab[$key] ) ) ) . '.tpl';
$name_file = 'tab-' . strtolower( change_alias( $arr_tab[$key] ) ) . '-' . NV_LANG_DATA . '.tpl';
$html_tpl = "<!-- BEGIN: main -->\n";
$html_tpl .= "\t<ul>\n\n";
$html_tpl .= "\t<ul>\n";

foreach( $value as $key => $val )
{
$html_tpl .= "\t\t<!-- BEGIN: " . $val . " -->\n";
$html_tpl .= "\t\t\t<li>\n";
$html_tpl .= "\t\t\t\t<p> <strong>{CUSTOM_LANG." . $val . "}:</strong> {CUSTOM_DATA." . $val . "}</p>\n";
$html_tpl .= "\t\t\t</li>\n";
$html_tpl .= "\t\t<!-- END: " . $val . " -->\n\n";
$html_tpl .= "\t\t<!-- END: " . $val . " -->\n";
}

$html_tpl .= "\t<ul>\n";
$html_tpl .= "\t</ul>\n";
$html_tpl .= "<!-- END: main -->";

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

include NV_ROOTDIR . '/includes/header.php';
echo nv_admin_theme( $contents );
include NV_ROOTDIR . '/includes/footer.php';
include NV_ROOTDIR . '/includes/footer.php';
13 changes: 8 additions & 5 deletions modules/shops/admin/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,19 @@

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

if( empty( $data['title'] ) )
$count = $db->query( 'SELECT * FROM ' . $db_config['prefix'] . '_' . $module_data . '_template where alias=' . $db->quote( $data['alias'] ) . ' AND id!=' . $data['id'] )->fetchColumn();
if( $count > 0 )
{
$error = $lang_module['template_error_name'];
$_tem_id = $db->query( 'SELECT MAX(id) FROM ' . $db_config['prefix'] . '_' . $module_data . '_template WHERE alias=' . $db->quote( $data['alias'] ) )->fetchColumn();
$data['alias'] = $data['alias'] . '-' . $_tem_id;
}
elseif( !empty( $stmt ) )

if( empty( $data['title'] ) )
{
$error = $lang_module['block_error_alias'];
$error = $lang_module['template_error_name'];
}

else
{
if( $data['id'] == 0 )
Expand Down
15 changes: 3 additions & 12 deletions modules/shops/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ function SetSessionProView( $id, $title, $alias, $addtime, $link, $homeimgthumb
*/
function nv_custom_tpl( $name_file, $array_custom, $array_custom_lang, $idtemplate )
{
global $module_data, $module_info, $module_file, $lang_module, $db_config, $db, $global_config;
global $module_data, $module_info, $module_name, $module_file, $lang_module, $db_config, $db, $global_config;

$sql = 'SELECT * FROM ' . $db_config['prefix'] . '_' . $module_data . '_field';
$result = $db->query( $sql );
Expand All @@ -353,18 +353,9 @@ function nv_custom_tpl( $name_file, $array_custom, $array_custom_lang, $idtempla
}
}
}
$html ='';

if( file_exists( NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $module_file . '/' . $name_file ) )
{
$theme_tpl = $global_config['module_theme'];
}
else
{
$theme_tpl = 'default';
}

$xtpl = new XTemplate( $name_file, NV_ROOTDIR . '/themes/' . $theme_tpl . '/modules/' . $module_file );
$html ='';
$xtpl = new XTemplate( $name_file, NV_ROOTDIR . '/' . NV_ASSETS_DIR . '/' . $module_name . '/files_tpl' );
$xtpl->assign( 'CUSTOM_LANG', $array_custom_lang );
$xtpl->assign( 'CUSTOM_DATA', $array_custom );
$count = 0;
Expand Down
14 changes: 6 additions & 8 deletions modules/shops/language/admin_vi.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
$lang_module['setting_facebookAppID'] = 'Facebook App ID';
$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>)';
$lang_module['setting_socialbutton'] = 'Hiển thị các công cụ Like facebook, G+, Twitter khi xem bài viết';
$lang_module['template_setting_active'] = 'Sử dụng chức Tùy biến dữ liệu';
$lang_module['setup_payment'] = 'Tích hợp cổng thanh toán';
$lang_module['setup_payment_guide'] = 'Xem hướng dẫn Tích hợp cổng thanh toán';
$lang_module['setting_stt'] = 'STT';
Expand Down Expand Up @@ -566,6 +567,7 @@

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

$lang_module['template_setting_active'] = 'Sử dụng chức Tùy biến dữ liệu';

//Lang for function tabs
$lang_module['tabs'] = 'Quản lý tab';
$lang_module['tabs_icon'] = 'Biểu tượng';
Expand All @@ -693,10 +695,6 @@
$lang_module['tabs_content_customdata'] = 'Dữ liệu tùy biến';
$lang_module['error_required_content'] = 'Lỗi: bạn cần nhập dữ liệu cho Nội dung';

//Lang for function field
$lang_module['field_tab_page'] = 'Hiển thị dữ liệu cho tab';
$lang_module['introduce'] = 'Giới thiệu';

$lang_module['updateprice']='Cập nhật giá theo loại';
$lang_module['updateprice'] = 'Cập nhật giá theo loại';
$lang_module['cateid'] = 'Loại sản phẩm';
$lang_module['newprice'] = 'Giá mới';
$lang_module['newprice'] = 'Giá mới';
4 changes: 2 additions & 2 deletions modules/shops/theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -1340,7 +1340,7 @@ function detail_product( $data_content, $data_unit, $data_others, $array_other_v
// Hien thi du lieu tuy bien o phan gioi thieu
if( !empty( $data_content['array_custom'] ) and !empty( $data_content['array_custom_lang'] ) )
{
$custom_data = nv_custom_tpl( 'tab_introduce.tpl', $data_content['array_custom'], $data_content['array_custom_lang'], $idtemplate );
$custom_data = nv_custom_tpl( 'tab-introduce-' . NV_LANG_DATA . '.tpl', $data_content['array_custom'], $data_content['array_custom_lang'], $idtemplate );
$xtpl->assign( 'CUSTOM_DATA', $custom_data );
$xtpl->parse( 'main.custom_data' );

Expand Down Expand Up @@ -1409,7 +1409,7 @@ function detail_product( $data_content, $data_unit, $data_others, $array_other_v
{
if( !empty( $data_content['array_custom'] ) and !empty( $data_content['array_custom_lang'] ) )
{
$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 );
$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 );
}
}

Expand Down
3 changes: 1 addition & 2 deletions themes/admin_default/modules/shops/field_tab.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<colgroup>
<col class="w100" />
<col />
<col class="w100" />
</colgroup>
<thead>
<tr>
Expand All @@ -29,7 +28,7 @@
</select></td>
<td> {VIEW.field} </td>
<!-- BEGIN: tab -->
<td class="text-center"><input type="checkbox" name="check[{VIEW.fid}][{tab}]" value="{tab}" {CHECK} /></td>
<td class="text-center w200"><input type="checkbox" name="check[{VIEW.fid}][{tab}]" value="{tab}" {CHECK} /></td>
<!-- END: tab -->
</tr>
<!-- END: loop -->
Expand Down
2 changes: 0 additions & 2 deletions themes/default/modules/shops/tab_introduce.tpl

This file was deleted.

0 comments on commit 39ea656

Please sign in to comment.