Esempio n. 1
0
 function nv_block_data_config_html($module, $data_block, $lang_block)
 {
     global $lang_module;
     if (defined('NV_EDITOR')) {
         require NV_ROOTDIR . '/' . NV_EDITORSDIR . '/' . NV_EDITOR . '/nv.php';
     }
     $htmlcontent = htmlspecialchars(nv_editor_br2nl($data_block['htmlcontent']));
     if (defined('NV_EDITOR') and nv_function_exists('nv_aleditor')) {
         $html = nv_add_editor_js() . nv_aleditor("htmlcontent", '100%', '150px', $htmlcontent);
     } else {
         $html = "<textarea style=\"width: 100%\" name=\"htmlcontent\" id=\"htmlcontent\" cols=\"20\" rows=\"8\">" . $htmlcontent . "</textarea>";
     }
     return '<tr><td colspan="2">' . $lang_block['htmlcontent'] . '<br>' . $html . '</td></tr>';
 }
Esempio n. 2
0
function nv_admin_theme($contents, $head_site = 1)
{
    global $global_config, $lang_global, $admin_mods, $site_mods, $admin_menu_mods, $module_name, $module_file, $module_info, $admin_info, $db, $page_title, $submenu, $select_options, $op, $set_active_op, $array_lang_admin, $my_head, $my_footer, $array_mod_title, $array_url_instruction, $op, $client_info;
    $dir_template = '';
    if ($head_site == 1) {
        $file_name_tpl = 'main.tpl';
        if (file_exists(NV_ROOTDIR . '/themes/' . $global_config['admin_theme'] . '/system/' . $file_name_tpl)) {
            $dir_template = NV_ROOTDIR . '/themes/' . $global_config['admin_theme'] . '/system';
        } else {
            $dir_template = NV_ROOTDIR . '/themes/admin_default/system';
            $global_config['admin_theme'] = 'admin_default';
        }
    } else {
        $file_name_tpl = 'content.tpl';
        if (file_exists(NV_ROOTDIR . '/themes/' . $global_config['admin_theme'] . '/system/' . $file_name_tpl)) {
            $dir_template = NV_ROOTDIR . '/themes/' . $global_config['admin_theme'] . '/system';
        } else {
            $dir_template = NV_ROOTDIR . '/themes/admin_default/system';
            $global_config['admin_theme'] = 'admin_default';
        }
    }
    $global_config['site_name'] = empty($global_config['site_name']) ? NV_SERVER_NAME : $global_config['site_name'];
    $xtpl = new XTemplate($file_name_tpl, $dir_template);
    $xtpl->assign('NV_SITE_COPYRIGHT', $global_config['site_name'] . ' [' . $global_config['site_email'] . '] ');
    $xtpl->assign('NV_SITE_NAME', $global_config['site_name']);
    $xtpl->assign('NV_SITE_TITLE', $global_config['site_name'] . ' ' . NV_TITLEBAR_DEFIS . ' ' . $lang_global['admin_page'] . ' ' . NV_TITLEBAR_DEFIS . ' ' . $module_info['custom_title']);
    $xtpl->assign('SITE_DESCRIPTION', $global_config['site_description']);
    $xtpl->assign('NV_CHECK_PASS_MSTIME', (intval($global_config['admin_check_pass_time']) - 62) * 1000);
    $xtpl->assign('NV_BASE_SITEURL', NV_BASE_SITEURL);
    $xtpl->assign('NV_ADMINDIR', NV_ADMINDIR);
    $xtpl->assign('NV_BASE_ADMINURL', NV_BASE_ADMINURL);
    $xtpl->assign('NV_ASSETS_DIR', NV_ASSETS_DIR);
    $xtpl->assign('MODULE_NAME', $module_name);
    $xtpl->assign('MODULE_FILE', $module_file);
    $xtpl->assign('NV_ADMIN_THEME', $global_config['admin_theme']);
    $xtpl->assign('LANG', $lang_global);
    if (file_exists(NV_ROOTDIR . '/themes/' . $global_config['admin_theme'] . '/css/' . $module_file . '.css')) {
        $xtpl->assign('NV_CSS_MODULE_THEME', NV_BASE_SITEURL . 'themes/' . $global_config['admin_theme'] . '/css/' . $module_file . '.css');
        $xtpl->parse('main.css_module');
    } elseif (file_exists(NV_ROOTDIR . '/themes/admin_default/css/' . $module_file . '.css')) {
        $xtpl->assign('NV_CSS_MODULE_THEME', NV_BASE_SITEURL . 'themes/admin_default/css/' . $module_file . '.css');
        $xtpl->parse('main.css_module');
    }
    $xtpl->assign('NV_LANG_VARIABLE', NV_LANG_VARIABLE);
    $xtpl->assign('NV_LANG_INTERFACE', NV_LANG_INTERFACE);
    $xtpl->assign('NV_NAME_VARIABLE', NV_NAME_VARIABLE);
    $xtpl->assign('NV_OP_VARIABLE', NV_OP_VARIABLE);
    $xtpl->assign('NV_SITE_TIMEZONE_OFFSET', round(NV_SITE_TIMEZONE_OFFSET / 3600));
    $xtpl->assign('NV_CURRENTTIME', nv_date('T', NV_CURRENTTIME));
    $xtpl->assign('NV_COOKIE_PREFIX', $global_config['cookie_prefix']);
    if (file_exists(NV_ROOTDIR . '/themes/' . $global_config['admin_theme'] . '/js/' . $module_file . '.js')) {
        $xtpl->assign('NV_JS_MODULE', NV_BASE_SITEURL . 'themes/' . $global_config['admin_theme'] . '/js/' . $module_file . '.js');
        $xtpl->parse('main.module_js');
    }
    if (defined('NV_EDITOR') and nv_function_exists('nv_add_editor_js')) {
        $xtpl->assign('NV_ADD_EDITOR_JS', nv_add_editor_js());
        $xtpl->parse('main.nv_add_editor_js');
    }
    if ($head_site == 1) {
        $xtpl->assign('NV_GO_CLIENTSECTOR', $lang_global['go_clientsector']);
        $lang_site = !empty($site_mods) ? NV_LANG_DATA : $global_config['site_lang'];
        $xtpl->assign('NV_GO_CLIENTSECTOR_URL', NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . $lang_site);
        $xtpl->assign('NV_LOGOUT', $lang_global['admin_logout_title']);
        if (!empty($array_lang_admin)) {
            $xtpl->assign('NV_LANGDATA', $lang_global['langdata']);
            $xtpl->assign('NV_LANGDATA_CURRENT', $array_lang_admin[NV_LANG_DATA]);
            foreach ($array_lang_admin as $lang_i => $lang_name) {
                $xtpl->assign('DISABLED', $lang_i == NV_LANG_DATA ? " class=\"disabled\"" : "");
                $xtpl->assign('LANGVALUE', $lang_name);
                $xtpl->assign('LANGOP', NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . $lang_i);
                $xtpl->parse('main.langdata.option');
            }
            $xtpl->parse('main.langdata');
        }
        // Top_menu
        $top_menu = $admin_mods;
        if (sizeof($top_menu) > 8) {
            if ($module_name != 'authors') {
                unset($top_menu['authors']);
            }
            if ($module_name != 'language') {
                unset($top_menu['language']);
            }
        }
        foreach ($top_menu as $m => $v) {
            if (!empty($v['custom_title'])) {
                $array_submenu = nv_get_submenu($m);
                $xtpl->assign('TOP_MENU_CLASS', $array_submenu ? ' class="dropdown"' : '');
                $xtpl->assign('TOP_MENU_HREF', $m);
                $xtpl->assign('TOP_MENU_NAME', $v['custom_title']);
                if (!empty($array_submenu)) {
                    $xtpl->parse('main.top_menu_loop.has_sub');
                    foreach ($array_submenu as $mop => $submenu_i) {
                        $xtpl->assign('SUBMENULINK', NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&amp;' . NV_NAME_VARIABLE . '=' . $m . '&amp;' . NV_OP_VARIABLE . '=' . $mop);
                        $xtpl->assign('SUBMENUTITLE', $submenu_i);
                        $xtpl->parse('main.top_menu_loop.submenu.submenu_loop');
                    }
                    $xtpl->parse('main.top_menu_loop.submenu');
                }
                $xtpl->parse('main.top_menu_loop');
            }
        }
        $xtpl->parse('main.top_menu');
        $xtpl->assign('NV_DIGCLOCK', nv_date('H:i T l, d/m/Y', NV_CURRENTTIME));
        if ($admin_info['current_login'] >= NV_CURRENTTIME - 60) {
            if (!empty($admin_info['last_login'])) {
                $temp = sprintf($lang_global['hello_admin1'], $admin_info['username'], date('H:i d/m/Y', $admin_info['last_login']), $admin_info['last_ip']);
                $xtpl->assign('HELLO_ADMIN1', $temp);
                $xtpl->parse('main.hello_admin');
            } else {
                $temp = sprintf($lang_global['hello_admin3'], $admin_info['username']);
                $xtpl->assign('HELLO_ADMIN3', $temp);
                $xtpl->parse('main.hello_admin3');
            }
        } else {
            $temp = sprintf($lang_global['hello_admin2'], $admin_info['username'], nv_convertfromSec(NV_CURRENTTIME - $admin_info['current_login']), $admin_info['current_ip']);
            $xtpl->assign('HELLO_ADMIN2', $temp);
            $xtpl->parse('main.hello_admin2');
        }
        // Admin photo
        $xtpl->assign('ADMIN_USERNAME', $admin_info['username']);
        if (!empty($admin_info['photo']) and file_exists(NV_ROOTDIR . '/' . $admin_info['photo'])) {
            $xtpl->assign('ADMIN_PHOTO', NV_BASE_SITEURL . $admin_info['photo']);
        } else {
            $xtpl->assign('ADMIN_PHOTO', NV_BASE_SITEURL . 'themes/default/images/users/no_avatar.png');
        }
        // Vertical menu
        foreach ($admin_menu_mods as $m => $v) {
            $xtpl->assign('MENU_CLASS', $module_name == $m ? ' class="active"' : '');
            $xtpl->assign('MENU_HREF', $m);
            $xtpl->assign('MENU_NAME', $v);
            if ($m != $module_name) {
                $submenu = nv_get_submenu_mod($m);
                $xtpl->assign('MENU_CLASS', $submenu ? ' class="dropdown"' : '');
                if (!empty($submenu)) {
                    foreach ($submenu as $n => $l) {
                        $xtpl->assign('MENU_SUB_HREF', $m);
                        $xtpl->assign('MENU_SUB_OP', $n);
                        $xtpl->assign('MENU_SUB_NAME', (is_array($l) and isset($l['title'])) ? $l['title'] : $l);
                        $xtpl->parse('main.menu_loop.submenu.loop');
                    }
                    $xtpl->parse('main.menu_loop.submenu');
                }
            } elseif (!empty($submenu)) {
                foreach ($submenu as $n => $l) {
                    if (is_array($l) and isset($l['submenu'])) {
                        $_subtitle = $l['title'];
                        $_submenu_i = $l['submenu'];
                    } else {
                        $_subtitle = $l;
                        $_submenu_i = '';
                    }
                    $xtpl->assign('MENU_SUB_CURRENT', (!empty($op) and $op == $n or !empty($set_active_op) and $set_active_op == $n) ? 'subactive' : 'subcurrent');
                    $xtpl->assign('MENU_SUB_HREF', $m);
                    $xtpl->assign('MENU_SUB_OP', $n);
                    $xtpl->assign('MENU_SUB_NAME', $_subtitle);
                    $xtpl->assign('MENU_CLASS', '');
                    if (!empty($_submenu_i)) {
                        $xtpl->assign('MENU_CLASS', ' class="dropdown"');
                        foreach ($_submenu_i as $sn => $sl) {
                            $xtpl->assign('CUR_SUB_OP', $sn);
                            $xtpl->assign('CUR_SUB_NAME', $sl);
                            $xtpl->parse('main.menu_loop.current.submenu.loop');
                        }
                        $xtpl->parse('main.menu_loop.current.submenu');
                    }
                    $xtpl->parse('main.menu_loop.current');
                }
            }
            $xtpl->parse('main.menu_loop');
        }
        // Notification icon
        if ($global_config['notification_active']) {
            $xtpl->parse('main.notification');
            $xtpl->parse('main.notification_js');
        }
    }
    if (!empty($select_options)) {
        $xtpl->assign('PLEASE_SELECT', $lang_global['please_select']);
        foreach ($select_options as $value => $link) {
            $xtpl->assign('SELECT_NAME', $link);
            $xtpl->assign('SELECT_VALUE', $value);
            $xtpl->parse('main.select_option.select_option_loop');
        }
        $xtpl->parse('main.select_option');
    } elseif (isset($site_mods[$module_name]['main_file']) and $site_mods[$module_name]['main_file']) {
        $xtpl->assign('NV_GO_CLIENTMOD', $lang_global['go_clientmod']);
        $xtpl->parse('main.site_mods');
    }
    if (!empty($array_url_instruction)) {
        foreach ($array_url_instruction as $key => $value) {
            if ($op == $key and filter_var($value, FILTER_VALIDATE_URL)) {
                $xtpl->assign('NV_INSTRUCTION', $lang_global['go_instrucion']);
                $xtpl->assign('NV_URL_INSTRUCTION', $value);
                $xtpl->parse('main.url_instruction');
                break;
            }
        }
    }
    /**
     * Breadcrumbs
     * Note: If active is true, the link will be dismiss
     * If empty $array_mod_title and $page_title, breadcrumbs do not display
     * By default, breadcrumbs is $page_title
     */
    if (empty($array_mod_title) and !empty($page_title)) {
        $array_mod_title = array(0 => array('title' => $page_title, 'link' => '', 'active' => true));
    }
    if (!empty($array_mod_title)) {
        foreach ($array_mod_title as $breadcrumbs) {
            $xtpl->assign('BREADCRUMBS', $breadcrumbs);
            if (!empty($breadcrumbs['active'])) {
                $xtpl->parse('main.breadcrumbs.loop.active');
            }
            if (!empty($breadcrumbs['link']) and empty($breadcrumbs['active'])) {
                $xtpl->parse('main.breadcrumbs.loop.linked');
            } else {
                $xtpl->parse('main.breadcrumbs.loop.text');
            }
            $xtpl->parse('main.breadcrumbs.loop');
        }
        $xtpl->parse('main.breadcrumbs');
    }
    $xtpl->assign('THEME_ERROR_INFO', nv_error_info());
    $xtpl->assign('MODULE_CONTENT', $contents);
    $xtpl->assign('NV_COPYRIGHT', sprintf($lang_global['copyright'], $global_config['site_name']));
    if (defined('CKEDITOR')) {
        $xtpl->parse('main.ckeditor');
    }
    if (defined('NV_IS_SPADMIN') and $admin_info['level'] == 1) {
        $xtpl->parse('main.memory_time_usage');
    }
    if ($client_info['browser']['key'] == 'explorer' and $client_info['browser']['version'] < 9) {
        $xtpl->parse('main.lt_ie9');
    }
    $xtpl->parse('main');
    $sitecontent = $xtpl->text('main');
    if (!empty($my_head)) {
        $sitecontent = preg_replace('/(<\\/head>)/i', $my_head . "\\1", $sitecontent, 1);
    }
    if (!empty($my_footer)) {
        $sitecontent = preg_replace('/(<\\/body>)/i', $my_footer . "\\1", $sitecontent, 1);
    }
    return $sitecontent;
}
/**
 * nv_html_site_js()
 *
 * @param bool $html
 * @return
 */
function nv_html_site_js($html = true)
{
    global $global_config, $module_info, $module_name, $module_file, $lang_global, $op, $client_info;
    $jsDef = "var nv_siteroot=\"" . NV_BASE_SITEURL . "\",nv_sitelang=\"" . NV_LANG_INTERFACE . "\",nv_name_variable=\"" . NV_NAME_VARIABLE . "\",nv_fc_variable=\"" . NV_OP_VARIABLE . "\",nv_lang_variable=\"" . NV_LANG_VARIABLE . "\",nv_module_name=\"" . $module_name . "\",nv_func_name=\"" . $op . "\",nv_is_user="******"NV_IS_USER") . ", nv_my_ofs=" . round(NV_SITE_TIMEZONE_OFFSET / 3600) . ",nv_my_abbr=\"" . nv_date("T", NV_CURRENTTIME) . "\",nv_cookie_prefix=\"" . $global_config['cookie_prefix'] . "\",nv_check_pass_mstime=" . (intval($global_config['user_check_pass_time']) - 62) * 1000 . ",nv_area_admin=0,theme_responsive=" . (int) ($global_config['current_theme_type'] == 'r');
    if (defined('NV_IS_DRAG_BLOCK')) {
        $jsDef .= ',drag_block=1,blockredirect="' . nv_base64_encode($client_info['selfurl']) . '",selfurl="' . $client_info['selfurl'] . '",block_delete_confirm="' . $lang_global['block_delete_confirm'] . '",block_outgroup_confirm="' . $lang_global['block_outgroup_confirm'] . '",blocks_saved="' . $lang_global['blocks_saved'] . '",blocks_saved_error="' . $lang_global['blocks_saved_error'] . '",post_url="' . NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=themes&' . NV_OP_VARIABLE . '=",func_id=' . $module_info['funcs'][$op]['func_id'] . ',module_theme="' . $global_config['module_theme'] . '"';
    }
    $jsDef .= ";";
    $return = array();
    $return[] = array('ext' => 0, 'content' => $jsDef);
    $return[] = array('ext' => 1, 'content' => NV_BASE_SITEURL . NV_ASSETS_DIR . "/js/jquery/jquery.min.js");
    $return[] = array('ext' => 1, 'content' => NV_BASE_SITEURL . NV_ASSETS_DIR . "/js/language/" . NV_LANG_INTERFACE . ".js");
    $return[] = array('ext' => 1, 'content' => NV_BASE_SITEURL . NV_ASSETS_DIR . "/js/global.js");
    if (defined('NV_IS_ADMIN')) {
        $return[] = array('ext' => 1, 'content' => NV_BASE_SITEURL . NV_ASSETS_DIR . "/js/admin.js");
    }
    // module js
    if (file_exists(NV_ROOTDIR . '/themes/' . $module_info['template'] . '/js/' . $module_file . '.js')) {
        $return[] = array('ext' => 1, 'content' => NV_BASE_SITEURL . 'themes/' . $module_info['template'] . '/js/' . $module_file . '.js');
    }
    if (defined('NV_EDITOR') and nv_function_exists('nv_add_editor_js')) {
        $editor_js = nv_add_editor_js();
        preg_match("/src\\s*=\\s*[\"']([^\"']+)[\"']/i", $editor_js, $matches);
        $return[] = array('ext' => 1, 'content' => $matches[1]);
    }
    if (defined('NV_IS_DRAG_BLOCK')) {
        $return[] = array('ext' => 1, 'content' => NV_BASE_SITEURL . NV_ASSETS_DIR . "/js/ui/jquery.ui.core.min.js");
        $return[] = array('ext' => 1, 'content' => NV_BASE_SITEURL . NV_ASSETS_DIR . "/js/ui/jquery.ui.sortable.min.js");
    }
    if (!$html) {
        return $return;
    }
    $res = "";
    foreach ($return as $js) {
        if ($js['ext'] == 1) {
            $res .= "<script src=\"" . $js['content'] . "\"></script>" . PHP_EOL;
        } else {
            $res .= "<script>" . PHP_EOL;
            $res .= $js['content'] . PHP_EOL;
            $res .= "</script>" . PHP_EOL;
        }
    }
    return $res;
}
Esempio n. 4
0
/**
 * nv_html_site_js()
 *
 * @return
 */
