<?php

/**
 * @Project NUKEVIET 4.x
 * @Author webvang (hoang.nguyen@webvang.vn)
 * @Copyright (C) 2015 Webvang. All rights reserved
 * @License GNU/GPL version 2 or any later version
 * @Createdate 11/10/2015 00:00
 */
if (!defined('NV_IS_FILE_ADMIN')) {
    die('Stop!!!');
}
if (!defined('NV_MODULE_LOCATION')) {
    $contents = '<p class="note_fam">' . $lang_module['note_location'] . '</p>';
    include NV_ROOTDIR . '/includes/header.php';
    echo nv_admin_theme($contents);
    include NV_ROOTDIR . '/includes/footer.php';
    die;
}
if (!defined('NV_IS_AJAX')) {
    die('Wrong URL');
}
$parentid = $nv_Request->get_int('parentid', 'get', 0);
$contents = nv_show_fam_list($parentid);
include NV_ROOTDIR . '/includes/header.php';
echo $contents;
include NV_ROOTDIR . '/includes/footer.php';
$xtpl = new XTemplate('fam.tpl', NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $module_file);
$xtpl->assign('LANG', $lang_module);
$xtpl->assign('GLANG', $lang_global);
$xtpl->assign('NV_BASE_ADMINURL', NV_BASE_ADMINURL);
$xtpl->assign('NV_NAME_VARIABLE', NV_NAME_VARIABLE);
$xtpl->assign('MODULE_NAME', $module_name);
$xtpl->assign('OP', $op);
$xtpl->assign('caption', $caption);
$xtpl->assign('fid', $fid);
$xtpl->assign('title', $title);
$xtpl->assign('titlesite', $titlesite);
$xtpl->assign('alias', $alias);
$xtpl->assign('parentid', $parentid);
$xtpl->assign('keywords', $keywords);
$xtpl->assign('description', nv_htmlspecialchars(nv_br2nl($description)));
$xtpl->assign('FAM_LIST', nv_show_fam_list($parentid));
$xtpl->assign('UPLOAD_CURRENT', NV_UPLOADS_DIR . '/' . $module_upload);
if (!empty($image) and file_exists(NV_UPLOADS_REAL_DIR . '/' . $module_upload . '/' . $image)) {
    $image = NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $module_upload . '/' . $image;
}
$xtpl->assign('image', $image);
for ($i = 0; $i <= 2; $i++) {
    $data = array('value' => $i, 'selected' => $viewdescription == $i ? ' checked="checked"' : '', 'title' => $lang_module['viewdescription_' . $i]);
    $xtpl->assign('VIEWDESCRIPTION', $data);
    $xtpl->parse('main.content.viewdescription');
}
if ($fid > 0) {
    $sql = 'SELECT id FROM ' . NV_PREFIXLANG . '_' . $module_data . '_' . $fid . ' WHERE status=1 ORDER BY publtime DESC LIMIT 100';
    $result = $db->query($sql);
    $array_id = array();
    $array_id[] = $featured;