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         $plugin->insert_profile_module();
00050 }
00051 /**
00052  * if post update then we update
00053  */
00054 if (isset($_POST['mod_plugin']))
00055 {
00056         extract ($_POST);
00057         $plugin=new Extension($cn);
00058         $plugin->me_code=$me_code;
00059         $plugin->me_menu=$me_menu;
00060         $plugin->me_file=$me_file;
00061         $plugin->me_description=$me_description;
00062         $plugin->me_parameter='plugin_code='.$me_code;
00063         if ( !isset ($delete_pl))
00064         {
00065                 $plugin->update_plugin();
00066         }
00067         else
00068         {
00069                 $plugin->remove_plugin();
00070         }
00071 }
00072 /**
00073  * if post save then we save a new one
00074  */
00075 if ( isset($_POST['create_menu'])|| isset($_POST['modify_menu']))
00076 {
00077         extract($_POST);
00078         $menu_ref=new Menu_Ref($cn);
00079         $menu_ref->me_code=$me_code;
00080         $menu_ref->me_menu=$me_menu;
00081         $menu_ref->me_file=$me_file;
00082         $menu_ref->me_description=$me_description;
00083         $menu_ref->me_parameter=$me_parameter;
00084         $menu_ref->me_url=$me_url;
00085         $menu_ref->me_javascript=$me_javascript;
00086         $menu_ref->me_type='ME';
00087         $check=$menu_ref->verify();
00088         if ($check == 0)
00089         {
00090                 if (isset($_POST['create_menu']))
00091                 {
00092                         $menu_ref->insert();
00093                 }
00094                 elseif (isset($_POST['modify_menu']))
00095                 {
00096                         if ($menu_ref->verify() == 0)
00097                                 $menu_ref->update();
00098                 }
00099         }
00100 }
00101 /**
00102  * if delete then delete
00103  */
00104 
00105 //////////////////////////////////////////////////////////////////////////////
00106 // Show the list of menu
00107 //////////////////////////////////////////////////////////////////////////////
00108 global $cn;
00109 
00110 $table=new Sort_Table();
00111 $url=$_SERVER['REQUEST_URI'];
00112 
00113 $table->add(_('Code'),$url,"order by me_code asc","order by me_code desc","codea","coded");
00114 $table->add(_('Menu'),$url,"order by me_menu asc","order by me_menu desc","menua","menud");
00115 $table->add(_('Description'),$url,"order by me_description asc","order by me_description desc","desa","desd");
00116 $table->add(_('Type'),$url,"order by me_type asc","order by me_type desc","ta","td");
00117 $table->add(_('Fichier'),$url,"order by me_file asc","order by me_file desc","fa","fd");
00118 $table->add(_('URL'),$url,"order by me_url asc","order by me_url desc","urla","urld");
00119 $table->add(_('Paramètre'),$url,"order by me_parametere asc","order by me_parameter desc","paa","pad");
00120 $table->add(_('Javascript'),$url,"order by me_javascript asc","order by me_javascript desc","jsa","jsd");
00121 
00122 $ord=(isset($_REQUEST['ord']))?$_REQUEST['ord']:'codea';
00123 
00124 $order=$table->get_sql_order($ord);
00125 
00126 
00127 
00128 $iselect=new ISelect('p_type');
00129 $iselect->value=array(
00130         array("value"=>'',"label"=>_("Tout")),
00131         array("value"=>'ME',"label"=>_("Menu")),
00132         array("value"=>'PR',"label"=>_("Impression")),
00133         array("value"=>'PL',"label"=>_("Extension / Plugin")),
00134         array("value"=>'SP',"label"=>_("Valeurs spéciales"))
00135         );
00136 $iselect->selected=(isset($_REQUEST['p_type']))?$_REQUEST['p_type']:'';
00137 $sql="";
00138 if ( $iselect->selected != '')
00139 {
00140         $sql="where me_type='".sql_string($_REQUEST['p_type'])."'  ";
00141 }
00142 $menu=new Menu_Ref_sql($cn);
00143 $ret=$menu->seek($sql.$order);
00144 ?>
00145 <fieldset><legend>Recherche</legend>
00146 <form method="GET">
00147         <?php echo $iselect->input()?>
00148         <?php echo HtmlInput::submit("search", _("Recherche"))?>
00149         <?php echo HtmlInput::request_to_hidden(array('ac','gDossier','ord'))?>
00150 </form>
00151      <?php echo _('Filtre'),HtmlInput::filter_table('menu_tb', '0,1,2,4', '1'); ?>
00152 </fieldset>
00153 <?php 
00154 $gDossier=Dossier::id();
00155 echo HtmlInput::button("Add_plugin", _("Ajout d'un plugin"), "onclick=add_plugin($gDossier)");
00156 echo HtmlInput::button("Add_menu", _("Ajout d'un menu"), "onclick=create_menu($gDossier)");
00157 
00158 echo '<table class="result" id="menu_tb">';
00159 echo '<tr>';
00160 echo '<th>'.$table->get_header(0).'</th>';
00161 echo '<th>'.$table->get_header(1).'</th>';
00162 echo '<th>'.$table->get_header(2).'</th>';
00163 echo '<th>'.$table->get_header(3).HtmlInput::infobulle(33).'</th>';
00164 echo '<th>'.$table->get_header(4).'</th>';
00165 echo '<th>'.$table->get_header(5).'</th>';
00166 echo '<th>'.$table->get_header(6).'</th>';
00167 echo '<th>'.$table->get_header(7).'</th>';
00168 echo '</tr>';
00169 
00170 for ($i = 0; $i < Database::num_row($ret); $i++)
00171 {
00172     $row = $menu->get_object($ret, $i);
00173     $js = $row->me_code;
00174     switch ($row->me_type)
00175     {
00176         case 'PL':
00177             $js = sprintf('<A class="line" href="javascript:void(0)"  onclick="mod_plugin(\'%s\',\'%s\')">%s</A>', $gDossier, $row->me_code, $row->me_code);
00178             break;
00179         case 'ME':
00180             $js = sprintf('<A class="line" href="javascript:void(0)"  onclick="modify_menu(\'%s\',\'%s\')">%s</A>', $gDossier, $row->me_code, $row->me_code);
00181             break;
00182     }
00183     $class = ( $i % 2 == 0) ? $class = ' class="odd"' : $class = ' class="even"';
00184     echo "<tr $class>";
00185     echo td($js);
00186     echo td(_($row->me_menu));
00187     echo td(h(_($row->me_description)));
00188     echo td(h($row->me_type));
00189     echo td(h($row->me_file));
00190     echo td(h($row->me_url));
00191     echo td(h($row->me_parameter));
00192     echo td(h($row->me_javascript));
00193     echo '</tr>';
00194 }
00195 echo '</table>';
00196 
00197 ?>
 All Data Structures Namespaces Files Functions Variables Enumerations