Skip to content

Commit

Permalink
module faq for NukeViet 3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
vuthao committed Nov 28, 2013
0 parents commit 613c5a0
Show file tree
Hide file tree
Showing 57 changed files with 3,142 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/.settings
/.project
60 changes: 60 additions & 0 deletions modules/faq/action.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

/**
* @Project NUKEVIET 3.x
* @Author VINADES.,JSC ([email protected])
* @Copyright (C) 2012 VINADES.,JSC. All rights reserved
* @Createdate 28/8/2010, 23:11
*/

if ( ! defined( 'NV_IS_FILE_MODULES' ) ) die( 'Stop!!!' );

$sql_drop_module = array();

$sql_drop_module[] = "DROP TABLE IF EXISTS `" . $db_config['prefix'] . "_" . $lang . "_" . $module_data . "`";
$sql_drop_module[] = "DROP TABLE IF EXISTS `" . $db_config['prefix'] . "_" . $lang . "_" . $module_data . "_categories`";
$sql_drop_module[] = "DROP TABLE IF EXISTS `" . $db_config['prefix'] . "_" . $lang . "_" . $module_data . "_config`";

$sql_create_module = $sql_drop_module;

$sql_create_module[] = "CREATE TABLE IF NOT EXISTS `" . $db_config['prefix'] . "_" . $lang . "_" . $module_data . "` (
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`catid` mediumint(8) unsigned NOT NULL,
`title` varchar(255) NOT NULL,
`alias` varchar(255) NOT NULL,
`question` mediumtext NOT NULL,
`answer` mediumtext NOT NULL,
`weight` smallint(4) unsigned NOT NULL DEFAULT '0',
`status` tinyint(1) unsigned NOT NULL DEFAULT '0',
`addtime` int(11) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `alias` (`alias`),
KEY `catid` (`catid`)
)ENGINE=MyISAM";

$sql_create_module[] = "CREATE TABLE IF NOT EXISTS `" . $db_config['prefix'] . "_" . $lang . "_" . $module_data . "_categories` (
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`parentid` mediumint(8) unsigned NOT NULL,
`title` varchar(255) NOT NULL,
`alias` varchar(255) NOT NULL,
`description` mediumtext NOT NULL,
`who_view` tinyint(1) unsigned NOT NULL DEFAULT '0',
`groups_view` varchar(255) NOT NULL,
`weight` smallint(4) unsigned NOT NULL DEFAULT '0',
`status` tinyint(1) unsigned NOT NULL DEFAULT '0',
`keywords` mediumtext NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `alias` (`alias`)
)ENGINE=MyISAM";

// Config
$sql_create_module[] = "CREATE TABLE IF NOT EXISTS `" . $db_config['prefix'] . "_" . $lang . "_" . $module_data . "_config` (
`config_name` varchar(30) NOT NULL,
`config_value` varchar(255) NOT NULL,
UNIQUE KEY `config_name` (`config_name`)
)ENGINE=MyISAM";

$sql_create_module[] = "INSERT INTO `" . $db_config['prefix'] . "_" . $lang . "_" . $module_data . "_config` VALUES
('type_main', '0')";

?>
140 changes: 140 additions & 0 deletions modules/faq/admin.functions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
<?php

/**
* @Project NUKEVIET 3.x
* @Author VINADES.,JSC ([email protected])
* @copyright 2009
* @createdate 12/31/2009 2:29
*/

if ( ! defined( 'NV_ADMIN' ) or ! defined( 'NV_MAINFILE' ) or ! defined( 'NV_IS_MODADMIN' ) ) die( 'Stop!!!' );

$submenu['cat'] = $lang_module['faq_catmanager'];
$submenu['config'] = $lang_module['config'];

$allow_func = array( 'main', 'cat', 'config' );

define( 'NV_IS_FILE_ADMIN', true );

/**
* nv_setcats()
*
* @param mixed $list2
* @param mixed $id
* @param mixed $list
* @param integer $m
* @param integer $num
* @return
*/
function nv_setcats( $list2, $id, $list, $m = 0, $num = 0 )
{
++$num;
$defis = "";
for ( $i = 0; $i < $num; ++$i )
{
$defis .= "--";
}

if ( isset( $list[$id] ) )
{
foreach ( $list[$id] as $value )
{
if ( $value['id'] != $m )
{
$list2[$value['id']] = $value;
$list2[$value['id']]['name'] = "|" . $defis . "&gt; " . $list2[$value['id']]['name'];
if ( isset( $list[$value['id']] ) )
{
$list2 = nv_setcats( $list2, $value['id'], $list, $m, $num );
}
}
}
}
return $list2;
}

/**
* nv_listcats()
*
* @param mixed $parentid
* @param integer $m
* @return
*/
function nv_listcats( $parentid, $m = 0 )
{
global $db, $module_data;

$sql = "SELECT * FROM `" . NV_PREFIXLANG . "_" . $module_data . "_categories` ORDER BY `parentid`,`weight` ASC";
$result = $db->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;
}

?>
1 change: 1 addition & 0 deletions modules/faq/admin/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deny from all
Loading

0 comments on commit 613c5a0

Please sign in to comment.