<?php
/*
Copyright (C) 2008 by oscim   Project lossim  12.08.2009 17:29:18 oscim @oscim
// kate: replace-trailing-space-save true; space-indent on; indent-width 2; mixedindent off; indent-mode cstyle; word-wrap-marker-color #41C2A4
ENCODE UTF-8
*/

function _prefix_chemin(){
	if (@include(CHEMIN_DU_SITE."include/sys_config.php")) define('ADD_PATH_ADMIN', CHEMIN_DU_SITE);
	else define('ADD_PATH_ADMIN', "../");
	return ADD_PATH_ADMIN;
}

## Constrution du li
function _app_top_tep_ss_menu_li($titre,$img,$link,$niveau=5,$html='',$alt=''){
	$l= "<li><a href='%3\$s' title='%6\$s' %5\$s ><span>%4\$s</span><img src='%1\$s/img/%2\$s.png' /></a></li>\n";
	$s= (_USER_PERSO__GRP<=$niveau) ? sprintf($l,URL_ADMIN."template/".THEME_ADMIN,$img,$link,nett_acen($titre),$html,$alt) : '';
	if (tep_not_null($link)) return $s;
}
// destinée production nxtxt menbu
function txt_on_off($vars,$txt_on,$txt_off){
	$VAR=strtoupper($vars);
	$e=constant($VAR);
	if($e =='true') return $txt_off;
	else return $txt_on;
}
function menu_e($e,$_PX_icons){
  include('admin/template/color/inc/def_icon.inc');
  print "<div id='edition' >"
        ."<div id='m_edition'>\n"
        ."<ul id='menu_admin'>\n"
        ._app_top_tep_ss_menu_li(DECONNEXION,@$_PX_icons['610'],URL_ADMIN.'deconnexion.php')
        ._app_top_tep_ss_menu_li(RETOUR_MANAGER,@$_PX_icons['50'],URL_ADMIN.'admin.php')
        ._app_top_tep_ss_menu_li(MENU_CONTENU_AJOUTER_DOC,@$_PX_icons['140'],URL_ADMIN.'xmedia.php', 3)
        ._app_top_tep_ss_menu_li(txt_on_off('cache_public',MENU_ACTION_ON_CACHE,MENU_ACTION_OFF_CACHE),@$_PX_icons['450'],'#',1,'onclick="javascript:on_off_conf(\'cache_public\')"',MENU_ACTION_ON_OFF_CACHE_ALT)
        ._app_top_tep_ss_menu_li(MENU_ACTION_VIDE_CACHE,@$_PX_icons['460'],'#',2,'onclick="javascript:videcache()"')
        ." </ul>\n"
        ."<ul id='menu_info'>\n"
        ._app_top_tep_ss_menu_li(MODIFIER_CETTE_PAGE,@$_PX_icons['120'],URL_ADMIN.'modifier_un_fichier.php?file=../xml/'.$e.'.xml', 3)
        ._app_top_tep_ss_menu_li('Gabarit: '.NAME_GABARIT,@$_PX_icons['530'],URL_ADMIN.'edit_template.php?&file=../template/'.NOM_DU_THEME.'/'.NAME_GABARIT.'.php', 2);
        if ( (defined('DEVELOP'))AND(DEVELOP>0) ) {
                print _app_top_tep_ss_menu_li(MENU_DEVELOP_DEBUG,@$_PX_icons['910'],'#js',1,"onclick=\"{ upload_ajax('form_ajax_txt','include/inc/signal_bug.inc','signal_bug', '\'0\'', '".MENU_DEVELOP_DEBUG_TXT."' ); add_close('admin.php','close','parent.getElementById(\'form_ajax\').style=none;'); montre('form_ajax');  false}\"");
        }
  print " </ul>\n"
          ."</div>"

          ."<div id='edition_menuaff'><a id='menuaff' href='#up'> <img src=\"".URL_ADMIN."/template/".THEME_ADMIN."/img/".@$_PX_icons['51'].".png\" alt=\"menu\"/></a></div>"
          .'<div id="pied_menu"><div id="pied_menu_fd"></div></div>'
  ."</div>";
}

/**
* @author oscim - LossimTeam
* @note appel css menu admin
*/
function appel_css_e(){
  print "<link rel=\"stylesheet\" href=\"".URL_ADMIN."template/edit/edit.css\"  type=\"text/css\" media=\"all\" />\n";
}

function appel_js_page_e($dest,$function_js_init){
?>
<script src="ext/prototype/prototype.js" type="text/javascript"></script>
<script type='text/javascript'>
	function menu_up_down(){
		var menuaff= document.getElementById('menuaff');
		var edition= document.getElementById('edition');
		edition.style.width = '210px';
		menuaff.onclick = function(){
			if (menuaff.hash=='#up') {
				Element.hide('menu_admin');
				Element.hide('menu_info');
				edition.style.width = '20px';
				menuaff.innerHTML = "<?php print "<img src='".URL_ADMIN."template/".THEME_ADMIN."/img/".MMENU_IMG_DOWN.".png' alt='menu'/>"; ?>";
				menuaff.href="#down";
				return false;
			} else {
				Element.show('menu_admin');
				Element.show('menu_info');
				edition.style.width = '210px';
				menuaff.innerHTML = "<?php print "<img src='".URL_ADMIN."template/".THEME_ADMIN."/img/".MMENU_IMG_UP.".png' alt='menu'/>"; ?>";
				menuaff.href="#up";
				return false;
			}
		}
	}
	// EMPTY CACHE
	function videcache(){
		 var funct = "include/inc/advRmDir.inc";
		 var act = "advRmDir";
		 var failure     = function(t){execFailed(t, obj);}
		 var url = 'admin/appel_fct.php';
		 var pars = 'funct=' + funct +'&act=' + act ;
		 var myAjax = new Ajax.Request(url, {method:'post', postBody:pars, onSuccess:alert('Le cache est vide'), onFailure:failure});
	}

	function on_off_conf(lavar){
		 var funct = "include/inc/on_off_conf.inc";
		 var act = "on_off_conf";
		 var failure     = function(t){execFailed(t, obj);}
		 var url = 'admin/appel_fct.php';
		 var pars = 'funct=' + funct +'&act=' + act +'&vars=' + lavar ;
		 var myAjax = new Ajax.Request(url, {method:'post', postBody:pars, onSuccess:alert('ok !'), onFailure:failure});
	}
function upload_ajax(id,funct,act,param,sortie){
	 var url = 'admin/appel_fct.php';
	var pars = 'funct=' + funct +'&act=' + act + '&sortie=' + sortie + '&vars=' + param  ;
        var myAjax = new Ajax.Updater(id, url, {method:'post', postBody:pars, evalScripts:true,
				Success: function(){
				var ter = getElementById(id);
				ter.innerHTML = r.reponseText;
				lightwindowInit(false);
				},
				Failure:  function(){
				var ter = getElementById(id);
				ter.innerHTML = function(t){execFailed(t, obj);};
				},
				Complete:  function(){
				var ter = getElementById(id);
				ter.innerHTML = "En cours";
					}
				});
}
</script>
 <?php
      array_push($function_js_init, "menu_up_down();");
      return $function_js_init;
}

?>