diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..650751b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/.settings +/.project diff --git a/modules/faq/action.php b/modules/faq/action.php new file mode 100644 index 0000000..9083b54 --- /dev/null +++ b/modules/faq/action.php @@ -0,0 +1,60 @@ + \ No newline at end of file diff --git a/modules/faq/admin.functions.php b/modules/faq/admin.functions.php new file mode 100644 index 0000000..5b47e49 --- /dev/null +++ b/modules/faq/admin.functions.php @@ -0,0 +1,140 @@ +sql_query( $sql ); + $list = array(); + while ( $row = $db->sql_fetchrow( $result ) ) + { + $list[$row['parentid']][] = array( // + 'id' => ( int )$row['id'], // + 'parentid' => ( int )$row['parentid'], // + 'title' => $row['title'], // + 'alias' => $row['alias'], // + 'description' => $row['description'], // + 'who_view' => ( int )$row['who_view'], // + 'groups_view' => ! empty( $row['groups_view'] ) ? explode( ",", $row['groups_view'] ) : array(), // + 'weight' => ( int )$row['weight'], // + 'status' => $row['weight'], // + 'name' => $row['title'], // + 'selected' => $parentid == $row['id'] ? " selected=\"selected\"" : "" // + ); + } + + if ( empty( $list ) ) + { + return $list; + } + + $list2 = array(); + foreach ( $list[0] as $value ) + { + if ( $value['id'] != $m ) + { + $list2[$value['id']] = $value; + if ( isset( $list[$value['id']] ) ) + { + $list2 = nv_setcats( $list2, $value['id'], $list, $m ); + } + } + } + + return $list2; +} + +/** + * nv_update_keywords() + * + * @param mixed $catid + * @return + */ +function nv_update_keywords( $catid ) +{ + global $db, $module_data; + + $content = array(); + + $sql = "SELECT * FROM `" . NV_PREFIXLANG . "_" . $module_data . "` WHERE `catid`=" . $catid . " AND `status`=1"; + $result = $db->sql_query( $sql ); + + while ( $row = $db->sql_fetchrow( $result ) ) + { + $content[] = $row['title'] . " " . $row['question'] . " " . $row['answer']; + } + + $content = implode( " ", $content ); + + $keywords = nv_get_keywords( $content ); + + if ( ! empty( $keywords ) ) + { + $db->sql_query( "UPDATE `" . NV_PREFIXLANG . "_" . $module_data . "_categories` SET `keywords`=" . $db->dbescape( $keywords ) . " WHERE `id`=" . $catid ); + } + + return $keywords; +} + +?> \ No newline at end of file diff --git a/modules/faq/admin/.htaccess b/modules/faq/admin/.htaccess new file mode 100644 index 0000000..3418e55 --- /dev/null +++ b/modules/faq/admin/.htaccess @@ -0,0 +1 @@ +deny from all \ No newline at end of file diff --git a/modules/faq/admin/cat.php b/modules/faq/admin/cat.php new file mode 100644 index 0000000..0ec3b25 --- /dev/null +++ b/modules/faq/admin/cat.php @@ -0,0 +1,621 @@ +sql_query( $sql ); + $weight = 0; + while ( $row = $db->sql_fetchrow( $result ) ) + { + ++$weight; + $db->sql_query( "UPDATE `" . NV_PREFIXLANG . "_" . $module_data . "_categories` SET `weight`=" . $weight . " WHERE `id`=" . $row['id'] ); + } +} + +/** + * nv_del_cat() + * + * @param mixed $catid + * @return + */ +function nv_del_cat( $catid ) +{ + global $db, $module_data; + + $sql = "DELETE FROM `" . NV_PREFIXLANG . "_" . $module_data . "` WHERE `catid`=" . $catid; + $db->sql_query( $sql ); + + $sql = "SELECT `id` FROM `" . NV_PREFIXLANG . "_" . $module_data . "_categories` WHERE `parentid`=" . $catid; + $result = $db->sql_query( $sql ); + while ( list( $id ) = $db->sql_fetchrow( $result ) ) + { + nv_del_cat( $id ); + } + + $sql = "DELETE FROM `" . NV_PREFIXLANG . "_" . $module_data . "_categories` WHERE `id`=" . $catid; + $db->sql_query( $sql ); +} + +$groups_list = nv_groups_list(); +$array_who = array( $lang_global['who_view0'], $lang_global['who_view1'], $lang_global['who_view2'] ); +if ( ! empty( $groups_list ) ) +{ + $array_who[] = $lang_global['who_view3']; +} + +$array = array(); +$error = ""; + +//them chu de +if ( $nv_Request->isset_request( 'add', 'get' ) ) +{ + $page_title = $lang_module['faq_addcat_titlebox']; + + $is_error = false; + + if ( $nv_Request->isset_request( 'submit', 'post' ) ) + { + $array['parentid'] = $nv_Request->get_int( 'parentid', 'post', 0 ); + $array['title'] = filter_text_input( 'title', 'post', '', 1 ); + $array['description'] = filter_text_input( 'description', 'post', '' ); + $array['who_view'] = $nv_Request->get_int( 'who_view', 'post', 0 ); + $array['groups_view'] = $nv_Request->get_typed_array( 'groups_view', 'post', 'int' ); + + $alias = change_alias( $array['title'] ); + + if ( empty( $array['title'] ) ) + { + $error = $lang_module['faq_error_cat2']; + $is_error = true; + } + else + { + if ( ! empty( $array['parentid'] ) ) + { + $sql = "SELECT COUNT(*) AS count FROM `" . NV_PREFIXLANG . "_" . $module_data . "_categories` WHERE `id`=" . $array['parentid']; + $result = $db->sql_query( $sql ); + list( $count ) = $db->sql_fetchrow( $result ); + + if ( ! $count ) + { + $error = $lang_module['faq_error_cat3']; + $is_error = true; + } + } + + if ( ! $is_error ) + { + $sql = "SELECT COUNT(*) AS count FROM `" . NV_PREFIXLANG . "_" . $module_data . "_categories` WHERE `alias`=" . $db->dbescape( $alias ); + $result = $db->sql_query( $sql ); + list( $count ) = $db->sql_fetchrow( $result ); + + if ( $count ) + { + $error = $lang_module['faq_error_cat1']; + $is_error = true; + } + } + } + + if ( ! $is_error ) + { + if ( ! in_array( $array['who_view'], array_keys( $array_who ) ) ) + { + $array['who_view'] = 0; + } + + $array['groups_view'] = ( ! empty( $array['groups_view'] ) ) ? implode( ',', $array['groups_view'] ) : ''; + + $sql = "SELECT MAX(weight) AS new_weight FROM `" . NV_PREFIXLANG . "_" . $module_data . "_categories` WHERE `parentid`=" . $array['parentid']; + $result = $db->sql_query( $sql ); + list( $new_weight ) = $db->sql_fetchrow( $result ); + $new_weight = ( int )$new_weight; + ++$new_weight; + + $sql = "INSERT INTO `" . NV_PREFIXLANG . "_" . $module_data . "_categories` VALUES ( + NULL, + " . $array['parentid'] . ", + " . $db->dbescape( $array['title'] ) . ", + " . $db->dbescape( $alias ) . ", + " . $db->dbescape( $array['description'] ) . ", + " . $array['who_view'] . ", + " . $db->dbescape( $array['groups_view'] ) . ", + " . $new_weight . ", + 1, '')"; + + $catid = $db->sql_query_insert_id( $sql ); + + if ( ! $catid ) + { + $error = $lang_module['faq_error_cat4']; + $is_error = true; + } + else + { + nv_insert_logs( NV_LANG_DATA, $module_name, 'log_add_cat', "cat ".$catid, $admin_info['userid'] ); + Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=cat" ); + exit(); + } + } + } + else + { + $array['parentid'] = 0; + $array['title'] = ""; + $array['description'] = ""; + $array['who_view'] = 0; + $array['groups_view'] = array(); + } + + $listcats = array( array( 'id' => 0, 'name' => $lang_module['faq_category_cat_maincat'], 'selected' => "" ) ); + $listcats = $listcats + nv_listcats( $array['parentid'] ); + + $who_view = $array['who_view']; + $array['who_view'] = array(); + foreach ( $array_who as $key => $who ) + { + $array['who_view'][] = array( // + 'key' => $key, // + 'title' => $who, // + 'selected' => $key == $who_view ? " selected=\"selected\"" : "" // + ); + } + + $groups_view = $array['groups_view']; + $array['groups_view'] = array(); + if ( ! empty( $groups_list ) ) + { + foreach ( $groups_list as $key => $title ) + { + $array['groups_view'][] = array( // + 'key' => $key, // + 'title' => $title, // + 'checked' => in_array( $key, $groups_view ) ? " checked=\"checked\"" : "" // + ); + } + } + + $xtpl = new XTemplate( "cat_add.tpl", NV_ROOTDIR . "/themes/" . $global_config['module_theme'] . "/modules/" . $module_file ); + $xtpl->assign( 'FORM_ACTION', NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=" . $op . "&add=1" ); + $xtpl->assign( 'LANG', $lang_module ); + $xtpl->assign( 'DATA', $array ); + + if ( ! empty( $error ) ) + { + $xtpl->assign( 'ERROR', $error ); + $xtpl->parse( 'main.error' ); + } + + foreach ( $listcats as $cat ) + { + $xtpl->assign( 'LISTCATS', $cat ); + $xtpl->parse( 'main.parentid' ); + } + + foreach ( $array['who_view'] as $who ) + { + $xtpl->assign( 'WHO_VIEW', $who ); + $xtpl->parse( 'main.who_view' ); + } + + if ( ! empty( $array['groups_view'] ) ) + { + foreach ( $array['groups_view'] as $group ) + { + $xtpl->assign( 'GROUPS_VIEW', $group ); + $xtpl->parse( 'main.group_view_empty.groups_view' ); + } + $xtpl->parse( 'main.group_view_empty' ); + } + + $xtpl->parse( 'main' ); + $contents = $xtpl->text( 'main' ); + + include ( NV_ROOTDIR . "/includes/header.php" ); + echo nv_admin_theme( $contents ); + include ( NV_ROOTDIR . "/includes/footer.php" ); + + exit; +} + +//Sua chu de +if ( $nv_Request->isset_request( 'edit', 'get' ) ) +{ + $page_title = $lang_module['faq_editcat_cat']; + + $catid = $nv_Request->get_int( 'catid', 'get', 0 ); + + if ( empty( $catid ) ) + { + Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=cat" ); + exit(); + } + + $sql = "SELECT * FROM `" . NV_PREFIXLANG . "_" . $module_data . "_categories` WHERE `id`=" . $catid; + $result = $db->sql_query( $sql ); + $numcat = $db->sql_numrows( $result ); + + if ( $numcat != 1 ) + { + Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=cat" ); + exit(); + } + + $row = $db->sql_fetchrow( $result ); + + $is_error = false; + + if ( $nv_Request->isset_request( 'submit', 'post' ) ) + { + $array['parentid'] = $nv_Request->get_int( 'parentid', 'post', 0 ); + $array['title'] = filter_text_input( 'title', 'post', '', 1 ); + $array['description'] = filter_text_input( 'description', 'post', '' ); + $array['who_view'] = $nv_Request->get_int( 'who_view', 'post', 0 ); + $array['groups_view'] = $nv_Request->get_typed_array( 'groups_view', 'post', 'int' ); + + $alias = change_alias( $array['title'] ); + + if ( empty( $array['title'] ) ) + { + $error = $lang_module['faq_error_cat2']; + $is_error = true; + } + else + { + if ( ! empty( $array['parentid'] ) ) + { + $sql = "SELECT COUNT(*) AS count FROM `" . NV_PREFIXLANG . "_" . $module_data . "_categories` WHERE `id`=" . $array['parentid']; + $result = $db->sql_query( $sql ); + list( $count ) = $db->sql_fetchrow( $result ); + + if ( ! $count ) + { + $error = $lang_module['faq_error_cat3']; + $is_error = true; + } + } + + if ( ! $is_error ) + { + $sql = "SELECT COUNT(*) AS count FROM `" . NV_PREFIXLANG . "_" . $module_data . "_categories` WHERE `id`!=" . $catid . " AND `alias`=" . $db->dbescape( $alias ) . " AND `parentid`=" . $array['parentid']; + $result = $db->sql_query( $sql ); + list( $count ) = $db->sql_fetchrow( $result ); + + if ( $count ) + { + $error = $lang_module['faq_error_cat1']; + $is_error = true; + } + } + } + + if ( ! $is_error ) + { + if ( ! in_array( $array['who_view'], array_keys( $array_who ) ) ) + { + $array['who_view'] = 0; + } + + $array['groups_view'] = ( ! empty( $array['groups_view'] ) ) ? implode( ',', $array['groups_view'] ) : ''; + + if ( $array['parentid'] != $row['parentid'] ) + { + $sql = "SELECT MAX(weight) AS new_weight FROM `" . NV_PREFIXLANG . "_" . $module_data . "_categories` WHERE `parentid`=" . $array['parentid']; + $result = $db->sql_query( $sql ); + list( $new_weight ) = $db->sql_fetchrow( $result ); + $new_weight = ( int )$new_weight; + ++$new_weight; + } + else + { + $new_weight = $row['weight']; + } + + $sql = "UPDATE `" . NV_PREFIXLANG . "_" . $module_data . "_categories` SET + `parentid`=" . $array['parentid'] . ", + `title`=" . $db->dbescape( $array['title'] ) . ", + `alias`=" . $db->dbescape( $alias ) . ", + `description`=" . $db->dbescape( $array['description'] ) . ", + `who_view`=" . $array['who_view'] . ", + `groups_view`=" . $db->dbescape( $array['groups_view'] ) . ", + `weight`=" . $new_weight . " + WHERE `id`=" . $catid; + $result = $db->sql_query( $sql ); + + if ( ! $result ) + { + $error = $lang_module['faq_error_cat5']; + $is_error = true; + } + else + { + if ( $array['parentid'] != $row['parentid'] ) + { + nv_FixWeightCat( $row['parentid'] ); + } + + Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=cat" ); + exit(); + } + } + } + else + { + $array['parentid'] = ( int )$row['parentid']; + $array['title'] = $row['title']; + $array['description'] = $row['description']; + $array['who_view'] = ( int )$row['who_view']; + $array['groups_view'] = ! empty( $row['groups_view'] ) ? explode( ",", $row['groups_view'] ) : array(); + } + + $listcats = array( array( 'id' => 0, 'name' => $lang_module['faq_category_cat_maincat'], 'selected' => "" ) ); + $listcats = $listcats + nv_listcats( $array['parentid'], $catid ); + + $who_view = $array['who_view']; + $array['who_view'] = array(); + foreach ( $array_who as $key => $who ) + { + $array['who_view'][] = array( // + 'key' => $key, // + 'title' => $who, // + 'selected' => $key == $who_view ? " selected=\"selected\"" : "" // + ); + } + + $groups_view = $array['groups_view']; + $array['groups_view'] = array(); + if ( ! empty( $groups_list ) ) + { + foreach ( $groups_list as $key => $title ) + { + $array['groups_view'][] = array( // + 'key' => $key, // + 'title' => $title, // + 'checked' => in_array( $key, $groups_view ) ? " checked=\"checked\"" : "" // + ); + } + } + + $xtpl = new XTemplate( "cat_add.tpl", NV_ROOTDIR . "/themes/" . $global_config['module_theme'] . "/modules/" . $module_file ); + $xtpl->assign( 'FORM_ACTION', NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=" . $op . "&edit=1&catid=" . $catid ); + $xtpl->assign( 'LANG', $lang_module ); + $xtpl->assign( 'DATA', $array ); + + if ( ! empty( $error ) ) + { + $xtpl->assign( 'ERROR', $error ); + $xtpl->parse( 'main.error' ); + } + + foreach ( $listcats as $cat ) + { + $xtpl->assign( 'LISTCATS', $cat ); + $xtpl->parse( 'main.parentid' ); + } + + foreach ( $array['who_view'] as $who ) + { + $xtpl->assign( 'WHO_VIEW', $who ); + $xtpl->parse( 'main.who_view' ); + } + + if ( ! empty( $array['groups_view'] ) ) + { + foreach ( $array['groups_view'] as $group ) + { + $xtpl->assign( 'GROUPS_VIEW', $group ); + $xtpl->parse( 'main.group_view_empty.groups_view' ); + } + $xtpl->parse( 'main.group_view_empty' ); + } + + $xtpl->parse( 'main' ); + $contents = $xtpl->text( 'main' ); + + include ( NV_ROOTDIR . "/includes/header.php" ); + echo nv_admin_theme( $contents ); + include ( NV_ROOTDIR . "/includes/footer.php" ); + + exit; +} + +//Xoa chu de +if ( $nv_Request->isset_request( 'del', 'post' ) ) +{ + if ( ! defined( 'NV_IS_AJAX' ) ) die( 'Wrong URL' ); + + $catid = $nv_Request->get_int( 'catid', 'post', 0 ); + + if ( empty( $catid ) ) + { + die( "NO" ); + } + + $sql = "SELECT COUNT(*) AS count, `parentid` FROM `" . NV_PREFIXLANG . "_" . $module_data . "_categories` WHERE `id`=" . $catid; + $result = $db->sql_query( $sql ); + list( $count, $parentid ) = $db->sql_fetchrow( $result ); + + if ( $count != 1 ) + { + die( "NO" ); + } + + nv_del_cat( $catid ); + nv_FixWeightCat( $parentid ); + + die( "OK" ); +} + +//Chinh thu tu chu de +if ( $nv_Request->isset_request( 'changeweight', 'post' ) ) +{ + if ( ! defined( 'NV_IS_AJAX' ) ) die( 'Wrong URL' ); + + $catid = $nv_Request->get_int( 'catid', 'post', 0 ); + $new = $nv_Request->get_int( 'new', 'post', 0 ); + + if ( empty( $catid ) ) die( "NO" ); + + $query = "SELECT `parentid` FROM `" . NV_PREFIXLANG . "_" . $module_data . "_categories` WHERE `id`=" . $catid; + $result = $db->sql_query( $query ); + $numrows = $db->sql_numrows( $result ); + if ( $numrows != 1 ) die( 'NO' ); + list( $parentid ) = $db->sql_fetchrow( $result ); + + $query = "SELECT `id` FROM `" . NV_PREFIXLANG . "_" . $module_data . "_categories` WHERE `id`!=" . $catid . " AND `parentid`=" . $parentid . " ORDER BY `weight` ASC"; + $result = $db->sql_query( $query ); + $weight = 0; + while ( $row = $db->sql_fetchrow( $result ) ) + { + ++$weight; + if ( $weight == $new ) ++$weight; + $sql = "UPDATE `" . NV_PREFIXLANG . "_" . $module_data . "_categories` SET `weight`=" . $weight . " WHERE `id`=" . $row['id']; + $db->sql_query( $sql ); + } + $sql = "UPDATE `" . NV_PREFIXLANG . "_" . $module_data . "_categories` SET `weight`=" . $new . " WHERE `id`=" . $catid; + $db->sql_query( $sql ); + die( "OK" ); +} + +//Kich hoat - dinh chi +if ( $nv_Request->isset_request( 'changestatus', 'post' ) ) +{ + if ( ! defined( 'NV_IS_AJAX' ) ) die( 'Wrong URL' ); + + $catid = $nv_Request->get_int( 'catid', 'post', 0 ); + + if ( empty( $catid ) ) die( "NO" ); + + $query = "SELECT `status` FROM `" . NV_PREFIXLANG . "_" . $module_data . "_categories` WHERE `id`=" . $catid; + $result = $db->sql_query( $query ); + $numrows = $db->sql_numrows( $result ); + if ( $numrows != 1 ) die( 'NO' ); + + list( $status ) = $db->sql_fetchrow( $result ); + $status = $status ? 0 : 1; + + $sql = "UPDATE `" . NV_PREFIXLANG . "_" . $module_data . "_categories` SET `status`=" . $status . " WHERE `id`=" . $catid; + $db->sql_query( $sql ); + die( "OK" ); +} + +//Danh sach chu de +$page_title = $lang_module['faq_catmanager']; + +$pid = $nv_Request->get_int( 'pid', 'get', 0 ); + +$sql = "SELECT * FROM `" . NV_PREFIXLANG . "_" . $module_data . "_categories` WHERE `parentid`=" . $pid . " ORDER BY `weight` ASC"; +$result = $db->sql_query( $sql ); +$num = $db->sql_numrows( $result ); + +if ( ! $num ) +{ + if ( $pid ) + { + Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=cat" ); + } + else + { + Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=cat&add=1" ); + } + exit(); +} + +if ( $pid ) +{ + $sql2 = "SELECT `title`,`parentid` FROM `" . NV_PREFIXLANG . "_" . $module_data . "_categories` WHERE `id`=" . $pid; + $result2 = $db->sql_query( $sql2 ); + list( $parentid, $parentid2 ) = $db->sql_fetchrow( $result2 ); + $caption = sprintf( $lang_module['faq_table_caption2'], $parentid ); + $parentid = "" . $parentid . ""; +} +else +{ + $caption = $lang_module['faq_table_caption1']; + $parentid = $lang_module['faq_category_cat_maincat']; +} + +$list = array(); +$a = 0; + +while ( $row = $db->sql_fetchrow( $result ) ) +{ + $numsub = $db->sql_numrows( $db->sql_query( "SELECT `id` FROM `" . NV_PREFIXLANG . "_" . $module_data . "_categories` WHERE parentid=" . $row['id'] ) ); + if ( $numsub ) + { + $numsub = " (" . $numsub . " " . $lang_module['faq_category_cat_sub'] . ")"; + } + else + { + $numsub = ""; + } + + $weight = array(); + for ( $i = 1; $i <= $num; ++$i ) + { + $weight[$i]['title'] = $i; + $weight[$i]['pos'] = $i; + $weight[$i]['selected'] = ( $i == $row['weight'] ) ? " selected=\"selected\"" : ""; + } + + $class = ( $a % 2 ) ? " class=\"second\"" : ""; + + $list[$row['id']] = array( // + 'id' => ( int )$row['id'], // + 'title' => $row['title'], // + 'titlelink' => NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&catid=" . $row['id'], // + 'numsub' => $numsub, // + 'parentid' => $parentid, // + 'weight' => $weight, // + 'status' => $row['status'] ? " checked=\"checked\"" : "", // + 'class' => $class // + ); + + ++$a; +} + +$xtpl = new XTemplate( "cat_list.tpl", NV_ROOTDIR . "/themes/" . $global_config['module_theme'] . "/modules/" . $module_file ); +$xtpl->assign( 'ADD_NEW_CAT', NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=cat&add=1" ); +$xtpl->assign( 'TABLE_CAPTION', $caption ); +$xtpl->assign( 'GLANG', $lang_global ); +$xtpl->assign( 'LANG', $lang_module ); + +foreach ( $list as $row ) +{ + $xtpl->assign( 'ROW', $row ); + + foreach ( $row['weight'] as $weight ) + { + $xtpl->assign( 'WEIGHT', $weight ); + $xtpl->parse( 'main.row.weight' ); + } + + $xtpl->assign( 'EDIT_URL', NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=cat&edit=1&catid=" . $row['id'] ); + $xtpl->parse( 'main.row' ); +} + +$xtpl->parse( 'main' ); +$contents = $xtpl->text( 'main' ); + +include ( NV_ROOTDIR . "/includes/header.php" ); +echo nv_admin_theme( $contents ); +include ( NV_ROOTDIR . "/includes/footer.php" ); + +?> \ No newline at end of file diff --git a/modules/faq/admin/config.php b/modules/faq/admin/config.php new file mode 100644 index 0000000..dd105a9 --- /dev/null +++ b/modules/faq/admin/config.php @@ -0,0 +1,79 @@ +isset_request( 'submit', 'post' ) ) +{ + $array_config['type_main'] = $nv_Request->get_int( 'type_main', 'post', 0 ); + + foreach ( $array_config as $config_name => $config_value ) + { + $query = "REPLACE INTO `" . NV_PREFIXLANG . "_" . $module_data . "_config` VALUES (" . $db->dbescape( $config_name ) . "," . $db->dbescape( $config_value ) . ")"; + $db->sql_query( $query ); + } + + nv_del_moduleCache( $module_name ); + + Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=" . $op ); + die(); +} + +$array_config['type_main'] = 0; + +$sql = "SELECT `config_name`, `config_value` FROM `" . NV_PREFIXLANG . "_" . $module_data . "_config`"; +$result = $db->sql_query( $sql ); +while ( list( $c_config_name, $c_config_value ) = $db->sql_fetchrow( $result ) ) +{ + $array_config[$c_config_name] = $c_config_value; +} + +// +$type_main = $array_config['type_main']; +$array_config['type_main'] = array(); +$array_config['type_main'][] = array( // + 'key' => 0, // + 'title' => $lang_module['config_type_main_0'], // + 'selected' => 0 == $type_main ? " selected=\"selected\"" : "" // +); +$array_config['type_main'][] = array( // + 'key' => 1, // + 'title' => $lang_module['config_type_main_1'], // + 'selected' => 1 == $type_main ? " selected=\"selected\"" : "" // +); +$array_config['type_main'][] = array( // + 'key' => 2, // + 'title' => $lang_module['config_type_main_2'], // + 'selected' => 2 == $type_main ? " selected=\"selected\"" : "" // +); + +$xtpl = new XTemplate( "config.tpl", NV_ROOTDIR . "/themes/" . $global_config['module_theme'] . "/modules/" . $module_file ); +$xtpl->assign( 'FORM_ACTION', NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=" . $op ); +$xtpl->assign( 'LANG', $lang_module ); +$xtpl->assign( 'DATA', $array_config ); + +// +foreach ( $array_config['type_main'] as $type_main ) +{ + $xtpl->assign( 'TYPE_MAIN', $type_main ); + $xtpl->parse( 'main.type_main' ); +} + +$xtpl->parse( 'main' ); +$contents = $xtpl->text( 'main' ); + +include ( NV_ROOTDIR . "/includes/header.php" ); +echo nv_admin_theme( $contents ); +include ( NV_ROOTDIR . "/includes/footer.php" ); + +?> \ No newline at end of file diff --git a/modules/faq/admin/index.html b/modules/faq/admin/index.html new file mode 100644 index 0000000..e69de29 diff --git a/modules/faq/admin/main.php b/modules/faq/admin/main.php new file mode 100644 index 0000000..7f9f340 --- /dev/null +++ b/modules/faq/admin/main.php @@ -0,0 +1,510 @@ +sql_query( $sql ); + $weight = 0; + while ( $row = $db->sql_fetchrow( $result ) ) + { + ++$weight; + $db->sql_query( "UPDATE `" . NV_PREFIXLANG . "_" . $module_data . "` SET `weight`=" . $weight . " WHERE `id`=" . $row['id'] ); + } +} + +//Add, edit file +if ( $nv_Request->isset_request( 'add', 'get' ) or $nv_Request->isset_request( 'edit', 'get' ) ) +{ + if ( $nv_Request->isset_request( 'edit', 'get' ) ) + { + $id = $nv_Request->get_int( 'id', 'get', 0 ); + + if ( $id ) + { + $query = "SELECT * FROM `" . NV_PREFIXLANG . "_" . $module_data . "` WHERE `id`=" . $id; + $result = $db->sql_query( $query ); + $numrows = $db->sql_numrows( $result ); + if ( $numrows != 1 ) + { + Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name ); + exit(); + } + + define( 'IS_EDIT', true ); + $page_title = $lang_module['faq_editfaq']; + + $row = $db->sql_fetchrow( $result ); + } + else + { + Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name ); + exit(); + } + } + else + { + define( 'IS_ADD', true ); + $page_title = $lang_module['faq_addfaq']; + } + + $groups_list = nv_groups_list(); + $array_who = array( $lang_global['who_view0'], $lang_global['who_view1'], $lang_global['who_view2'] ); + if ( ! empty( $groups_list ) ) + { + $array_who[] = $lang_global['who_view3']; + } + + $array = array(); + $is_error = false; + $error = ""; + + if ( $nv_Request->isset_request( 'submit', 'post' ) ) + { + $array['catid'] = $nv_Request->get_int( 'catid', 'post', 0 ); + $array['title'] = filter_text_input( 'title', 'post', '', 1 ); + $array['question'] = filter_text_textarea( 'question', '', NV_ALLOWED_HTML_TAGS ); + $array['answer'] = nv_editor_filter_textarea( 'answer', '', NV_ALLOWED_HTML_TAGS ); + + $alias = change_alias( $array['title'] ); + + if ( defined( 'IS_ADD' ) ) + { + $sql = "SELECT COUNT(*) FROM `" . NV_PREFIXLANG . "_" . $module_data . "` WHERE `alias`=" . $db->dbescape( $alias ); + $result = $db->sql_query( $sql ); + list( $is_exists ) = $db->sql_fetchrow( $result ); + } + else + { + $sql = "SELECT COUNT(*) FROM `" . NV_PREFIXLANG . "_" . $module_data . "` WHERE `id`!=" . $id . " AND `alias`=" . $db->dbescape( $alias ); + $result = $db->sql_query( $sql ); + list( $is_exists ) = $db->sql_fetchrow( $result ); + } + + if ( empty( $array['title'] ) ) + { + $is_error = true; + $error = $lang_module['faq_error_title']; + } elseif ( $is_exists ) + { + $is_error = true; + $error = $lang_module['faq_title_exists']; + } elseif ( empty( $array['question'] ) ) + { + $is_error = true; + $error = $lang_module['faq_error_question']; + } elseif ( empty( $array['answer'] ) ) + { + $is_error = true; + $error = $lang_module['faq_error_answer']; + } + else + { + $array['question'] = nv_nl2br( $array['question'], "
" ); + $array['answer'] = nv_editor_nl2br( $array['answer'] ); + + if ( defined( 'IS_EDIT' ) ) + { + if ( $array['catid'] != $row['catid'] ) + { + $sql = "SELECT MAX(weight) AS new_weight FROM `" . NV_PREFIXLANG . "_" . $module_data . "` WHERE `catid`=" . $array['catid']; + $result = $db->sql_query( $sql ); + list( $new_weight ) = $db->sql_fetchrow( $result ); + $new_weight = ( int )$new_weight; + ++$new_weight; + } + else + { + $new_weight = $row['weight']; + } + + $sql = "UPDATE `" . NV_PREFIXLANG . "_" . $module_data . "` SET + `catid`=" . $array['catid'] . ", + `title`=" . $db->dbescape( $array['title'] ) . ", + `alias`=" . $db->dbescape( $alias ) . ", + `question`=" . $db->dbescape( $array['question'] ) . ", + `answer`=" . $db->dbescape( $array['answer'] ) . ", + `weight`=" . $new_weight . " + WHERE `id`=" . $id; + $result = $db->sql_query( $sql ); + + if ( ! $result ) + { + $is_error = true; + $error = $lang_module['faq_error_notResult']; + } + else + { + nv_update_keywords( $array['catid'] ); + + if ( $array['catid'] != $row['catid'] ) + { + nv_FixWeight( $row['catid'] ); + nv_update_keywords( $row['catid'] ); + } + + Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name ); + exit(); + } + } elseif ( defined( 'IS_ADD' ) ) + { + $sql = "SELECT MAX(weight) AS new_weight FROM `" . NV_PREFIXLANG . "_" . $module_data . "` WHERE `catid`=" . $array['catid']; + $result = $db->sql_query( $sql ); + list( $new_weight ) = $db->sql_fetchrow( $result ); + $new_weight = ( int )$new_weight; + ++$new_weight; + + $sql = "INSERT INTO `" . NV_PREFIXLANG . "_" . $module_data . "` VALUES ( + NULL, + " . $array['catid'] . ", + " . $db->dbescape( $array['title'] ) . ", + " . $db->dbescape( $alias ) . ", + " . $db->dbescape( $array['question'] ) . ", + " . $db->dbescape( $array['answer'] ) . ", + " . $new_weight . ", + 1, " . NV_CURRENTTIME . ")"; + + if ( ! $db->sql_query_insert_id( $sql ) ) + { + $is_error = true; + $error = $lang_module['faq_error_notResult2']; + } + else + { + nv_update_keywords( $array['catid'] ); + + Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name ); + exit(); + } + } + } + } + else + { + if ( defined( 'IS_EDIT' ) ) + { + $array['catid'] = ( int )$row['catid']; + $array['title'] = $row['title']; + $array['answer'] = nv_editor_br2nl( $row['answer'] ); + $array['question'] = nv_br2nl( $row['question'] ); + } + else + { + $array['catid'] = 0; + $array['title'] = $array['answer'] = $array['question'] = ""; + } + } + + if ( ! empty( $array['answer'] ) ) $array['answer'] = nv_htmlspecialchars( $array['answer'] ); + if ( ! empty( $array['question'] ) ) $array['question'] = nv_htmlspecialchars( $array['question'] ); + + $listcats = array(); + $listcats[0] = array( + 'id' => 0, // + 'name' => $lang_module['nocat'], // + 'selected' => $array['catid'] == 0 ? " selected=\"selected\"" : "" // + ); + $listcats = $listcats + nv_listcats( $array['catid'] ); + if ( empty( $listcats ) ) + { + Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=cat&add=1" ); + exit(); + } + + if ( defined( 'NV_EDITOR' ) ) + { + require_once ( NV_ROOTDIR . '/' . NV_EDITORSDIR . '/' . NV_EDITOR . '/nv.php' ); + } + + if ( defined( 'NV_EDITOR' ) and nv_function_exists( 'nv_aleditor' ) ) + { + $array['answer'] = nv_aleditor( 'answer', '100%', '300px', $array['answer'] ); + } + else + { + $array['answer'] = ""; + } + + $xtpl = new XTemplate( "content.tpl", NV_ROOTDIR . "/themes/" . $global_config['module_theme'] . "/modules/" . $module_file ); + + if ( defined( 'IS_EDIT' ) ) + { + $xtpl->assign( 'FORM_ACTION', NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&edit=1&id=" . $id ); + } + else + { + $xtpl->assign( 'FORM_ACTION', NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&add=1" ); + } + + $xtpl->assign( 'LANG', $lang_module ); + $xtpl->assign( 'DATA', $array ); + + if ( ! empty( $error ) ) + { + $xtpl->assign( 'ERROR', $error ); + $xtpl->parse( 'main.error' ); + } + + foreach ( $listcats as $cat ) + { + $xtpl->assign( 'LISTCATS', $cat ); + $xtpl->parse( 'main.catid' ); + } + + $xtpl->parse( 'main' ); + $contents = $xtpl->text( 'main' ); + + include ( NV_ROOTDIR . "/includes/header.php" ); + echo nv_admin_theme( $contents ); + include ( NV_ROOTDIR . "/includes/footer.php" ); + exit(); +} + +//change weight +if ( $nv_Request->isset_request( 'changeweight', 'post' ) ) +{ + if ( ! defined( 'NV_IS_AJAX' ) ) die( 'Wrong URL' ); + + $id = $nv_Request->get_int( 'id', 'post', 0 ); + $new = $nv_Request->get_int( 'new', 'post', 0 ); + + if ( empty( $id ) ) die( "NO" ); + + $query = "SELECT `catid` FROM `" . NV_PREFIXLANG . "_" . $module_data . "` WHERE `id`=" . $id; + $result = $db->sql_query( $query ); + $numrows = $db->sql_numrows( $result ); + if ( $numrows != 1 ) die( 'NO' ); + list( $catid ) = $db->sql_fetchrow( $result ); + + $query = "SELECT `id` FROM `" . NV_PREFIXLANG . "_" . $module_data . "` WHERE `id`!=" . $id . " AND `catid`=" . $catid . " ORDER BY `weight` ASC"; + $result = $db->sql_query( $query ); + $weight = 0; + while ( $row = $db->sql_fetchrow( $result ) ) + { + ++$weight; + if ( $weight == $new ) ++$weight; + $sql = "UPDATE `" . NV_PREFIXLANG . "_" . $module_data . "` SET `weight`=" . $weight . " WHERE `id`=" . $row['id']; + $db->sql_query( $sql ); + } + $sql = "UPDATE `" . NV_PREFIXLANG . "_" . $module_data . "` SET `weight`=" . $new . " WHERE `id`=" . $id; + $db->sql_query( $sql ); + die( "OK" ); +} + +//Kich hoat - dinh chi +if ( $nv_Request->isset_request( 'changestatus', 'post' ) ) +{ + if ( ! defined( 'NV_IS_AJAX' ) ) die( 'Wrong URL' ); + + $id = $nv_Request->get_int( 'id', 'post', 0 ); + + if ( empty( $id ) ) die( "NO" ); + + $query = "SELECT `catid`, `status` FROM `" . NV_PREFIXLANG . "_" . $module_data . "` WHERE `id`=" . $id; + $result = $db->sql_query( $query ); + $numrows = $db->sql_numrows( $result ); + if ( $numrows != 1 ) die( 'NO' ); + + list( $catid, $status ) = $db->sql_fetchrow( $result ); + $status = $status ? 0 : 1; + + $sql = "UPDATE `" . NV_PREFIXLANG . "_" . $module_data . "` SET `status`=" . $status . " WHERE `id`=" . $id; + $db->sql_query( $sql ); + + nv_update_keywords( $catid ); + + die( "OK" ); +} + +//Xoa +if ( $nv_Request->isset_request( 'del', 'post' ) ) +{ + if ( ! defined( 'NV_IS_AJAX' ) ) die( 'Wrong URL' ); + + $id = $nv_Request->get_int( 'id', 'post', 0 ); + + if ( empty( $id ) ) + { + die( "NO" ); + } + + $sql = "SELECT COUNT(*) AS count, `catid` FROM `" . NV_PREFIXLANG . "_" . $module_data . "` WHERE `id`=" . $id; + $result = $db->sql_query( $sql ); + list( $count, $catid ) = $db->sql_fetchrow( $result ); + + if ( $count != 1 ) + { + die( "NO" ); + } + + $sql = "DELETE FROM `" . NV_PREFIXLANG . "_" . $module_data . "` WHERE `id`=" . $id; + $db->sql_query( $sql ); + + nv_update_keywords( $catid ); + + nv_FixWeight( $catid ); + + die( "OK" ); +} + +//List faq +$listcats = array(); +$listcats[0] = array( + 'id' => 0, // + 'name' => $lang_module['nocat'], // + 'title' => $lang_module['nocat'], // + 'selected' => 0 == 0 ? " selected=\"selected\"" : "" // +); +$listcats = $listcats + nv_listcats( 0 ); +if ( empty( $listcats ) ) +{ + Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=cat&add=1" ); + exit(); +} + +$page_title = $lang_module['faq_manager']; + +$page = $nv_Request->get_int( 'page', 'get', 0 ); +$per_page = 30; + +$sql = "SELECT SQL_CALC_FOUND_ROWS * FROM `" . NV_PREFIXLANG . "_" . $module_data . "`"; +$base_url = NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name; + +if ( $nv_Request->isset_request( "catid", "get" ) ) +{ + $catid = $nv_Request->get_int( 'catid', 'get', 0 ); + if ( ! $catid or ! isset( $listcats[$catid] ) ) + { + Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name ); + exit(); + } + + $caption = sprintf( $lang_module['faq_list_by_cat'], $listcats[$catid]['title'] ); + $sql .= " WHERE `catid`=" . $catid . " ORDER BY `weight` ASC"; + $base_url .= "&catid=" . $catid; + + define( 'NV_IS_CAT', true ); +} +else +{ + $caption = $lang_module['faq_manager']; + $sql .= " ORDER BY `id` DESC"; +} + +$sql .= " LIMIT " . $page . ", " . $per_page; + +$query = $db->sql_query( $sql ); + +$result = $db->sql_query( "SELECT FOUND_ROWS()" ); +list( $all_page ) = $db->sql_fetchrow( $result ); + +if ( ! $all_page ) +{ + if ( defined( 'NV_IS_CAT' ) ) + { + $contents = ""; + include ( NV_ROOTDIR . "/includes/header.php" ); + echo nv_admin_theme( $contents ); + include ( NV_ROOTDIR . "/includes/footer.php" ); + exit(); + } + else + { + Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&add=1" ); + exit(); + } +} + +$array = array(); + +while ( $row = $db->sql_fetchrow( $query ) ) +{ + $array[$row['id']] = array( // + 'id' => ( int )$row['id'], // + 'title' => $row['title'], // + 'cattitle' => $listcats[$row['catid']]['title'], // + 'catlink' => NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&catid=" . $row['catid'], // + 'status' => $row['status'] ? " checked=\"checked\"" : "" // + ); + + if ( defined( 'NV_IS_CAT' ) ) + { + $weight = array(); + for ( $i = 1; $i <= $all_page; ++$i ) + { + $weight[$i]['title'] = $i; + $weight[$i]['pos'] = $i; + $weight[$i]['selected'] = ( $i == $row['weight'] ) ? " selected=\"selected\"" : ""; + } + + $array[$row['id']]['weight'] = $weight; + } +} + +$generate_page = nv_generate_page( $base_url, $all_page, $per_page, $page ); + +$xtpl = new XTemplate( "main.tpl", NV_ROOTDIR . "/themes/" . $global_config['module_theme'] . "/modules/" . $module_file ); +$xtpl->assign( 'LANG', $lang_module ); +$xtpl->assign( 'GLANG', $lang_global ); +$xtpl->assign( 'TABLE_CAPTION', $caption ); +$xtpl->assign( 'ADD_NEW_FAQ', NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&add=1" ); + +if ( defined( 'NV_IS_CAT' ) ) +{ + $xtpl->parse( 'main.is_cat1' ); +} + +if ( ! empty( $array ) ) +{ + $a = 0; + foreach ( $array as $row ) + { + $xtpl->assign( 'CLASS', $a % 2 == 1 ? " class=\"second\"" : "" ); + $xtpl->assign( 'ROW', $row ); + + if ( defined( 'NV_IS_CAT' ) ) + { + foreach ( $row['weight'] as $weight ) + { + $xtpl->assign( 'WEIGHT', $weight ); + $xtpl->parse( 'main.row.is_cat2.weight' ); + } + $xtpl->parse( 'main.row.is_cat2' ); + } + + $xtpl->assign( 'EDIT_URL', NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&edit=1&id=" . $row['id'] ); + $xtpl->parse( 'main.row' ); + ++$a; + } +} + +if ( ! empty( $generate_page ) ) +{ + $xtpl->assign( 'GENERATE_PAGE', $generate_page ); + $xtpl->parse( 'main.generate_page' ); +} + +$xtpl->parse( 'main' ); +$contents = $xtpl->text( 'main' ); + +include ( NV_ROOTDIR . "/includes/header.php" ); +echo nv_admin_theme( $contents ); +include ( NV_ROOTDIR . "/includes/footer.php" ); + +?> \ No newline at end of file diff --git a/modules/faq/blocks/.htaccess b/modules/faq/blocks/.htaccess new file mode 100644 index 0000000..3418e55 --- /dev/null +++ b/modules/faq/blocks/.htaccess @@ -0,0 +1 @@ +deny from all \ No newline at end of file diff --git a/modules/faq/blocks/index.html b/modules/faq/blocks/index.html new file mode 100644 index 0000000..e69de29 diff --git a/modules/faq/funcs/.htaccess b/modules/faq/funcs/.htaccess new file mode 100644 index 0000000..3418e55 --- /dev/null +++ b/modules/faq/funcs/.htaccess @@ -0,0 +1 @@ +deny from all \ No newline at end of file diff --git a/modules/faq/funcs/Sitemap.php b/modules/faq/funcs/Sitemap.php new file mode 100644 index 0000000..ec63748 --- /dev/null +++ b/modules/faq/funcs/Sitemap.php @@ -0,0 +1,49 @@ += $pa ) +{ + $url = unserialize( $cache ); +} +else +{ + $list_cats = nv_list_cats(); + $in = array_keys( $list_cats ); + $in = implode( ",", $in ); + + $sql = "SELECT `id`, `catid`, `addtime` + FROM `" . NV_PREFIXLANG . "_" . $module_data . "` WHERE `catid` IN (" . $in . ") + AND `status`=1 ORDER BY `weight` ASC LIMIT 1000"; + $result = $db->sql_query( $sql ); + + while ( list( $id, $cid, $publtime ) = $db->sql_fetchrow( $result ) ) + { + $url[] = array( // + 'link' => NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=" . $list_cats[$cid]['alias'] . "#faq" . $id, // + 'publtime' => $publtime // + ); + } + + $cache = serialize($url); + nv_set_cache( $cacheFile, $cache ); +} + +nv_xmlSitemap_generate( $url ); +die(); + +?> \ No newline at end of file diff --git a/modules/faq/funcs/index.html b/modules/faq/funcs/index.html new file mode 100644 index 0000000..e69de29 diff --git a/modules/faq/funcs/main.php b/modules/faq/funcs/main.php new file mode 100644 index 0000000..f796222 --- /dev/null +++ b/modules/faq/funcs/main.php @@ -0,0 +1,99 @@ +sql_query( $query ); + + $faq = array(); + + while ( list( $fid, $ftitle, $fquestion, $fanswer ) = $db->sql_fetchrow( $result ) ) + { + $faq[$fid] = array( // + 'id' => $fid, // + 'title' => $ftitle, // + 'question' => $fquestion, // + 'answer' => $fanswer // + ); + } + + if ( ! empty( $list_cats[$catid]['keywords'] ) ) + { + $key_words = $list_cats[$catid]['keywords']; + } elseif ( ! empty( $faq ) ) + { + $key_words = update_keywords( $catid, $faq ); + } + + $contents = theme_cat_faq( $list_cats, $catid, $faq, $mod_title ); + + include ( NV_ROOTDIR . "/includes/header.php" ); + echo nv_site_theme( $contents ); + include ( NV_ROOTDIR . "/includes/footer.php" ); + exit(); +} +elseif ( $module_setting['type_main'] == 0 ) +{ + $contents = theme_main_faq( $list_cats, $mod_title ); +} +elseif ( $module_setting['type_main'] == 1 or $module_setting['type_main'] == 2 ) +{ + $order = ( $module_setting['type_main'] == 1 ) ? "DESC" : "ASC"; + + $query = "SELECT `id`,`title`, `question`, `answer` FROM `" . NV_PREFIXLANG . "_" . $module_data . "` WHERE `status`=1 ORDER BY `addtime` " . $order; + $result = $db->sql_query( $query ); + + $faq = array(); + + while ( list( $fid, $ftitle, $fquestion, $fanswer ) = $db->sql_fetchrow( $result ) ) + { + $faq[$fid] = array( // + 'id' => $fid, // + 'title' => $ftitle, // + 'question' => $fquestion, // + 'answer' => $fanswer // + ); + } + + $contents = theme_cat_faq( array(), 0, $faq, $mod_title ); +} +else +{ + nv_info_die( $lang_global['error_404_title'], $lang_global['error_404_title'], $lang_global['error_404_content'] ); +} + +include ( NV_ROOTDIR . "/includes/header.php" ); +echo nv_site_theme( $contents ); +include ( NV_ROOTDIR . "/includes/footer.php" ); + +?> \ No newline at end of file diff --git a/modules/faq/funcs/rss.php b/modules/faq/funcs/rss.php new file mode 100644 index 0000000..67de619 --- /dev/null +++ b/modules/faq/funcs/rss.php @@ -0,0 +1,76 @@ + 0 ) + { + $channel['title'] = $module_name . ' - ' . $list_cats[$catid]['title']; + $channel['link'] = NV_MY_DOMAIN . NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=" . $list_cats[$catid]['alias']; + $channel['description'] = $list_cats[$catid]['description']; + + $sql = "SELECT `id`, `catid`, `title`, `question`, `addtime` + FROM `" . NV_PREFIXLANG . "_" . $module_data . "` WHERE `catid`=" . $catid . " + AND `status`=1 ORDER BY `weight` ASC LIMIT 30"; + } + else + { + $in = array_keys( $list_cats ); + $in = implode( ",", $in ); + $sql = "SELECT `id`, `catid`, `title`, `question`, `addtime` + FROM `" . NV_PREFIXLANG . "_" . $module_data . "` WHERE `catid` IN (" . $in . ") + AND `status`=1 ORDER BY `weight` ASC LIMIT 30"; + } + if ( $module_info['rss'] ) + { + if ( ( $result = $db->sql_query( $sql ) ) !== false ) + { + while ( list( $id, $cid, $title, $question, $addtime ) = $db->sql_fetchrow( $result ) ) + { + $items[] = array( // + 'title' => $title, // + 'link' => NV_MY_DOMAIN . NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=" . $list_cats[$cid]['alias'] . "#faq" . $id, // + 'guid' => $module_name . '_' . $id, // + 'description' => $lang_module['faq_question'] . ": " . $question, // + 'pubdate' => $addtime // + ); + } + } + } +} + +nv_rss_generate( $channel, $items ); +die(); + +?> \ No newline at end of file diff --git a/modules/faq/functions.php b/modules/faq/functions.php new file mode 100644 index 0000000..7b7e7e6 --- /dev/null +++ b/modules/faq/functions.php @@ -0,0 +1,225 @@ +" . $list[$id]['title'] . " » " . $name; + } + else + { + $name = $list[$id]['title'] . " » " . $name; + } + $parentid = $list[$id]['parentid']; + if ( $parentid ) + { + $name = nv_setcats( $parentid, $list, $name, $is_parentlink ); + } + + return $name; +} + +/** + * nv_list_cats() + * + * @param bool $is_link + * @param bool $is_parentlink + * @return + */ +function nv_list_cats( $is_link = false, $is_parentlink = true ) +{ + global $db, $module_data, $module_name, $module_info; + + $sql = "SELECT * FROM `" . NV_PREFIXLANG . "_" . $module_data . "_categories` WHERE `status`=1 ORDER BY `parentid`,`weight` ASC"; + $result = $db->sql_query( $sql ); + + $list = array(); + while ( $row = $db->sql_fetchrow( $result ) ) + { + if ( nv_set_allow( $row['who_view'], $row['groups_view'] ) ) + { + $list[$row['id']] = array( // + 'id' => ( int )$row['id'], // + 'title' => $row['title'], // + 'alias' => $row['alias'], // + 'description' => $row['description'], // + 'parentid' => ( int )$row['parentid'], // + 'subcats' => array(), // + 'keywords' => $row['keywords'] // + ); + } + } + + $list2 = array(); + + if ( ! empty( $list ) ) + { + foreach ( $list as $row ) + { + if ( ! $row['parentid'] or isset( $list[$row['parentid']] ) ) + { + $list2[$row['id']] = $list[$row['id']]; + $list2[$row['id']]['name'] = $list[$row['id']]['title']; + if ( $is_link ) + { + $list2[$row['id']]['name'] = "" . $list2[$row['id']]['name'] . ""; + } + + if ( $row['parentid'] ) + { + $list2[$row['parentid']]['subcats'][] = $row['id']; + + $list2[$row['id']]['name'] = nv_setcats( $row['parentid'], $list, $list2[$row['id']]['name'], $is_parentlink ); + } + + if ( $is_parentlink ) + { + $list2[$row['id']]['name'] = "" . $module_info['custom_title'] . " » " . $list2[$row['id']]['name']; + } + } + } + } + + return $list2; +} + +/** + * initial_config_data() + * + * @return + */ +function initial_config_data ( ) +{ + global $module_data; + + $sql = "SELECT `config_name`,`config_value` FROM `" . NV_PREFIXLANG . "_" . $module_data . "_config`"; + + $list = nv_db_cache( $sql ); + + $module_setting = array(); + foreach ( $list as $values ) + { + $module_setting[$values['config_name']] = $values['config_value']; + } + + return $module_setting; +} + +$module_setting = initial_config_data ( ); + +/** + * update_keywords() + * + * @param mixed $catid + * @param mixed $faq + * @return + */ +function update_keywords( $catid, $faq ) +{ + global $db, $module_data; + + $content = array(); + foreach ( $faq as $row ) + { + $content[] = $row['title'] . " " . $row['question'] . " " . $row['answer']; + } + + $content = implode( " ", $content ); + + $keywords = nv_get_keywords( $content ); + + if ( ! empty( $keywords ) ) + { + $db->sql_query( "UPDATE `" . NV_PREFIXLANG . "_" . $module_data . "_categories` SET `keywords`=" . $db->dbescape( $keywords ) . " WHERE `id`=" . $catid ); + } + + return $keywords; +} + +$alias = ""; +if ( ! empty( $array_op ) ) +{ + $alias = isset( $array_op[0] ) ? $array_op[0] : ""; +} + +$list_cats = nv_list_cats( true ); + +// Xac dinh ID cua chu de +$catid = 0; +foreach ( $list_cats as $c ) +{ + if ( $c['alias'] == $alias ) + { + $catid = intval( $c['id'] ); + break; + } +} +//Het Xac dinh ID cua chu de + +//Xac dinh menu +$nv_vertical_menu = array(); + +//Xac dinh RSS +if ($module_info['rss']) +{ + $rss[] = array( // + 'title' => $module_info['custom_title'], // + 'src' => NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=rss" // + ); +} + +foreach ( $list_cats as $c ) +{ + if ( $c['parentid'] == 0 ) + { + $sub_menu = array(); + $act = ( $c['id'] == $catid ) ? 1 : 0; + if ( $act or ( $catid > 0 and $c['id'] == $list_cats[$catid]['parentid'] ) ) + { + foreach ( $c['subcats'] as $catid_i ) + { + $s_c = $list_cats[$catid_i]; + $s_act = ( $s_c['alias'] == $alias ) ? 1 : 0; + $s_link = NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=" . $s_c['alias']; + $sub_menu[] = array( $s_c['title'], $s_link, $s_act ); + } + } + + $link = NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=" . $c['alias']; + $nv_vertical_menu[] = array( $c['title'], $link, $act, 'submenu' => $sub_menu ); + } + if ($module_info['rss']) + { + $rss[] = array( // + 'title' => $module_info['custom_title'] . ' - ' . $c['title'], // + 'src' => NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=rss/" . $c['alias'] // + ); + } +} +//Het Xac dinh menu +//Het Xac dinh RSS + + +?> \ No newline at end of file diff --git a/modules/faq/index.html b/modules/faq/index.html new file mode 100644 index 0000000..e69de29 diff --git a/modules/faq/js/admin.js b/modules/faq/js/admin.js new file mode 100644 index 0000000..3e9d1c5 --- /dev/null +++ b/modules/faq/js/admin.js @@ -0,0 +1,144 @@ +/* * + * @Project NUKEVIET 3.x + * @Author VINADES.,JSC ( contact@vinades.vn ) + * @Copyright ( C ) 2010 VINADES.,JSC. All rights reserved + * @Createdate 1 - 31 - 2010 5 : 12 + */ + +function nv_cat_del( catid ) +{ + if ( confirm( nv_is_del_confirm[0] ) ) + { + nv_ajax( 'post', script_name, nv_name_variable + '=' + nv_module_name + '&' + nv_fc_variable + '=cat&del=1&catid=' + catid, '', 'nv_cat_del_result' ); + } + return false; +} + +// --------------------------------------- + +function nv_cat_del_result( res ) +{ + if( res == 'OK' ) + { + window.location.href = window.location.href; + } + else + { + alert( nv_is_del_confirm[2] ); + } + return false; +} + +// --------------------------------------- + +function nv_chang_weight( catid ) +{ + var nv_timer = nv_settimeout_disable( 'weight' + catid, 5000 ); + var newpos = document.getElementById( 'weight' + catid ).options[document.getElementById( 'weight' + catid ).selectedIndex].value; + nv_ajax( "post", script_name, nv_name_variable + '=' + nv_module_name + '&' + nv_fc_variable + '=cat&changeweight=1&catid=' + catid + '&new=' + newpos + '&num=' + nv_randomPassword( 8 ), '', 'nv_chang_weight_result' ); + return; +} + +// --------------------------------------- + +function nv_chang_weight_result( res ) +{ + if ( res != 'OK' ) + { + alert( nv_is_change_act_confirm[2] ); + } + clearTimeout( nv_timer ); + window.location.href = window.location.href; + return; +} + +// --------------------------------------- + +function nv_chang_status( catid ) +{ + var nv_timer = nv_settimeout_disable( 'change_status' + catid, 5000 ); + nv_ajax( "post", script_name, nv_name_variable + '=' + nv_module_name + '&' + nv_fc_variable + '=cat&changestatus=1&catid=' + catid + '&num=' + nv_randomPassword( 8 ), '', 'nv_chang_status_res' ); + return; +} + +// --------------------------------------- + +function nv_chang_status_res( res ) +{ + if( res != 'OK' ) + { + alert( nv_is_change_act_confirm[2] ); + window.location.href = window.location.href; + } + return; +} + +// --------------------------------------- + +function nv_chang_row_weight( fid ) +{ + var nv_timer = nv_settimeout_disable( 'weight' + fid, 5000 ); + var newpos = document.getElementById( 'weight' + fid ).options[document.getElementById( 'weight' + fid ).selectedIndex].value; + nv_ajax( "post", script_name, nv_name_variable + '=' + nv_module_name + '&changeweight=1&id=' + fid + '&new=' + newpos + '&num=' + nv_randomPassword( 8 ), '', 'nv_chang_row_weight_res' ); + return; +} + +// --------------------------------------- + +function nv_chang_row_weight_res( res ) +{ + if ( res != 'OK' ) + { + alert( nv_is_change_act_confirm[2] ); + } + clearTimeout( nv_timer ); + window.location.href = window.location.href; + return; +} + +// --------------------------------------- + +function nv_chang_row_status( fid ) +{ + var nv_timer = nv_settimeout_disable( 'change_status' + fid, 5000 ); + nv_ajax( "post", script_name, nv_name_variable + '=' + nv_module_name + '&changestatus=1&id=' + fid + '&num=' + nv_randomPassword( 8 ), '', 'nv_chang_row_status_res' ); + return; +} + +// --------------------------------------- + +function nv_chang_row_status_res( res ) +{ + if( res != 'OK' ) + { + alert( nv_is_change_act_confirm[2] ); + window.location.href = window.location.href; + } + return; +} + +// --------------------------------------- + +function nv_row_del( fid ) +{ + if ( confirm( nv_is_del_confirm[0] ) ) + { + nv_ajax( 'post', script_name, nv_name_variable + '=' + nv_module_name + '&del=1&id=' + fid, '', 'nv_row_del_result' ); + } + return false; +} + +// --------------------------------------- + +function nv_row_del_result( res ) +{ + if( res == 'OK' ) + { + window.location.href = window.location.href; + } + else + { + alert( nv_is_del_confirm[2] ); + } + return false; +} diff --git a/modules/faq/js/index.html b/modules/faq/js/index.html new file mode 100644 index 0000000..e69de29 diff --git a/modules/faq/js/user.js b/modules/faq/js/user.js new file mode 100644 index 0000000..71d2777 --- /dev/null +++ b/modules/faq/js/user.js @@ -0,0 +1 @@ +function faq_show_content(a){window.location.href="#faq"+a}; \ No newline at end of file diff --git a/modules/faq/language/.htaccess b/modules/faq/language/.htaccess new file mode 100644 index 0000000..3418e55 --- /dev/null +++ b/modules/faq/language/.htaccess @@ -0,0 +1 @@ +deny from all \ No newline at end of file diff --git a/modules/faq/language/admin_cs.php b/modules/faq/language/admin_cs.php new file mode 100644 index 0000000..9b986da --- /dev/null +++ b/modules/faq/language/admin_cs.php @@ -0,0 +1,64 @@ +%s”'; +$lang_module['faq_category_cat_sort'] = 'Umístění'; +$lang_module['faq_category_cat_active'] = 'Aktivity'; +$lang_module['faq_category_cat_feature'] = 'funkce'; +$lang_module['faq_category_cat_sub'] = 'vedlejší kategorie'; +$lang_module['faq_addfaq'] = 'přidat často kladené otázky'; +$lang_module['faq_editfaq'] = 'upravit často kladené otázky'; +$lang_module['faq_error_title'] = 'chyba: titul často kladené otázky nebyl zadano'; +$lang_module['faq_title_exists'] = 'chyba:titul již existoval . Vyberte jiný titul'; +$lang_module['faq_error_question'] = 'chyba: otazka nebyla zadana'; +$lang_module['faq_error_answer'] = 'chyba:odpověd nebyla zadana'; +$lang_module['faq_error_notResult'] = 'chyba:změny nebyly uloženy z neznámého důvodu'; +$lang_module['faq_error_notResult2'] = 'chyba: nové často kladené otazky nebyly přijímat z neznámého důvodu'; +$lang_module['faq_title_faq'] = 'Nazev'; +$lang_module['faq_question_faq'] = 'Otázka'; +$lang_module['faq_answer_faq'] = 'Odpověď'; +$lang_module['faq_catid_faq'] = 'patři kategorie'; +$lang_module['faq_save'] = 'Uložit'; +$lang_module['faq_list_by_cat'] = 'seznam často kladené otázky patří kategorie “%s”'; +$lang_module['faq_manager'] = 'správce často kladené otázky'; +$lang_module['faq_pos'] = 'Umístění'; +$lang_module['faq_feature'] = 'Funkce'; +$lang_module['faq_active'] = 'Aktivity'; +$lang_module['nocat'] = 'Žádná témata'; +$lang_module['config'] = 'configurace'; +$lang_module['config_type_main'] = 'Configurace hlavní stránka'; +$lang_module['config_type_main_0'] = 'Zobrazit témata'; +$lang_module['config_type_main_1'] = 'Nějnověší'; +$lang_module['config_type_main_2'] = 'Nějstarší'; + +?> \ No newline at end of file diff --git a/modules/faq/language/admin_en.php b/modules/faq/language/admin_en.php new file mode 100644 index 0000000..23b1919 --- /dev/null +++ b/modules/faq/language/admin_en.php @@ -0,0 +1,64 @@ +%s” \'s sub categories list'; +$lang_module['faq_category_cat_sort'] = 'Sort'; +$lang_module['faq_category_cat_active'] = 'Active'; +$lang_module['faq_category_cat_feature'] = 'Feature'; +$lang_module['faq_category_cat_sub'] = 'Sub category'; +$lang_module['faq_addfaq'] = 'Add FAQ'; +$lang_module['faq_editfaq'] = 'Edit FAQ'; +$lang_module['faq_error_title'] = 'Error: Empty title'; +$lang_module['faq_title_exists'] = 'Error: Title exists. Please choose another title.'; +$lang_module['faq_error_question'] = 'Error: Empty question'; +$lang_module['faq_error_answer'] = 'Error: Empty answer'; +$lang_module['faq_error_notResult'] = 'Error: Update failed by some reasons.'; +$lang_module['faq_error_notResult2'] = 'Error: Add failed by some reasons.'; +$lang_module['faq_title_faq'] = 'Title'; +$lang_module['faq_question_faq'] = 'Question'; +$lang_module['faq_answer_faq'] = 'Answer'; +$lang_module['faq_catid_faq'] = 'Parent category'; +$lang_module['faq_save'] = 'Save'; +$lang_module['faq_list_by_cat'] = 'List of FAQ in “%s”'; +$lang_module['faq_manager'] = 'Manage FAQ'; +$lang_module['faq_pos'] = 'Position'; +$lang_module['faq_feature'] = 'Features'; +$lang_module['faq_active'] = 'Active'; +$lang_module['nocat'] = 'Not under any topic'; +$lang_module['config'] = 'Module configuration'; +$lang_module['config_type_main'] = 'Ways to show on the home page'; +$lang_module['config_type_main_0'] = 'Displaying Topics'; +$lang_module['config_type_main_1'] = 'List, newer first'; +$lang_module['config_type_main_2'] = 'List, oldest First'; + +?> \ No newline at end of file diff --git a/modules/faq/language/admin_fr.php b/modules/faq/language/admin_fr.php new file mode 100644 index 0000000..60df4a4 --- /dev/null +++ b/modules/faq/language/admin_fr.php @@ -0,0 +1,64 @@ +%s”'; +$lang_module['faq_category_cat_sort'] = 'Position'; +$lang_module['faq_category_cat_active'] = 'Activer'; +$lang_module['faq_category_cat_feature'] = 'Actions'; +$lang_module['faq_category_cat_sub'] = 'Sous-catégorie'; +$lang_module['faq_addfaq'] = 'Ajouter'; +$lang_module['faq_editfaq'] = 'Éditer'; +$lang_module['faq_error_title'] = 'Erreur: vous n\'avez pas encore donné le titre'; +$lang_module['faq_title_exists'] = 'Erreur: le titre a été utilisé. Veuillez donner un autre titre'; +$lang_module['faq_error_question'] = 'Erreur: vous n\'avez pas encore donné la question'; +$lang_module['faq_error_answer'] = 'Erreur: vous n\'avez pas encore donné la réponse'; +$lang_module['faq_error_notResult'] = 'Erreur: Les changements n\'ont pas été enregistré par un raison inconnu'; +$lang_module['faq_error_notResult2'] = 'Erreur: La nouvelle question/réponse n\'a pas été enregistré par un raison inconnu'; +$lang_module['faq_title_faq'] = 'Titre'; +$lang_module['faq_question_faq'] = 'Question'; +$lang_module['faq_answer_faq'] = 'Réponse'; +$lang_module['faq_catid_faq'] = 'Catégorie'; +$lang_module['faq_save'] = 'Sauver'; +$lang_module['faq_list_by_cat'] = 'Liste des questions/réponses de la catégorie “%s”'; +$lang_module['faq_manager'] = 'Gestion de questions/réponses'; +$lang_module['faq_pos'] = 'Position'; +$lang_module['faq_feature'] = 'Fonctionalité'; +$lang_module['faq_active'] = 'Actif'; +$lang_module['nocat'] = 'Ne pas appartenir à aucune catégorie'; +$lang_module['config'] = 'Configuration du module'; +$lang_module['config_type_main'] = 'Affiche sur l’accueil'; +$lang_module['config_type_main_0'] = 'Afficher le catégories'; +$lang_module['config_type_main_1'] = 'Nouveau en haut'; +$lang_module['config_type_main_2'] = 'ancien en haut'; + +?> \ No newline at end of file diff --git a/modules/faq/language/admin_tr.php b/modules/faq/language/admin_tr.php new file mode 100644 index 0000000..dbe0f7b --- /dev/null +++ b/modules/faq/language/admin_tr.php @@ -0,0 +1,64 @@ +%s” \'s sub categories list'; +$lang_module['faq_category_cat_sort'] = 'Sıralama'; +$lang_module['faq_category_cat_active'] = 'Aktif'; +$lang_module['faq_category_cat_feature'] = 'Seçenekler'; +$lang_module['faq_category_cat_sub'] = 'Alt kategori'; +$lang_module['faq_addfaq'] = 'Soru Ekle'; +$lang_module['faq_editfaq'] = 'Soru Düzenle'; +$lang_module['faq_error_title'] = 'Hata: Başlık boş'; +$lang_module['faq_title_exists'] = 'Error: Title exists. Please choose another title.'; +$lang_module['faq_error_question'] = 'Hata: Soru boş'; +$lang_module['faq_error_answer'] = 'Hata: Cevap boş'; +$lang_module['faq_error_notResult'] = 'Error: Update failed by some reasons.'; +$lang_module['faq_error_notResult2'] = 'Error: Add failed by some reasons.'; +$lang_module['faq_title_faq'] = 'Başlık'; +$lang_module['faq_question_faq'] = 'Soru'; +$lang_module['faq_answer_faq'] = 'Cevap'; +$lang_module['faq_catid_faq'] = 'Ana kategori'; +$lang_module['faq_save'] = 'Kaydet'; +$lang_module['faq_list_by_cat'] = 'List of FAQ in “%s”'; +$lang_module['faq_manager'] = 'FAQ Yönetimi'; +$lang_module['faq_pos'] = 'Pozisyon'; +$lang_module['faq_feature'] = 'Seçenekler'; +$lang_module['faq_active'] = 'Aktif'; +$lang_module['nocat'] = 'Herhangi bir konu değil altında'; +$lang_module['config'] = 'Modül ayarları'; +$lang_module['config_type_main'] = 'Yollar ana sayfasında göstermek için'; +$lang_module['config_type_main_0'] = 'Gösteren konular'; +$lang_module['config_type_main_1'] = 'Liste, yeni ilk'; +$lang_module['config_type_main_2'] = 'Liste, eski birinci'; + +?> \ No newline at end of file diff --git a/modules/faq/language/admin_vi.php b/modules/faq/language/admin_vi.php new file mode 100644 index 0000000..231332c --- /dev/null +++ b/modules/faq/language/admin_vi.php @@ -0,0 +1,64 @@ +%s”'; +$lang_module['faq_category_cat_sort'] = 'Vị trí'; +$lang_module['faq_category_cat_active'] = 'Hoạt động'; +$lang_module['faq_category_cat_feature'] = 'Chức năng'; +$lang_module['faq_category_cat_sub'] = 'chủ đề con'; +$lang_module['faq_addfaq'] = 'Thêm Hỏi đáp'; +$lang_module['faq_editfaq'] = 'Sửa Hỏi đáp'; +$lang_module['faq_error_title'] = 'Lỗi: Tiêu đề Hỏi đáp chưa được khai báo'; +$lang_module['faq_title_exists'] = 'Lỗi: Tiêu đề mà bạn khai báo đã được sử dụng. Hãy chọn tiêu đè khác'; +$lang_module['faq_error_question'] = 'Lỗi: Câu hỏi chưa được khai báo'; +$lang_module['faq_error_answer'] = 'Lỗi: Câu trả lời chưa được khai báo'; +$lang_module['faq_error_notResult'] = 'Lỗi: Các thay đổi không được ghi nhận vì một lý do không xác định'; +$lang_module['faq_error_notResult2'] = 'Lỗi: Hỏi đáp mới không được ghi nhận vì một lý do không xác định'; +$lang_module['faq_title_faq'] = 'Tiêu đề'; +$lang_module['faq_question_faq'] = 'Câu hỏi'; +$lang_module['faq_answer_faq'] = 'Câu trả lời'; +$lang_module['faq_catid_faq'] = 'Thuộc chủ đề'; +$lang_module['faq_save'] = 'Thực hiện'; +$lang_module['faq_list_by_cat'] = 'Danh sách Hỏi đáp thuộc chủ đề “%s”'; +$lang_module['faq_manager'] = 'Quản lý Hỏi đáp'; +$lang_module['faq_pos'] = 'Vị trí'; +$lang_module['faq_feature'] = 'Chức năng'; +$lang_module['faq_active'] = 'Hoạt động'; +$lang_module['nocat'] = 'Không thuộc chủ đề nào'; +$lang_module['config'] = 'Cấu hình module'; +$lang_module['config_type_main'] = 'Cách thể hiện trên trang chủ'; +$lang_module['config_type_main_0'] = 'Hiển thị các chủ đề'; +$lang_module['config_type_main_1'] = 'Danh sách mới lên trên'; +$lang_module['config_type_main_2'] = 'Danh sách cũ lên trên'; + +?> \ No newline at end of file diff --git a/modules/faq/language/cs.php b/modules/faq/language/cs.php new file mode 100644 index 0000000..c4365df --- /dev/null +++ b/modules/faq/language/cs.php @@ -0,0 +1,24 @@ + \ No newline at end of file diff --git a/modules/faq/language/en.php b/modules/faq/language/en.php new file mode 100644 index 0000000..4d9f0ee --- /dev/null +++ b/modules/faq/language/en.php @@ -0,0 +1,24 @@ + \ No newline at end of file diff --git a/modules/faq/language/fr.php b/modules/faq/language/fr.php new file mode 100644 index 0000000..4a58fee --- /dev/null +++ b/modules/faq/language/fr.php @@ -0,0 +1,24 @@ + \ No newline at end of file diff --git a/modules/faq/language/index.html b/modules/faq/language/index.html new file mode 100644 index 0000000..e69de29 diff --git a/modules/faq/language/tr.php b/modules/faq/language/tr.php new file mode 100644 index 0000000..fc96c05 --- /dev/null +++ b/modules/faq/language/tr.php @@ -0,0 +1,24 @@ + \ No newline at end of file diff --git a/modules/faq/language/vi.php b/modules/faq/language/vi.php new file mode 100644 index 0000000..e8dceb3 --- /dev/null +++ b/modules/faq/language/vi.php @@ -0,0 +1,24 @@ + \ No newline at end of file diff --git a/modules/faq/rssdata.php b/modules/faq/rssdata.php new file mode 100644 index 0000000..456dc7c --- /dev/null +++ b/modules/faq/rssdata.php @@ -0,0 +1,24 @@ + 0, 'parentid' => 0, 'title' => '', 'link' => ''); + + +$sql = "SELECT `id` AS `catid`, `parentid`, `title`, `alias` FROM `" . NV_PREFIXLANG . "_" . $mod_name . "_categories` ORDER BY `weight` ASC"; +$list = nv_db_cache( $sql, '', $mod_name ); +foreach ( $list as $value ) +{ + $value['link'] = NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&" . NV_NAME_VARIABLE . "=" . $mod_name . "&" . NV_OP_VARIABLE . "=rss/" . $value['alias']; + $rssarray[] = $value; +} + +?> \ No newline at end of file diff --git a/modules/faq/search.php b/modules/faq/search.php new file mode 100644 index 0000000..4db6c27 --- /dev/null +++ b/modules/faq/search.php @@ -0,0 +1,93 @@ +sql_query( $sql ); + + $list = array(); + while ( $row = $db->sql_fetchrow( $result ) ) + { + if ( nv_faq_set_allow( $row['who_view'], $row['groups_view'] ) ) + { + $list[$row['id']] = array( // + 'id' => ( int )$row['id'], // + 'title' => $row['title'], // + 'alias' => $row['alias'] // + ); + } + } + + return $list; +} + +$list_cats = nv_faq_list_cats( $m_values['module_data'] ); +$in = implode( ",", array_keys( $list_cats ) ); + +$sql = "SELECT SQL_CALC_FOUND_ROWS `id`,`question`, `answer`, `catid` +FROM `" . NV_PREFIXLANG . "_" . $m_values['module_data'] . "` +WHERE `catid` IN (" . $in . ") +AND +(" . nv_like_logic( 'question', $dbkeyword, $logic ) . " +OR " . nv_like_logic( 'answer', $dbkeyword, $logic ) . ") +LIMIT " . $pages . "," . $limit; + +$tmp_re = $db->sql_query( $sql ); + +$result = $db->sql_query( "SELECT FOUND_ROWS()" ); +list( $all_page ) = $db->sql_fetchrow( $result ); + +if ( $all_page ) +{ + $link = NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&" . NV_NAME_VARIABLE . "=" . $m_values['module_name'] . '&' . NV_OP_VARIABLE . '='; + + while ( list( $id, $question, $answer, $catid ) = $db->sql_fetchrow( $tmp_re ) ) + { + $result_array[] = array( // + 'link' => $link . $list_cats[$catid]['alias'] . '#faq' . $id, // + 'title' => BoldKeywordInStr( $question, $key, $logic ), // + 'content' => BoldKeywordInStr( $answer, $key, $logic ) // + ); + } +} + +?> \ No newline at end of file diff --git a/modules/faq/theme.php b/modules/faq/theme.php new file mode 100644 index 0000000..a276b4a --- /dev/null +++ b/modules/faq/theme.php @@ -0,0 +1,112 @@ +assign( 'LANG', $lang_module ); + $xtpl->assign( 'PAGE_TITLE', $mod_title ); + $xtpl->assign( 'WELCOME', $lang_module['faq_welcome'] ); + $xtpl->parse( 'main.welcome' ); + + foreach ( $list_cats as $cat ) + { + if ( ! $cat['parentid'] ) + { + $cat['link'] = NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=" . $cat['alias']; + $cat['name'] = "" . $cat['title'] . ""; + $xtpl->assign( 'SUBCAT', $cat ); + if ( ! empty( $cat['description'] ) ) + { + $xtpl->parse( 'main.subcats.li.description' ); + } + $xtpl->parse( 'main.subcats.li' ); + } + } + $xtpl->parse( 'main.subcats' ); + + $xtpl->parse( 'main' ); + return $xtpl->text( 'main' ); +} + +/** + * theme_cat_faq() + * + * @param mixed $list_cats + * @param mixed $catid + * @param mixed $faq + * @param mixed $mod_title + * @return + */ +function theme_cat_faq( $list_cats, $catid, $faq, $mod_title ) +{ + global $global_config, $lang_module, $lang_global, $module_info, $module_name, $module_file; + + $xtpl = new XTemplate( "main_page.tpl", NV_ROOTDIR . "/themes/" . $module_info['template'] . "/modules/" . $module_file . "/" ); + $xtpl->assign( 'LANG', $lang_module ); + $xtpl->assign( 'PAGE_TITLE', $mod_title ); + + if ( ! empty( $list_cats[$catid]['description'] ) ) + { + $xtpl->assign( 'WELCOME', $list_cats[$catid]['description'] ); + $xtpl->parse( 'main.welcome' ); + } + + if ( ! empty( $list_cats[$catid]['subcats'] ) ) + { + foreach ( $list_cats[$catid]['subcats'] as $subcat ) + { + $cat = $list_cats[$subcat]; + $cat['link'] = NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=" . $cat['alias']; + $cat['name'] = "" . $cat['title'] . ""; + $xtpl->assign( 'SUBCAT', $cat ); + if ( ! empty( $cat['description'] ) ) + { + $xtpl->parse( 'main.subcats.li.description' ); + } + $xtpl->parse( 'main.subcats.li' ); + } + $xtpl->parse( 'main.subcats' ); + } + + if ( ! empty( $faq ) ) + { + foreach ( $faq as $row ) + { + $xtpl->assign( 'ROW', $row ); + $xtpl->parse( 'main.is_show_row.row' ); + } + + $xtpl->assign( 'IMG_GO_TOP_SRC', NV_BASE_SITEURL . 'themes/' . $module_info['template'] . '/images/' . $module_name . '/' ); + + foreach ( $faq as $row ) + { + $xtpl->assign( 'ROW', $row ); + $xtpl->parse( 'main.is_show_row.detail' ); + } + + $xtpl->parse( 'main.is_show_row' ); + } + + $xtpl->parse( 'main' ); + return $xtpl->text( 'main' ); +} + +?> \ No newline at end of file diff --git a/modules/faq/version.php b/modules/faq/version.php new file mode 100644 index 0000000..750716e --- /dev/null +++ b/modules/faq/version.php @@ -0,0 +1,23 @@ + "Faq", // + "modfuncs" => "main", // + "is_sysmod" => 0, // + "virtual" => 1, // + "version" => "3.0.01", // + "date" => "Wed, 20 Oct 2010 00:00:00 GMT", // + "author" => "VINADES (contact@vinades.vn)", // + "note" => "" // + ); + +?> \ No newline at end of file diff --git a/themes/admin_default/modules/faq/.htaccess b/themes/admin_default/modules/faq/.htaccess new file mode 100644 index 0000000..3418e55 --- /dev/null +++ b/themes/admin_default/modules/faq/.htaccess @@ -0,0 +1 @@ +deny from all \ No newline at end of file diff --git a/themes/admin_default/modules/faq/cat_add.tpl b/themes/admin_default/modules/faq/cat_add.tpl new file mode 100644 index 0000000..eedb49c --- /dev/null +++ b/themes/admin_default/modules/faq/cat_add.tpl @@ -0,0 +1,78 @@ + + +
+
+

+ {ERROR} +

+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ {LANG.faq_category_cat_name} + + +
+ {LANG.faq_description} + + +
+ {LANG.faq_category_cat_parent} + + +
+ {LANG.faq_who_view} + + + +
+ {LANG.groups_upload}
+ + {GROUPS_VIEW.title}
+ + +
+ +
+
+ diff --git a/themes/admin_default/modules/faq/cat_list.tpl b/themes/admin_default/modules/faq/cat_list.tpl new file mode 100644 index 0000000..c6f2804 --- /dev/null +++ b/themes/admin_default/modules/faq/cat_list.tpl @@ -0,0 +1,55 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + +
{TABLE_CAPTION}
+ {LANG.faq_category_cat_sort} + + {LANG.faq_category_cat_name} + + {LANG.faq_category_cat_parent} + + {LANG.faq_category_cat_active} + + {LANG.faq_category_cat_feature} +
+ + + {ROW.title}{ROW.numsub} + + {ROW.parentid} + + + + {GLANG.edit} +   {GLANG.delete} +
+
+
+ {LANG.faq_addcat_titlebox} +
+ diff --git a/themes/admin_default/modules/faq/config.tpl b/themes/admin_default/modules/faq/config.tpl new file mode 100644 index 0000000..4784c89 --- /dev/null +++ b/themes/admin_default/modules/faq/config.tpl @@ -0,0 +1,22 @@ + +
+
+ + + + + + + +
{LANG.config_type_main} + +
+
+ +
+
+
diff --git a/themes/admin_default/modules/faq/content.tpl b/themes/admin_default/modules/faq/content.tpl new file mode 100644 index 0000000..fafd25c --- /dev/null +++ b/themes/admin_default/modules/faq/content.tpl @@ -0,0 +1,59 @@ + + +
+
+

+ {ERROR} +

+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ {LANG.faq_title_faq} + + +
+ {LANG.faq_catid_faq} + + +
+ {LANG.faq_question_faq} + + +
+ +
+ {LANG.faq_answer_faq}
+ {DATA.answer} +
+ +
+ +
+
+ diff --git a/themes/admin_default/modules/faq/index.html b/themes/admin_default/modules/faq/index.html new file mode 100644 index 0000000..e69de29 diff --git a/themes/admin_default/modules/faq/main.tpl b/themes/admin_default/modules/faq/main.tpl new file mode 100644 index 0000000..cc78e59 --- /dev/null +++ b/themes/admin_default/modules/faq/main.tpl @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{TABLE_CAPTION}
+ {LANG.faq_pos} + + {LANG.faq_title_faq} + + {LANG.faq_catid_faq} + + {LANG.faq_active} + + {LANG.faq_feature} +
+ + + {ROW.title} + + {ROW.cattitle} + + + + {GLANG.edit} +   {GLANG.delete} +
+
+ {LANG.faq_addfaq} +
+ diff --git a/themes/default/css/faq.css b/themes/default/css/faq.css new file mode 100644 index 0000000..858e3ba --- /dev/null +++ b/themes/default/css/faq.css @@ -0,0 +1,14 @@ +.block_faq .title{background:url(../images/faq/faq.gif) no-repeat left -96px;padding-left:27px} +.block_faq .title a{text-decoration:underline} +.catlist{margin-bottom:15px;margin-top:5px;padding-left:20px} +.catlist li.description{color:#666;font:normal 12px arial, verdana, sans-serif;padding-bottom:10px;padding-left:27px} +.catlist li.main{background:url(../images/faq/faq.gif) no-repeat left -24px;font:bold 12px/24px arial, verdana, sans-serif;padding-left:27px} +.page_title{border-bottom:1px solid #ccc;font:bold 12px/23px arial, verdana, sans-serif} +.show_detail .detail_faq{padding-bottom:15px} +.show_detail .detail_faq .question{padding-bottom:10px} +.show_detail .detail_faq .title{background:url(../images/faq/faq.gif) no-repeat left -48px;border-bottom:1px solid #92c2fe;display:block;font:bold 12px/24px arial, verdana, sans-serif;margin-bottom:5px;padding-left:27px} +.show_detail .detail_faq .title .gotop{float:right;padding-top:4px} +.show_row{padding-bottom:30px;padding-left:20px} +.welcome{font:bold 13px arial, verdana, sans-serif;padding-bottom:10px;padding-top:5px} +.block_faq .title a:hover{text-decoration:none} +.catlist li.main:hover{background:url(../images/faq/faq.gif) no-repeat left 0;font:bold 12px/24px arial, verdana, sans-serif;padding-left:27px} \ No newline at end of file diff --git a/themes/default/images/faq/faq.gif b/themes/default/images/faq/faq.gif new file mode 100644 index 0000000..21c0d8c Binary files /dev/null and b/themes/default/images/faq/faq.gif differ diff --git a/themes/default/images/faq/index.html b/themes/default/images/faq/index.html new file mode 100644 index 0000000..e69de29 diff --git a/themes/default/images/faq/top.gif b/themes/default/images/faq/top.gif new file mode 100644 index 0000000..8c87d3a Binary files /dev/null and b/themes/default/images/faq/top.gif differ diff --git a/themes/default/modules/faq/.htaccess b/themes/default/modules/faq/.htaccess new file mode 100644 index 0000000..3418e55 --- /dev/null +++ b/themes/default/modules/faq/.htaccess @@ -0,0 +1 @@ +deny from all \ No newline at end of file diff --git a/themes/default/modules/faq/index.html b/themes/default/modules/faq/index.html new file mode 100644 index 0000000..d175333 --- /dev/null +++ b/themes/default/modules/faq/index.html @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/themes/default/modules/faq/main_page.tpl b/themes/default/modules/faq/main_page.tpl new file mode 100644 index 0000000..beb56c0 --- /dev/null +++ b/themes/default/modules/faq/main_page.tpl @@ -0,0 +1,57 @@ + +
+ {PAGE_TITLE} +
+ +
+ {WELCOME}. +
+ + + + + +
+ + +
+ +
+ +
+
+ + +
+
+
+ {LANG.go_top} +
+ {ROW.title} +
+
+ {LANG.faq_question}:
+ {ROW.question} +
+
+ {LANG.faq_answer}:
+ {ROW.answer} +
+
+ +
+ + diff --git a/themes/modern/css/faq.css b/themes/modern/css/faq.css new file mode 100644 index 0000000..8990eef --- /dev/null +++ b/themes/modern/css/faq.css @@ -0,0 +1,14 @@ +#faq .faq-header h4{border-bottom:1px solid #d8d8d8;font-size:1.3em;font-weight:bold;line-height:2;margin-bottom:.8em} +#faq .block_faq .title{background:url(../images/faq/faq.gif) no-repeat left -96px;padding-left:27px} +#faq .block_faq .title a{text-decoration:underline} +#faq .catlist{list-style-type:none;margin:0 0 10px} +#faq .catlist li{padding-top:10px} +#faq .catlist .description{color:#666;padding-left:30px} +#faq .catlist .cat{background:url(../images/faq/faq.gif) no-repeat left -24px;font-size:1.3em;font-weight:bold;line-height:24px;margin-bottom:.5em;padding-left:30px} +#faq .show_detail .detail_faq{margin-bottom:20px} +#faq .show_detail .detail_faq .question{border-bottom:1px solid #d8d8d8;color:#234765;margin-bottom:20px} +#faq .show_detail .detail_faq .title{border-bottom:1px solid #B93D00;font:bold 12px/24px arial,verdana,sans-serif;font-size:1.2em;margin-bottom:10px} +#faq .show_detail .detail_faq .title .gotop{float:right;padding-top:4px} +#faq .show_row{padding-bottom:30px;padding-left:20px} +#faq .block_faq .title a:hover{text-decoration:none} +#faq .catlist li.main:hover{background:url(../images/faq/faq.gif) no-repeat left 0;font:bold 12px/24px arial,verdana,sans-serif;padding-left:27px} \ No newline at end of file diff --git a/themes/modern/images/faq/faq.gif b/themes/modern/images/faq/faq.gif new file mode 100644 index 0000000..21c0d8c Binary files /dev/null and b/themes/modern/images/faq/faq.gif differ diff --git a/themes/modern/images/faq/index.html b/themes/modern/images/faq/index.html new file mode 100644 index 0000000..e69de29 diff --git a/themes/modern/images/faq/top.gif b/themes/modern/images/faq/top.gif new file mode 100644 index 0000000..8c87d3a Binary files /dev/null and b/themes/modern/images/faq/top.gif differ diff --git a/themes/modern/modules/faq/.htaccess b/themes/modern/modules/faq/.htaccess new file mode 100644 index 0000000..3418e55 --- /dev/null +++ b/themes/modern/modules/faq/.htaccess @@ -0,0 +1 @@ +deny from all \ No newline at end of file diff --git a/themes/modern/modules/faq/index.html b/themes/modern/modules/faq/index.html new file mode 100644 index 0000000..d175333 --- /dev/null +++ b/themes/modern/modules/faq/index.html @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/themes/modern/modules/faq/main_page.tpl b/themes/modern/modules/faq/main_page.tpl new file mode 100644 index 0000000..3c77e73 --- /dev/null +++ b/themes/modern/modules/faq/main_page.tpl @@ -0,0 +1,60 @@ + +
+
+

{PAGE_TITLE}

+
+ +

+ {WELCOME}. +

+ + + + + +
+ + +
+ +
+ +
+
+ + +
+
+
+ {LANG.go_top} +
+ {ROW.title} +
+
+ {LANG.faq_question}:
+

{ROW.question}

+
+
+ {LANG.faq_answer}:
+ {ROW.answer} +
+
+ +
+ +
+