From 32f00f67f3c9930a8694d6e367e8758222835e6d Mon Sep 17 00:00:00 2001 From: KennyNguyen Date: Sat, 6 Aug 2016 12:58:38 +0700 Subject: [PATCH] Fix custom TPL of shops + Fix function, change $module_name to $module_upload. + Virtual module now can add custom TPL. + Fix admin TPL.. --- modules/shops/admin.functions.php | 8 +- modules/shops/admin/cat.php | 112 ++++++--- modules/shops/admin/field_tab.php | 73 +++--- modules/shops/admin/fields.php | 226 +++++++++--------- modules/shops/functions.php | 156 ++++++------ modules/shops/version.php | 15 +- themes/admin_default/modules/shops/fields.tpl | 2 +- 7 files changed, 328 insertions(+), 264 deletions(-) diff --git a/modules/shops/admin.functions.php b/modules/shops/admin.functions.php index e2793834b..6a89fc840 100644 --- a/modules/shops/admin.functions.php +++ b/modules/shops/admin.functions.php @@ -1153,7 +1153,7 @@ function Insertabl_catfields($table, $array, $idshop) function nv_create_form_file($array_template_id) { - global $db, $db_config, $module_name, $module_data, $module_file, $array_template, $lang_module; + global $db, $db_config, $module_upload, $module_data, $module_file, $array_template, $lang_module; foreach ($array_template_id as $templateids_i) { $array_views = array(); @@ -1294,11 +1294,11 @@ function nv_create_form_file($array_template_id) $content_2 .= ""; - if (!file_exists(NV_ROOTDIR . '/' . NV_ASSETS_DIR . '/' . $module_name . '/files_tpl')) { - nv_mkdir(NV_ROOTDIR . '/' . NV_ASSETS_DIR . '/' . $module_name, 'files_tpl'); + if (!file_exists(NV_ROOTDIR . '/' . NV_ASSETS_DIR . '/' . $module_upload . '/files_tpl')) { + nv_mkdir(NV_ROOTDIR . '/' . NV_ASSETS_DIR . '/' . $module_upload, 'files_tpl'); } - $file = NV_ROOTDIR . '/' . NV_ASSETS_DIR . '/' . $module_name . '/files_tpl/cat_form_' . preg_replace('/[\-]/', '_', $array_template[$templateids_i]['alias']) . '.tpl'; + $file = NV_ROOTDIR . '/' . NV_ASSETS_DIR . '/' . $module_upload . '/files_tpl/cat_form_' . preg_replace('/[\-]/', '_', $array_template[$templateids_i]['alias']) . '.tpl'; file_put_contents($file, $content_2, LOCK_EX); } } diff --git a/modules/shops/admin/cat.php b/modules/shops/admin/cat.php index 9ca03b639..1d840f172 100644 --- a/modules/shops/admin/cat.php +++ b/modules/shops/admin/cat.php @@ -7,7 +7,6 @@ * @License GNU/GPL version 2 or any later version * @Createdate 2-9-2010 14:43 */ - if (! defined('NV_IS_FILE_ADMIN')) { die('Stop!!!'); } @@ -25,17 +24,36 @@ } $currentpath = NV_UPLOADS_DIR . '/' . $module_upload . '/' . date('Y_m'); -if (!file_exists($currentpath)) { +if (! file_exists($currentpath)) { nv_mkdir(NV_UPLOADS_REAL_DIR . '/' . $module_upload, date('Y_m'), true); } -list($data['catid'], $data['parentid'], $data['title'], $data['title_custom'], $data['alias'], $data['description'], $data[NV_LANG_DATA . '_descriptionhtml'], $data['keywords'], $data['groups_view'], $data['cat_allow_point'], $data['cat_number_point'], $data['cat_number_product'], $data['image'], $data['form'], $data['group_price'], $data['viewdescriptionhtml'], $data['newday'], $data['typeprice']) = array( 0, 0, '', '', '', '', '', '', '6', 0, 0, 0, '', '', $pro_config['group_price'], 0, 7, 1); +list ($data['catid'], $data['parentid'], $data['title'], $data['title_custom'], $data['alias'], $data['description'], $data[NV_LANG_DATA . '_descriptionhtml'], $data['keywords'], $data['groups_view'], $data['cat_allow_point'], $data['cat_number_point'], $data['cat_number_product'], $data['image'], $data['form'], $data['group_price'], $data['viewdescriptionhtml'], $data['newday'], $data['typeprice']) = array( + 0, + 0, + '', + '', + '', + '', + '', + '', + '6', + 0, + 0, + 0, + '', + '', + $pro_config['group_price'], + 0, + 7, + 1 +); $savecat = $nv_Request->get_int('savecat', 'post', 0); $cat_form_exit = array(); -if(is_dir(NV_ROOTDIR . '/' . NV_ASSETS_DIR . '/' . $module_file . '/files_tpl')) { - $_form_exit = scandir(NV_ROOTDIR . '/' . NV_ASSETS_DIR . '/' . $module_file . '/files_tpl'); +if (is_dir(NV_ROOTDIR . '/' . NV_ASSETS_DIR . '/' . $module_upload . '/files_tpl')) { + $_form_exit = scandir(NV_ROOTDIR . '/' . NV_ASSETS_DIR . '/' . $module_upload . '/files_tpl'); foreach ($_form_exit as $_form) { if (preg_match('/^cat\_form\_([a-zA-Z0-9\-\_]+)\.tpl$/', $_form, $m)) { $cat_form_exit[] = $m[1]; @@ -45,7 +63,7 @@ if (! empty($savecat)) { $field_lang = nv_file_table($table_name); - + $data['catid'] = $nv_Request->get_int('catid', 'post', 0); $data['typeprice'] = $nv_Request->get_int('typeprice', 'post', 2); $data['parentid_old'] = $nv_Request->get_int('parentid_old', 'post', 0); @@ -61,21 +79,21 @@ $data['cat_allow_point'] = $nv_Request->get_int('cat_allow_point', 'post', 0); $data['cat_number_point'] = $nv_Request->get_int('cat_number_point', 'post', 0); $data['cat_number_product'] = $nv_Request->get_int('cat_number_product', 'post', 0); - + $data['alias'] = ($data['alias'] == '') ? change_alias($data['title']) : change_alias($data['alias']); - + // Cat mo ta cho chinh xac if (strlen($data['description']) > 255) { $data['description'] = nv_clean60($data['description'], 250); } - + $_groups_post = $nv_Request->get_array('groups_view', 'post', array()); $data['groups_view'] = ! empty($_groups_post) ? implode(',', nv_groups_post(array_intersect($_groups_post, array_keys($groups_list)))) : ''; - + if ($data['title'] == '') { $error = $lang_module['error_cat_name']; } - + $image = $nv_Request->get_string('image', 'post', ''); if (is_file(NV_DOCUMENT_ROOT . $image)) { $lu = strlen(NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $module_upload . '/'); @@ -83,37 +101,37 @@ } else { $data['image'] = ''; } - + $data['form'] = $nv_Request->get_title('cat_form', 'post', ''); if (! in_array($data['form'], $cat_form_exit)) { $data['form'] = ''; } - + $data['group_price'] = $nv_Request->get_textarea('group_price', '', 'br'); - + $stmt = $db->prepare('SELECT count(*) FROM ' . $table_name . ' WHERE catid!=' . $data['catid'] . ' AND ' . NV_LANG_DATA . '_alias= :alias'); $stmt->bindParam(':alias', $data['alias'], PDO::PARAM_STR); $stmt->execute(); $check_alias = $stmt->fetchColumn(); - + if ($check_alias and $data['parentid'] > 0) { $parentid_alias = $db->query('SELECT ' . NV_LANG_DATA . '_alias FROM ' . $table_name . ' WHERE catid=' . $data['parentid'])->fetchColumn(); $data['alias'] = $parentid_alias . '-' . $data['alias']; } - + if ($data['catid'] == 0 and $data['title'] != '' and $error == '') { $listfield = ''; $listvalue = ''; foreach ($field_lang as $field_lang_i) { - list($flang, $fname) = $field_lang_i; + list ($flang, $fname) = $field_lang_i; $listfield .= ', ' . $flang . '_' . $fname; $listvalue .= ', :' . $flang . '_' . $fname; } - $w='SELECT max(weight) FROM ' . $table_name . ' WHERE parentid=' . $data['parentid']; + $w = 'SELECT max(weight) FROM ' . $table_name . ' WHERE parentid=' . $data['parentid']; $rw = $db->query($w); $weight = $rw->fetchColumn(); $weight = intval($weight) + 1; - + $sql = "INSERT INTO " . $table_name . " (catid, parentid, image, weight, sort, lev, viewcat, numsubcat, subcatid, inhome, numlinks, newday, typeprice, form, group_price, viewdescriptionhtml, admins, add_time, edit_time, groups_view, cat_allow_point, cat_number_point, cat_number_product " . $listfield . " ) VALUES (NULL, :parentid, :image," . $weight . ", '0', '0', :viewcat, '0', :subcatid, '1', '4', :newday, :typeprice, :form, :group_price, :viewdescriptionhtml, :admins, " . NV_CURRENTTIME . ", " . NV_CURRENTTIME . ", :groups_view, :cat_allow_point, :cat_number_point, :cat_number_product" . $listvalue . ")"; $data_insert = array(); @@ -132,10 +150,10 @@ $data_insert['cat_number_point'] = $data['cat_number_point']; $data_insert['cat_number_product'] = $data['cat_number_product']; foreach ($field_lang as $field_lang_i) { - list($flang, $fname) = $field_lang_i; + list ($flang, $fname) = $field_lang_i; $data_insert[$flang . '_' . $fname] = $data[$fname]; } - + $newcatid = intval($db->insert_id($sql, 'catid', $data_insert)); if ($newcatid > 0) { nv_insert_logs(NV_LANG_DATA, $module_name, 'log_add_catalog', 'id ' . $newcatid, $admin_info['userid']); @@ -165,12 +183,12 @@ $stmt->bindParam(':cat_allow_point', $data['cat_allow_point'], PDO::PARAM_INT); $stmt->bindParam(':cat_number_point', $data['cat_number_point'], PDO::PARAM_INT); $stmt->bindParam(':cat_number_product', $data['cat_number_product'], PDO::PARAM_INT); - + if ($stmt->execute()) { nv_insert_logs(NV_LANG_DATA, $module_name, 'log_edit_catalog', 'id ' . $data['catid'], $admin_info['userid']); - + if ($data['parentid'] != $data['parentid_old']) { - $w='SELECT max(weight) FROM ' . $table_name . ' WHERE parentid=' . $data['parentid']; + $w = 'SELECT max(weight) FROM ' . $table_name . ' WHERE parentid=' . $data['parentid']; $rw = $db->query($w); $weight = $rw->fetchColumn(); $weight = intval($weight) + 1; @@ -178,14 +196,14 @@ $db->query($sql); nv_fix_cat_order(); } - - //cập nhật các form dữ liệu tùy biến cho các subcat + + // cập nhật các form dữ liệu tùy biến cho các subcat $_sql = 'SELECT catid FROM ' . $table_name . ' WHERE parentid=' . intval($data['catid']); $_query = $db->query($_sql); while ($row_catid = $_query->fetch()) { - $db->query('UPDATE ' . $table_name . ' SET form=' .$db->quote($data['form']). ' WHERE catid=' . intval($row_catid['catid'])); + $db->query('UPDATE ' . $table_name . ' SET form=' . $db->quote($data['form']) . ' WHERE catid=' . intval($row_catid['catid'])); } - + $nv_Cache->delMod($module_name); Header('Location: ' . NV_BASE_ADMINURL . 'index.php?' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $op . '&parentid=' . $data['parentid']); die(); @@ -196,7 +214,7 @@ } } else { $data['parentid'] = $nv_Request->get_int('parentid', 'get,post', 0); - + $data['catid'] = $nv_Request->get_int('catid', 'get', 0); if ($data['catid'] > 0) { $data = $db->query('SELECT * FROM ' . $table_name . ' where catid=' . $data['catid'])->fetch(); @@ -212,7 +230,7 @@ } if ($data['parentid']) { $data['form'] = $db->query('SELECT form FROM ' . $table_name . ' where catid=' . $data['parentid'])->fetchColumn(); - list($parent_title, $group_price) = $db->query('SELECT ' . NV_LANG_DATA . '_title, group_price FROM ' . $table_name . ' where catid=' . $data['parentid'])->fetch(3); + list ($parent_title, $group_price) = $db->query('SELECT ' . NV_LANG_DATA . '_title, group_price FROM ' . $table_name . ' where catid=' . $data['parentid'])->fetch(3); $data['group_price'] = $group_price; $data['parent_title'] = $parent_title; } @@ -221,18 +239,24 @@ $sql = 'SELECT catid, ' . NV_LANG_DATA . '_title, lev FROM ' . $table_name . ' WHERE catid !=' . $data['catid'] . ' ORDER BY sort ASC'; $result = $db->query($sql); $array_cat_list = array(); -$array_cat_list[0] = array( '0', $lang_module['cat_sub_sl'] ); +$array_cat_list[0] = array( + '0', + $lang_module['cat_sub_sl'] +); -while (list($catid_i, $title_i, $lev_i) = $result->fetch(3)) { +while (list ($catid_i, $title_i, $lev_i) = $result->fetch(3)) { $xtitle_i = ''; if ($lev_i > 0) { $xtitle_i .= ' '; - for ($i = 1; $i <= $lev_i; $i++) { + for ($i = 1; $i <= $lev_i; $i ++) { $xtitle_i .= '---'; } } $xtitle_i .= $title_i; - $array_cat_list[] = array( $catid_i, $xtitle_i ); + $array_cat_list[] = array( + $catid_i, + $xtitle_i + ); } $lang_global['title_suggest_max'] = sprintf($lang_global['length_suggest_max'], 65); @@ -301,10 +325,18 @@ } // Cach tinh gia san pham -$array_typeprice = array( $lang_module['typeprice_none'], $lang_module['config_discounts'], $lang_module['typeprice_per_product'] ); +$array_typeprice = array( + $lang_module['typeprice_none'], + $lang_module['config_discounts'], + $lang_module['typeprice_per_product'] +); foreach ($array_typeprice as $key => $value) { $ck = $data['typeprice'] == $key ? 'checked="checked"' : ''; - $xtpl->assign('TYPEPRICE', array( 'key' => $key, 'value' => $value, 'checked' => $ck )); + $xtpl->assign('TYPEPRICE', array( + 'key' => $key, + 'value' => $value, + 'checked' => $ck + )); $xtpl->parse('main.typeprice_loop'); } @@ -332,8 +364,12 @@ } $xtpl->assign('DESCRIPTIONHTML', $descriptionhtml); -for ($i = 0; $i <= 2; $i++) { - $xtpl->assign('VIEWDESCRIPTION', array( 'value' => $i, 'checked' => $data['viewdescriptionhtml'] == $i ? ' checked="checked"' : '', 'title' => $lang_module['content_bodytext_display_' . $i] )); +for ($i = 0; $i <= 2; $i ++) { + $xtpl->assign('VIEWDESCRIPTION', array( + 'value' => $i, + 'checked' => $data['viewdescriptionhtml'] == $i ? ' checked="checked"' : '', + 'title' => $lang_module['content_bodytext_display_' . $i] + )); $xtpl->parse('main.viewdescriptionhtml'); } diff --git a/modules/shops/admin/field_tab.php b/modules/shops/admin/field_tab.php index 8b09ec1aa..b00001e2b 100644 --- a/modules/shops/admin/field_tab.php +++ b/modules/shops/admin/field_tab.php @@ -7,20 +7,19 @@ * @License GNU/GPL version 2 or any later version * @Createdate Fri, 29 May 2015 09:00:55 GMT */ - -if (!defined('NV_IS_FILE_ADMIN')) { +if (! defined('NV_IS_FILE_ADMIN')) { die('Stop!!!'); } $table_name = $db_config['prefix'] . '_' . $module_data . '_tabs'; -$arr_tab = array( ); +$arr_tab = array(); $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); while ($row = $result->fetch()) { - $arr_tab[$row['id']] = $row[NV_LANG_DATA.'_title']; + $arr_tab[$row['id']] = $row[NV_LANG_DATA . '_title']; } if ($nv_Request->isset_request('ajax_action', 'post')) { @@ -32,9 +31,9 @@ $result = $db->query($sql); $weight = 0; while ($row = $result->fetch()) { - ++$weight; + ++ $weight; if ($weight == $new_vid) { - ++$weight; + ++ $weight; } $sql = 'UPDATE ' . $db_config['prefix'] . '_' . $module_data . '_field SET weight=' . $weight . ' WHERE fid=' . $row['fid']; $db->query($sql); @@ -50,22 +49,28 @@ exit(); } -$row = array( ); +$row = array(); $row['fid'] = $nv_Request->get_int('fid', 'post,get', 0); $template = $nv_Request->get_int('template', 'post,get', 0); // Fetch Limit $show_view = false; -if (!$nv_Request->isset_request('id', 'post,get')) { +if (! $nv_Request->isset_request('id', 'post,get')) { $show_view = true; $per_page = 20; $page = $nv_Request->get_int('page', 'post,get', 1); - $db->sqlreset()->select('COUNT(*)')->from('' . $db_config['prefix'] . '_' . $module_data . '_field'); + $db->sqlreset() + ->select('COUNT(*)') + ->from('' . $db_config['prefix'] . '_' . $module_data . '_field'); $sth = $db->prepare($db->sql()); $sth->execute(); $num_items = $sth->fetchColumn(); - - $db->select('*')->where(' FIND_IN_SET (' . $template . ',listtemplate)')->order('weight ASC')->limit($per_page)->offset(($page - 1) * $per_page); + + $db->select('*') + ->where(' FIND_IN_SET (' . $template . ',listtemplate)') + ->order('weight ASC') + ->limit($per_page) + ->offset(($page - 1) * $per_page); $sth = $db->prepare($db->sql()); $sth->execute(); } @@ -90,10 +95,10 @@ $xtpl->parse('main.view.title_tab'); } unset($arr_tab_tmp); - + while ($view = $sth->fetch()) { $arr_display_tab = unserialize($view['tab']); - for ($i = 1; $i <= $num_items; ++$i) { + for ($i = 1; $i <= $num_items; ++ $i) { $xtpl->assign('WEIGHT', array( 'key' => $i, 'title' => $i, @@ -106,10 +111,10 @@ $xtpl->assign('VIEW', $view); foreach ($arr_tab as $key => $value) { $xtpl->assign('tab', $key); - if (!empty($arr_display_tab[$template])) { + if (! empty($arr_display_tab[$template])) { $xtpl->assign('CHECK', in_array($key, $arr_display_tab[$template]) ? ' checked="checked"' : ''); } - + $xtpl->parse('main.view.loop.tab'); } $xtpl->parse('main.view.loop'); @@ -122,11 +127,11 @@ $page_title = $lang_module['field_tab_page']; -if ($nv_Request->isset_request('submit', 'post')) {// luu lai +if ($nv_Request->isset_request('submit', 'post')) { // luu lai $check = $nv_Request->get_array('check', 'post'); $template = $nv_Request->get_int('template', 'post'); - $arr_tab_ser = array( ); - + $arr_tab_ser = array(); + $sql = 'SELECT * FROM ' . $db_config['prefix'] . '_' . $module_data . '_field where FIND_IN_SET (' . $template . ',listtemplate)'; $result = $db->query($sql); while ($row = $result->fetch()) { @@ -137,14 +142,14 @@ $sql = 'UPDATE ' . $db_config['prefix'] . '_' . $module_data . '_field SET tab=' . $db->quote($tab) . ' WHERE fid=' . $row['fid']; $db->query($sql); } - + foreach ($check as $key => $value) { $tab = ''; - $arr_tab_ser = array( ); + $arr_tab_ser = array(); foreach ($value as $val) { $arr_tab_ser[$template][] = $val; } - + foreach ($tab_old[$key][0] as $key_old => $value_old) { if ($key_old != $template and $value_old != null) { $arr_tab_ser[$key_old] = $value_old; @@ -154,7 +159,7 @@ $sql = 'UPDATE ' . $db_config['prefix'] . '_' . $module_data . '_field SET tab=' . $db->quote($tab) . ' WHERE fid=' . $key; $db->query($sql); } - + // Tao file tpl $sql = 'SELECT * FROM ' . $db_config['prefix'] . '_' . $module_data . '_field'; $result = $db->query($sql); @@ -166,22 +171,22 @@ } } } - + foreach ($arr as $key => $value) { // loai bo phan tu trung nhau - + $arr_tab_tpl[$key] = array_unique($value); } - - if (!file_exists(NV_ROOTDIR . '/' . NV_ASSETS_DIR . '/' . $module_name . '/files_tpl')) { - nv_mkdir(NV_ROOTDIR . '/' . NV_ASSETS_DIR . '/' . $module_name, 'files_tpl'); + + if (! file_exists(NV_ROOTDIR . '/' . NV_ASSETS_DIR . '/' . $module_upload . '/files_tpl')) { + nv_mkdir(NV_ROOTDIR . '/' . NV_ASSETS_DIR . '/' . $module_upload, 'files_tpl'); } - + foreach ($arr_tab_tpl as $key => $value) { - $name_file = 'tab-' . strtolower(change_alias($arr_tab[$key])) . '.tpl'; + $name_file = 'tab-' . strtolower(change_alias($arr_tab[$key])) . '.tpl'; $html_tpl = "\n"; $html_tpl .= "\t\n"; $html_tpl .= ""; - - file_put_contents(NV_ROOTDIR . '/' . NV_ASSETS_DIR . '/' . $module_name . '/files_tpl/' . $name_file, $html_tpl, LOCK_EX); + + file_put_contents(NV_ROOTDIR . '/' . NV_ASSETS_DIR . '/' . $module_upload . '/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 ; + exit(); } include NV_ROOTDIR . '/includes/header.php'; diff --git a/modules/shops/admin/fields.php b/modules/shops/admin/fields.php index 3f403a43c..818eb704b 100644 --- a/modules/shops/admin/fields.php +++ b/modules/shops/admin/fields.php @@ -7,17 +7,16 @@ * @License GNU/GPL version 2 or any later version * @Createdate Sun, 08 Apr 2012 00:00:00 GMT GMT */ - -if (!defined('NV_IS_FILE_ADMIN')) { +if (! defined('NV_IS_FILE_ADMIN')) { die('Stop!!!'); } -if (!defined('NV_IS_SPADMIN')) { +if (! defined('NV_IS_SPADMIN')) { Header('Location: ' . NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name); die(); } -//Ket noi ngon ngu cua module users +// Ket noi ngon ngu cua module users if (file_exists(NV_ROOTDIR . '/modules/users/language/admin_' . NV_LANG_INTERFACE . '.php')) { require NV_ROOTDIR . '/modules/users/language/admin_' . NV_LANG_INTERFACE . '.php'; } elseif (file_exists(NV_ROOTDIR . '/modules/users/language/admin_' . NV_LANG_DATA . '.php')) { @@ -35,37 +34,37 @@ } $result = $db->query($sql); -$array_template = array( ); +$array_template = array(); while ($row = $result->fetch()) { $array_template[$row['id']] = array( 'id' => $row['id'], 'title' => $row[NV_LANG_DATA . "_title"], - 'alias' => $row["alias"], + 'alias' => $row["alias"] ); } // Chinh thu tu if ($nv_Request->isset_request('changeweight', 'post')) { - if (!defined('NV_IS_AJAX')) { + if (! defined('NV_IS_AJAX')) { die('Wrong URL'); } - + $fid = $nv_Request->get_int('fid', 'post', 0); $new_vid = $nv_Request->get_int('new_vid', 'post', 0); - + $query = 'SELECT COUNT(*) FROM ' . $db_config['prefix'] . '_' . $module_data . '_field WHERE fid=' . $fid; $numrows = $db->query($query)->fetchColumn(); if ($numrows != 1) { die('NO'); } - + $query = 'SELECT fid FROM ' . $db_config['prefix'] . '_' . $module_data . '_field WHERE fid!=' . $fid . ' ORDER BY weight ASC'; $result = $db->query($query); $weight = 0; while ($row = $result->fetch()) { - ++$weight; + ++ $weight; if ($weight == $new_vid) { - ++$weight; + ++ $weight; } $sql = 'UPDATE ' . $db_config['prefix'] . '_' . $module_data . '_field SET weight=' . $weight . ' WHERE fid=' . $row['fid']; $db->query($sql); @@ -77,20 +76,20 @@ // lay du lieu sql if ($nv_Request->isset_request('choicesql', 'post')) { - if (!defined('NV_IS_AJAX')) { + if (! defined('NV_IS_AJAX')) { die('Wrong URL'); } - + $array_choicesql = array( 'module' => 'table', 'table' => 'column' ); $choice = $nv_Request->get_string('choice', 'post', ''); $choice_seltected = $nv_Request->get_string('choice_seltected', 'post', ''); - + $xtpl = new XTemplate('fields.tpl', NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $module_file); $xtpl->assign('LANG', $lang_module); - + if ($choice == 'module') { $xtpl->assign('choicesql_name', 'choicesql_' . $choice); $xtpl->assign('choicesql_next', $array_choicesql[$choice]); @@ -112,11 +111,11 @@ } $_items = $db->query("SHOW TABLE STATUS LIKE '%\_" . $module . "%'")->fetchAll(); $num_table = sizeof($_items); - - $array_table_module = array( ); + + $array_table_module = array(); $xtpl->assign('choicesql_name', 'choicesql_' . $choice); $xtpl->assign('choicesql_next', $array_choicesql[$choice]); - + if ($num_table > 0) { $xtpl->parse('choicesql.loop'); foreach ($_items as $item) { @@ -135,11 +134,11 @@ if ($table == '') { exit(); } - + $_items = $db->columns_array($table); $num_table = sizeof($_items); - - $array_table_module = array( ); + + $array_table_module = array(); $xtpl->assign('choicesql_name', 'choicesql_' . $choice); $xtpl->assign('choicesql_next', $array_choicesql[$choice]); if ($num_table > 0) { @@ -158,16 +157,16 @@ $xtpl->parse('column'); $contents = $xtpl->text('column'); } - + include NV_ROOTDIR . '/includes/header.php'; echo $contents; include NV_ROOTDIR . '/includes/footer.php'; } -//ADD +// ADD $text_fields = $number_fields = $date_fields = $choice_fields = $choice_type_sql = $choice_type_text = 0; $error = ''; -$field_choices = array( ); +$field_choices = array(); if ($nv_Request->isset_request('submit', 'post')) { $validatefield = array( 'pattern' => '/[^a-zA-Z\_]/', @@ -177,43 +176,43 @@ 'pattern' => '/[^a-zA-Z0-9\_]/', 'replacement' => '' ); - - $dataform = array( ); + + $dataform = array(); $dataform['fid'] = $nv_Request->get_int('fid', 'post', 0); $dataform['sql_choices'] = ''; $dataform['class'] = ''; - - $templateids = array_unique($nv_Request->get_typed_array('templateid', 'post', 'int', array( ))); - - if (!empty($templateids)) { + + $templateids = array_unique($nv_Request->get_typed_array('templateid', 'post', 'int', array())); + + if (! empty($templateids)) { $dataform['listtemplate'] = implode(",", $templateids); } else { $dataform['listtemplate'] = ''; } - + if (empty($dataform['listtemplate'])) { $error = $lang_module['field_error_template']; } - + $dataform['title'] = $nv_Request->get_title('title', 'post', ''); $dataform['description'] = $nv_Request->get_title('description', 'post', ''); - + $dataform['field_type'] = nv_substr($nv_Request->get_title('field_type', 'post', '', 0, $preg_replace), 0, 50); - + $save = 0; - $language = array( ); + $language = array(); if ($dataform['fid']) { $dataform_old = $db->query('SELECT * FROM ' . $db_config['prefix'] . '_' . $module_data . '_field WHERE fid=' . $dataform['fid'])->fetch(); $dataform['field_type'] = $dataform_old['field_type']; - if (!empty($dataform['language'])) { + if (! empty($dataform['language'])) { $language = unserialize($dataform['language']); } $dataform['field'] = $dataform['fieldid'] = nv_substr($nv_Request->get_title('fieldid', 'post', '', 0, $preg_replace), 0, 50); } else { $dataform['field'] = nv_substr($nv_Request->get_title('field', 'post', '', 0, $validatefield), 0, 50); - + require_once NV_ROOTDIR . '/includes/field_not_allow.php'; - + if (in_array($dataform['field'], $field_not_allow)) { $error = $lang_module['field_error_not_allow']; } elseif (empty($dataform['field'])) { @@ -228,38 +227,38 @@ } } } - + $language = unserialize($dataform_old['language']); $language[NV_LANG_DATA] = array( $dataform['title'], $dataform['description'] ); - + if ($dataform['field_type'] == 'textbox' || $dataform['field_type'] == 'textarea' || $dataform['field_type'] == 'editor') { $text_fields = 1; $dataform['match_type'] = nv_substr($nv_Request->get_title('match_type', 'post', '', 0, $preg_replace), 0, 50); $dataform['match_regex'] = ($dataform['match_type'] == 'regex') ? $nv_Request->get_string('match_regex', 'post', '', false) : ''; $dataform['func_callback'] = ($dataform['match_type'] == 'callback') ? $nv_Request->get_string('match_callback', 'post', '', false) : ''; - if ($dataform['func_callback'] != '' and !function_exists($dataform['func_callback'])) { + if ($dataform['func_callback'] != '' and ! function_exists($dataform['func_callback'])) { $dataform['func_callback'] = ''; } - + if ($dataform['field_type'] == 'editor') { $dataform['editor_width'] = $nv_Request->get_string('editor_width', 'post', '100%', 0); $dataform['editor_height'] = $nv_Request->get_string('editor_height', 'post', '300px', 0); - if (!preg_match('/^([0-9]+)(\%|px)+$/', $dataform['editor_width'])) { + if (! preg_match('/^([0-9]+)(\%|px)+$/', $dataform['editor_width'])) { $dataform['editor_width'] = '100%'; } - if (!preg_match('/^([0-9]+)(\%|px)+$/', $dataform['editor_height'])) { + if (! preg_match('/^([0-9]+)(\%|px)+$/', $dataform['editor_height'])) { $dataform['editor_height'] = '300px'; } $dataform['class'] = $dataform['editor_width'] . '@' . $dataform['editor_height']; } - + $dataform['min_length'] = $nv_Request->get_int('min_length', 'post', 255); $dataform['max_length'] = $nv_Request->get_int('max_length', 'post', 255); $dataform['default_value'] = $nv_Request->get_title('default_value', 'post', ''); - + if ($dataform['min_length'] >= $dataform['max_length']) { $error = $lang_module['field_number_error']; } else { @@ -279,14 +278,16 @@ $dataform['max_length'] = $nv_Request->get_int('max_number_length', 'post', 0); $dataform['match_type'] = 'none'; $dataform['match_regex'] = $dataform['func_callback'] = ''; - + $field_choices['number_type'] = $dataform['number_type']; $dataform['default_value'] = $dataform['default_value_number']; - + if ($dataform['min_length'] >= $dataform['max_length']) { $error = $lang_module['field_number_error']; } else { - $dataform['field_choices'] = serialize(array( 'number_type' => $dataform['number_type'] )); + $dataform['field_choices'] = serialize(array( + 'number_type' => $dataform['number_type'] + )); } } elseif ($dataform['field_type'] == 'date') { $date_fields = 1; @@ -300,9 +301,9 @@ } else { $dataform['max_length'] = 0; } - + $dataform['current_date'] = $nv_Request->get_int('current_date', 'post', 0); - if (!$dataform['current_date'] and preg_match('/^([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4})$/', $nv_Request->get_string('default_date', 'post'), $m)) { + if (! $dataform['current_date'] and preg_match('/^([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4})$/', $nv_Request->get_string('default_date', 'post'), $m)) { $dataform['default_value'] = mktime(0, 0, 0, $m[2], $m[1], $m[3]); } else { $dataform['default_value'] = 0; @@ -313,7 +314,9 @@ if ($dataform['min_length'] >= $dataform['max_length']) { $error = $lang_module['field_date_error']; } else { - $dataform['field_choices'] = serialize(array( 'current_date' => $dataform['current_date'] )); + $dataform['field_choices'] = serialize(array( + 'current_date' => $dataform['current_date'] + )); } } else { $dataform['choicetypes'] = $nv_Request->get_string('choicetypes', 'post', ''); @@ -322,10 +325,10 @@ $dataform['min_length'] = 0; $dataform['max_length'] = 255; $dataform['default_value'] = $nv_Request->get_int('default_value_choice', 'post', 0); - + if ($dataform['choicetypes'] == 'field_choicetypes_text') { $dataform['sql_choices'] = ''; - + $field_choice_value = $nv_Request->get_array('field_choice', 'post'); $field_choice_text = $nv_Request->get_array('field_choice_text', 'post'); $field_choices = array_combine(array_map('strip_punctuation', $field_choice_value), array_map('strip_punctuation', $field_choice_text)); @@ -337,13 +340,13 @@ } } else { $choicesql_module = $nv_Request->get_string('choicesql_module', 'post', ''); - //module data + // module data $choicesql_table = $nv_Request->get_string('choicesql_table', 'post', ''); - //table trong module + // table trong module $choicesql_column_key = $nv_Request->get_string('choicesql_column_key', 'post', ''); - //cot value cho fields + // cot value cho fields $choicesql_column_val = $nv_Request->get_string('choicesql_column_val', 'post', ''); - //cot key cho fields + // cot key cho fields $dataform['sql_choices'] = ''; if ($choicesql_module != '' && $choicesql_table != '' && $choicesql_column_key != '' && $choicesql_column_val != '') { $dataform['sql_choices'] = $choicesql_module . ',' . $choicesql_table . ',' . $choicesql_column_key . ',' . $choicesql_column_val; @@ -352,15 +355,15 @@ } } } - + if (empty($error)) { if (empty($dataform['fid'])) { // Them truong du lieu moi - - if ($dataform['max_length'] <= 4294967296 and !empty($dataform['field']) and !empty($dataform['title'])) { + + if ($dataform['max_length'] <= 4294967296 and ! empty($dataform['field']) and ! empty($dataform['title'])) { $weight = $db->query('SELECT MAX(weight) FROM ' . $db_config['prefix'] . '_' . $module_data . '_field')->fetchColumn(); $weight = intval($weight) + 1; - + $sql = "INSERT INTO " . $db_config['prefix'] . '_' . $module_data . "_field (field,listtemplate, weight, field_type, field_choices, sql_choices, match_type, match_regex, func_callback, min_length, max_length, @@ -369,15 +372,15 @@ class, language, default_value) VALUES '" . $dataform['match_regex'] . "', '" . $dataform['func_callback'] . "', " . $dataform['min_length'] . ", " . $dataform['max_length'] . ", '" . $dataform['class'] . "', '" . serialize($language) . "', :default_value)"; - - $data_insert = array( ); + + $data_insert = array(); $data_insert['default_value'] = $dataform['default_value']; $dataform['fid'] = $db->insert_id($sql, 'fid', $data_insert); - + if ($dataform['fid']) { $type_date = nv_get_data_type($dataform); nv_create_form_file($templateids); - + Header('Location: ' . NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $op . '&rand=' . nv_genpass()); die(); } @@ -385,12 +388,12 @@ class, language, default_value) VALUES } elseif ($dataform['max_length'] <= 4294967296) { try { $query = "UPDATE " . $db_config['prefix'] . '_' . $module_data . "_field SET"; - + if ($text_fields == 1) { $query .= " match_type='" . $dataform['match_type'] . "', match_regex='" . $dataform['match_regex'] . "', func_callback='" . $dataform['func_callback'] . "', "; } - + $query .= " max_length=" . $dataform['max_length'] . ", min_length=" . $dataform['min_length'] . ", listtemplate = '" . $dataform['listtemplate'] . "', field_choices='" . $dataform['field_choices'] . "', @@ -399,11 +402,11 @@ class = '" . $dataform['class'] . "', language='" . serialize($language) . "', default_value= :default_value WHERE fid = " . $dataform['fid']; - + $stmt = $db->prepare($query); $stmt->bindParam(':default_value', $dataform['default_value'], PDO::PARAM_STR, strlen($dataform['default_value'])); $save = $stmt->execute(); - + if ($save) { nv_create_form_file($templateids); } @@ -418,27 +421,30 @@ class = '" . $dataform['class'] . "', // DEL if ($nv_Request->isset_request('del', 'post')) { - if (!defined('NV_IS_AJAX')) { + if (! defined('NV_IS_AJAX')) { die('Wrong URL'); } - + $fid = $nv_Request->get_int('fid', 'post,get', 0); - - list($fid, $listtemplate, $field, $weight) = $db->query('SELECT fid,listtemplate, field, weight FROM ' . $db_config['prefix'] . '_' . $module_data . '_field WHERE fid=' . $fid)->fetch(3); - if ($fid and !empty($field)) { + + list ($fid, $listtemplate, $field, $weight) = $db->query('SELECT fid,listtemplate, field, weight FROM ' . $db_config['prefix'] . '_' . $module_data . '_field WHERE fid=' . $fid)->fetch(3); + if ($fid and ! empty($field)) { $query1 = 'DELETE FROM ' . $db_config['prefix'] . '_' . $module_data . '_field WHERE fid=' . $fid; if ($db->query($query1)) { $query = 'SELECT fid FROM ' . $db_config['prefix'] . '_' . $module_data . '_field WHERE weight > ' . $weight . ' ORDER BY weight ASC'; $result = $db->query($query); while ($row = $result->fetch()) { $db->query('UPDATE ' . $db_config['prefix'] . '_' . $module_data . '_field SET weight=' . $weight . ' WHERE fid=' . $row['fid']); - ++$weight; + ++ $weight; } - nv_create_form_file($listtemplate); + $del_array = array( + $listtemplate + ); + nv_create_form_file($del_array); die('OK'); } } - + die('NO'); } @@ -473,21 +479,27 @@ class = '" . $dataform['class'] . "', // Danh sach $show_view = false; -if (!$nv_Request->isset_request('id', 'post,get')) { +if (! $nv_Request->isset_request('id', 'post,get')) { $show_view = true; - + $per_page = 60; - + $page = $nv_Request->get_int('page', 'post,get', 1); $xtpl->assign('page', $page); $base_url = NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $op; - - $db->sqlreset()->select('COUNT(*)')->from('' . $db_config['prefix'] . '_' . $module_data . '_field'); - - $num_items = $db->query($db->sql())->fetchColumn(); - - $db->select('*')->order('weight ASC')->limit($per_page)->offset(($page - 1) * $per_page); - + + $db->sqlreset() + ->select('COUNT(*)') + ->from('' . $db_config['prefix'] . '_' . $module_data . '_field'); + + $num_items = $db->query($db->sql()) + ->fetchColumn(); + + $db->select('*') + ->order('weight ASC') + ->limit($per_page) + ->offset(($page - 1) * $per_page); + $sth = $db->prepare($db->sql()); $sth->execute(); } @@ -501,8 +513,8 @@ class = '" . $dataform['class'] . "', 'field_lang' => (isset($language[NV_LANG_DATA])) ? $language[NV_LANG_DATA][0] : '', 'field_type' => $array_field_type[$row['field_type']] )); - - for ($i = 1; $i <= $num_items; ++$i) { + + for ($i = 1; $i <= $num_items; ++ $i) { $xtpl->assign('WEIGHT', array( 'key' => $i, 'title' => $i, @@ -510,24 +522,24 @@ class = '" . $dataform['class'] . "', )); $xtpl->parse('main.data.loop.weight'); } - + $xtpl->parse('main.data.loop'); } - + $xtpl->assign('NV_GENERATE_PAGE', nv_generate_page($base_url, $num_items, $per_page, $page)); $xtpl->parse('main.data'); } } $fid = $nv_Request->get_int('fid', 'get,post', 0); -if (!isset($dataform)) { +if (! isset($dataform)) { if ($fid) { $dataform = $db->query('SELECT * FROM ' . $db_config['prefix'] . '_' . $module_data . '_field WHERE fid=' . $fid)->fetch(); - - if (!empty($dataform['field_choices'])) { + + if (! empty($dataform['field_choices'])) { $field_choices = unserialize($dataform['field_choices']); } - if (!empty($dataform['language'])) { + if (! empty($dataform['language'])) { $language = unserialize($dataform['language']); if (isset($language[NV_LANG_DATA])) { $dataform['title'] = $language[NV_LANG_DATA][0]; @@ -537,7 +549,7 @@ class = '" . $dataform['class'] . "', $dataform['fieldid'] = $dataform['field']; $dataform['default_value_number'] = $dataform['default_value']; } else { - $dataform = array( ); + $dataform = array(); $dataform['field_type'] = 'textbox'; $dataform['match_type'] = 'none'; $dataform['min_length'] = 0; @@ -573,7 +585,7 @@ class = '" . $dataform['class'] . "', $dataform['max_date'] = empty($dataform['max_length']) ? '' : date('d/m/Y', $dataform['max_length']); } else { $choice_fields = 1; - if (!empty($dataform['sql_choices'])) { + if (! empty($dataform['sql_choices'])) { $choice_type_sql = 1; $sql_data_choice = explode(',', $dataform['sql_choices']); $xtpl->assign('SQL_DATA_CHOICE', $sql_data_choice); @@ -584,11 +596,11 @@ class = '" . $dataform['class'] . "', } if ($fid == 0 or $text_fields == 0) { $number = 1; - if (!empty($field_choices)) { + if (! empty($field_choices)) { foreach ($field_choices as $key => $value) { $xtpl->assign('FIELD_CHOICES', array( 'checked' => ($number == $dataform['default_value']) ? ' checked="checked"' : '', - "number" => $number++, + "number" => $number ++, 'key' => $key, 'value' => $value )); @@ -627,7 +639,7 @@ class = '" . $dataform['class'] . "', $xtpl->parse('main.load.field_type.loop'); } $xtpl->parse('main.load.field_type'); - + foreach ($array_choice_type as $key => $value) { $xtpl->assign('CHOICE_TYPES', array( 'key' => $key, @@ -643,9 +655,9 @@ class = '" . $dataform['class'] . "', Header('Location: ' . NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=fields'); die(); } - + $xtpl->assign('FIELD_TYPE_TEXT', $array_field_type[$dataform['field_type']]); - if ((!empty($dataform['sql_choices']))) { + if ((! empty($dataform['sql_choices']))) { $xtpl->assign('choicetypes_add_hidden', 'field_choicetypes_sql'); $xtpl->assign('FIELD_TYPE_SQL', $array_choice_type['field_choicetypes_sql']); } else { @@ -654,7 +666,7 @@ class = '" . $dataform['class'] . "', } $xtpl->parse('main.load.choicetypes_add_hidden'); } -$array_match_type = array( ); +$array_match_type = array(); $array_match_type['none'] = $lang_module['field_match_type_none']; if ($dataform['field_type'] != 'editor' and $dataform['field_type'] != 'textarea') { $array_match_type['alphanumeric'] = $lang_module['field_match_type_alphanumeric']; @@ -671,14 +683,14 @@ class = '" . $dataform['class'] . "', "checked" => ($dataform['match_type'] == $key) ? ' checked="checked"' : '', "match_disabled" => ($dataform['match_type'] != $key) ? ' disabled="disabled"' : '' )); - + if ($key == 'regex' or $key == 'callback') { $xtpl->parse('main.load.match_type.match_input'); } $xtpl->parse('main.load.match_type'); } -if (!empty($error)) { +if (! empty($error)) { $xtpl->assign('ERROR', $error); $xtpl->parse('main.load.error'); } diff --git a/modules/shops/functions.php b/modules/shops/functions.php index 006d788f2..573bce01f 100644 --- a/modules/shops/functions.php +++ b/modules/shops/functions.php @@ -7,7 +7,6 @@ * @License GNU/GPL version 2 or any later version * @Createdate 12/31/2009 0:51 */ - if (! defined('NV_SYSTEM')) { die('Stop!!!'); } @@ -34,8 +33,8 @@ // Categories foreach ($global_array_shops_cat as $row) { - $global_array_shops_cat[$row['catid']]['link'] = NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $row['alias']; - + $global_array_shops_cat[$row['catid']]['link'] = NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $row['alias']; + if ($alias_cat_url == $row['alias']) { $catid = $row['catid']; $parentid = $row['parentid']; @@ -57,7 +56,7 @@ if ($op == 'main') { if (empty($catid)) { if (preg_match('/^page\-([0-9]+)$/', (isset($array_op[0]) ? $array_op[0] : ''), $m)) { - $page = ( int )$m[1]; + $page = (int) $m[1]; } } else { if (sizeof($array_op) == 2 and preg_match('/^([a-z0-9\-]+)$/i', $array_op[1]) and ! preg_match('/^page\-([0-9]+)$/', $array_op[1], $m2)) { @@ -66,7 +65,7 @@ } else { $op = 'viewcat'; } - + $parentid = $catid; while ($parentid > 0) { $array_cat_i = $global_array_shops_cat[$parentid]; @@ -92,35 +91,36 @@ /** * GetDataIn() * - * @param mixed $result - * @param mixed $catid + * @param mixed $result + * @param mixed $catid * @return + * */ function GetDataIn($result, $catid) { global $global_array_shops_cat, $module_name, $module_file, $module_upload, $db, $link, $module_info, $global_config; - + $data_content = array(); $data = array(); - while (list($id, $listcatid, $publtime, $title, $alias, $hometext, $homeimgalt, $homeimgfile, $homeimgthumb, $product_code, $product_number, $product_price, $money_unit, $discount_id, $showprice, $gift_content, $gift_from, $gift_to, $newday) = $result->fetch(3)) { + while (list ($id, $listcatid, $publtime, $title, $alias, $hometext, $homeimgalt, $homeimgfile, $homeimgthumb, $product_code, $product_number, $product_price, $money_unit, $discount_id, $showprice, $gift_content, $gift_from, $gift_to, $newday) = $result->fetch(3)) { if ($homeimgthumb == 1) { - //image thumb - + // image thumb + $thumb = NV_BASE_SITEURL . NV_FILES_DIR . '/' . $module_upload . '/' . $homeimgfile; } elseif ($homeimgthumb == 2) { - //image file - + // image file + $thumb = NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $module_upload . '/' . $homeimgfile; } elseif ($homeimgthumb == 3) { - //image url - + // image url + $thumb = $homeimgfile; } else { - //no image - + // no image + $thumb = NV_BASE_SITEURL . 'themes/' . $module_info['template'] . '/images/' . $module_file . '/no-image.jpg'; } - + $data[] = array( 'id' => $id, 'listcatid' => $listcatid, @@ -137,56 +137,57 @@ function GetDataIn($result, $catid) 'money_unit' => $money_unit, 'showprice' => $showprice, 'newday' => $newday, - 'gift_content'=> $gift_content, - 'gift_from'=> $gift_from, - 'gift_to'=> $gift_to, + 'gift_content' => $gift_content, + 'gift_from' => $gift_from, + 'gift_to' => $gift_to, 'link_pro' => $link . $global_array_shops_cat[$listcatid]['alias'] . '/' . $alias . $global_config['rewrite_exturl'], 'link_order' => $link . 'setcart&id=' . $id ); } - + $data_content['id'] = $catid; $data_content['title'] = $global_array_shops_cat[$catid]['title']; $data_content['image'] = $global_array_shops_cat[$catid]['image']; $data_content['data'] = $data; $data_content['alias'] = $global_array_shops_cat[$catid]['alias']; - + return $data_content; } /** * GetDataInGroup() * - * @param mixed $result - * @param mixed $groupid + * @param mixed $result + * @param mixed $groupid * @return + * */ function GetDataInGroups($result, $array_g) { global $global_array_group, $module_name, $module_file, $module_upload, $db, $link, $module_info, $global_array_shops_cat, $global_config; - + $data_content = array(); $data = array(); - - while (list($id, $listcatid, $publtime, $title, $alias, $hometext, $homeimgalt, $homeimgfile, $homeimgthumb, $product_code, $product_number, $product_price, $money_unit, $discount_id, $showprice, $gift_content, $newday) = $result->fetch(3)) { + + while (list ($id, $listcatid, $publtime, $title, $alias, $hometext, $homeimgalt, $homeimgfile, $homeimgthumb, $product_code, $product_number, $product_price, $money_unit, $discount_id, $showprice, $gift_content, $newday) = $result->fetch(3)) { if ($homeimgthumb == 1) { - //image thumb - + // image thumb + $thumb = NV_BASE_SITEURL . NV_FILES_DIR . '/' . $module_upload . '/' . $homeimgfile; } elseif ($homeimgthumb == 2) { - //image file - + // image file + $thumb = NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $module_upload . '/' . $homeimgfile; } elseif ($homeimgthumb == 3) { - //image url - + // image url + $thumb = $homeimgfile; } else { - //no image - + // no image + $thumb = NV_BASE_SITEURL . 'themes/' . $module_info['template'] . '/images/' . $module_file . '/no-image.jpg'; } - + $data[] = array( 'id' => $id, 'listcatid' => $listcatid, @@ -208,48 +209,49 @@ function GetDataInGroups($result, $array_g) 'link_order' => $link . 'setcart&id=' . $id ); } - + $data_content['id'] = $array_g[0]; $data_content['title'] = $global_array_group[$array_g[0]]['title']; $data_content['data'] = $data; $data_content['alias'] = $global_array_group[$array_g[0]]['alias']; - + return $data_content; } /** * GetDataInGroup() * - * @param mixed $result - * @param mixed $groupid + * @param mixed $result + * @param mixed $groupid * @return + * */ function GetDataInGroup($result, $groupid) { global $global_array_group, $module_name, $module_file, $module_upload, $db, $link, $module_info, $global_array_shops_cat, $global_config; - + $data_content = array(); $data = array(); - - while (list($id, $listcatid, $publtime, $title, $alias, $hometext, $homeimgalt, $homeimgfile, $homeimgthumb, $product_code, $product_number, $product_price, $money_unit, $discount_id, $showprice, $gift_content, $gift_to, $gift_from) = $result->fetch(3)) { + + while (list ($id, $listcatid, $publtime, $title, $alias, $hometext, $homeimgalt, $homeimgfile, $homeimgthumb, $product_code, $product_number, $product_price, $money_unit, $discount_id, $showprice, $gift_content, $gift_to, $gift_from) = $result->fetch(3)) { if ($homeimgthumb == 1) { - //image thumb - + // image thumb + $thumb = NV_BASE_SITEURL . NV_FILES_DIR . '/' . $module_upload . '/' . $homeimgfile; } elseif ($homeimgthumb == 2) { - //image file - + // image file + $thumb = NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $module_upload . '/' . $homeimgfile; } elseif ($homeimgthumb == 3) { - //image url - + // image url + $thumb = $homeimgfile; } else { - //no image - + // no image + $thumb = NV_BASE_SITEURL . 'themes/' . $module_info['template'] . '/images/' . $module_file . '/no-image.jpg'; } - + $data[] = array( 'id' => $id, 'listcatid' => $listcatid, @@ -273,27 +275,28 @@ function GetDataInGroup($result, $groupid) 'link_order' => $link . 'setcart&id=' . $id ); } - + $data_content['id'] = $groupid; $data_content['title'] = $global_array_group[$groupid]['title']; $data_content['data'] = $data; $data_content['alias'] = $global_array_group[$groupid]['alias']; $data_content['description'] = $global_array_group[$groupid]['description']; $data_content['image'] = $global_array_group[$groupid]['image']; - + return $data_content; } /** * SetSessionProView() * - * @param mixed $id - * @param mixed $title - * @param mixed $alias - * @param mixed $addtime - * @param mixed $link - * @param mixed $homeimgthumb + * @param mixed $id + * @param mixed $title + * @param mixed $alias + * @param mixed $addtime + * @param mixed $link + * @param mixed $homeimgthumb * @return + * */ function SetSessionProView($id, $title, $alias, $addtime, $link, $homeimgthumb) { @@ -315,21 +318,22 @@ function SetSessionProView($id, $title, $alias, $addtime, $link, $homeimgthumb) /** * nv_custom_tpl() * - * @param mixed $name_file - * @param mixed $array_custom - * @param mixed $array_custom_lang - * @param mixed $idtemplate + * @param mixed $name_file + * @param mixed $array_custom + * @param mixed $array_custom_lang + * @param mixed $idtemplate * @return + * */ function nv_custom_tpl($name_file, $array_custom, $array_custom_lang, $idtemplate) { - global $module_data, $module_info, $module_name, $module_file, $lang_module, $db_config, $db, $global_config; - + global $module_data, $module_info, $module_upload, $module_file, $lang_module, $db_config, $db, $global_config; + $sql = 'SELECT * FROM ' . $db_config['prefix'] . '_' . $module_data . '_field'; $result = $db->query($sql); while ($row = $result->fetch()) { $row['tab'] = unserialize($row['tab']); - if (!empty($row['tab'])) { + if (! empty($row['tab'])) { foreach ($row['tab'] as $key => $value) { if ($key == $idtemplate) { $arr[$row['field']] = 1; @@ -337,24 +341,24 @@ function nv_custom_tpl($name_file, $array_custom, $array_custom_lang, $idtemplat } } } - - $html =''; - $xtpl = new XTemplate($name_file, NV_ROOTDIR . '/' . NV_ASSETS_DIR . '/' . $module_name . '/files_tpl'); + + $html = ''; + $xtpl = new XTemplate($name_file, NV_ROOTDIR . '/' . NV_ASSETS_DIR . '/' . $module_upload . '/files_tpl'); $xtpl->assign('CUSTOM_LANG', $array_custom_lang); $xtpl->assign('CUSTOM_DATA', $array_custom); $count = 0; - + foreach ($array_custom as $key => $value) { - if (isset($arr[$key]) and !empty($value)) { - $xtpl->parse('main.'.$key); + if (isset($arr[$key]) and ! empty($value)) { + $xtpl->parse('main.' . $key); $count ++; } } - + if ($count > 0) { $xtpl->parse('main'); $html = $xtpl->text('main'); } - + return $html; } diff --git a/modules/shops/version.php b/modules/shops/version.php index 27c023ea0..38f28d4e2 100644 --- a/modules/shops/version.php +++ b/modules/shops/version.php @@ -7,7 +7,6 @@ * @License GNU/GPL version 2 or any later version * @Createdate 05/07/2010 09:47 */ - if (! defined('NV_ADMIN') or ! defined('NV_MAINFILE')) { die('Stop!!!'); } @@ -17,9 +16,17 @@ 'modfuncs' => 'main,viewcat,detail,search,cart,order,payment,complete,history,group,search_result,compare,wishlist,tag,point,shippingajax,download, blockcat', // Cac function co block 'is_sysmod' => 0, // 1:0 => Co phai la module he thong hay khong 'virtual' => 1, // 1:0 => Co cho phep ao hao module hay khong - 'version' => '4.0.29', // Module Shops 4 - 'date' => 'Fri, 20 May 2016 17:00:00 GMT', // Ngay phat hanh phien ban + 'version' => '4.0.25', // Module Shops 4 Release Candidate 1 + 'date' => 'Sun, 21 Jun 2013 00:50:00 GMT', // Ngay phat hanh phien ban 'author' => 'VINADES (contact@vinades.vn)', // Tac gia 'note' => '', // Ghi chu - 'uploads_dir' => array( $module_upload, $module_upload . '/temp_pic', $module_upload . '/' . date('Y_m'), $module_upload . '/files' ) + 'uploads_dir' => array( + $module_upload, + $module_upload . '/temp_pic', + $module_upload . '/' . date('Y_m'), + $module_upload . '/files' + ), + 'files_dir' => array( + $module_upload . '/files_tpl' + ) ); \ No newline at end of file diff --git a/themes/admin_default/modules/shops/fields.tpl b/themes/admin_default/modules/shops/fields.tpl index a0209be7d..f3e4a0b1b 100644 --- a/themes/admin_default/modules/shops/fields.tpl +++ b/themes/admin_default/modules/shops/fields.tpl @@ -110,7 +110,7 @@
- +