function nv_html_site_js()
{
    global $global_config, $module_info, $module_name, $module_file, $lang_global, $op, $client_info;
    $return = "<script type=\"text/javascript\" src=\"" . NV_BASE_SITEURL . "js/language/" . NV_LANG_INTERFACE . ".js\"></script>\n";
    $return .= "<script type=\"text/javascript\" src=\"" . NV_BASE_SITEURL . "js/jquery/jquery.min.js\"></script>\n";
    $return .= "<script type=\"text/javascript\">\n//<![CDATA[\n";
    $return .= "var nv_siteroot=\"" . NV_BASE_SITEURL . "\",nv_sitelang=\"" . NV_LANG_INTERFACE . "\",nv_name_variable=\"" . NV_NAME_VARIABLE . "\",nv_fc_variable=\"" . NV_OP_VARIABLE . "\",nv_lang_variable=\"" . NV_LANG_VARIABLE . "\",nv_module_name=\"" . $module_name . "\",nv_my_ofs=" . round(NV_SITE_TIMEZONE_OFFSET / 3600) . ",nv_my_abbr=\"" . nv_date("T", NV_CURRENTTIME) . "\",nv_cookie_prefix=\"" . $global_config['cookie_prefix'] . "\",nv_area_admin=0;\n";
    $return .= "//]]>\n</script>\n";
    $return .= "<script type=\"text/javascript\" src=\"" . NV_BASE_SITEURL . "js/global.js\"></script>\n";
    if (defined('NV_IS_ADMIN')) {
        $return .= "<script type=\"text/javascript\" src=\"" . NV_BASE_SITEURL . "js/admin.js\"></script>\n";
    }
    if (file_exists(NV_ROOTDIR . "/modules/" . $module_file . "/js/user.js")) {
        $return .= "<script type=\"text/javascript\" src=\"" . NV_BASE_SITEURL . "modules/" . $module_file . "/js/user.js\"></script>\n";
    }
    if (defined('NV_EDITOR') and nv_function_exists('nv_add_editor_js')) {
        $return .= nv_add_editor_js();
    }
    if (defined('NV_IS_DRAG_BLOCK')) {
        if (!defined('SHADOWBOX')) {
            $return .= "<link type=\"text/css\" rel=\"Stylesheet\" href=\"" . NV_BASE_SITEURL . "js/shadowbox/shadowbox.css\" />\n";
            $return .= "<script type=\"text/javascript\" src=\"" . NV_BASE_SITEURL . "js/shadowbox/shadowbox.js\"></script>\n";
            $return .= "<script type=\"text/javascript\">Shadowbox.init();</script>";
            define('SHADOWBOX', true);
        }
        $return .= "<script type=\"text/javascript\" src=\"" . NV_BASE_SITEURL . "js/ui/jquery.ui.core.min.js\"></script>\n";
        $return .= "<script type=\"text/javascript\" src=\"" . NV_BASE_SITEURL . "js/ui/jquery.ui.sortable.min.js\"></script>\n";
        $return .= '<script type="text/javascript">
        			//<![CDATA[
					var blockredirect = "' . nv_base64_encode($client_info['selfurl']) . '";
					$(function() {
						$("a.delblock").click(function(){
							var bid = $(this).attr("name");
							if (confirm("' . $lang_global['block_delete_confirm'] . '")){
								$.post("' . NV_BASE_ADMINURL . 'index.php?' . NV_NAME_VARIABLE . '=themes&' . NV_OP_VARIABLE . '=blocks_del", "bid="+bid, function(theResponse){
									alert(theResponse);
									window.location.href = "' . $client_info['selfurl'] . '";
								});
							}
						});

						$("a.outgroupblock").click(function(){
							var bid = $(this).attr("name");
							if (confirm("' . $lang_global['block_outgroup_confirm'] . '")){
								$.post("' . NV_BASE_ADMINURL . 'index.php?' . NV_NAME_VARIABLE . '=themes&' . NV_OP_VARIABLE . '=front_outgroup", "func_id=' . $module_info['funcs'][$op]['func_id'] . '&bid="+bid, function(theResponse){
									alert(theResponse);
								});
							}
						});

						$("a.block_content").click(function(){
							var bid = $(this).attr("name");
							var tag = $(this).attr("id");
							Shadowbox.open(
						      {
						         content : "<iframe src=\'' . NV_BASE_ADMINURL . 'index.php?' . NV_NAME_VARIABLE . '=themes&' . NV_OP_VARIABLE . '=block_content&selectthemes=' . $global_config['module_theme'] . '&tag="+tag+"&bid="+bid+"&blockredirect="+blockredirect+"\' style=\'width:780px;height:450px\'></iframe>",
						         player : "html",
						         height : 450,
						         width : 780
						      }
						      );
	            		});

	            		var func_id = ' . $module_info['funcs'][$op]['func_id'] . ';
	            		var post_order = false;
						$(".column").sortable({
							connectWith: \'.column\',
							opacity: 0.8,
							cursor: \'move\',
							receive: function(){
									post_order = true;
									var position = $(this).attr("id");
									var order = $(this).sortable("serialize");
									$.post("' . NV_BASE_ADMINURL . 'index.php?' . NV_NAME_VARIABLE . '=themes&' . NV_OP_VARIABLE . '=sort_order", order+"&position="+position+"&func_id="+func_id, function(theResponse){
										if(theResponse=="OK_"+func_id){
					    					$("div#toolbar>ul.info").html("<li><span style=\'color:#ff0000;padding-left:150px;font-weight:700;\'>' . $lang_global['blocks_saved'] . '</span></li>").fadeIn(1000);
										}
										else{
											alert("' . $lang_global['blocks_saved_error'] . '");
										}
									});
							},
							stop: function() {
								if(post_order == false){
									var order = $(this).sortable("serialize");
									$.post("' . NV_BASE_ADMINURL . 'index.php?' . NV_NAME_VARIABLE . '=themes&' . NV_OP_VARIABLE . '=sort_order", order+"&func_id="+func_id, function(theResponse){
										if(theResponse=="OK_"+func_id){
					    					$("div#toolbar>ul.info").html("<span style=\'color:#ff0000;padding-left:150px;font-weight:700;\'>' . $lang_global['blocks_saved'] . '</span>").fadeIn(1000);
										}
										else{
											alert("' . $lang_global['blocks_saved_error'] . '");
										}
									});
								}
							}
						});
						$(".column").disableSelection();
					});
					//]]>
					</script>';
    }
    return $return;
}
Esempio n. 5
0
function nv_admin_theme($contents)
{
    global $global_config, $lang_global, $admin_mods, $site_mods, $admin_menu_mods, $module_name, $module_file, $module_info, $admin_info, $db, $page_title, $submenu, $select_options, $op, $set_active_op, $array_lang_admin, $my_head;
    $dir_template = "";
    if (file_exists(NV_ROOTDIR . "/themes/" . $global_config['admin_theme'] . "/system/main.tpl")) {
        $dir_template = NV_ROOTDIR . "/themes/" . $global_config['admin_theme'] . "/system";
    } else {
        $dir_template = NV_ROOTDIR . "/themes/admin_default/system";
        $global_config['admin_theme'] = "default";
    }
    $global_config['site_name'] = empty($global_config['site_name']) ? NV_SERVER_NAME : $global_config['site_name'];
    $xtpl = new XTemplate("main.tpl", $dir_template);
    $xtpl->assign('NV_SITE_COPYRIGHT', "" . $global_config['site_name'] . " [" . $global_config['site_email'] . "] ");
    $xtpl->assign('NV_SITE_NAME', $global_config['site_name']);
    $xtpl->assign('NV_SITE_TITLE', "" . $global_config['site_name'] . " " . NV_TITLEBAR_DEFIS . " " . $lang_global['admin_page'] . " " . NV_TITLEBAR_DEFIS . " " . $module_info['custom_title'] . "");
    $xtpl->assign('NV_ADMIN_CHECK_PASS_TIME', NV_ADMIN_CHECK_PASS_TIME);
    $xtpl->assign('NV_BASE_SITEURL', NV_BASE_SITEURL);
    $xtpl->assign('NV_ADMINDIR', NV_ADMINDIR);
    $xtpl->assign('NV_BASE_ADMINURL', NV_BASE_ADMINURL);
    $xtpl->assign('MODULE_NAME', $module_name);
    $xtpl->assign('MODULE_FILE', $module_file);
    $xtpl->assign('NV_ADMIN_THEME', $global_config['admin_theme']);
    if (file_exists(NV_ROOTDIR . "/themes/" . $global_config['admin_theme'] . "/css/" . $module_file . ".css")) {
        $xtpl->parse('main.header.css_module');
    }
    $xtpl->assign('NV_LANG_VARIABLE', NV_LANG_VARIABLE);
    $xtpl->assign('NV_LANG_INTERFACE', NV_LANG_INTERFACE);
    $xtpl->assign('NV_NAME_VARIABLE', NV_NAME_VARIABLE);
    $xtpl->assign('NV_OP_VARIABLE', NV_OP_VARIABLE);
    $xtpl->assign('NV_LANG_VARIABLE', NV_LANG_VARIABLE);
    $xtpl->assign('NV_SITE_TIMEZONE_OFFSET', round(NV_SITE_TIMEZONE_OFFSET / 3600));
    $xtpl->assign('NV_CURRENTTIME', nv_date("T", NV_CURRENTTIME));
    $xtpl->assign('NV_COOKIE_PREFIX', $global_config['cookie_prefix']);
    if (file_exists(NV_ROOTDIR . "/js/admin_" . $module_file . ".js")) {
        $xtpl->assign('NV_JS_MODULE', NV_BASE_SITEURL . "js/admin_" . $module_file . ".js");
        $xtpl->parse('main.header.module_js');
    } elseif (file_exists(NV_ROOTDIR . "/modules/" . $module_file . "/js/admin.js")) {
        $xtpl->assign('NV_JS_MODULE', NV_BASE_SITEURL . "modules/" . $module_file . "/js/admin.js");
        $xtpl->parse('main.header.module_js');
    }
    if (defined('NV_EDITOR') and function_exists('nv_add_editor_js')) {
        $xtpl->assign('NV_ADD_EDITOR_JS', nv_add_editor_js());
        $xtpl->parse('main.header.nv_add_editor_js');
    }
    if (!empty($my_head)) {
        $xtpl->assign('NV_ADD_MY_HEAD', $my_head);
        $xtpl->parse('main.header.nv_add_my_head');
    }
    $xtpl->assign('NV_GO_CLIENTSECTOR', $lang_global['go_clientsector']);
    $lang_site = !empty($site_mods) ? NV_LANG_DATA : $global_config['site_lang'];
    $xtpl->assign('NV_GO_CLIENTSECTOR_URL', NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . $lang_site);
    $xtpl->assign('NV_LOGOUT', $lang_global['logout']);
    if (!empty($array_lang_admin)) {
        $xtpl->assign('NV_LANGDATA', $lang_global['langdata']);
        foreach ($array_lang_admin as $lang_i => $lang_name) {
            $xtpl->assign('SELECTED', $lang_i == NV_LANG_DATA ? " selected=\"selected\"" : "");
            $xtpl->assign('LANGVALUE', $lang_name);
            $xtpl->assign('LANGOP', NV_BASE_ADMINURL . "index.php?" . NV_LANG_VARIABLE . "=" . $lang_i);
            $xtpl->parse('main.header.langdata.option');
        }
        $xtpl->parse('main.header.langdata');
    }
    //Top_menu
    foreach ($admin_mods as $m => $v) {
        if (!empty($v['custom_title'])) {
            $xtpl->assign('TOP_MENU_CURRENT', $module_name == $m ? " class=\"current\"" : "");
            $xtpl->assign('TOP_MENU_HREF', $m);
            $xtpl->assign('TOP_MENU_NAME', $v['custom_title']);
            $xtpl->parse('main.header.top_menu.top_menu_loop');
        }
    }
    $xtpl->parse('main.header.top_menu');
    $xtpl->assign('NV_DIGCLOCK', nv_date("H:i T l, d/m/Y", NV_CURRENTTIME));
    if ($admin_info['current_login'] >= NV_CURRENTTIME - 60) {
        if (!empty($admin_info['last_login'])) {
            $temp = sprintf($lang_global['hello_admin1'], "<strong>" . $admin_info['username'] . "</strong>", date("H:i d/m/Y", $admin_info['last_login']), $admin_info['last_ip']);
            $xtpl->assign('HELLO_ADMIN1', $temp);
            $xtpl->parse('main.header.hello_admin');
        } else {
            $temp = sprintf($lang_global['hello_admin3'], "<strong>" . $admin_info['username'] . "</strong>");
            $xtpl->assign('HELLO_ADMIN3', $temp);
            $xtpl->parse('main.header.hello_admin3');
        }
    } else {
        $temp = sprintf($lang_global['hello_admin2'], "<strong>" . $admin_info['username'] . "</strong>", nv_convertfromSec(NV_CURRENTTIME - $admin_info['current_login']), $admin_info['current_ip']);
        $xtpl->assign('HELLO_ADMIN2', $temp);
        $xtpl->parse('main.header.hello_admin2');
    }
    $xtpl->parse('main.header');
    if (!empty($admin_menu_mods)) {
        //Vertical menu
        foreach ($admin_menu_mods as $m => $v) {
            $xtpl->assign('VERTICAL_MENU_CURRENT', $module_name == $m ? "class=\"current\"" : "");
            $xtpl->assign('VERTICAL_MENU_HREF', $m);
            $xtpl->assign('VERTICAL_MENU_NAME', $v);
            if ($m == $module_name and !empty($submenu)) {
                foreach ($submenu as $n => $l) {
                    $xtpl->assign('VERTICAL_MENU_SUB_CURRENT', (!empty($op) and $op == $n or !empty($set_active_op) and $set_active_op == $n) ? " class=\"sub_current\"" : " class=\"sub_normal\"");
                    $xtpl->assign('VERTICAL_MENU_SUB_HREF', $m);
                    $xtpl->assign('VERTICAL_MENU_SUB_HREF1', $n);
                    $xtpl->assign('VERTICAL_MENU_SUB_NAME', $l);
                    $xtpl->parse('main.vertical_menu.vertical_menu_loop.vertical_menu_sub_loop');
                }
            }
            $xtpl->parse('main.vertical_menu.vertical_menu_loop');
        }
    }
    $xtpl->parse('main.vertical_menu');
    if (!empty($select_options)) {
        $xtpl->assign('PLEASE_SELECT', $lang_global['please_select']);
        foreach ($select_options as $value => $link) {
            $xtpl->assign('SELECT_NAME', $link);
            $xtpl->assign('SELECT_VALUE', $value);
            $xtpl->parse('main.select_option.select_option_loop');
        }
        $xtpl->parse('main.select_option');
    } elseif (!isset($admin_mods[$module_name]) and isset($site_mods[$module_name])) {
        $xtpl->assign('NV_GO_CLIENTMOD', $lang_global['go_clientmod']);
        $xtpl->parse('main.site_mods');
    }
    if (!empty($page_title)) {
        $xtpl->assign('PAGE_TITLE', $page_title);
        $xtpl->parse('main.empty_page_title');
    }
    $xtpl->assign('THEME_ERROR_INFO', nv_error_info());
    $xtpl->assign('MODULE_CONTENT', $contents);
    $end_time = array_sum(explode(" ", microtime()));
    $total_time = substr($end_time - NV_START_TIME + $db->time, 0, 5);
    $xtpl->assign('NV_TOTAL_TIME', substr($end_time - NV_START_TIME + $db->time, 0, 5));
    if (defined("NV_IS_SPADMIN")) {
        $xtpl->assign('NV_SHOW_QUERIES', $lang_global['show_queries']);
    }
    $xtpl->assign('NV_DB_NUM_QUERIES', $lang_global['db_num_queries']);
    $xtpl->assign('COUNT_QUERY_STRS', count($db->query_strs));
    $xtpl->assign('NV_COPYRIGHT', sprintf($lang_global['copyright'], $global_config['site_name']));
    if (defined("NV_IS_SPADMIN")) {
        foreach ($db->query_strs as $key => $field) {
            $xtpl->assign('NV_SHOW_QUERIES_CLASS', $key % 2 ? " class=\"second\"" : "");
            $xtpl->assign('NV_FIELD1', $field[1] ? "<img alt=\"" . $lang_global['ok'] . "\" title=\"" . $lang_global['ok'] . "\" src=\"" . NV_BASE_SITEURL . "themes/" . $global_config['admin_theme'] . "/images/icons/good.png\" />" : "<img alt=\"" . $lang_global['fail'] . "\" title=\"" . $lang_global['fail'] . "\" src=\"" . NV_BASE_SITEURL . "themes/" . $global_config['admin_theme'] . "/images/icons/bad.png\" />");
            $xtpl->assign('NV_FIELD', $field[0]);
            $xtpl->parse('main.footer.nv_show_queries.nv_show_queries_loop');
        }
        $xtpl->parse('main.footer.nv_show_queries');
    }
    if (NV_LANG_INTERFACE == 'vi' and NV_LANG_DATA == 'vi') {
        $xtpl->parse('main.footer.nv_if_mudim');
    }
    $xtpl->assign('NV_GENPASS', nv_genpass());
    $xtpl->parse('main.footer');
    $xtpl->parse('main');
    $xtpl->out('main');
}
/**
 * nv_html_site_js()
 * 
 * @return
 */
