<?php
/*
Copyright (C) 2008 by oscim   Project lossim  [ 15.09.2009, 09:17:59] @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
*/
/**
  Tableau de bord
*/
  error_reporting(E_ALL);


//! ACTION
 $action=(isset($post['action']) ) ?$post['action'] : 'list';

 $table=( (isset($_GET['table'])) && (!empty($_GET['table'])) )  ? $_GET['table'] : '../include/menu/menu.inc' ;

  //! obj
    $cstr->_add_class('db_rubrique',_BO_CLASS .'class.db_rubrique.php');
    $cstr->_add_class('db_menu',_BO_CLASS .'class.db_menu.php',$table);
    $cstr->_add_class('view_menu',_BO_CLASS .'class.view_menu.php');

//   $p="<p>%1\$s</p>";
//   $link_retour='<a  class="button exe" href="'._FILENAME_RUBRIQUES.'" alt="'.RETOUR.'" onclick=" montre(\'onload\');" >'.RETOUR.'</a>';
//
$url= ( (isset($_GET['menu']))AND(tep_not_null($_GET['menu'])) ) ? "&amp;menu=".$_GET['menu'] :  '' ;

$p="<p>%1\$s</p>";

$link_retour= '<a href="'._FILENAME_MENU.'?'.$url.'" title="'.RETOUR.'" >'.RETOUR.'</a>';
$link_annuler= '<a href="'._FILENAME_MENU.'?'.$url.'" title="'.ANNULER.'">'.ANNULER.'</a>';
$link_add='<a  class="button exe" href="'._FILENAME_MENU.'?action=add"  >'.ADD_ITEM_MENU.'</a>';


 switch($action){
  case 'up':
    $cstr->_call('view_menu','prepa_item',$post);

    redirect(_FILENAME_MENU);
  break;

  case 'add':
    $post=array( 'table'=>$table
                );
    $array[]['text']=$cstr->_call('view_menu','draw_form_edit',$post,'add');

    $array_right[]['text']='<p style="text-align:center"><a class="button exe" href="'._FILENAME_MENU.'">'.HISTORY_BACK.'</a></p>';
  break;
  case 'edit':

    $array[]['text']=$cstr->_call('view_menu','draw_form_edit',$post);

    $array_right=$cstr->_call('view_menu','draw_block_action');
    $array_right[]['text']='<p style="text-align:center"><a class="button exe" href="'._FILENAME_MENU.'">'.HISTORY_BACK.'</a></p>';
  break;


  default:
    $array[]['text']=$cstr->_call('view_menu','draw_list',$table);

    $array_right=$cstr->_call('view_menu','draw_block_action','');
    $array_right[]['text']='<p style="text-align:center"><a class="button exe" href="'._FILENAME_MENU.'?table='.$table.'&amp;action=add">'.ADD_ITEM_MENU.'</a></p>';
 }

 /**
  Colonne droite
 */
if ( (!empty($_GET)) AND (isset($_GET['conf'])) ){
  switch($_GET['conf']){
//         case 'new':
//           if (!isset($_POST['menu_key']))  print aff_menu_name_form($url,$table, true).$link_annuler;
//           else {
//             include (ADD_PATH_ADMIN.$table);
//             if ( (isset($menu_auto[$_POST['menu_key']]))OR (etat_files(ADD_PATH_ADMIN.'xml/'.$_POST['menu_key'].'.xml')) ) echo "<p class='erreur'>".KEY_MENU_EXISTS." </p><br /> \n ";
//             else print aff_menu_form($_POST['menu_key'],$url).$link_annuler;
//           }
//         break;
//         case 'new_menu':
//           if (!isset($_POST['menu_name'])) print aff_menu_name(true).$link_annuler;
//           else {
//             if (etat_files(ADD_PATH_ADMIN.'include/menu/'.$_POST['menu_name'].'.inc')) echo "<p class='erreur'>".MENU_EXISTS." </p><br /> \n ";
//             else print  create_file_menu($_POST['menu_name']);
//           }
//         break;
        case 'supp_menu':
          if (isset($_POST['r_menu_supp'])) print supp_menu($_POST['r_menu_supp']).$link_annuler;
          else supp_ss_menu_form($url, true);
        break;
        case 'edit':
//           if (tep_not_null($_POST['menu_key'])) print NewFct('edit_entree_menu',$_POST['menu_key'],$table,_FILENAME_MENU,"conf=up".$url);
        break;
//         case 'up':
//                 if (tep_not_null($_POST['menu_key'])) print NewFct('up_entree_menu',$_POST['menu_key'],$_POST,$table);
//         break;
//         case 'add':
//                 print NewFct('add_menu_primaire',$_POST['menu_key'],$_POST,$table);

        break;
        case 'supp':
        if (tep_not_null($_POST['menu_key'])){
                if (isset($_GET['confirm'])) {
                        $query ='DELETE FROM '.$table.' WHERE  id = \''.$_POST['menu_key'].'\'';
                        $e = sql ('',ADD_PATH_ADMIN.$table,'menu_auto',$query,'');
                        print $e;
                }
                else tep_page_confirm(_FILENAME_MENU,'conf=supp&amp;confirm=supp'.$url,CONFIRM_SUPP_MENU,$_POST,'');
        }
        break;
        case 'desa':
        if (tep_not_null($_POST['menu_key'])){
                if ( (isset($_GET['mode'])) AND ($_GET['mode']=='rub') ){ // des entete rub
                        if (isset($_GET['confirm'])) print on_off_entree_menu_entete_rub($_POST['menu_key'],$_POST['rub'],$table);
                // else tep_page_confirm('menu.php','conf=desa&amp;mode=rub&amp;confirm=supp'.$url,CONFIRM_DESA_MENU_RUB,$_POST,'');
                }else { if (isset($_GET['confirm'])) print NewFct('on_off_entree_menu',$_POST['menu_key'],$_POST['etat'],$table);
                // else tep_page_confirm('menu.php','conf=desa&amp;confirm=supp'.$url,CONFIRM_ACTIV_MENU_RUB,$_POST,'');
                }
        }
        break;
        default:

  }

  array_push($function_js_init, "init_centre();");
}

array_push($js_lib, "add_click_onload"); array_push($function_js_init, "add_click_onload('menu','');");





?>