noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
menu.inc.php
Go to the documentation of this file.
00001 <?php
00002 
00003 /*
00004  *   This file is part of NOALYSS.
00005  *
00006  *   NOALYSS is free software; you can redistribute it and/or modify
00007  *   it under the terms of the GNU General Public License as published by
00008  *   the Free Software Foundation; either version 2 of the License, or
00009  *   (at your option) any later version.
00010  *
00011  *   NOALYSS is distributed in the hope that it will be useful,
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *   GNU General Public License for more details.
00015  *
00016  *   You should have received a copy of the GNU General Public License
00017  *   along with NOALYSS; if not, write to the Free Software
00018  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  */
00020 
00021 // Copyright Author Dany De Bontridder danydb@aevalys.eu
00022 
00023 /**\file
00024  *
00025  *
00026  * \brief Show the table menu and let you add your own
00027  *
00028  */
00029 if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
00030 require_once 'class_menu_ref.php';
00031 require_once 'class_sort_table.php';
00032 require_once 'class_extension.php';
00033 
00034 
00035 echo '<div class="content">';
00036 /**
00037  * if post save then we save a new one
00038  */
00039 if ( isset($_POST['save_plugin']))
00040 {
00041         extract($_POST);
00042         $plugin=new Extension($cn);
00043         $plugin->me_code=$me_code;
00044         $plugin->me_menu=$me_menu;
00045         $plugin->me_file=$me_file;
00046         $plugin->me_description=$me_description;
00047         $plugin->me_parameter='plugin_code='.$me_code;
00048         $plugin->insert_plugin();
00049 }
00050 /**
00051  * if post update then we update
00052  */
00053 if (isset($_POST['mod_plugin']))
00054 {
00055         extract ($_POST);
00056         $plugin=new Extension($cn);
00057         $plugin->me_code=$me_code;
00058         $plugin->me_menu=$me_menu;
00059         $plugin->me_file=$me_file;
00060         $plugin->me_description=$me_description;
00061         $plugin->me_parameter='plugin_code='.$me_code;
00062         if ( !isset ($delete_pl))
00063         {
00064                 $plugin->update_plugin();
00065         }
00066         else
00067         {
00068                 $plugin->remove_plugin();
00069         }
00070 }
00071 /**
00072  * if post save then we save a new one
00073  */
00074 if ( isset($_POST['create_menu'])|| isset($_POST['modify_menu']))
00075 {
00076         extract($_POST);
00077         $menu_ref=new Menu_Ref($cn);
00078         $menu_ref->me_code=$me_code;
00079         $menu_ref->me_menu=$me_menu;
00080         $menu_ref->me_file=$me_file;
00081         $menu_ref->me_description=$me_description;
00082         $menu_ref->me_parameter=$me_parameter;
00083         $menu_ref->me_url=$me_url;
00084         $menu_ref->me_javascript=$me_javascript;
00085         $menu_ref->me_type='ME';
00086         $check=$menu_ref->verify();
00087         if ($check == 0)
00088         {
00089                 if (isset($_POST['create_menu']))
00090                 {
00091                         $menu_ref->insert();
00092                 }
00093                 elseif (isset($_POST['modify_menu']))
00094                 {
00095                         if ($menu_ref->verify() == 0)
00096                                 $menu_ref->update();
00097                 }
00098         }
00099 }
00100 /**
00101  * if delete then delete
00102  */
00103 
00104 //////////////////////////////////////////////////////////////////////////////
00105 // Show the list of menu
00106 //////////////////////////////////////////////////////////////////////////////
00107 global $cn;
00108 
00109 $table=new Sort_Table();
00110 $url=$_SERVER['REQUEST_URI'];
00111 
00112 $table->add(_('Code'),$url,"order by me_code asc","order by me_code desc","codea","coded");
00113 $table->add(_('Menu'),$url,"order by me_menu asc","order by me_menu desc","menua","menud");
00114 $table->add(_('Description'),$url,"order by me_description asc","order by me_description desc","desa","desd");
00115 $table->add(_('Type'),$url,"order by me_type asc","order by me_type desc","ta","td");
00116 $table->add(_('Fichier'),$url,"order by me_file asc","order by me_file desc","fa","fd");
00117 $table->add(_('URL'),$url,"order by me_url asc","order by me_url desc","urla","urld");
00118 $table->add(_('Paramètre'),$url,"order by me_parametere asc","order by me_parameter desc","paa","pad");
00119 $table->add(_('Javascript'),$url,"order by me_javascript asc","order by me_javascript desc","jsa","jsd");
00120 
00121 $ord=(isset($_REQUEST['ord']))?$_REQUEST['ord']:'codea';
00122 
00123 $order=$table->get_sql_order($ord);
00124 
00125 
00126 
00127 $iselect=new ISelect('p_type');
00128 $iselect->value=array(
00129         array("value"=>'',"label"=>_("Tout")),
00130         array("value"=>'ME',"label"=>_("Menu")),
00131         array("value"=>'PR',"label"=>_("Impression")),
00132         array("value"=>'PL',"label"=>_("Extension / Plugin")),
00133         array("value"=>'SP',"label"=>_("Valeurs spéciales"))
00134         );
00135 $iselect->selected=(isset($_REQUEST['p_type']))?$_REQUEST['p_type']:'';
00136 $sql="";
00137 if ( $iselect->selected != '')
00138 {
00139         $sql="where me_type='".sql_string($_REQUEST['p_type'])."'  ";
00140 }
00141 $menu=new Menu_Ref_sql($cn);
00142 $ret=$menu->seek($sql.$order);
00143 ?>
00144 <fieldset><legend>Recherche</legend>
00145 <form method="GET">
00146         <?php echo $iselect->input()?>
00147         <?php echo HtmlInput::submit("search", _("Recherche"))?>
00148         <?php echo HtmlInput::request_to_hidden(array('ac','gDossier','ord'))?>
00149 </form>
00150      <?php echo _('Filtre'),HtmlInput::filter_table('menu_tb', '0,1,2,4', '1'); ?>
00151 </fieldset>
00152 <?php 
00153 $gDossier=Dossier::id();
00154 echo HtmlInput::button("Add_plugin", _("Ajout d'un plugin"), "onclick=add_plugin($gDossier)");
00155 echo HtmlInput::button("Add_menu", _("Ajout d'un menu"), "onclick=create_menu($gDossier)");
00156 
00157 echo '<table class="result" id="menu_tb">';
00158 echo '<tr>';
00159 echo '<th>'.$table->get_header(0).'</th>';
00160 echo '<th>'.$table->get_header(1).'</th>';
00161 echo '<th>'.$table->get_header(2).'</th>';
00162 echo '<th>'.$table->get_header(3).HtmlInput::infobulle(33).'</th>';
00163 echo '<th>'.$table->get_header(4).'</th>';
00164 echo '<th>'.$table->get_header(5).'</th>';
00165 echo '<th>'.$table->get_header(6).'</th>';
00166 echo '<th>'.$table->get_header(7).'</th>';
00167 echo '</tr>';
00168 
00169 for ($i = 0; $i < Database::num_row($ret); $i++)
00170 {
00171     $row = $menu->get_object($ret, $i);
00172     $js = $row->me_code;
00173     switch ($row->me_type)
00174     {
00175         case 'PL':
00176             $js = sprintf('<A class="line" href="javascript:void(0)"  onclick="mod_plugin(\'%s\',\'%s\')">%s</A>', $gDossier, $row->me_code, $row->me_code);
00177             break;
00178         case 'ME':
00179             $js = sprintf('<A class="line" href="javascript:void(0)"  onclick="modify_menu(\'%s\',\'%s\')">%s</A>', $gDossier, $row->me_code, $row->me_code);
00180             break;
00181     }
00182     $class = ( $i % 2 == 0) ? $class = ' class="odd"' : $class = ' class="even"';
00183     echo "<tr $class>";
00184     echo td($js);
00185     echo td(_($row->me_menu));
00186     echo td(h(_($row->me_description)));
00187     echo td(h($row->me_type));
00188     echo td(h($row->me_file));
00189     echo td(h($row->me_url));
00190     echo td(h($row->me_parameter));
00191     echo td(h($row->me_javascript));
00192     echo '</tr>';
00193 }
00194 echo '</table>';
00195 
00196 ?>
 All Data Structures Namespaces Files Functions Variables Enumerations