function nv_html_site_js()
{
    global $global_config, $module_info, $module_name, $module_file, $lang_global, $op, $my_head, $client_info;
    $return = "";
    $return .= "<script type=\"text/javascript\" src=\"" . NV_BASE_SITEURL . "js/language/" . NV_LANG_INTERFACE . ".js\"></script>\n";
    $return .= "<script type=\"text/javascript\" src=\"" . NV_BASE_SITEURL . "js/jquery/jquery.min.js\"></script>\n";
    $return .= "<script type=\"text/javascript\">\n";
    $return .= "var nv_siteroot = '" . NV_BASE_SITEURL . "';\n";
    $return .= "var nv_sitelang = '" . NV_LANG_INTERFACE . "';\n";
    $return .= "var nv_name_variable = '" . NV_NAME_VARIABLE . "';\n";
    $return .= "var nv_fc_variable = '" . NV_OP_VARIABLE . "';\n";
    $return .= "var nv_lang_variable = '" . NV_LANG_VARIABLE . "';\n";
    $return .= "var nv_module_name = '" . $module_name . "';\n";
    $return .= "var nv_my_ofs = " . round(NV_SITE_TIMEZONE_OFFSET / 3600) . ";\n";
    $return .= "var nv_my_abbr = '" . nv_date("T", NV_CURRENTTIME) . "';\n";
    $return .= "var nv_cookie_prefix = '" . $global_config['cookie_prefix'] . "';\n";
    $return .= "var nv_area_admin = 0;\n";
    $return .= "</script>\n";
    $return .= "<script type=\"text/javascript\" src=\"" . NV_BASE_SITEURL . "js/global.js\"></script>\n";
    if (defined('NV_IS_ADMIN')) {
        $return .= "<script type=\"text/javascript\" src=\"" . NV_BASE_SITEURL . "js/admin.js\"></script>\n";
    }
    if (file_exists(NV_ROOTDIR . "/modules/" . $module_file . "/js/user.js")) {
        $return .= "<script type=\"text/javascript\" src=\"" . NV_BASE_SITEURL . "modules/" . $module_file . "/js/user.js\"></script>\n";
    }
    if (defined('NV_EDITOR') and function_exists('nv_add_editor_js')) {
        $return .= nv_add_editor_js();
    }
    if (!defined('SHADOWBOX')) {
        $my_head .= "<link rel=\"Stylesheet\" href=\"" . NV_BASE_SITEURL . "js/shadowbox/shadowbox.css\" />\n";
        $my_head .= "<script type=\"text/javascript\" src=\"" . NV_BASE_SITEURL . "js/shadowbox/shadowbox.js\"></script>\n";
        $my_head .= "<script type=\"text/javascript\">Shadowbox.init();</script>";
        define('SHADOWBOX', true);
    }
    if (!empty($my_head)) {
        $return .= $my_head;
    }
    if (defined('NV_IS_DRAG_BLOCK')) {
        $return .= "<div style='display:none' title='" . $lang_global['add_block'] . "' id='addblock'></div>\n";
        $return .= "<link type='text/css' href='" . NV_BASE_SITEURL . "js/ui/jquery.ui.all.css' rel='stylesheet' />\n";
        $return .= "<script type=\"text/javascript\" src=\"" . NV_BASE_SITEURL . "js/ui/jquery-ui-1.8.2.custom.js\"></script>\n";
        $return .= '<script type="text/javascript">
        			var blockredirect = "' . nv_base64_encode($client_info['selfurl']) . '";
					$(function() {				
					$("a.delblock").click(function(){
						var bid = $(this).attr("name");
						if (confirm("' . $lang_global['block_delete_confirm'] . '")){
							$.post("' . NV_BASE_ADMINURL . 'index.php?' . NV_NAME_VARIABLE . '=themes&' . NV_OP_VARIABLE . '=front_del", "bid="+bid+"&blockredirect="+blockredirect, function(theResponse){
								alert(theResponse);
								window.location.href = "' . $client_info['selfurl'] . '";
							});
						}
					});
					
					$("a.outgroupblock").click(function(){
						var bid = $(this).attr("name");
						if (confirm("' . $lang_global['block_outgroup_confirm'] . '")){
							$.post("' . NV_BASE_ADMINURL . 'index.php?' . NV_NAME_VARIABLE . '=themes&' . NV_OP_VARIABLE . '=front_outgroup", "bid="+bid+"&blockredirect="+blockredirect, function(theResponse){
								alert(theResponse);
							});
						}
					});
										
					$("a.editblock").click(function(){
						var bid = $(this).attr("name");
						$("div#addblock").html("<iframe src=\'' . NV_BASE_ADMINURL . 'index.php?' . NV_NAME_VARIABLE . '=themes&' . NV_OP_VARIABLE . '=front_add&selectthemes=' . $global_config['module_theme'] . '&bid="+bid+"&blockredirect="+blockredirect+"\' style=\'width:780px;height:400px\'></iframe>");
            			$("div#addblock").dialog("open");
						return false;
					});
					$("div#addblock").dialog({
						autoOpen: false,
						width: 800,
						modal: true,
						position: "top"
					});
					
					$("a.addblock").click(function(){
						var tag = $(this).attr("id");
						$("div#addblock").html("<iframe src=\'' . NV_BASE_ADMINURL . 'index.php?' . NV_NAME_VARIABLE . '=themes&' . NV_OP_VARIABLE . '=front_add&selectthemes=' . $global_config['module_theme'] . '&tag="+tag+"&blockredirect="+blockredirect+"\' style=\'width:780px;height:400px\'></iframe>");
            			$("div#addblock").dialog("open");
						return false;
            		});
					var position=new Array();
					var func_id = ' . $module_info['funcs'][$op]['func_id'] . ';
						$(".column").sortable({
							connectWith: \'.column\',
							opacity: 0.8, 
							cursor: \'move\',
							receive: function(){
									var target = $(this).attr("id");
									var order = $(this).sortable("serialize");
									$.post("' . NV_BASE_ADMINURL . 'index.php?' . NV_NAME_VARIABLE . '=themes&' . NV_OP_VARIABLE . '=sort_order", order+"&position="+target+"&func="+func_id, function(theResponse){
									if(theResponse=="OK_"+func_id){
				    					$("div#toolbar>ul.info>li").hide();
				    					$("div#toolbar>ul.info>li").html("<span style=\'color:red;padding-left:150px;font-weight:bold\'>' . $lang_global['blocks_saved'] . '</span>").fadeIn(1000);
									}
									else{
										alert("' . $lang_global['blocks_saved_error'] . '");
									}
									});	
							},
							stop: function() {
								var order = $(this).sortable("serialize");
								$.post("' . NV_BASE_ADMINURL . 'index.php?' . NV_NAME_VARIABLE . '=themes&' . NV_OP_VARIABLE . '=sort_order", order, function(theResponse){
									if(theResponse=="OK_0"){
				    					$("div#toolbar>ul.info>li").hide();
				    					$("div#toolbar>ul.info>li").html("<span style=\'color:red;padding-left:150px;font-weight:bold\'>' . $lang_global['blocks_saved'] . '</span>").fadeIn(1000);
									}
									else{
										alert("' . $lang_global['blocks_saved_error'] . '");
									}
								});
							}
						});	
						$(".column").disableSelection();
					});
					</script>';
    }
    return $return;
}